- Joined
- Mar 29, 2011
- Messages
- 3,755
I have a little problem in these triggers. could anyone solve this. I want that if a unit is attacked he will be converted with a xx duration. For some units, it worked but to some specially if the unit dies immediately during conversion, it wont go back to the previous owner. I don't know how to register the previous owner. How should I do that or is my indexing wrong?
-
HCabilitylearned
-

Events
-


Unit - A unit Learns a skill
-
-

Conditions
-


(Learned Hero Skill) Equal to Holy Conversion
-
-

Actions
-


Unit Group - Add (Triggering unit) to HC_attackers
-
-
-
HCinit
-

Events
-


Map initialization
-
-

Conditions
-

Actions
-


-------- chance to convert --------
-


Set HC_Chance[1] = 50
-


Set HC_Chance[2] = 70
-


Set HC_Chance[3] = 90
-


-------- set the ability SFX's --------
-


Set HC_SFX = Abilities\Spells\Items\AIob\AIobTarget.mdl
-


Set HC_SFX_1 = Abilities\Spells\Other\Charm\CharmTarget.mdl
-


Set HC_SFX_2 = Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
-


Set HC_SFX_3 = Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
-


Set HC_SFX_APoint = overhead
-


Set HC_SFX_APoint_1 = origin
-


Set HC_SFX_APoint_2 = origin
-


Set HC_SFX_APoint_3 = origin
-


-------- this is the lenght time of your converted units --------
-


Set HC_conversion_timer = 3.00
-


-------- the ability --------
-


Set HC_Ability = Holy Conversion
-
-
-
HCAttack
-

Events
-


Unit - A unit Is attacked
-
-

Conditions
-


((Attacking unit) is in HC_attackers) Equal to True
-
-

Actions
-


Set HC_size = (HC_size + 1)
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




HC_size Greater than HC_maxSize
-
-



Then - Actions
-




Set HC_index[HC_size] = HC_size
-




Set HC_maxSize = HC_size
-
-



Else - Actions
-
-


Set HC_integer = HC_index[HC_size]
-


-------- ================================================ --------
-


Set HC_Attaker[HC_integer] = (Attacking unit)
-


Set HC_AttackedUnit[HC_integer] = (Triggering unit)
-


Set HC_AttackerOwner[HC_integer] = (Owner of HC_Attaker[HC_integer])
-


Set HC_AttackedOwner[HC_integer] = (Owner of HC_AttackedUnit[HC_integer])
-


Set HC_level = (Level of HC_Ability for HC_Attaker[HC_integer])
-


-------- ================================================ --------
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




(Random integer number between 1 and 100) Less than or equal to HC_Chance[HC_level]
-




(HC_AttackedUnit[HC_integer] belongs to an enemy of HC_AttackerOwner[HC_integer]) Equal to True
-




(HC_AttackedUnit[HC_integer] is alive) Equal to True
-




(HC_AttackedUnit[HC_integer] is Magic Immune) Equal to False
-




(HC_AttackedUnit[HC_integer] is A Hero) Equal to False
-
-



Then - Actions
-




Set HC_conversion_timer_real[HC_integer] = (HC_conversion_timer x (Real(HC_level)))
-




Unit - Change ownership of HC_AttackedUnit[HC_integer] to HC_AttackerOwner[HC_integer] and Change color
-




Special Effect - Create a special effect attached to the HC_SFX_APoint of HC_AttackedUnit[HC_integer] using HC_SFX
-




Set HC_Effect[HC_integer] = (Last created special effect)
-




Special Effect - Create a special effect attached to the HC_SFX_APoint_1 of HC_AttackedUnit[HC_integer] using HC_SFX_1
-




Special Effect - Destroy (Last created special effect)
-




Special Effect - Create a special effect attached to the HC_SFX_APoint_3 of HC_Attaker[HC_integer] using HC_SFX_3
-




Special Effect - Destroy (Last created special effect)
-




Trigger - Turn on HCloop <gen>
-
-



Else - Actions
-




-------- if the attacked unit is not converted, this has to be recycled --------
-




Set HC_index[HC_size] = HC_integer
-




Set HC_size = (HC_size - 1)
-
-
-


-------- ================================================ --------
-
-
-
HCloop
-

Events
-


Time - Every 1.00 seconds of game time
-
-

Conditions
-

Actions
-


-------- ================================================ --------
-


For each (Integer HC_loop) from 1 to HC_size, do (Actions)
-



Loop - Actions
-




Set HC_integer = HC_index[HC_loop]
-




Set HC_conversion_timer_real[HC_integer] = (HC_conversion_timer_real[HC_integer] - 1.00)
-




If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-





If - Conditions
-






Or - Any (Conditions) are true
-







Conditions
-








HC_conversion_timer_real[HC_integer] Less than or equal to 0.00
-








(HC_AttackedUnit[HC_integer] is dead) Equal to True
-
-
-
-





Then - Actions
-






Unit - Change ownership of HC_AttackedUnit[HC_integer] to HC_AttackedOwner[HC_integer] and Change color
-






Special Effect - Destroy HC_Effect[HC_integer]
-






Special Effect - Create a special effect attached to the HC_SFX_APoint_2 of HC_AttackedUnit[HC_integer] using HC_SFX_2
-






Special Effect - Destroy (Last created special effect)
-






Set HC_index[HC_loop] = HC_index[HC_size]
-






Set HC_index[HC_size] = HC_integer
-






Set HC_size = (HC_size - 1)
-






Set HC_loop = (HC_loop - 1)
-






If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-







If - Conditions
-








HC_size Equal to 0
-
-







Then - Actions
-








Trigger - Turn off (This trigger)
-
-







Else - Actions
-
-
-





Else - Actions
-
-
-
-


-------- ================================================ --------
-
-



