home *** CD-ROM | disk | FTP | other *** search
/ Superpower (Alt) / SUPERPOWER.iso / q / patch / mbq057 / bot.qc < prev    next >
Encoding:
Text File  |  1996-08-31  |  5.4 KB  |  190 lines

  1. /*
  2. ==============================================================================
  3.  
  4. BOT
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. // Prototypes
  10.  
  11. void    ()              botrespawn;
  12. void    ()              Bot_Precache;
  13. void    ()              BotCreate;
  14. void    ()              four;       // BGADMbot - Spawn 4 in one impulse
  15. void    ()              BotFire;
  16. entity  ()              SelectSpawnPoint;
  17. void (vector org, vector vec) LaunchLaser;
  18. void (vector org) spawn_tfog;
  19.  
  20. void (vector org, entity death_owner) spawn_tdeath;
  21. //=============================================================
  22. // Bot_Precache - called by Worldspawn
  23. //=============================================================
  24. void () Bot_Precache =
  25. {
  26.     precache_model2 ("progs/enforcer.mdl");
  27.     precache_model2 ("progs/h_mega.mdl");
  28.     precache_model2 ("progs/laser.mdl");
  29.  
  30.     precache_sound2 ("enforcer/death1.wav");
  31.     precache_sound2 ("enforcer/enfire.wav");
  32.     precache_sound2 ("enforcer/enfstop.wav");
  33.     precache_sound2 ("enforcer/idle1.wav");
  34.     precache_sound2 ("enforcer/pain1.wav");
  35.     precache_sound2 ("enforcer/pain2.wav");
  36.     precache_sound2 ("enforcer/sight1.wav");
  37.     precache_sound2 ("enforcer/sight2.wav");
  38.     precache_sound2 ("enforcer/sight3.wav");
  39.     precache_sound2 ("enforcer/sight4.wav");
  40. };
  41.  
  42.  
  43. //=============================================================
  44. // BotActivate - Activates the bot
  45. //=============================================================
  46. void () BotCreate =
  47. {
  48. // sounds and models precached in the world.qc file
  49.  
  50.     local entity    newbot;
  51.     local entity    spot;
  52.     local float     cyc,one,two;
  53.     
  54.     newbot = spawn();
  55.     totalbots=totalbots + 1;  //* BGADMbot - for counting bots, this will
  56.                   //    come in handy for rankings; defined in
  57.                   //    defs.qc as global
  58.     newbot.whichbot = totalbots;
  59.     newbot.solid = SOLID_SLIDEBOX;
  60.     newbot.movetype = MOVETYPE_STEP;
  61.  
  62.     newbot.angles = self.angles;
  63.     newbot.classname = "bot";
  64.     newbot.health = 250;               //* BGADMbot - changed to 250 for
  65.     newbot.max_health = 250;           //  more challenge
  66.     newbot.takedamage = DAMAGE_AIM;
  67.     newbot.goalentity = self;
  68.     newbot.movetarget = self;
  69.     newbot.pausetime = time + 2;
  70.     newbot.ideal_yaw = newbot.angles * '0 1 0';
  71.     newbot.yaw_speed = 90;
  72.     newbot.weapon = 2;
  73.     newbot.ammo_shells = 100;
  74.     newbot.view_ofs = '0 0 25';
  75.     newbot.th_stand = bot_stand1;
  76.     newbot.th_walk = bot_walk1;
  77.     newbot.th_run = bot_run1;
  78.     newbot.th_pain = bot_pain;
  79.     newbot.th_die = bot_die;
  80.     newbot.th_missile = bot_atk1;
  81.     setmodel (newbot, "progs/enforcer.mdl");
  82.     setsize (newbot, '-16 -16 -24', '16 16 40');
  83.        
  84.     
  85.     
  86.     spot=SelectSpawnPoint();  //*BGADMbot - for finding a deathmatch origin
  87.     
  88.     newbot.netname="bot";  //* BGADMbot - sets netname and frags, 
  89.     newbot.frags=0;        //  if i could figure     
  90.                    //  rankings, this would help
  91.     
  92.     
  93.     setorigin(newbot, spot.origin);
  94.     spawn_tdeath(newbot.origin, newbot);
  95.     
  96.     spawn_tfog (newbot.origin + v_forward*20);
  97.     bprint("New Bot Created \n");
  98.     
  99.     newbot.nextthink = time + 0.1;
  100.     newbot.think = newbot.th_stand;
  101. };
  102.  
  103. /*
  104. ==============================================
  105. BotFire - Have bot fire at its current target
  106. ==============================================
  107. */
  108. void () BotFire =
  109. {
  110. //        local entity oldself;
  111.     local vector org;
  112.  
  113. //        oldself = self;
  114. //        self = self.bot;
  115.  
  116.     if (self.enemy != world && self.enemy.health > 1
  117.         && !(self.enemy.items & IT_INVISIBILITY) && visible(self.enemy))
  118.     {
  119.         sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);
  120.         enforcer_fire();
  121.     }
  122.     else
  123.     {
  124.         sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);
  125.         self.effects = self.effects | EF_MUZZLEFLASH;
  126.         makevectors (self.angles);
  127.         org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
  128.         LaunchLaser(org, v_forward);
  129.     }
  130.  
  131. //        self = oldself;
  132.     return;
  133. };
  134. //* BGADMbot - NEW RESPAWN - this "respawns" the current bot that died //
  135. //  without actually doing a spawn so that the current bot is still active,
  136. //  and thus all stats not changed here are still in effect //
  137.  
  138. void () botrespawn = {
  139.     local entity spot;
  140.     self.solid = SOLID_SLIDEBOX;
  141.     self.movetype = MOVETYPE_STEP;
  142.  
  143.     self.angles = self.angles;
  144.     self.classname = "bot";
  145.     self.health = 250;
  146.     self.max_health = 250;
  147.     self.takedamage = DAMAGE_AIM;
  148.     self.deadflag = DEAD_NO;
  149.     self.goalentity = self;
  150.     self.movetarget = self;
  151.     self.pausetime = time + 2;
  152.     self.ideal_yaw = self.angles * '0 1 0';
  153.     self.yaw_speed = 90;
  154.     self.items=IT_SHOTGUN & IT_AXE;
  155.     
  156.     self.weapon = 2;
  157.     self.ammo_shells = 100;
  158.     self.view_ofs = '0 0 25';
  159.     self.th_stand = bot_stand1;
  160.     self.th_walk = bot_walk1;
  161.     self.th_run = bot_run1;
  162.     self.th_pain = bot_pain;
  163.     self.th_die = bot_die;
  164.     self.th_missile = bot_atk1;
  165.     setmodel (self, "progs/enforcer.mdl");
  166.     setsize (self, '-16 -16 -24', '16 16 40');
  167.     spot = SelectSpawnPoint(); 
  168.     setorigin(self, spot.origin);
  169.     spawn_tfog (self.origin + v_forward*20);
  170.     spawn_tdeath(self.origin, self);
  171.     bprint ("Bot respawned\n");
  172.     if (random () < 0.25) {        // prints the total number of bots
  173.     bprint ("Total Bots: ");       // originally for debugging
  174.     bprint (ftos(totalbots));
  175.     bprint ("\n");
  176.     }
  177.     bot_stand1();
  178.     };
  179.  
  180. //** Spawn 4 bots with one impulse **//
  181. void () four = {        
  182.     local float detour;
  183.     detour=4;
  184.     while (detour>0) {
  185.     BotCreate();
  186.     detour=detour - 1;
  187.     }
  188.     
  189.     };
  190.