MISCELLANEOUS
Object RECEIVERS

Many of the map objects have their own specific receivers that can be used to change, set up or check or store (in variables) their properties. No check for the object's existence is made at map startup, but one is made when the command is executed. When you see the "Number" of the object, that means that you can set the number of this object from 0 to 31. This number is used when hero visits the object as a check value (visited/not).

Note that you can use indirect syntax to refer ANY of this receivers, for example
  !!MN998:XXXX
will execute XXXX commands for mine with location stored in v998/v999/v1000.

!!MN#1/#2/#3:XXXX;

!!MN#1/#2/#3: Mine at x,y,l coordinates
(Mines are Types 53 and 220)

O
$
- Set/check an owner
        0...7= See Format E1
        -2=current player
        -1=nobody's
O$/1 the same as MN:O$ but without redrawing

R$ - Set/check produced resource type (0...6). See Format_R.
R
$/1
the same as MN:R$ but without redrawing

M
#1/$2/$3 - Change/check guards
   #1 - Number of slot (0...7)
   $2 - Monsters type (-1 means free slot). See Format C.
   $3 - Number of Monsters
Comments:
You can't set guards on a mine that doesn't have an owner unless the mine is an abandoned mine.


Note: if someone wishes to loop through all mines, (s)he should use the "no redraw" option, or else the loop will take longer than other, comparable loops (for example, a loop through all heroes)

!!SC#1/#2/#3:XXXX; !!SCx/y/l: Scholar at x,y,l coordinates
(Scholars are Type 81)

   T$ - Type of bonus: 0=primary skill, 1=secondary skill, 2=spell
   P$ - Primary skill index. See Format PK

   S$ - Secondary skill index. See
Format SS.
   L$ - Spell index. See
Format SP.
!!CH#1/#2/#3:XXXX; !!CHx/y/l: Treasure Chest at x,y,l coordinates
(Treasure Chests are Type 101)

   S$ - Type of bonus Art.=1 or Gold / Experience=0
   A$ - Artifact number (
Format A1)
   B$ - Bonus as gold/experience to $
