wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > Trigger (GUI)/ AI editor Tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-10-2007, 06:35 AM   #1
jonadrian619
User
 
jonadrian619's Avatar
 
Join Date: Oct 2006
Posts: 69

Submissions (9)

jonadrian619 is on a distinguished road (15)

Default Game Cache Tutorial

Game Cache Tutorial


Table of Contents

1) Operating Game Caches
2) Game Cache Actions
3) Saving heroes using Game Caches
4) Advanced Game Cache Techniques

FAQ about Game Caches


1) What is a Game Cache?
A cache is a file created from a map that is saved on your computer thats stores information. The game cache can store information from one level, and load it when you play the next level. It can save objects like a hero, Integer value, Real value or character, and load them again after the level is finished.
2) What is the purpose in creating Game Caches?
The purpose is usual, to save objects or values in a particular level, and load these objects, values again in the next or higher levels. There are other advanced purposes in creating one. They will be discussed later.

Operating Game Caches:
Now, here's where we are standing. Before you create a Game Cache, you should create a Variable first. Go to Variables (With the X icon in it, or hotkey Ctrl+B). Click New Variable and then type the name of your variable. Then set it's type to 'Game Cache'. If you have multiple game caches, check the 'Array' checkbox and set the size (If you have multiple game caches) Then click OK.
Now you have a Game Cache variable which can be used to associate game caches.


Game Cache Actions

Here are the actions of the Game Cache category which are shown in the trigger editor. To create a Game Cache action, click the New Action (Hotkey Ctrl+R) button and click a 'Game Cache - ' Action. Each action has useful details and examples.


Game Cache - Create Game Cache
- Creates a new Game Cache from a map. The Game Cache should be created from your map. Type the map filename in the 'MapName.w3v' field value and change it to your map's filename. The game cache should be from your map so that it's functions will work properly. If the map filename you have typed does not exist, the cache will be created.

Game Cache - Save Game Cache- Saves the game cache, using the same filename from which it was created. If you use the Actions; Store Integer,Boolean, Unit, etc., then using the Save Game Cache action will save those objects and are available for restoration.

Game Cache - Store Unit- Stores unit as a Label in a Category in an existing Game Cache. 2 ways to select a unit. First select a function like last created unit, picked unit, etc. Or to store a particular unit, select a unit in the map then use the unit's variable in the field (ex. Peon 0015 <gen>).
"Store Unit" Field Values
- Store Unit (The field wherein your selected unit will be stored) as Label (The unit's label in a category. You can type any) of Category (The category wherein the label will be saved) in (Last Created Game Cache). You can also change it's value like a Game Cache variable or simply last created game cache.

Game Cache - Store Real- Same as 'Store Unit' but more different. You'll have to store a Real number this time. A Real number is a decimal (ex. 1.00, 1.25, 2.79, etc.).
"Store Unit" Field Values
- Same as the 'Store Unit' fields, but the object stored is a Real number this time. Also create individual categories for the values.

Game Cache - Store Integer- Same as 'Store Unit' but much more different. You'll have to store an Integer this time. An Integer is a non-decimal or plain number. (ex. 1, 2, 3, 4, 5, etc.).
"Store Unit" Field Values
- Same as the 'Store Unit' fields, but the object stored is an Integer this time. Also create individual categories for the values.

Game Cache - Store Boolean- Same as 'Store Unit' but much more different. You'll have to store a Boolean value this time. A Boolean value is a value that associates with events and conditions. (ex. 'A unit enters Region 001' then follows the condition 'Triggering unit is a Hero equal to True'. The Boolean value is set to true, so the unit that enters Region 001 should be a hero. If the condition is met, then the actions will be initiated).
"Store Unit" Field Values
- Same as the 'Store Unit' fields, but the object stored is an Integer this time. Also create individual categories for the values.

Game Cache - Restore Unit Facing Angle- Restores a unit 'Label' from a created Category in a game cache. This action restores or loads a stored unit for a player in a region facing a particular facing angle. The angle is shown in degrees.

Game Cache - Restore Unit Facing Point- Same as the 'Restore Unit Facing Angle' action. But the unit loaded this time faces a region, not the facing angle itself.

Game Cache - Reload All- Reloads all game cache from the computer's disk.

Game Cache - Clear Game Cache- Clears all labels of all categories in a game cache.

Game Cache - Clear Category- Clears all labels of a specific category in a game cache.


Saving heroes using Game Caches
If you are making an RPG map, then this tutorial will definitely be the best support. If you create an RPG game most likely selecting a hero or a builder or anything, you should create a trigger that saves objects, yet it is not initially on,
with the 'initially on' checkbox unchecked. Once your hero is selected, the trigger will be turned on using 'Trigger - Turn On (The name of the trigger). You can make many events. Here are 2 examples of triggers that can be used in saving objects.

Here are Game Caches for the impatient mappers. Try this in an empty map:


Examples:
Trigger:
Save Hero Typing save
Collapse Events
Player - Player 1 (Red) types a chat message containing -save as An exact match
Collapse Conditions
((Triggering player) controller) Equal to User
Collapse Actions
Game Cache - Create a game cache from Game Cache Demo.w3v
Set GameCache = (Last created game cache)
Collapse Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked unit) is A Hero) Equal to True
Collapse Then - Actions
Game Cache - Store (Picked unit) as Heroes of SavedHeroes in GameCache
Trigger - Turn on Load Hero <gen>
Unit - Remove (Picked Unit) from the game
Collapse Else - Actions
Do nothing
In the second trigger you'll have to place a Circle of Power of any size and then create a region in the circle, particularly named
'Save Hero Circle' in my demo map.


