Please or Register to create posts and topics.

How do you detect if all turrets have been killed/disabled

I'm trying to get an event triggered when all turrets in an area have been killed or disabled (the area could be a sub chamber in a larger chamber so other turrets may exist in other parts of the chamber). My first thought was to put a math counted in and increment it when each turret is killed/disabled. However, I've only found the following outputs from the turret:

- OnExplode
- OnRetire
- OnTipped

There is no OnKilled and therefore it does not detect when, for example, a turret is dropped into a pool of deadly goo. Can anybody suggest a way to create a trigger when the last turret of a group of turrets is killed/disabled (regardless of the way they have been killed/disabled). No doubt I'm missing a more obvious way of doing it (I hope!).

Thanks

(This isn't the most obvious way, but it'll be more robust.)

OnExplode and OnTipped will detect when they die that way. For goo, there's a trigger_multiple in there already to kill objects - you can just piggyback off of that. I suggest using the user in/outputs to make sure a turret can't be counted as dead twice (if you knock it over, then drop into goo that would count.)

On every turret, add an OnUser4 output to Add 1 to your math_counter. Set it to trigger once only. The OnExplode and OnTipped outputs should FireUser4 on "!self" (special targetname). The goo trigger should also FireUser4 on "!activator". Delay the other outputs on the trigger (by 0.1s or so) to ensure the turrets aren't deleted before they finish their outputting.

My stuff:
[spoiler]- BEE2 Addons | (BEE2)
- Hammer Addons
Maps:
- Crushed Gel
- Gel is Not Always Helpful[/spoiler]
TeamSpen210 wrote:
(This isn't the most obvious way, but it'll be more robust.)

OnExplode and OnTipped will detect when they die that way. For goo, there's a trigger_multiple in there already to kill objects - you can just piggyback off of that. I suggest using the user in/outputs to make sure a turret can't be counted as dead twice (if you knock it over, then drop into goo that would count.)

On every turret, add an OnUser4 output to Add 1 to your math_counter. Set it to trigger once only. The OnExplode and OnTipped outputs should FireUser4 on "!self" (special targetname). The goo trigger should also FireUser4 on "!activator". Delay the other outputs on the trigger (by 0.1s or so) to ensure the turrets aren't deleted before they finish their outputting.

Thanks for the reply but... wooh :shock: ... this is a bit (aka, a lot) beyond my level of knowledge (I should have mentioned that I'm not quite a newbie - but I'm not far off!). I haven't explored the user in/outs and I don't understand the piggy-backing thingy. I also don't follow the "trigger_multiple in there already to kill objects" and "special targetname" bits (basically, you lost me after the first sentance! :oops:).

I think I'm going to need a step by step guide but I'm prepared to do some homework and preparation first. To start with, and cover some of the basics, can you point me at any tutorials that will explain the use of user in/outs and then I'll try and progress to the next stage.

Try this:

Step 1: Count the amount of turrets in your chamber. There is no way to detect whether or not there are any surviving turrets, you will have to have the enities count the turrets that are killed and see if it matches up with your specified total.

Step 2: Create a Math_Counter entity. In the Class Info tab, Give it a name, and change the "Maximum Legal Value" to your total number of turrets.

Step 3: Next to each turret, create a logic_relay. The logic relay will be useful for making sure that one turret's death will not count for multiple deaths. In the output's tab on each of these logic_relays, give it the output: "OnTrigger >> <name of math_counter> >> Add >> 1". Be sure to check the box that says "Fire Once Only". Also, be sure to give each of these logic_relays a different name.

Step 4: On each turret, create an output for each way the turret can die that "Trigger"s the nearby logic_relay you made in step 3.

Step 5: On the Math_counter you made in Step 2, Give it the output: OnHitMax >> <Whatever you want killing all the turrets to do>. Once the math counter hits the number you assigned to the Maximum Legal Value property, it will trigger any outputs started by OnHitMax.

I hope this helps.

Thanks, Goldenknighttim. I think I understand the process for the math counter, the problem I'm got is how to get a trigger from the turret when it's killed as you mention in your step 4:

Goldenknighttim wrote:
Step 4: On each turret, create an output for each way the turret can die that "Trigger"s the nearby logic_relay you made in step 3.

There does not appear to be an output for OnKilled (there's only outputs for OnExplode, OnRetire and OnTipped).

There is no output for the turret being killed, but you can use the OnExplede and OnTipped both at the same time. Don't use OnRetire though, because that is triggered when the turret stops trying to shoot you. If you have Fizzlers or goo in your chamber, you may want to add triggers_multiples around each of these objects. Then use the Logic_coop_manager with both the turret and the triggers. For example, with a fizzler, When the turret goes through the trigger over the fizzler, 'b' is set to true. Also OnPhysGunPickup sets 'a' to true while OnPhysGunDrop set's 'a' to false(preferably on a delay in case the player throws the turret). When all are set to true on the logic_coop_manager, then send the trigger output to the logic_relay.

Thanks Goldenknighttim & TeamSpen210 - I now understand that I have to use both an output from the turret and a trigger multiple for when turret is dropped into goo (and that I can use the existing trigger multiple as used in the goo to kill the turret):

TeamSpen210 wrote:
...you can just piggyback off of that. I suggest using the user in/outputs to make sure a turret can't be counted as dead twice (if you knock it over, then drop into goo that would count.)

But the bit I don't understand is the function of the user in/outs and how you set them up to be able to detect when a previously tilted turret is dropped onto the trigger. I've looked at the page in the Valve Developer Community:
https://developer.valvesoftware.com/wiki/User_Inputs_and_Outputs
but I'm having a bit of difficulty following it (only half life examples). Any pointers to other articles or tutorials would be useful

Basically, whenever you trigger the FireUser1 input, the OnUser1 input triggers immediately. It's similar to four logic_relays, except a bit more limited. The reason I was suggesting using them is because of the Only Once checkbox. This basically deletes the output from the entity after it triggers once. Therefore the first time any one turret gets the FireUser4 input, it will trigger the OnUser4 output to count it as dead. The output then deletes itself, so if you tip over a turret, then burn it it won't trigger the add input twice. This also has the bonus feature of discriminating between different objects. Cubes are also destroyed by the trigger_multiple, and would trigger the onStartTouch output too. Since you won't add an OnUser4 output to them, nothing will happen when it is triggered.

The reason I'm suggesting using FireUser4 not 1 is that cube droppers use the first input to only fizzle the cube fhat's not sitting inside the dropper whenever the dropper dispenses a new cube. When a cube falls outside the dropper logic adds an output with the AddOutput command (another very powerful command) to make FireUser1 dissolve the cube. The one inside the dropper has't had this happen yet, so it won't dissolve.

My stuff:
[spoiler]- BEE2 Addons | (BEE2)
- Hammer Addons
Maps:
- Crushed Gel
- Gel is Not Always Helpful[/spoiler]