CapsAdmin

Untitled

Mar 8th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.31 KB | None | 0 0
  1. easylua.StartWeapon("blarghhh2")
  2.  
  3. SWEP.Base = "weapon_base"
  4. SWEP.PrintName = "sword"
  5.  
  6. SWEP.Slot = 0
  7. SWEP.SlotPos = 0
  8.  
  9. SWEP.DrawWeaponInfoBox=false
  10. SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
  11. SWEP.ViewModelFOV = 54
  12.  
  13. SWEP.Primary.ClipSize = -1
  14. SWEP.Primary.DefaultClip = -1
  15. SWEP.Primary.Automatic = true
  16. SWEP.Primary.Ammo = "none"
  17.  
  18. SWEP.Secondary.ClipSize = -1
  19. SWEP.Secondary.DefaultClip = -1
  20. SWEP.Secondary.Automatic = false
  21. SWEP.Secondary.Ammo = "none"
  22.  
  23. SWEP.SwingSound = "Weapon_Crowbar.Single"
  24. SWEP.HitSound = "Weapon_Crowbar.Melee_Hit"
  25.  
  26. SWEP.HoldType="melee"
  27.  
  28. SWEP.Delay=0.4
  29. SWEP.Range=75
  30. SWEP.Damage=25
  31.  
  32. function SWEP:Initialize()
  33.     self:SetWeaponHoldType(self.HoldType)
  34. end
  35.  
  36. function SWEP:PrimaryAttack()
  37.  
  38.     local owner = self.Owner
  39.     local forward = owner:GetAimVector()
  40.    
  41.     self:SetNextPrimaryFire(CurTime() + self.Delay)
  42.     self.Owner:SetAnimation(PLAYER_ATTACK1)
  43.    
  44.     local trace = {}
  45.         trace.start = owner:EyePos()
  46.         trace.endpos = owner:EyePos() + (forward * self.Range)
  47.         trace.filter = {owner}
  48.        
  49.         trace.mins = Vector(1, 1, 1) * -15
  50.         trace.maxs = Vector(1, 1, 1) * 15  
  51.     trace = util.TraceHull(trace)
  52.        
  53.     if trace.Hit then
  54.                
  55.         self:SendWeaponAnim(ACT_VM_HITCENTER)
  56.         self:EmitSound(self.HitSound)
  57.        
  58.         local ent = trace.Entity
  59.        
  60.         if SERVER and not trace.HitWorld and ent:IsValid() then
  61.        
  62.             local params = DamageInfo()
  63.                 params:SetAttacker(owner)
  64.                 params:SetInflictor(self)
  65.                 params:SetDamage(self.Damage)
  66.                 params:SetDamageForce(forward * self.Damage * 700)
  67.                 params:SetDamagePosition(trace.HitPos)
  68.                 params:SetDamageType(DMG_SLASH)
  69.             ent:TakeDamageInfo(params)
  70.            
  71.             if ent:GetPhysicsObject():IsValid() then
  72.                 ent:SetPhysicsAttacker(self.Owner)
  73.             end
  74.         end
  75.        
  76.         if trace.MatType ~= MAT_GRATE then
  77.             local params = {}
  78.            
  79.                 params.Num = 1
  80.                 params.Src = owner:EyePos()
  81.                 params.Dir = owner:GetAimVector()
  82.                 params.Spread = Vector(0,0,0)
  83.                 params.Tracer = 0
  84.                 params.Force = 0
  85.                 params.Damage = 0
  86.                 params.Callback = function() return {damage = false} end
  87.                
  88.             owner:FireBullets(B)
  89.         end
  90.     else
  91.         self:SendWeaponAnim(ACT_VM_MISSCENTER)
  92.         self:EmitSound(self.SwingSound)
  93.     end    
  94. end
  95.  
  96. function SWEP:SecondaryAttack()
  97.     return false
  98. end
  99.  
  100. function SWEP:DrawWeaponSelection(x,y,w,t,a)
  101.     draw.SimpleText("c", "TitleFont2", x + w / 2, y, Color(255, 255, 255, a), TEXT_ALIGN_CENTER)
  102. end
  103.  
  104. function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha)
  105.     surface.SetDrawColor( color_transparent )
  106.     surface.SetTextColor( 255, 220, 0, alpha )
  107.     surface.SetFont( "TitleFont2" )
  108.     local w, h = surface.GetTextSize( "c" )
  109.  
  110.     surface.SetTextPos( x + ( wide / 2 ) - ( w / 2 ), y + ( tall / 2 ) - ( h / 2 ) )
  111.     surface.DrawText( "c" )
  112. end
  113.  
  114. function SWEP:GetCapabilities()
  115.     return bit.bor(CAP_WEAPON_MELEE_ATTACK1 , CAP_INNATE_MELEE_ATTACK1)
  116. end
  117.  
  118. function SWEP:SetupWeaponHoldTypeForAI( t )
  119.  
  120.     self.ActivityTranslateAI = {}
  121.     self.ActivityTranslateAI [ ACT_STAND ] = ACT_IDLE_MELEE
  122.     self.ActivityTranslateAI [ ACT_IDLE_ANGRY ] = ACT_IDLE_ANGRY_MELEE
  123.  
  124.     self.ActivityTranslateAI [ ACT_MP_RUN ] = ACT_HL2MP_RUN_MELEE
  125.     self.ActivityTranslateAI [ ACT_MP_CROUCHWALK ] = ACT_HL2MP_WALK_CROUCH_MELEE
  126.  
  127.     self.ActivityTranslateAI [ ACT_MELEE_ATTACK1 ] = ACT_MELEE_ATTACK1
  128.  
  129.     self.ActivityTranslateAI [ ACT_RELOAD ] = ACT_RELOAD
  130. end
  131.  
  132. easylua.EndWeapon()
Advertisement
Add Comment
Please, Sign In to add comment