home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 3 / CD_Magazyn_EXEC_nr_3.iso / Internet / Strony_WWW / Quake / patches / Qboost4_qc.lha / Qboost4_qc / monsters.qc < prev    next >
Text File  |  1999-02-04  |  5KB  |  242 lines

  1. /* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
  2.  
  3. // name =[framenum,    nexttime, nextthink] {code}
  4. // expands to:
  5. // name ()
  6. // {
  7. //        self.frame=framenum;
  8. //        self.nextthink = time + nexttime;
  9. //        self.think = nextthink
  10. //        <code>
  11. // };
  12.  
  13.  
  14. /*
  15. ================
  16. monster_use
  17.  
  18. Using a monster makes it angry at the current activator
  19. ================
  20. */
  21. void() monster_use =
  22. {
  23.     if (self.enemy)
  24.         return;
  25.     if (self.health <= 0)
  26.         return;
  27.     if (activator.items & IT_INVISIBILITY)
  28.         return;
  29.     if (activator.flags & FL_NOTARGET)
  30.         return;
  31.     if (activator.classname != "player")
  32.         return;
  33.     
  34. // delay reaction so if the monster is teleported, its sound is still
  35. // heard
  36.     self.enemy = activator;
  37.     self.nextthink = time + 0.1;
  38.     self.think = FoundTarget;
  39. };
  40.  
  41. /*
  42. ================
  43. monster_death_use
  44.  
  45. When a mosnter dies, it fires all of its targets with the current
  46. enemy as activator.
  47. ================
  48. */
  49. void() monster_death_use =
  50. {
  51.     local entity     ent, otemp, stemp;
  52.  
  53. // fall to ground
  54.     if (self.flags & FL_FLY)
  55.         self.flags = self.flags - FL_FLY;
  56. //DropBackpack; //addition
  57. //remove(self); //attemt to remove body
  58.  
  59.     if (self.flags & FL_SWIM)
  60.         self.flags = self.flags - FL_SWIM;
  61. //DropBackpack; //addition
  62. //remove(self); //attemt to remove body
  63.  
  64.     if (!self.target)
  65.         return;
  66.  
  67.     activator = self.enemy;
  68.     SUB_UseTargets ();
  69. };
  70.  
  71.  
  72. //============================================================================
  73.  
  74. void() walkmonster_start_go =
  75. {
  76. local string    stemp;
  77. local entity    etemp;
  78.  
  79.     self.origin_z = self.origin_z + 1;    // raise off floor a bit
  80.     droptofloor();
  81.     
  82.     if (!walkmove(0,0))
  83.     {
  84.         dprint ("walkmonster in wall at: ");
  85.         dprint (vtos(self.origin));
  86.         dprint ("\n");
  87.     }
  88.     
  89.     self.takedamage = DAMAGE_AIM;
  90.  
  91.     self.ideal_yaw = self.angles * '0 1 0';
  92.     if (!self.yaw_speed)
  93.         self.yaw_speed = 20;
  94.     self.view_ofs = '0 0 25';
  95.     self.use = monster_use;
  96.     
  97.     self.flags = self.flags | FL_MONSTER;
  98.     
  99.     if (self.target)
  100.     {
  101.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  102.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  103.         if (!self.movetarget)
  104.         {
  105.             dprint ("Monster can't find target at ");
  106.             dprint (vtos(self.origin));
  107.             dprint ("\n");
  108.         }
  109. // this used to be an objerror
  110.         if (self.movetarget.classname == "path_corner")
  111.             self.th_walk ();
  112.         else
  113.             self.pausetime = 99999999;
  114.             self.th_stand ();
  115.     }
  116.     else
  117.     {
  118.         self.pausetime = 99999999;
  119.         self.th_stand ();
  120.     }
  121.  
  122. // spread think times so they don't all happen at same time
  123.     self.nextthink = self.nextthink + random()*0.5;
  124. };
  125.  
  126.  
  127. void() walkmonster_start =
  128. {
  129. // delay drop to floor to make sure all doors have been spawned
  130. // spread think times so they don't all happen at same time
  131.     self.nextthink = self.nextthink + random()*0.5;
  132.     self.think = walkmonster_start_go;
  133.     total_monsters = total_monsters + 1;
  134. };
  135.  
  136.  
  137.  
  138. void() flymonster_start_go =
  139. {
  140.     self.takedamage = DAMAGE_AIM;
  141.  
  142.     self.ideal_yaw = self.angles * '0 1 0';
  143.     if (!self.yaw_speed)
  144.         self.yaw_speed = 10;
  145.     self.view_ofs = '0 0 25';
  146.     self.use = monster_use;
  147.  
  148.     self.flags = self.flags | FL_FLY;
  149.     self.flags = self.flags | FL_MONSTER;
  150.  
  151.     if (!walkmove(0,0))
  152.     {
  153.         dprint ("flymonster in wall at: ");
  154.         dprint (vtos(self.origin));
  155.         dprint ("\n");
  156.     }
  157.  
  158.     if (self.target)
  159.     {
  160.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  161.         if (!self.movetarget)
  162.         {
  163.             dprint ("Monster can't find target at ");
  164.             dprint (vtos(self.origin));
  165.             dprint ("\n");
  166.         }
  167. // this used to be an objerror
  168.         if (self.movetarget.classname == "path_corner")
  169.             self.th_walk ();
  170.         else
  171.             self.pausetime = 99999999;
  172.             self.th_stand ();
  173.     }
  174.     else
  175.     {
  176.         self.pausetime = 99999999;
  177.         self.th_stand ();
  178.     }
  179. };
  180.  
  181. void() flymonster_start =
  182. {
  183. // spread think times so they don't all happen at same time
  184.     self.nextthink = self.nextthink + random()*0.5;
  185.     self.think = flymonster_start_go;
  186.     total_monsters = total_monsters + 1;
  187. };
  188.  
  189.  
  190. void() swimmonster_start_go =
  191. {
  192.     if (deathmatch)
  193.     {
  194.         remove(self);
  195.         return;
  196.     }
  197.  
  198.     self.takedamage = DAMAGE_AIM;
  199.     total_monsters = total_monsters + 1;
  200.  
  201.     self.ideal_yaw = self.angles * '0 1 0';
  202.     if (!self.yaw_speed)
  203.         self.yaw_speed = 10;
  204.     self.view_ofs = '0 0 10';
  205.     self.use = monster_use;
  206.     
  207.     self.flags = self.flags | FL_SWIM;
  208.     self.flags = self.flags | FL_MONSTER;
  209.  
  210.     if (self.target)
  211.     {
  212.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  213.         if (!self.movetarget)
  214.         {
  215.             dprint ("Monster can't find target at ");
  216.             dprint (vtos(self.origin));
  217.             dprint ("\n");
  218.         }
  219. // this used to be an objerror
  220.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  221.         self.th_walk ();
  222.     }
  223.     else
  224.     {
  225.         self.pausetime = 99999999;
  226.         self.th_stand ();
  227.     }
  228.  
  229. // spread think times so they don't all happen at same time
  230.     self.nextthink = self.nextthink + random()*0.5;
  231. };
  232.  
  233. void() swimmonster_start =
  234. {
  235. // spread think times so they don't all happen at same time
  236.     self.nextthink = self.nextthink + random()*0.5;
  237.     self.think = swimmonster_start_go;
  238.     total_monsters = total_monsters + 1;
  239. };
  240.  
  241.  
  242.