Adding a "wait" kills my code

Xebarsis

New Member
Reaction score
7
In my game, every time you die you immediately respawn with a new unit. I want to make it so that if you're killed by the unit called "Dummy killer" that the new unit you respawn with will be invulnerable for a split second, and then have the invulnerability removed.

Adding invulnerable isn't the problem. Once I add a wait after it, nothing after the wait ever happens, so I can't remove the ability.

Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set NukePreventionGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Add Invulnerable (Neutral) to (Picked unit)
          • Wait 0.50 seconds
          • Unit - Remove Invulnerable (Neutral) from (Picked unit)
          • Unit Group - Remove (Picked unit) from NukePreventionGroup[(Player number of (Owner of (Dying unit)))]


I can't get any trigger to work past the 0.50 second wait, and I'm not sure why. Even if I make it a .01 second wait, everything past it never happens. Even if I add just a simple chat message after the wait, that doesn't even happen.

How do I get any code past the wait to work? The invulnerability MUST remain on the unit for at least a brief amount of time.
 

Romek

Super Moderator
Reaction score
964
You can't put waits in 'Pick every unit' loops.

Frankly, I can't think of any non-crappy, simply way to do what you want in GUI.
Oh, the joy. :p
 

Admit

New Member
Reaction score
25
Wait dosn't work in "pick every player loop".

Edit* You could try to pick it 2 times.. No idea if it works.

Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set Temp_UnitGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in Temp_UnitGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Invulnerable
      • Wait 0.50 seconds
      • Unit Group - Pick every unit in Temp_UnitGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Vulnerable
          • Unit Group - Remove (Picked unit) from Temp_UnitGroup[(Player number of (Owner of (Dying unit)))]
 

Xebarsis

New Member
Reaction score
7
Nope, NOTHING can possibly work after the wait.. but I tried what you posted just in case. Unfortunately it didn't work. :(
 

Admit

New Member
Reaction score
25
I tried my trigger and it did work.

You must have done something wrong.
 

Sartan

New Member
Reaction score
23
Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set Temp_UnitGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in Temp_UnitGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Add Divine Shield to (Picked unit)
          • Unit - Order (Picked unit) to Human Paladin - Activate Divine Shield

Trigger:
  • Untitled Trigger 001 Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Shield
    • Actions
      • Unit - Remove Divine Shield from (Triggering unit)

divine shield is a remade ability of the orginal with 1 lvl and no mana cost and no hero ability
 

ChaosWarlock

New Member
Reaction score
7
just a couple ideas... sorry no editor in front of me.

Could try running the wait in another trigger. Not sure if this will work inside a loop though.

Delete everything after "Unit - Add Invulnerable (Neutral) to (Picked unit)" and add this action instead.

Action: Run Trigger "Remove Invulnerable"

Make a new trigger named "Remove Invulnerable" that looks like the following:

Event:
Condition:
Action: Wait .5 sec
Remove Invulnerable from picked unit
Remove picked unit from unitgroup

----------------------------------------------------------------------

If that doesn't work you could try this.

have a dummy unit cast the invulnerability spell on each unit.
Add a buff to your Invulnerability spell
make the spell effect only last .5 sec

Delete everything after "Unit - Add Invulnerable (Neutral) to (Picked unit)" and add this action instead.

Create another trigger that looks like this:

Event: Every .1 sec of game time
Condition: Units in NukePreventionGroup greater than 0
Action: Unit group - pick every unit in NukePreventionGroup
Loop
If unit has buff Invulnerability = false
Then remove unit from unit group NukePreventionGroup
Else do nothing

the invulnerable spell will wear off on its own so all you have to do is remove the unit from the group.
 

Xebarsis

New Member
Reaction score
7
I tried my trigger and it did work.

You must have done something wrong.

Is this wrong?

Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set NukePreventionGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Invulnerable
          • Wait 0.50 seconds
          • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
            • Loop - Actions
              • Unit - Make (Picked unit) Vulnerable
              • Unit Group - Remove (Picked unit) from NukePreventionGroup[(Player number of (Owner of (Dying unit)))]
 

Sartan

New Member
Reaction score
23
Is this wrong?

Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set NukePreventionGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Invulnerable
          • Wait 0.50 seconds
          • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
            • Loop - Actions
              • Unit - Make (Picked unit) Vulnerable
              • Unit Group - Remove (Picked unit) from NukePreventionGroup[(Player number of (Owner of (Dying unit)))]

yes, thats wrong, you got your loops inside your first loop, but use my trigger 2 posts above
 

Xebarsis

New Member
Reaction score
7
Will the divine shield interfere if the unit that spawns already has a divine shield spell?

Edit: Okay, I fixed the above trigger to be exactly like Admit's and now it works. The respawned unit receives the invulnerability and it is removed immediately after the wait.

Thank you all for helping me with this trigger!
 

Admit

New Member
Reaction score
25
Is this wrong?

Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set NukePreventionGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Invulnerable
          • Wait 0.50 seconds
          • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
            • Loop - Actions
              • Unit - Make (Picked unit) Vulnerable
              • Unit Group - Remove (Picked unit) from NukePreventionGroup[(Player number of (Owner of (Dying unit)))]


Yes thats wrong you have the loop inside the loop, you should have 2 invidual loops.

Here is the trigger, just copy paste it.

Edit* Removed the map.
 

Xebarsis

New Member
Reaction score
7
Wow, unbelievable. It was working... and I changed nothing, but now it stopped working. I don't understand, I didn't mess with any triggers. Some reason now I can't even get the invulnerability to go ON the unit unless I add a wait at the very beginning. But even if I add a wait of .01 second, units that respawn immediately die again to the "dummy killer" so I have to have the invulnerability up right away. But.. how in the hell is the trigger not working anymore? Here's what I have:

Trigger:
  • Death Via Nuke
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Equal to Dummy Killer
    • Actions
      • Set NukePreventionGroup[(Player number of (Owner of (Dying unit)))] = (Units in (Playable map area) owned by (Owner of (Dying unit)))
      • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Invulnerable
      • Wait 0.50 seconds
      • Unit Group - Pick every unit in NukePreventionGroup[(Player number of (Owner of (Dying unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Make (Picked unit) Vulnerable
          • Unit Group - Remove (Picked unit) from NukePreventionGroup[(Player number of (Owner of (Dying unit)))]
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
I don't know, that trigger should work perfectly fine.
And by the way why are you removing all units in that group?
Clearing the group isnt clearing the leak if that's what you want to do. And maybe that's also what's messing with your trigger.

Btw (again) the array size of NukePreventionGroup in the variable editor must match the number of players.
 

Xebarsis

New Member
Reaction score
7
I array size is 12. Even if I disable every line of code in this trigger past the first loop, invulnerability does not get put on my units.
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Try adding the Invulnerability (Neutral Hostile) instead of Making the unit invulnerable?
 

ludnica

Long gone
Reaction score
61
Or make a rune item with the invulnerability (Potion of Divinity, or something) skill, then give the item to the hero.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top