Improved knockback messages
authorMartin Read <martin@blackswordsonics.com>
Tue, 24 Sep 2013 19:44:35 +0000 (20:44 +0100)
committerMartin Read <martin@blackswordsonics.com>
Tue, 24 Sep 2013 19:44:35 +0000 (20:44 +0100)
monsters.c

index 7c273e7..dfa17ce 100644 (file)
@@ -44,33 +44,33 @@ int summoning(int y, int x, int how_many)
     int pmon;
     for (i = 0; i < how_many; i++)
     {
-       for (tryct = 0; tryct < 20; tryct++)
-       {
-           dy = zero_die(3) - 1;
-           dx = zero_die(3) - 1;
-           if ((terrain[y + dy][x + dx] == FLOOR) &&
-               (mapmonster[y + dy][x + dx] == -1) &&
-               ((y + dy != u.y) || (x + dx != u.x)))
-           {
-               pmon = get_random_pmon();
-               if (pmon_is_magician(pmon))
-               {
-                   /* Never summon magicians! */
-                   continue;
-               }
-               mon = create_mon(-1, y + dy, x + dx);
-               if (mon != -1)
-               {
-                   created++;
-                   break;
-               }
-           }
-       }
+        for (tryct = 0; tryct < 20; tryct++)
+        {
+            dy = zero_die(3) - 1;
+            dx = zero_die(3) - 1;
+            if ((terrain[y + dy][x + dx] == FLOOR) &&
+                (mapmonster[y + dy][x + dx] == -1) &&
+                ((y + dy != u.y) || (x + dx != u.x)))
+            {
+                pmon = get_random_pmon();
+                if (pmon_is_magician(pmon))
+                {
+                    /* Never summon magicians! */
+                    continue;
+                }
+                mon = create_mon(-1, y + dy, x + dx);
+                if (mon != -1)
+                {
+                    created++;
+                    break;
+                }
+            }
+        }
     }
     if (created > 0)
     {
-       map_updated = 1;
-       display_update();
+        map_updated = 1;
+        display_update();
     }
     return created;
 }
@@ -86,13 +86,13 @@ int get_random_pmon(void)
     int pm;
     for (tryct = 0; tryct < 200; tryct++)
     {
-       pm = zero_die(NUM_OF_PERMONS);
-       if (reject_mon(pm))
-       {
-           pm = -1;
-           continue;
-       }
-       break;
+        pm = zero_die(NUM_OF_PERMONS);
+        if (reject_mon(pm))
+        {
+            pm = -1;
+            continue;
+        }
+        break;
     }
     return pm;
 }
@@ -102,47 +102,47 @@ int create_mon(int pm_idx, int y, int x)
     int mon;
     if (mapmonster[y][x] != -1)
     {
-       print_msg("Attempt to create monster at occupied space %d %d\n", y, x);
-       return -1;
+        print_msg("Attempt to create monster at occupied space %d %d\n", y, x);
+        return -1;
     }
     if (pm_idx == -1)
     {
-       pm_idx = get_random_pmon();
-       if (pm_idx == -1)
-       {
-           return -1;
-       }
+        pm_idx = get_random_pmon();
+        if (pm_idx == -1)
+        {
+            return -1;
+        }
     }
     for (mon = 0; mon < 100; mon++)
     {
-       if (monsters[mon].used == 0)
-       {
-           monsters[mon].mon_id = pm_idx;
-           monsters[mon].used = 1;
-           monsters[mon].y = y;
-           monsters[mon].x = x;
-           monsters[mon].ai_lasty = -1;
-           monsters[mon].ai_lastx = -1;
-           monsters[mon].hpmax = permons[pm_idx].hp + ood(permons[pm_idx].power, 1);
-           monsters[mon].hpcur = monsters[mon].hpmax;
-           monsters[mon].mtohit = permons[pm_idx].mtohit + ood(permons[pm_idx].power, 3);
-           monsters[mon].defence = permons[pm_idx].defence + ood(permons[pm_idx].power, 3);
-           monsters[mon].mdam = permons[pm_idx].mdam + ood(permons[pm_idx].power, 5);
-           if (permons[pm_idx].rdam != -1)
-           {
-               monsters[mon].rtohit = permons[pm_idx].rtohit + ood(permons[pm_idx].power, 3);
-               monsters[mon].rdam = permons[pm_idx].rdam + ood(permons[pm_idx].power, 5);
-           }
-           else
-           {
-               monsters[mon].rtohit = -1;
-               monsters[mon].rdam = -1;
-           }
-           monsters[mon].awake = 0;
-           mapmonster[y][x] = mon;
-           newsym(y, x);
-           return mon;
-       }
+        if (monsters[mon].used == 0)
+        {
+            monsters[mon].mon_id = pm_idx;
+            monsters[mon].used = 1;
+            monsters[mon].y = y;
+            monsters[mon].x = x;
+            monsters[mon].ai_lasty = -1;
+            monsters[mon].ai_lastx = -1;
+            monsters[mon].hpmax = permons[pm_idx].hp + ood(permons[pm_idx].power, 1);
+            monsters[mon].hpcur = monsters[mon].hpmax;
+            monsters[mon].mtohit = permons[pm_idx].mtohit + ood(permons[pm_idx].power, 3);
+            monsters[mon].defence = permons[pm_idx].defence + ood(permons[pm_idx].power, 3);
+            monsters[mon].mdam = permons[pm_idx].mdam + ood(permons[pm_idx].power, 5);
+            if (permons[pm_idx].rdam != -1)
+            {
+                monsters[mon].rtohit = permons[pm_idx].rtohit + ood(permons[pm_idx].power, 3);
+                monsters[mon].rdam = permons[pm_idx].rdam + ood(permons[pm_idx].power, 5);
+            }
+            else
+            {
+                monsters[mon].rtohit = -1;
+                monsters[mon].rdam = -1;
+            }
+            monsters[mon].awake = 0;
+            mapmonster[y][x] = mon;
+            newsym(y, x);
+            return mon;
+        }
     }
     return -1;
 }
