I am currently working on a Nextbot which should walk around Normally but start to Panic when injured.
So ive got everything working besides the RunBehaviour.
Heres the Code:
function ENT:RunBehaviour()
local function PanicCheck()
if panic == true then
panic = false
local pos = self:FindSpot( "random", { type = 'hiding', radius = 10000 } )
print ("triggered")
self:StartActivity( ACT_RUN ) -- run anim
self.loco:SetDesiredSpeed( 200 ) -- run speed
self:EmitSound(soundlistm[math.random(#soundlistm)])
self:MoveToPos( pos ) -- move to position (yielding)
self:PlaySequenceAndWait( "fear_reaction" ) -- play a fear animation
self:StartActivity( ACT_IDLE ) -- when we finished, go into the idle anim
end
end
while ( true ) do
function self:Think()
PanicCheck()
end
self:StartActivity(6) -- walk anims
self.loco:SetDesiredSpeed( math.random(50, 90) ) -- walk speeds
self.loco:SetDesiredSpeed( math.random(50, 90) ) -- walk speeds
self.loco:SetStepHeight( self.StepHeight )
self.loco:SetJumpHeight( 40 )
self.loco:SetDeathDropHeight( self.StepHeight )
self:WalkTo( {pos = self:FindNewDestination()} ) -- walk to a random place
self:StartActivity( ACT_IDLE )
coroutine.wait(3)
self:StartActivity( ACT_WALK )
end
end
Now I´m getting this error:
[ERROR] gamemodes/base/entities/entities/base_nextbot/sv_nextbot.lua:325: attempt to yield across C-call boundary
1. yield - [C]:-1
2. MoveToPos - gamemodes/base/entities/entities/base_nextbot/sv_nextbot.lua:325
3. PanicCheck - addons/p3nextbot/lua/entities/npc_p3.lua:120
4. unknown - addons/p3nextbot/lua/entities/npc_p3.lua:127
So im currently trying to figure out how to make the Bot do what i want it to do but I Really cant seem to find it out on my own so im asking for help,
Thanks.
Sorry, you need to Log In to post a reply to this thread.