AI Ignore Player: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(Created page with "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...")
 
No edit summary
Line 44: Line 44:
         //access the script floats.
         //access the script floats.


ai theAI = sys.getEntity(name);
ai theAI = sys.getEntity(name);


         if ( theAI.getHealth() >= 0 )                                                                                          //Is this AI dead? Dead men tell no tales.
         if ( theAI.getHealth() >= 0 )                                                                                          //Is this AI dead? Dead men tell no tales.
        {                                                                                                                                        //If not...
        {                                                                                                                                        //If not...
                 if ( theAI.hasSeenEvidence() && theAI.AI_AlertLevel > 11 )                                                     //Have you seen evidence, or are you pissed off?
                 if ( theAI.hasSeenEvidence() && theAI.AI_AlertLevel > 11 )                                                       //Have you seen evidence, or are you pissed off?
                {                                                                                                                                                        //If so...
                {                                                                                                                                                        //If so...
                         ai theAIbuddy = theAI.findFriendlyAI(-1);                                                                                                              //See if you can find any buddy near to you
                         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 );                                                                                                //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.
                         sys.println( theAI.getName() + ": Evidence of a crime! Or I was just informed of a crime!\n");  //And print something in the console.
                 }
                 }
Line 58: Line 58:
                 {                                                                                                                                                                //If so...
                 {                                                                                                                                                                //If so...
                         theAI.lookAt( $player1, 3 );                                                                                                                                                    //Look at that nasty jerk player.
                         theAI.lookAt( $player1, 3 );                                                                                                                                                    //Look at that nasty jerk player.
                         theAI.setEntityRelation( $player1, -1 );                                                                                                                               //He is now your enemy! Go get 'em!
                         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!
                         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!
                 }
                 }

Revision as of 21:57, 6 June 2012

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, 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!
               }
       }


}