• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Jass Game Cache problem

Status
Not open for further replies.
Level 20
Joined
Jan 6, 2008
Messages
2,627
Umm, its basicly a jass problem, so i thought that would be the prefix, as i use custom scripts tho xD...

Okay, i use a load trigger, which looks like this:
  • Load
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Game Cache - Create a game cache from Map1.w3v
      • Set GameCache = (Last created game cache)
      • Set Point = (Player 1 (Red) start location)
      • Game Cache - Restore Hero of Hero from GameCache for Player 1 (Red) at Point facing 0.00
      • Set Unit = (Last restored unit)
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call SaveGameCache(udg_GameCache)
      • Game Cache - Create a game cache from Map1.w3v
      • Set InvCache = (Last created game cache)
      • Custom script: call SaveGameCache(udg_InvCache)
      • Wait 0.01 seconds
      • For each (Integer A) from 1 to 1000, do (Actions)
        • Loop - Actions
          • Custom script: set udg_GameCacheIntegerY[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, "Y+I2S([bj_forLoopAIndex])", "Category")
          • Custom script: set udg_GameCacheIntegerX[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, "X+I2S([bj_forLoopAIndex])", "Category")
          • Custom script: set udg_CacheString[bj_forLoopAIndex] = GetStoredString(udg_InvCache, "S+I2S([bj_forLoopAIndex])", "Category")
      • Wait 0.01 seconds
      • Game - Display to (All players) the text: (String(GameCacheIntegerX[12]))
      • For each (Integer A) from 1 to 1000, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CacheString[(Integer A)] Equal to ES
            • Then - Actions
              • Game - Display to (All players) the text: :>
              • Game - Display to (All players) the text: (String(GameCacheIntegerX[(Integer A)]))
              • Set Point = (Point((Real(GameCacheIntegerX[(Integer A)])), (Real(GameCacheIntegerY[(Integer A)]))))
              • Destructible - Create a Empty Slot at Point facing 0.00 with scale 0.75 and variation 1
              • Set SlotDests[(Integer A)] = (Last created destructible)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CacheString[(Integer A)] Equal to EX
            • Then - Actions
              • Set Point = (Point((Real(GameCacheIntegerX[(Integer A)])), (Real(GameCacheIntegerY[(Integer A)]))))
              • Destructible - Create a Exit at Point facing 0.00 with scale 0.75 and variation 1
              • Set SlotDests[(Integer A)] = (Last created destructible)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CacheString[(Integer A)] Equal to DR
            • Then - Actions
              • Set Point = (Point((Real(GameCacheIntegerX[(Integer A)])), (Real(GameCacheIntegerY[(Integer A)]))))
              • Destructible - Create a Drop at Point facing 0.00 with scale 0.75 and variation 1
              • Set SlotDests[(Integer A)] = (Last created destructible)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
      • Custom script: call SaveGameCache(udg_InvCache)

