Author Topic: AI Level and what toggles it  (Read 537 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AI Level and what toggles it
« on: August 11, 2012, 08:54:53 am »


               What toggles the AI level? Anything hardcoded/automatic?

I am specifically interested in knowing if DM possession lower teh AI level for a creature. 
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
AI Level and what toggles it
« Reply #1 on: August 11, 2012, 01:10:32 pm »


               DM possession completely disables  AI, including any custom OnDeath scripts that might be handing out XP.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
AI Level and what toggles it
« Reply #2 on: August 11, 2012, 03:04:13 pm »


               I have no Idea if DM possession changes the AI state or not.  You could place a Hb on your DM possessed creature to report there AI state.  

The Script set used by a DM possessed creature is set in statescripts.2da, The default settings clear all of the scripts from the creature.  I have also never tested to find out if the 2da is client/server side.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AI Level and what toggles it
« Reply #3 on: August 11, 2012, 05:07:41 pm »


                Preliminary Test:

No PC/DM in area AI level = VERY LOW
1 PC/DM in area AI = LOW
PC Attacks NPC AI = NORMAL

after DM dispossesses an NPC  AI = HIGH
during DM possession the heartbeat script of the creature did not run at all
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
AI Level and what toggles it
« Reply #4 on: August 11, 2012, 05:40:51 pm »


               Hmm,  Did you give it a DM possessed HB script?
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AI Level and what toggles it
« Reply #5 on: August 11, 2012, 06:12:32 pm »


                For debuging I threw in the following snippet in the heartbeat script:


    int nAI     = GetAILevel();
    string sName= GetName(OBJECT_SELF);

    object oNotify    = GetFirstPC();
    if(GetIsDMPossessed(OBJECT_SELF))
        oNotify   = OBJECT_SELF;
    // * if not runnning normal or better Ai then exit for performance reasons
    if(nAI == AI_LEVEL_INVALID)
    {
        SendMessageToPC(oNotify, sName+" AI invalid ... setting to default");
        SetAILevel(OBJECT_SELF, AI_LEVEL_DEFAULT);
    }
    else if (nAI == AI_LEVEL_VERY_LOW)
    {
        SendMessageToPC(oNotify, sName+" AI very low exiting");
        return;
    }
    else
    {
        SendMessageToPC(oNotify, sName+" AI level("+IntToString(nAI)+")");
    }


I only tested the AI level in the heartbeat script
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
AI Level and what toggles it
« Reply #6 on: August 11, 2012, 06:23:01 pm »


               Yes the Possesed creature has its scripts changed to the settings in statescripts.2da when he gets possesed.  so unless you placed your script name on line 23  DMPossessedHeartbeat,  Your script will not run when possesed by the DM.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AI Level and what toggles it
« Reply #7 on: August 11, 2012, 06:34:52 pm »


               Yeah... I was lazy. Looked into that 2da now.

This means that unless I add the default scripts to statescripts.2da, I don't need to catch DM Possession in the AI.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
AI Level and what toggles it
« Reply #8 on: August 11, 2012, 06:37:34 pm »


               Correct.   But if you want your NPC to give a custom XP when possesed and Killed, You may want to add a OnDeath event.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AI Level and what toggles it
« Reply #9 on: August 11, 2012, 07:17:23 pm »


               Ok I made some changes to statescripts including a dm possessed statescript.

When DM Possessed an NPC's AI is HIGH, and it remains so when dispossessed until there are no PCs in the area.

[EDIT]
Another upside about this is that I now have a better system for tracking the DM object on a DM possessed creature. Thanks for the info on statescripts.

By using a DM Possessed heartbeat I can use that to track DM possession (place a pointer to the DM on the NPC) without the need to add this code to the default heartbeat.
               
               

               


                     Modifié par henesua, 11 août 2012 - 06:47 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
AI Level and what toggles it
« Reply #10 on: August 11, 2012, 09:39:20 pm »


               Did another test:

statescripts.2da functions adequately as server side only. Doesn't need to be on the client.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
AI Level and what toggles it
« Reply #11 on: August 12, 2012, 04:21:30 pm »


               

Lightfoot8 wrote...

Correct.   But if you want your NPC to give a custom XP when possesed and Killed, You may want to add a OnDeath event.

Just FYI. This feature was added in initial Community Patch 1.70 release already. The script in DMOnDeath event looks like this:

void main()
{
string script = GetLocalString(OBJECT_SELF,"DEATH_SCRIPT");
 if(script == "")
 {
 script = "nw_c2_default7";
 }
ExecuteScript(script,OBJECT_SELF);
}

and all default monsters (resp. their blueprints) with nonstandard OnDeath script has the local variable DEATH_SCRIPT defined.