• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Store height in custom script

Status
Not open for further replies.
Level 3
Joined
Sep 26, 2012
Messages
39
How would I store (ground's height at a position of a unit + Flying height of unit) in a real variable?

I'm trying to attach a lightning effect to a flying unit but since my map terrain has been raised by alot, it seems like using GetUnitFlyHeight will set the lightning's height to the height between the ground and the flying unit but starting from the very bottom of the map. Idk if that makes any sense, if not I'll try to explain better
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
JASS:
    //in case the unit is local:
    local unit theunit = someunit //that is no real function or expression
    local location l = Location(GetUnitX(theunit), GetUnitY(theunit))
    local real r = GetLocationZ(l) + GetUnitFlyHeight(theunit)
    //perform shit here or just replace the local real r with some global
    call RemoveLocation(l)
    /*
        calling RemoveLocation is necessery no matter if the location is local or not
        to prevent leaks
    */
    set l = null
    set u = null
    /*
        nulling is only required if the variable is local
    */
 
Status
Not open for further replies.
Top