Author Sticky: Post Working Scripts Here
Nilyan Posted: Sunday, 21 July 06:48PM
Script Name: AI - NPC run if too low level

What it does: If NPC is too low of a level vs. PC it will run vs. fight.

This script is mainly for worlds having multiple PC levels -

I have a newbie zone with low level wandering monsters that 1st level PC's can fight for experience. But, I wanted it so that my high level characters wouldn't be harrassed if having to travel through a zone with low level encounters.

I call my script lf_combatround...here it is:


NWScript:
/* Script created by Nilyan: AKA Duane Tucker

   July 19, 2002

   ///////////////////////////////////////////////////////////////////

   Sript is to be called on lines 35 and 54 of nw_c2_default2

   using - ExecuteScript("lf_combatround", OBJECT_SELF); - in place of

   DetermineCombatRound();

*/

#include "NW_I0_GENERIC"

void main()

{

object oPC = GetLastPerceived();

int iHDpc = GetHitDice(oPC);

int iHDcr = GetHitDice(OBJECT_SELF) + 3;//Default is set at 3. Change to your liking

if ((iHDpc > iHDcr) && GetIsPC(oPC)) //If PC is too high of a level...run

    {

    ActionMoveAwayFromObject(oPC,TRUE,60.0f);//Will run a distance of 60

    }

    else

    {

    ClearAllActions();

    DetermineCombatRound();

    }

}





Instructions:

1. Save script above.

2. Find Bioware's nw_c2_default2 script, and on lines 35, and 54 place - ExecuteScript("lf_combatround", OBJECT_SELF); in place of DetermineCombatRound();

3. Save file, or save under a different name (I saved mine under a different name - simply because I like keeping all of Bioware's default scripts untouched, and I selectively use this AI script depending on the mob/zone types.

You can change how high of level you want the PC to be before the NPC runs. You can also set it that the NPC won't run and do nothing by just commenting out the else section.

Good luck and I hope this script helps you.

Nilyan