• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Respawn system

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2018
Messages
383
  • CR Setup
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Set CR_Temp_Unit_Group = (Units in (Playable map area) owned by Neutral Hostile)
      • Unit Group - Pick every unit in CR_Temp_Unit_Group and do (Actions)
        • Loop - Actions
          • Set CR_Type[CR_Integer] = (Unit-type of (Picked unit))
          • Set CR_Angle[CR_Integer] = (Facing of (Picked unit))
          • Set CR_Point[CR_Integer] = (Position of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to CR_Integer
          • Set CR_Integer = (CR_Integer + 1)
      • Custom script: call DestroyGroup (udg_CR_Temp_Unit_Group)
  • CR Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Neutral Hostile
      • (Unit-type of (Dying unit)) Not equal to |cff6f2583Undead King Aldous|r
      • (Unit-type of (Dying unit)) Not equal to |cffffff00Elizabeth Daughter of the light|r
      • (Unit-type of (Dying unit)) Not equal to |cff404040Forgotton Nightmare|r
      • (Unit-type of (Dying unit)) Not equal to |cFFFFD700 Vanos, God Of Honor|r
      • (Unit-type of (Dying unit)) Not equal to |cff80ff80Ancient Tree Of The Old Lords|r
      • (Unit-type of (Dying unit)) Not equal to Forgotten Slave Knight Mars
    • Actions
      • Wait 10.00 seconds
      • Unit - Create 1 CR_Type[(Custom value of (Dying unit))] for Neutral Hostile at CR_Point[(Custom value of (Dying unit))] facing CR_Angle[(Custom value of (Dying unit))] degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Dying unit))
      • Unit - Remove (Dying unit) from the game
Some units don't respawn i excluded some because they're bosses but only 1 unit respawn the Forest troll. and sometimes it get stuck on some point.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
1) You use CR_Integer in your Setup trigger but then use Custom Value in your Respawn Trigger. This is incorrect, these values are not going to be equal to one another. The 4th picked unit could have a Custom Value of 2, but it'll be assigned CR_Angle[4] / CR_Point[4].

2) You don't need CR_Type, you can reference the Unit-type of triggering unit when it dies.

3) After respawning your unit you change it's Custom Value. This is not needed, it'll be assigned a new Custom Value automatically by the Unit Indexer.

Here's a working system that's very similar to what you were already doing.

It uses local udg_ to take advantage of local variables so that the Point/Angle of the dying unit is not lost during the 10.00 second Wait.

UnitIndexEvent is a special Event that comes with Bribe's Unit Indexer. It runs at the start of the game immediately after every single unit has been Indexed. If you aren't using Bribe's Unit Indexer then use your Elapsed Time Event instead.
  • CR Setup
    • Events
      • Game - UnitIndexEvent becomes Equal to 3.00
    • Conditions
    • Actions
      • Set VariableSet TempGroup = (Units owned by Neutral Hostile.)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • Set VariableSet CR_Point[UDex] = (Position of (Picked unit))
          • Set VariableSet CR_Angle[UDex] = (Facing of (Picked unit))
      • Custom script: call DestroyGroup (udg_TempGroup)
  • CR Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Custom script: local location udg_TempPoint
      • Custom script: local real udg_TempReal
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • Set VariableSet TempPoint = (CR_Point[UDex] offset by (0.00, 0.00))
      • Set VariableSet TempReal = CR_Angle[UDex]
      • Custom script: call RemoveLocation (udg_CR_Point[udg_UDex])
      • Wait 10.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at TempPoint facing TempReal degrees
      • Set VariableSet UDex = (Custom value of (Last created unit))
      • Set VariableSet CR_Point[UDex] = (Position of (Last created unit))
      • Set VariableSet CR_Angle[UDex] = (Facing of (Last created unit))
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: set udg_TempPoint = null
 

Attachments

  • Creep Respawn v1.w3m
    25.2 KB · Views: 31
Last edited:
Level 8
Joined
Jul 10, 2018
Messages
383
1) You use CR_Integer in your Setup trigger but then use Custom Value in your Respawn Trigger. This is incorrect, these values are not going to be equal to one another. The 4th picked unit could have a Custom Value of 2, but it'll be assigned CR_Angle[4] / CR_Point[4].

2) You don't need CR_Type, you can reference the Unit-type of triggering unit when it dies.

3) After respawning your unit you change it's Custom Value. This is not needed, it'll be assigned a new Custom Value automatically by the Unit Indexer.