@@ -156,62 +156,62 @@ void death_drop(int mon)
     int tryct;
     while (((mapobject[y][x] != -1) || (terrain[y][x] != FLOOR)) && tryct < 100)
     {
-       dy = zero_die(3) - 1;
-       dx = zero_die(3) - 1;
-       tryct++;
-       y += dy;
-       x += dx;
+        dy = zero_die(3) - 1;
+        dx = zero_die(3) - 1;
+        tryct++;
+        y += dy;
+        x += dx;
     }
     if (tryct >= 100)
     {
-       return;
+        return;
     }
     switch (pm)
     {
     case PM_GOBLIN:
-       if (!zero_die(4))
-       {
-           create_obj(PO_DAGGER, 1, 0, y, x);
-       }
-       break;
+        if (!zero_die(4))
+        {
+            create_obj(PO_DAGGER, 1, 0, y, x);
+        }
+        break;
     case PM_THUG:
     case PM_GOON:
-       if (!zero_die(4))
-       {
-           create_obj(PO_MACE, 1, 0, y, x);
-       }
-       else if (!zero_die(3))
-       {
-           create_obj(PO_LEATHER_ARMOUR, 1, 0, y, x);
-       }
-       break;
+        if (!zero_die(4))
+        {
+            create_obj(PO_MACE, 1, 0, y, x);
+        }
+        else if (!zero_die(3))
+        {
+            create_obj(PO_LEATHER_ARMOUR, 1, 0, y, x);
+        }
+        break;
     case PM_HUNTER:
-       if (!zero_die(6))
-       {
-           create_obj(PO_BOW, 1, 0, y, x);
-       }
-       break;
+        if (!zero_die(6))
+        {
+            create_obj(PO_BOW, 1, 0, y, x);
+        }
+        break;
     case PM_DUELLIST:
-       if (!zero_die(6))
-       {
-           create_obj(PO_LONG_SWORD, 1, 0, y, x);
-       }
-       break;
+        if (!zero_die(6))
+        {
+            create_obj(PO_LONG_SWORD, 1, 0, y, x);
+        }
+        break;
     case PM_WIZARD:
-       if (!zero_die(4))
-       {
-           create_obj_class(POCLASS_SCROLL, 1, 0, y, x);
-       }
-       else if (!zero_die(3))
-       {
-           create_obj_class(POCLASS_POTION, 1, 0, y, x);
-       }
+        if (!zero_die(4))
+        {
+            create_obj_class(POCLASS_SCROLL, 1, 0, y, x);
+        }
+        else if (!zero_die(3))
+        {
+            create_obj_class(POCLASS_POTION, 1, 0, y, x);
+        }
         break;
     case PM_WARLORD:
-       if (!zero_die(3))
-       {
-           create_obj(PO_RUNESWORD, 1, 0, y, x);
-       }
+        if (!zero_die(3))
+        {
+            create_obj(PO_RUNESWORD, 1, 0, y, x);
+        }
         break;
     case PM_DEMON:
         if (!zero_die(100))
@@ -226,7 +226,7 @@ void death_drop(int mon)
         }
         break;
     default:
-       break;
+        break;
     }
     map_updated = 1;
 }
