Jump to content
The Dark Mod Forums

AI don't threaten player until he does something


Springheel

Recommended Posts

I know this topic has come up on wishlists from time to time, and I know some mappers have managed to cobble together versions for their maps. Couldn't figure out what term to search for, however, so I couldn't find any details.

 

How hard is it, currently, to make the AI in a location neutral to the player, and then change that relationship if the player does something aggressive? I'm working on a map that has a public area that the player should theoretically be able to explore without being challenged. But I want him to be considered an enemy if he does either of the following:

 

-- takes any loot

-- passes into one of three trigger areas

 

Since the player won't have any of his equipment, attacking or picking locks isn't an issue.

 

Anyone with experience with this, can you give me some insight into how difficult it is to do, and maybe point me towards some thread or wiki post with info on how to do it?

Link to comment
Share on other sites

Well, Im sure some guys who actually know what they are talking about will answer soon, but one possibility which I used in my own map was the set relations entity (http://wiki.thedarkm...s_%28Editing%29):

 

a ) Neutral NPCs would change to a hostile team if you unlocked (triggered) a certain door next to them (would work the same if you trigger it from a simple or timed trigger);

 

b ) I also wanted certain characters, when fleeing, to actually alert those same neutral NPCs and send them your way (they are friends inside the story, but from different teams); so they also activate the set relations entity when they pass through a trigger (knowing where they had to pass through when fleeing outside), making the NPCs friendly to them (automaticly behaving as allies from then on, answering to the call, etc).

 

It was pretty limited, I remember Sotha (and possibly Fieldmedic) discussing a much broader and complex way to set this up...

 

