Logic random outputs: Difference between revisions
Jump to navigation
Jump to search

Bug:
[other games?] The numbering of the KeyValues and outputs does not match: In-game, the game expects the KeyValues
Example:When receiving the
Bug:
Instead, the output
(proof before i get reverted: https://cdn.discordapp.com/attachments/451068614817349634/693148132753801226/unknown.png) |
(Bug in CS:GO.) |
||
Line 1: | Line 1: | ||
{{lang|logic_random_outputs}} | |||
{{toc-right}} | |||
{{base point|logic_random_outputs|since=Alien Swarm}} It randomly fires one of up to eight separate outputs. Use [[logic_case]] in older engine branches or if you need twice as many outputs. | {{base point|logic_random_outputs|since=Alien Swarm|sprite=1}} It randomly fires one of up to eight separate outputs. Use [[logic_case]] in older engine branches or if you need twice as many outputs. | ||
{{clr|left}} | |||
{{bug|{{csgo}}{{inline note|name=other games?}} The numbering of the KeyValues and outputs does not match: In-game, the game expects the KeyValues <code>OnTriggerChance0-7</code> (and not 1-8), mapping to the outputs <code>OnTrigger1-8</code>.<sup>[https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/server/logic_random_outputs.cpp#L70 code]</sup> This means that the KeyValue <code>OnTriggerChance8</code> doesn't exist and that the output <code>OnTrigger1</code> can only be fired if the KeyValue <code>OnTriggerChance0</code> is given (and > 0), which however is {{!fgd}}. See [[#FGD Code|below]] for a fix.}} | |||
{{Example|When receiving the <code>Trigger</code> input while <code>OnTriggerChance1</code> equals 0.25, this entity will fire its <code>OnTrigger1</code> output with a probability of 25 %. {{bug|{{csgo}} Instead, the output <code>OnTrigger2</code> is fired with 25 %.}}}} | |||
{{clr}} | |||
==Keyvalues== | ==Keyvalues== | ||
{{KV|OnTrigger1 Chance|to=OnTrigger8 Chance|float|Chance (from 0 to 1) of the OnTrigger1-8 output firing when this entity is triggered. | {{KV|OnTrigger1 Chance|to=OnTrigger8 Chance|intn=OnTriggerChance1|intn2=OnTriggerChance8|float|Chance (from 0 to 1) of the OnTrigger1-8 output firing when this entity is triggered.}} | ||
{{KV EnableDisable}} | {{KV EnableDisable}} | ||
{{KV BaseEntity}} | |||
==Flags== | ==Flags== | ||
{{fl|1|Only trigger once}} | |||
{{fl|2|Allow fast retrigger}} | |||
==Inputs== | ==Inputs== | ||
Line 18: | Line 21: | ||
{{IO|Toggle|Toggle this entity between enabled and disabled.}} | {{IO|Toggle|Toggle this entity between enabled and disabled.}} | ||
{{IO|CancelPending|Cancel any events fired by this entity that are currently pending in the I/O event queue.}} | {{IO|CancelPending|Cancel any events fired by this entity that are currently pending in the I/O event queue.}} | ||
{{I EnableDisable}} | {{I EnableDisable}} | ||
{{I BaseEntity}} | |||
==Outputs== | ==Outputs== | ||
{{IO|OnSpawn|Fired when this entity is spawned. If this entity is set to only trigger once, it will delete itself after firing this output.}} | {{IO|OnSpawn|Fired when this entity is spawned. If this entity is set to only trigger once, it will delete itself after firing this output.}} | ||
{{IO|OnTrigger1|to=OnTrigger8|This output has a chance to fire when the entity is triggered.}} | {{IO|OnTrigger1|to=OnTrigger8|This output has a chance to fire when the entity is triggered.}} | ||
{{O | {{O BaseEntity}} | ||
==[[FGD]] Code== | |||
{{csgo}}{{inline note|name=other games?}} This code belongs to [[base.fgd]]. In the highlighted lines, the index of the KeyValue's name was decreased by 1 each but not their display text, so that with this fix, the numbering of the KeyValues and outputs will match in [[Hammer]] as long as [[SmartEdit]] is turned on. | |||
<syntaxhighlight lang=cpp highlight=9-16> | |||
@PointClass base(Targetname, EnableDisable) iconsprite("editor/logic_random_outputs.vmt") = logic_random_outputs : | |||
"A message forwarder. Fires up to eight separate outputs, each with a different chance of firing." | |||
[ | |||
spawnflags(flags) = | |||
[ | |||
1: "Only trigger once" : 0 | |||
2: "Allow fast retrigger" : 0 | |||
] | |||
OnTriggerChance0(float) : "OnTrigger1 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger1 output firing when this entity is triggered." | |||
OnTriggerChance1(float) : "OnTrigger2 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger2 output firing when this entity is triggered." | |||
OnTriggerChance2(float) : "OnTrigger3 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger3 output firing when this entity is triggered." | |||
OnTriggerChance3(float) : "OnTrigger4 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger4 output firing when this entity is triggered." | |||
OnTriggerChance4(float) : "OnTrigger5 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger5 output firing when this entity is triggered." | |||
OnTriggerChance5(float) : "OnTrigger6 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger6 output firing when this entity is triggered." | |||
OnTriggerChance6(float) : "OnTrigger7 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger7 output firing when this entity is triggered." | |||
OnTriggerChance7(float) : "OnTrigger8 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger8 output firing when this entity is triggered." | |||
// Inputs | |||
input Trigger(void) : "Trigger this entity, causing its OnTrigger outputs to fire if it is enabled." | |||
input Toggle(void) : "Toggle this entity between enabled and disabled." | |||
input CancelPending(void) : "Cancel any events fired by this entity that are currently pending in the I/O event queue." | |||
// Outputs | |||
output OnSpawn(void) : "Fired when this entity is spawned. If this entity is set to only trigger once, it will "+ | |||
"delete itself after firing this output." | |||
output OnTrigger1(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger2(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger3(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger4(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger5(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger6(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger7(void) : "This output has a chance to fire when the entity is triggered." | |||
output OnTrigger8(void) : "This output has a chance to fire when the entity is triggered." | |||
] | |||
</syntaxhighlight> |
Revision as of 02:31, 12 March 2022


Template:Base point It randomly fires one of up to eight separate outputs. Use logic_case in older engine branches or if you need twice as many outputs.


OnTriggerChance0-7
(and not 1-8), mapping to the outputs OnTrigger1-8
.code This means that the KeyValue OnTriggerChance8
doesn't exist and that the output OnTrigger1
can only be fired if the KeyValue OnTriggerChance0
is given (and > 0), which however is !FGD. See below for a fix. [todo tested in ?]
Trigger
input while OnTriggerChance1
equals 0.25, this entity will fire its OnTrigger1
output with a probability of 25 %. 

OnTrigger2
is fired with 25 %. [todo tested in ?]Keyvalues
- OnTrigger1 Chance (OnTriggerChance1) to OnTrigger8 Chance (OnTriggerChance8) <float>
- Chance (from 0 to 1) of the OnTrigger1-8 output firing when this entity is triggered.
- Start Disabled (StartDisabled) <boolean>
- Stay dormant until activated (with the
Enable
input).
Flags
- Only trigger once : [1]
- Allow fast retrigger : [2]
Inputs
- Trigger
- Trigger this entity, causing its OnTrigger outputs to fire if it is enabled.
- Toggle
- Toggle this entity between enabled and disabled.
- CancelPending
- Cancel any events fired by this entity that are currently pending in the I/O event queue.
EnableDisable:
- Enable / Disable
- Enable/disable this entity from performing its task. It might also disappear from view.
Outputs
- OnSpawn
- Fired when this entity is spawned. If this entity is set to only trigger once, it will delete itself after firing this output.
- OnTrigger1 to OnTrigger8
- This output has a chance to fire when the entity is triggered.
FGD Code
[other games?] This code belongs to base.fgd. In the highlighted lines, the index of the KeyValue's name was decreased by 1 each but not their display text, so that with this fix, the numbering of the KeyValues and outputs will match in Hammer as long as SmartEdit is turned on.
@PointClass base(Targetname, EnableDisable) iconsprite("editor/logic_random_outputs.vmt") = logic_random_outputs :
"A message forwarder. Fires up to eight separate outputs, each with a different chance of firing."
[
spawnflags(flags) =
[
1: "Only trigger once" : 0
2: "Allow fast retrigger" : 0
]
OnTriggerChance0(float) : "OnTrigger1 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger1 output firing when this entity is triggered."
OnTriggerChance1(float) : "OnTrigger2 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger2 output firing when this entity is triggered."
OnTriggerChance2(float) : "OnTrigger3 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger3 output firing when this entity is triggered."
OnTriggerChance3(float) : "OnTrigger4 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger4 output firing when this entity is triggered."
OnTriggerChance4(float) : "OnTrigger5 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger5 output firing when this entity is triggered."
OnTriggerChance5(float) : "OnTrigger6 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger6 output firing when this entity is triggered."
OnTriggerChance6(float) : "OnTrigger7 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger7 output firing when this entity is triggered."
OnTriggerChance7(float) : "OnTrigger8 Chance" : "1.0" : "Chance (from 0 to 1) of the OnTrigger8 output firing when this entity is triggered."
// Inputs
input Trigger(void) : "Trigger this entity, causing its OnTrigger outputs to fire if it is enabled."
input Toggle(void) : "Toggle this entity between enabled and disabled."
input CancelPending(void) : "Cancel any events fired by this entity that are currently pending in the I/O event queue."
// Outputs
output OnSpawn(void) : "Fired when this entity is spawned. If this entity is set to only trigger once, it will "+
"delete itself after firing this output."
output OnTrigger1(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger2(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger3(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger4(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger5(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger6(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger7(void) : "This output has a chance to fire when the entity is triggered."
output OnTrigger8(void) : "This output has a chance to fire when the entity is triggered."
]