LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - trap.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 219 0.0 %
Date: 2017-09-08 22:00:26 Functions: 0 13 0.0 %
Branches: 0 82 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
       2                 :            : /* trap.c */
       3                 :            : /* trap movement functions */
       4                 :            : 
       5                 :            : #include "glob.h"
       6                 :            : 
       7                 :            : 
       8                 :            : /* various traps */
       9                 :            : 
      10                 :            : /* note special function on different levels */
      11                 :          0 : void l_trap_siren(void)
      12                 :            : {
      13                 :            :   pml ml;
      14                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
      15                 :          0 :   lset(Player.x, Player.y, CHANGED);
      16                 :          0 :   print1("A klaxon goes off!");
      17                 :          0 :   print2("'Intruder Alert -- Intruder Alert -- Intruder Alert'");
      18                 :          0 :   print3("You have the feeling you have been discovered....");
      19                 :          0 :   morewait();
      20                 :          0 :   clearmsg();
      21 [ #  # ][ #  # ]:          0 :   if ((Current_Environment == E_HOUSE) ||
      22                 :          0 :       (Current_Environment == E_MANSION)) {
      23         [ #  # ]:          0 :     if (! gamestatusp(DESTROYED_ORDER)) {
      24                 :          0 :       print1("The city guard arrives!");
      25                 :          0 :       print2("You are apprehended....");
      26                 :          0 :       morewait();
      27                 :          0 :       send_to_jail();
      28                 :            :     }
      29                 :          0 :     else print1("Nobody answers the alarm.");
      30                 :            :   }
      31         [ #  # ]:          0 :   else if (Current_Environment == E_HOVEL) 
      32                 :          0 :     print1("Nobody answers the alarm.");
      33                 :            :   else {
      34         [ #  # ]:          0 :     if (Current_Environment == E_CIRCLE) {
      35                 :          0 :       summon(-1,DEMON_PRINCE); /* prime circle demon */
      36                 :          0 :       summon(-1,DEMON_PRINCE);
      37                 :          0 :       summon(-1,DEMON_PRINCE);
      38                 :            :     }
      39         [ #  # ]:          0 :     for(ml=Level->mlist;ml!=NULL;ml=ml->next) {
      40                 :          0 :       m_status_set(ml->m,AWAKE);
      41                 :          0 :       ml->m->sense *= 2;
      42 [ #  # ][ #  # ]:          0 :       if ((Current_Environment == E_CIRCLE) ||
      43 [ #  # ][ #  # ]:          0 :           ((Current_Environment == E_VILLAGE) && (ml->m->id == GUARD)) ||
      44         [ #  # ]:          0 :           ((Current_Environment == E_CITY) && (ml->m->id == GUARD)))
      45                 :          0 :         m_status_set(ml->m,HOSTILE);
      46                 :            :     }
      47                 :            :   }
      48                 :          0 : }
      49                 :            : 
      50                 :          0 : void l_trap_dart(void)
      51                 :            : {
      52                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
      53                 :          0 :   lset(Player.x, Player.y, CHANGED);
      54         [ #  # ]:          0 :   if (gamestatusp(MOUNTED)) {
      55                 :          0 :     mprint("A dart annoys your horse....");
      56                 :            :   }
      57         [ #  # ]:          0 :   else if (random_range(100) < Player.absorption) 
      58                 :          0 :     mprint("A dart plinks off your armor");
      59                 :            :   else {
      60                 :          0 :     mprint("You were hit by a dart!");
      61                 :          0 :     p_damage(difficulty(),NORMAL_DAMAGE,"a dart trap");
      62         [ #  # ]:          0 :     if (random_range(3)==1) {
      63                 :          0 :       mprint("It was poisoned!");
      64                 :          0 :       morewait();
      65                 :          0 :       p_poison(difficulty());
      66                 :            :     }
      67                 :            :   }
      68                 :          0 : }
      69                 :            : 
      70                 :          0 : void l_trap_pit(void)
      71                 :            : {
      72                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
      73                 :          0 :   lset(Player.x, Player.y, CHANGED);
      74         [ #  # ]:          0 :   if (gamestatusp(MOUNTED)) {
      75                 :          0 :     mprint("Your horse stumbles into a pit and breaks a leg!");
      76                 :          0 :     morewait();
      77                 :          0 :     mprint("You are forced to put it out of its misery.");
      78                 :          0 :     morewait();
      79                 :          0 :     resetgamestatus(MOUNTED);
      80                 :          0 :     showflags();
      81                 :            :   }
      82         [ #  # ]:          0 :   else if (Player.itemweight < ((int) (Player.maxweight / 2)))
      83                 :          0 :     mprint("You nimbly dodge a pit trap.");
      84                 :            :   else {
      85                 :          0 :     mprint("You fell into a pit!");
      86         [ #  # ]:          0 :     if (random_range(3) == 1) {
      87                 :          0 :       mprint("And were impaled by spikes!");
      88                 :          0 :       morewait();
      89                 :          0 :       p_damage(difficulty()*5,NORMAL_DAMAGE,"a spiked pit");
      90                 :            :     }
      91                 :          0 :     else p_damage(difficulty()*2,NORMAL_DAMAGE,"a pit");
      92                 :          0 :     Player.status[IMMOBILE] ++;
      93                 :            :   }
      94                 :          0 : }
      95                 :            : 
      96                 :          0 : void l_trap_door(void)
      97                 :            : {
      98         [ #  # ]:          0 :   if (Current_Environment != Current_Dungeon)
      99                 :          0 :     mprint("You feel oddly lucky.");
     100                 :            :   else {
     101                 :          0 :     Level->site[Player.x][Player.y].locchar = TRAP;
     102                 :          0 :     lset(Player.x, Player.y, CHANGED);
     103         [ #  # ]:          0 :     if (gamestatusp(MOUNTED)) {
     104                 :          0 :       mprint("You and your horse fall through a trap door!");
     105                 :          0 :       morewait();
     106                 :          0 :       mprint("Your horse breaks its back. Snif.");
     107                 :          0 :       morewait();
     108         [ #  # ]:          0 :       if (Level->site[Player.x][Player.y].aux != S_DISINTEGRATE) {
     109                 :          0 :         mprint("You're hit by a rockslide!");
     110                 :          0 :         morewait();
     111                 :          0 :         p_damage(Level->depth*difficulty(),UNSTOPPABLE,"a rockslide");
     112                 :            :       }
     113                 :          0 :       change_level(Level->depth,Level->depth+1,FALSE);
     114                 :          0 :       resetgamestatus(MOUNTED);
     115                 :          0 :       showflags();
     116                 :          0 :       roomcheck();
     117                 :            :     }
     118         [ #  # ]:          0 :     else if (random_range(100) < Player.agi)
     119                 :          0 :       mprint("You leap over a trap door.");
     120                 :            :     else {
     121                 :          0 :       mprint("You fell through a trap door!");
     122                 :          0 :       morewait();
     123                 :          0 :       p_damage(difficulty(),NORMAL_DAMAGE,"a trap door");
     124         [ #  # ]:          0 :       if (Level->site[Player.x][Player.y].aux != S_DISINTEGRATE) {
     125                 :          0 :         mprint("You're hit by a rockslide!");
     126                 :          0 :         morewait();
     127                 :          0 :         p_damage(Level->depth*difficulty(),UNSTOPPABLE,"a rockslide");
     128                 :            :       }
     129                 :          0 :       change_level(Level->depth,Level->depth+1,FALSE);
     130                 :          0 :       roomcheck();
     131                 :            :     }
     132                 :            :   }
     133                 :          0 : }
     134                 :            : 
     135                 :          0 : void l_trap_snare(void)
     136                 :            : {
     137                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     138                 :          0 :   lset(Player.x, Player.y, CHANGED);
     139         [ #  # ]:          0 :   if (gamestatusp(MOUNTED)) 
     140                 :          0 :     mprint("Your horse steps out of a snare trap.");
     141         [ #  # ]:          0 :   else if (random_range(100) < Player.agi)
     142                 :          0 :     mprint("You agilely avoid a snare.");
     143                 :            :   else {
     144                 :          0 :     mprint("You were caught in a snare!");
     145                 :          0 :     Player.status[IMMOBILE]+=difficulty();
     146                 :            :   }
     147                 :          0 : }
     148                 :            : 
     149                 :          0 : void l_trap_blade(void)
     150                 :            : {
     151                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     152                 :          0 :   lset(Player.x, Player.y, CHANGED);
     153         [ #  # ]:          0 :   if (random_range(30) < Player.agi+Player.level)
     154                 :          0 :     mprint("You duck under a scything blade!");
     155                 :            :   else {
     156         [ #  # ]:          0 :     if (gamestatusp(MOUNTED)) {
     157                 :          0 :       mprint("Your horse is struck by a scything blade and killed instantly.");
     158                 :          0 :       morewait();
     159                 :          0 :       resetgamestatus(MOUNTED);
     160                 :          0 :       showflags();
     161                 :            :     }
     162                 :            :     else {
     163                 :          0 :       mprint("A heavy blade scythes across the room and hits you!");
     164                 :          0 :       morewait();
     165                 :          0 :       p_damage(random_range(difficulty()*3)+difficulty()-Player.absorption,
     166                 :            :                NORMAL_DAMAGE,
     167                 :            :                "a blade trap");
     168                 :            :     }
     169                 :            :   }
     170                 :          0 : }
     171                 :            : 
     172                 :          0 : void l_trap_fire(void)
     173                 :            : {
     174         [ #  # ]:          0 :   if (gamestatusp(MOUNTED)) {
     175                 :          0 :     mprint("Your horse is struck by a blast of fire and is charbroiled!");
     176                 :          0 :     morewait();
     177                 :          0 :     resetgamestatus(MOUNTED);
     178                 :          0 :     showflags();
     179                 :            :   }
     180         [ #  # ]:          0 :   else if (random_range(50) < Player.agi+Player.level)
     181                 :          0 :     mprint("You dodge a pillar of fire!");
     182                 :            :   else {
     183                 :          0 :     mprint("You were blasted by a fire trap!");
     184                 :          0 :     morewait();
     185                 :          0 :     p_damage(random_range((difficulty()+1)*5),FLAME,"a fire trap");
     186                 :            :   }
     187                 :          0 :   Level->site[Player.x][Player.y].locchar = FIRE;
     188                 :          0 :   Level->site[Player.x][Player.y].p_locf = L_FIRE;
     189                 :          0 :   lset(Player.x, Player.y, CHANGED);
     190                 :          0 : }
     191                 :            : 
     192                 :          0 : void l_trap_teleport(void)
     193                 :            : {
     194                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     195                 :          0 :   lset(Player.x, Player.y, CHANGED);
     196                 :          0 :   mprint("You experience a momentary disorientation....");
     197                 :          0 :   morewait();
     198         [ #  # ]:          0 :   if (random_range(10000) > difficulty()*difficulty()) p_teleport(0);
     199                 :          0 :   else p_teleport(-1);
     200                 :          0 : }
     201                 :            : 
     202                 :          0 : void l_trap_disintegrate(void)
     203                 :            : {
     204                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     205                 :          0 :   lset(Player.x, Player.y, CHANGED);
     206                 :          0 :   mprint("Oh, no! A disintegration trap!");
     207                 :          0 :   morewait();
     208         [ #  # ]:          0 :   if (gamestatusp(MOUNTED)) {
     209                 :          0 :     mprint("Your horse falls apart into its component atoms...");
     210                 :          0 :     morewait();
     211                 :          0 :     resetgamestatus(MOUNTED);
     212                 :          0 :     showflags();
     213                 :            :   }
     214                 :          0 :   disintegrate(Player.x,Player.y);
     215                 :          0 : }
     216                 :            : 
     217                 :          0 : void l_trap_sleepgas(void)
     218                 :            : {
     219                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     220                 :          0 :   lset(Player.x, Player.y, CHANGED);
     221                 :          0 :   mprint("Hsssssssss....");
     222                 :          0 :   morewait();
     223                 :          0 :   mprint("You detect a strange odor....");
     224                 :          0 :   morewait();
     225                 :          0 :   sleep_player((difficulty()/5)+1);
     226                 :          0 : }
     227                 :            : 
     228                 :            : 
     229                 :          0 : void l_trap_acid(void)
     230                 :            : {
     231                 :            :   int i,k,itemdamage;
     232                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     233                 :          0 :   lset(Player.x, Player.y, CHANGED);
     234         [ #  # ]:          0 :   if (Player.agi+Player.level < random_range(100)) {
     235                 :          0 :     mprint("You are drenched by a spray of acid!");
     236                 :          0 :     morewait();
     237         [ #  # ]:          0 :     if (gamestatusp(MOUNTED)) {
     238                 :          0 :       mprint("Your horse dies unpleasantly.");
     239                 :          0 :       morewait();
     240                 :          0 :       resetgamestatus(MOUNTED);
     241                 :          0 :       showflags();
     242                 :            :     }
     243                 :          0 :     p_damage(random_range(difficulty()*5),ACID,"an acid trap");
     244         [ #  # ]:          0 :     if (! p_immune(ACID)) {
     245                 :          0 :       mprint("The acid seeps over your possessions...");
     246                 :          0 :       morewait();
     247                 :          0 :       itemdamage = random_range(5);
     248 [ #  # ][ #  # ]:          0 :       for(i=k=0;((i<MAXITEMS) && (k<itemdamage));i++)
     249         [ #  # ]:          0 :         if (Player.possessions[i]!=NULL) {
     250                 :          0 :           k++;
     251                 :          0 :           (void) damage_item(Player.possessions[i]);
     252                 :            :         }
     253                 :            :     }
     254                 :            :   }
     255                 :          0 :   else mprint("You somehow dodge a shower of hydroflouric acid!");
     256                 :          0 : }
     257                 :            : 
     258                 :          0 : void l_trap_abyss(void)
     259                 :            : {
     260                 :          0 :   Level->site[Player.x][Player.y].locchar = ABYSS;
     261                 :          0 :   lset(Player.x, Player.y, CHANGED);
     262         [ #  # ]:          0 :   if (gamestatusp(MOUNTED)) {
     263                 :          0 :     mprint("You and your horse fall into the infinite abyss!");
     264                 :          0 :     morewait();
     265                 :          0 :     l_abyss();
     266                 :            :   }
     267         [ #  # ]:          0 :   if (Player.dex + Player.level < random_range(100)) {
     268                 :          0 :     mprint("You stumble over a concealed entrance to the abyss!");
     269                 :          0 :     morewait();
     270                 :          0 :     l_abyss();
     271                 :            :   }
     272                 :          0 :   else mprint("You gingerly step around a concealed entrance to the abyss!");
     273                 :          0 : }
     274                 :            : 
     275                 :          0 : void l_trap_manadrain(void)
     276                 :            : {
     277                 :          0 :   Level->site[Player.x][Player.y].locchar = TRAP;
     278                 :          0 :   lset(Player.x, Player.y, CHANGED);
     279         [ #  # ]:          0 :   if (Player.mana==0) {
     280         [ #  # ]:          0 :     if (random_range(10)==3) {
     281                 :          0 :       mprint("The manadrain trap overloads -- positive feedback....");
     282                 :          0 :       mprint("That's strange.... You feel repowered!");
     283                 :          0 :       morewait();
     284                 :          0 :       Level->site[Player.x][Player.y].locchar = FLOOR;
     285                 :          0 :       Level->site[Player.x][Player.y].p_locf = L_NO_OP;
     286                 :          0 :       lset(Player.x, Player.y, CHANGED);
     287                 :          0 :       Player.mana = calcmana();
     288                 :            :     }
     289                 :          0 :     else mprint("You feel strangely unaffected by the manadrain trap.");
     290                 :            :   }
     291                 :            :   else {
     292                 :          0 :     mprint("A weird rainbow light seems to play over you....");
     293                 :          0 :     mprint("You feel drained.");
     294                 :          0 :     morewait();
     295         [ #  # ]:          0 :     while (Player.mana > 1) {
     296                 :          0 :       Player.mana /= 2;
     297                 :          0 :       dataprint();
     298                 :            :     }
     299                 :          0 :     Player.mana = 0;
     300                 :          0 :     dispel(-1);
     301                 :            :   }
     302                 :          0 : }

Generated by: LCOV version 1.11