Save Hero Enter Region
Trigger:
Collapse Events
Unit - A unit enters Save Hero Circle <gen>
Collapse Conditions
((Triggering unit) is A Hero) Equal to True
Collapse Actions
Game Cache - Create a game cache from Game Cache Demo.w3v
Set GameCache = (Last created game cache)
Game Cache - Store (Triggering unit) as Heroes of SavedHeroes in GameCache
Unit - Remove (Triggering Unit) from the game
Trigger - Turn on Load Hero <gen>
NOTE: After saving a hero, you'll have to create a trigger that turns on the load hero trigger when the hero dies. It isn't
applied in this area of the tutorial. It'll be discussed later

You can also create an enabled but not intitially on trigger that loads the unit in a game cache. Here's an example.


Trigger:
Load Hero
Collapse =Events
Player - Player 1 (Red) types a chat message containing -load as An exact match
Collapse =Conditions
((Triggering player) controller) Equal to User
Collapse =Actions
Game Cache - Restore Heroes of SavedHeroes from GameCache for Player 1 (Red) at (Center of Load Game <gen>) facing Default building facing
Game - Display to (All players) the text: It works!!

You'll see your newly loaded hero with the same hp, mana and attributes unlike before!! That's only for beginners. More types
will be discussed later.

Advanced Game Cache Techniques:

Highly advanced game cache techniques are shown here. Those who want to save more than units and other techniques, are here. Two
detailed techniques are shown.

1) Saving an Army then Loading it again.
It works the same way as of saving a single hero, but much more special and tougher. You'll need to create an army and then
create triggers the same way you create a trigger to save a hero. Try using the action "Unit Group - Pick every unit in (Function) and do Action".
Create a trigger that loads units similar to above, still not initially on. Create a large region for the army to be restored
and make sure nothing is in it. You can then make events to load the army. You can then see your army with the same units and
attributes as of before you stored them.
2) Saving a Whole Town
The most difficult technique where you'll have to create a town that contains lots of units, buildings and heroes.
You'll save your whole town with all the units and buildings. You'll have to load those units just like above. But for this you'll also need to store the x/y coordinates and facing angle etc of all the buildings.

ADDITIONAL TUTORIALS

1) How to save heroes and load them to another map
This is a trigger where in you will save the used hero in the currently played map. I use the hero thrall. You also need a variable.

You can use any event..

Trigger:
Save Thrall
Collapse Events
Magtheridon 0019 <gen> Dies
Conditions
Collapse Actions
Game Cache - Create a game cache from Lvl1Game.w3v
Set HeroCache - (Last Created Game Cache)
Game Cache - Store Thrall 0001 <gen> as Thrall of Lvl1 in HeroCache
Game Cache - Save HeroCache