Here's a working system that's very similar to what you were already doing.

It uses local udg_ to take advantage of "local" variables so that the Point/Angle of the dying unit is not lost during the 10.00 second Wait.

UnitIndexEvent is a special Event that comes with Bribe's Unit Indexer. It runs at the start of the game immediately after every single unit has been Indexed. If you aren't using Bribe's Unit Indexer then use your Elapsed Time Event instead.
  • CR Setup
    • Events
      • Game - UnitIndexEvent becomes Equal to 3.00
    • Conditions
    • Actions
      • Set VariableSet TempGroup = (Units owned by Neutral Hostile.)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • Set VariableSet CR_Point[UDex] = (Position of (Picked unit))
          • Set VariableSet CR_Angle[UDex] = (Facing of (Picked unit))
      • Custom script: call DestroyGroup (udg_TempGroup)
  • CR Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Custom script: local location udg_TempPoint
      • Custom script: local real udg_TempReal
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • Set VariableSet TempPoint = (CR_Point[UDex] offset by (0.00, 0.00))
      • Set VariableSet TempReal = CR_Angle[UDex]
      • Custom script: call RemoveLocation (udg_CR_Point[udg_UDex])
      • Wait 10.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at TempPoint facing TempReal degrees
      • Set VariableSet UDex = (Custom value of (Last created unit))
      • Set VariableSet CR_Point[UDex] = (Position of (Last created unit))
      • Set VariableSet CR_Angle[UDex] = (Facing of (Last created unit))
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: set udg_TempPoint = null

Like this?

  • CR Setup
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Set CR_Temp_Unit_Group = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in CR_Temp_Unit_Group and do (Actions)
        • Loop - Actions
          • Set Udex101 = (Custom value of (Picked unit))
          • Set CR_Type[CR_Integer] = (Unit-type of (Picked unit))
          • Set CR_Angle[CR_Integer] = (Facing of (Picked unit))
          • Set CR_Point[CR_Integer] = (Position of (Picked unit))
      • Custom script: call DestroyGroup (udg_CR_Temp_Unit_Group)
  • CR Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Neutral Hostile
      • (Unit-type of (Dying unit)) Not equal to |cff6f2583Undead King Aldous|r
      • (Unit-type of (Dying unit)) Not equal to |cffffff00Elizabeth Daughter of the light|r
      • (Unit-type of (Dying unit)) Not equal to |cff404040Forgotton Nightmare|r
      • (Unit-type of (Dying unit)) Not equal to |cFFFFD700 Vanos, God Of Honor|r
      • (Unit-type of (Dying unit)) Not equal to |cff80ff80Ancient Tree Of The Old Lords|r
      • (Unit-type of (Dying unit)) Not equal to Forgotten Slave Knight Mars
    • Actions
      • Custom script: local location udg_TempPoint
      • Custom script: local location udg_TempReal
      • Set Udex101 = (Custom value of (Triggering unit))
      • Set TempPoint = CR_Point[UDex]
      • Set TempReal = CR_Angle[UDex]
      • Custom script: call RemoveLocation (udg_CR_Point[udg_UDex])
      • Wait 10.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at TempPoint facing TempReal degrees
      • Set Udex101 = (Custom value of (Last created unit))
      • Set TempPoint = (Position of (Last created unit))
      • Set TempReal = CR_Angle[UDex]
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: set udg_TempPoint = null
 
Level 8
Joined
Jul 10, 2018
Messages
383
Like this?

  • CR Setup
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Set CR_Temp_Unit_Group = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in CR_Temp_Unit_Group and do (Actions)
        • Loop - Actions
          • Set Udex101 = (Custom value of (Picked unit))
          • Set CR_Type[CR_Integer] = (Unit-type of (Picked unit))
          • Set CR_Angle[CR_Integer] = (Facing of (Picked unit))
          • Set CR_Point[CR_Integer] = (Position of (Picked unit))
      • Custom script: call DestroyGroup (udg_CR_Temp_Unit_Group)
  • CR Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Dying unit)) Equal to Neutral Hostile
      • (Unit-type of (Dying unit)) Not equal to |cff6f2583Undead King Aldous|r
      • (Unit-type of (Dying unit)) Not equal to |cffffff00Elizabeth Daughter of the light|r
      • (Unit-type of (Dying unit)) Not equal to |cff404040Forgotton Nightmare|r
      • (Unit-type of (Dying unit)) Not equal to |cFFFFD700 Vanos, God Of Honor|r
      • (Unit-type of (Dying unit)) Not equal to |cff80ff80Ancient Tree Of The Old Lords|r
      • (Unit-type of (Dying unit)) Not equal to Forgotten Slave Knight Mars
    • Actions
      • Custom script: local location udg_TempPoint
      • Custom script: local location udg_TempReal
      • Set Udex101 = (Custom value of (Triggering unit))
      • Set TempPoint = CR_Point[UDex]
      • Set TempReal = CR_Angle[UDex]
      • Custom script: call RemoveLocation (udg_CR_Point[udg_UDex])
      • Wait 10.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at TempPoint facing TempReal degrees
      • Set Udex101 = (Custom value of (Last created unit))
      • Set TempPoint = (Position of (Last created unit))
      • Set TempReal = CR_Angle[UDex]
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: set udg_TempPoint = null
Ignore the udex101 i forgot that i had Unit indexer.
 
Level 8
Joined
Jul 10, 2018
Messages
383
1) You use CR_Integer in your Setup trigger but then use Custom Value in your Respawn Trigger. This is incorrect, these values are not going to be equal to one another. The 4th picked unit could have a Custom Value of 2, but it'll be assigned CR_Angle[4] / CR_Point[4].

2) You don't need CR_Type, you can reference the Unit-type of triggering unit when it dies.

3) After respawning your unit you change it's Custom Value. This is not needed, it'll be assigned a new Custom Value automatically by the Unit Indexer.

Here's a working system that's very similar to what you were already doing.

It uses local udg_ to take advantage of "local" variables so that the Point/Angle of the dying unit is not lost during the 10.00 second Wait.

UnitIndexEvent is a special Event that comes with Bribe's Unit Indexer. It runs at the start of the game immediately after every single unit has been Indexed. If you aren't using Bribe's Unit Indexer then use your Elapsed Time Event instead.
  • CR Setup
    • Events
      • Game - UnitIndexEvent becomes Equal to 3.00
    • Conditions
    • Actions
      • Set VariableSet TempGroup = (Units owned by Neutral Hostile.)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • Set VariableSet CR_Point[UDex] = (Position of (Picked unit))
          • Set VariableSet CR_Angle[UDex] = (Facing of (Picked unit))
      • Custom script: call DestroyGroup (udg_TempGroup)
  • CR Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Custom script: local location udg_TempPoint
      • Custom script: local real udg_TempReal
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • Set VariableSet TempPoint = (CR_Point[UDex] offset by (0.00, 0.00))
      • Set VariableSet TempReal = CR_Angle[UDex]
      • Custom script: call RemoveLocation (udg_CR_Point[udg_UDex])
      • Wait 10.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at TempPoint facing TempReal degrees
      • Set VariableSet UDex = (Custom value of (Last created unit))
      • Set VariableSet CR_Point[UDex] = (Position of (Last created unit))
      • Set VariableSet CR_Angle[UDex] = (Facing of (Last created unit))
      • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: set udg_TempPoint = null
Screenshot - 4be55210ccd8b2bbfcfb3b19fa6e13c1 - Gyazo
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
CR Setup Trigger:
1) You can delete CR_Type as it's not needed/used
2) You're still using CR_Integer instead of UDex (Custom value of picked unit)

CR Respawn Trigger:
1) Your local custom script is wrong. You did: Custom script: local location udg_TempReal -> It should be: Custom script: local real udg_TempReal
2) Your second TempReal should be Facing of last created unit not CR_Angle[UDex]
3) Your first TempPoint should be Point with Offset: Set Variable TempPoint = (CR_Point[UDex] offset by (0.00, 0.00))

Look carefully at my trigger and yours, compare each line of code. If one thing is slightly off it won't work.
 
Last edited:
Level 8
Joined
Jul 10, 2018
Messages
383
CR Setup Trigger:
1) You can delete CR_Type as it's not needed/used
2) You're still using CR_Integer instead of UDex (Custom value of picked unit)

CR Respawn Trigger:
1) Your local custom script is wrong. You did: Custom script: local location udg_TempReal -> It should be: Custom script: local real udg_TempReal
2) Your second TempReal should be Facing of last created unit not CR_Angle[UDex]
3) Your first TempPoint should be Point with Offset: Set Variable TempPoint = (CR_Point[UDex] offset by (0.00, 0.00))

Look carefully at my trigger and yours, compare each line of code. If one thing is slightly off it won't work.
Ok i got it to work but now i have a little request if you mind.

I got a problem with excluding bosses timers

for example i don't want bosses to respawn as the units
and i have some triggers for the bosses spells but i don't know how to make them trigger the correct way after they're respawned.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
Isn't that what these conditions are for? -> (Unit-type of (Dying unit)) Not equal to Forgotten Slave Knight Mars

That should exclude the bosses. Also, you should use a Variable to keep track of your Bosses, and set the Variable again after the Boss respawns.
 
Level 8
Joined
Jul 10, 2018
Messages
383
That should exclude the bosses. Also, you should use a Variable to keep track of your Bosses, and set the Variable again after the Boss respawns.[/QUOTE]


Everybody is telling me to use a variable to keep track of the bosses and set the variable again but i dont know how!! :(
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
Use a Unit variable.
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Variable PaladinBoss = Paladin 0000 <gen>
      • -------- OR --------
      • Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set Variable PaladinBoss = (Last created unit)
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Dying unit) Equal to PaladinBoss
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Boss died.
 
Level 8
Joined
Jul 10, 2018
Messages
383
Use a Unit variable.
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Variable PaladinBoss = Paladin 0000 <gen>
      • -------- OR --------
      • Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set Variable PaladinBoss = (Last created unit)
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Dying unit) Equal to PaladinBoss
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Boss died.
Does this work with already created unit?

and also how do i recreate my boss? my spells trigger off when they're on so it doesn't loop
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
"Does this work with already created unit?"
That's what this is doing: Set Variable PaladinBoss = Paladin 0000 <gen>

And I don't really know what you mean. Are you saying you use Specific Events like these?
  • Events
    • Unit - Paladin 0000 <gen> Dies
If so you can:

1) Change your Boss triggers so that they use Generic Events and reference the Boss variable. Like this:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to PaladinBoss
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Boss died.
OR

2) Make your Bosses Heroes so that you can revive them instead of recreating them, this way the Event still works. Like this:
  • Untitled Trigger 002
    • Events
      • Unit - Paladin 0000 <gen> Dies
    • Conditions
    • Actions
      • Wait 10.00 seconds
      • Hero - Instantly revive Paladin 0000 <gen> at (Center of (Playable map area)), Hide revival graphics
 
Level 8
Joined
Jul 10, 2018
Messages
383
"Does this work with already created unit?"
That's what this is doing: Set Variable PaladinBoss = Paladin 0000 <gen>

And I don't really know what you mean. Are you saying you use Specific Events like these?
  • Events
    • Unit - Paladin 0000 <gen> Dies
If so you can:

1) Change your Boss triggers so that they use Generic Events and reference the Boss variable. Like this:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to PaladinBoss
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Boss died.
OR

2) Make your Bosses Heroes so that you can revive them instead of recreating them, this way the Event still works. Like this:
  • Untitled Trigger 002
    • Events
      • Unit - Paladin 0000 <gen> Dies
    • Conditions
    • Actions
      • Wait 10.00 seconds
      • Hero - Instantly revive Paladin 0000 <gen> at (Center of (Playable map area)), Hide revival graphics
Ok all of that works perfectly but 1 last question

I have based health spells

Like these

  • AAbility 1
    • Events
      • Unit - |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen>'s life becomes Less than 20000000.00
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Floating Text - Create floating text that reads |cff80ff80Wrath of ... above |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen> with Z offset 0.00, using font size 20.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Unit - Pause |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen>
      • Sound - Play Warning <gen>
      • Sound - Play ReviveNightElf <gen>
      • Wait 7.00 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 700.00 of (Position of |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen>)) and do (Actions)
        • Loop - Actions
          • Unit - Cause |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen> to damage (Picked unit), dealing 500000000.00 damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Soul Beam.mdx
          • Special Effect - Destroy (Last created special effect)
      • Sound - Play Warning <gen>
      • Sound - Play ReviveNightElf <gen>
      • Special Effect - Create a special effect attached to the origin of |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen> using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
      • Special Effect - Set Scale of (Last created special effect) to 7.00
      • Special Effect - Destroy (Last created special effect)
      • Unit - Unpause |cff80ff80Ancient Tree Of The Old Lords|r 0438 <gen>

If i resurrect the boss will this effect anything? because i will turn on the spells trigger after they're resurrected.
 
Status
Not open for further replies.
Top