Monster Placement
At the beginning of a combat event we need to determine the initial positions of all the monster combatants. Here is how we go about it:
We determine how many monsters will be present and divide them up into the four possible directions from the party as specified by the combat definition editor.
For each of the four directions we look for a Global Special ability named 'CombatPlacement'. If it is found we search the Special Ability for a script named 'PlaceMonsterClose', 'PlaceMonsterNear', or 'PlaceMonsterFar', depending on the choice made in the combat editor.. If found, we run it.
The script can control the placement of the monsters in that one direction. It can place the monsters wherever it chooses but it can only control those monsters that the editor said should be placed in the one particular direction.
The script controls monster placement by controlling a 'virtual' turtle. The turtle starts at the location of the party. It may very well be that there is no party member at that location (See Party Arrangement). The script can tell the turtle to take a step forward, backward, left, or right. We avoid absolute directions like 'North' so that the same turtle commands will work for any of the four directions from the party. The turtle can also cause a monster to be placed at the turtle's current position.
For example, to place three monsters in a single rank six cells from the party the instructions might be:
Forward six steps
Place a monster
Right one step
Place a monster
Left 2 steps
Place a monster
The script issues these commands by executing $MonsterPlacement(string). The string contains single character commands which are executed one-at-a-time:
'F' - One step forward
'B' - One step Backward
'R' - One step to the right
'L' - One step to the left
'P' - Plant a monster here.
'?' - What kind of cell does the turtle occupy? A character will be added to the resulting status string. See Status Codes below.
'S' - Sets the turtle size to the size of the next monster to be placed. This affects the results of the '?' command.
'V' - 'Visible' - Enforce 'Line-of-Sight' placement. 'P' commands are ignored unless the turtle can see any of the party members or previously placed monsters.
'd' - Enforce a minimum distance from the nearest party member. Ignore any placement command in a cell that is less distant than the turtle's current distance from the party member nearest the turtle.
'E' – Search the area around the turtle in an 'E'xpanding circle and place a monster in any position that meets the current limitations such as those imposed by 'd', 'b', 'V', etc.
'f', 'b', 'l', 'r' – 'f'orward, 'b'ackward, 'l'eft, and 'r'ight limits. Draw perpendicular north/south and east/west lines through the turtle. No monster can be placed 'f'orward, 'b'ackward, 'l'eft, or 'r'ight of the appropriate line. Notice that these lines would not be perpendicular as displayed on the combat screen. A north/south line would go from the top-left to the bottom-right of the screen.
'u' and 'o' – P'u'sh and P'o'p the turtle's position. 'Push' causes the turtle's position to be written down on a 3x5 card and the card is pushed onto a stack of such cards. 'Pop' causes the top card in the stack to be removed and the turtle to be moved to the position written on the card. If you 'pop' when there are no cards on the stack, the turtle will be returned to its initial position at the party origin.
'w', 'n', 'p', 's' – directions on a ship. Bo'w' is to the front (the direction in which the monsters are being placed). Ster'n' is toward the rear. The left side is the 'p'ort side. The right side is the 's'tarboard side. These commands cause the turtle to move in one of the four directions so as to be even with the party member who is the farthest advanced in that direction. For example, 'w' moves the turtle to the party rank closest to the monsters being placed. If we wanted to be sure that the monsters were placed at least one cell forward of the party we could supply the string “uwFbo”. This remembers the turtle's position, goes to the party's front rank, goes forward one step, sets the monster placement limit, and restores the turtle's initial position.
Any of the commands can also be preceded by an integer telling how many times to repeat the next step. The string for our example would be: “6FPRPLLP”.
The script can call this function as many times as is needed to position all of the monsters in a single direction.
Status Codes
$MonsterPlacement() returns a string as status. A '0' (zero) indicates that the command contained a 'P' (to place a monster) but that there were no more monsters available to be placed.
Responses to the '? command. If the turtle size is other than one-by-one then it is possible that more than one status could apply. But you only receive the the one we discover first.
'w' - Wall
''s' – A lingering spell effect
'o' – Occupied by another combatants
'i' – Illegal location --- off the map
'n' – Nothing. Empty cell.
Hook Parameters
None
Context
None