SetUnitX, Y, not working maybe?

Tyman2007

Ya Rly >.
Reaction score
74
Well.. I have this issue here. I'm trying to make a spell and am in the process of making it, but for some reason whenever I use the ability, the missle spawns, but does not move an inch. I added in a debug message to keep checking the location of the unit and the location of the unit is changing, but the appearant location is not.

Here's the trigger I'm using. I'm not too good w/ vJass so please bear with me.

JASS:
library MagicExplosion initializer Init requires TimerUtils
    ////////////////////////////////////////////////////////////////////////////////////
    //                           Start of Configuration                               //
    ////////////////////////////////////////////////////////////////////////////////////
    
    globals
        private constant boolean DMG_ALL = false        //Set to true to damage allies AND enemies
        private constant integer ABIL_CODE = 'Axpl'     //Rawcode of the ability
        private constant integer DUMM_CODE = 'h000'     //Rawcode of the missle dummy
        private constant real DUMM_OFFSET = 200         //Offset of the missle dummy
        
        private constant string EXPL_STR = "War3Imported\\MagicExplosion.mdl"   //Path to the Explosion
        private constant real RADIANS = 0.01745         //Real value of 1 radian
        private constant real SPD = 0.03125             //Speed of the missle. Change not recommended
        private constant boolean ROD = true             //Cancels the spell if the caster dies while casting
        private constant real MOVE_DIST = 30           //Distance between each move tick of the missle
        
        private constant real RADIUS = 350              //Radius of the blast
        private constant real DAMAGE = 100              //+Damage per level
        private constant real WAIT_TIME = .5            //Time before the missle is sent
        private constant string CAST_ANIM = "Spell"     //Animation name of the casting animation
        private constant string CHAN_ANIM = "Stand Channel"     //Animation name of the channeling animation. Set to "" for no channel animation
    endglobals
    
    ////////////////////////////////////////////////////////////////////////////////////
    //                           End of Configuration                                 //
    ////////////////////////////////////////////////////////////////////////////////////

    //Function to square a real. I feel it's a bit easier to do Sq(r) than Pow(r, 2)
    private function Sq takes real x returns real
        return x * x
    endfunction
    
    //My distance function. Added to take up space
    private function Distance takes real x1, real x2, real y1, real y2 returns real
        local real r
        set r = SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))
        return r
    endfunction
    
    private struct Data
        unit u
        real x
        real y
        real x2
        real y2
        
        real ox
        real oy
        real angle
        real dist
        player p
        
        unit dummy
        
        static method create takes unit u, real x2, real y2 returns Data
            local Data d = Data.allocate()
            local real angle = GetUnitFacing(u)
            local real x = GetUnitX(u)
            local real y = GetUnitY(u)
            
            set d.x2 = x2
            set d.y2 = y2
            
            set d.angle = angle
            set d.u = u
            set d.dist = Distance(x, x2, y, y2)
            
            set d.x = x
            set d.y = y
            set d.ox = x + DUMM_OFFSET * Cos(angle * RADIANS)
            set d.oy = y + DUMM_OFFSET * Sin(angle * RADIANS)
            
            set d.p = GetOwningPlayer(u)
            call PauseUnit(u, true)
            call SetUnitAnimation(u, CAST_ANIM)
            return d
        endmethod
    endstruct
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == ABIL_CODE
    endfunction

    private function Check takes nothing returns boolean
        if DMG_ALL == true then
            return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
        endif
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
    endfunction
    
    private function CallBack takes nothing returns nothing
        local Data d = GetTimerData(GetExpiredTimer())
        local timer t = GetExpiredTimer()
        local real x = GetUnitX(d.dummy)
        local real y = GetUnitY(d.dummy)
        
        call BJDebugMsg(R2S(x))
        if d.dist > MOVE_DIST then
            set d.ox = x + MOVE_DIST * Cos(d.angle * RADIANS)
            set d.oy = y + MOVE_DIST * Sin(d.angle * RADIANS)
            set d.dist = d.dist - 30
            call SetUnitX(d.dummy, d.ox)
            call SetUnitY(d.dummy, d.oy)
        else
            call ReleaseTimer(t)
            call SetUnitAnimation(d.u, "Stand")
            call PauseUnit(d.u, false)
        endif
    endfunction

    private function Actions takes nothing returns nothing
        local location l = GetSpellTargetLoc()
        local unit u = GetSpellAbilityUnit()
        local real x = GetLocationX(l)
        local real y = GetLocationY(l)
        local Data d = Data.create(u, x, y)
        local timer t = NewTimer()
        
        call RemoveLocation(l)
        set d.dummy = CreateUnit(d.p, DUMM_CODE, d.ox, d.oy, d.angle)
        
        call TriggerSleepAction(WAIT_TIME)
        if CHAN_ANIM == "" then
            call SetUnitAnimation(u, CAST_ANIM)
        else
            call SetUnitAnimation(u, CHAN_ANIM)
        endif
        call SetTimerData(t, d)
        call TimerStart(t, SPD, true, function CallBack)
    endfunction

    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( trig, Condition( function Conditions ) )
        call TriggerAddAction( trig, function Actions )
    endfunction

