AI Patrol: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(New page: == Introduction == Under construction. Written by Sotha. This article describes the ways how the mapper can get his/her AI's to move around in their map. Regardless of which method you us...)
 
Line 17: Line 17:
===Scripting===
===Scripting===
Scripting is a powerful tool to control all kinds of things. AI movement can be also controlled with scripting.
Scripting is a powerful tool to control all kinds of things. AI movement can be also controlled with scripting.
====Example AI control====
*Place an AI in your map. Name it ai.
*Place a path_corner in your map. Name it destination.
*Place a atdm:target_callscriptfunction. Name it call_ai_walk_script. Add spawnarg "call" "ai_walk_script"
*Place a switch in your map, which targets the above atdm:target_callscriptfunction.
*Create an ordinary textfile mymapname.script and place it in your /maps folder.
*Put the following info in the script file:
void ai_walk_script()
{
$ai.moveToEntity($destination);
}
When the player pulls the lever, the AI walks to the entity destination.
Mappers can also use $ai_name_here.moveToPosition("123,456,768"); and replace the coordinates where the AI should go. (Not tested.)
Other AI control commands exist, like $ai_name_here.turnToEntity(entityname);, which makes the AI to turn towards the specified entity.

Revision as of 09:03, 23 January 2011

Introduction

Under construction. Written by Sotha.

This article describes the ways how the mapper can get his/her AI's to move around in their map. Regardless of which method you use, you should understand basic Pathfinding. Read that article first.

There are several methods of getting your AI to move around your map.

  • Path_corners
  • Conversations
  • Scripting

Path_corners

The typical choice the mappers use path-corners. Using them is quite straight forward. Information how to set up path_corners is given here A - Z Beginner Full Guide Page 4 and here Path Nodes

Conversations

Conversation entities can be used to move AI too. See information in the Conversation article.

Scripting

Scripting is a powerful tool to control all kinds of things. AI movement can be also controlled with scripting.

Example AI control

  • Place an AI in your map. Name it ai.
  • Place a path_corner in your map. Name it destination.
  • Place a atdm:target_callscriptfunction. Name it call_ai_walk_script. Add spawnarg "call" "ai_walk_script"
  • Place a switch in your map, which targets the above atdm:target_callscriptfunction.
  • Create an ordinary textfile mymapname.script and place it in your /maps folder.
  • Put the following info in the script file:
void ai_walk_script() 
{
$ai.moveToEntity($destination);
}

When the player pulls the lever, the AI walks to the entity destination.

Mappers can also use $ai_name_here.moveToPosition("123,456,768"); and replace the coordinates where the AI should go. (Not tested.)

Other AI control commands exist, like $ai_name_here.turnToEntity(entityname);, which makes the AI to turn towards the specified entity.