TRIGGERS
List and Definition of All Triggers
Syntax | Triggers |
AI calculate square value. Triggered when AI gets weight of a map square. Coordinates of given square are kept in v998/v999/v1000. HE-1 is the hero for which the value is calculated. There is a corresponding |
|
Equip/Unequip artifact trigger. !?AE0; Take off an artifact !?AE1; Put on an artifact The current Hero (!!HE-1) is a Hero-owner v998 keeps an artifact number v999 keeps a position (slot) number Comments. It does not work for backpack. If you change one artifact to another, it produces some extra triggers call. Here the sequence is: 1. AE0 (prev) 2. AE1 (prev) 3. AE0 (prev) 4. AE1 (new) 5. AE0 (new) 6. AE1 (new) If you take an artifact from a backpack and a slot that this artifact may be placed is busy, you will get the next sequence for every slot this artifact may be placed: 1. AE0 (prev) 2. AE1 (prev) So be careful and do not count that if a specific artifact is not taken off, you will not have AE0 trigger switched for this art. |
|
This will be called when any battle occurs. # = 0 Turn on at start of every battle. # = 1 Turn on at end of every battle. # = 50 !?BA50; is the equivalent of !?BA0; but runs only on the defending side in a multiplayer network battle, and runs *instead of !?BA0; on that side (on the defending computer). # = 51 Likewise, !?BA51; runs instead of !?BA1; on the defending computer in a network battle. # = 52 - called at a battle start at both sides # = 53 - called at a battle end at both sides Sequence at a battle start: 1. If it is an attacker's PC (or non MP game) BA0 is called 2. If it is a defender's PC BA50 is called 3. BA52 is called. At battle end: 1. If it is an attacker's PC (or non MP game) BA1 is called 2. If it is a defender's PC BA51 is called 3. BA53 is called. This means that if you want to have an identical code for BA0 and BA50, you just need to make one section with BA52 header. Note: If you want to test scripts in MP mode you cannot do it at the first game turn (day 1). You need to pass one day so all players will have an identical environment. Network service: !?BG and !?BF work at both sides and if the variables are the same, they will give you the identical effect at both sides. Only user related actions are not synchronous for both sides and BA0/BA50 and BA1/BA51 triggers make a difference. To set up a battle, use the |
|
Trigger will be called when a battlefield is prepared for a battle prior to the combat beginning. It may be used in conjunction with the Suggestion: Do not use !!BU:R command in !?BF trigger and before it. |
|
Trigger occurs at every action taken by any stack or by the hero (for spell casting, retreating and surrendering). !?BG0 is called before the action occurs. !?BG1 is called after the action occurs. Variable v997 keeps the number of the current turn: 0 - start turn (after Tactics phase) 1 - second turn 2 - third turn ... Comments: You can use this with the |
|
!?BR; | Trigger occurs every turn of a battle (for the first turn it occurs twice). Variable v997 keeps the number of the current turn: -1 - start turn (before Tactics phase) 0 - start turn (after Tactics phase) 1 - second turn 2 - third turn ... Comments: 1. The starting turn (-1,0) goes in darkness and you will not be able to show any message, though you can take actions. 2. The turn of a battle (v997) may be not the same if a Tactics phase took place. For the full sequence of triggers, see the detailed |
!?CM#; | The trigger occurs when you click the mouse button. It sets up an internal ERM structure that can be used with the Comments: Data in the structure will not be saved. This means that you can use it in a receiver section of this trigger. |
!?CM0; | Right-mouse click on the adventure map |
!?CM1; | Mouse manager trigger for town screen. The trigger occurs when you click mouse button You can also use !!CM receivers with the commands TSIFAR and cannot use P. The trigger works for left mouse push (subtype=12), left mouse release (subtype=13) and right mouse push (subtype=14) and also has a corresponding bit in flags. |
!?CM2; | Mouse manager trigger for Hero information screen. The current hero !!HE-1:... is an active one |
!?CM3; | Mouse manager trigger for Heroes meeting screen. |
!?CM4; | Mouse manager trigger for battle field. Get the number of position on the battle field (and heroes image) |
!?CM5; | Left-mouse click on the adventure map It may be used with all CM receiver commands that you use for right-mouse click: TSIFAPR. |
!?CI; | Castle income triggers !?CI0; is triggered when the game calculates castle income !?CI1; is triggered when the game calculates monster growth in a castle. See also |
!?CO#; | Commander triggers !?CO0; is called before opening the Commander Dialog !?CO1; is called after closing the Commander Dialog !?CO2; is called after buying a Commander in a Town !?CO3; is called after reviving a Commander in a Town Notes: Flag 1000 set to 1 only if the owner of the hero is a human player who sits before the screen. Flag 999 as usual shows whether this turn is a human player who sits before the screen. You can use !!HE-1:... to get the current hero info and !!CO-1:...to get current Commander info. Vars v998,v999,v1000 as usual shows the position of the current hero on the map. |
!?DG; | Digging for Grail It is triggered when a hero is digging for Grail and the hole has already been placed v998, v999 and v1000 keep coordinates. Flag 1000 shows you that the hero belongs to the player sitting at the monitor. HE-1 gives you the digging hero. There is a corresponding |
!?DL; | Custom dialogs trigger It is called when a mouse and keyboard (not supported yet) action is taken at any dialog item. Notes: When the trigger is called the next vars are set: v998 = Dialog Id v999 = Item Id v1000 = action Action for now: 12 - left mouse button push 13 - left mouse button release 14 - right mouse button push |
!?FC; | Get flag's color
It is triggered when the game needs flag color. Now any object can have a flag. (Via tests I failed to flag windmill this way tho) v998, v999 and v1000 keep coordinates of the object entrance. Note that it is using EVERY time game need to get color of ANY flag, not only when changing one. For example, this script !?FC; !!VRy1:S0; !!FC:T?y1; !!if&y1=53:; !!FC:C?y2; !!OW&y2<>-1:Ry2/2/d5; !!en:;. will be called repeatedly as long as you see ANY mine flagged with your color, giving you tons of ore. Flag color seems to be only cosmetic feature itself, although maybe you can use it inside scripts. |
!?FU#; | Function number # (integer value 1-30000) called within a block of ERM code by an |
!?FU-#; | Local function number # (integer value 1-100) called within a block of ERM code by an |
!?GE#; | This is a "global" event with number #. The # must be first in the Event text, separated from rest with newline. This number WON'T APPEAR later in message text in the game as long as it's used by a trigger. The event title doesn't matter. Example: Global event with text "1230 There you are!" transforms to "There you are!" with number 1230. To change a global event, use the |
!?GM#; | Saving/Loading trigger. # = 0 - is called right after loading a saved game but before showing the map. # = 1 - is called right before saving the game but after choosing the game to save. |
!?HD; | Hint Display Triggered when the game needs to display a hint for an object. v998/v999/v1000 keep coordinates of the square that was clicked by mouse. |
!?HE#; | This will be called when any hero attacks an enemy hero or visits/trades
with an allied hero having the specified hero #. See To change characteristics of a hero, use the |
!?HL#; | Will be triggered whenever a hero gains a level. # = number of hero (-1 = all, see If you have !?HL-1 and !?HL5, for example, first will be processed all receivers for all heroes (HL-1) and then a particular hero (HL5). To change the primary and secondary skills available when a hero gains a level, use the |
!$HL#; | Post hero level-up trigger. Triggered after the dialog is closed and skills are enhanced. # = number of hero (-1 = all, see |
!?HM#; | Take control over every step a hero # takes.
It is triggered before the hero takes each step (not after).
So if you check v998, v999, v1000, you get a coordinate of the point the Hero will
move TO. This movement cannot be cancelled. # = number of hero (-1 = all, see At triggering moment you can find: HE-1 will refer to a hero who moves. v998,v999,v1000 = x,y and level of the point of destination. Also, flag1000 is set to gamer (1) or AI (0) as usual. If you have !?HM-1; and !?HM5 for example, first will be processed all receivers for all heroes (HM-1) and then a particular hero (HM5). Example: !?HM-1; !!IF:M^Moving!^; !?HM0; !!IF:M^Personal Orin's Moving!^; |
!?IP#; | Multiplayer support. If one player's hero attacks another player's hero, there will be the next sequence: 1) !?BA0 trigger for attacker switches; 2) !?IP0; trigger switches for attacker 3) data transferred to defender: - attacker's Hero info; - attacker's Hero Commander info (completely); - v vars set v9001-v10000; - all potentially changed monster statistics; 4) all sent data received at defender side; 5) !?IP1; trigger switches for defender; 6) !?BA0; trigger switches for defender; -- Now the battle takes place -- If attacker wins, no WoG data transferred. if defender wins, there will be the next sequence: 7) attacker goes to wait until defender gains levels; 8) defender's Hero and Commander gain levels; 9) !?IP2; trigger switches for defender; 10) data transferred tp attacker: - defender's Hero sec. skills (all 28), level and exp.; - defender's Hero Commander info (completely); - v vars set v9001-v10000; 11) !?BA1; trigger switches for defender; 12) attacker goes from waiting until defender gains levels; 13) all sent data received at attacker side; 14) !?IP3; trigger switches for attacker; 15) !?BA1; trigger switches for attacker; As you can see, monsters, heroes and Commanders statistics should be identical now. As a side effect I can say that 10 sec. skills for Hero is a multiplayer safe rule. All 28 sec. skills transferred in both directions if needed. |
An Event on the map can be a Trigger. The contents and features of the Event are not significant in any way. The event won't be changed. It is used as an Event Trigger only. #1 - X position of the Event on the map #2 - Y position on the map #3 - level (0-ground, 1-underground). An Event must exist at that position on the adventure map. You can refer to the exact position of the event in receivers following the trigger: x,y and level will be stored in v998,v999 and v1000 when the trigger activates. Example: ?!LE10/21/0; This will identify an event at the location x=10, y=21 on the surface map level (0) as a trigger. If a hero trips this event, then all ERM statements following the trigger code will be executed. To change the properties of an event, use the |
|
Post visit LE trigger | |
Trigger for a stack taking physical damage(before an action) used with |
|
!?MG0; !?MG1; |
Spell casting on the adventure map !?MG0; - pre trigger !?MG1; - post trigger Sequence: 1) player clicks the "cast spell" icon 2) !?MG0; works out (you can adjust current hero spells) 3) Magic Book appears and a player chooses a spell 4) Spell casting 5) !?MG1; works out (the cast spell number is stored in v997) Example: ZVSE !?MG0; !!IF:M^Magic is ready to cast^; !?MG1; !!VRy-10:Sv997; !!IF:M^Magic was cast. Spell number: %Y-10^; Comments: This doesn't work for AI heroes, only human players. |
!?MM0; | For control over scroll text during a battle This trigger works when WoG is trying to show hint text in the scroll field (e.g., "fly here"). (See Comments: The !?MM0 trigger only functions prior to an action being chosen. So, for example, if I cast a spell, the display hints that show up while choosing a target don't occur within the !?MM0 trigger at all. Once the target's been chosen and the spell's been cast, it returns to using the !?MM0 trigger until the next action is taken. |
!?MM1; | Trigger when a player moves the mouse pointer inside the town screen. It will work when you go over a section and when you go off a section. This trigger works out after standard behavior (usually hint text displaying). (See |
!?MP; | Trigger when music starts to play. (See |
!?MR0; |
Stack Resistance ERM control. !?MR0 works out just before calculating a resistance correction for a stack. And !?MR1 works out after calculating. So here is the sequence: - we have a basic damage from a spell (M,S,D); - !?MR0 is called (M,S,D,F[=D]); - WoG calculates a standard resistance correction (S,M, D->F); - !?MR1 is called (M,S,D,F); - end of correction (F). Here M means a monster type, S means a spell number, D means the basic damage, F means the corrected damage. Standard WoG correction function calculated F from D and returned it. For creatures that have no resistance F=D. (See |
!?MR1; | |
!?MR2; | Dwarf-style Magic Resistance !?MR2; will work out when the game calculates dwarf-style magic resistance. You may use !!MR and other triggers. !!MR:N, !!MR:M works as before (described in !?MR0 and !?MR1 trigger section). The !!MR:F here is used as a percentage (0..100) of a chance for the spell to work. Example: ZVSE !?MR2; !!MR:F0; all creatures are completely immune to all |
!?MW0; | Trigger for Wandering Monsters Called when monster reaches a destination point/hero Comments: It will be called a next turn after monster really reached a position or just before attacking a Hero. Called if only a corresponding flag is set. v997 keep a number of WM that is a caller. (See |
!?MW1; | Trigger for Wandering Monsters, called when a monster is killed. Comments: It will be called the turn after a monster is really killed. It's only called if the corresponding flag is set. v997 keep the number of the WM that is the caller. (See |
|
This trigger works for any object that has an "entrance" (yellow square in editor). Note: this includes monsters, artifacts, and resource piles too but does not include other heroes (use the HL trigger for heroes). #1 - X position of entrance on the map #2 - Y position on the map #3 - level (0-Surface, 1-Underground). Important: The sequence of finding object triggers: !?OB$; common by type !?OB$/$; common by type and subtype !?OB$/$/$; particular object You can refer to the exact position of the object in receivers following the trigger: x,y and level will be stored in v998,v999 and v1000 when the trigger activates. Example: !?OB101; come here for any chest on the map !!CH998:... change whatever you want using indexed variables as a position x,y,l for a particular chest at x,y,l. To set up or change the properties of an object, use the appropriate For a more detailed and explained version of OB trigger, read |
!$OB#1/#2/#3; | Post visit OB trigger for object at x=#1, y=#2, level=#3 |
!?OB#1; | Alternate format for OB trigger. Turns on for any objects of #1 type. See |
!?OB#1/#2; | Alternate format for OB trigger. Turns on for any objects of #1 type and #2 subtype. (See |
!$OB#1/#2; | Alternate format for Post visit trigger Turns on for any objects of #1 type and #2 subtype. (See |
!?OB; | Alternate format for Pre visit trigger Turns on for any objects. |
!$OB; | Alternate format for Post visit trigger Turns on for any objects. |
Post Instruction. This trigger works out a bit later than instruction are executed but after the majority of settings are done for the map. The other specific thing here is that this trigger works out ONLY if you start a new game but not if you load a saved game (so the same way as instructions do). Example: ZVSE !#IF:M^Instr^; !?PI; !!IF:M^Post Instr^; If you start this map, you will have two messages: "Instr" and then "Post Instr". When the first message appears, almost no settings are done for the map and when the second message appears, the most settings are done already. If you load a saved game, you will have no messages at all. |
|
In-game sound effects trigger This triggers for any sound (WAV or M82, but NOT MP3). It triggers every time any sound is LOADED, which doesn't always happen at the same time it is played. There is a corresponding For the sound effects list, please see |
|
Triggers for Town Hall access. !?TH0; is called when you enter a Town Hall !?TH1; is called when you leave a Town Hall Comments: 1. You could use the TH1 trigger to check for a new building built in a town. 2. You could also use it to reset the build flag with the |
|
!?TL#; ![]() | Real-Time Timer # = 0 - period of call is 1 second # = 1 - period of call is 2 seconds # = 2 - period of call is 5 seconds # = 3 - period of call is 10 seconds # = 4 - period of call is 60 seconds Example: To see how it works, you can use the next ERM code: !?TL0; !!IF:L^Tick 1 sec^; !?TL1; !!IF:L^Tick 2 sec^; !?TL2; !!IF:L^Tick 5 sec^; !?TL3; !!IF:L^Tick 10 sec^; !?TL4; !!IF:L^Tick 60 sec^; |
This is the ERM equivalent of timed events. # - from 1 to 100 - the number of a timer. To set up a timer, use the |
|
Automatic constant timers #1 - The first day (activating) #2 - The last day (-1 for infinite) #3 - The interval (in days) of happening #4 - Colours to whom it will be applied No need to set up those timers. |