- Joined
- Mar 3, 2006
- Messages
- 1,564
Transitions in Campaigns Guide
[/TD]
This tutorial will teach you how to make a campaign with multiple maps that you can navigate through, like the 'Orc Bonus Campaign' but in much more advanced fashion.
In fact, Ralle's tutorial inspired me to make this one also with example campaign implemented with the tutorial for more detailed illustration.
Last word before we get started, I am using Blizzard's style and names for the triggers and variable; the reason for that is when I started learning how to make transition I used Blizzard's triggers and learned from it.
Now lets get started,
The idea to link the entire map network is very simple; this idea is giving each map a unique ID; that ID will be the reference to this map in the map network.

As you can see, each area has a number which represents its ID; this ID is the key for making the transition work
Lets see the triggers then ...
Note: You could merge the following triggers' actions if you want but I like Blizzard's Style
A list of common variables and their type: (Sorted by Type)
Variable Name | Variable Type | Initial Value |
TransitionDataHT | Hashtable | - None - |
AreaCount | Integer | 0 (Default) |
AreaIndex | Integer | 0 (Default) |
NHeroes | Integer | 0 (Default) |
RestorePointIndex | Integer | 0 (Default) |
SourceAreaIndex | Integer | 0 (Default) |
TargetAreaIndex | Integer | 0 (Default) |
Controller | Player | - None - |
RestorePoint | Point | - None - |
RestorePointReference | Point Array (20) | - None - |
Facing | Real | 0 (Default) |
FacingRestore | Real Array (20) | 0 (Default) |
AreaName | String | - None - |
CacheName | String | - None - |
MapExtension | String | - None - |
SaveExtension | String | - None - |
TransitionKey | String | - None - |
AreaMap | String Array (20) | - None - |
AreaSave | String Array (20) | <Empty String> |
TransitionHero | Unit | - None - |
Hero | Unit Array (4) | - None - |
The first trigger will be the 'Init SyncData' fired by 'Map Initialization'
-
Initialization
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Trigger - Run Init 01 Players <gen> (checking conditions)
-
Trigger - Run Init 02 Units <gen> (checking conditions)
-
Trigger - Run Init 03 Items <gen> (checking conditions)
-
Trigger - Run Init 04 Quests <gen> (checking conditions)
-
Trigger - Run Init 09 SyncData <gen> (checking conditions)
-
-
-
Init 05 SyncData
-
Events
-
Conditions
-
Actions
-
Trigger - Run Init Zones <gen> (checking conditions)
-
-
This trigger will include all data that need to be synchronized with the other maps as you will see later in this tutorial.
-
Init Zones
-
Events
-
Conditions
-
Actions
-
-------- Current Area ID --------
-
Trigger - Run Identify Area <gen> (checking conditions)
-
-------- General Transition Data --------
-
Set CacheName = CCampaign.w3v
-
Hashtable - Create a hashtable
-
Set TransitionDataHT = (Last created hashtable)
-
Set TransitionKey = (tt + Transitions)
-
Set SaveExtension = .w3z
-
Set MapExtension = .w3x
-
Set AreaCount = 6
-
-------- Area Names --------
-
Set AreaMap[1] = AR0100
-
Set AreaMap[2] = AR0101
-
Set AreaMap[3] = AR0102
-
Set AreaMap[4] = AR0103
-
Set AreaMap[5] = AR0104
-
Set AreaMap[6] = AR0105
-
-------- Restore Points Data --------
-
-------- The 1st number in the hashtable is the child key and it represents the restore position index --------
-
-------- The 2nd number in the hashtable is the parent key and it represents the area index --------
-
Hashtable - Save Handle Of(Center of HeroRestore from Forests <gen>) as 1 of 2 in TransitionDataHT
-
Hashtable - Save Handle Of(Center of HeroRestore from Waterfalls <gen>) as 1 of 3 in TransitionDataHT
-
Hashtable - Save Handle Of(Center of HeroRestore from Caves A <gen>) as 1 of 5 in TransitionDataHT
-
Hashtable - Save Handle Of(Center of HeroRestore from Caves B <gen>) as 2 of 5 in TransitionDataHT
-
Hashtable - Save Handle Of(Center of HeroRestore from Volcano Cave <gen>) as 1 of 6 in TransitionDataHT
-
-------- Restore Facing Angle Data --------
-
Hashtable - Save 270.00 as 1 of 2 in TransitionDataHT
-
Hashtable - Save 0.00 as 1 of 3 in TransitionDataHT
-
Hashtable - Save 270.00 as 1 of 5 in TransitionDataHT
-
Hashtable - Save 90.00 as 2 of 5 in TransitionDataHT
-
Hashtable - Save 180.00 as 1 of 6 in TransitionDataHT
-
-
This trigger is the most important one in transition because this will determine and identify the entire map network. Although most of the following triggers are identical; this one will be different from one map (Area) to another but the top of this trigger will be identical though.
-
Actions
-
-------- Current Area ID --------
-
Trigger - Run Identify Area <gen> (checking conditions)
-
-
Identify Area
-
Events
-
Conditions
-
Actions
-
Set AreaIndex = 1
-
Set AreaName = AR0100
-
-
AreaName, this string will hold the area name, you could name it what you want but its important that this name be unique as well; that's why I am using this name AR####
-
Set CacheName = CCampaign.w3v
-
Actions
-
Hashtable - Create a hashtable
-
TransitionDataHT = (Last created hashtable)
-
-
Set TransitionKey = (tt + Transitions)
-
Set SaveExtension = .w3z
-
Set MapExtension = .w3x
-
Set AreaCount = 6
-
Actions
-
-------- Area Names --------
-
Set AreaMap[1] = AR0100
-
Set AreaMap[2] = AR0101
-
Set AreaMap[3] = AR0102
-
Set AreaMap[4] = AR0103
-
Set AreaMap[5] = AR0104
-
Set AreaMap[6] = AR0105
-
-
Actions
-
-------- Area Names --------
-
Set AreaMap[1] = AR0101
-
Set AreaMap[2] = AR0100
-
Set AreaMap[3] = AR0105
-
Set AreaMap[4] = AR0103
-
Set AreaMap[5] = AR0104
-
Set AreaMap[6] = AR0102
-
Well that is the identical part in this trigger in all maps.
-
Actions
-
-------- Restore Points Data --------
-
Hashtable - Save Handle Of(Center of HeroRestore from Forests <gen>) as 1 of 2 in TransitionDataHT
-
I am using two integers as keys for the hastable, the first number, is called (I call it) "Restore Position Index". Areas may have more than one entrance for the same area so we need an ID for each entrance. The second number, is "Area Index" and this is the unique ID for each area I mentioned above.
So when I store a RestorePoint as 1 of 2 what does that mean ?
It means that point we are storing the restore point of the area with ID = 2 and restore position index = 1
Another example:
-
Actions
-
Hashtable - Save Handle Of(Center of HeroRestore from Caves A <gen>) as 1 of 5 in TransitionDataHT
-
Hashtable - Save Handle Of(Center of HeroRestore from Caves B <gen>) as 2 of 5 in TransitionDataHT
-
Remember, a hashtable can store one handle only and since points (Locations) are handles so we can't save another handle that's why I will store Reals as the facing angle after the unit is restored. Like this:
-
Actions
-
-------- Restore Facing Angle Data --------
-
Hashtable - Save 270.00 as 1 of 2 in TransitionDataHT
-
Hashtable - Save 0.00 as 1 of 3 in TransitionDataHT
-
Hashtable - Save 270.00 as 1 of 5 in TransitionDataHT
-
Hashtable - Save 90.00 as 2 of 5 in TransitionDataHT
-
Hashtable - Save 180.00 as 1 of 6 in TransitionDataHT
-
- That means that this area can't be reached from the current area.
Now, I have finished the Area Initialization trigger.
Transition to a certain Area
-
To the Forests
-
Events
-
Unit - A unit enters Transition2Forests <gen>
-
-
Conditions
-
(The trigger queue is empty) Equal to True
-
(Owner of (Triggering unit)) Equal to Controller
-
((Triggering unit) is A Hero) Equal to True
-
-
Actions
-
Trigger - Turn off (This trigger)
-
Set TargetAreaIndex = 2
-
Set RestorePointIndex = 1
-
Trigger - Add Area Change Begin <gen> to the trigger queue (Checking conditions)
-
Wait 4.00 seconds
-
Trigger - Turn on (This trigger)
-
-
The 2nd condition checks the player, Controller is a variable and 3rd condition is to check that the entering unit is a hero so that not any unit could fire the trigger.
Now to explain the Actions ...
-
Set TargetAreaIndex = 2
-
Set RestorePointIndex = 1
-
Trigger - Add Area Change Begin <gen> to the trigger queue (Checking conditions)
-
Area Change Begin
-
Events
-
Conditions
-
Actions
-
Cinematic - Fade out over 0.25 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
-
Wait 0.25 seconds
-
Cinematic - Turn cinematic mode On for (All players) over 0.20 seconds
-
Wait 0.20 seconds
-
Trigger - Run Transition <gen> (checking conditions)
-
-
-
Transition
-
Events
-
Conditions
-
Actions
-
Set SourceAreaIndex = AreaIndex
-
Set AreaSave[SourceAreaIndex] = (AreaMap[SourceAreaIndex] + SaveExtension)
-
Trigger - Run Export All <gen> (checking conditions)
-
Trigger - Run Perform Map Transition <gen> (checking conditions)
-
-
Now we prepare a string for the save named after the current area and stored in an array string variable with the Source Area ID (current area ID) as an array index.
After that we need to store all our mission data in a cache, like the quests progress, your resources and most importantly your heroes. (will be explained later)
Finally, we perform the transition which is "Saving And Loading" or "Saving And Changing Level" depending on whether we visited the target area before or not.
Performing the Transition
-
Perform Map Transition
-
Events
-
Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AreaSave[TargetAreaIndex] Not equal to <Empty String>
-
(The AreaSave[TargetAreaIndex] saved-game exists) Equal to True
-
-
Then - Actions
-
Game - Display to (All players) the text: Loading ...
-
Game - Save game as AreaSave[SourceAreaIndex] and load AreaSave[TargetAreaIndex] (Skip scores)
-
-
Else - Actions
-
Game - Display to (All players) the text: Initializing ...
-
Game - Save game as AreaSave[SourceAreaIndex] and change level to (AreaMap[TargetAreaIndex] + MapExtension) (Skip scores)
-
-
-
-
Well, the saved game will be loaded and the target area will be loaded as well but the status of the area will belong to the old game, so another condition is needed for checking the string variable that store the names of the saves, since those variables are set to <Empty String> each time a new campaign is started it will not matter if the saved game exists or not.
Note that the messages that I added are just for testing and is better if they are removed.
Exporting data to cache
-
Export All
-
Events
-
Conditions
-
Actions
-
Game Cache - Create a game cache from CacheName
-
Game Cache - Clear all labels of TransitionKey in (Last created game cache)
-
-------- Export Area Saves (Saved-game filenames) --------
-
For each (Integer A) from 1 to AreaCount, do (Actions)
-
Loop - Actions
-
Game Cache - Store AreaSave[(Integer A)] as (AreaSave + (String((Integer A)))) of TransitionKey in (Last created game cache)
-
-
-
-------- Export Transition Data --------
-
Game Cache - Store SourceAreaIndex as SourceAreaIndex of TransitionKey in (Last created game cache)
-
Game Cache - Store RestorePointIndex as RestorePointIndex of TransitionKey in (Last created game cache)
-
-------- Export Campaign Data and Heroes --------
-
Trigger - Run Export Mission Data <gen> (checking conditions)
-
Trigger - Run Export Hero <gen> (checking conditions)
-
Game Cache - Save (Last created game cache)
-
-
The strings holding the save names must be stored to be able to load them from any area. Also, the source area ID and the restore point index must be stored as well because in the target area it is important to know the ID of the area we are coming from.
-
Export Mission Data
-
Events
-
Conditions
-
Actions
-
Game Cache - Store (Controller Current gold) as Res_Gold of TransitionKey in (Last created game cache)
-
Game Cache - Store (Controller Current lumber) as Res_Lumber of TransitionKey in (Last created game cache)
-
-
-
Export Hero
-
Events
-
Conditions
-
Actions
-
Set TransitionHero = Hero[1]
-
Game Cache - Store TransitionHero as Hero1 of TransitionKey in (Last created game cache)
-
Game Cache - Store (Life of TransitionHero) as HeroLife1 of TransitionKey in (Last created game cache)
-
Game Cache - Store (Mana of TransitionHero) as HeroMana1 of TransitionKey in (Last created game cache)
-
Unit - Remove TransitionHero from the game
-
-
I made the trigger this way in case I have more than one hero then a loop could be used and will be like this:
-
Actions
-
Game Cache - Store NHeroes as NHeroes of TransitionKey in (Last created game cache)
-
For each (Integer A) from 1 to NHeroes, do (Actions)
-
Loop - Actions
-
Set TransitionHero = Hero[(Integer A)]
-
Game Cache - Store TransitionHero as (Hero + (String((Integer A)))) of TransitionKey in (Last created game cache)
-
Game Cache - Store (Life of TransitionHero) as (HeroLife + (String((Integer A)))) of TransitionKey in (Last created game cache)
-
Game Cache - Store (Mana of TransitionHero) as (HeroMana + (String((Integer A)))) of TransitionKey in (Last created game cache)
-
Unit - Remove TransitionHero from the game
-
-
-
Now, the data exporting phase is done.
Since the target area is visited for the first time the Initialization trigger will run so the data needs to be synced. After that, this area will always be loaded and sync will be easier.
There is a difference between this area and the previous area (which we came from); in the starting area (first area the campaign start with) the Hero(es) is created but in this area they are restored so in the initialization no need to create a hero, if the hero can be restored with no problem but that is related to the hero restoration part which I will explain soon.
The target area is initialized, let's see ...
-
Initialization
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Trigger - Run Init 01 Units <gen> (checking conditions)
-
Trigger - Run Init 02 Players <gen> (checking conditions)
-
Trigger - Run Init 03 SyncData <gen> (checking conditions)
-
-
-
Init 03 SyncData
-
Events
-
Conditions
-
Actions
-
Trigger - Run Init Zones <gen> (checking conditions)
-
Trigger - Run Import All <gen> (checking conditions)
-
Camera - Pan camera for Controller to RestorePoint over 0.00 seconds
-
Selection - Select TransitionHero for Controller
-
-
-
Import All
-
Events
-
Conditions
-
Actions
-
Game Cache - Reload all game cache data from disk
-
Game Cache - Create a game cache from CacheName
-
-------- Import Zone Saves --------
-
For each (Integer A) from 1 to AreaCount, do (Actions)
-
Loop - Actions
-
Set AreaSave[(Integer A)] = (Load (AreaSave + (String((Integer A)))) of TransitionKey from (Last created game cache))
-
-
-
-------- Import Transition Data --------
-
Set SourceAreaIndex = (Load SourceAreaIndex of TransitionKey from (Last created game cache))
-
Set RestorePointIndex = (Load RestorePointIndex of TransitionKey from (Last created game cache))
-
Trigger - Run Import Mission Data <gen> (checking conditions)
-
Trigger - Run Import Heroes <gen> (checking conditions)
-
-
NoteI have seen many examples in which the cache is created first then all data is reloaded from disk but I don't know which is correct or better but it seems the two methods work
After that, we import the mission data and the heroes.
-
Import Mission Data
-
Events
-
Conditions
-
Actions
-
-------- Restore Resources --------
-
Player - Set Controller Current gold to (Load Res_Gold of TransitionKey from (Last created game cache))
-
Player - Set Controller Current lumber to (Load Res_Lumber of TransitionKey from (Last created game cache))
-
-
-
Import Heroes
-
Events
-
Conditions
-
Actions
-
Trigger - Run Set Hero Locations <gen> (checking conditions)
-
Trigger - Run Import Hero 1 <gen> (checking conditions)
-
-
-
Set Hero Locations
-
Events
-
Conditions
-
Actions
-
Set RestorePoint = (Load RestorePointIndex of SourceAreaIndex in TransitionDataHT)
-
Set Facing = (Load RestorePointIndex of SourceAreaIndex from TransitionDataHT)
-
-
-
Init Zones
-
Events
-
Conditions
-
Actions
-
-------- Current Area ID --------
-
Trigger - Run Identify Area <gen> (checking conditions)
-
-------- General Transition Data --------
-
Set CacheName = CCampaign.w3v
-
Hashtable - Create a hashtable
-
Set TransitionDataHT = (Last created hashtable)
-
Set TransitionKey = (tt + Transitions)
-
Set SaveExtension = .w3z
-
Set MapExtension = .w3x
-
Set AreaCount = 6
-
-------- Area Names --------
-
Set AreaMap[1] = AR0100
-
Set AreaMap[2] = AR0101
-
Set AreaMap[3] = AR0102
-
Set AreaMap[4] = AR0103
-
Set AreaMap[5] = AR0104
-
Set AreaMap[6] = AR0105
-
-------- Restore Points Data --------
-
-------- The 1st number in the hashtable is the child key and it represents the restore position index --------
-
-------- The 2nd number in the hashtable is the parent key and it represents the area index --------
-
Hashtable - Save Handle Of(Center of HeroRestore from Camp <gen>) as 1 of 1 in TransitionDataHT
-
Hashtable - Save Handle Of(Center of HeroRestore from Hills <gen>) as 1 of 4 in TransitionDataHT
-
-------- Restore Facing Angle Data --------
-
Hashtable - Save 90.00 as 1 of 1 in TransitionDataHT
-
Hashtable - Save 0.00 as 1 of 4 in TransitionDataHT
-
-
-
Import Hero 1
-
Events
-
Conditions
-
Actions
-
Game Cache - Restore Hero1 of TransitionKey from (Last created game cache) for Controller at RestorePoint facing Facing
-
Set Hero[1] = (Last restored unit)
-
Set TransitionHero = (Last restored unit)
-
Unit - Set life of TransitionHero to (Load HeroLife1 of TransitionKey from (Last created game cache))
-
Unit - Set mana of TransitionHero to (Load HeroMana1 of TransitionKey from (Last created game cache))
-
-
-
Import Hero
-
Events
-
Conditions
-
Actions
-
Set NHeroes = (Load NHeroes of TransitionKey from (Last created game cache))
-
For each (Integer A) from 1 to NHeroes, do (Actions)
-
Loop - Actions
-
Game Cache - Restore (Hero + (String((Integer A)))) of TransitionKey from (Last created game cache) for Controller at RestorePointFormation[(Integer A)] facing Facing
-
Set Hero[(Integer A)] = (Last restored unit)
-
Set TransitionHero = (Last restored unit)
-
Unit - Set life of TransitionHero to (Load (HeroLife + (String((Integer A)))) of TransitionKey from (Last created game cache))
-
Unit - Set mana of TransitionHero to (Load (HeroMana + (String((Integer A)))) of TransitionKey from (Last created game cache))
-
-
-
-
That concludes the Initialization part, lets now try to return to the previous area and see how we could do that.
-
Road to Camp
-
Events
-
Unit - A unit enters Transition2Camp <gen>
-
-
Conditions
-
(The trigger queue is empty) Equal to True
-
(Owner of (Triggering unit)) Equal to Controller
-
((Triggering unit) is A Hero) Equal to True
-
-
Actions
-
Trigger - Turn off (This trigger)
-
Set TargetAreaIndex = 1
-
Set RestorePointIndex = 1
-
Trigger - Add Area Change Begin <gen> to the trigger queue (Checking conditions)
-
Wait 4.00 seconds
-
Trigger - Turn on (This trigger)
-
-
The same triggers will run as mentioned above (Export All, Export Mission Data ... etc)
After the previous area loads
At first the map was initialized but now the saved game will be loaded.
-
Game Load
-
Events
-
Game - A saved game is loaded
-
-
Conditions
-
(Map transitioned is set) Equal to True
-
-
Actions
-
Trigger - Run Import All <gen> (checking conditions)
-
Trigger - Run Resume Game <gen> (checking conditions)
-
Trigger - Run Disable Area Restart <gen> (checking conditions)
-
-
-
Resume Game
-
Events
-
Conditions
-
Actions
-
-------- Set camera --------
-
Camera - Pan camera for Controller to RestorePoint over 0.00 seconds
-
Trigger - Add Area Change Finish <gen> to the trigger queue (Checking conditions)
-
Trigger - Remove Area Change Begin <gen> from the trigger queue
-
Wait 0.51 seconds
-
Selection - Select TransitionHero for Controller
-
-
-
Area Change Finish
-
Events
-
Conditions
-
Actions
-
Cinematic - Fade out over 0.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
-
Wait 0.50 seconds
-
Cinematic - Turn cinematic mode Off for (All players) over 0.30 seconds
-
Wait 0.20 seconds
-
Cinematic - Fade in over 0.50 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
-
Wait 0.50 seconds
-
Trigger - Remove (This trigger) from the trigger queue
-
-
-
Disable Area Restart
-
Events
-
Conditions
-
Actions
-
Wait 0.00 seconds
-
Custom script: call DisableRestartMission( false )
-
-
An example campaign is attached for proper illustration.
I hope you like this tutorial.
Good Mapping.
More will be added to this tutorial but that is the basic things needed to make a Transition System.
For JASS loversI will work hard to make this in JASS
11:52 PM 7/27/2012 Updated the attached campaign
Attachments
Last edited by a moderator: