Jump to content
The Dark Mod Forums

Easy Alert AI Custom Behavior Recipe


Sotha

Recommended Posts

Sometimes the mapper wants the AI to do something special if they are alerted. That is, when the AI sees the player, instead of attacking, they run to do some special action and then come to fight. A typical thing that comes to mind is to run to the alarm switch and press it.

 

This behavior is done like this:

1) Make the setup and the script that asks the AI alert levels periodically. This was explained here:

http://forums.thedarkmod.com/topic/17157-easy-alert-ai-recipe/

 

2) Make a conversation that executes the task you want the AI to do. For example: run to an alarm button and press it. Or run to the hostages and hit them with a sword. Or launch the rockets.

 

3) Use this kind of script:

 

 

void check_ai_alert()			//check if ai gets alerted. If he does, stop asking alert status anymore and start custom behavior
{

        float alert_lev = $ai.getAlertLevelOfOtherAI($ai);
        
        if ( alert_lev >= $ai.getFloatKey("alert_thresh5") ) //start behavior if alert_thresh5 is exceeded. Alert level 5 is the state AI enters when it goes to combat.
        {
		sys.println("AI sees the player. Start custom behavior.");
		$ai_status_query_timer.remove(); //remove the trigger that runs the script periodically. It is not needed anymore.

//make AI blind and deaf. This is to make sure other AI and the player will not confuse it from achieving the task.
$ai.setAcuity("tact", 0);
$ai.setAcuity("vis", 0);
$ai.setAcuity("aud", 0);

$ai.setHealth(1); //You might want to make the AI easy to stop if the task is very dangerous for the player. The AI is, after all, turning his back and running.

$ai.setTeam(5); //put AI to neutral team so he isn't spooked by bodies, enemies, etc.

//Make AI unalerted. This is required to make the AI able to play conversations. Only idle AI can engage in convos.
$ai.setAlertLevel(0);

//This triggers atdm:target_startconversation, which starts your custom behavior. You basically make a conversation that is the behavior you want the AI to do when he sees the player.
sys.trigger($start_ai_activity);

//wait for a while. You must know how long the activity the AI doing is going to take. Once the time has passed, make AI back normal again.
//Alternatively, you could have the AI fire a script that sets him back to normal state when he finishes the task you've given him.
//It is probably good to have the AI reset after both by task completion AND by time period. That way the AI will always be reset, even if he fails to complete the task.
sys.wait(5); 

//Restore the abilities of the AI.
$ai.setAcuity("tact", 100);
$ai.setAcuity("vis", 100);
$ai.setAcuity("aud", 100);	

$ai.setHealth(100); //Give AI it's health back.

$ai.setTeam(2); //put AI back to the team he was originally in.

$ai.setAlertLevel(5); //make him alerted again.
        }

}

 

 

 

4) You will also need a second script that repeats the AI reset blocks and have that script called once the AI finishes his task.

 

Previously in the Easy Recipe series:

http://forums.thedarkmod.com/topic/17157-easy-alert-ai-recipe/

http://forums.thedar...sy-bush-recipe/

http://forums.thedar...utdoors-recipe/

http://forums.thedar...y-vault-recipe/

http://forums.thedar...caverns-recipe/

  • Like 4

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
    • Ansome

      Well then, it's been about a week since I released my first FM and I must say that I was very pleasantly surprised by its reception. I had expected half as much interest in my short little FM as I received and even less when it came to positive feedback, but I am glad that the aspects of my mission that I put the most heart into were often the most appreciated. It was also delightful to read plenty of honest criticism and helpful feedback, as I've already been given plenty of useful pointers on improving my brushwork, level design, and gameplay difficulty.
      I've gotten back into the groove of chipping away at my reading and game list, as well as the endless FM catalogue here, but I may very well try my hand at the 15th anniversary contest should it materialize. That is assuming my eyes are ready for a few more months of Dark Radiant's bright interface while burning the midnight oil, of course!
      · 4 replies
×
×
  • Create New...