Please or Register to create posts and topics.

Multiple box respawning

I recently ran into a little problem relating to respawning 2 boxes from the same spawn point (a standard box dropper). A kill trigger in an acid pool would destroy a box and trigger a respawn but if multiple boxes were killed withing a second or so of each other bad things would happen, like boxes stuck in the dropper, only one box dropping out, no boxes dropping out etc..

After fooling around with various fixes, the best I could come up was this:

The trigger kills the box and sends a 'test' to a logic_branch.

The logic_branch triggers a logic_relay (relay#1) if false and a second relay (#2) if true. Both logic relays do the same thing; set the logic_branch to true, run the spawn/animation sequence and then set the logic_branch back to false. The only difference between the two are timing; one takes 2 seconds and the other 4.

This can wind up with a couple of boxes in the 'hopper' but I haven't been able to break it (eg, send 2 boxes into the acid pool and wind up with one or zero boxes coming out of the dropper).

These are the actual details:

trigger_multiple
- 0 second delay
- Flags: physics objects

Output:
OnStartTouch !activator kill
OnStartTouch dropper_branch Test

logic_branch (dropper_branch)
Output:
OnFalse dropper_logic Trigger
OnTrue dropper_logic2 Trigger

logic_relay (dropper_logic)
Output:
OnTrigger dropper_branch SetValue 1
OnTrigger dropper_cover SetAnimation open
OnTrigger dropper_branch SetValue 0 (2 seconds)
OnTrigger dropper_cover SetAnimation close (2 seconds)
OnTrigger dropper_maker ForceSpawn (2 seconds) (this is the env_entity_maker)

logic_relay2 (dropper_logic)
Output:
OnTrigger dropper_branch SetValue 1
OnTrigger dropper_cover SetAnimation open (3 seconds) - drops the box
OnTrigger dropper_branch SetValue 0 (4 seconds) - extra second to clear things up before allowing the regular spawn to run
OnTrigger dropper_cover SetAnimation close (4 seconds)
OnTrigger dropper_maker ForceSpawn (4 seconds)

It should be noted that a logic_auto runs a ForceSpawn at the beginning of the level, so the entire sequence starts with a box in the hopper.

Is there a better method of doing this? I'm guessing that there's probably an exact sequence of timing that could break everything. The box dropper is right by the hazard so I was able to chuck boxes in (singly and doubly) at various intervals. Tossing two boxes in at the same time--which is what I fear the most--works like a charm.

I didn't read but, my guess is that you should decrement a counter each time you destroy a cube, and increment it each time you spawn one. This counter could take its values between 0 and 2, and you should use a logic_timer to increment its value one time per 1 to 3 seconds.
It should look like this, although it's a bit hard to write this kind of things without having access to Hammer.

Code: Select all
TRIGGER_MULTIPLE (the water, with filter to catch boxes only)

My output named : OnTrigger
Targets entities named : !activator
Via this input : Break

Code: Select all
BOXES

My output named : OnBreak/OnOutOfWorld
Targets entities named : math_counter
Via this input : Substract
With a parameter override of : 1

Code: Select all
MATH_COUNTER

My output named : OutValue
Targets entities named : logic_compare
Via this input : SetValueCompare

Code: Select all
LOGIC_COMPARE (compare value = 2)

My output named : OnLessThan
Targets entities named : logic_timer
Via this input : Enable

My output named : OnEqualTo
Targets entities named : logic_timer
Via this input : Disable

Code: Select all
LOGIC_TIMER (with repetition delay to 1 or 2)

My output named : OnTimer
Targets entities named : env_entity_maker
Via this input : ForceSpawn

Code: Select all
ENV_ENTITY_MAKER

My output named : OnEntitySpawned
Targets entities named : math_counter
Via this input : Add
With a parameter override of : 1

That makes total sense and was exactly what I was looking for. Very elegant, thanks.

Keep us informed of your progress.

You'll get the level when it's done. :D

Unfortunately that will probably be awhile. I don't have the time I'd like to map and learn.