HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Loading and Saving heroes/stuff

08-19-2003, 08:23 PM#1
TheBestofDaBest
Post your way of doing so here. Maybe we can get such a advanced way of doing this we might not need a full proof saving system like d2 has for example. So basically lets all combine ideas here! k thx. I'm ArmyOfDark-Ness the creator of GDE :).

I will be posting my way here as well.. I will upgrade it in the future a lot more so its not so easily cheatable on... like it is currently with items lol.
09-16-2003, 08:28 PM#2
fenrirknight
What exactly do you mean?

If you mean saving a character on a map and then loading it up later, or switching maps and loading it up on the next map, here's how I do it. As far as I know it's pretty much the only way to do it.

When the map ends, first you have to create a game cache:
"Game Cache - Create a game cache from GameCacheName.w3v"

Then for each hero you want to store you do the following (Note: "HeroA" is a unit variable representing the hero you want to store; "HeroALife", "HeroAMana", and "HeroAUnit" are just string values representing the thing you store in the game cache; and "HeroStatus" is just a category within the game cache that you can use to sort different types of info that you carry from one map to the next.):

"Game Cache - Store (Percentage life of HeroA) as HeroALife of HeroStatus in (Last created game cache)"
"Game Cache - Store (Percentage mana of HeroA) as HeroAMana of HeroStatus in (Last created game cache)"
"Game Cache - Store HeroA as HeroAUnit of HeroStatus in (Last created game cache)"

...and any other non-status information about the Hero you want to store, like string values for what class the character is or any other variables you are using to keep track of the unit somehow. Afterwards run the trigger "Game Cache - Save (Last created game cache)."

When you are ready to reload the hero, you run these triggers:

"Game Cache - Create a game cache from GameCacheName.w3v" (this is so the new map you've loaded up will load up info from this particular game cache)

"Game Cache - Restore HeroAUnit of HeroStatus from (Last created game cache) for Player 1 (Red) at (Random point in Entrance <gen>) facing 45.00" (The restored unit will have all of its previous items, levels, skills, etc. BUT NOT the same amount of life and mana as before, so you need...)

"Unit - Set life of (Last restored unit) to (Load HeroALife of HeroStatus from (Last created game cache))%"

"Unit - Set mana of (Last restored unit) to (Load HeroAMana of HeroStatus from (Last created game cache))%"

...as well as loading any other variable info that you stored before. Then you can set the variables again, such as... "Set HeroA = (Last restored unit)."


Well I hope that's the info you were looking for.
09-17-2003, 12:13 AM#3
Zycat
What about with JASS functions? Inside an A.I? That would be very interesting!
09-17-2003, 02:03 AM#4
fenrirknight
Hmm... I guess I really just don't understand the whole JASS thing. I'm new to the "AI/JASS vault", I guess I'm just exploring it to try and find out just what it is. I don't see how AI scripting has anything to do with saving heroes though... hmm...
01-24-2004, 06:20 PM#5
Drake Eternal
u really only need to load and save the unit

u dont need to load and save its status
01-24-2004, 07:30 PM#6
Vidstige
Good explanation fenrirknight.

Zycat, you could probably figure out how to do that from jass/ai-script by converting the trigger to custom code, and then investigate what that code actually does, like what functions it call, and what those functions call in there turn. It is possible though that the cache can't be used form script, but AIAndy probably knows that...