• Entity gets all jittery and stupid when sequence is applied.
    0 replies, posted
So my "NPC" who is supposed to just stand there with a weapon out has decided, instead of doing the animation, which is just the Idle rifle carry act, he will have a seizure. I have no idea why he does this, but he just freaks out as if the animation is being called over and over again instantly. Here is the code, I know that isn't the right animation, but literally any of these poses don't work properly. AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") local modelselect = { "models/player/smitty/bf2_reg/st_sergeant/st_sergeant.mdl" } ENT.WeaponData = { // *** had to change the "combine_smg1" and the others to actual weapons that exist in vanilla gmod     ["bf2017_dc15s"] = {sound=Sound("Weapon_AR2.Single"),     damage=20,delay=0.11,cone=0.1775,range=750,type="AR2Tracer",act=ACT_RANGE_ATTACK_AR2,        actm=ACT_RUN_AIM_RIFLE,     gest=ACT_GESTURE_RANGE_ATTACK_AR2}, } ENT.Walk = ACT_RUN_AIM_RIFLE function ENT:GetGuns()     return {"bf2017_dc15s"} // *** end function ENT:GetActiveWeapon()     return self.Weapon end function ENT:Initialize()     self:SetModel(modelselect[math.random(1, #modelselect)])     self:SetHullType(HULL_HUMAN)     self:SetHullSizeNormal()     self:SetNPCState(NPC_STATE_SCRIPT)     self:SetSolid(SOLID_BBOX)     self:SetInitializeCapabilities()     self:SetUseType(SIMPLE_USE) -- Makes the ENT.Use hook only get called once at every use.     self:DropToFloor()     self:SetMaxYawSpeed(35)     for k, v in pairs(player.GetAll()) do         self:SetTarget(v)     end     local gun = table.Random(self:GetGuns())         if type(gun) == "table" then             gun = gun[1]         end     self:GiveWeapon(gun)     if self.WeaponData[gun] then         self.Weapon.NPCShoot_Primary = nil     end end function ENT:Think()     self:SetSequence(ACT_GESTURE_RANGE_ATTACK1)         self:NextThink( 6 ) -- Set the next think for the serverside hook to be the next frame/tick     end end function ENT:SetInitializeCapabilities()     self:CapabilitiesAdd(bit.bor(CAP_ANIMATEDFACE))     self:CapabilitiesAdd(bit.bor(CAP_TURN_HEAD))     self:CapabilitiesAdd(bit.bor(CAP_MOVE_GROUND))     self:CapabilitiesAdd(bit.bor(CAP_OPEN_DOORS))     self:CapabilitiesAdd(bit.bor(CAP_AUTO_DOORS))     self:CapabilitiesAdd(bit.bor(CAP_MOVE_JUMP)) end util.AddNetworkString("Smirk") function ENT:AcceptInput(input, activator, caller)     if input == "Use" then         net.Start("Smirk")         net.Send(caller)     end end function ENT:SelectSchedule()     local MyNearbyTargets = ents.FindInSphere(self:GetPos(),150)     if (!MyNearbyTargets) then return end     for k,v in pairs(MyNearbyTargets) do         if v:IsPlayer() then             self:SetSchedule(SCHED_TARGET_FACE)         end     end end function ENT:GiveWeapon(class)     local ent = self     if !IsValid(ent) then return end     if ent.Weapon then ent.Weapon:Remove() end     local att = "anim_attachment_RH"     local shootpos = ent:GetAttachment(ent:LookupAttachment(att))          local wep = ents.Create(class)     wep:SetOwner(ent)     wep:SetPos(shootpos.Pos)     --wep:SetAngles(ang)     wep:Spawn()     wep.DontPickUp = true     wep:SetSolid(SOLID_NONE)              wep:SetParent(ent)     wep:Fire("setparentattachment", "anim_attachment_RH")     wep:AddEffects(EF_BONEMERGE)     wep:SetAngles(ent:GetForward():Angle())              self.Weapon = wep // *** end function ENT:GetActiveWeapon()     return self.Weapon end hook.Add("PlayerCanPickupWeapon","NoPickUpGun",function(ply,ent)     return not ent.DontPickUp end)
Sorry, you need to Log In to post a reply to this thread.