home *** CD-ROM | disk | FTP | other *** search
/ Assassins - Ultimate CD Games Collection 4 / Assassins 4 (1999)(Weird Science).iso / misc / omega / source / trap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-02  |  8.3 KB  |  303 lines

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