Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

MissionScriptsDynamicEvents

Rey edited this page Oct 11, 2017 · 10 revisions

Events

Events are written in a form procedure EVENT_NAME(EVENT_PARAMETERS); like so:

    procedure OnHouseBuilt(aHouseID: Integer);
    begin
      // code
    end;
Ver
sion
Event Description Parameters
and types
6570 OnBeacon
Occurs when a player places a beacon on the map.
aPlayer: Integer;
aX: Word;
aY: Word;
6220 OnGroupHungry
Occurs when the player would be shown a message about a group being hungry (when they first get hungry, then every 4 minutes after that if there are still hungry group members). Occurs regardless of whether the group has hunger messages enabled or not.
aGroup: Integer;
6114 OnHouseAfterDestroyed
Occurs after a house is destroyed and has been completely removed from the game, meaning the area it previously occupied can be used. If you need more information about the house use the !OnHouseDestroyed event.
aHouseType: THouseType;
aOwner: Integer;
aX: Word;
aY: Word;
5057 OnHouseBuilt
Occurs when player has built a house.
aHouse: Integer;
5882 OnHouseDamaged
Occurs when a house is damaged by the enemy soldier. !Attacker is -1 the house was damaged some other way, such as from Actions.!HouseAddDamage.
aHouse: Integer;
aAttacker: Integer;
5407 OnHouseDestroyed
Occurs when a house is destroyed. If !DestroyerIndex is -1 the house was destroyed some other way, such as from Actions.!HouseDestroy. If !DestroyerIndex is the same as the house owner (States.!HouseOwner), the house was demolished by the player who owns it. Otherwise it was destroyed by an enemy. Called just before the house is destroyed so HouseID is usable only during this event, and the area occupied by the house is still unusable.
aHouse: Integer;
aDestroyerIndex: Integer; // Index of player who destroyed it
5871 OnHousePlanPlaced
Occurs when player has placed a house plan.
aPlayer: Integer;
aX: Word;
aY: Word;
aType: THouseType;
6298 OnHousePlanRemoved
Occurs when player has removed a house plan.
aPlayer: Integer;
aX: Word;
aY: Word;
aType: THouseType;
6216 OnMarketTrade
Occurs when a trade happens in a market (at the moment when resources are exchanged by serfs).
aMarket: Integer;
aFrom: TWareType;
aTo: TWareType;
5057 OnMissionStart
Occurs immediately after the mission is loaded.
5964 OnPlanFieldPlaced
Occurs when player has placed a field plan.
aPlayer: Integer;
aX: Word;
aY: Word;
6301 OnPlanFieldRemoved
Occurs when player has removed a field plan.
aPlayer: Integer;
aX: Word;
aY: Word;
5964 OnPlanRoadPlaced
Occurs when player has placed a road plan.
aPlayer: Integer;
aX: Word;
aY: Word;
6301 OnPlanRoadRemoved
Occurs when player has removed a road plan.
aPlayer: Integer;
aX: Word;
aY: Word;
5964 OnPlanWinefieldPlaced
Occurs when player has placed a wine field plan.
aPlayer: Integer;
aX: Word;
aY: Word;
6301 OnPlanWinefieldRemoved
Occurs when player has removed a wine field plan.
aPlayer: Integer;
aX: Word;
aY: Word;
5057 OnPlayerDefeated
Occurs when certain player has been defeated. Defeat conditions are checked separately by Player AI.
aPlayer: Integer;
5057 OnPlayerVictory
Occurs when certain player is declared victorious. Victory conditions are checked separately by Player AI.
aPlayer: Integer;
5057 OnTick
Occurs every game logic update.
6114 OnUnitAfterDied
Occurs after a unit has died and has been completely removed from the game, meaning the tile it previously occupied can be used. If you need more information about the unit use the !OnUnitDied event. Note: Because units have a death animation there is a delay of several ticks between !OnUnitDied and !OnUnitAfterDied.
aUnitType: TUnitType;
aOwner: Integer;
aX: Word;
aY: Word;
6587 OnUnitAttacked
Happens when a unit is attacked (shot at by archers or hit in melee). Attacker is always a warrior (could be archer or melee). This event will occur very frequently during battles.
aUnit: Integer;
aAttacker: Integer; // Warrior who attacked the unit
5407 OnUnitDied
Occurs when a unit dies. If !KillerIndex is -1 the unit died from another cause such as hunger or Actions.!UnitKill. Called just before the unit is killed so UnitID is usable only during this event, and the tile occupied by the unit is still taken.
aUnit: Integer;
aKillerOwner: Integer; // Index of player who killed it
5057 OnUnitTrained
Occurs when player trains a unit.
aUnit: Integer;
5884 OnUnitWounded
Happens when unit is wounded. Attacker can be a warrior, recruit in tower or unknown (-1).
aUnit: Integer;
aAttacker: Integer; // Unit who attacked the unit
5057 OnWarriorEquipped
Occurs when player equips a warrior.
aUnit: Integer;
aGroup: Integer;