Guest User

Untitled

a guest
May 27th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. .float shotgun_bullets_fired;
  2. .float shotgun_bullets_hit;
  3.  
  4. void W_Shotgun_Attack (void)
  5. {
  6. float sc;
  7. float bullets;
  8. float d;
  9. float f;
  10. float spread;
  11. local entity flash;
  12.  
  13. bullets = cvar("g_balance_shotgun_primary_bullets");
  14. d = cvar("g_balance_shotgun_primary_damage");
  15. f = cvar("g_balance_shotgun_primary_force");
  16. spread = cvar("g_balance_shotgun_primary_spread");
  17. self.shotgun_bullets_fired = self.shotgun_bullets_fired + bullets;
  18.  
  19. W_SetupShot (self, '25 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
  20. for (sc = 0;sc < bullets;sc = sc + 1)
  21. self.shotgun_bullets_hit = self.shotgun_bullets_hit + fireBullet (w_shotorg, w_shotdir, spread, d, f, WEP_SHOTGUN, sc < 3);
  22. if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
  23. self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_primary_ammo");
  24. if not(self.isbot)
  25. {
  26. string s;
  27. float e;
  28. e = self.shotgun_bullets_hit / self.shotgun_bullets_fired ;
  29. e = f * 100;
  30. e = rint(e);
  31. s = ftos(e);
  32. sprint(self, "Shotgun Hit%: ",s,"\n");
  33. }
  34.  
  35. pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_primary_ammo"));
  36.  
  37. // casing code
  38. if (cvar("g_casings") >= 1)
  39. SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
  40.  
  41. // muzzle flash for 1st person view
  42. flash = spawn();
  43. setorigin(flash, '53 5 0');
  44. setmodel(flash, "models/uziflash.md3"); // precision set below
  45. setattachment(flash, self.weaponentity, "bone01");
  46. flash.owner = self;
  47. flash.viewmodelforclient = self;
  48. flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
  49. flash.scale = 1.2;
  50. flash.think = SUB_Remove;
  51. flash.nextthink = time + 0.06;
  52. flash.angles_z = flash.v_angle_z + random() * 180;
  53. flash.alpha = 1;
  54. flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
  55.  
  56. }
  57.  
  58. void W_Shotgun_Attack2 (void)
  59. {
  60. float sc;
  61. float bullets;
  62. float d;
  63. float f;
  64. float spread;
  65. local entity flash;
  66.  
  67. bullets = cvar("g_balance_shotgun_secondary_bullets");
  68. d = cvar("g_balance_shotgun_secondary_damage");
  69. f = cvar("g_balance_shotgun_secondary_force");
  70. spread = cvar("g_balance_shotgun_secondary_spread");
  71.  
  72. W_SetupShot (self, '25 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
  73. for (sc = 0;sc < bullets;sc = sc + 1)
  74. fireBullet (w_shotorg, w_shotdir, spread, d, f, WEP_SHOTGUN | HITTYPE_SECONDARY, sc < 3);
  75. if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
  76. self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_secondary_ammo");
  77.  
  78. pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_secondary_ammo"));
  79.  
  80. // casing code
  81. if (cvar("g_casings") >= 1)
  82. SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
  83.  
  84. flash = spawn();
  85. setorigin(flash, '53 5 0');
  86. setmodel(flash, "models/uziflash.md3"); // precision set below
  87. setattachment(flash, self.weaponentity, "bone01");
  88. flash.owner = self;
  89. flash.viewmodelforclient = self;
  90. flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
  91. flash.scale = 1.2;
  92. flash.think = SUB_Remove;
  93. flash.nextthink = time + 0.06;
  94. flash.angles_z = flash.v_angle_z + random() * 180;
  95. flash.alpha = 1;
  96. flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
  97. }
  98.  
  99. // weapon frames
  100. void shotgun_fire2_03()
  101. {
  102. W_Shotgun_Attack2();
  103. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), w_ready);
  104. }
  105. void shotgun_fire2_02()
  106. {
  107. W_Shotgun_Attack2();
  108. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
  109. }
  110.  
  111. void spawnfunc_weapon_shotgun(); // defined in t_items.qc
  112.  
  113. float w_shotgun(float req)
  114. {
  115. if (req == WR_AIM)
  116. if(vlen(self.origin-self.enemy.origin)>200)
  117. self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
  118. else
  119. self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
  120. else if (req == WR_THINK)
  121. {
  122. if (self.BUTTON_ATCK)
  123. if (weapon_prepareattack(0, cvar("g_balance_shotgun_primary_refire")))
  124. {
  125. W_Shotgun_Attack();
  126. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), w_ready);
  127. }
  128. if (self.BUTTON_ATCK2)
  129. if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
  130. {
  131. W_Shotgun_Attack2();
  132. weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
  133. }
  134. }
  135. else if (req == WR_PRECACHE)
  136. {
  137. precache_model ("models/uziflash.md3");
  138. precache_model ("models/tracer.mdl");
  139. precache_model ("models/weapons/g_shotgun.md3");
  140. precache_model ("models/weapons/v_shotgun.md3");
  141. precache_model ("models/weapons/w_shotgun.zym");
  142. precache_sound ("misc/itempickup.wav");
  143. precache_sound ("weapons/ric1.wav");
  144. precache_sound ("weapons/ric2.wav");
  145. precache_sound ("weapons/ric3.wav");
  146. precache_sound ("weapons/shotgun_fire.wav");
  147. if (cvar("g_casings") >= 1)
  148. {
  149. precache_sound ("weapons/casings1.wav");
  150. precache_sound ("weapons/casings2.wav");
  151. precache_sound ("weapons/casings3.wav");
  152. precache_model ("models/casing_shell.mdl");
  153. }
  154. }
  155. else if (req == WR_SETUP)
  156. weapon_setup(WEP_SHOTGUN);
  157. else if (req == WR_CHECKAMMO1)
  158. return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
  159. else if (req == WR_CHECKAMMO2)
  160. return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
  161. else if (req == WR_SUICIDEMESSAGE)
  162. w_deathtypestring = "did the impossible";
  163. else if (req == WR_KILLMESSAGE)
  164. {
  165. w_deathtypestring = "was gunned by"; // unchecked: SECONDARY
  166. }
  167. return TRUE;
  168. };
Add Comment
Please, Sign In to add comment