• Using Enums as HoldType?
    2 replies, posted
Hey guys, is it possible to use ACT_ Enums directly as a holdtype animation reference? Something like self:SetWeaponHoldType(ACT_HL2MP_IDLE_FIST) in the SWEP lua?
See this: [url]http://luabin.foszor.com/code/gamemodes/base/entities/weapons/weapon_base/init.lua#56[/url] maybe you can do something with self.ActivityTranslate
Okay well i tried to use the Combofist addon and implement it in the cider base, my hands lua looks like that: [code] --[[ Name: "shared.lua". Product: "Cider (Roleplay)". --]] if (SERVER) then AddCSLuaFile("shared.lua"); resource.AddFile("models/weapons/w_fists_t.mdl") resource.AddFile("models/weapons/w_fists_t.vvd") resource.AddFile("models/weapons/w_fists_t.phy") resource.AddFile("models/weapons/w_fists_t.sw.vtx") resource.AddFile("models/weapons/w_fists_t.dx90.vtx") resource.AddFile("models/weapons/w_fists_t.dx80.vtx") resource.AddFile("models/weapons/v_punch.mdl") resource.AddFile("models/weapons/v_punch.vvd") resource.AddFile("models/weapons/v_punch.sw.vtx") resource.AddFile("models/weapons/v_punch.dx90.vtx") resource.AddFile("models/weapons/v_punch.dx80.vtx") resource.AddFile("sound/weapons/fists/hl2_slash1.wav") resource.AddFile("sound/weapons/fists/hl2_slash2.wav") end; -- Check if we're running on the client. if (CLIENT) then SWEP.PrintName = "Hands"; SWEP.Slot = 1; SWEP.SlotPos = 1; SWEP.DrawAmmo = false; SWEP.DrawCrosshair = true; if(file.Exists("../materials/VGUI/killicons/cf_killicon.vmt")) then killicon.Add("hl2_combo_fists","VGUI/killicons/cf_killicon",Color(255,255,255)); end end -- Define some shared variables. SWEP.Author = "Anonymous"; SWEP.Instructions = "Primary Punch, Secondary Knock"; SWEP.Contact = ""; SWEP.Purpose = "Punching And Knocking"; -- Set the view model and the world model to nil. SWEP.ViewModel = "models/weapons/v_punch.mdl"; SWEP.WorldModel = "models/weapons/w_fists_t.mdl"; -- Set the animation prefix and some other settings. SWEP.Spawnable = false; SWEP.AdminSpawnable = false; -- Set the primary fire settings. SWEP.Primary.Damage = 7.5; SWEP.Primary.ClipSize = -1; SWEP.Primary.DefaultClip = 0; SWEP.Primary.Automatic = false; SWEP.Primary.Ammo = ""; -- Set the secondary fire settings. SWEP.Secondary.ClipSize = -1; SWEP.Secondary.DefaultClip = 0; SWEP.Secondary.Automatic = false; SWEP.Secondary.Ammo = ""; -- Set the iron sight positions (pointless here). SWEP.IronSightPos = Vector(0, 0, 0); SWEP.IronSightAng = Vector(0, 0, 0); SWEP.NoIronSightFovChange = true; SWEP.NoIronSightAttack = true; SWEP.ComboActivated = false SWEP.Delay = 0.35 SWEP.Holdtype = "normal" -- Called when the SWEP is initialized. function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) self.HitHuman = { Sound("physics/body/body_medium_impact_hard1.wav"), Sound("physics/body/body_medium_impact_hard3.wav"), Sound("physics/body/body_medium_impact_hard5.wav") } self.HitElse = { Sound("physics/flesh/flesh_impact_bullet2.wav"), Sound("physics/flesh/flesh_impact_bullet4.wav"), Sound("physics/flesh/flesh_impact_bullet5.wav") } self.Swing = { Sound("weapons/fists/hl2_slash1.wav"), Sound("weapons/fists/hl2_slash2.wav") } end function SWEP:Precache() end function SWEP:PrimaryAttack() local trace = self.Owner:GetEyeTrace() local phys = trace.Entity:GetPhysicsObject() if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 70 then -- If we're in range if self.ComboActivated == true then self.ComboActivated = false else -- Otherwise if trace.Entity:IsPlayer() or trace.Entity:IsNPC() then -- And if we hit a player or an NPC self.Weapon:EmitSound(self.HitHuman[math.random(#self.HitHuman)]) else self.Weapon:EmitSound(self.HitElse[math.random(#self.HitElse)]) if phys:IsValid() then phys:ApplyForceOffset(self.Owner:GetAimVector():GetNormalized() * math.random(5000, 7000), trace.HitPos) else if SERVER then trace.Entity:SetVelocity(self.Owner:GetAimVector():GetNormalized() * math.random(5000, 7000)) end end end if SERVER then trace.Entity:TakeDamage(math.random(1, 4), self.Owner, self.Owner) -- Do less damage end self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- Display a normal animation self.Owner:ViewPunch(Angle(-1.5, -2.0, 0)) end else self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) self.Weapon:EmitSound(self.Swing[math.random(#self.Swing)], 100, math.random(95, 105)) self.Owner:ViewPunch(Angle(-1, -1.5, 0)) end self:SetNextPrimaryFire(CurTime() + self.Delay) self.Owner:SetAnimation( PLAYER_ATTACK1 ) end -- Called when the player attempts to secondary fire. function SWEP:SecondaryAttack() self.Weapon:SetNextSecondaryFire(CurTime() + 0.5); -- Get a trace from the owner's eyes. local trace = self.Owner:GetEyeTrace(); -- Check to see if the trace entity is valid and that it's a door. if (ValidEntity(trace.Entity) and (cider.entity.isDoor(trace.Entity) or trace.Entity:GetClass() == "prop_dynamic") ) then if (self.Owner:GetPos():Distance(trace.HitPos) <= 128) then self.Weapon:EmitSound("physics/wood/wood_crate_impact_hard2.wav"); self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER); end; end; end; [/code] Im especially having a problem with the holdtype, not even "normal" works, my goddamn character holds his hands like the pistol holdtype, although i have set the holdtype to normal, where the hands should just be beside him. what am i doing wrong? here's the isolated important part: [code] SWEP.Holdtype = "normal" -- Called when the SWEP is initialized. function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) [/code] edit: yeah just realized that alot of sounds etc are not needed cause they dont get used in the functions anyways, so i inserted the cleaner version now
Sorry, you need to Log In to post a reply to this thread.