home » builders » builder's lessons » shooting mobs
Shooting mobs
You have protected your area with archers, but they only attack when the PC is in the room with them, not from a distance. How do you make them attack a PC from a room or two away like an archer should?
Use a greet prog in the rooms before the archers, and with the use of the mpat command you can get your archers happily shooting PC intruders. Another is to put fight progs on the mobiles who are currently fighting the PC, to have the archers shoot from the other room to aid in the battle. To follow are samples from the Storm Keep area where mobiles with ranged weapons shoot at PC's as the enter the hallway.
#2201 Troll Guard~ {20}a troll guard~ {20}A troll guard stands here. ~ This troll is unusually big and ugly, with dark yellowing teeth and breath that reeks of rotting flesh. He is hunched over, and though his red eyes are filled with malice they show little signs of intelligence. ~ S 45 CLASS_FIGHTERS RACE_TROLL SEX_MALE POS_STANDING DEITY_NONE ACT_SENTINEL >greet_prog 60~ say You not welcome. Go away! mpkill $n ~ >fight_prog 80~ if inroom($i) == 2200 or inroom($i) == 2201 or inroom($i) == 2202 mpat 2203 mpforce m2208 mpoload 2207 mpat 2203 mpforce m2208 shoot south $n mpechoat $n {80}Someone shoots a crossbow bolt at you, from the north. mpechoaround $n {80}Someone shoots a crossbow bolt at $N, from the north. else if inroom($i) == 2212 or inroom($i) == 2211 mpat 2203 mpforce m2208 mpoload 2207 mpat 2203 mpforce m2208 shoot east $n mpechoat $n {80}Someone shoots a crossbow bolt at you, from the west. mpechoaround $n {80}Someone shoots a crossbow bolt at $N, from the west. endif endif ~ |
In the above example when this troll is under attack, trolls that are a room or two away will shoot into the battle at the PC. What is being loaded is a fresh crossbow bolt. The trolls have the actual crossbow on them in resets, but the code makes them load a fresh bolt each time.
In another area I use a greet prog in the room to get mobiles to shoot from a few rooms away at an entering PC. See the sample below.
>greet_prog 100~ if level($n) > 10 mpat 6592 mpforce m6500 shoot south $n endif ~ |
It should be noted that if the mobiles are not in the room in question, then this prog will not work. So if the PC has already killed the mobile then it wont work. You will perhaps need to make sure that your mobiles are sentinel so that there are there to shoot at the PC, and not wandered off to another room.