endlibrary
 

XeNiM666

I lurk for pizza
Reaction score
138
does you dummy unit have 0 movement speed?
if yes then set its movement speed to something not equal to 0

apparently, SetUnitX/Y doesnt work if the unit has no movement speed.
 

Tyman2007

Ya Rly >.
Reaction score
74
Dang, I was just going to give my world editor some sugar pills and say they're a miracle cure so that it would work, but that's the same thing and holy balls it works!

Thanks man, do you want a + or - rep? :p
The text under your name makes me confuse
 

Bribe

vJass errors are legion
Reaction score
67
JASS:
local real r
set r = SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))
return r


Nein, nein, nein, nein, nein. Do

[ljass]return SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))[/ljass]

We're talking efficiency if we're talking scripting.

JASS:
private function Check takes nothing returns boolean
    if DMG_ALL == true then
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
    endif
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction

//should be:

private function Check takes nothing returns boolean
    static if DMG_ALL then
        return GetWidgetLife(GetFilterUnit()) > 0.435
    else
        return GetWidgetLife(GetFilterUnit()) > 0.435 and IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer())
    endif
endfunction


JASS:
local Data d = GetTimerData(GetExpiredTimer())
local timer t = GetExpiredTimer()

// change to:

local timer t = GetExpiredTimer()
local Data d = GetTimerData(t)


JASS:
local location l = GetSpellTargetLoc()
local unit u = GetSpellAbilityUnit()
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local Data d = Data.create(u, x, y)

// change to:

local unit u = GetTriggerUnit() // faster/more accurate than GetSpellAbilityUnit()
local Data d = Data.create(u, GetSpellTargetX(), GetSpellTargetY())


[ljass]private constant real RADIANS = 0.01745 //Real value of 1 radian[/ljass]

Not sure what you mean here. 1 radian ~ 57.2958 degrees. A radian is 180/pi, not pi/180.
 

Tyman2007

Ya Rly >.
Reaction score
74
JASS:
local real r
set r = SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))
return r


Nein, nein, nein, nein, nein. Do

[ljass]return SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))[/ljass]

We're talking efficiency if we're talking scripting.

I know about that :p I like to do things that don't really matter like that to take up space. It doesn't make my eyes bleed as badly.

JASS:
private function Check takes nothing returns boolean
    if DMG_ALL == true then
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
    endif
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction

//should be:

private function Check takes nothing returns boolean
    static if DMG_ALL then
        return GetWidgetLife(GetFilterUnit()) > 0.435
    else
        return GetWidgetLife(GetFilterUnit()) > 0.435 and IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer())
    endif
endfunction


oh, never thought of that :p

JASS:
local Data d = GetTimerData(GetExpiredTimer())
local timer t = GetExpiredTimer()

// change to:

local timer t = GetExpiredTimer()
local Data d = GetTimerData(t)


Well it doesn't quite matter whether I store it in a variable before I use it, which leads to you contradicting yourself a little bit on this part

JASS:
local location l = GetSpellTargetLoc()
local unit u = GetSpellAbilityUnit()
local real x = GetLocationX(l)
local real y = GetLocationY(l)
local Data d = Data.create(u, x, y)

