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

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 2 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...