• Antlion SNPCs will only walk, and won't jump around like normal npc_antlions.
    0 replies, posted
Hi, for awhile I've been trying to get an Antlion SNPC to follow the player. It can do this pretty well, but it will only follow the player along the ground, and will almost never fly up or down a ledge like a normal npc_antlion. I've tested this on several, well noded maps that include info_node_hints, and on all these maps ( like gm_construct ) regular Antlions will navigate them perfectly by jumping and flying around, but my SNPCs always have to walk to their destination. I say almost, because I have a theory about what's going on. The places my SNPCs will jump/fly down from are very short distances, short enough that they won't injure themselves. These are the same nodes that I've noticed npc_metropolice will also feel comfortable jumping down from. Basically, how can I make my SNPCs stop ignoring nodes that would otherwise injure them if they were to jump from them? Here's the code for the init.lua: [lua] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') // //Any custom schedules go below here: // local huntPly = ai_schedule.New( "Ant Rundown" ) //creates the schedule used for this npc huntPly:AddTask( "ChoosePlayer", 0 ) huntPly:EngTask( "TASK_GET_PATH_TO_TARGET", 0 ) huntPly:EngTask( "TASK_MOVE_TO_TARGET_RANGE", 100 ) huntPly:EngTask( "TASK_WAIT_FOR_MOVEMENT", 0 ) // //SNPC initialization and logic go here: // function ENT:Initialize() self:SetModel( "models/AntLion.mdl" ) self:SetSkin( math.Rand( 0, self:SkinCount() ) ) self:SetHullType( HULL_MEDIUM ); self:SetHullSizeNormal(); self:SetSolid( SOLID_BBOX ) self:SetMoveType( MOVETYPE_STEP ) self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_MOVE_JUMP ) self:SetMaxYawSpeed( 5000 ) self:SetHealth(100) end function ENT:OnTakeDamage(dmg) print( "That hurt!" ) end //Sets the schedule function ENT:SelectSchedule() self:StartSchedule( huntPly ) end //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Custom getters and mutators go here! //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // //Getter functions: // function NPC_FindEnemy( npc, currEnemy ) local players = player.GetAll() local entPos = npc:GetPos() local nearestPly = players[1] for i = 1, table.Count( players ) do if entPos:Distance( players[i]:GetPos() ) < entPos:Distance( nearestPly:GetPos() ) then nearestPly = players[i] end end return nearestPly end //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Custom tasks go below here! //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Choose player task: function ENT:TaskStart_ChoosePlayer( data ) //this task gets run every time CHOOSEPLAYER starts. print( "Choosing player to hunt down." ) self:SetEnemy( NPC_FindEnemy( self, self:GetEnemy() ) ) self:SetTarget( self:GetEnemy() ) end function ENT:Task_ChoosePlayer( data ) //this task gets run every think. print( "Thinking about choosing player to hunt down." ) self:TaskComplete() end [/lua]
Sorry, you need to Log In to post a reply to this thread.