// change to:

local unit u = GetTriggerUnit() // faster/more accurate than GetSpellAbilityUnit()
local Data d = Data.create(u, GetSpellTargetX(), GetSpellTargetY())


if it was found more efficient then I should leave the timer and data locations alone, no?

Not sure what you mean here. 1 radian ~ 57.2958 degrees. A radian is 180/pi, not pi/180.

oops :p I shouldof noted that 1 degree is equal to .07145 in which you shouldof understood if you looked a little closer at
[ljass] set d.ox = x + DUMM_OFFSET * Cos(angle * RADIANS)[/ljass]

This is the incomplete script. There's nothing much to change. however, I will take this into note :p
JASS:
local unit u = GetTriggerUnit() // faster/more accurate than GetSpellAbilityUnit()
local Data d = Data.create(u, GetSpellTargetX(), GetSpellTargetY())

[/JASS]

one thing I've noticed about that though, is that I use the variables a few times. May look good on the top buutt..... might just lead to very long lines.
 

hgkjfhfdsj

Active Member
Reaction score
55
[DEL]you can probably inline the GetTriggerUnit() in the Data.create() and move the SetUnitAnimation in the create method instead. saves you from setting/nulling a local[/DEL]
actually nvm.. didnt see the tsa..
 

saw792

Is known to say things. That is all.
Reaction score
280
I would be using UnitAlive instead of GetWidgetLife() myself... It's a native from common.ai that you can use but you do have to declare it in the map script somewhere with
JASS:
native UnitAlive takes unit u returns boolean
 

Tyman2007

Ya Rly >.
Reaction score
74
Well, thanks everyone for your help.

Here's my script (Without the optimizations, not worrying about that right now)

