- Joined
- Sep 9, 2009
- Messages
- 658
So I triggered a missile spell with a dummy unit as the missile and it works fine but how do I make it go upwards when targeting air units?
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.
function GetUnitHeightDifference takes unit u1, unit u2 returns real
local location l1 = GetUnitLoc (u1)
local location l2 = GetUnitLoc (u2)
local real r1 = GetLocationZ (l1)
local real r2 = GetLocationZ (l2)
call RemoveLocation (l1)
call RemoveLocation (l2)
return (r1 + GetUnitFlyHeight (u1)) - (r2 + GetUnitFlyHeight (u2))
endfunction
Custom script: set udg_HeightChange = GetUnitHeightDifference (udg_Target, udg_Missile)
You can get the target's flying height and then calculate the change in flying height of the projectile per interval based on the distance.
You need to use this Jass function to get the height difference then with each missile movement, change its height by height difference/loop count (0.03s will get a loop count of 33)
JASS:function GetUnitHeightDifference takes unit u1, unit u2 returns real local location l1 = GetUnitLoc (u1) local location l2 = GetUnitLoc (u2) local real r1 = GetLocationZ (l1) local real r2 = GetLocationZ (l2) call RemoveLocation (l1) call RemoveLocation (l2) return (r1 + GetUnitFlyHeight (u1)) - (r2 + GetUnitFlyHeight (u2)) endfunction
Use it like this in the cast phase of the spell. HeightChange is a real var.
It may return negative if the missile is higher than the unit. Also, changing height of either unit midflight will cause this to malfunction. You should note that.
Custom script: set udg_HeightChange = GetUnitHeightDifference (udg_Missile, udg_Target)
Glacial Blast Loop

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Custom script: set udg_HeightChange = GetUnitHeightDifference (udg_GB_unit[1], udg_GB_dummy)


Set GB_real = (HeightChange / 25.00)


Set GB_speed = 1150.00


Set GB_loc[1] = (Position of GB_dummy)


Set GB_loc[2] = (Position of GB_unit[1])


Set GB_loc[3] = (GB_loc[1] offset by (GB_speed x 0.04) towards (Angle from GB_loc[1] to GB_loc[2]) degrees)


Unit - Move GB_dummy instantly to GB_loc[3]


Animation - Change GB_dummy flying height to GB_real at 100.00


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



If - Conditions




(Distance between GB_loc[2] and GB_loc[1]) Less than or equal to 100.00



Then - Actions




Trigger - Turn off (This trigger)




Unit - Kill GB_dummy




Unit - Cause GB_unit[0] to damage GB_unit[1], dealing GB_damage damage of attack type Chaos and damage type Universal




Custom script: call RemoveLocation (udg_GB_loc[1])




Custom script: call RemoveLocation (udg_GB_loc[2])




Custom script: call RemoveLocation (udg_GB_loc[3])



Else - Actions




Custom script: call RemoveLocation (udg_GB_loc[1])




Custom script: call RemoveLocation (udg_GB_loc[2])




Custom script: call RemoveLocation (udg_GB_loc[3])
Glacial Blast Loop

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Custom script: set udg_HeightChange = GetUnitHeightDifference (udg_GB_dummy, udg_GB_unit[1])


Set GB_real = (HeightChange / 25.00)


Set GB_speed = 1150.00


Set GB_loc[1] = (Position of GB_dummy)


Set GB_loc[2] = (Position of GB_unit[1])


Set GB_loc[3] = (GB_loc[1] offset by (GB_speed x 0.04) towards (Angle from GB_loc[1] to GB_loc[2]) degrees)


Unit - Move GB_dummy instantly to GB_loc[3]


Unit - Add Crow Form to GB_dummy


Animation - Change GB_dummy flying height to ((Current flying height of GB_dummy) + GB_real) at 100.00


Unit - Remove Crow Form from GB_dummy


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



If - Conditions




(Distance between GB_loc[2] and GB_loc[1]) Less than or equal to 100.00



Then - Actions




Trigger - Turn off (This trigger)




Unit - Kill GB_dummy




Unit - Cause GB_unit[0] to damage GB_unit[1], dealing GB_damage damage of attack type Chaos and damage type Universal




Custom script: call RemoveLocation (udg_GB_loc[1])




Custom script: call RemoveLocation (udg_GB_loc[2])




Custom script: call RemoveLocation (udg_GB_loc[3])



Else - Actions




Custom script: call RemoveLocation (udg_GB_loc[1])




Custom script: call RemoveLocation (udg_GB_loc[2])




Custom script: call RemoveLocation (udg_GB_loc[3])