@@ -236,16 +236,16 @@ int mon_can_pass(int mon, int y, int x)
     enum terrain_num terr;
     if ((y < 0) || (x < 0) || (y >= DUN_HEIGHT) || (x >= DUN_WIDTH))
     {
-       return 0;
+        return 0;
     }
     if (mapmonster[y][x] != -1)
     {
-       return 0;
+        return 0;
     }
     if ((y == u.y) && (x == u.x))
     {
-       /* Sanity check! */
-       return 0;
+        /* Sanity check! */
+        return 0;
     }
     if (mon_is_ethereal(mon))
     {
@@ -282,23 +282,23 @@ void print_mon_name(int mon, int article)
 {
     if (permons[monsters[mon].mon_id].name[0] == '\0')
     {
-       print_msg("GROB THE VOID (%d)", monsters[mon].mon_id);
+        print_msg("GROB THE VOID (%d)", monsters[mon].mon_id);
         return;
     }
     switch (article)
     {
-    case 0:    /* a */
-       print_msg("a%s %s", is_vowel(permons[monsters[mon].mon_id].name[0]) ? "n" : "", permons[monsters[mon].mon_id].name);
-       break;
+    case 0:     /* a */
+        print_msg("a%s %s", is_vowel(permons[monsters[mon].mon_id].name[0]) ? "n" : "", permons[monsters[mon].mon_id].name);
+        break;
     case 1: /* the */
-       print_msg("the %s", permons[monsters[mon].mon_id].name);
-       break;
+        print_msg("the %s", permons[monsters[mon].mon_id].name);
+        break;
     case 2: /* A */
-       print_msg("A%s %s", is_vowel(permons[monsters[mon].mon_id].name[0]) ? "n" : "", permons[monsters[mon].mon_id].name);
-       break;
+        print_msg("A%s %s", is_vowel(permons[monsters[mon].mon_id].name[0]) ? "n" : "", permons[monsters[mon].mon_id].name);
+        break;
     case 3: /* The */
-       print_msg("The %s", permons[monsters[mon].mon_id].name);
-       break;
+        print_msg("The %s", permons[monsters[mon].mon_id].name);
+        break;
     }
 }
 
@@ -306,16 +306,16 @@ void heal_mon(int mon, int amount, int cansee)
 {
     if (amount > (monsters[mon].hpmax - monsters[mon].hpcur))
     {
-       amount = monsters[mon].hpmax - monsters[mon].hpcur;
+        amount = monsters[mon].hpmax - monsters[mon].hpcur;
     }
     if (amount > 0)
     {
-       if (cansee)
-       {
-           print_mon_name(mon, 3);
-           print_msg(" looks healthier.\n");
-       }
-       monsters[mon].hpcur += amount;
+        if (cansee)
+        {
+            print_mon_name(mon, 3);
+            print_msg(" looks healthier.\n");
+        }
+        monsters[mon].hpcur += amount;
     }
 }
 
@@ -325,22 +325,22 @@ void damage_mon(int mon, int amount, int by_you)
     mptr = monsters + mon;
     if (amount >= mptr->hpcur)
     {
-       if (by_you)
-       {
-           print_msg("You kill ");
-           if (mon_visible(mon))
-           {
-               print_mon_name(mon, 1);
-           }
-           else
-           {
-               print_msg("something");
-           }
-           print_msg("!\n");
-           gain_experience(permons[mptr->mon_id].exp);
-       }
-       else if (mon_visible(mon))
-       {
+        if (by_you)
+        {
+            print_msg("You kill ");
+            if (mon_visible(mon))
+            {
+                print_mon_name(mon, 1);
+            }
+            else
+            {
+                print_msg("something");
+            }
+            print_msg("!\n");
+            gain_experience(permons[mptr->mon_id].exp);
+        }
+        else if (mon_visible(mon))
+        {
             print_mon_name(mon, 2);
             print_msg(" dies.\n");
         }
@@ -386,10 +386,10 @@ int teleport_mon_to_you(int mon)
     }
     if (success)
     {
-       reloc_mon(mon, y, x);
-       print_mon_name(mon, 2);
-       print_msg(" appears in a puff of smoke.\n");
-       return 1;
+        reloc_mon(mon, y, x);
+        print_mon_name(mon, 2);
+        print_msg(" appears in a puff of smoke.\n");
+        return 1;
     }
     return 0;
 }
@@ -434,29 +434,61 @@ int knockback_mon(int mon, int sy, int sx, bool cansee, bool by_you)
     {
     case WALL:
     case HARDWALL:
+        print_mon_name(mon, 3);
+        print_msg(" is slammed against the wall.\n");
         return 0;
     case LAVA:
-        if (cansee)
+        if (mon_can_fly(mon))
         {
-            print_mon_name(mon, 3);
-            print_msg(" tumbles into a pool of molten rock.\n");
+            if (cansee)
+            {
+                print_mon_name(mon, 3);
+                print_msg(" is hurled out over the lava.\n");
+            }
         }
-        if (!mon_resists_fire(mon))
+        else
         {
-            damage_mon(mon, 9999, by_you);
-            return 2;
+            if (cansee)
+            {
+                print_mon_name(mon, 3);
+                print_msg(" tumbles into a pool of molten rock.\n");
+            }
+            else
+            {
+                print_msg("Splut!\n");
+            }
+            if (!mon_resists_fire(mon))
+            {
+                damage_mon(mon, 9999, by_you);
+                return 2;
+            }
         }
         break;
     case WATER:
-        if (cansee)
+        if (mon_can_fly(mon))
         {
-            print_mon_name(mon, 3);
-            print_msg(" tumbles into the water.\n");
+            if (cansee)
+            {
+                print_mon_name(mon, 3);
+                print_msg(" is hurled out over the water.\n");
+            }
         }
-        if (!mon_resists_drowning(mon))
+        else
         {
-            damage_mon(mon, 9999, by_you);
-            return 2;
+            if (cansee)
+            {
+                print_mon_name(mon, 3);
+                print_msg(" tumbles into the water.\n");
+            }
+            else
+            {
+                print_msg("Splash!\n");
+            }
+            if (!mon_resists_drowning(mon))
+            {
+                damage_mon(mon, 9999, by_you);
+                return 2;
+            }
         }
         break;
     default:
@@ -488,9 +520,9 @@ void move_mon(int mon, int y, int x)
     mptr = monsters + mon;
     if (mapmonster[mptr->y][mptr->x] != mon)
     {
-       print_msg("Monster map array in disorder.\n");
-       press_enter();
-       return;
+        print_msg("Monster map array in disorder.\n");
+        press_enter();
+        return;
     }
     reloc_mon(mon, y, x);
     display_update();
@@ -503,17 +535,17 @@ void summon_demon_near(int y, int x)
     y2 = y - 1 + zero_die(3);
     x2 = x - 1 + zero_die(3);
     if ((terrain[y2][x2] == FLOOR) && (mapmonster[y2][x2] == -1) &&
-       ((y2 != u.y) || (x2 != u.x)))
-    {
-       i = create_mon(PM_DEMON, y2, x2);
-       if (i != -1)
-       {
-           print_msg("Another demon appears!\n");
-       }
-       else
-       {
-           print_msg("You smell sulphurous fumes.\n");
-       }
+        ((y2 != u.y) || (x2 != u.x)))
+    {
+        i = create_mon(PM_DEMON, y2, x2);
+        if (i != -1)
+        {
+            print_msg("Another demon appears!\n");
+        }
+        else
+        {
+            print_msg("You smell sulphurous fumes.\n");
+        }
     }
 }
 
@@ -522,17 +554,17 @@ int mon_visible(int mon)
     int dy, dx;
     if (monsters[mon].used == 0)
     {
-       return 0;
+        return 0;
     }
     dy = monsters[mon].y - u.y;
     dx = monsters[mon].x - u.x;
     if (((dy > -11) && (dy < 11) && (dx > -11) && (dx < 11)))
     {
-       return player_fov.affected[MAX_FOV_RADIUS + dy][MAX_FOV_RADIUS + dx];
+        return player_fov.affected[MAX_FOV_RADIUS + dy][MAX_FOV_RADIUS + dx];
     }
     else
     {
-       return 0;
+        return 0;
     }
 }
 