$ may be 0...15
gold = $*500
experience =$*500-500
If $=0, that means that you get 0 gold and -500 exp.
As you can see, you can give a hero up to 7500 gold or 7000 exp.
!!WT#1/#2/#3:XXXX; !!WT#1/#2/#3: Warrior's Tomb at x,y,l coordinates
(Warrior's Tombs are Type 108)

   A$ - Artifact number (
Format A1)
   S$ - has artifact=1 or not=0
!!KT#1/#2/#3:XXXX; !!KT#1/#2/#3: Tree of Knowledge at x,y,l coordinates
(Trees of Knowledge are Type 102)

   S$ - Type of tree:
 
          =0 (Free)
           =1 (2000 gold)
           =2 (10 gems)
   N$ - Number of the Knowledge Tree (0...31)
!!FR#1/#2/#3:XXXX; !!FR#1/#2/#3: Campfire at x,y,l coordinates
(Campfires are Type 12)

   B$1/$2 - Bonus type ($1) (Format R) and value ($2)
Comments:
Campfires always have a resource as well as gold. So if the value of $2 is 5, it will have 5 of the resource ($1) and 500 gold.
!!LN#1/#2/#3:XXXX; !!LN#1/#2/#3: Lean To at x,y,l coordinates
(The Lean To is Type 38)

   B$1/$2 - Bonus type ($1) (Format R) and value ($2)
   N$ - Number of the Lean To (0...31)
!!ST#1/#2/#3:XXXX; !!ST#1/#2/#3: Learning Stone at x,y,l coordinates
(Learning Stones are Type 100)

   N$ - Number of the Learning Stone (0...31)
!!WG#1/#2/#3:XXXX; !!WG#1/#2/#3: Wagon at x,y,l coordinates
(Wagons are Type 105)

   S$ - Has bonus=1 or not=0
   B$ - Bonus is artifact=1 or resource=0
   A$ - Artifact number. See
Format A1
   R$1/$2 - Resource type ($1) and value ($2). See Format R.
!!SK#1/#2/#3:XXXX; !!SK#1/#2/#3: Skeleton (Corpse) at x,y,l coordinates
(Skeletons are Type 22)

   A$ - Artifact number. See
Format A1
   N$ - Number of the Skeleton (0...31)
   S$ - Has artifact=1 or not=0
!!SP#1/#2/#3:XXXX; !!SP#1/#2/#3: Magic Spring at x,y,l coordinates
(Magic Springs are Type 48)

   S$ - Loaded=1 or empty=0
   N$ - Number of the Magic Spring (0...31)
!!WM#1/#2/#3:XXXX; !!WM#1/#2/#3: Water Wheel at x,y,l coordinates
(Water Wheels are Type 109)

   B$ - Gold value
!!SW#1/#2/#3:XXXX; !!SW#1/#2/#3: Swan Pond at x,y,l coordinates
(Swan Ponds are Type 14)

   B$ - Value of luck 1...3
   N$ - Number of the Lake (0...31)
!!MT#1/#2/#3:XXXX; !!MT#1/#2/#3: Obelisk at x,y,l coordinates
(Obelisks are Type 57)

   N$ - Number of the Obelisk (0...31)
!!GD#1/#2/#3:XXXX; !!GD#1/#2/#3: Mystical Garden at x,y,l coordinates
(Mystical Gardens are Type 55)

   B$ - Type of resource [usually = 5]. See Format R
   T$ - Bonus type is resource=1 or gold=0
   N$ - Number of the Mystical Garden (0...31)
!!ML#1/#2/#3:XXXX; !!ML#1/#2/#3: Windmill at x,y,l coordinates
(Windmills are Type 112)

B$1/$2 - Resource type ($1) and value ($2). See Format R
!!DW#1/#2/#3:XXXX; !!DW#1/#2/#3: Monster dwelling at x,y,l coordinates
(Monster Dwellings are Types 17 and 20, See Format CG)

M
#1/$2/$3
- set/get/check the monster to hire
   #1 = Slot (0...3) - you can hire up to 4 different monsters at one dwelling.
   $2 = Type of the monster (-1=disable this slot) (Format C)
   $3 = Number to hire

G
#1/$2/$3
- set/get/check the monster as a Guard
   #1 = Slot (0...6)
   $2 = Type of the monster (-1=no monster there). See
Format C
   $3 = Number of Monsters

O
$
- Set/get an owner (-1=nobody's)

O$/1; pass control over a dwelling to another player
   $ = is a new owner.
   The second parameter is a dummy but use 1 there.

   This syntax chenges the owner plus calls an internal structure to adjust all growth numbers for the previous and a new owner.
   Should work in MP mode.

Note: if someone wants to set up a dwelling to sell more than one creature type, none of the creatures should be level 1, or there will be trouble because level 1 creature are normally handed out for free 

!!WH#1/#2/#3:XXXX; !!WH#1/#2/#3:: Witch Hut at x,y,l coordinates.
(Witch Huts are Type 113)

Command S$ can set/check/get the skill to 0...27 (Format SS)
!!SY#1/#2/#3:XXXX !!SY#1/#2/#3: Shipyard at x,y,l coordinates
(Shipyards are Type 87)

O$ : Set/check/get the owner (0...7,-1). See
Format E1

P$1/$2 : Set the point on the map where the boat will be placed if you buy it. By default this is x+1 and y+1 from right bottom corner of the shipyard. You can place it not only on water :-)
If the point is out of the map, you cannot buy a boat.

!!GR#1/#2/#3:XXXX; !!GR#1/#2/#3: Garrison at x,y,l coordinates
(Garrisons are Types 33 and 219)

O$ : Set/check/get the owner (0...7,-1). See Format E1.

G#1/#2/#3 : Set/check/get the monster as a Guard
   #1 = Slot (0...6)
   $2 = Type of the monster (-1=no monster there). See
Format C
   $3 = Number of Monsters

F$ : Set/check/get if you can delete (remove?) the guards (1=no, 0=yes).

!!SR#1/#2/#3:XXXX; !!SR#1/#2/#3: Magic shrine at x,y,l coordinates
(Magic Shrines are Types 88, 89 and 90)

S$ : Set/get/check the spell number (see
Format SP) for any kind of Shrine.
!!UR#1/#2/#3:XXXX; !!UR#1/#2/#3: at x,y,l coordinates- University
(Universities are Type 104)

S$1/$2/$3/$4 are the skills that will be offered. See
Format SS.
You can now place a new university correctly with the UN:I command and set the skills offered with the UR receiver.
!!SG#1/#2/#3:XXXX; !!SG#1/#2/#3: - Sign or bottle at x,y,l coordinates.
(Signs are Type 91. Bottles are Type 59)

For Sign (t=91, terrain dependable) or Bottle (t=59) you can set any message. 
M#, M^...^, M-1 - restore the default message. When placed on the map the message is any from default list.
!!CB#1/#2/#3:XXXX; !!CB#1/#2/#3: - Creature Bank at x,y,l coordinates.

Commands:
   M$1/$2 - set/get/check a bonus creature type $1 and number $2
     The number of bonus creatures should be >0 and <128.
     To remove bonus creatures, set it to type -1 and number 0.
   G#1/$2/$3 - set/get/check a guard creature in slot #1 (0...7), to type $2 and number $3.
   R#1/$2 - set/get/check a resource bonus. Resource type #1 and amount $2. You may set all 7 resources simultaneously.
   T$ - set/get/check whether CrBank is taken already (1) or not yet (0). Note, that if you reset a bank to not taken (set to 0), you still should set at least one guard stack unless you want the next hero that visits to get the treasure for free.
   V$ - set/check/get a word of visiting of a player. This is a bit mask, so red is 1, blue is 2, tan is 4, green is 8 and so on.

Artifact bonus.
   A1/$ - get/check number of artifacts in the bonus list (you cannot set it).
   A2/$ - get/set/check an artifact $ at position # (0...) in the bonus list.
   A3/$ - add an artifact $ to the end of the bonus list.
   A4/$ - remove artifact at position $ (0...) in the bonus list.
Comments.
You can make an almost unlimited list of artifacts for any Creature Bank.
You cannot set a scroll as an artifact; the game will treat it wrong and then crash.
The CB receiver should also work with Dragon Utopia, Crypt, Derelict Ship, and Shipwreck.
!!MK#1/#2/#3:XXXX;
Alpha 8.2
!!MK#1/#2/#3: Black Market at x,y,l coordinates.
(Black Markets are type 7)

  A#/$; - Get/set artifact in given slot
    # - slot (0..6)
    $ - set/get artifact (
Format A1)
    Setting scroll instead of regular artifact may lead to crash

  I$; - Get/set index of Black Market's pool
    $ - index (0 up to Number of Black Markets on Map - 1)
    You can setup multiple Black Markets to use same pool of artifacts - buying artifact in one will make it unavailable in other one aswell. Technically it's same as OB:C, except it secures type (doesn't work if type <> 7) and index value ( 0 <= index <= number_of_black_markets-1, otherwise error is shown)

