Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. .float uzi_bullets_fired;
  2. .float uzi_bullets_hit;
  3.  
  4. // leilei's fancy muzzleflash stuff
  5. void W_Uzi_Flash_Go() {
  6. if (self.frame > 10){
  7. SUB_Remove();
  8. return;
  9. }
  10. self.frame = self.frame + 2;
  11. self.alpha = self.alpha - 0.2;
  12. self.think = W_Uzi_Flash_Go;
  13. self.nextthink = time + 0.02;
  14. };
  15.  
  16. .float uzi_bulletcounter;
  17. void W_Uzi_Attack (float deathtype)
  18. {
  19. local entity flash, flash2;
  20. self.uzi_bullets_fired = self.uzi_bullets_fired + 1;
  21.  
  22. if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
  23. {
  24. if (self.uzi_bulletcounter == 1)
  25. self.ammo_nails = self.ammo_nails - cvar("g_balance_uzi_first_ammo");
  26. else
  27. self.ammo_nails = self.ammo_nails - cvar("g_balance_uzi_sustained_ammo");
  28. }
  29. W_SetupShot (self, '25 5.5 -8', TRUE, 0, "weapons/uzi_fire.wav");
  30. //W_SetupShot (self, '25 8 -8', TRUE, 0, "weapons/uzi_fire.wav"); // TODO: move model to the right a little
  31. if (!g_norecoil)
  32. {
  33. self.punchangle_x = random () - 0.5;
  34. self.punchangle_y = random () - 0.5;
  35. }
  36.  
  37. // this attack_finished just enforces a cooldown at the end of a burst
  38. ATTACK_FINISHED(self) = time + cvar("g_balance_uzi_first_refire");
  39.  
  40. if (self.uzi_bulletcounter == 1)
  41. self.uzi_bullets_hit = self.uzi_bullets_hit + fireBullet (w_shotorg, w_shotdir, cvar("g_balance_uzi_first_spread"), cvar("g_balance_uzi_first_damage"), cvar("g_balance_uzi_first_force"), deathtype, TRUE);
  42. else
  43. self.uzi_bullets_hit = self.uzi_bullets_hit + fireBullet (w_shotorg, w_shotdir, cvar("g_balance_uzi_sustained_spread"), cvar("g_balance_uzi_sustained_damage"), cvar("g_balance_uzi_sustained_force"), deathtype, (self.uzi_bulletcounter & 3) == 0);
  44.  
  45. pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
  46.  
  47. // muzzle flash for 1st person view
  48. flash = spawn();
  49. setorigin(flash, '53 5 0');
  50. setmodel(flash, "models/uziflash.md3"); // precision set below
  51. setattachment(flash, self.weaponentity, "bone01");
  52. flash.owner = self;
  53. flash.viewmodelforclient = self;
  54. flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
  55. flash.scale = 1.2;
  56. //SUB_SetFade(flash, time + 0.06, 0);
  57. flash.think = W_Uzi_Flash_Go;
  58. flash.nextthink = time + 0.02;
  59. flash.frame = 2;
  60.  
  61. // muzzle flash for 3rd person view
  62. flash2 = spawn();
  63. setorigin(flash2, '43 1 8');
  64. setmodel(flash2, "models/uziflash.md3"); // precision set below
  65. setattachment(flash2, self.exteriorweaponentity, "");
  66. //SUB_SetFade(flash2, time + 0.06, 0);
  67. flash2.think = W_Uzi_Flash_Go;
  68. flash2.nextthink = time + 0.02;
  69. flash2.frame = 2;
  70. // common properties
  71. flash.angles_z = flash2.angles_z = flash.v_angle_z + random() * 180;
  72. flash.alpha = flash2.alpha = 1;
  73. flash.effects = flash2.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
  74.  
  75. // casing code
  76. if (cvar("g_casings") >= 2)
  77. SpawnCasing (w_shotorg + v_forward * 10, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3);
  78. }
  79.  
  80. // weapon frames
  81. void uzi_fire1_02()
  82. {
  83. if(self.weapon != self.switchweapon) // abort immediately if switching
  84. {
  85. w_ready();
  86. return;
  87. }
  88. if (self.BUTTON_ATCK)
  89. {
  90. if (!weapon_action(self.weapon, WR_CHECKAMMO2))
  91. {
  92. W_SwitchWeapon_Force(self, w_getbestweapon(self));
  93. w_ready();
  94. return;
  95. }
  96. ATTACK_FINISHED(self) = time + cvar("g_balance_uzi_refire");
  97. self.uzi_bulletcounter = self.uzi_bulletcounter + 1;
  98. W_Uzi_Attack(WEP_UZI);
  99. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
  100. }
  101. else
  102. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
  103. };
  104.  
  105. void spawnfunc_weapon_machinegun(); // defined in t_items.qc
  106.  
  107. float w_uzi(float req)
  108. {
  109. if (req == WR_AIM)
  110. if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
  111. self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
  112. else
  113. {
  114. self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
  115. }
  116. else if (req == WR_THINK)
  117. {
  118. if (self.BUTTON_ATCK)
  119. if (weapon_prepareattack(0, cvar("g_balance_uzi_refire")))
  120. {
  121. self.uzi_bulletcounter = 1;
  122. W_Uzi_Attack(WEP_UZI);
  123. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
  124. }
  125. if (self.BUTTON_ATCK2)
  126. if (weapon_prepareattack(1, cvar("g_balance_uzi_refire")))
  127. {
  128. self.uzi_bulletcounter = 1;
  129. W_Uzi_Attack(WEP_UZI | HITTYPE_SECONDARY);
  130. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
  131. }
  132. }
  133. else if (req == WR_PRECACHE)
  134. {
  135. precache_model ("models/tracer.mdl");
  136. precache_model ("models/uziflash.md3");
  137. precache_model ("models/weapons/g_uzi.md3");
  138. precache_model ("models/weapons/v_uzi.md3");
  139. precache_model ("models/weapons/w_uzi.zym");
  140. precache_sound ("weapons/ric1.wav");
  141. precache_sound ("weapons/ric2.wav");
  142. precache_sound ("weapons/ric3.wav");
  143. precache_sound ("weapons/uzi_fire.wav");
  144. if (cvar("g_casings") >= 2)
  145. {
  146. precache_sound ("weapons/brass1.wav");
  147. precache_sound ("weapons/brass2.wav");
  148. precache_sound ("weapons/brass3.wav");
  149. precache_model ("models/casing_bronze.mdl");
  150. }
  151. }
  152. else if (req == WR_SETUP)
  153. weapon_setup(WEP_UZI);
  154. else if (req == WR_CHECKAMMO1)
  155. return self.ammo_nails >= cvar("g_balance_uzi_first_ammo");
  156. else if (req == WR_CHECKAMMO2)
  157. return self.ammo_nails >= cvar("g_balance_uzi_first_ammo");
  158. else if (req == WR_SUICIDEMESSAGE)
  159. w_deathtypestring = "did the impossible";
  160. else if (req == WR_KILLMESSAGE)
  161. {
  162. if(w_deathtype & HITTYPE_SECONDARY)
  163. w_deathtypestring = "was sniped by";
  164. else
  165. w_deathtypestring = "was riddled full of holes by";
  166. }
  167. return TRUE;
  168. };
Add Comment
Please, Sign In to add comment