The save trigger is like this

  • GameCache
    • Events
      • Time - Elapsed game time is 0.69 seconds
    • Conditions
    • Actions
      • Game Cache - Create a game cache from Map1.w3v
      • Set InvCache = (Last created game cache)
      • Wait 0.01 seconds
      • Destructible - Pick every destructible in Region 004 <gen> and do (Actions)
        • Loop - Actions
          • Set InvInt = (InvInt + 1)
          • Set GameCacheIntegerX[InvInt] = (Integer((X of (Position of (Picked destructible)))))
          • Set GameCacheIntegerY[InvInt] = (Integer((Y of (Position of (Picked destructible)))))
          • Game Cache - Store TrackX[InvInt] as (X + (String(InvInt))) of Category in InvCache
          • Game Cache - Store TrackY[InvInt] as (Y + (String(InvInt))) of Category in InvCache
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Empty Slot
            • Then - Actions
              • Set CacheString[InvInt] = ES
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Exit
            • Then - Actions
              • Set CacheString[InvInt] = EX
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Drop
            • Then - Actions
              • Set CacheString[InvInt] = DR
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Background
            • Then - Actions
              • Set CacheString[InvInt] = B1
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Background
            • Then - Actions
              • Set CacheString[InvInt] = B2
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Border1
            • Then - Actions
              • Set CacheString[InvInt] = BO1
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Border2
            • Then - Actions
              • Set CacheString[InvInt] = BO2
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Border3
            • Then - Actions
              • Set CacheString[InvInt] = BO3
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Border4
            • Then - Actions
              • Set CacheString[InvInt] = BO4
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Corner1
            • Then - Actions
              • Set CacheString[InvInt] = C1
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Corner2
            • Then - Actions
              • Set CacheString[InvInt] = C2
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Corner3
            • Then - Actions
              • Set CacheString[InvInt] = C3
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Corner4
            • Then - Actions
              • Set CacheString[InvInt] = C4
            • Else - Actions
          • Game Cache - Store CacheString[InvInt] as (S + (String(InvInt))) of Category in InvCache
      • Custom script: call SaveGameCache(udg_InvCache)


But the

JASS:
Custom script:   set udg_GameCacheIntegerY[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, "Y+I2S([bj_forLoopAIndex])", "Category")
Custom script:   set udg_GameCacheIntegerX[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, "X+I2S([bj_forLoopAIndex])", "Category")
Custom script:   set udg_CacheString[bj_forLoopAIndex] = GetStoredString(udg_InvCache, "S+I2S([bj_forLoopAIndex])", "Category")

Wont load

btw: Big credits to TriggerHappy who gave me the functions xD
 
Level 20
Joined
Jan 6, 2008
Messages
2,627
hmm, created a syntax, i can work in jass if needed...
JASS:
call InitGameCacheBJ( "Map1.w3v" )
    set udg_InvCache = GetLastCreatedGameCacheBJ()
    call SaveGameCache(udg_InvCache)
    call TriggerSleepAction( 0.02 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 1000
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_GameCacheIntegerY[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, "Y+I2S([bj_forLoopAIndex])", "Y")
        set udg_GameCacheIntegerX[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, "X+I2S([bj_forLoopAIndex])", "X")
        set udg_CacheString[bj_forLoopAIndex] = GetStoredString(udg_InvCache, "S+I2S([bj_forLoopAIndex])", "S")
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DisplayTextToForce( GetPlayersAll(), I2S(udg_GameCacheIntegerX[12]) )
    call TriggerSleepAction( 0.02 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 1000
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_Load_Copy_Func015Func001C() ) then
            call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_021" )
            call DisplayTextToForce( GetPlayersAll(), I2S(udg_GameCacheIntegerX[GetForLoopIndexA()]) )
            set udg_Point = Location(I2R(udg_GameCacheIntegerX[GetForLoopIndexA()]), I2R(udg_GameCacheIntegerY[GetForLoopIndexA()]))
            call CreateDestructableLoc( 'B609', udg_Point, 0.00, 0.75, 1 )
            set udg_SlotDests[GetForLoopIndexA()] = GetLastCreatedDestructable()
            call RemoveLocation(udg_Point)
        else
        endif
        if ( Trig_Load_Copy_Func015Func002C() ) then
            set udg_Point = Location(I2R(udg_GameCacheIntegerX[GetForLoopIndexA()]), I2R(udg_GameCacheIntegerY[GetForLoopIndexA()]))
            call CreateDestructableLoc( 'B60A', udg_Point, 0.00, 0.75, 1 )
            set udg_SlotDests[GetForLoopIndexA()] = GetLastCreatedDestructable()
            call RemoveLocation(udg_Point)
        else
        endif
        if ( Trig_Load_Copy_Func015Func003C() ) then
            set udg_Point = Location(I2R(udg_GameCacheIntegerX[GetForLoopIndexA()]), I2R(udg_GameCacheIntegerY[GetForLoopIndexA()]))
            call CreateDestructableLoc( 'B60L', udg_Point, 0.00, 0.75, 1 )
            set udg_SlotDests[GetForLoopIndexA()] = GetLastCreatedDestructable()
            call RemoveLocation(udg_Point)
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call SaveGameCache(udg_InvCache)
endfunction

//===========================================================================
function InitTrig_Load_Copy takes nothing returns nothing
    set gg_trg_Load_Copy = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Load_Copy, 0.01 )
    call TriggerAddAction( gg_trg_Load_Copy, function Trig_Load_Copy_Actions )
