Considering this is already a player model you don't really have to recompile it to be an NPC model, just make the ACTs on the npc code match that of the model
I tried using ENT:SetSequence, ENT:SetMovementSequence, ENT:ResetSequence, ENT:SetMovementActicity but for some reason most of them did nothing.
ENT:SetSequence starts the walking animation but it ends midway then stops.
Do you have an idea why ?
Those functions are for NPCs and are superseded once used in an npc. What you need is StartActivity. Have a look here for an example of how to get it rolling: https://wiki.garrysmod.com/page/NextBot_NPC_Creation
I also tried creating a custom schedule but that doesn't seem to work either. I can set it to play the correct animation but it still doesn't move. This is the server-side code:
AddCSLuaFile('cl_init.lua')
AddCSLuaFile('shared.lua')
include('shared.lua')
resource.AddFile("materials/entities/drg_scp178_1.png")
--[[local schdWander = ai_schedule.New("SCP-178-1 Wander")
schdWander:EngTask("TASK_GET_PATH_TO_RANDOM_NODE", 128)
schdWander:EngTask("TASK_RUN_PATH", 0)
schdWander:EngTask("TASK_WAIT_FOR_MOVEMENT", 0)
schdWander:AddTask("PlaySequence", {Name = "walk_all", Speed = 2})
schdWander:AddTask("PlaySequence", {Name = "idle", Speed = 1})]]
function ENT:Initialize()
self:SetModel("models/jq/178e/scp178_e_unity_p.mdl")
--self:SetModel("models/Kleiner.mdl")
if GetConVar("scp178_1_physics"):GetBool() then
self:SetHullType(HULL_LARGE)
self:SetHullSizeNormal()
self:SetSolid(SOLID_BBOX)
end
self:SetMoveType(MOVETYPE_STEP)
self:CapabilitiesAdd(CAP_MOVE_GROUND)
self:SetCollisionGroup(COLLISION_GROUP_WORLD)
self:SetHealth(1)
self:SetSchedule(SCHED_IDLE_WANDER)
end
function ENT:Think()
local focusRange = ents.FindInSphere(self:GetPos(), GetConVar("scp178_1_detection_range"):GetInt())
for _, ent in pairs(focusRange) do
if CanFocus(ent) then
Focus(ent)
end
end
local killRange = ents.FindInSphere(self:GetPos() + Vector(0, 0, 52), GetConVar("scp178_1_attack_range"):GetInt())
for _, ent in pairs(killRange) do
if CanAttack(ent) then
Attack(ent, self)
end
end
end
--[[function ENT:SelectSchedule()
self:StartSchedule(schdWander)
end]]
function ENT:OnTakeDamage(dmgInfo)
local ent = dmgInfo:GetAttacker()
if not IgnoreEnt(ent) and
ent:GetNWBool("Wearing178") then
Focus(ent)
end
end
function IgnoreEnt(ent)
return not ent:IsPlayer() or
GetConVar("ai_ignoreplayers"):GetBool()
end
function CanFocus(ent)
return not IgnoreEnt(ent) and
(ent:GetNWBool("TargetedBy178") or
GetConVar("scp178_1_attack_all"):GetBool())
end
function CanAttack(ent)
return not IgnoreEnt(ent) and
(ent:GetNWBool("Wearing178") or
ent:GetNWBool("TargetedBy178") or
GetConVar("scp178_1_attack_all"):GetBool())
end
function Focus(ent)
local scps = ents.FindInSphere(ent:GetPos(), GetConVar("scp178_1_help_range"):GetInt())
ent:SetNWBool("TargetedBy178", true)
for _, scp in pairs(scps) do
if scp:GetClass() == "drg_scp178_1" then
scp:SetTarget(ent)
scp:SetSchedule(SCHED_TARGET_CHASE)
end
end
end
function Attack(ent, attacker)
if ent:IsPlayer() and not ent:Alive() then
return
end
if not ent:GetNWBool("Cooldown178") then
ent:SetNWBool("TargetedBy178", true)
attacker:EmitSound("scp178/damage.ogg")
ent:TakeDamage(GetConVar("scp178_1_damage"):GetInt(), attacker)
ent:SetNWBool("Cooldown178", true)
ent:ViewPunch(Angle(math.random(0, 20), math.random(0, 20), math.random(-10, 10)))
timer.Simple("0.25", function()
ent:SetNWBool("Cooldown178", false)
end)
end
end
Sorry, you need to Log In to post a reply to this thread.