AI Ignore Player: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 3: Line 3:
Here is one possible script:
Here is one possible script:


 
void crime_watch_entity(string name)
 
{
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.    *
*      This is the AI relations script for NHAT 2/3: A Night Out on the Town.  *
* a atdm:team_relations entity changes their regular relation to the player    *
*                                                                                                                                                       *
* to neutral ("rel 2,0" "0").                                                   *                                                          
* 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    *
* They are still neutral to builders and other commoners etc (team 5)          *
* to neutral ("rel 2,0" "0").                                                                                           *
* seen on the streets. The only significant difference between them and the    *                                                                                       
*                                                                                                                                                       *
* commoners is that they are allied to builders (assaulting a builder will      *
* They are still neutral to builders and other commoners etc (team 5)          *
* get you busted) and it is not against objectives to kill these guys.          *
* seen on the streets. The only significant difference between them and the    *                                                                                       
*                                                                               *
* commoners is that they are allied to builders (assaulting a builder will      *
* When the script is run, AI check to see if they've "seen any evidence" of    *
* get you busted) and it is not against objectives to kill these guys.          *
* crime, such as corpses, stolen goods, weapons (including arrows that the      *
*                                                                                                                                                       *
* player may have shot).                                                       *
* 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      *
* If they've seen any evidence (or have generally been pissed off) they'll     *
* player may have shot).                                                                                                       *
* alert any nearby buddies (citywatch, commoners, beggars).                     *
*                                                                                                                                                       *
*                                                                               *
* If they've seen any evidence (or have generally been pissed off) they'll       *
* The AI and his buddies will check to see if the player is in sight.          *
* alert any nearby buddies (citywatch, commoners, beggars).                                     *
* 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         *
* The AI and his buddies will check to see if the player is in sight.          *
* enough, no relation change will occur, and he will stay neutral.             *
* 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 *
*                Tl;dr?                                                         *
* enough, no relation change will occur, and he will stay neutral.                     *
* 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.                                       *
*                Tl;dr?                                                                                                                         *
********************************************************************************/
* Don't be caught at the scene of any crime.                                                           *
* Come back later, when the AI have cooled down.                                                       *
    // You must cast the entity before we can access the script floats.
* Then you should be safe to walk around.                                                                       *
*****************************************************************************/
    ai theAI = sys.getEntity(name);
 
    if ( theAI.getHealth() >= 0 ) // Is this AI dead? Dead men tell no tales.
        //You must cast the entity before we can
    {
        //access the script floats.
        // If not ...
 
ai theAI = sys.getEntity(name);
        if ( theAI.hasSeenEvidence() && ( theAI.AI_AlertLevel > 11 ) ) // Have you seen evidence, and are you pissed off?
 
        {
        if ( theAI.getHealth() >= 0 )                                                                                           //Is this AI dead? Dead men tell no tales.
            // If so ...
        {                                                                                                                                         //If not...
                if ( theAI.hasSeenEvidence() && theAI.AI_AlertLevel > 11 )                                                       //Have you seen evidence, or are you pissed off?
            ai theAIbuddy = theAI.findFriendlyAI(-1); // See if you can find any buddy near to you
                {                                                                                                                                                         //If so...
            if ( theAIbuddy != $null_entity )
                        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.
                theAIbuddy.setAlertLevel(theAI.AI_AlertLevel); // 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.
                sys.println(theAI.getName() + ": Evidence of a crime! Or I was just informed of a crime!\n"); // Print to 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!
                }
         }
         }
 
        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"); // Print to the console!
        }
    }
}

Revision as of 01:37, 10 January 2013

Sometimes there's no reason for AI to attack the player on sight. Public places, like taverns or city streets, should often be safe for the player unless they do something wrong.

Here is one possible script:

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, and are you pissed off?
       {
           // If so ...

           ai theAIbuddy = theAI.findFriendlyAI(-1); // See if you can find any buddy near to you
           if ( theAIbuddy != $null_entity )
           {
               theAIbuddy.setAlertLevel(theAI.AI_AlertLevel); // 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"); // Print to 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"); // Print to the console!
       }
   }
}