-- weapon_vape/cl_init.lua -- Defines common clientside code/defaults for Vape SWEP -- Vape SWEP by Swamp Onions - http://steamcommunity.com/id/swamponions/ include('shared.lua') function SWEP:DrawWorldModel() local ply = self:GetOwner() local vapeScale = self.VapeScale or 1 self:SetModelScale(vapeScale, 0) self:SetSubMaterial() if IsValid(ply) then local modelStr = ply:GetModel():sub(1,17) local isPony = modelStr=="models/ppm/player" or modelStr=="models/mlp/player" or modelStr=="models/cppm/playe" local bn = isPony and "LrigScull" or "ValveBiped.Bip01_R_Hand" if ply.vapeArmFullyUp then bn ="ValveBiped.Bip01_Head1" end local bon = ply:LookupBone(bn) or 0 local opos = self:GetPos() local oang = self:GetAngles() local bp,ba = ply:GetBonePosition(bon) if bp then opos = bp end if ba then oang = ba end if isPony then --pony position opos = opos + (oang:Forward()*19.4) + (oang:Right()*-4.36) + (oang:Up()*-2.5) oang:RotateAroundAxis(oang:Right(),80) oang:RotateAroundAxis(oang:Forward(),12) oang:RotateAroundAxis(oang:Up(),20) opos = opos + (oang:Up()*(2.3+((vapeScale-1)*-10.25))) else if ply.vapeArmFullyUp then --head position opos = opos + (oang:Forward()*0.74) + (oang:Right()*15) + (oang:Up()*2) oang:RotateAroundAxis(oang:Forward(),-100) oang:RotateAroundAxis(oang:Up(),100) opos = opos + (oang:Up()*(vapeScale-1)*-10.25) else --hand position oang:RotateAroundAxis(oang:Forward(),90) oang:RotateAroundAxis(oang:Right(),90) opos = opos + (oang:Forward()*2) + (oang:Up()*-4.5) + (oang:Right()*-2) oang:RotateAroundAxis(oang:Forward(),69) oang:RotateAroundAxis(oang:Up(),10) opos = opos + (oang:Up()*(vapeScale-1)*-10.25) if self:GetClass()=="weapon_vape_butterfly" then opos = opos + (oang:Up()*6) oang:RotateAroundAxis(oang:Right(),Lerp(ply.vapeArmUpAmt or 0,0,-360)) opos = opos + (oang:Up()*-6) end end end self:SetupBones() local mrt = self:GetBoneMatrix(0) if mrt then mrt:SetTranslation(opos) mrt:SetAngles(oang) self:SetBoneMatrix(0, mrt) end end self:DrawModel() end function SWEP:GetViewModelPosition(pos, ang) --mouth pos local vmpos1=self.VapeVMPos1 or Vector(18.5,-3.4,-3) local vmang1=self.VapeVMAng1 or Vector(170,-105,82) --hand pos local vmpos2=self.VapeVMPos2 or Vector(24,-8,-11.2) local vmang2=self.VapeVMAng2 or Vector(170,-108,132) if not LocalPlayer().vapeArmTime then LocalPlayer().vapeArmTime=0 end local lerp = math.Clamp((os.clock()-LocalPlayer().vapeArmTime)*3,0,1) if LocalPlayer().vapeArm then lerp = 1-lerp end local newpos = LerpVector(lerp,vmpos1,vmpos2) local newang = LerpVector(lerp,vmang1,vmang2) --I have a good reason for doing it like this newang = Angle(newang.x,newang.y,newang.z) pos,ang = LocalToWorld(newpos,newang,pos,ang) return pos, ang end