SHARE
TWEET

Untitled

a guest Jan 26th, 2016 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ==============================================================================
  3.  
  4. BFG
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. void()  bfgshot1    =   [0,     bfgshot2] {self.nextthink = time + 0.05;};
  10. void()  bfgshot2    =   [1,     bfgshot1] {self.nextthink = time + 0.05;};
  11.  
  12. void() bfg_ball_think =
  13. {
  14.  
  15. //continuous lightning bolt targetting nearby ennemies from BFG orb
  16.     local   vector          org;
  17.     //local   float       cells,damage=0;
  18.     local   entity      head;
  19.  
  20.         org = self.origin + '0 0 16';
  21.  
  22.      head = findradius(self.origin, 250);  // finds all entitys within 250 (2.5 meters?)
  23.         while (head)
  24.         {
  25.         if (head.takedamage)
  26.           {
  27.             if(head != self)  // if the entity (head) is you (self), skip
  28.             {
  29.                 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  30.                 WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  31.                 WriteEntity (MSG_BROADCAST, head);  // Start position for lightning
  32.                 WriteCoord (MSG_BROADCAST, org_x);  // Your position
  33.                 WriteCoord (MSG_BROADCAST, org_y);
  34.                 WriteCoord (MSG_BROADCAST, org_z);
  35.                 WriteCoord (MSG_BROADCAST, head.origin_x);  // entity's position
  36.                 WriteCoord (MSG_BROADCAST, head.origin_y);
  37.                 WriteCoord (MSG_BROADCAST, head.origin_z);
  38.                 sound (head, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  39.                 damage = 40; //40 + random()*20
  40.                 T_Damage (head, self, self.owner, damage);
  41.             }
  42.           }
  43.         //head = head.chain;  // cycle to next head (entity)
  44.         }
  45.  
  46. }
  47.  
  48.  
  49. void(vector org, vector vec) BFGShot =
  50. {
  51.     local   vector  vec;
  52.     local   entity bfgsphere;
  53.        
  54.     vec = normalize(vec);
  55.    
  56.     bfgsphere = spawn();
  57.     bfgsphere.owner = self;
  58.     bfgsphere.movetype = MOVETYPE_FLY;
  59.     bfgsphere.solid = SOLID_BBOX;
  60.     bfgsphere.effects = EF_DIMLIGHT;
  61.  
  62.     setmodel (bfgsphere, "progs/bfgshot.spr");
  63.     setsize (bfgsphere, '0 0 0', '0 0 0');
  64.     bfgsphere.think = bfgshot1;    
  65.  
  66.     setorigin (bfgsphere, org);
  67.  
  68.     bfgsphere.velocity = vec * 800; //600
  69.     bfgsphere.angles = vectoangles(bfgsphere.velocity);
  70.  
  71.     bfgsphere.nextthink = time + 0.1;
  72.     bfgsphere.think = bfgshot1;
  73.  
  74.     self.nextthink = time + 0.1; //how often lightning strikes, 0.3 original value
  75.     self.think = bfg_ball_think; //keep repeating
  76.  
  77.     bfgsphere.nextthink = time + 5;
  78.     bfgsphere.think = SUB_Remove
  79.  
  80.     bfgsphere.touch = BFG_Touch;
  81. };
  82.  
  83. void() BFG_Touch =
  84. {
  85. local float rand;
  86.     if (other == self.owner)
  87.         return;
  88.  
  89.     if (other.solid == SOLID_TRIGGER)
  90.         return; // trigger field, do nothing
  91.  
  92.     if (pointcontents(self.origin) == CONTENT_SKY)
  93.     {
  94.         remove(self);
  95.         return;
  96.     }
  97.    
  98. // hit something that bleeds
  99.     if (other.takedamage)
  100.     {
  101.         spawn_touchblood (32);
  102.         T_Damage (other, self, self.owner, 300); //most monsters would gib on impact, so it will keep going. If the body's still in one piece when dying, the orb should explode as they're solid.
  103.     }
  104.     else
  105.     {
  106.         BFG_Expl();
  107.         remove(self);
  108.     }
  109.  
  110.  
  111. };
  112.  
  113. void() bfg_fire =
  114. {
  115.     local vector org;
  116.  
  117.     self.effects = self.effects | EF_MUZZLEFLASH;
  118.     makevectors (self.angles);
  119.    
  120.     org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
  121.     sound (head, CHAN_WEAPON, "weapons/bfgfire1.wav", 1, ATTN_NORM);
  122.  
  123.     BFGShot(org, self.enemy.origin - self.origin);
  124. };
  125.  
  126. void()  bfgexpl1    =   [0,     bfgexpl2] {self.nextthink = time + 0.05;};
  127. void()  bfgexpl2    =   [1,     bfgexpl3] {self.nextthink = time + 0.05;};
  128. void()  bfgexpl3    =   [2,     bfgexpl4] {self.nextthink = time + 0.05;};
  129. void()  bfgexpl4    =   [3,     bfgexpl5] {self.nextthink = time + 0.05;};
  130. void()  bfgexpl5    =   [4,     SUB_Remove] {self.nextthink = time + 0.05;};
  131.  
  132. void()  bfgblast1   =   [0,     bfgblast2] {self.nextthink = time + 0.05;};
  133. void()  bfgblast2   =   [1,     bfgblast3] {self.nextthink = time + 0.05;};
  134. void()  bfgblast3   =   [2,     bfgblast4] {self.nextthink = time + 0.05;};
  135. void()  bfgblast4   =   [3,     bfgblast5] {self.nextthink = time + 0.05;};
  136. void()  bfgblast5   =   [4,     SUB_Remove] {self.nextthink = time + 0.05;};
  137.  
  138. void() BFG_Expl =
  139. {
  140.  
  141.     local   vector          org;
  142.     local   entity      head;
  143.  
  144.     self.movetype = MOVETYPE_NONE;
  145.     self.velocity = '0 0 0';
  146.     self.touch = SUB_Null;
  147.     setmodel (self, "progs/bfgexpl.spr");
  148.     self.solid = SOLID_NOT;
  149.     bfgexpl1 ();   
  150.  
  151. //the bfg blast fires deadlier lightning bolts to nearby enemies, comes from BFG orb on impact
  152.  
  153.      org = self.origin + '0 0 16';
  154.  
  155.      head = findradius(self.origin, 300);
  156.         while (head)
  157.         {
  158.         if (head.takedamage)
  159.           {
  160.             if(head != self)  // if the entity (head) is you (self), skip
  161.             {
  162.                 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  163.                 WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  164.                 WriteEntity (MSG_BROADCAST, head);  // Start position for lightning
  165.                 WriteCoord (MSG_BROADCAST, org_x);  // Your position
  166.                 WriteCoord (MSG_BROADCAST, org_y);
  167.                 WriteCoord (MSG_BROADCAST, org_z);
  168.                 WriteCoord (MSG_BROADCAST, head.origin_x);  // entity's position
  169.                 WriteCoord (MSG_BROADCAST, head.origin_y);
  170.                 WriteCoord (MSG_BROADCAST, head.origin_z);
  171.                 damage = 100;
  172.                 T_Damage (head, self, self.owner, damage);
  173.             }
  174.           }
  175.         head = head.chain;  // cycle to next head (entity)
  176.         }
  177.  
  178. };
  179.  
  180. void() BFG_Blast =
  181. {
  182.  
  183.     local   vector          org;
  184.     local   entity      head;
  185.  
  186.     self.movetype = MOVETYPE_NONE;
  187.     self.velocity = '0 0 0';
  188.     self.touch = SUB_Null;
  189.     setmodel (self, "progs/bfgblast.spr");
  190.     self.solid = SOLID_NOT;
  191.     bfgexpl1 ();
  192.     sound (head, CHAN_WEAPON, "weapons/bfgblast.wav", 1, ATTN_NORM);
  193. };
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top