• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Game Caches

Level 24
Joined
Jun 14, 2005
Messages
2,506
Introduction
This tutorial will tell you how to move units and other things from map to map. Remember that Game Caches can not be used on Battle Net, and are almost only ever used for campaigns.

Creating the Game Cache

The first thing you want to do is to create a variable for the Game Cache, go into the Variale editor and create a new Game Cache, like in the pictures bellow.

Click the "X" sign to open the variable editor, and create a new one like so:
attachment.php



Then when the Game Caches variable has been created use this trigger to create the Game Cache.
You can name your gamecache anything you'd like (it is "TutorialCache.w3v" in this tutorial), but do not put
any spaces in it.

  • Create Cache
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game Cache - Create a game cache from TutorialCache.w3v
      • Set TutorialCache = (Last created game cache)
      • Game Cache - Save TutorialCache
Storing Heros and Other Things

Now i'll show you how to store things using a Game Cache. The following trigger can be used to store a hero.

  • Store Hero
    • Events
    • Conditions
    • Actions
      • Game Cache - Store Paladin 0032 <gen> as Paladin of Heros in TutorialCache
      • Game Cache - Save TutorialCache
      • Trigger - Run Store Gold <gen> (ignoring conditions)
Remember that you will have to create all the nesecary variables in order for the triggers to work. This next trigger will show you how to store a players gold or lumber. This will require a variable, unlike storing a hero.

  • Store Gold
    • Events
    • Conditions
    • Actions
      • Set Gold = (Player 1 (Red) Current gold)
      • Game Cache - Store Gold as Gold of Recources in TutorialCache
      • Game Cache - Save TutorialCache
      • Trigger - Run Store Hero Name <gen> (ignoring conditions)
This next trigger will show you how to store a heros proper name, and one of the ways it can be used in a different map.

  • Store Hero Name
    • Events
    • Conditions
    • Actions
      • Set HeroName = (Proper name of Paladin 0032 <gen>)
      • Game Cache - Store HeroName as HeroName of Heros in TutorialCache
      • Game Cache - Save (Last created game cache)
      • Trigger - Run End Game <gen> (ignoring conditions)
This will also require a variable.

Restoring things from the Game Cache

I am now going to show you how to restore all these things in a different map. The first thing we need to do is the re-create all the variables. It makes it alot easier if the new variables in the new map are the same as in the old map. After all the required variables have been made make this trigger.

  • Load Game Cache
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game Cache - Create a game cache from TutorialCache.w3v
      • Set TutorialCache = (Last created game cache)
Now that the Game Cache has been re-created we can restore our heros, gold and hero names. This next trigger is used to restore the hero.

  • Restore Gold
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Gold = (Load Gold of Recources from TutorialCache)
      • Player - Set Player 1 (Red) Current gold to Gold
Now that our gold has been restored we can make a text message appear on the screen saying Your heros proper name is the last game was: and have the heros proper name appear. You can do this with almost anything. Heres the trigger for it.

  • Restore Hero Name
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set HeroName = (Load HeroName of Heros from TutorialCache)
      • Game - Display to (All players) for 20.00 seconds the text: (Your heros proper name is the last game was: + (Load HeroName of Heros from TutorialCache))
Conclusion

I hope you now find Game Caches alot easier, if you would like to ask me anything just private message me or email me at [email protected]. If you need it you maybe download the demo Here.
 

Attachments

  • variable2tu.gif
    variable2tu.gif
    5 KB · Views: 2,769
Last edited by a moderator:
Level 13
Joined
Jun 22, 2004
Messages
783
Bob27 said:
Nah Game Caches can be used in b.net, its just when u exit the game or b.net (either one) the Cache is completly useless and will not work.

Thats why its not handy to really use in multiplayer made, making a load/save key is way better ^_^.

but like said above, nice tutorial.
 
Level 1
Joined
Nov 4, 2014
Messages
1
Below the sentence :Creating the Game Cache

The first thing you want to do is to create a variable for the Game Cache, go into the Variale editor and create a new Game Cache, like in the pictures bellow. : two photos only show this
variableeditor5wa.gif





What do?
 
Post in Triggers&Scripts with your triggers. People may be able to help you more quickly in that section. :)

Make sure that you have something that actually runs "Store Hero"/"Store Gold"/"Store Hero Name". In the tutorial, those triggers don't have any events so they should be ran from an external trigger. Otherwise nothing ever gets saved.
 
It's important to know that game cache's name shouldn't contain a space else it won't work. InitGameCache("game cache.w3v") doesn't work, InitGameCache("gamecache.w3v") works.

I wonder tho where (in which directory) are cache files got saved? Is it even visible?

Updated.

I assume it is in "/Save/Profile#/gamecache.w3v". I haven't checked though.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
Updated.

I assume it is in "/Save/Profile#/gamecache.w3v". I haven't checked though.

No, they aren't there.
I have auto save system in my map using game caches, named it with "dc_#.w3v", # is version number from one and it has reached 20 by now. Means the older versions contain flaws so they are no longer used. I want to remove them so they won't become trashes somewhere in my disk. But I can't find them even after using the search feature.
 
No, they aren't there.
I have auto save system in my map using game caches, named it with "dc_#.w3v", # is version number from one and it has reached 20 by now. Means the older versions contain flaws so they are no longer used. I want to remove them so they won't become trashes somewhere in my disk. But I can't find them even after using the search feature.

Sorry, it is actually within "/Save/Profile#/Campaigns.w3v" as an aggregate.
 
Level 19
Joined
Jul 2, 2011
Messages
2,162
I don't understand the purpose of this code?

you can do the same thing within the world editor by exporting all object data.

why is this extraordinarily long version better?

ps, exporting via the world editor doesn't limit your maps to campaigns
 
Level 18
Joined
Oct 17, 2012
Messages
818
I don't understand the purpose of this code?

you can do the same thing within the world editor by exporting all object data.

why is this extraordinarily long version better?

ps, exporting via the world editor doesn't limit your maps to campaigns

Game Caches do not transfer object data, but game data, such as hero levels, lumber amount, health of hero, etc. At the very least, game caches were used for that purpose.

When there is a tutorial that is supposed to explain?

What?
 
Level 19
Joined
Jul 2, 2011
Messages
2,162
@GhostHunter123

sorry didn't see your message...

game data like hero levels, now that explains it. much better. now I just wonder why this tool is in the grave yard.

ps... is there a tool to perfectly transfer object data from one map to another without erasing old data? (I'm taking about units and items...etc not levels and resources)
 
So what's preventing sending/receiving cache files from third-party server? That could facilitate real large-scale MMOs.
Although I guess latency would be brutal.

there are a couple of issues kinda preventing that: (1) gamecaches don't get stored to disk in multiplayer iirc (2) the files can be large (3) it is hard to design your map around that, especially if the cache can change at any time

Usually with MMOs you'll want to only stream the info you need. In that case, you can use a custom host-bot and send metadata that'll control sending/receiving data from your server, as shown here:
Web Requests (HTTP) from your map (and more)

And TriggerHappy did make a little mmo demo (or as I like to call it, a demmo) here:
[Role Playing Game] - Warcraft 3 MMO - Persistent Gameplay
 
Top