SHARE
TWEET

Untitled

a guest May 19th, 2016 67 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 sprites
  10. void()  bfgexpl1    =   [0,     bfgexpl2] {};
  11. void()  bfgexpl2    =   [1,     bfgexpl3] {};
  12. void()  bfgexpl3    =   [2,     bfgexpl4] {};
  13. void()  bfgexpl4    =   [3,     bfgexpl5] {};
  14. void()  bfgexpl5    =   [4,     SUB_Remove] {};
  15.  
  16. //BFG blast sprites
  17. void()  bfgblast1   =   [4,     bfgblast2] {};
  18. void()  bfgblast2   =   [0,     bfgblast3] {};
  19. void()  bfgblast3   =   [1,     bfgblast4] {};
  20. void()  bfgblast4   =   [2,     bfgblast5] {};
  21. void()  bfgblast5   =   [3,     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;
  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.owner as stated in BFG_Shot), 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 = 20; //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 (newent, "progs/bfgblst.spr"); //self
  77.     newent.solid = SOLID_NOT;
  78.  
  79.     //bfgblast1();
  80.     newent.nextthink = time + 0.01;
  81.     newent.think = bfgblast1;
  82.  
  83.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  84.     WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  85.     WriteCoord (MSG_BROADCAST, org_x); //self.origin, org_
  86.     WriteCoord (MSG_BROADCAST, org_y);
  87.     WriteCoord (MSG_BROADCAST, org_z);
  88.     WriteByte (MSG_BROADCAST, 246);
  89.     WriteByte (MSG_BROADCAST, 1);
  90.     sound (newent, CHAN_WEAPON, "weapons/bfgblast.wav", 1, ATTN_NORM);
  91. };
  92.  
  93. void() BFG_Expl =
  94. {
  95.  
  96.     local   vector          org;
  97.     local   entity      head;
  98.     local   float   damage;
  99.     local   entity   bfgexpl;
  100.  
  101.     self.movetype = MOVETYPE_NONE;
  102.     self.velocity = '0 0 0';
  103.     self.touch = SUB_Null;
  104.     setmodel (self, "progs/bfgexpl.spr"); //self
  105.     self.solid = SOLID_NOT;
  106.     //bfgexpl1();
  107.     self.nextthink = time + 0.01;
  108.     self.think = bfgexpl1;
  109.  
  110. //the bfg blast fires deadlier lightning bolts to nearby enemies, comes from BFG orb on impact
  111.  
  112.      org = self.origin;
  113.  
  114.      head = findradius(self.origin, 300);
  115.         while (head)
  116.         {
  117.         if (head.takedamage)
  118.           {
  119.             if(head != self.owner)  // if the entity (head) is you (self.owner as stated in BFG_Shot), skip
  120.             {
  121.                 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  122.                 WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  123.                 WriteEntity (MSG_BROADCAST, head);  // Start position for lightning
  124.                 WriteCoord (MSG_BROADCAST, org_x);  // Your position
  125.                 WriteCoord (MSG_BROADCAST, org_y);
  126.                 WriteCoord (MSG_BROADCAST, org_z);
  127.                 WriteCoord (MSG_BROADCAST, head.origin_x);  // entity's position
  128.                 WriteCoord (MSG_BROADCAST, head.origin_y);
  129.                 WriteCoord (MSG_BROADCAST, head.origin_z);
  130.                 damage = 150;
  131.                 T_Damage (head, self, self.owner, damage);
  132.                 BFG_Blast(head.origin);
  133.             }
  134.           }
  135.         head = head.chain;  // cycle to next head (entity)
  136.         }
  137.  
  138. };
  139.  
  140. void() BFG_Touch =
  141. {
  142. local float rand;
  143.     if (other == self.owner)
  144.         return;
  145.  
  146.     if (other.solid == SOLID_TRIGGER)
  147.         return; // trigger field, do nothing
  148.  
  149.     if (pointcontents(self.origin) == CONTENT_SKY)
  150.     {
  151.         remove(self);
  152.         return;
  153.     }
  154.    
  155. // hit something that bleeds
  156.     if (other.takedamage)
  157.     {
  158.         if (other.health < 265)
  159.         {
  160.             spawn_touchblood (32);
  161.             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.
  162.         }
  163.         else
  164.         {
  165.             //spawn_touchblood (16);
  166.             WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  167.             WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  168.             WriteCoord (MSG_BROADCAST, self.origin_x);
  169.             WriteCoord (MSG_BROADCAST, self.origin_y);
  170.             WriteCoord (MSG_BROADCAST, self.origin_z);
  171.             WriteByte (MSG_BROADCAST, 246);
  172.             WriteByte (MSG_BROADCAST, 1);
  173.             sound (self, CHAN_WEAPON, "weapons/bfgexp.wav", 1, ATTN_NORM); 
  174.  
  175.             T_Damage (other, self, self.owner, 300);
  176.             BFG_Expl();
  177.             remove(self);
  178.         }
  179.        
  180.     }
  181.     else
  182.     {
  183.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  184.         WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
  185.         WriteCoord (MSG_BROADCAST, self.origin_x);
  186.         WriteCoord (MSG_BROADCAST, self.origin_y);
  187.         WriteCoord (MSG_BROADCAST, self.origin_z);
  188.         WriteByte (MSG_BROADCAST, 246);
  189.         WriteByte (MSG_BROADCAST, 1);
  190.         sound (self, CHAN_WEAPON, "weapons/bfgexp.wav", 1, ATTN_NORM); 
  191.  
  192.         BFG_Expl();
  193.         remove(self);
  194.     }
  195.  
  196. };
  197.  
  198. void(vector org, vector vec) BFGShot =
  199. {
  200.     local   vector  vec;
  201.     local   entity bfgsphere;
  202.        
  203.     vec = normalize(vec);
  204.    
  205.     bfgsphere = spawn();
  206.     bfgsphere.owner = self;
  207.     bfgsphere.movetype = MOVETYPE_FLY;
  208.     bfgsphere.solid = SOLID_BBOX;
  209.     bfgsphere.effects = EF_DIMLIGHT;
  210.  
  211.     setmodel (bfgsphere, "progs/bfgshot.spr");
  212.     setsize (bfgsphere, '0 0 0', '0 0 0');
  213.     bfgsphere.think = bfgshot1;    
  214.  
  215.     setorigin (bfgsphere, org);
  216.  
  217.     bfgsphere.velocity = vec * 800; //600
  218.     bfgsphere.angles = vectoangles(bfgsphere.velocity);
  219.  
  220.     //bfgsphere.nextthink = time + 5;
  221.     //bfgsphere.think = SUB_Remove;
  222.  
  223.     //bfgsphere.nextthink = time + 0.3; //how often lightning strikes
  224.     //bfgsphere.think = bfg_ball_think; //keep repeating
  225.  
  226.     bfgsphere.nextthink = time + 0.1;
  227.     bfgsphere.think = bfgshot1;
  228.  
  229.     //for nextthinks: the greater values ust be put at first
  230.  
  231.     bfgsphere.touch = BFG_Touch;
  232. };
  233.  
  234. void() W_Bfg_Fire =
  235. {
  236.     local vector org;
  237.  
  238.     self.effects = self.effects | EF_MUZZLEFLASH;
  239.     makevectors (self.v_angle); //v_xxx refers to the player's facing direction
  240.    
  241.     org = self.origin + v_forward * 30 + '0 0 16'; //org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
  242.     sound (self, CHAN_WEAPON, "weapons/bfgfire1.wav", 1, ATTN_NORM);
  243.  
  244.     BFGShot(org, v_forward);
  245.     self.currentammo = self.ammo_cells = self.ammo_cells - 30;
  246. };
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top