ai_schedule.New

From GMod Wiki

Jump to: navigation, search
Function
Syntax ai_schedule.New( String schedulename )
Where is this used?
Description:
Creates a schedule for use with scripted npcs
Returns: nil
Part of Library: ai_schedule
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Ai schedule.New]Ai schedule.New [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCreates a schedule, example is from garry's fighter NPC
Used onNewerServer.png
Code
 
  local schdChase = ai_schedule.New( "AIFighter Chase" ) //creates the schedule 
                                                         // used for this npc
 
   // Run away randomly (first objective in task)
   schdChase:EngTask( "TASK_GET_PATH_TO_RANDOM_NODE", 128 )
   schdChase:EngTask( "TASK_RUN_PATH", 0 )
   schdChase:EngTask( "TASK_WAIT_FOR_MOVEMENT", 0 )
   schdChase:AddTask( "PlaySequence", { Name = "cheer1", Speed = 1 } )
 
   // Find an enemy and run to it (second objectives in task)
   schdChase:AddTask( "FindEnemy", { Class = "player", Radius = 2000 } )
   schdChase:EngTask( "TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS", 0 )
   schdChase:EngTask( "TASK_RUN_PATH", 0 )
   schdChase:EngTask( "TASK_WAIT_FOR_MOVEMENT", 0 )
 
   // Shoot it (third objective in task)
   schdChase:EngTask( "TASK_STOP_MOVING", 0 )
   schdChase:EngTask( "TASK_FACE_ENEMY", 0 )
   schdChase:EngTask( "TASK_ANNOUNCE_ATTACK", 0 )
   schdChase:EngTask( "TASK_RANGE_ATTACK1", 0 )
   schdChase:EngTask( "TASK_RELOAD", 0 )
   //schedule is looped till you give it a different schedule
 
OutputNone


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox