- Joined
- Jul 6, 2012
- Messages
- 66
So I have this spell which is replaces the hero with another unit (a spirit) when it dies, which lasts until your hero revives/respawns. When your hero respawns, it respawns at the unit's location, and the unit disappears.
The ability itself works fine. But it breaks down when I have multiple heroes with that ability.
The first part of it works completely fine, no matter how many heroes with it die. But upon respawning, it messes up. The first respawning hero removes its own unit, and the 2nd hero's unit as well. The 2nd respawning hero therefore respawns at the altar, instead of where its spirit was, because it doesn't have a spirit anymore. The 3rd respawning hero respawns at the altar as well and its spirit isn't removed at all.
So there clearly is an indexing issue, but I can't figure out what's wrong. I used the same indexing for several other spells and they all work fine. This is the only instance where I use it with deaths/respawning units.
Here are the codes
death event trigger
The ability itself works fine. But it breaks down when I have multiple heroes with that ability.
The first part of it works completely fine, no matter how many heroes with it die. But upon respawning, it messes up. The first respawning hero removes its own unit, and the 2nd hero's unit as well. The 2nd respawning hero therefore respawns at the altar, instead of where its spirit was, because it doesn't have a spirit anymore. The 3rd respawning hero respawns at the altar as well and its spirit isn't removed at all.
So there clearly is an indexing issue, but I can't figure out what's wrong. I used the same indexing for several other spells and they all work fine. This is the only instance where I use it with deaths/respawning units.
Here are the codes
death event trigger
-
Light Form death
-
Events
-
Unit - A unit Dies
-
-
Conditions
-
(Level of Light Form for (Dying unit)) Greater than 0
-
-
Actions
-
Set LightFormDeathIndex = (LightFormDeathIndex + 1)
-
Set LightFormDeathHero[LightFormDeathIndex] = (Dying unit)
-
Set LightFormDeathTimer[LightFormDeathIndex] = 2.60
-
Set LightFormDeathLoc[LightFormDeathIndex] = (Position of LightFormDeathHero[LightFormDeathIndex])
-
Unit - Create 1 Light Image for (Owner of LightFormDeathHero[LightFormDeathIndex]) at LightFormDeathLoc[LightFormDeathIndex] facing (Facing of LightFormDeathHero[LightFormDeathIndex]) degrees
-
Set LightFormDeathSummon[LightFormDeathIndex] = (Last created unit)
-
Unit - Make LightFormDeathSummon[LightFormDeathIndex] Invulnerable
-
Unit - Hide LightFormDeathSummon[LightFormDeathIndex]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Light Form for LightFormDeathHero[LightFormDeathIndex]) Equal to 1
-
-
Then - Actions
-
Unit - Add Revealing Light (Light Image 1) to LightFormDeathSummon[LightFormDeathIndex]
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Light Form for LightFormDeathHero[LightFormDeathIndex]) Equal to 2
-
-
Then - Actions
-
Unit - Add Revealing Light (Light Image 1) to LightFormDeathSummon[LightFormDeathIndex]
-
Unit - Add Teleport (Light Image 2) to LightFormDeathSummon[LightFormDeathIndex]
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Light Form for LightFormDeathHero[LightFormDeathIndex]) Equal to 3
-
-
Then - Actions
-
Unit - Add Revealing Light (Light Image 1) to LightFormDeathSummon[LightFormDeathIndex]
-
Unit - Add Teleport (Light Image 2) to LightFormDeathSummon[LightFormDeathIndex]
-
Unit - Add Blinding Aura (Light Image 3) to LightFormDeathSummon[LightFormDeathIndex]
-
-
Else - Actions
-
-
-
-
-
-
Special Effect - Create a special effect at LightFormDeathLoc[LightFormDeathIndex] using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
-
Special Effect - Destroy (Last created special effect)
-
Animation - Change LightFormDeathHero[LightFormDeathIndex]'s animation speed to 70.00% of its original speed
-
If (LightFormDeathIndex Equal to 1) then do (Trigger - Turn on Light Form death effect <gen>) else do (Do nothing)
-
-
-
Light Form death effect
-
Events
-
Time - Every 0.10 seconds of game time
-
-
Conditions
-
Actions
-
For each (Integer LightFormDeathLoop) from 1 to LightFormDeathIndex, do (Actions)
-
Loop - Actions
-
Set LightFormDeathTimer[LightFormDeathLoop] = (LightFormDeathTimer[LightFormDeathLoop] - 0.10)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
LightFormDeathTimer[LightFormDeathLoop] Equal to 2.50
-
-
Then - Actions
-
Custom script: call SetUnitAnimationByIndex(udg_LightFormDeathHero[udg_LightFormDeathLoop], 3)
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
LightFormDeathTimer[LightFormDeathLoop] Equal to 1.50
-
-
Then - Actions
-
Special Effect - Create a special effect at LightFormDeathLoc[LightFormDeathLoop] using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
-
Special Effect - Destroy (Last created special effect)
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
LightFormDeathTimer[LightFormDeathLoop] Equal to 0.00
-
-
Then - Actions
-
Unit - Hide LightFormDeathHero[LightFormDeathLoop]
-
Unit - Move LightFormDeathSummon[LightFormDeathLoop] instantly to LightFormDeathLoc[LightFormDeathLoop], facing (Facing of LightFormDeathHero[LightFormDeathLoop]) degrees
-
Unit - Unhide LightFormDeathSummon[LightFormDeathLoop]
-
Animation - Change LightFormDeathHero[LightFormDeathLoop]'s animation speed to 100.00% of its original speed
-
Selection - Add LightFormDeathSummon[LightFormDeathLoop] to selection for (Owner of LightFormDeathSummon[LightFormDeathLoop])
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(LightFormDeathHero[LightFormDeathLoop] is alive) Equal to True
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(LightFormDeathSummon[LightFormDeathLoop] is in (Units currently selected by (Owner of LightFormDeathSummon[LightFormDeathLoop]))) Equal to True
-
-
Then - Actions
-
Selection - Add LightFormDeathHero[LightFormDeathLoop] to selection for (Owner of LightFormDeathHero[LightFormDeathLoop])
-
-
Else - Actions
-
-
Unit - Hide LightFormDeathSummon[LightFormDeathLoop]
-
Set LightFormDeathLocSummon = (Position of LightFormDeathSummon[LightFormDeathLoop])
-
Unit - Move LightFormDeathHero[LightFormDeathLoop] instantly to LightFormDeathLocSummon, facing (Facing of LightFormDeathSummon[LightFormDeathLoop]) degrees
-
Custom script: call RemoveLocation(udg_LightFormDeathLocSummon)
-
Unit - Kill LightFormDeathSummon[LightFormDeathLoop]
-
Set LightFormDeathSummon[LightFormDeathLoop] = LightFormDeathSummon[LightFormDeathIndex]
-
Set LightFormDeathHero[LightFormDeathLoop] = LightFormDeathHero[LightFormDeathIndex]
-
Set LightFormDeathTimer[LightFormDeathLoop] = LightFormDeathTimer[LightFormDeathIndex]
-
Custom script: call RemoveLocation(udg_LightFormDeathLoc[udg_LightFormDeathLoop])
-
Set LightFormDeathLoc[LightFormDeathLoop] = LightFormDeathLoc[LightFormDeathIndex]
-
Set LightFormDeathIndex = (LightFormDeathIndex - 1)
-
Set LightFormDeathLoop = (LightFormDeathLoop - 1)
-
If (LightFormDeathIndex Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
-
-
Else - Actions
-
-
-
-
-
-
...
-
Set LightFormDeathSummon[LightFormDeathLoop] = LightFormDeathSummon[LightFormDeathIndex]
-
Set LightFormDeathHero[LightFormDeathLoop] = LightFormDeathHero[LightFormDeathIndex]
-
Set LightFormDeathTimer[LightFormDeathLoop] = LightFormDeathTimer[LightFormDeathIndex]
-
Custom script: call RemoveLocation(udg_LightFormDeathLoc[udg_LightFormDeathLoop])
-
Set LightFormDeathLoc[LightFormDeathLoop] = LightFormDeathLoc[LightFormDeathIndex]
-
Set LightFormDeathIndex = (LightFormDeathIndex - 1)
-
Set LightFormDeathLoop = (LightFormDeathLoop - 1)
-
If (LightFormDeathIndex Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
-
Else - Actions
-