• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Campaign help

Status
Not open for further replies.

Bod

Bod

Level 2
Joined
May 16, 2009
Messages
9
I have a campaign and there is a problem.the problem is the storing of the heroes.i have searched many guides and forums and i tried with all of their tutorials but it didnt helped.How to store more than one hero and to restore them in the next map?pls help+rep
 
Level 10
Joined
Jan 28, 2009
Messages
442
I have a campaign and there is a problem.the problem is the storing of the heroes.i have searched many guides and forums and i tried with all of their tutorials but it didnt helped.How to store more than one hero and to restore them in the next map?pls help+rep

Then you probably learned something about game caches. And I hope you know about 2d arrays too. You can check the "Array" box in the variable manager to make a variable array. The variable will then be able to store multiple values, and you can refer to each by putting a number into the brackets [] after the variable name: "HeroName[7]". In essence, an array is a list of the same variable type with the same name.

Arrays are always a good starting point. By using them, you can make a count integer, which counts something (how many heroes there are, for instance). By making a unit array, you can have a variable for each hero, and refer to them as 1, 2, 3, etc. in brackets.

You may thus do like this:
  • Actions
    • For each Integer A from 1 to HeroCount loop actions
      • Game Cache - Store (Hero[Integer A]) as (HeroLabel[Integer A]) of Heroes in MyCache
    • Game Cache - Save game cache MyCache
How to restore...
You need to recreate the cache first. It's always a good idea to have some base triggers that look exactly the same in all your missions. Game caches go to your generic campaign triggers. So you'll use the same variables when you recreate the game cache. I hope this was enough help.
 
  • Like
Reactions: Bod
Status
Not open for further replies.
Top