HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Gamecache real

02-21-2006, 03:37 PM#1
Panto
Greetings. One of these triggers stores the X and Y of a unit. The other gets them back later and compares them with the X and Y of the point the unit is ordered to. Something's going wrong, though, and all 4 reals (both sets of X and Y) are coming up as 0.0000.
Old


Collapse JASS:
//===============================
//   Functions
//===============================
function Trig_Store_origin_Actions takes nothing returns nothing
//== Locals =====================
    local unit unitSoldier = GetEnteringUnit()
    local string stringHandle = null

//== Actions ====================
    if ((GetPlayerController(GetOwningPlayer(unitSoldier)) == MAP_CONTROL_COMPUTER) and (IsUnitType(unitSoldier, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(unitSoldier, UNIT_TYPE_HERO) == false) and (GetUnitUserData(unitSoldier) == 0)) then
        set stringHandle = I2S(Handle2Int(unitSoldier))

        call StoreReal(udg_gcPFW, stringHandle, "realX", GetUnitX(unitSoldier))
        call StoreReal(udg_gcPFW, stringHandle, "realY", GetUnitY(unitSoldier))
    endif

//== Cleanup ====================
    set unitSoldier = null
endfunction

//===============================
//   Events
//===============================
function InitTrig_Store_origin takes nothing returns nothing
    set gg_trg_Store_origin = CreateTrigger()
    call TriggerRegisterEnterRectSimple(gg_trg_Store_origin, GetPlayableMapRect())
    call TriggerAddAction(gg_trg_Store_origin, function Trig_Store_origin_Actions)
endfunction
Collapse JASS:
//===============================
//   Functions
//===============================
function Trig_Ignore_guard_Actions takes nothing returns nothing
//== Locals =====================
    local unit unitSoldier = GetOrderedUnit()
    local string stringHandle = null
    local location locOrder = null
    local real realXOrigin = 0
    local real realYOrigin = 0
    local real realXOrder = 0
    local real realYOrder = 0

//== Actions ====================
    if ((GetIssuedOrderId() == String2OrderIdBJ("attack")) and (GetPlayerController(GetOwningPlayer(unitSoldier)) == MAP_CONTROL_COMPUTER) and (GetUnitUserData(unitSoldier) == 0)) then
        set locOrder = GetOrderPointLoc()
        set realXOrder = GetLocationX(locOrder)
        set realYOrder = GetLocationY(locOrder)
        set stringHandle = I2S(Handle2Int(unitSoldier))

        set realXOrigin = GetStoredReal(udg_gcPFW, stringHandle, "realX")
        set realYOrigin = GetStoredReal(udg_gcPFW, stringHandle, "realY")

        call DisplayTimedTextToForce(GetPlayersAll(), 5.00, ("XOrder " + R2S(realXOrigin) + ", YOrder " + R2S(realYOrigin) + ", XOrigin " + R2S(realXOrigin) + ", YOrigin " + R2S(realYOrigin)))

        if ((realXOrder == realXOrigin) and (realYOrder == realYOrigin)) then
            call SetUnitUserData(unitSoldier, 1)
            call RemoveGuardPosition(unitSoldier)

            call FlushStoredReal(udg_gcPFW, stringHandle, "realX")
            call FlushStoredReal(udg_gcPFW, stringHandle, "realY")
        endif
    endif

//== Cleanup ====================
    set unitSoldier = null
    call RemoveLocation(locOrder)
    set locOrder = null
endfunction

//===============================
//   Events
//===============================
function InitTrig_Ignore_guard takes nothing returns nothing
    set gg_trg_Ignore_guard = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Ignore_guard, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
    call TriggerAddAction(gg_trg_Ignore_guard, function Trig_Ignore_guard_Actions)
endfunction



The output message comes up as "XOrder 0.0000, YOrder 0.0000, XOrigin 0.0000, YOrigin 0.0000", so both the stored reals and the "target of order" reals are completely lost. There must be some elementary error of conception or implementation, but I'm not sure what.
02-21-2006, 03:50 PM#2
Anitarf
Allright, first of all, you're displaying origin coordinates twice, rather than order once and origin once. So, it's likely that the problem is only with the origin coordinates. To get a better idea regarding what's wrong with those, add some debug messages to the first trigger.
02-21-2006, 03:52 PM#3
MindWorX
This is just a random thing, but what happens if you set "stringHandle" to something else than "null" ?

Edit:
Nevermind, i missread something...
02-21-2006, 05:18 PM#4
Blade.dk
Are you sure the gamecache is initialized?

Else it can be caused by a bug with gamecaches that Vex found: http://www.wc3jass.com/viewtopic.php?t=2334

Try to make a new profile and check with that.
02-21-2006, 06:40 PM#5
Vexorian
make sure the conditions of the first trigger are true
02-22-2006, 04:37 AM#6
Panto
Well, I fixed up the debug info; that was silly of me. Now, however, I have a rougher problem. The values seem to be adding up perfectly, but the units are still returning to their guard position.
Zoom (requires log in)
For reference, these run on map init:
Trigger:
General Initialization
Collapse Events
Map initialization
Conditions
Collapse Actions
Game Cache - Create a game cache from PFW.w3v
Set gcPFW = (Last created game cache)
And these are the message-fixed jass triggers.
Collapse JASS:
//===============================
//   Functions
//===============================
function Trig_Store_origin_Actions takes nothing returns nothing
//== Locals =====================
    local unit unitSoldier = GetEnteringUnit()
    local string stringHandle = null

//== Actions ====================
    if ((GetPlayerController(GetOwningPlayer(unitSoldier)) == MAP_CONTROL_COMPUTER) and (IsUnitType(unitSoldier, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(unitSoldier, UNIT_TYPE_HERO) == false) and (GetUnitUserData(unitSoldier) == 0)) then
        set stringHandle = I2S(Handle2Int(unitSoldier))

        call DisplayTimedTextToForce(GetPlayersAll(), 5.00, ("Store origin: XOrigin " + R2S(GetUnitX(unitSoldier)) + ", YOrigin " + R2S(GetUnitY(unitSoldier))))

        call StoreReal(udg_gcPFW, stringHandle, "realX", GetUnitX(unitSoldier))
        call StoreReal(udg_gcPFW, stringHandle, "realY", GetUnitY(unitSoldier))
    endif

//== Cleanup ====================
    set unitSoldier = null
endfunction

//===============================
//   Events
//===============================
function InitTrig_Store_origin takes nothing returns nothing
    set gg_trg_Store_origin = CreateTrigger()
    call TriggerRegisterEnterRectSimple(gg_trg_Store_origin, GetPlayableMapRect())
    call TriggerAddAction(gg_trg_Store_origin, function Trig_Store_origin_Actions)
endfunction
Collapse JASS:
//===============================
//   Functions
//===============================
function Trig_Ignore_guard_Actions takes nothing returns nothing
//== Locals =====================
    local unit unitSoldier = GetOrderedUnit()
    local string stringHandle = null
    local location locOrder = null
    local real realXOrigin = 0
    local real realYOrigin = 0
    local real realXOrder = 0
    local real realYOrder = 0

//== Actions ====================
    if ((GetIssuedOrderId() == String2OrderIdBJ("attack")) and (GetPlayerController(GetOwningPlayer(unitSoldier)) == MAP_CONTROL_COMPUTER) and (GetUnitUserData(unitSoldier) == 0)) then
        set locOrder = GetOrderPointLoc()
        set realXOrder = GetLocationX(locOrder)
        set realYOrder = GetLocationY(locOrder)
        set stringHandle = I2S(Handle2Int(unitSoldier))

        set realXOrigin = GetStoredReal(udg_gcPFW, stringHandle, "realX")
        set realYOrigin = GetStoredReal(udg_gcPFW, stringHandle, "realY")

        call DisplayTimedTextToForce(GetPlayersAll(), 5.00, ("Ignore guard: XOrder " + R2S(realXOrder) + ", YOrder " + R2S(realYOrder) + ", XOrigin " + R2S(realXOrigin) + ", YOrigin " + R2S(realYOrigin)))

        if ((realXOrder == realXOrigin) and (realYOrder == realYOrigin)) then
            call SetUnitUserData(unitSoldier, 1)
            call RemoveGuardPosition(unitSoldier)

            call FlushStoredReal(udg_gcPFW, stringHandle, "realX")
            call FlushStoredReal(udg_gcPFW, stringHandle, "realY")
        endif
    endif

//== Cleanup ====================
    set unitSoldier = null
    call RemoveLocation(locOrder)
    set locOrder = null
endfunction

//===============================
//   Events
//===============================
function InitTrig_Ignore_guard takes nothing returns nothing
    set gg_trg_Ignore_guard = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Ignore_guard, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
    call TriggerAddAction(gg_trg_Ignore_guard, function Trig_Ignore_guard_Actions)
endfunction
Attached Images
File type: jpgignoreguard.jpg (105.3 KB)
02-22-2006, 04:50 AM#7
Panto
Wait! I got it!

I needed to pause the unit before and unpause it after the call to ignore guard position.

Now, as far as I can tell, it works great! Thanks for the insight.