Guest User

Untitled

a guest
Jan 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. --[[
  2. Name: "sh_auto.lua".
  3. Product: "Cider Two".
  4. --]]
  5.  
  6. if (SERVER) then
  7. AddCSLuaFile("sh_auto.lua");
  8.  
  9. resource.AddFile("materials/models/weapons/baseball_bat/metal_bat.vtf");
  10. resource.AddFile("materials/models/weapons/baseball_bat/metal_bat.vmt");
  11.  
  12. for k, v in pairs( _file.Find("../models/weapons/v_basball.*") ) do
  13. resource.AddFile("models/weapons/"..v);
  14. end;
  15.  
  16. for k, v in pairs( _file.Find("../models/weapons/w_basball.*") ) do
  17. resource.AddFile("models/weapons/"..v);
  18. end;
  19. end;
  20.  
  21. if (CLIENT) then
  22. SWEP.Slot = 0;
  23. SWEP.SlotPos = 5;
  24. SWEP.DrawAmmo = false;
  25. SWEP.PrintName = "Baseball Bat";
  26. SWEP.DrawCrosshair = true;
  27. end
  28.  
  29. SWEP.Instructions = "Primary Fire: Whack.";
  30. SWEP.Purpose = "Beating the shit out the infected folk.";
  31. SWEP.Contact = "";
  32. SWEP.Author = "kurozael";
  33.  
  34. SWEP.WorldModel = "models/weapons/w_basball.mdl";
  35. SWEP.ViewModel = "models/weapons/v_basball.mdl";
  36. SWEP.HoldType = "melee";
  37.  
  38. SWEP.AdminSpawnable = false;
  39. SWEP.Spawnable = false;
  40.  
  41. SWEP.Primary.DefaultClip = 0;
  42. SWEP.Primary.Automatic = false;
  43. SWEP.Primary.ClipSize = -1;
  44. SWEP.Primary.Damage = 10;
  45. SWEP.Primary.Delay = 1;
  46. SWEP.Primary.Ammo = "";
  47.  
  48. SWEP.Secondary.NeverRaised = true;
  49. SWEP.Secondary.DefaultClip = 0;
  50. SWEP.Secondary.Automatic = false;
  51. SWEP.Secondary.ClipSize = -1;
  52. SWEP.Secondary.Delay = 1;
  53. SWEP.Secondary.Ammo = "";
  54.  
  55. SWEP.NoIronSightFovChange = true;
  56. SWEP.NoIronSightAttack = true;
  57. SWEP.IronSightPos = Vector(0, 0, 0);
  58. SWEP.IronSightAng = Vector(0, 0, 0);
  59.  
  60. -- Called when the SWEP is deployed.
  61. function SWEP:Deploy()
  62. self:SendWeaponAnim(ACT_VM_DRAW);
  63. end;
  64.  
  65. -- Called when the SWEP is holstered.
  66. function SWEP:Holster(switchingTo)
  67. self:SendWeaponAnim(ACT_VM_HOLSTER);
  68.  
  69. return true;
  70. end;
  71.  
  72. -- Called when the SWEP is initialized.
  73. function SWEP:Initialize()
  74. self:SetWeaponHoldType(self.HoldType);
  75. end;
  76.  
  77. -- A function to do the SWEP's hit effects.
  78. function SWEP:DoHitEffects()
  79. local trace = self.Owner:GetEyeTraceNoCursor();
  80.  
  81. if ( ( (trace.Hit or trace.HitWorld) and self.Owner:GetPos():Distance(trace.HitPos) <= 96 ) ) then
  82. self:SendWeaponAnim(ACT_VM_HITCENTER);
  83. self:EmitSound("weapons/crossbow/hitbod2.wav");
  84. else
  85. self:SendWeaponAnim(ACT_VM_MISSCENTER);
  86. self:EmitSound("weapons/stunstick/stunstick_swing"..math.random(1, 2)..".wav");
  87. end;
  88. end;
  89.  
  90. -- A function to do the SWEP's animations.
  91. function SWEP:DoAnimations(idle)
  92. if (!idle) then
  93. self.Owner:SetAnimation(PLAYER_ATTACK1);
  94. end;
  95. end;
  96.  
  97. -- Called when the player attempts to primary fire.
  98. function SWEP:PrimaryAttack()
  99. self:SetNextPrimaryFire(CurTime() + self.Primary.Delay);
  100. self:SetNextSecondaryFire(CurTime() + self.Primary.Delay);
  101.  
  102. self:DoAnimations(); self:DoHitEffects();
  103.  
  104. if (SERVER) then
  105. if (self.Owner.LagCompensation) then
  106. self.Owner:LagCompensation(true);
  107. end;
  108.  
  109. local trace = self.Owner:GetEyeTraceNoCursor();
  110.  
  111. if (self.Owner:GetShootPos():Distance(trace.HitPos) <= 96) then
  112. if ( IsValid(trace.Entity) ) then
  113. local player = openAura.entity:GetPlayer(trace.Entity);
  114. local strength = openAura.attributes:Fraction(self.Owner, ATB_STRENGTH, 10, 5);
  115.  
  116. if ( trace.Entity:IsPlayer() or trace.Entity:IsNPC() ) then
  117. local normal = ( trace.Entity:GetPos() - self.Owner:GetPos() ):Normalize();
  118. local push = 128 * normal;
  119.  
  120. trace.Entity:SetVelocity(push);
  121.  
  122. timer.Simple(FrameTime() * 0.5, function()
  123. if ( IsValid(trace.Entity) ) then
  124. trace.Entity:TakeDamageInfo( openAura:FakeDamageInfo(self.Primary.Damage + strength, self, self, trace.HitPos, DMG_CLUB, 2) );
  125. end;
  126. end);
  127.  
  128. self.Owner:ProgressAttribute(ATB_STRENGTH, 1, true);
  129. else
  130. local physicsObject = trace.Entity:GetPhysicsObject();
  131.  
  132. if ( IsValid(physicsObject) ) then
  133. physicsObject:ApplyForceOffset(self.Owner:GetAimVector() * math.max(math.min(physicsObject:GetMass(), 100) * 10, 1024), trace.HitPos);
  134.  
  135. if (!player) then
  136. timer.Simple(FrameTime() * 0.5, function()
  137. if ( IsValid(trace.Entity) ) then
  138. trace.Entity:TakeDamageInfo( openAura:FakeDamageInfo( (self.Primary.Damage / 2) + strength, self, self.Owner, trace.HitPos, DMG_CLUB, 2 ) );
  139. end;
  140. end);
  141.  
  142. self.Owner:ProgressAttribute(ATB_STRENGTH, 0.5, true);
  143. else
  144. timer.Simple(FrameTime() * 0.5, function()
  145. if ( IsValid(trace.Entity) ) then
  146. trace.Entity:TakeDamageInfo( openAura:FakeDamageInfo(self.Primary.Damage + strength, self, self.Owner, trace.HitPos, DMG_CLUB, 2) );
  147. end;
  148. end);
  149.  
  150. self.Owner:ProgressAttribute(ATB_STRENGTH, 1, true);
  151. end;
  152. end;
  153. end;
  154. else
  155. self.Owner:FireBullets( {
  156. Spread = Vector(0, 0, 0),
  157. Damage = 1,
  158. Tracer = 0,
  159. Force = 1,
  160. Num = 1,
  161. Src = self.Owner:GetShootPos(),
  162. Dir = self.Owner:GetAimVector()
  163. } );
  164. end;
  165. end;
  166.  
  167. if (self.Owner.LagCompensation) then
  168. self.Owner:LagCompensation(false);
  169. end;
  170. end;
  171. end;
  172.  
  173. -- Called when the player attempts to secondary fire.
  174. function SWEP:SecondaryAttack() end;
Add Comment
Please, Sign In to add comment