Jump to content
The Dark Mod Forums

Easy Alert AI Recipe


Sotha

Recommended Posts

Often when mapper put relaxing AI in the map, they forget to give them tasks what to do if they get alerted.

 

Cardplayers will play cards. Then they get alerted and throw their cards to the floor. Once they relax again, they just go back to their chairs and sit with their swords in their hands. BAD! They should be doing something instead of sitting, the taffing slackers!

 

Here is an Easy Recipe how to get them to work if they are alerted!

 

1) Put cardplayers into the mission. Name them cardplayer1 and cardplayer2. Put them into the chairs with "sitting 1" spawnarg. Give them no targets. (You could examine the exact setup in the Ulysses: Protecting the Flock .pk4.)

 

2) Add a trigger_timer in your mission.

Name it "cardplayer_status_query_timer"

Give it "start_on 1", "wait 1". Now it is on all the time and trigger something once per second.

 

3) Add a atdm:target_callscriptfunction.

Name it "cardplayer_status_query"

Give it "call check_cardplayer_alert"

 

4) Have "cardplayer_status_query_timer" target "cardplayer_status_query"

 

5) make a script file for your map. Into it put the following script:

 

 

void check_cardplayer_alert()			//If cardplayers are alerted, give em new targets.
{

        float alert_lev = $cardplayer1.getAlertLevelOfOtherAI($cardplayer1);

        
        if ( alert_lev >= $cardplayer1.getFloatKey("alert_thresh3") )
        {
		sys.println("Giving cardplayers new targets");
		$cardplayer_status_query_timer.remove();

		$cardplayer1.addTarget($cardplayer1_watch_position);
		$cardplayer2.addTarget($cardplayer2_watch_position);		
        }

}

 

 

 

5) Add paths to your map, named "cardplayer1_watch_position" and "cardplayer2_watch_position" and put these to do the activity you would like the alerted AI to do.

 

6) You could make it more likely that the cardplayers get alerted: put an alarm entity into the room they are in. Or put a flee_point there, and make sure some AI are set to flee as soon as they see the player.

 

How the whole thing works?

The script shown is fired once per second by the entities set up in steps 2,3 and 4. It asks the cardplayer1 AI if his alert level is over "alert_thresh3", which is the alert level where the AI drops stuff (cards, bottles) and pulls their sword out.

 

If this happens, all the AI's playing cards (cardplayer1 AND 2) are given new targets "cardplayer1_watch_position". You need to add these paths to your map. The paths will send the alerted AI to do what you want, usually to a RIT network or the AI's could stand guard to a map choke point.

 

The script also removes the "cardplayer_status_query_timer", which means that it will no longer ask the AI about their alerts: it has already fulfilled it's need.

 

Enjoy!

 

Previously in the Easy Recipe series:

http://forums.thedarkmod.com/topic/16160-easy-bush-recipe/

http://forums.thedarkmod.com/topic/16159-easy-outdoors-recipe/

http://forums.thedarkmod.com/topic/14859-easy-vault-recipe/

http://forums.thedarkmod.com/topic/14469-quick-caverns-recipe/

  • Like 2

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

Can't alert idle path nodes do the same thing?

Possibly. I've not tested it. The path method, I think, would require the AI to get up occasionally, so that they get back to the crossroad where they choose idle only or alert only path.

 

I think one could use path_waitfortrigger instead of adding targets, but the alert catching would work the same way.

 

AI alert can also be catched with the objectives system, but this is unreliable (the objective does not always fire). I reported it a while ago.

 

The effect can be achieved with a multiple way, this is one of them I know that works.

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

Possibly. I've not tested it. The path method, I think, would require the AI to get up occasionally, so that they get back to the crossroad where they choose idle only or alert only path.

 

 

In your example above, you would put an "idle_only" spawnarg on the sitting path, and then "alert_only" (or whatever the correct syntax is) on the pathnodes you want them to use when alerted. As soon as they're alerted and calm back down, they'll ignore the sitting and go to the first "alert_only". The only thing I'm not sure of is whether alert_only kicks in at alert level 3 or 4. It might only kick in once they hit 4. It would be cool to have control over that.

 

For reference, the wiki:

 

There are now two new spawnargs, "alert_idle_only" and "idle_only" that can be set on path nodes. The nodes are then only chosen when the AI is in that state. For example, if you set a path_corner as "idle_only", then the AI will no longer go to that path node when it has been alerted. This allows the mapper to set a complete set of alternate patrols and actions for AI who have been alerted (like sending them to guard important areas).

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
       
      · 1 reply
    • 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...