Coordinate Issues..

n[u]ll

You can change this now in User CP.
Reaction score
93
Well, I've got a pretty long JASS function.. So I'll make it short and simple:
JASS:
call CreateUnitAtLoc(Player(bj_PLAYER_NEUTRAL_VICTIM), 'dumy', p2, 0)
call BJDebugMsg(R2S(GetLocationX(GetUnitLoc(GetLastCreatedUnit()))) + " " + R2S(GetLocationY(GetUnitLoc(GetLastCreatedUnit())))) //Retrieve Dummy's location
call BJDebugMsg(R2S(GetLocationX(GetUnitLoc(u))) + " " + R2S(GetLocationY(GetUnitLoc(u)))) //Retrieve MY unit's location


I took out as much variables as I could as to make 100% sure it wasnt an error with any of them..
The remaining variables are:
p2 = My unit's position
u = my unit

It should spawn the dummy directly on top of my unit, well it does.. But when I call for it's location, it gives me:



If you want the full trig (or map) just say so.

+Rep for any help:D
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
dont use a debug message just use display text to player
 

Exide

I am amazingly focused right now!
Reaction score
448
p2 is a location?
You should use coordinates. (x and y)
Show us the complete function.

This should be posted in the JASS forums.


dont use a debug message just use display text to player

There's nothing wrong with BJDebugMsg, as long as you use it for debugging only. (Remove it from the final version of the game.)
 

n[u]ll

You can change this now in User CP.
Reaction score
93
I changed to coordinates like Exide suggested, and changed a bit of the code. Which helped narrow down to the problem.
JASS:
scope BossP2 initializer Init

    globals
        private constant real    Time     = 1
        private constant real    X        = 750
        private constant real    Height   = 750
        private constant boolean Arced    = false
        private constant boolean Paused   = false
        private constant integer Speed    = 1000
        //>> Useless
        private constant boolean AffectZ  = false
        private constant string  Effect   = "" 
        private constant string  EffectAttach  = ""
        private constant string  Art      = ""
        private constant string  ArtAttach  = "" 
        //<<
    endglobals 
 
    private function Conditions takes nothing returns boolean
        return GetBooleanAnd( IsUnitAliveBJ(GetFilterUnit()) == true, GetUnitTypeId(GetFilterUnit()) == 'Edem')
    endfunction    

    private function Actions takes nothing returns nothing
   //>> local variables
        local unit Object = gg_unit_Aglm_0023
        local group g = GetUnitsInRectMatching(gg_rct_BossRectWhole, Condition(function Conditions))
        local unit u = GroupPickRandomUnit(g)
        local unit u2
        local location p1 = GetUnitLoc(Object)
        local integer i = 0
        local real Arc
        local real RadAngle = 270*(bj_PI/180)
        local real Dist = 0.001
        local real FacAngle
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        
    //<<
        //>> Init
            set udg_BossPhase = 2
            loop
                exitwhen i > 11
                call DisplayTextToPlayer(Player(i), 0.5, 0.5, "|CFFFF4800Obsidiarc jumps and slams the ground, stunning all those nearby.|r" )
                set i = i + 1
            endloop
            call PlaySoundBJ(gg_snd_Warning)
        //<<
        //>> Boss Jump
            call JumpTimedEx(Object, RadAngle, X, Time, Dist, Arced, Paused, Effect, EffectAttach, Art, ArtAttach)
        //<<
        call TriggerSleepAction ( 0.45 )
        call SetUnitAnimation(Object, "Spell Slam")
        call TriggerSleepAction ( 1.034 )
        call ResetUnitAnimation(Object)

        //>> Ground Slam
            call SetUnitFacingToFaceUnitTimed( Object, u, 0.25 )
            call TriggerSleepAction ( 0.25 )
            set FacAngle = GetUnitFacing(Object)
            call SetUnitAnimation( Object, "Attack" )
            call TriggerSleepAction( 0.25 )
            call TerrainDeformationWaveBJ( 1.00, p1, Location(x,y), 300.00, -240, 0 )
            call TriggerSleepAction( 0.6 )
            //>> Set Jump Variables
                //>> Get Dist
                    call CreateUnit(Player(bj_PLAYER_NEUTRAL_VICTIM), 'dumy', x, y, FacAngle)
                    set u2 = GroupPickRandomUnit(GetUnitsOfTypeIdAll('dumy'))
                    call BJDebugMsg("The variables X & Y are: " + R2S(x) + " " + R2S(y))
                    call BJDebugMsg("The coords of the Dummy are: " + R2S(GetUnitX(u2)) + " " + R2S(GetUnitY(u2)))
                    call BJDebugMsg("The coords of My unit are: " + R2S(GetUnitX(u)) + " " + R2S(GetUnitY(u)))
                    loop
                        if (RectContainsCoords(gg_rct_JumpBounds, x, y) == false) then
                            call BJDebugMsg("Exiting")
                            exitwhen true
                        endif
                        call SetUnitX(u2,x+2*Cos(0.017453278*GetUnitFacing(u2))) 
                        call SetUnitY(u2,y+2*Sin(0.017453278*GetUnitFacing(u2)))
                        set x = GetUnitX(u2)
                        set y = GetUnitY(u2)
                    endloop
                    call BJDebugMsg("The variables X & Y are: " + R2S(x) + " " + R2S(y))
                    call RemoveUnit(u2)
                //<<
                set RadAngle = Deg2Rad(FacAngle)
                set Arc = 100
                set p1 = GetUnitLoc(u)
                set Dist = DistanceBetweenPoints(Location(x,y), p1)
                set Object = u
            //<<
            call BJDebugMsg("RadAngle = " + R2S(RadAngle) + " Arc = " + R2S(Arc) +  " Dist = " + R2S(Dist) + " Object = " + I2S(GetHandleId(u)))
            call JumpArc(Object, RadAngle, Arc, Speed, Dist, Paused)
        //<<
        call RemoveUnit(u2)
        call RemoveLocation(p1)
        set Object= null
    endfunction

    private function Init takes nothing returns nothing
        local trigger trg = CreateTrigger()
        call TriggerRegisterPlayerChatEvent(trg, Player(0), "-", true)
        call TriggerAddAction( trg, function Actions )
        set trg = null
    endfunction
    
endscope

What I found was that the function GetLastCreatedUnit wasn't registering that I spawned the unit, and reverting to a different unit spawned in a seperate trigger at map init.

I added a little workaround because I could not figure out why it didn't register the dummy being spawned, and now it works just like I had planned, so thanks and cheers!:D



Edit: Oh and btw,
dont use a debug message just use display text to player


BJDebugMsg does this:
JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction
 

Summoned

New Member
Reaction score
51
GetLastCreatedUnit() returns the unit value of bj_lastCreatedUnit (a global unit variable made by blizzard). For it to register properly, you have to create units like this:



When you look at the function for CreateNUnitsAtLoc (the BJ function used in regular GUI), you'll see they use the same creation method.

JASS:
function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction

//which further calls

function CreateUnitAtLocSaveLast takes player id, integer unitid, location loc, real face returns unit
    if (unitid == 'ugol') then
        set bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face)
    else
//this thing
        set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)
//here
    endif

    return bj_lastCreatedUnit
endfunction
 

n[u]ll

You can change this now in User CP.
Reaction score
93
GetLastCreatedUnit() returns the unit value of bj_lastCreatedUnit (a global unit variable made by blizzard).[/jass]
I started learning JASS this week, and I guess I still have a lot to learn.. :D

Just tried that out and it worked flawlessly.
Muchos Gracias!
 
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