AI behaviour depending on players actions (new version)

From The DarkMod Wiki
Revision as of 10:25, 17 March 2013 by Obsttorte (talk | contribs) (This article describes the steps needed for setting up missions, in which the ai is neutral to the player, but becomes hostile once he has done something forbidden.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Overview

If you want to create a mission, in which the ai is neutral to the player, but becomes hostile if he sees him doing something forbidden, like for example stealing an object or picking a lock, you can use the following approach. The setup is, as you'll se, pretty simple.

Scripting

The first steps to do is to download the script file here and put it in the script folder. In the same folder, create a file caled tdm_custom_scripts.script and put the following line in it

 #include "script/responseEffects.script"

Then go to your maps directory and create a file called mymapname.script', where mymapname is the name of your map. Put the following lines in it

 void main() {
   thread checkStatus();
 }

That's it. No moer scripting needed.

DarkRadiant

There are some steps that need to be performed in DarkRadiant to get things working.

- On every ai, set the spawnarg "scriptobject" "ai_stim" - On flashbombs, flashmines and mines change the scriptobject spawnarg by adding "_stim" at the end

 Example: the flashbomb uses the scriptobject playertools_flashbomb by default, which you must change to playertools_flashbomb_stim

- On every piece of loot and other objects which the player should not be allowed to take add the spawnarg "frob_action_script" "frobsLoot"

If you want to have areas where the player is allowed to be, and others where he isn't, you need to use the zone system (via info_location_settings and info_location / info_location_seperator). On the info_location entities belonging to areas where the player is allowed to be, add "call_on_entry" "setNeutralZone", on the entities belonging to not allowed areas, set "call_on_entry" "setHostileZone".

That's it. --Obsttorte (talk) 06:25, 17 March 2013 (EDT)