PS: In this situation, the sound responses will be often highly inconsistent (they'll shout things like "Aha! There you are!" and such inconvinient barks when you suddenly become "visible" to them).

Edited by RPGista
Link to comment
Share on other sites

Yes, you might find some detail in the Reap as you Sow WIP thread (if there was one)... or the map itself...

 

I'll see what I can find...

 

Edit: Argh. It must be buried in the Newbie DR thread... Plus some of it might be lost in the Beta testing forum

that was deleted :(

Edited by nbohr1more

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I'm here to help if you want, Springs! Both of your situations are used in Reap

 

I used scripts and trigger multi-boxes

 

 

 

void AIhostile() // CALLED FROM A TRIGGER THAT WILL REVERT AI TO HOSTILE

{

 

unauthorized = 1; // TENSION BECAUSE OF MOVING INTO UNAUTHORIZED AREA

 

 

if (blown == 0 && curse == 0) // CHECKS IF THE PLAYER'S COVER IS BLOWN OR CURSE IS ACTIVE

{

$AIHostile.activate($player1); // ACTIVATES THE ENTITY THAT CHANGE TEAM BEHAVIOUR TO HOSTILE

 

if (tension_level == 0)

{

$player1.callGui(gauge, "high");

sys.print("\nTension is risen because of moving into unauthorized area!\n");

tension_level = 1;

}

}

 

}

 

// IF PLAYER HAS PICKPOCKETED OR COVER IS BLOWN, THIS SCRIPT WILL BE SKIPPED

 

void AIfriendly() // CALLED FROM A TRIGGER THAT WILL REVERT AI TO FRIENDLY

{

if (unauthorized == 1)

{

sys.wait(2); // PAUSE TO KEEP TENSION FOR 2 SECONDS

}

 

if (blown == 0 && unauthorized == 1 && theft == 0 && corpses == 0 && curse == 0)

{

$AIFriend.activate($player1); // ACTIVATES THE ENTITY THAT CHANGE TEAM BEHAVIOUR TO FRIENDLY

 

if (tension_level == 1)

{

$player1.callGui(gauge, "low");

sys.print("\nTension is low again\n");

tension_level = 0;

}

 

unauthorized = 0;

}

}

 

 

 

 

Put one trigger box INSIDE the area and call AIhostile

Put one trigger box OUTSIDE the area and call AIfriendly

 

 

 

This is the script that will run when the player frobs loot (spawnarg 'frob_action_script' and script name, in my case PickpocketMakeHostile)

 

 

 

 

void PickpocketMakeHostile()

{

sys.wait(3); // PAUSE TO KEEP TENSION FOR 3 SECONDS

$AIHostile.activate($player1); // ACTIVATES THE ENTITY THAT CHANGE TEAM BEHAVIOUR TO HOSTILE

 

 

theft = 1; // GIVE SWITCH SO HOSTILE-->FRIENLDLY TRIGGERS DON'T WORK FOR 3 SECONDS

 

 

 

if (blown == 0)

{

if (tension_level == 0)

{

$player1.callGui(gauge, "high");

sys.print("\nTension has risen due to theft!\n");

tension_level = 1;

}

}

 

sys.wait(3); // KEEP TENSION FOR 3 SECONDS

 

if (blown == 0) // CHECKING IF THE PLAYER HAS BEEN SPOTTED

{

 

if (tension_level == 1)

{

$AIFriend.activate($player1); // ACTIVATES THE ENTITY THAT CHANGE TEAM BEHAVIOUR TO FRIENDLY

$player1.callGui(gauge, "low");

sys.print("\nTension is low!\n");

tension_level = 0;

}

}

 

theft = 0;

 

}

 

 

 

 

'AIHostile' and 'AIFriend' are atdm:target_setrelations enities

 

Note that I had to use switches (theft) to distinguish the cause for the alert rise; Without it, I could steal all I would IF I was standing in a trigger box outside a restriced area as this triggers the script that will make the AI friendly...

 

Hope that helps a bit, feel free to ask questions! :)

 

Note that some of the scripts are related to the tension meter gui which isn't really neccessary for the thing to work, but if it's not perfectly obvious that the area is restricted, it's nice to see that the tension has risen...

Edited by Fieldmedic
Link to comment
Share on other sites

Ok, thanks. I don't know much about scripts so it will take me some time to digest this...

Link to comment
Share on other sites

The basics in the script is quite easy, but as one add more factors it's getting more complicated...

 

The flow is like this:

Player frobs loot

The loot calls a script

The script activates an entity that changes the relations so that the AI is HOSTILE to the player

Then a timer is started and when that is up, the script calls an entity to change the relations back to FRIENDLY

This means that the tension will be high (anyone sees you during these seconds assaults you)

But then it goes back to normal

UNLESS

You are seen; then you must make it impossible to go back to normal. Or else the guard will charge you and stop when the timer runs out.

Link to comment
Share on other sites

Ah, so it only makes them agressive if they see you within X seconds? That's quite cool.

Link to comment
Share on other sites

I worked on something like this for NHAT 2/3. I documented it best I could in the map script file, so I'll post a snippit here.

 

void crime_watch_entity(string name)
{


/****************************************************************************
*																		  
*	This is the AI relations script for NHAT 2/3: A Night Out on the Town.  
*																		  
* General guards, like the citywatch, all are all set to team 2: citywatch.  
* a atdm:team_relations entity changes their regular relation to the player  
* to neutral ("rel 2,0" "0").											  
*																		  
* They are still neutral to builders and other commoners etc (team 5)	  
* seen on the streets. The only significant difference between them and the									  
* commoners is that they are allied to builders (assaulting a builder will  
* get you busted) and it is not against objectives to kill these guys.	  
*																		  
* When the script is run, AI check to see if they've "seen any evidence" of  
* crime, such as corpses, stolen goods, weapons (including arrows that the  
* player may have shot).												  
*																			
* If they've seen any evidence (or have generally been pissed off) they'll	
* alert any nearby buddies (citywatch, commoners, beggars).				  
*																		  
* The AI and his buddies will check to see if the player is in sight.	  
* If he can see the player, and he's pissed off JUST ENOUGH, the AI will be  
* set to "hostile". If he cannot see the player, or he's not pissed off  
* enough, no relation change will occur, and he will stay neutral.		  
*																		  
*																		  
*		 Tl;dr?															  
* Don't be caught at the scene of any crime.							  
* Come back later, when the AI have cooled down.						  
* Then you should be safe to walk around.								  
*****************************************************************************/

   //You must cast the entity before we can
   //access the script floats.

ai theAI = sys.getEntity(name);

   if ( theAI.getHealth() >= 0 )                                                //Is this AI dead? Dead men tell no tales.
   {                                                                            //If not...
       if ( theAI.hasSeenEvidence() && theAI.AI_AlertLevel > 11 )                            //Have you seen evidence, or are you pissed off?
       {                                                                                    //If so...
           ai theAIbuddy = theAI.findFriendlyAI(-1);                                                        //See if you can find any buddy near to you
           theAIbuddy.setAlertLevel( theAI.AI_AlertLevel );                                                //If you found him, Warn him, and piss him off, too.
           sys.println( theAI.getName() + ": Evidence of a crime! Or I was just informed of a crime!\n");    //And print something in the console.
       }

       if ( theAI.canSeeExt($player1, 1, 1) && theAI.AI_AlertLevel > 17 )                        //Are you REALLY pissed off? AND can you see the player?
       {                                                                                        //If so...
           theAI.lookAt( $player1, 3 );                                                                            //Look at that nasty jerk player.
           theAI.setEntityRelation( $player1, -1 );                                                                //He is now your enemy! Go get 'em!
           sys.println(theAI.getName() + ": I've just seen the player at a crime scene! I'm gonna kill him!\n");    //And print that in the console!
       }
   }



}

void crimewatch_1()
{

/*******************************

This script gets called every
trigger_timer_1 "wait" seconds

Don't overdo how often it gets
called, or you'll really suck
away your CPU.

********************************/

crime_watch_entity("atdm_ai_citywatch_THIS_IS_MY_NAME");
crime_watch_entity("atdm_ai_citywatch_THIS_IS_ALSO_MY_NAME");


}

yay seuss crease touss dome in ouss nose tair

Link to comment
Share on other sites

I did this along time ago, I did it like this but not sure if/how posible in this editor....

 

I simply added the trigger, had the AI as "team" 0 then in blue room had his "evil" team 3 clone ready to be warped in and replace the team 0 guy... the warp was so fast the player didnt see the swap... used this on alot of non pathing guards I made in a museuem level I had.

 

hope this helps

Link to comment
Share on other sites

  • 1 year later...

I've been trying to find my old post but this is the closest I've found.

 

As I recall, some of these behaviors are now part of the neutral team AI?

 

If not, it would probably be a good idea to make some teams where this is the default behavior as scripting

is far more taxing on the CPU than native SDK code.

 

Shall I open a bug in tracker?

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

If you want to make it a one time change, or ai are hostile only while the player is inside forbidden grounds, and will "chase" you out then go back to being neutral, I've got that in one of my wips, can detail how it was done after I get food, all using stuff within DR, no scripting.

Intel Sandy Bridge i7 2600K @ 3.4ghz stock clocks
8gb Kingston 1600mhz CL8 XMP RAM stock frequency
Sapphire Radeon HD7870 2GB FLeX GHz Edition @ stock @ 1920x1080

Link to comment
Share on other sites

I barely remember posting a script called "hitman style" a while ago. You may searhc for that in my mapping thread.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I was asking if I should open a tracker for including some of these behaviors in some AI "Teams" because doing so would improve

performance compared to using scripts for this.

 

Ideally, we would follow-up on Fabien Sanglard's suggestion and upgrade the script VM to include JIT compiling like Q3 but short of that

pipe dream it would be cool if we had teams where these behaviors were built-in so minimal scripting would be needed.

 

This particular thread points to a highly discussed request in the newbie mapper thread.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

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

    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • 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
×
×
  • Create New...