Then you'll make another trigger in another map to load the hero in the previous map. Always save a game cache before loading it. You need another variable in the other map. In this trigger there are also additional actions like learning skills. I've got it in a campaign map using mpqmaster or winmpq, opened the map and saw the triggers

Trigger:
Load Thrall in Lvl2Game
Collapse Events
Elapsed game time is 5.00 seconds
Conditions
Collapse Actions
Game Cache - Restore Thrall of Lvl1 from (Last created game cache) for Player 1 (Red) at (Center of ThrallLoad <gen>) facing 360.00
Set Thrall = (Last restored unit)
If (Thrall Not equal to No unit) then do (Skip remaining actions) else do (Do nothing)
-------- Create Default Hero --------
Unit - Create 1 Thrall for Playa1 at (Center of ThrallLoad <gen>) facing 350.00 degrees
Hero - Set (Last created unit) Hero-level to 4, Hide level-up graphics
Hero - Learn skill for (Last created unit): Orc Far Seer - Far Sight
Hero - Learn skill for (Last created unit): Orc Far Seer - Chain Lightning
Hero - Learn skill for (Last created unit): Orc Far Seer - Chain Lightning
Hero - Learn skill for (Last created unit): Orc Far Seer - Feral Spirit
Set Thrall = (Last created unit)



Tutorial Summary
I hope these things have polished some of your triggering skills especially in creating Game Caches.
You can download the attached demo map also.

Written by jonadrian619. View the alternate version of this tutorial in The Helper.net. This tutorial is complete.
Attached Files
File Type: w3x Game Cache Demo.w3x (49.8 KB, 114 views)
__________________




Game Interface Tutorials
Basics | Custom Training Queue
Other Tutorials
How to make Custom Skies

Last edited by PitzerMike : 03-11-2007 at 10:33 PM.
jonadrian619 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-16-2007, 01:00 AM   #2
Anopob
Yay!
 
Anopob's Avatar
 
Join Date: May 2006
Posts: 870

Anopob has a spectacular aura about (120)

Default

Before reading, don't we have a GC tut?

EDIT: Hm, nvm, correct me if I'm wrong though.
__________________
Give +REP to people who help you with things or make good resources.
Better Ways of Requesting For Help - Race Contest #2 WIP Thread (Bone Race)
As of December 1st I have my blue rep. Yay :D

Last edited by Anopob : 02-16-2007 at 01:01 AM.
Anopob is offline   Reply With Quote
Old 03-11-2007, 10:20 PM   #3
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default

Good extension of Bob's game cache tutorial.
I've attached your demo map to your post now and approved this.
__________________
Zoom (requires log in)
PitzerMike is offline   Reply With Quote
Old 12-15-2008, 03:29 AM   #4
CYD
User
 
Join Date: Dec 2008
Posts: 5

CYD has little to show at this moment (0)

Default

Hi everyone, I'm new here.

I just wanted to ask a small question to the author of this good tutorial :

I'm doing a RPG, with transitions between two maps - just like the orc Bonus Campaign with Rexxar. Consequently, I have to use the game cache in order to save and restore the hero from one map to the other ... but as far as I try, it doesn't work and the map loaded remains blank of all unit.

I have done well on the first map, and when I type "-load", the hero appears, everything is ok. But, my question is : how can you, on a second map, use a gamecache that has been created for the first map ? I can't seem to find how to do it, to transfer one map's game cache datas to another map.

I would be glad to have some help on this one.

Thank you,
CYD
CYD is offline   Reply With Quote
Old 05-13-2009, 09:11 PM   #5
Verbinguden
User
 
Verbinguden's Avatar
 
Join Date: May 2009
Posts: 2

Verbinguden has little to show at this moment (0)

Default

The only benefits of a game cache is to save memory? To put an individual set of units, spells, and buildings into a game cache, rather than make an individual trigger for each specific one? (As well as a transer between maps, of course)

Is that correct?
Verbinguden is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:33 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services