- 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?
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
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)