SHARE
TWEET

Untitled

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