So, I've been working for around an hour trying to get this SNPC to move from one position to another.
It seems as if that NPC:SetLastPosition() Is not working on SNPCS.
Code:
[code]AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
ENT.bGoingToProp = false
function ENT:Initialize()
self:SetModel( "models/Combine_Soldier.mdl" )
self:SetSkin(1)
self:SetHullType( HULL_HUMAN )
self:SetHullSizeNormal();
self:SetNPCState( NPC_STATE_SCRIPT )
self:SetHealth( 100 )
self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )
self:CapabilitiesAdd( bit.bor(CAP_MOVE_GROUND , CAP_OPEN_DOORS , CAP_SQUAD , CAP_ANIMATEDFACE , CAP_USE_WEAPONS , CAP_SQUAD , CAP_DUCK , CAP_MOVE_SHOOT , CAP_TURN_HEAD , CAP_USE_SHOT_REGULATOR , CAP_AIM_GUN ))
self:SetMaxYawSpeed( 5000 )
self:Give("weapon_ar2")
self:SetUseType( SIMPLE_USE )
self:SetEnemy(NULL)
self.bGoingToProp = false
end
function ENT:AcceptInput( Name, Activator, Caller )
if Name == "Use" and Caller:IsSuperAdmin() then
self:SetPos(Vector(0,0,-12250)) -- Basicly resets the entity to the middle of the gm_flatgrass
self:DropToFloor()
local effectData = EffectData()
effectData:SetEntity(self)
util.Effect("propspawn", effectData)
local effectData = EffectData()
effectData:SetEntity(self)
effectData:SetOrigin(self:GetPos()+Vector(0, 0, 50))
util.Effect("balloon_pop", effectData)
self.bGoingToProp = false
end
end
function ENT:Think()
local balls = ents.FindByClass("sent_ball")
local target = balls[math.random(1,#balls)]
if !IsValid(target) then
self:NextThink( CurTime() + 20 )
return;
end
if self.bGoingToProp == false then
Msg("Janitor - Acquired Target")
self:SetLastPosition( target:GetPos() )
self:SetSchedule( SCHED_FORCED_GO_RUN )
self:SetEyeTarget(target:GetPos())
self.bGoingToProp = true
end
self:NextThink( CurTime() + 10 )
end[/code]
When there is a sent_ball active it does print Janitor - Acquired Target in console, but thats pretty much it. the SNPC refuses to move AT ALL.
If anyone has any idea of what is wrong or on how I can improve my code could you please speak up. :).
Thanks! :wink:
Bump, Sorry I still need help with this, cant find any info at all.
I too am having very similar issues, particularly when my snpc model is humanoid and supposed to wield weapons. The most I can get it to do is melee bash me, without a weapon. Creatures like headcrabs or antlions behave just fine, and I'm unsure why.
Sorry, you need to Log In to post a reply to this thread.