endfunction

Is there another way to load it? :>
 
Level 20
Joined
Jan 6, 2008
Messages
2,627
The problem is the same :S,

  • Load
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Game Cache - Create a game cache from Map1.w3v
      • Set GameCache = (Last created game cache)
      • Set Point = (Player 1 (Red) start location)
      • Game Cache - Restore Hero of Hero from GameCache for Player 1 (Red) at Point facing 0.00
      • Set Unit = (Last restored unit)
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call SaveGameCache(udg_GameCache)
      • Game Cache - Create a game cache from Map1.w3v
      • Set InvCache = (Last created game cache)
      • Custom script: call SaveGameCache(udg_InvCache)
      • Wait 0.02 seconds
      • For each (Integer A) from 1 to 1000, do (Actions)
        • Loop - Actions
          • Set LoadString = (Y + (String((Integer A))))
          • Custom script: set udg_GameCacheIntegerY[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, udg_LoadString, "Y")
          • Set LoadString = (X + (String((Integer A))))
          • Custom script: set udg_GameCacheIntegerX[bj_forLoopAIndex] = GetStoredInteger(udg_InvCache, udg_LoadString, "X")
          • Set LoadString = (S + (String((Integer A))))
          • Custom script: set udg_CacheString[bj_forLoopAIndex] = GetStoredString(udg_InvCache, udg_LoadString, "S")
      • Custom script: call SaveGameCache(udg_InvCache)
      • Game - Display to (All players) the text: (String(GameCacheIntegerX[12]))
      • Wait 0.02 seconds
      • For each (Integer A) from 1 to 1000, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CacheString[(Integer A)] Equal to ES
            • Then - Actions
              • Game - Display to (All players) the text: :>
              • Game - Display to (All players) the text: (String(GameCacheIntegerX[(Integer A)]))
              • Set Point = (Point((Real(GameCacheIntegerX[(Integer A)])), (Real(GameCacheIntegerY[(Integer A)]))))
              • Destructible - Create a Empty Slot at Point facing 0.00 with scale 0.75 and variation 1
              • Set SlotDests[(Integer A)] = (Last created destructible)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CacheString[(Integer A)] Equal to EX
            • Then - Actions
              • Set Point = (Point((Real(GameCacheIntegerX[(Integer A)])), (Real(GameCacheIntegerY[(Integer A)]))))
              • Destructible - Create a Exit at Point facing 0.00 with scale 0.75 and variation 1
              • Set SlotDests[(Integer A)] = (Last created destructible)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CacheString[(Integer A)] Equal to DR
            • Then - Actions
              • Set Point = (Point((Real(GameCacheIntegerX[(Integer A)])), (Real(GameCacheIntegerY[(Integer A)]))))
              • Destructible - Create a Drop at Point facing 0.00 with scale 0.75 and variation 1
              • Set SlotDests[(Integer A)] = (Last created destructible)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
      • Custom script: call SaveGameCache(udg_InvCache)
I mean this would work..
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Check if your value saving system is functioning correctly.

Save a value, then under the same conditions try and recall it. It can be any value like lets say... 2 as long as it is not a default value. Just make sure that you can save and recall information from the cache as it could be an underlying problem with your method you use.

If it does work then the source of the problem is the logic of the code you have written, so run a follow through to check if everything does function as you intend it to.
 
Status
Not open for further replies.
Top