SHARE
TWEET

Untitled

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