So i’m trying to make my SNPC chase a player then stop when they get nearby and begin to shoot them.
My current SNPCs are able to locate and run to the player, but when they are supposed to shoot they just sit there and play the animation. I’ve tried a shitload of things and none of them seem to work.
I prefer to use the default engine stuff because the Lua tasks seem much less functional (was it Avon who posted that thread showing the differences between scripted and engine tasks?).
Here’s what i have currently:
local enemy = self.Entity:GetEnemy() local sched = SCHED_IDLE_WANDER if enemy and enemy:IsValid() then if self.Entity:HasCondition( 21 ) then // COND_CAN_RANGE_ATTACK1 sched = SCHED_RANGE_ATTACK1 else sched = SCHED_CHASE_ENEMY end else self.Entity:UpdateEnemy( self.Entity:FindEnemy() ) end self.Entity:SetSchedule( sched )
I tried using StartSchedule instead of using SCHED_RANGE_ATTACK1 and it also didn’t work:
[lua]local shooter = ai_schedule.New( “AIFighter Chase” )
shooter:EngTask( “TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS”, 0 )
shooter:EngTask( “TASK_RUN_PATH”, 0 )
shooter:EngTask( “TASK_WAIT_FOR_MOVEMENT”, 0 )
// Shoot it
shooter:EngTask( “TASK_STOP_MOVING”, 0 )
shooter:EngTask( “TASK_FACE_ENEMY”, 0 )
shooter:EngTask( “TASK_ANNOUNCE_ATTACK”, 0 )
shooter:EngTask( “TASK_RANGE_ATTACK1”, 0 )[/lua]