UNIVERSAL COMMANDS (UN)
RECEIVER

Used for universal commands that make changes to the map and/or game. 

!!UN:XXXX;

Universal commands. These commands relate to changes on the heroes map.

OPTIONS

A#/$; Set/check/get artifact enabling to appear on the map
   # - artifact number (Format A1)
   $ - variable to set/get or check value
      1-artifact disabled
      0-artifact enabled
A#1/#2/$;

Get/check/set an artifact's info
   #1 - Artifact number
(Format A1)
   #2 - Type of info

       =  1 - Cost
       =  2 - Position on body (Format P2)
       =  3 - Type (artifact class: see below)
       =  4 - Number of combo artifact (Format CO)
       =  5 - Part of combo artifact (Format CO)
       =  8 - Gives spell or not
       =  9 - Artifact name
       =10 - Artifact description
   $ - Value
Comments:
1.Cost: This value appears to be 1/5th the purchase price of an artifact from a town Artifact Merchant if you possess no additional marketplaces. The Grail and new WoG artifacts all have an initial value of 0.
2. Position on body: If you place an artifact in an incorrect position with ERM it will still function the same way. For example, you can set Sandals of the Saint to work in the head slot instead of feet and when you equip them on your head, you get all the statistic bonuses (and lose them when you take the sandals off).
If a hero has an artifact already equipped and you change the position of that artifact type with ERM, the artifact will be left there (fully functioning) until you remove it; at that point you simply can't reequip it at that position.
3. Type: This value sets the class of artifact - no class, which includes spell books, war machines and the Grail (1), treasure (2), minor (4), major (8) or relic (16), which also includes combo artifacts and the three new WoG artifacts. Other values could probably be set as a way of making a type of custom class.
4. Number of Combo Artifact: Each combination artifact has a number that identifies it. The first one, Angelic Alliance, is number 0 and the last one, Cornucopia, is number 11. Non-Combo artifacts have a value of -1.
5. Part of a Combo Artifact: If the artifact is one that makes up a combo artifact, it will have the combo artifact number here. For any artifact that isn't part of a combo (including combo artifacts themselves), it will have a value of -1 instead.
8. Gives spell: This is set to 0 for most artifacts and 1 for artifacts like tomes, Spellbinders Hat, Sea Captain's Hat -- basically anything that gives you an additional spell. There's currently no way of checking which spells are added, however, short of comparing all spells a hero knows before and after picking up the artifact, nor any way to set the spell given by the artifact.
Setting this value to 0 (if it's normally 1) stops you getting the spells from the artifact. This is a neat way to disable these types of artifacts but still let them appear on the map and be equipped -- good for making artifacts with new abilities but not the old ones.
9. Artifact Name: This lets you set a new name for the artifact. $ is the index number of a z variable in which you've stored a new name for the artifact. A value of 0 restores the original name. A neat trick is to change the name and description of an artifact just prior to displaying it in a dialogue box -- this lets you make use of any of the artifact pictures for other display purposes.
10. Artifact Description: This lets you set a new description for the artifact. $ is the index number of a z variable  in which you've stored a new description for the artifact. A value of 0 restores the original description.

B; Remove a description/hint for an object
B#/$; Set operation or new chests and Mithril
   # = Type 
      0 - Mithril
      1...6 - new chests
   $ = Operation (0-standard,1-advanced)
The new Chests
: Type 101 Subtype 1
: Type 101 Subtype 2
: Type 101 Subtype 3
: Type 101 Subtype 4
           :  Type 101 Subtype 5
            :  Type 101 Subtype 6
The new resource : Mithril 
  : Type 79 Subtype 7
Comments:

For all new chests (type 101, subtype 1...6) standard operation means a standard Treasure Chest. Extended gives nothing to a visiting Hero (assumed that all is defined through the ERM). In both cases, the chest will disappear after being taken.
For Mithril (type 79, subtype 7) standard operation means that when you (or AI) pick it up, you will get a random type of resource (except wood or ore) and quantity that is set up for the stack in the map editor (for gold will be *100). Extended operation means that Mithril will be added to the Mithril stock of the player and you can check and set it with UN:R#/7/$.
Both work for human or AI. The AI treats Mithril as gold when deciding to pick it up or not.
C$1/$2/$3; Set/get/check memory
   $1 = memory address
   $2 = 1,2,3 or 4 -size of data in bytes
   $3 = data
D#1/#2/#3;

Make a square of water passable for hero
   #1 = x
   #2 = y
   #3 = Level
Comment:
The square is impassable for boats

D#1/#2/#3/$; Additional syntax for D commands: 
Place/remove path (logs) over water

   $ means place (1) or remove (0) logs
E#1/#2/#3;

Check where to place an object. 
This command will check if a map square is available to place a one square object.
Receiver UN, command E#1/#2/#3 in form Ex/y/l
   #1= X
   #2= Y
   #3= Level
Comments:
As a result the flag 1 will be set to TRUE (1) if the space is NOT available (a yellow or red square) and FALSE (0) if it is available. It does not mean that you cannot use this command to check if the place is ready to place a bigger object (more than 1x1). But you should check at least an accessible point (the trigger square (yellow square in the editor). Trigger squares must not overlap each other.

F$1/$2/$3/$4/$5; Provoke a fire (if possible)
   $1 = x
   $2 = y
   $3 = l
   $4
= dx
   $5
= dy
Comments:
I just wanted to check out the Fire-function. I used this script. There are only Oak Trees, no stones, mountains or anything else. So, the ERM-help says "when it's possible", but when is it?
This is possible only for one object now. Go to the map editor -> castle section -> the latest element.
If you place this tree on the map, it starts to fire as you could
see this with Gorynych' town.
We want to have more objects like this (more trees) but we have no ready. We can make a dynamic animation like burning trees, flooding and anything else. All is ready but we have no objects.
G0/#1/#2/$3; Set secondary skill text.
   #1 is a skill number (0...27) (see Format SS)
   #2 is a type of text (0...3)
         0 - name of skill
         1 - basic level description
         2 - advanced level description
         3 - expert level description
   $3 is a number of z vars (1...1000) or 0
         0 means to restore original text
Comments.
All is similar to artifacts.
You should set z vars to correspondent text (you can use only global
z vars z1...z1000)
Then set the the text.
If you change the text in this used z var - it will immediately
appear as a new text for this skill. So do not use this var for other
tasks.
Example:
!#VRz10:S^My new Name^;
!#VRz11:S^My new Basic Description^;

!$LE7/5/0;
!!UN:G0/2/0/10;
!!UN:G0/2/1/11;

!$LE8/5/0;
!!UN:G0/2/1/0;

It will set the Logistic skill name and description to the new texts
if you visit a local event at 7/5/0. The description of the basic
level of the Logistic will be restored if you visit a local event at
8/5/0.
G1/#1/#2/$; Change Monster names.
   #1 - Number of Monster (see Creature Format)
   #2 - Type of text
         0 - Singular name
         1 - Plural name
         2 - Specialty text
   $ - z variable (or its number) that keep the new text
         0 means restore original
G2/#1/#2/#3;
 
Let you set the text and picture for hero specialities.
#1-number of hero.(see Format H)
#2- set
     2-if
description text
     3- if picture
#3- is:
     -
z variable index (0 to restore) if #2=2
     -
number of the picture (0-155) if #2=3

The pictures match the current hero specialty pictures so for example, if
you wanted a picture of gems, you could use 111 (Saurug's specialty) for
the picture number. In the future, additional specialty pictures will be
added.
H#1/#2/#3/#4/#5;

Hide part of the map (round area)
   #1 = x
   #2 = y
   #3 = Level
   #4 = Owner (Format E1)
   #5 = Radius
Comments:
The shroud will be replaced for all players except the owner.

I$1/$2/$3/$4/$5; Place an object
   $1 = x
   $2 = y
   $3 = Level
   $4 = Type of object (see Format OB)
   $5 = Subtype of object
Comments:
1.
For this command, x, y and level refer to the lower right corner of the object and not to the trigger square. Sometimes this square will not even appear to be part of the object, so it's best to check in the editor; click once on the object and look for the white rectangle that appears around it--the lower-right square in this rectangle is the square that x/y/l refers to.
2 . This command is very powerful but should be used with caution. Some objects will be properly set up when placed, others must be set up using their specific object receiver or in some cases the generic !!OB receiver, and still others will not work at all and may make the game unstable. See below for a detailed list.
I$1/$2/$3/$4/$5/$6; Additional syntax for placing objects: 
$6 - Redraw
  
1 - Redraw immediately (slower), 
  
0 - Does not redraw (faster) 
Comments:
For all previous syntaxes the screen will be redrawn 
l#1/#2/#3/#4/#5/#6/#7/#8; Advanced syntax for placing objects:
   #1 = x
   #2 = y
   #3 = Level
   #4 = Type of object (see Format OB)
   #5 = Subtype of object 
   #6 = Type2 of object (see Format OB)
   #7 = Subtype2 of object 
   #8 = Terrain (see Format TR)
This means that there will be placed an object type/subtype but it will look like object type2/subtype2
Example: a two-way monolith which looks like a town.
J0/#/$; Disable spells
  # - number of spell 0...69
(see Format SP)
  $ -  0 = Enabled
        1 = Disabled
Comments:
This disabling only works for mage guilds and pyramids, but you can check the value set here and use in any ERM script. Since mage guild and pyramid spells are set at the start of a map (before it fully loads), it makes sense to use this command in an instruction or in a function called from an instruction.

There is another internal structure that is changing when shrines are being placed (every placed shrine marks a corresponding spell as disabled), so for shrines, this disabling will not work. However, you could set a disabled spell and then disable it in the shrine with a shrine receiver after checking the value with this command.
K#/$; Set up *new week* property.
   K1/$ - disable ($=1) all *week of ...* (monster +5, Imp*2) or enable ($=0) as usual.
   K2/$ - set the message of new week to string variable $.

Note: it wont disable weeks/months generated by Deities of Fire- imps/familiars will get extra growth and be spawned all over the map regardless

L#1/#2/#3/#4; Move a view to the position
   #1 = x
   #2 = y
   #3 = Level
   #4 = delay after (1000 is a second?)
Comments:
It work like Eye of the Magi but does not open a view
L#1/#2/$; Set/check/get Obelisk visited.
   #1 - player number (-2,-1,0...7)
      -2 = to all
      -1 = to current
   #2 - Obelisk index (-1,0...47)
      -1 = to all;
      $ = Obelisk visited 1 or not 0;
M#/$; Set new "Month of the" properties.
   M0 - Original behavior
   M1 - Disable weeks of monster*2 and all/2
   M2/$ - Set up a week of $ monster (monster*2) (see Format C)
   M3 - Set up a week of plague (all/2)
Comments:
 * 2nd parameter ($) only applies to M2.

Note:
it wont disable weeks/months generated by Deities of Fire- imps/familiars will get extra growth and be spawned all over the map regardless
N0/z var index/$;
N1/z var index/$;
N2/z var index/$1/$2;
N3/z var index/$1/$2;
N4/z var index/$;
Name Lookup. 
This command lets you get the name of an artifact, spell, building, monster or secondary skill by specifying its number and assign it a z string variable so you can use it in a message.
   N0/zvarind/$; - name of artifact ($=artifact number)
(see Format A1)
   N1/zvarind/$; - name of spell name ($=spell number)
(see Format SP)
   N2/zvarind/$1/$2; - name of building ($2)
(see Format U) inside town type ($1) (see Format T)
   N3/zvarind/$1/$2; - name of monster ($1=monster number)
(see Format C) in singular ($2=0) or plural ($2=1)
  
N4/zvarind/$; - name of secondary skill ($=skill number)
(see Format SS)

Example:
!#UN:N0/z100/5;
!#UN:N1/z101/6;
!#UN:N2/102/7/1;
!#UN:N3/103/8/0;
!#UN:N3/104/8/1;
!#IF:M^=%Z100=%Z101=%Z102=%Z103=%Z104=^;
O$1/$2/$3; Delete an object.
   $1 = x
   $2 = y
   $3 = Level
Comments:
For this command, x, y and level refer to the lower right corner of the object and not to the trigger square. Sometimes this square will not even appear to be part of the object, so it's best to check in the editor; click once on the object and look for the white rectangle that appears around it--the lower-right square in this rectangle is the square that x/y/l refers to.
O$1/$2/$3/h; Delete object at x/y/l and a description/hint (if was set).
   h = 1 - delete description/hint
   h = 0 - do not delete
For the style Ox/y/l description/hint will not be deleted (h=0).
P$; Setting lvl8 dwellings behaviour
   $ =1 - Standard behaviour for lvl8 dwellings (=0-as usual)

Comments:
Standard behaviour means that the level 8 dwelling will function like any other dwelling in the game, so you must visit it each week to recruit level 8 creatures there and they won't appear in the upgraded level 7 dwelling for the associated town.
P#/$; Set WOG options
   # - Number of option
   $ - Option state
Comments
# = 0 and $ = Lvl8 dwelling SoD (1) or WoG (0) [doubling for !!UN:P$]
# = 1 and $ = Towers Experience SoD (1) or WoG (0)
# = 2 and $ = Leave Monsters on the map SoD (1) or WoG (0)
# = 3 and $ = Disable Commanders (1) or Enable Commanders (0) See below for more info.
# = 4 and $ = Disable Town Demolition by a player (1) or Enable Town Demolition by a player (0)
# = 5 and $ = WoGify: random maps and maps beginning "wogify_" (0), all WoG format maps (1), all Heroes 3 maps of any format (2)
# = 6 and $ = Heroes start with Commanders (0) or they must be hired (1)
Comments:
Both WoGified and Non-WoGified WoG maps with no scripts will use the WoGify Options selected for enabling or disabling the features above.
To set Commanders so they must be hired at a town for 100 gold instead of heroes automatically starting with them, you must use UN:P6/1 before the UN:P3/0 command. You can put this all into one line as:
!!UN:P6/1 P3/0; if you wish.
P3/#; Commander enabling/disabling Now if a map has internal scripts and does not have !#UN:P3/# command, the map is running in WoG 3.56 environment (without Commanders and all). But if the map has this command (no matter !#UN:P3/0 or !#UN:P3/1), the map is treated as a new one and runs in WoG 3.57 environment (so all hard coded WoG features are taken from WoGification setup or installed by !#UN:P instructions).
This will fix the problem with impossibility to enable Commanders with !#UN:P3/0 instructions unless used in the timer trigger section.
P7/#; Dwelling accumulation enabling /disabling
New hardcoded flag to make all external dwellings accumulate creatures every week.
You can turn it on !#UN:P7/1; or off !#UN:P7/0; (default).
   # = 0 creature dwellings reset start of each week
   # = 1
creature dwellings accumulate unpurchased creatures from week-to-week.
P8/#; Guards accumulation enabling/disabling
N
ew hardcoded flag to make all external dwelling guards accumulate creatures every week.
You can turn it on !#UN:P8/1; or off !#UN:P8/0; (default).
  
# = 0 creature dwellings with guards keep the same number of guards
   # = 1
creature dwellings with guards accumulate undefeated guards from week-to-week..
Q#; Win or lose the game for CURRENT player.
  
# = 0 to lose the game
   #
= 1 to win
R#; Redraw the screen
   1 - Redraw map, heroes screen and chosen hero screen
       (all at right side).
   2 - Redraw status line with resources.
R3/#; Redraw the hero Screen inside CM2 Trigger
This command only works in a CM2 trigger while the hero screen is displayed. Trying to use it elsewhere will cause a game crash. You can redraw the screen with every mouse click if you need to update it. e.g. if you change a hero's skills or picture while the hero screen is displayed.
  
# is a hero number (-1 = current).
S#1/#2/#3/#4/#5; Open (show) part of the map (round area)
   #1 = X
   #2 = Y
   #3 = L
   #4 = Owner (Format E1)
   #5 = Radius
T#1/#2/#3/$;

Set a type of monster to hire in towns.
   #1 - Type of a town (0...8) (Format T)
   #2 - Dwelling level (0...6)
   #3 - Basic (0) or upgraded (1)
    $  - Type of monster to hire (Format C)
Comments. 
1. It works only in Towns and for AI as well.
2. You can set it with !#UN. Do not forget that you can "force" the AI to prefer hiring of one monster to another by setting "AI Value" parameter for monster by !!(#)MA:I
3. Additional resources supposed to be only for level 7 dwelling.

U#1/#2/?$1; Calculate all objects on the map
   #1 = Type of object (Format OB)
   #2 = Subtype of object (-1 = any)
   $1 = Number of objects of type #1, subtype #2 (check or get syntax only)


Example: 
U54/i/?n;
n now have a number of objects type 54 and subtype i
U#1/#2/#3/#4; Get coordinates of an object
   #1 = Type of object (Format OB)
   #2 = Subtype of object (-1 = any)
   #3 = Number of object (1...final object number)
   #4 = Index of first v variable to store the coordinates
i.e., v[#4]=x, v[#4+1]=y, v[#4+2]=l
Example: 
U54/i/3/324;
v324,v325 and v326 now keep coordinates of object type 54, subtype i and number 3
Comments:
All objects are calculated:
(first) left to right
(second) up to down
(third) surface to underground
V?$1/?$2; Gets the version of WoG and ERM being used.
   $1 version of WoG (now 356 as 3.56)
   $2 version of ERM (now 250 as 2.50)

Comments:
You can only get or check but not set the values:
e.g., !!UN:V?i/?j;
Recommendation:
Use the instruction !#UN:V to check version and then display a message for the player at the start of the map that they have an older version of the Addon (if they do). This is better then them getting half way through the map before finding out they can't finish it.
V?$1/?$2/$?3/?$4/?$5; Gets the version of WoG and ERM being used.
Additional Syntax
   $1 - Get or check the WoG version
   $2 - Get or check the ERM version
   $3 - Get or check "one or more humans" in the game
             = 1 for one human
             = 2 for more than one human 
   $4 - Get or check "one or more PCs" in the game
            = 0 for one PC (no net), =1 for more than one PC (net)
   $5 - Get or check type of the game
           = 0 - Single Player 
           = 1 - IPX
           = 2 - TCP/IP
           = 3 - Hot Seat
           = 4 - Direct Connect
           = 5 - Modem
W#1/#2/#3/#4/#5;

Make a "line" of water passable for hero
   #1 = X1
   #2 = Y1
   #3 = X2
   #4 = Y2
   #5 = Level
Comment:
This line is impassable for a boat. This is a line so be careful when using it.

W#x1/#y1/#x2/#y2/#l/#1; Additional syntax for W in UN receiver.
Place/remove path (logs) over water

   #1 means place (1) or remove (0)
X?$1/?$2; Get a size of map
   $1 will receive the size of the map (X=Y)
   $2 will be 0 if you have one level and 1 if you have two levels
You can only GET or CHECK values but not SET them.
Example:
!#UN:X?i/?j;
!#VRz1:S^only one level^; !#VRz1&j=1:S^two levels^;
!#IF:M^Map is X=%Vi by Y=%Vi and has %Z1.^;

Placing Objects (with I option):
These objects should work correctly without additional set up. Many may be customized with a specific object receiver if desired.

Artifacts (type=5, subtype=0-143) - Receiver: !!AR
Boats (type=8, subtype=0-2)
Creature Generators (type=17, subtype=0-88 and 20, subtype=?) - Receiver: !!DW
Garrison (type=33, subtype=0 for standard, =1 for anti-magic) - Receiver: !!GR
Grail (type=36, subtype=0)
Lighthouse (type=42, subtype=0-7 for player colours or -1 for neutral)  - Receiver: !!MN (same as for mines)
Marletto Tower (type=23, subtype=0)
Monolith Two Way (type=45, subtype=0-7)
Mine (type=53, subtype=0-7) - Receiver: !!MN
Monster (type=54, subtype=0-144) - Receiver: !!MO
Ocean Bottle (type=59, subtype=0) - Receiver: !!SG (same as for signs)
Redwood Observatory (type=58, subtype=0)
Resource (type=79, subtype=0-6) - Receiver: !!AR (same as for artifacts)
Sanctuary (type=80, subtype=0)
Shipyard (type=87, subtype=0-7 for player colours or -1 for neutral)  - Receiver: !!SY
Sign (type=91, subtype=0) - Receiver: !!SG
Spell Scroll (type=93, subtype=0-69) - Receiver: !!AR
Town (type=98, subtype=0-8) - Receiver: !!CA
University (type=104, subtype=0) - Receiver: !!UR
Witch Hut (type=113, subtype=0-27) - Receiver: !!WH

These objects will probably need additional set up with their specific object receiver to work correctly:

Campfire (type=12, subtype=0) - Receiver: !!FR
Corpse (skeleton) (type=22, subtype=0) - Receiver: !!SK
Event (type=25, subtype=0) - Receiver: !!LE - if placed with I option, this event will initially be set as enabled to all players and will not be cancelled after the first visit.
Lean To (type=39, subtype=0) - Receiver: !!LN
Learning Stone (type=100, subtype=0) - Receiver: !!ST
Magic Shrine (type=88,89,90, subtype=0) - Receiver: !!SR
Magic Spring (type=48, subtype=0) - Receiver: !!SP
Mystical Garden (type=55, subtype=0) - Receiver: !!GD
Obelisk (type=57, subtype=0) - Receiver: !!MT
Pyramid (type=63, subtype=0)  - Receiver: !!PM
Scholar (type=81, subtype=0) - Receiver: !!SC
Swan Pond (type=14, subtype=0) - Receiver: !!SW
Treasure Chest (type=101, subtype=0) - Receiver: !!CH
Tree of Knowledge (type=102, subtype=0) - Receiver: !!KT
Wagon (type=105, subtype=0) - Receiver: !!WG
Warrior's Tomb (type=108, subtype=0) - Receiver: !!WT
Water Wheel (type=109, subtype=0) - Receiver: !!WM
Windmill (type=112, subtype=0) - Receiver: !!ML

These objects will NOT work properly and may possibly cause game instabilities, map crashes or other problems if placed:

Pandora's Box (type=6)
Hero (type=34) - (use the HE:P command to place a hero on the map instead)
Prison (type=62)
Seer's Hut (type=83)
Quest Guard (type=215)

Other Objects
Some other objects not listed above (aside from rocks, trees, etc.) may need to be set up with the generic object command; you can try changing their control number so as not to duplicate an existing object of the same type, but this is by no means guaranteed to work. Also, some objects not listed may actually work fine with no set up required--but they have not been tested yet. Proceed at your own risk.

About deleting objects
There are several tables for every object on the map. And cross reference links not always exist. Usually the Heroes use a way to find for positions. When you delete an object, some tables still are the same (keep info about deleted object). If then you add a new object of the same type at the same place, the new info is also added to those tables. But then when the game need to get info about this new object, it starts to search it in the table by position. Obviously, that the info for the first (deleted) object will be found first. This is not very good :-(
Good that we know it now. And Donald's proposition to set up an old object before deletion look fine. I still recommend both set up an old object, delete it, place a new one and set it up again :-)
Remember that this problem is possible for objects of the same type and not every type.