JASS:
library MagicExplosion initializer Init requires TimerUtils
    
    ////////////////////////////////////////////////////////////////////////////////////
    //                           Start of Configuration                               //
    ////////////////////////////////////////////////////////////////////////////////////
    
    globals
        private constant boolean DMG_ALL = false        //Set to true to damage allies AND enemies
        private constant integer ABIL_CODE = 'Axpl'     //Rawcode of the ability
        private constant integer DUMM_CODE = 'h000'     //Rawcode of the missle dummy
        private constant real DUMM_OFFSET = 200         //Offset of the missle dummy
        
        private constant integer EXPL_CODE = 'h001'     //Rawcode of the Explosion Dummy
        private constant real RADIANS = 0.01745         //Radians per degree
        private constant real SPD = 0.03125             //Speed of the missle. Change not recommended
        private constant boolean ROD = true             //Cancels the spell if the caster dies while casting
        private constant real MOVE_DIST = 30            //Distance between each move tick of the missle
        
        private constant real RADIUS = 350              //Radius of the blast
        private constant real DAMAGE = 100              //+Damage per level
        private constant real WAIT_TIME = .5            //Time before the missle is sent
        private constant string CAST_ANIM = "Spell"     //Animation name of the casting animation
        private constant string CHAN_ANIM = "Stand Channel"     //Animation name of the channeling animation. Set to "" for no channel animation
        
        //*     Ripple Configuration if Extra FX is on
        //Doesn't work at all =\
        private constant boolean EXTRAFX = TRUE
        
        private constant real DURATION = 4000           //Time in milliseconds the ripple lasts
        private constant real RAD_START = 350           //Start radius of the ripple
        private constant real RAD_END = 350             //End radius of the ripple
        
        private constant real DEPTH = 64                //Depth of the ripple
        private constant real PERIOD = 1                //X ripples per second
        private constant real WIDTH = 125               //Width of the ripples
        
        //*     Thunder clap, for extra boom if extra FX 2 is on
        private constant boolean EXTRAFX2 = true
        
        private constant string TC = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"     //Thunder clap model
        
        //*     Sounds. Cast if Sound FX is on, Explode if Sound FX 2 is on
        private constant boolean SOUNDFX = true
        private constant boolean SOUNDFX2 = true        
        
        private constant string SND_CAST = "EtherealHeavyHit2"
        private constant string SND_EXPLODE = "RockHeavyBashMetal2"
        private constant real VOLUME = 100              //Volume in percent
        
    endglobals
    
    ////////////////////////////////////////////////////////////////////////////////////
    //                           End of Configuration                                 //
    ////////////////////////////////////////////////////////////////////////////////////

    //Function to square a real. I feel it's a bit easier to do Sq(r) than Pow(r, 2)
    private function Sq takes real x returns real
        return x * x
    endfunction
    
    //My distance function. Added to take up space <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    private function Distance takes real x1, real x2, real y1, real y2 returns real
        local real r
        set r = SquareRoot(Sq(x2 - x1) + Sq(y2 - y1))
        return r
    endfunction
    
    private function NewSound takes string soundName, real volumePercent, real x, real y, real z returns nothing
        local integer result = R2I(volumePercent * I2R(127) * 0.01)
        local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, &quot;&quot;)
        
        call StartSound(soundHandle)
        call KillSoundWhenDone(soundHandle)
        
        if (result &lt; 0) then
            set result = 0
        elseif (result &gt; 127) then
            set result = 127
        endif
    
        call SetSoundPosition(soundHandle, x, y, z)
        call SetSoundVolume(soundHandle, result)
        
        call StartSound(soundHandle)
        call KillSoundWhenDone(soundHandle)
    endfunction
    
    private function Ripple takes real x, real y returns terraindeformation
        local terraindeformation td
        local real spaceWave
        local real timeWave
        local real radiusRatio
    
        if (RAD_END &lt;= 0 or WIDTH &lt;= 0 or PERIOD &lt;= 0) then
            return null
        endif

        set timeWave = 2.0 * DURATION / PERIOD
        set spaceWave = 2.0 * RAD_END / WIDTH
        set radiusRatio = RAD_START / RAD_END

        set td = TerrainDeformRipple(x, y, RAD_END, DEPTH, R2I(DURATION), 1, spaceWave, timeWave, radiusRatio, false)
        return td
    endfunction
    
    private struct Data
        unit u
        real x
        real y
        real x2
        real y2
        
        real ox
        real oy
        real angle
        real dist
        player p
        
        unit dummy
        
        static method create takes unit u, real x2, real y2 returns Data
            local Data d = Data.allocate()
            local real angle = GetUnitFacing(u)
            local real x = GetUnitX(u)
            local real y = GetUnitY(u)
            
            set d.x2 = x2
            set d.y2 = y2
            
            set d.angle = angle
            set d.u = u
            set d.dist = Distance(x, x2, y, y2)
            
            set d.x = x
            set d.y = y
            set d.ox = x + DUMM_OFFSET * Cos(angle * RADIANS)
            set d.oy = y + DUMM_OFFSET * Sin(angle * RADIANS)
            
            set d.p = GetOwningPlayer(u)
            call PauseUnit(u, true)
            call SetUnitAnimation(u, CAST_ANIM)
            return d
        endmethod
        
        static method FX takes real x, real y returns nothing
        
            static if EXTRAFX then
                call Ripple(x, y)
            endif
            
            static if EXTRAFX2 then
                call DestroyEffect(AddSpecialEffect(TC, x, y))
            endif
            
            static if SOUNDFX2 then
                call NewSound(SND_EXPLODE, VOLUME, x, y, 0)
            endif
            
        endmethod
        
        static method CastFX takes real x, real y returns nothing
        
            static if SOUNDFX then
                call NewSound(SND_CAST, VOLUME, x, y, 0)
            endif
            
        endmethod
    endstruct
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == ABIL_CODE
    endfunction
    
    private function CheckBool takes nothing returns boolean
        if EXTRAFX then
            return true
        elseif EXTRAFX2 then
            return true
        elseif SOUNDFX then
            return true
        elseif SOUNDFX2 then
            return true
        endif
        return false
    endfunction

    private function Check takes nothing returns boolean
        if DMG_ALL then
            return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0
        endif
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
    endfunction
    
    private function CallBack takes nothing returns nothing
        local Data d = GetTimerData(GetExpiredTimer())
        local timer t = GetExpiredTimer()
        local real x = GetUnitX(d.dummy)
        local real y = GetUnitY(d.dummy)
        local group g = CreateGroup()
        local unit u
        
        if d.dist &gt; MOVE_DIST then
            set d.ox = x + MOVE_DIST * Cos(d.angle * RADIANS)
            set d.oy = y + MOVE_DIST * Sin(d.angle * RADIANS)
            set d.dist = d.dist - 30
            call SetUnitX(d.dummy, d.ox)
            call SetUnitY(d.dummy, d.oy)
        else
            call ReleaseTimer(t)
            call GroupEnumUnitsInRange(g, x, y, RADIUS, Condition(function Check))
            call KillUnit(CreateUnit(d.p, EXPL_CODE, x, y, d.angle))
            
            loop   
                set u = FirstOfGroup(g)
                call GroupRemoveUnit(g, u)
                exitwhen u == null
                call UnitDamageTarget(d.u, u, DAMAGE, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                set u = null
            endloop
            
            call SetUnitAnimation(d.u, &quot;Stand&quot;)
            if CheckBool() then
                call d.FX(x, y)
            endif
            call RemoveUnit(d.dummy)
            call PauseUnit(d.u, false)
        endif
    endfunction

    private function Actions takes nothing returns nothing
        local location l = GetSpellTargetLoc()
        local unit u = GetSpellAbilityUnit()
        local real x = GetLocationX(l)
        local real y = GetLocationY(l)
        local Data d = Data.create(u, x, y)
        local timer t = NewTimer()
        local timer f = NewTimer()
        
        call RemoveLocation(l)
        set d.dummy = CreateUnit(d.p, DUMM_CODE, d.ox, d.oy, d.angle)
        
        call TriggerSleepAction(WAIT_TIME)
        if CHAN_ANIM == &quot;&quot; then
            call SetUnitAnimation(u, CAST_ANIM)
        else
            call SetUnitAnimation(u, CHAN_ANIM)
        endif
        
        call d.CastFX(x, y)
        call SetTimerData(t, d)
        call TimerStart(t, SPD, true, function CallBack)
    endfunction

    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( trig, Condition( function Conditions ) )
        call TriggerAddAction( trig, function Actions )
    endfunction

endlibrary


Ripple doesn't show, sound doesn't work (More worried about the ripple than the sound right now)

EDIT: posted before I did :p

There's a UnitAlive native? hmm.. never seen that.
 

Bribe

vJass errors are legion
Reaction score
67
> I know about that :p I like to do things that don't really matter like that to take up space. It doesn't make my eyes bleed as badly.

The way you did it makes my eyes bleed. But, then again, there are some people crazy enough to prefer unindented code, so, you have at it.


> Well it doesn't quite matter whether I store it in a variable before I use it, which leads to you contradicting yourself a little bit on this part

Storing it in a variable first = less typing & using "t" is much much faster than calling GetExpiredTimer() twice. The word "contradicting" doesn't even make sense here, did you choose the right word?


> if it was found more efficient then I should leave the timer and data locations alone, no?

Using locations like you've done here, is not even remotely pointing toward the direction of efficiency. You're barely scraping the bottom of memory leaking, and even then, when you "destroy" something in JASS, it is not being 100% destroyed.


> One thing I've noticed about that though, is that I use the variables a few times. May look good on the top buutt..... might just lead to very long lines.

I think you don't understand the concept of JASS scripting.

JASS:

SetUnitPosition(u, GetSpellTargetX(), GetSpellTargetY())

// is faster than

real x= GetSpellTargetX()
real y= GetSpellTargetY()
SetUnitPosition(u, x, y)

// but not just that, you&#039;re using...

location x = GetSpellTargetLoc() //just don&#039;t locations, they&#039;re pieces of crap.
 

Tyman2007

Ya Rly >.
Reaction score
74
well.. ignore what I said in my earlier post... Got 3 hours of sleep that day :p

Tried my hardest to avoid the use of a location, but I didn't know that you could use GetSpellTargetX/Y at the time.

Anyway.. My trigger doesn't seem to work with ripple or sounds. If anyone could help me out there, you'd have my gratitude :p I'm not worried about optimization atm, so please don't worry too much about that..
 

Sevion

The DIY Ninja
Reaction score
413
JASS:
private function Check takes nothing returns boolean
    if DMG_ALL == true then
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0
    endif
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction

//should be:

private function Check takes nothing returns boolean
    static if DMG_ALL then
        return GetWidgetLife(GetFilterUnit()) &gt; 0.435
    else
        return GetWidgetLife(GetFilterUnit()) &gt; 0.435 and IsUnitEnemy(GetFilterUnit(), GetTriggerPlayer())
    endif
endfunction


Wtf?

Why would you do that?

Just leave it as the first one... If DMG_ALL is true, it'll return the first boolean and terminate the function. There's no need for the "else" in there....

just don't locations, they're pieces of crap.

What? Since when? There are certain advantages that locations have over coordinates and vice versa.
 

Bribe

vJass errors are legion
Reaction score
67
> Wtf? Why would you do that? Just leave it as the first one... If DMG_ALL is true, it'll return the first boolean and terminate the function. There's no need for the "else" in there....

static if, as I'm sure you are well-aware of, is a compile-time deal that simply ignores code if it does not qualify. So, in the war3map.j file, if you don't include the "else", and DMG_ALL IS <true>, you'll have two return values. By using the else, there will be just that one return value so JassHelper will inline it. So, it's obviously not useless at all.


> What? Since when? There are certain advantages that locations have over coordinates and vice versa.

Locations are essentially for [ljass]GetLocationZ()[/ljass] at this point in JASS, which should only be accompanied by [ljass]MoveLocation[/ljass] of a preplaced global variable, not in the sense of GetSomethingLoc. Nearly everything should be using coordinates/vectors.

There's only one use other than that which I've seen, and it's check if a location is <null>. That's one exception out of thousands of better uses.
 

Sevion

The DIY Ninja
Reaction score
413
1) I didn't see the "static" and I only skimmed the thread. My mistake.