@@ -541,31 +573,31 @@ void update_mon(int mon)
     int cansee;
     if (monsters[mon].hpcur < monsters[mon].hpmax)
     {
-       cansee = mon_visible(mon);
-       switch (monsters[mon].mon_id)
-       {
-       case PM_TROLL:
-           if (!(game_tick % 10))
-           {
-               if (cansee)
-               {
-                   print_msg("The troll regenerates.\n");
-               }
-               heal_mon(mon, one_die(3) + 3, 0);
-           }
-           break;
-
-       case PM_ZOMBIE:
-           /* Zombies don't recover from their injuries. */
-           break;
-
-       default:
-           if (!(game_tick % 20))
-           {
-               heal_mon(mon, 1, cansee);
-           }
-           break;
-       }
+        cansee = mon_visible(mon);
+        switch (monsters[mon].mon_id)
+        {
+        case PM_TROLL:
+            if (!(game_tick % 10))
+            {
+                if (cansee)
+                {
+                    print_msg("The troll regenerates.\n");
+                }
+                heal_mon(mon, one_die(3) + 3, 0);
+            }
+            break;
+
+        case PM_ZOMBIE:
+            /* Zombies don't recover from their injuries. */
+            break;
+
+        default:
+            if (!(game_tick % 20))
+            {
+                heal_mon(mon, 1, cansee);
+            }
+            break;
+        }
     }
 }