- Joined
- Oct 4, 2011
- Messages
- 226
Hi. I was wondering how I would choose the closest unit to index as the target in the hashtable.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Fiery Claws

Events


Time - Every 4.00 seconds of game time

Conditions

Actions


Set FieryClawsCaster_UGrp = (Units in (Entire map) matching (((Level of Fiery Claws (Neutral Hostile) for (Matching unit)) Greater than 0) and (((Matching unit) is alive) Equal to True)))


Unit Group - Pick every unit in FieryClawsCaster_UGrp and do (Actions)



Loop - Actions




Hashtable - Save Handle Of(Picked unit) as (Key caster) of (Key fireball) in BlazingFiend01_HashTable




Hashtable - Save Handle Of(Position of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable)) as (Key location1) of (Key caster) in BlazingFiend01_HashTable




Set FieryClawsTargets_UGrp = (Units within 400.00 of (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) matching ((((Matching unit) belongs to an enemy of (Owner of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable))) Equal to True) and ((((Matching unit) b




Unit Group - Pick every unit in FieryClawsTargets_UGrp and do (Actions)





Loop - Actions






Set FieryClawsDistance_Real = (Distance between (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) and (Position of (Picked unit)))




Special Effect - Create a special effect at (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl




Special Effect - Destroy (Last created special effect)




-------- The Other location will have to be inserted before the unit is made and faces the direction --------




Unit - Create 1 Fireball for (Owner of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable)) at ((Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) offset by 75.00 towards (Angle from (Position of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable)) to (Position of (Triggering unit))) degrees) facing Default building facing degrees




Unit Group - Add (Last created unit) to Fireballs_UGrp


Unit Group - Remove all units from FieryClawsCaster_UGrp


Hashtable - Clear all child hashtables of child (Key location1) in BlazingFiend01_HashTable
Fiery Claws

Events


Time - Every 4.00 seconds of game time

Conditions

Actions


Set FieryClawsCaster_UGrp = (Units in (Entire map) matching (((Level of Fiery Claws (Neutral Hostile) for (Matching unit)) Greater than 0) and (((Matching unit) is alive) Equal to True)))


Set FieryClawsDistance2_Real = 400.00


Unit Group - Pick every unit in FieryClawsCaster_UGrp and do (Actions)



Loop - Actions




Hashtable - Save Handle Of(Picked unit) as (Key caster) of (Key fireball) in BlazingFiend01_HashTable




Hashtable - Save Handle Of(Position of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable)) as (Key location1) of (Key caster) in BlazingFiend01_HashTable




Set FieryClawsTargets_UGrp = (Units within 400.00 of (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) matching ((((Matching unit) belongs to an enemy of (Owner of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable))) Equal to True) and ((((Matching unit) b




Unit Group - Pick every unit in FieryClawsTargets_UGrp and do (Actions)





Loop - Actions






Hashtable - Save Handle Of(Position of (Picked unit)) as (Key location2) of (Key target) in BlazingFiend01_HashTable






Set FieryClawsDistance_Real = (Distance between (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) and (Load (Key location2) of (Key target) in BlazingFiend01_HashTable))






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







If - Conditions








FieryClawsDistance_Real Less than FieryClawsDistance2_Real








(((Picked unit) is A structure) Equal to False) and ((((Picked unit) belongs to an enemy of (Owner of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable))) Equal to True) and (((Picked unit) belongs to an ally of (Owner of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable))) Equal







Then - Actions








Set FieryClawsDistance2_Real = FieryClawsDistance_Real








Hashtable - Save Handle Of(Picked unit) as (Key target) of (Key fireball) in BlazingFiend01_HashTable







Else - Actions




Special Effect - Create a special effect at (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl




Special Effect - Destroy (Last created special effect)




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





If - Conditions






(Number of units in FieryClawsTargets_UGrp) Greater than 0





Then - Actions






Unit - Create 1 Fireball for (Owner of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable)) at ((Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) offset by 75.00 towards (Angle from (Position of (Load (Key caster) of (Key fireball) in BlazingFiend01_HashTable)) to (Load (Key location2) of (Key target) in BlazingFiend01_HashTable)) degr facing (Angle from (Load (Key location1) of (Key caster) in BlazingFiend01_HashTable) to (Load (Key location2) of (Key target) in BlazingFiend01_HashTable)) degrees






Hashtable - Save Handle Of(Last created unit) as (Key unit) of (Key fireball) in BlazingFiend01_HashTable






Unit Group - Add (Last created unit) to Fireballs_UGrp






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







If - Conditions








(Fiery Claws Mover <gen> is on) Equal to False







Then - Actions








Trigger - Turn on Fiery Claws Mover <gen>







Else - Actions





Else - Actions


Unit Group - Remove all units from FieryClawsCaster_UGrp


Hashtable - Clear all child hashtables of child (Key location1) in BlazingFiend01_HashTable
Fiery Claws Mover

Events


Time - Every 0.03 seconds of game time

Conditions

Actions


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



If - Conditions




(Number of units in Fireballs_UGrp) Equal to 0



Then - Actions




Trigger - Turn off (This trigger)



Else - Actions


Hashtable - Save Handle Of(Position of (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable)) as (Key location3) of (Key fireball) in BlazingFiend01_HashTable


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



If - Conditions




(Distance between (Load (Key location3) of (Key fireball) in BlazingFiend01_HashTable) and (Position of (Load (Key target) of (Key fireball) in BlazingFiend01_HashTable))) Less than 53.00



Then - Actions




Unit - Cause (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable) to damage (Load (Key target) of (Key fireball) in BlazingFiend01_HashTable), dealing 50.00 damage of attack type Spells and damage type Normal




Unit - Kill (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable)



Else - Actions




Unit - Move (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable) instantly to ((Position of (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable)) offset by 7.50 towards (Angle from (Position of (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable)) to (Position of (Load (Key target) of (Key fireball) in BlazingFien, facing (Angle from (Position of (Load (Key unit) of (Key fireball) in BlazingFiend01_HashTable)) to (Position of (Load (Key target) of (Key fireball) in BlazingFiend01_HashTable))) degrees


Hashtable - Clear all child hashtables of child (Key location3) in BlazingFiend01_HashTable
Hi. I was wondering how I would choose the closest unit to index as the target in the hashtable.
Are the index and the unit 2 different variables? or does the unit variable have an index. (Array type)
local unit u = GetTriggerUnit()
local unit pu
local player p = GetTriggerPlayer()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local integer index = 0
local integer cv = GetUnitUserData(u)
call GroupEnumUnitsInRange(udg_UG, x, y, 600.00, null)
loop
set pu = FirstOfGroup(udg_UG)
exitwhen (pu==null)
// if dont need if u dont want filter the unit
// if IsUnitAlly(pu, p) then
call SaveUnitHandle(udg_Target_Table, cv, index, pu)
set index = index + 1
// endif
call GroupRemoveUnit(udg_UG, pu)
endloop
set u = null
set p = null
set pu = null
local unit u = GetTriggerUnit()
local unit pu
local player p = GetTriggerPlayer()
local integer cv = GetUnitUserData(u)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
set udg_index = 0
call GroupEnumUnitsInRange(udg_UG, x, y, 600.00, null)
loop
set pu = FirstOfGroup(udg_UG)
exitwhen (pu==null)
//i removed the if but u can put back if u want
set udg_Target[cv] = pu
set udg_index[cv] = udg_index[cv] + 1
call GroupRemoveUnit(udg_UG, pu)
endloop
set u = null
set p = null
set pu = null