home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / bouncer / bouncer.qc next >
Encoding:
Text File  |  1996-08-08  |  3.7 KB  |  156 lines

  1. void() BecomeExplosion;
  2. void() PopperExplode;
  3. void(float dmg) spawn_touchblood;
  4. void() BouncerExplode;
  5. void() BouncerThink;
  6.  
  7. float WP_BOUNCER = 2;
  8. float IM_BOUNCER = 71;
  9.  
  10. float(float a, float b) min = {
  11.     if (a>b) 
  12.         return b; 
  13.     else 
  14.         return a;
  15. };
  16.  
  17. void() PopperTouch =
  18. {
  19.     PopperExplode();
  20. };
  21.  
  22. void() PopperExplode =
  23. {
  24.     local entity spike;
  25.     local float tmp=0;
  26.     while (tmp<20)
  27.     {
  28.         tmp=tmp+1;
  29.         spike=spawn();
  30.         spike.owner=self.owner;
  31.         spike.movetype=MOVETYPE_BOUNCE;
  32.         spike.solid=SOLID_BBOX;
  33.         self.touch=SUB_Null;
  34.         spike.classname="shrapnel";
  35.         spike.think=SUB_Remove;
  36.         spike.nextthink=time+6;
  37.         spike.velocity_x=crandom()*1000;
  38.         spike.velocity_y=crandom()*1000;
  39.         spike.velocity_z=0;
  40.         spike.angles=vectoangles(spike.velocity);
  41.         spike.avelocity='300 300 300';
  42.         spike.touch=ShrapnelTouch;
  43.         setmodel(spike,"progs/spike.mdl");
  44.         setsize(spike,'0 0 0','0 0 0');
  45.         setorigin(spike,self.origin);
  46.     }
  47.     T_RadiusDamage(self,self.owner,120,world);
  48.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  49.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  50.     WriteCoord (MSG_BROADCAST, self.origin_x);
  51.     WriteCoord (MSG_BROADCAST, self.origin_y);
  52.     WriteCoord (MSG_BROADCAST, self.origin_z);
  53.     self.solid=SOLID_NOT;
  54.     BecomeExplosion();
  55. };
  56.  
  57. void() BouncerFirstThink =
  58. {
  59.     self.nextthink=time+0.1;
  60.     if (self.velocity == '0 0 0') 
  61.     {
  62.         self.avelocity='0 0 0';
  63.         self.think=BouncerThink;
  64.         self.blasttimer=20;
  65.     }
  66. };
  67.         
  68. void() BouncerThink =
  69. {
  70.     local entity head;
  71.     local float expfl;
  72.     head = findradius(self.origin,120);
  73.     self.nextthink=time+0.1;
  74.     while (head)
  75.     {
  76.         if (head.takedamage) 
  77.             expfl=1;
  78.         head=head.chain;
  79.     }
  80.     if (expfl)
  81.     {
  82.         self.think=BouncerExplode;
  83.         self.nextthink=time+0.1;
  84.     }
  85.     if (self.blasttimer<time)
  86.     {
  87.         self.think=BouncerExplode;
  88.         self.nextthink=time+0.1;
  89.     }
  90. };
  91.  
  92. void() BouncerExplode =
  93. {
  94.     local entity popper;
  95.     popper=spawn();
  96.     popper.owner=self.owner;
  97.     popper.movetype=MOVETYPE_BOUNCE;
  98.     popper.solid=SOLID_BBOX;
  99.     popper.classname="popper";
  100.     popper.velocity='0 0 600';
  101.     popper.angles=vectoangles(popper.velocity);
  102.     popper.touch=PopperTouch;
  103.     popper.nextthink=time+0.05;
  104.     popper.think=PopperExplode;
  105.     setmodel(popper,"progs/grenade.mdl");
  106.     setsize(popper,'0 0 0','0 0 0');
  107.     setorigin(popper,self.origin);
  108. //    T_RadiusDamage (self, self.owner, 120, world);    
  109.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  110.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  111.     WriteCoord (MSG_BROADCAST, self.origin_x);
  112.     WriteCoord (MSG_BROADCAST, self.origin_y);
  113.     WriteCoord (MSG_BROADCAST, self.origin_z);
  114.     self.solid=SOLID_NOT;
  115.     BecomeExplosion();
  116. };
  117.  
  118. void() BouncerTouch =
  119. {
  120.     sound(self,CHAN_WEAPON,"weapons/bounce.wav",1,ATTN_NORM);
  121. };
  122.  
  123. void() W_FireBouncer =
  124. {
  125.     local entity bouncer;
  126.     local float tmp;
  127.     // pulls 1 rocket and 30 nails
  128.     self.ammo_rockets = self.ammo_rockets - 1;
  129.     self.ammo_nails = self.ammo_nails - 20;
  130.     sound(self,CHAN_WEAPON,"weapons/grenade.wav",1,ATTN_NORM);
  131.     tmp=floor(self.ammo_nails/20);
  132.     self.currentammo=min(self.ammo_rockets,tmp);
  133.     bouncer=spawn();
  134.     bouncer.owner=self;
  135.     bouncer.movetype=MOVETYPE_BOUNCE;
  136.     bouncer.solid=SOLID_BBOX;
  137.     bouncer.classname="bouncer";
  138.     makevectors(self.v_angle);
  139.     if (self.v_angle_x)
  140.         bouncer.velocity=v_forward*600+v_up*200+crandom()*v_right*10+crandom()*v_up*10;
  141.     else
  142.     {
  143.         bouncer.velocity=aim(self,10000);
  144.         bouncer.velocity=bouncer.velocity*600;
  145.         bouncer.velocity_z=200;
  146.     }
  147.     bouncer.avelocity='300 300 300';
  148.     bouncer.angles=vectoangles(bouncer.velocity);
  149.     bouncer.touch=BouncerTouch;
  150.     bouncer.think=BouncerFirstThink;
  151.     bouncer.nextthink=time+0.1;
  152.     bouncer.blasttimer=time+3;
  153.     setmodel(bouncer,"progs/grenade.mdl");
  154.     setsize(bouncer,'0 0 0','0 0 0');
  155.     setorigin(bouncer,self.origin);
  156. };