SHARE
TWEET

Untitled

a guest Feb 1st, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ==============================================================================
  3.  
  4. BFG
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. //BFG orb sprites
  10. void()  bfgshot1    =   [0,     bfgshot2] {self.nextthink = time + 0.05;};
  11. void()  bfgshot2    =   [1,     bfgshot1] {self.nextthink = time + 0.05;};
  12.  
  13. //BFG explosion on impact sprites
  14. void()  bfgexpl1    =   [0,     bfgexpl2] {self.nextthink = time + 0.05;};
  15. void()  bfgexpl2    =   [1,     bfgexpl3] {self.nextthink = time + 0.05;};
  16. void()  bfgexpl3    =   [2,     bfgexpl4] {self.nextthink = time + 0.05;};
  17. void()  bfgexpl4    =   [3,     bfgexpl5] {self.nextthink = time + 0.05;};
  18. void()  bfgexpl5    =   [4,     SUB_Remove] {self.nextthink = time + 0.05;};
  19.  
  20. //BFG blast after impact sprites
  21. void()  bfgblast1   =   [0,     bfgblast2] {};
  22. void()  bfgblast2   =   [1,     bfgblast3] {};
  23. void()  bfgblast3   =   [2,     bfgblast4] {};
  24. void()  bfgblast4   =   [3,     bfgblast5] {};
  25. void()  bfgblast5   =   [4,     SUB_Remove] {};
  26.  
  27.  
  28. void() bfg_ball_think =
  29. {
  30.  
  31. //continuous lightning bolt targetting nearby ennemies from BFG orb
  32.     local   vector          org;
  33.     //local   float       cells,damage=0;
  34.     local   entity      head;
  35.     local   float   damage;
  36.     local   entity   lightcont;
  37.  
  38.     org = lightcont.origin + '0 0 16';
  39.  
  40.      head = findradius(lightcont.origin, 250);  // finds all entitys within 250 (2.5 meters?)
  41.         while (head)
  42.         {
  43.         if (head.takedamage)
  44.           {
  45.             if(head != self)  // if the entity (head) is you (self), skip
  46.             {
  47.                 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  48.                 WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  49.                 WriteEntity (MSG_BROADCAST, head);  // Start position for lightning
  50.                 WriteCoord (MSG_BROADCAST, org_x);  // Your position
  51.                 WriteCoord (MSG_BROADCAST, org_y);
  52.                 WriteCoord (MSG_BROADCAST, org_z);
  53.                 WriteCoord (MSG_BROADCAST, head.origin_x);  // entity's position
  54.                 WriteCoord (MSG_BROADCAST, head.origin_y);
  55.                 WriteCoord (MSG_BROADCAST, head.origin_z);
  56.                 sound (head, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  57.                 damage = 40; //40 + random()*20
  58.                 T_Damage (head, lightcont, lightcont.owner, damage);
  59.             }
  60.           }
  61.         head = head.chain;  // cycle to next head (entity)
  62.         }
  63.  
  64. };
  65.  
  66. void(vector org) BFG_Blast =
  67. {
  68.  
  69.     local   entity      newent;
  70.  
  71.     newent = spawn(); //create new entity to become the blast
  72.     newent.origin = org; //set location to the ending of the lightning
  73.     newent.movetype = MOVETYPE_NONE;
  74.     newent.velocity = '0 0 0';
  75.     newent.touch = SUB_Null;
  76.     setmodel (self, "progs/bfgblast.spr");
  77.     newent.solid = SOLID_NOT;
  78.  
  79.     bfgblast1 ();
  80.  
  81.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  82.     WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  83.     WriteCoord (MSG_BROADCAST, self.origin_x);
  84.     WriteCoord (MSG_BROADCAST, self.origin_y);
  85.     WriteCoord (MSG_BROADCAST, self.origin_z);
  86.     WriteByte (MSG_BROADCAST, 246);
  87.     WriteByte (MSG_BROADCAST, 1);
  88.     sound (newent, CHAN_WEAPON, "weapons/bfgblast.wav", 1, ATTN_NORM);
  89. };
  90.  
  91. void() BFG_Expl =
  92. {
  93.  
  94.     local   vector          org;
  95.     local   entity      head;
  96.     local   float   damage;
  97.     local   entity   bfgexpl;
  98.  
  99.     bfgexpl.movetype = MOVETYPE_NONE;
  100.     bfgexpl.velocity = '0 0 0';
  101.     bfgexpl.touch = SUB_Null;
  102.     setmodel (bfgexpl, "progs/bfgexpl.spr");
  103.     bfgexpl.solid = SOLID_NOT;
  104.     bfgexpl1 ();
  105.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  106.     WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  107.     WriteCoord (MSG_BROADCAST, bfgexpl.origin_x);
  108.     WriteCoord (MSG_BROADCAST, bfgexpl.origin_y);
  109.     WriteCoord (MSG_BROADCAST, bfgexpl.origin_z);
  110.     WriteByte (MSG_BROADCAST, 246);
  111.     WriteByte (MSG_BROADCAST, 1);
  112.     sound (bfgexpl, CHAN_WEAPON, "weapons/bfgexpl.wav", 1, ATTN_NORM); 
  113.  
  114. //the bfg blast fires deadlier lightning bolts to nearby enemies, comes from BFG orb on impact
  115.  
  116.      org = self.origin + '0 0 16';
  117.  
  118.      head = findradius(self.origin, 300);
  119.         while (head)
  120.         {
  121.         if (head.takedamage)
  122.           {
  123.             if(head != self)  // if the entity (head) is you (self), skip
  124.             {
  125.                 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  126.                 WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  127.                 WriteEntity (MSG_BROADCAST, head);  // Start position for lightning
  128.                 WriteCoord (MSG_BROADCAST, org_x);  // Your position
  129.                 WriteCoord (MSG_BROADCAST, org_y);
  130.                 WriteCoord (MSG_BROADCAST, org_z);
  131.                 WriteCoord (MSG_BROADCAST, head.origin_x);  // entity's position
  132.                 WriteCoord (MSG_BROADCAST, head.origin_y);
  133.                 WriteCoord (MSG_BROADCAST, head.origin_z);
  134.                 damage = 150;
  135.                 T_Damage (head, self, self.owner, damage);
  136.                 BFG_Blast(head.origin);
  137.             }
  138.           }
  139.         head = head.chain;  // cycle to next head (entity)
  140.         }
  141.  
  142. };
  143.  
  144. void() BFG_Touch =
  145. {
  146. local float rand;
  147.     if (other == self.owner)
  148.         return;
  149.  
  150.     if (other.solid == SOLID_TRIGGER)
  151.         return; // trigger field, do nothing
  152.  
  153.     if (pointcontents(self.origin) == CONTENT_SKY)
  154.     {
  155.         remove(self);
  156.         return;
  157.     }
  158.    
  159. // hit something that bleeds
  160.     if (other.takedamage)
  161.     {
  162.         if (other.health < 265)
  163.         {
  164.             spawn_touchblood (32);
  165.             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.
  166.         }
  167.         else
  168.         {
  169.             spawn_touchblood (32);
  170.             T_Damage (other, self, self.owner, 300);
  171.             BFG_Expl();
  172.             remove(self);
  173.         }
  174.        
  175.     }
  176.     else
  177.     {
  178.         BFG_Expl();
  179.         remove(self);
  180.     }
  181.  
  182. };
  183.  
  184. void(vector org, vector vec) BFGShot =
  185. {
  186.     local   vector  vec;
  187.     local   entity bfgsphere;
  188.        
  189.     vec = normalize(vec);
  190.    
  191.     bfgsphere = spawn();
  192.     bfgsphere.owner = self;
  193.     bfgsphere.movetype = MOVETYPE_FLY;
  194.     bfgsphere.solid = SOLID_BBOX;
  195.     bfgsphere.effects = EF_DIMLIGHT;
  196.  
  197.     setmodel (bfgsphere, "progs/bfgshot.spr");
  198.     setsize (bfgsphere, '0 0 0', '0 0 0');
  199.     bfgsphere.think = bfgshot1;    
  200.  
  201.     setorigin (bfgsphere, org);
  202.  
  203.     bfgsphere.velocity = vec * 800; //600
  204.     bfgsphere.angles = vectoangles(bfgsphere.velocity);
  205.  
  206.     bfgsphere.nextthink = time + 5;
  207.     bfgsphere.think = SUB_Remove;
  208.  
  209.     bfgsphere.nextthink = time + 0.3; //how often lightning strikes
  210.     bfgsphere.think = bfg_ball_think; //keep repeating
  211.  
  212.     bfgsphere.nextthink = time + 0.1;
  213.     bfgsphere.think = bfgshot1;
  214.  
  215.     //for nextthinks: the greater values ust be put at first
  216.  
  217.     bfgsphere.touch = BFG_Touch;
  218. };
  219.  
  220. void() W_Bfg_Fire =
  221. {
  222.     local vector org;
  223.  
  224.     self.effects = self.effects | EF_MUZZLEFLASH;
  225.     makevectors (self.v_angle); //v_xxx refers to the player's facing direction
  226.    
  227.     org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
  228.     sound (self, CHAN_WEAPON, "weapons/bfgfire1.wav", 1, ATTN_NORM);
  229.  
  230.     BFGShot(org, v_forward);
  231. };
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top