Age of Wonders II Heaven Julia with Gameplay background

Scenario Design
    Scripting Database

SHADOW MAGIC SCRIPTING
Scripting Database

Creating an Altar for Player to Sacrifice Units for a Reward

Posted by: Swolte/Talon-Thorn on the AOW2 Scenario Forum

Outline:
Player moves units onto an alter. Units are teleported to an "area" where they enter battle. If the battle is won, the units are teleported to a second arena for another battle. If that battle is won as well, the player gets reward 2 (bigger reward), but if not, the player gets reward 1 (smaller reward). If neither is won, the player gets no reward.

The logistical problem with this script is that it has a "diminishing" trigger system; if the player's units win, a trigger will fire, but if they lose, there is no trigger to report the condition (at least, not in the same turn; it would require a "new turn" trigger to review what happened on the prior turn). Since the script must rely on the "win" event, the solution is to give the player both reward 1 (when first battle is won) and reward 2 (when second battle is won), and then take reward 1 away when the second battle is won.

Scripts:
The way I set this up is (using Swolte's setup) to have an "enter area" trigger located at the alter. This sends the units to staging area 1 (a 1-hex area in the rock); basically, if the player sends in units, he loses them; he can decide to cancel the ensuing battles but can't take his units back; this part could be omitted. Next, the units entering staging area 1 are teleported (enter area) to combat arena 1 (1-hex hole in rock) where independent combatants are waiting; player can fight or cancel. If the player fights and the units win, then the "enter area" trigger for arena 1 is tiggered. Use this trigger to send units to staging area 2. Another "enter area" trigger set on staging area 2 then teleports the surviving units to arena 2, where independent units are waiting for battle; player has choice to fight or cancel. If the player's units win this battle, "enter area" set for the arena 2 locatiion will be triggered.

The reason for staging area 2 is because without it, multiple rewards may be generated (due to a quirk in how "teleport units" works). It seems like a needless step, but is very necessary.

Swolte used "spawn units" for the rewards. Reward 2 has more powerful units. Since there is no trigger when the player's units die, it is necessary to fudge the results by generating reward 1 always, then deleting it when reward 2 is generated. Thus, if player wins in arena 1, then a trigger "enter area" fires and spawns reward 1 units; player can't do anything at this point because scripted events are still firing. Player's winning units teleport onward to arena 2. If the units lose, no additional activity is necessary. If they win, then the trigger "enter area" located on arena 2 fires. This trigger is used to do two things: 1) delete reward 1 units that were spawned and 2) spawn reward 2 units. Units are deleted by using a "change terrain" event based on trigger "enter area" for arena 2; the spawning location for reward 1 is changed to shadowvoid (killing all units) and then changed back to the previous terrain type.

One caviat: since the player can use the altar multiple times, he could leave reward 1 units at the reward 1 spawn site or could move his own units to the location where reward 1 is spawned. This will cause reward 1 units to be displaced to the nearest unoccupied location. The way to avoid this is to delete any units located at the spawn site before any other actions, each time the player moves a unit onto the alter ("enter area" on altar's location).

Setup:
To let the altar be used repeatedly, each arena location needs to be cleared when the player first moves units onto the alter. This is done by changing terrain at each hole in the rock to shadowvoid, then back to the desired terrain (wasteland in this case). Note: the type of terrain that the arenas are changed to may affect combat, since morale is determined by terrain type for some units.

Details:


All events are set to occur "Always"

--Setup/house cleaning:
Event: "Delete pre-arena1 units", Change Terrain, Location: pre-arena1, TerrainType: shadowvoid, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Delete arena1 units", Change Terrain, Location: arena1, TerrainType: shadowvoid, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Delete pre-arena2 units", Change Terrain, Location: pre-arena2, TerrainType: shadowvoid, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Delete arena2 units", Change Terrain, Location: arena2, TerrainType: shadowvoid, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Delete reward site units", Change Terrain, Location: reward-site, TerrainType: shadowvoid, Radius 0
Trigger: Enter Area, location: Alter-Location
(This script is needed to be sure reward1 units are located at the reward site when they are spawned; any units player places or leaves at the reward site will be lost when alter is used.)

--Setup/reset locations:
Event: "Reset pre-arena1", Change Terrain, Location: pre-arena1, TerrainType: dirt, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Reset arena1", Change Terrain, Location: arena1, TerrainType: dirt, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Reset pre-arena2", Change Terrain, Location: pre-arena2, TerrainType: dirt, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Reset arena2", Change Terrain, Location: arena2, TerrainType: dirt, Radius 0
Trigger: Enter Area, location: Alter-Location

Event: "Reset reward site", Change Terrain, Location: reward-site, TerrainType: grass, Radius 0
Trigger: Enter Area, location: Alter-Location

--Setup/spawn combatants:
Event: "Spawn arena1 combatants", Spawn Units, Units: (user specified), Location: arena1, Behavior: subNone
Trigger: Enter Area, location: Alter-Location

Event: "Spawn arena2 combatants", Spawn Units, Units: (user specified), Location: arena2, Behavior: subNone
Trigger: Enter Area, location: Alter-Location

--Execute Sacrifice:
Event: "Teleport units to pre-arena 1 location", Teleport Units, From: alter-location, To: Pre-Arena1
Trigger: Enter Area, location: Alter-Location
(This event could probably be omitted; including it makes sure that units are lost if player changes his mind after entering alter, since units can't get back to alter location.)

Event: "Teleport units to arena 1 location", Teleport Units, From: pre-arena1, To: arena1
Trigger: Enter Area, location: pre-arena1

Event: "Teleport units to pre-arena 2 location", Teleport Units, From: arena1, To: pre-arena2
Trigger: Enter Area, location: arena1

Event: "Teleport units to arena 2 location", Teleport Units, From: pre-arena2, To: arena2
Trigger: Enter Area, location: pre-arena2

--Generate Rewards
Event: "Reward1", Spawn Units, Player: independent, Units: (specify units), Location: reward-site, Behavior: subRefuge
Trigger: Enter Area, Location: arena1

Event: "Delete Reward1", Change Terrain, Location: reward-site, TerrainType: shadowvoid, Radius 0
Trigger: Enter Area, Location: arena1

Event: "Reset Reward Site", Change Terrain, Location: reward-site, TerrainType: grass, Radius 0
Trigger: Enter Area, Location: arena1

Event: "Reward2", Spawn Units, Player: independent, Units: (specify units), Location: reward-site, Behavior: subRefuge
Trigger: Enter Area, Location: arena2


You could have a reward other than units; it is possible to put an artifact on a hero, kill the hero, and thus, give an artifact reward. Also, units could be spawned with "Player" being the player instead of "independent." Could also use "Units Join" event and it's added features.

You would probably want to add a message and a Center View event to complete the script. Just use an Enter Area trigger. It might not be possible to have the message tailored to the reward (1 different than 2) due to the "diminishing" triggers.

Back to Event Scripting Resource Database Menu



BACK TO SCENARIO DESIGN MAIN MENU

HG Logo

Headlines

» AoW1 Summer 2008 Mapmaking Tournament

» Interview Kirky Picardo

» Scenario update

» The making of...

» A new PBEM Singles Champion is crowned - Swolte!!

Poll

What unit most resembles you?

Halfling peasant

Undead Vampire

Human Knight

Tigran Prowler

Orcish Warlord

Archon Saint

Dwarven Engineer

Chaos Spawn

Results :: Other Polls

Age of Wonders

Looking for info about the original AoW?
Visit AoW Heaven!

AoWH Logo

HeavenGames Sites

» Main Portal

» Age of Empires

» Age of Empires 3

» Age of Kings

» Age of Mythology

» Age of Wonders

» Age of Wonders 2

» Battle for Middle Earth 2

» Caesar 3

» Caesar 4

» Children of the Nile

» Dungeon Siege

» Empire at War

» Empire Earth

» Emperor: RotMK

» Medieval 2: Total War

» Pharaoh

» Rise & Fall: CaW

» Rise of Legends

» Rise of Nations

» Rome: Total War

» Stronghold

» Stronghold 2

» SW: Galactic Battlegrounds

» Zeus