• Swep functions to NPC
    1 replies, posted
I'm currently working on a combine guard SNPC and require information on how to turn a swep function from the strider cannon into a an NPC function... I'm no genius on functions, but this is what i've gathered... [code] function SWEP:ShootCannon() if not self.Charging then return end if not self.Weapon or not self.Weapon:IsValid() then return end if not self.Owner or not self.Owner:Alive() then return end local PlayerPos = self.Owner:GetShootPos() local tr = self.Owner:GetEyeTrace() local dist = (tr.HitPos - PlayerPos):Length() local delay = dist/8000 self:TakeSecondaryAmmo(1) self.Weapon:EmitSound(self.Cannon.ShootSound) local fx = EffectData() fx:SetEntity(self.Owner) fx:SetOrigin(tr.HitPos) fx:SetAttachment(1) util.Effect("stridcan_fire",fx) util.Effect("stridcan_mzzlflash",fx) --play animations self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) self.Owner:MuzzleFlash() self.Owner:SetAnimation(PLAYER_ATTACK1) --apply recoil self.Owner:ViewPunch( Angle(math.Rand(-0.2,-0.1)*self.Cannon.Recoil,math.Rand(-0.1,0.1)*self.Cannon.Recoil, 0)) timer.Simple(delay,self.Disintegrate,self,tr) self.Charging = false end [/code]
No, don't just copy paste code from other addons like the beta swep pack to a single half working entity and call it your work. This is an easy function, build it yourself and if you can't do that start with something simpler than an SNPC.
Sorry, you need to Log In to post a reply to this thread.