Dear thehelper.net members,
In my map I have a central base for players. A "safe-haven". Therefore the settlement is guarded by friendly unit, whom become hostile once you wage war in the city (and WILL attack you until your death (or theirs)). I can imagine that when player progress in my level, they may become powerful enough to take down some guards for the fun of it. Therefore I created a revival trigger for the guards (see below).
The trigger works fine, the first time a guard dies... but apparently the two times "Set Variable" after creating the unit fail to do their job. Because if that same guard dies another time, it's a permanent one - poor guard . I thought this was way more efficient than to set the variable for each guard separately, but I guess I missed something at the reassigning of the units when they "revive".
Thoughts?
Variables:
Guards_Unit_First [Array] = Each guard assigned to an array at the map initialization (23 guards in total as you can see).
Guards_Return_Point [Array] = The static position of each guard, also assigned at initialization.
Above variables all line up perfectly, for the sake of order. So for example:
Guard 1 has Guards_Unit_First[0] and Guards_Return_Point[0]
Guard 2 has Guards_Unit_First[1] and Guards_Return_Point[1]
In my map I have a central base for players. A "safe-haven". Therefore the settlement is guarded by friendly unit, whom become hostile once you wage war in the city (and WILL attack you until your death (or theirs)). I can imagine that when player progress in my level, they may become powerful enough to take down some guards for the fun of it. Therefore I created a revival trigger for the guards (see below).
The trigger works fine, the first time a guard dies... but apparently the two times "Set Variable" after creating the unit fail to do their job. Because if that same guard dies another time, it's a permanent one - poor guard . I thought this was way more efficient than to set the variable for each guard separately, but I guess I missed something at the reassigning of the units when they "revive".
Thoughts?
Code:
Guard Revival
Events
Unit - A unit owned by Player 6 (Orange) Dies
Conditions
Actions
For each (Integer A) from 0 to 22, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Dying unit) Equal to Guards_Unit_First[(Integer A)]
Then - Actions
Set Temp_Point = Guards_Return_Point[(Integer A)]
Unit - Create 1 (Unit-type of (Dying unit)) for Player 6 (Orange) at Temp_Point facing 270.00 degrees
Custom script: call RemoveLocation (udg_Temp_Point)
Set Guards_Unit_First[(Integer A)] = (Last created unit)
Set Guards_Return_Point[(Integer A)] = (Position of (Last created unit))
Set Temp_Point = Guards_Return_Point[(Integer A)]
Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation (udg_Temp_Point)
Else - Actions
Variables:
Guards_Unit_First [Array] = Each guard assigned to an array at the map initialization (23 guards in total as you can see).
Guards_Return_Point [Array] = The static position of each guard, also assigned at initialization.
Above variables all line up perfectly, for the sake of order. So for example:
Guard 1 has Guards_Unit_First[0] and Guards_Return_Point[0]
Guard 2 has Guards_Unit_First[1] and Guards_Return_Point[1]