Here is one for goblins:
//Goes OnUserDefined of a creature, or on perception, or hb.
#include "NW_I0_GENERIC"
void main()
{
object oPC = GetLastPerceived();
object oRoad = GetNearestObjectByTag ("Wp_Road");
object oBase = GetNearestObjectByTag ("SkullPole");
object oDummy = GetNearestObjectByTag ("Campfire");
object oArea = GetArea(OBJECT_SELF);
effect eRegenerate = EffectRegenerate(2, 3.0);
int iHd = GetHitDice(oPC);
location lWP = GetLocation(oRoad);
location lWP1 = GetLocation(oBase);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat())
return;
if (GetIsEnemy (oPC))
{
ActionAttack(oPC);
return;
}
if (GetDeity(oPC)== "Bocrewg")
{
DelayCommand(1.0,AssignCommand(OBJECT_SELF, PlayAnimation(ANIMATION_LOOPING_WORSHIP,0.5, 20.0)));
SetIsTemporaryFriend(oPC, OBJECT_SELF, TRUE, 100.0 + iHd * 10);
DelayCommand(10.0,AssignCommand(OBJECT_SELF, ActionForceFollowObject(oPC, 1.0 + iHd/6)));
return;
}
//if fighting fight on.
if (GetWeather(oArea) == WEATHER_RAIN)
{
DelayCommand (1.0, ActionForceMoveToLocation(lWP1,TRUE));
DelayCommand(3.0,AssignCommand(OBJECT_SELF, PlayAnimation(ANIMATION_LOOPING_SIT_CROSS,0.5, 20.0)));
DelayCommand (10.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRegenerate, OBJECT_SELF, 15.0));
return;
}
string sWPTag1 = "wp_random";//seed tag of wp. wp's must be placed.
string sRan = IntToString(d6()); //change dsize for more wp
string sWPTag = sWPTag1 + sRan; //selects wp_random1-6
location lWP2 = GetLocation(GetNearestObjectByTag(sWPTag));
if (d100()<50)
return;
{
ActionMoveToLocation(lWP, FALSE);
DelayCommand (6.0, ActionMoveAwayFromLocation(lWP, FALSE));
DelayCommand (12.0, ActionMoveToLocation(lWP2, FALSE));
{
if
(GetDistanceToObject (oBase) < 6.0)
return;
if (GetDistanceToObject (oDummy) > 25.0)
return;
else
switch( d4())
{
case 1: ActionMoveAwayFromObject(oPC, TRUE, 8.0);break;
case 2: DelayCommand (2.0,ActionMoveToLocation(lWP,TRUE));break;
case 3: ActionAttack(oDummy);break;
case 4: DelayCommand(3.0,AssignCommand(OBJECT_SELF, PlayAnimation(ANIMATION_LOOPING_SIT_CROSS,0.5, 10.0)));
}
}
}
}
Then for the ondamaged:
#include "nw_i0_generic"
#include "_prr_main"
void main()
{
object oBase = GetNearestObjectByTag ("SkullPole");
string sSoundName = "as_an_wolfhowl1";
object oEnemy = GetLastDamager();
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC,OBJECT_SELF);
location lWP = GetLocation(oBase);
float fRange = 3.0;
int nMaxInteger = 5;
int nRandom = (nMaxInteger);
int iHd = GetHitDice(oPC);
int nPercentage = 30 - iHd; //Percentage of HP the NPC has been damaged when they
//will start to run
int nDamage = d4(iHd/6);
if ((GetPercentageHPLoss(OBJECT_SELF) > nPercentage) || (iHd > 4))
PRR_AdjustHistoricalValue(oEnemy, OBJECT_SELF, -1);
if (GetHasFeat (FEAT_SNEAK_ATTACK, oPC) && (GetIsImmune(OBJECT_SELF, IMMUNITY_TYPE_CRITICAL_HIT))&&(GetLocalInt (OBJECT_SELF, "SneakAttacked")!=1))
{
effect eDamage = EffectDamage (nDamage, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_ONE);
effect eDeath = EffectDeath(TRUE, TRUE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, OBJECT_SELF);
SetLocalInt (OBJECT_SELF, "SneakAttacked",1);
DelayCommand (12.0, SetLocalInt (OBJECT_SELF, "SneakAttacked",0));
if ((GetCurrentHitPoints(OBJECT_SELF) < 5) && (oEnemy == oPC))
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, OBJECT_SELF);
SetLocalInt (oEnemy, "SneakKill", 1);
}
{
ClearAllActions(TRUE);
ActionMoveAwayFromObject(oEnemy, TRUE, fRange + nRandom + iHd);
DelayCommand (3.0, SetCommandable(FALSE,OBJECT_SELF));
DelayCommand (6.0, SetCommandable(TRUE,OBJECT_SELF));
DelayCommand (6.4, ActionEquipMostDamagingRanged());
DelayCommand (6.8, ActionAttack (oPC));
DelayCommand (12.0, ActionForceMoveToLocation(lWP, TRUE));
if (d20(2)> 25)
DelayCommand (25.0, ExecuteScript("_combatvanish",OBJECT_SELF));
return;
switch(d4())
{
case 1: ActionAttack (oEnemy);break;
case 2: PlaySound(sSoundName); break;//calling for wolves
case 3: TalentBuffSelf(); break;
case 4: UseStealthMode(); break;
}
}
}
Of course you don't have all those references to waypoints but you get the idea.