NERPs coordinated monster attack setup

This article is an unfinished work in progress or contains transferred information that needs to be rewritten or reformatted to fit our standards. Please excuse the mess and do not mark for deletion.

Warning: this was written a long time ago and may be outdated enough to be flat-out wrong. See Writing NERP Scripts for a more up-to-date commentary. In particular, SetRockMonsterAtTutorial is used to emerge monsters at the walls in Tuto.map and SetCongregationAtTutorial only seems to be affect a single monster once.


A coordinated monster attack involves having monsters emerge and attack at a specific location under specific circumstances, and possibly also following a predetermined path. This is done with tutorial blocks and a section of script that programs what those blocks trigger. This is a rather complicated setup and should only be tried by skilled modders.

Attack based on energy crystal count

Similar to the slimy slug setup, monsters can attack based on how many energy crystals the player has collected. An example that includes this bit of script would be Lava Laughter.

 GetCrystalsCurrentlyStored = 10 ? SetRockMonsterAtTutorial 1
 GetCrystalsCurrentlyStored = 20 ? SetRockMonsterAtTutorial 2
 GetCrystalsCurrentlyStored = 30 ? SetRockMonsterAtTutorial 3
 GetCrystalsCurrentlyStored = 40 ? SetRockMonsterAtTutorial 4
 GetCrystalsCurrentlyStored = 50 ? SetRockMonsterAtTutorial 3
 GetCrystalsCurrentlyStored = 60 ? SetRockMonsterAtTutorial 4

Though this does not control rock monsters emerging, this tells them where to go, based on the amount of crystals the player has collected. So if the player does not have many crystals, the monsters present on the level will ignore squares that have lots of crystals on them, and will go scavenging elsewhere. A few more crystals, and they would attack the base instead. With lots of crystals they would go straight for the large horde of crystals, and then attack base. When compiled, this translates to:

 0D 00 02 00 07 00 01 00 0A 00 00 00 04 00 01 00 9F 00 02 00 01 00 00 00
 0D 00 02 00 07 00 01 00 14 00 00 00 04 00 01 00 9F 00 02 00 02 00 00 00
 0D 00 02 00 07 00 01 00 1E 00 00 00 04 00 01 00 9F 00 02 00 03 00 00 00
 0D 00 02 00 07 00 01 00 28 00 00 00 04 00 01 00 9F 00 02 00 04 00 00 00
 0D 00 02 00 07 00 01 00 32 00 00 00 04 00 01 00 9F 00 02 00 03 00 00 00
 0D 00 02 00 07 00 01 00 3C 00 00 00 04 00 01 00 9F 00 02 00 04 00 00 00

Each line corresponds to the line of readable script to make it more easily decipherable.

Specialized attack setup

This is a somewhat more complicated method of script. A good example of a map with a specialized attack setup would be Don't Panic!. It is more or less the same as attacks based on energy crystal count, however it is instead determined by Rock Raiders crossing designated tutorial blocks which trigger Monster spawns and coordinates them to attack certain positions, which gets updated as the Rock Raiders progress through the cavern. This is designated in this long looking section (though its mostly repeated parameters):

 GetMonstersOnLevel > 2 ? :jump
 
 GetRecordObjectAtTutorial 31 > 0 ? SetRockMonsterAtTutorial 1
  	
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 19 0
 	
 GetRecordObjectAtTutorial 31 > 0 ? SetCongregationAtTutorial 11 1
 
 GetRecordObjectAtTutorial 32 > 0 ? SetRockMonsterAtTutorial 2
 		
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 19 0
 		
 GetRecordObjectAtTutorial 32 > 0 ? SetCongregationAtTutorial 12 1
 
 GetRecordObjectAtTutorial 33 > 0 ? SetRockMonsterAtTutorial 3
 		
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 19 0
 
 GetRecordObjectAtTutorial 33 > 0 ? SetCongregationAtTutorial 13 1
   
 GetRecordObjectAtTutorial 34 > 0 ? SetRockMonsterAtTutorial 4
 		
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 19 0
 		
 GetRecordObjectAtTutorial 34 > 0 ? SetCongregationAtTutorial 14 1
 
 GetRecordObjectAtTutorial 35 > 0 ? SetRockMonsterAtTutorial 5
 		
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 19 0
 	
 GetRecordObjectAtTutorial 35 > 0 ? SetCongregationAtTutorial 15 1
 
 GetRecordObjectAtTutorial 36 > 0 ? SetRockMonsterAtTutorial 6
   		
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 19 0
 	
 GetRecordObjectAtTutorial 36 > 0 ? SetCongregationAtTutorial 16 1
 
 GetRecordObjectAtTutorial 37 > 0 ? SetRockMonsterAtTutorial 7
 	
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 19 0
 	
 GetRecordObjectAtTutorial 37 > 0 ? SetCongregationAtTutorial 17 1
 
 GetRecordObjectAtTutorial 38 > 0 ? SetRockMonsterAtTutorial 8
 		
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 19 0
 
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 18 1
 
 GetRecordObjectAtTutorial 38 > 0 ? SetRockMonsterAtTutorial 9
 		
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 11 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 12 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 13 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 14 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 15 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 16 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 17 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 18 0
 GetRecordObjectAtTutorial 39 > 0 ? SetCongregationAtTutorial 19 0
 	
 GetRecordObjectAtTutorial 38 > 0 ? SetCongregationAtTutorial 19 1
 jump:
 		
 		GetOxygenLevel = 0 ? SetLevelFail
 		GetMiniFiguresOnLevel < 5 ? SetLevelFail
 		
 		TRUE ? SetR1 0
 		GetRecordObjectAtTutorial 21 > 0 ? AddR1 1
 		GetRecordObjectAtTutorial 22 > 0 ? AddR1 1
 		GetR1 = 0 ? Stop

This lengthy piece of script describes the specific conditions on how the monsters emerge. The first line "GetMonstersOnLevel > 2 ?" indicates the maximum number of monsters that emerge, which is three in this case. If more than that number of monsters spawns at a time, it jumps (indicated by :jump) to the bottom (indicated by jump:) and skips other spawns and forces extra monsters to evacuate.

The middle section coordinates what tutorial-block (marked in the Block Pointers map) squares the monsters spawn (SetRockMonsterAtTutorial, which must be on a wall) and what square they are heading towards (SetCongregationAtTutorial, which must be on a square of open cavern, preferably near a wall). These are triggered by the Rock Raiders (the "Record Object" in this case) crossing certain blocks (indicated by GetRecordObjectAtTutorial). This way as the Rock Raiders move through the cavern, the monster's destination is updated to the new squares. (This is accomplished by turning "goal" squares on and off by setting them to 1 or 0. Whenever the "goal" square is updated by the Rock Raiders triggering a certain block, all goal squares are set to 0 and then the new goal square is set to 1.) This is used rather effectively in Don't Panic to make it seem like monsters are chasing them through the cavern.

At the end of the section determines when to stop the coordinated attack, which is good to set so that monsters don't keep spawning when ever Rock Raiders pass over a certain square. If they are recorded across a certain square (in this case 21 or 22) the monster attack is set to stop, and the script ends. There are also two lines in the middle designating the terms for mission failure.

The specialized setup can be organized in any number of ways, depending on how the you want them to attack; this is just an example.

Examples of missions that include this setup