2) Actually, there are lots more advantages of locations including the ones you named.

For example, you can't reference via coords can you ;) GetHandleId(coord?)
 

Bribe

vJass errors are legion
Reaction score
67
Why would that matter except in debugging?

If you are using Anitarf's Vector Libarary, you can always do [ljass]BJDebugMsg(I2S(vec))[/ljass]

Please, give me any other uses of locations beyond what's already stated which are more advantagious (without sacrificing performance) than coordinates.
 

Sevion

The DIY Ninja
Reaction score
413
[ljass]call SaveInteger(thistype.hash, GetHandleId(something), GetHandleId(myLocation), this)[/ljass]
 

Bribe

vJass errors are legion
Reaction score
67
Curious, how can you use a location as a reference like that, in the in-game sense?
 

Sevion

The DIY Ninja
Reaction score
413
Imagine you have 50 objects referencing one location. You move that location. Now all 50 objects are pointing to that new location (still).

If you have 50 objects referencing reals, you set object 1's coords to something else. You want all 49 others to be the same. You have to loop through and set the coords.

That's one example.

Example two, say you want to save a struct instance to Unit,Location. You can't do Unit,X,Y can you?

That's the example shown above.

Sure, you can use Vector Lib, but are you going to require that for EVERY library that uses coords? I prefer not to.

I prefer to use XY when it's more convenient and efficient, but Locations when it's even more convenient. And they aren't slow as many believe them to be.

There are many more. These are just two.
 

Bribe

vJass errors are legion
Reaction score
67
Imagine you have 50 objects referencing one vector. You move that vector. Now all 50 objects are pointing to that new vector (still).

If you have 50 objects referencing reals, you set object 1's coords to something else. You want all 49 others to be the same. You have to loop through and set the coords.

That's one example.

Example two, say you want to save a struct instance to Unit,vector. You can't do Unit,X,Y can you?

That's the example shown above.

Sure, you can use Locations, I prefer not to. Having a vector library requirement is a simple bit of extra typing, compared to typing "RemoveLocation(loc)" over and over, and putting so much stress on the computer to do things like "GetLocationX/Y".

I prefer to use XY when it's more convenient and efficient, but Vectors when it's even more convenient. And they aren't pitiful like locations.

There are many more. These are just two.

Curious to know what other uses locations have, since you've given me nothing vectors can't do 10x better.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top