home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 3.2 / 1997-05_Disc_3.2.iso / QUAKECTF / SRC / CTF / HOOK.QC < prev    next >
Text File  |  1997-01-23  |  9KB  |  350 lines

  1.  
  2. /************\
  3. * BreakChain *
  4. \************/
  5.  
  6. void (entity Head) BreakChain =
  7. {
  8.         local entity link;
  9.  
  10.         link = Head.goalentity;
  11.         while (link != world)
  12.         {
  13.                 Head = link.goalentity;
  14.                 remove (link);
  15.                 link = Head;
  16.         }
  17. };
  18.  
  19. /*********\
  20. * LinkPos *
  21. \*********/
  22.  
  23. void () LinkPos =
  24. {
  25.         makevectors (self.enemy.angles);
  26.         setorigin (self, self.owner.origin + ( ( ( self.enemy.origin + 
  27.                 (v_up * 16 * (!self.enemy.button2)) + (v_forward * 16) ) - self.owner.origin ) *
  28.                 ( self.weapon ) ) );
  29.         self.nextthink = time + 0.1;
  30. };
  31.  
  32. /***********\
  33. * MakeChain *
  34. \***********/
  35.  
  36. entity (entity head, entity tail, float num) MakeChain =
  37. {
  38.         local entity link, prevlink;
  39.         local float linknum;
  40.  
  41.         linknum = num;
  42.         num = num + 1;
  43.         prevlink = world;
  44.         while (linknum > 0)
  45.         {
  46.                 link = spawn();
  47.  
  48.                 link.goalentity = prevlink;
  49.                 prevlink = link;
  50.  
  51.                 link.owner = head;
  52.                 link.enemy = tail;
  53.                 link.weapon = linknum / num;
  54.                 link.movetype = MOVETYPE_NOCLIP;
  55.                 link.solid = SOLID_NOT;
  56.                 link.angles_z = 51 * linknum;
  57.                 link.angles_y = 41 * linknum;
  58.                 link.angles_x = 31 * linknum;
  59.                 link.avelocity = '310 410 510';
  60.                 if (teamplay & TEAM_CAPTURE_CUSTOM)
  61.                     setmodel (link, "progs/bit.mdl");
  62.                 else
  63.                     setmodel (link, "progs/s_spike.mdl");
  64.                 setsize (link, '0 0 0', '0 0 0');
  65.                 makevectors (tail.angles);
  66.                 setorigin (link, head.origin + ( ( ( tail.origin 
  67.                         + (v_up * 16 * (!tail.button2)) + ( v_forward * 16 ) ) - head.origin )
  68.                         * ( link.weapon ) ) );
  69.                 link.nextthink = time + 0.1;
  70.                 link.think = LinkPos;
  71.                 linknum = linknum - 1;
  72.         }
  73.         return link;
  74. };
  75.  
  76.  
  77. /************\
  78. * HookVanish *
  79. \************/
  80.  
  81. void () HookVanish =
  82. {
  83.     // CTFBOT [[[
  84.     if ((bot_debug >= 3) && (self.owner.classname == "bot"))
  85.     {
  86.         dprint(self.owner.netname);
  87.         dprint(" HookVanish\n");
  88.     }
  89.     // CTFBOT ]]]
  90.  
  91.     self.owner.hook_out = FALSE;
  92.     
  93.     self.owner.stuck_count = 0;        // CTFBOT
  94.     self.owner.hook_snag_time = time + 99999999;    // CTFBOT
  95.     self.owner.hooked_on_someone = FALSE;        // CTFBOT
  96.  
  97. /*
  98.         if (self.enemy.classname == "player")
  99.                 self.enemy.attack_finished = time + 0.1;
  100. */
  101.         if (teamplay & TEAM_CAPTURE_CUSTOM)
  102.             sound(self.owner, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NORM);    // CTFBOT EXTRAS bug fix
  103.         BreakChain (self);
  104.         remove (self);
  105. };
  106.  
  107. /**********\
  108. * HookPull *
  109. \**********/
  110.  
  111. void () HookPull =
  112. {
  113.         local vector vel, spray;
  114.         local float v, dorg;
  115.  
  116.     // CTFBOT [[[
  117.     // hack to make bots be pulled by hook properly
  118.     if (self.owner.classname == "bot")
  119.     {
  120.         if (self.owner.flags & FL_ONGROUND)
  121.             self.owner.flags = self.owner.flags - FL_ONGROUND;
  122.  
  123.         // hack to make bots not get stuck on ceiling
  124.         if (!self.owner.button0)
  125.         {
  126.             // CTFBOT [[[
  127.             if ((bot_debug >= 3) && (self.owner.classname == "bot"))
  128.             {
  129.                 dprint(self.owner.netname);
  130.                 dprint(" HookVanish1\n");
  131.             }
  132.             // CTFBOT ]]]
  133.  
  134.             HookVanish();
  135.             return;
  136.         }
  137.     }
  138.     // CTFBOT ]]]
  139.  
  140.     if ((!self.owner.button0 && (self.owner.weapon == IT_HOOK)) ||
  141.         (self.owner.teleport_time > time ) || self.owner.deadflag ) 
  142.     {
  143.         // CTFBOT [[[
  144.         if ((bot_debug >= 3) && (self.owner.classname == "bot"))
  145.         {
  146.             dprint(self.owner.netname);
  147.             dprint(" HookVanish2\n");
  148.         }
  149.         // CTFBOT ]]]
  150.  
  151.         HookVanish();
  152.         return;
  153.     } else {
  154.          if (self.enemy.takedamage) {
  155.             // don't hurt teammates
  156.             if (self.enemy.classname != "player" 
  157.                 || self.enemy.classname != "bot"    // CTFBOT
  158.                 || !teamplay ||
  159.                 self.enemy.lastteam != self.owner.lastteam) {
  160.                 sound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM);
  161.                 T_Damage (self.enemy, self, self.owner, 1);
  162.                 makevectors (self.v_angle);
  163.                 spray_x = 100 * crandom();
  164.                 spray_y = 100 * crandom();
  165.                 spray_z = 100 * crandom() + 50;
  166.                 SpawnBlood (self.origin, spray, 20);
  167.             }
  168.             if (self.enemy.solid == SOLID_SLIDEBOX) {
  169.                     self.velocity = '0 0 0';
  170.                     setorigin (self, self.enemy.origin +
  171.                             self.enemy.mins +
  172.                             (self.enemy.size * 0.5));
  173.             } else {
  174.                     self.velocity = self.enemy.velocity;
  175.             }
  176.         } else {
  177.                 self.velocity = self.enemy.velocity;
  178.         }
  179.         if (self.enemy.solid == SOLID_NOT) 
  180.         {
  181.             // CTFBOT [[[
  182.             if ((bot_debug >= 3) && (self.owner.classname == "bot"))
  183.             {
  184.                 dprint(self.owner.netname);
  185.                 dprint(" HookVanish3\n");
  186.             }
  187.             // CTFBOT ]]]
  188.  
  189.             HookVanish();
  190.             return;
  191.         }
  192.         makevectors (self.owner.angles);
  193.         vel = self.origin - ( self.owner.origin + (v_up * 16 *
  194.                 (!self.owner.button2)) + (v_forward * 16));
  195.         v = vlen (vel);
  196.         if (v <= 100)
  197.                 vel = normalize(vel) * v * 10;  
  198.         if ( v > 100 )
  199.                 vel = normalize(vel) * 1000;  
  200.  
  201.         if (teamplay & TEAM_CAPTURE_CUSTOM) {
  202.             dorg = vlen(self.owner.origin - self.dest);
  203.             if (dorg > 10 && self.style == 3) {
  204.                 sound(self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  205.                 self.style = 2;
  206.             }
  207.             if (dorg < 10 && self.style == 2) {
  208.                 sound(self.owner, CHAN_WEAPON, "weapons/chain3.wav", 1, ATTN_NORM);
  209.                 self.style = 3;
  210.             }
  211.         }
  212.  
  213.         self.owner.velocity = vel;
  214.         self.dest = self.owner.origin;
  215.         self.nextthink = time + 0.1;
  216.         
  217.         if (vlen(self.owner.origin - self.owner.oldorigin) < 10)
  218.             self.owner.stuck_count = self.owner.stuck_count + 1;
  219.         self.owner.oldorigin = self.owner.origin;
  220.     }
  221. };
  222.  
  223. /**************\
  224. * T_ChainTouch *
  225. \**************/
  226.  
  227. void() T_ChainTouch =
  228. {
  229.     if (other == self.owner)
  230.             return;         // don't attach to owner
  231.                
  232.     self.owner.hook_snag_time = time;
  233.  
  234.     if (pointcontents(self.origin) == CONTENT_SKY) 
  235.     {
  236.         // CTFBOT [[[
  237.         if ((bot_debug >= 3) && (self.owner.classname == "bot"))
  238.         {
  239.             dprint(self.owner.netname);
  240.             dprint(" HookVanish4\n");
  241.         }
  242.         // CTFBOT ]]]
  243.         
  244.         HookVanish();
  245.         return;
  246.     }
  247.  
  248.     if ((other.classname == "player" || other.classname == "bot")    // CTFBOT
  249.         && teamplay &&
  250.         other.team == self.owner.lastteam)
  251.         return; // just pass through teammates
  252.  
  253.     if (other.takedamage) {
  254.         // don't damage teammates
  255.         if (other.classname == "player" || other.classname == "bot")    // CTFBOT
  256.             other.axhitme = 1; // make axe noise
  257.         else
  258.             sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  259.         T_Damage (other, self, self.owner, 10 );
  260.         SpawnBlood (self.origin, self.velocity, 10);
  261.         self.owner.hooked_on_someone = TRUE;        // CTFBOT
  262.     } else {
  263.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  264.         self.avelocity = '0 0 0';
  265.     }
  266.                
  267.     if (!self.owner.button0) 
  268.     {
  269.         // CTFBOT [[[
  270.         if ((bot_debug >= 3) && (self.owner.classname == "bot"))
  271.         {
  272.             dprint(self.owner.netname);
  273.             dprint(" HookVanish5\n");
  274.         }
  275.         // CTFBOT ]]]
  276.             
  277.         HookVanish();
  278.         return;
  279.             
  280.     } else {
  281.             if (other.solid == SOLID_SLIDEBOX) {
  282.                     setorigin (self, other.origin + other.mins +
  283.                             (other.size * 0.5));
  284.                     self.velocity = '0 0 0';
  285.             } else {
  286.                     self.velocity = other.velocity;
  287.             }
  288.             self.weapon = other.nextthink - time;
  289.             if (teamplay & TEAM_CAPTURE_CUSTOM)
  290.                 sound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  291.  
  292.             self.style = 2;
  293.             self.enemy = other;
  294.             self.nextthink = time + 0.1;
  295.             self.think = HookPull;
  296.             self.touch = SUB_Null;
  297.     }
  298. };
  299.  
  300. /*************\
  301. * W_FireChain *
  302. \*************/
  303.  
  304. void() W_FireChain =
  305. {
  306.         local entity hook;
  307.  
  308.         self.hook_out = TRUE;
  309.         hook = spawn ();
  310.         hook.owner = self;
  311.         hook.movetype = MOVETYPE_FLY;
  312.         hook.solid = SOLID_BBOX;
  313.         
  314. // set hook speed 
  315.  
  316.         makevectors (self.v_angle);
  317.  
  318.         // CTFBOT [[[
  319.         if (self.classname == "bot")
  320.             hook.velocity = self.bot_aim;
  321.         else
  322.         // CTFBOT ]]]        
  323.             hook.velocity = aim(self, 1000);
  324.              
  325.         hook.velocity = hook.velocity * 800;
  326.         hook.angles = vectoangles(hook.velocity);
  327.         hook.avelocity = '0 0 -500';
  328.     
  329.         hook.touch = T_ChainTouch;
  330.     
  331. // set hook sound
  332.         hook.nextthink = time + 5;
  333.         hook.think = HookVanish;
  334.  
  335.         if (teamplay & TEAM_CAPTURE_CUSTOM)
  336.             setmodel (hook, "progs/star.mdl");
  337.         else
  338.             setmodel (hook, "progs/v_spike.mdl");
  339.         setsize (hook, '0 0 0', '0 0 0');     
  340.         setorigin (hook, self.origin + (v_forward*16) + '0 0 16' );
  341.  
  342.         if (teamplay & TEAM_CAPTURE_CUSTOM)
  343.             sound (self, CHAN_WEAPON, "weapons/chain1.wav", 1, ATTN_NORM);    
  344.         else
  345.             sound (self, CHAN_WEAPON, "hknight/hit.wav", 1, ATTN_NORM);    
  346.  
  347.         hook.goalentity = MakeChain (hook, self, 3);
  348. };
  349.  
  350.