tracking the state of an entity to use as an output

UltraProAnti

Newbie
Joined
Nov 22, 2004
Messages
509
Reaction score
0
OK, this might be tricky to explain.

You know that collapsing tower prefab in Hammer - the one where you blow up the wood parts and the metal parts topple over and the npc dies? What I'm trying to do is have a structure like that as the extension of a solid (non-breakable), and an npc up there who dies when the tower collapses while he's on it, but doesn't when he's standing on the solid unbreakable bit.

Now the solution to this isn't as obvious as you may think. In order for the npc to die 'properly', you need a logic_relay with a SetHealth output override parameter set to 0 (this is to guarantee the npc dies and becomes a ragdoll so the effect looks right - otherwise it just falls to the ground on to it's feet). However the SetHealth 0 output should only fire

IF the npc is standing on the platform when it blows up, and
IF the platform blows up

I've tried using a math_counter, with a max value of 2, and tried to output Add values corresponding to the two IF conditions (each with a value of 1, i.e. 1+1=2, where 2 is the max value which triggers the SetHealth 0 output) - but this doesn't seem to work.

Thing is, the explosion of the platform is an EVENT, which happens once, but whether or not the npc is on the solid or breakable bits is a STATE, which changes back and forth as the npc wanders from solid to breakable, so:

if explosion + npc on solid then do not kill npc
if explosion + npc on breakable then kill npc
if no explosion + npc on solid or on breakable then do not kill npc

Any suggestions about how to do this?
 
Easy way: replace the logic_relay/SetHealth 0 with a trigger_hurt brush covering the places where the NPC can stand on top of the tower. Set the damage to a high value (>100). When the tower collapses, fire the trigger_hurt. If the NPC isn't standing within the trigger_hurt zone, it won't die.
This way has the added benefit that you can make it work with multiple NPCs on the tower without doing anything extra.

Harder way: place a trigger_multiple over the top of the tower. Filter it to the NPC (using filter_activator_class or filter_activator_name) and make sure the trigger's spawnflags are set so that it's activated by NPCs.

Add outputs to it:
OnStartTouch : KillRelay : Enable
OnEndTouch: KillRelay: Disable

Where KillRelay is the name of the logic_relay that does the SetHealth 0.

Thus whenever the NPC is inside the trigger_multiple, the relay is enabled, and will kill the NPC if the tower breaks. When it leaves the trigger_multiple, the relay is disabled, and so won't forward the SetHealth input.
 
Your easy way sounds perfect. LOL I can't believe I didn't think of that, since now you post it it seems so obvious.

The second way would work but with 2 logic_relays. ATM I have one with SetHealth 0 and also EnableMotion for the physboxes that make up the platform. I'd need to separate these outputs across relays otherwise if the platform broke while the npc wasn't on it - i.e. it was temporarily disabled - the various physboxes would stay suspended, which could look silly. More complicated, but I'll keep it in mind.

Thx :smoking:
 
One additional thing: the trigger_hurt brush works fine but I also added a second output to the trigger from the logic_relay which disabled the trigger_hurt after a delay of 0.50. Without this, a wandering npc can touch the trigger at the edge after the platform has collapsed.

One other thing: the npc gets flung through the air a bit when the trigger_hurt goes off. I've tried various damage types (including 'fall') and it doesn't seem to make any difference. Hmm.

Just for information purposes.
 
Back
Top