Comments:

In most cases it is inadvisable to try to set up objects using an immediate instruction (!#) at map start-up rather than using a standard receiver that follows a trigger. This is because these object setup commands often don't work as immediate instructions, or worse, will cause the map to crash.

There is one thing that worrys me: for example, Black Markets has allocated memory at map start (between !# and PI) There is one pool (7 slots) for every Black Market on map. OB:C stores index in this list. So, if you have 3 Black Markets, first found (topleft-topright-bottomleft-bottomright) has OB:C = MK:I = 0, next one has 1, last one will be 2.
What exactly happens if you place new Black Market with ERM though? Will it have non-existant pool 3 (this will likely cause segfault when visited) or will it be 0 - the same pool as first Black Market on map?
Same issue might apply to other objects, so be careful. Everything can be managed with smart coding though :)

Now you can not only set but also get the string parameters. You can use it when M command is used to set name/message.
Example:
!!IFv10:S5;
!!SG4/3/0:M1/v10; set sign message to string var z[v10] or z5
!!SG4/3/0:M1/?z10; get current sign message to z10 string var

Be careful: don't use OB command with an object with 2 entrance (yellow case)
When you place an object, it will set up only first right bottom entrance square that will be met. Then you should manually copy a control word (OB:C) from that square to all other yellow squares of this object.
The same goes for "Other Objects" receivers - most of those modify control word (OB:C)

How I check if AI visit objects?
When any hero visits an object the AI flag is stored in flag1000. So you can use it like here:
!?OB...;
!!IF&1000:M^Player^;
!!IF&-1000:M^AI^;