PWE_PRC8/_module/nss/j_inc_spawnin.nss
Jaysyn904 ee1dc35889 Initial Commit
Initial Commit
2025-04-03 10:29:41 -04:00

695 lines
28 KiB
Plaintext

// Walk waypoints, set listening patterns, and spawn in conditions here
// Note: Reset events to "normal" or default values. (just in case...)
//Master Constants- Default ones still used.
int NW_FLAG_SPECIAL_CONVERSATION = 0x00000001;
int NW_FLAG_SHOUT_ATTACK_MY_TARGET = 0x00000002;
int NW_FLAG_STEALTH = 0x00000004;
int NW_FLAG_SEARCH = 0x00000008;
int NW_FLAG_SPECIAL_COMBAT_CONVERSATION = 0x00040000;
int NW_FLAG_DAY_NIGHT_POSTING = 0x00400000;
int NW_FLAG_FAST_BUFF_ENEMY = 0x04000000;
//Master Constants for UDE
int NW_FLAG_PERCIEVE_EVENT = 0x00000200;
int NW_FLAG_ATTACK_EVENT = 0x00000400;
int NW_FLAG_DAMAGED_EVENT = 0x00000800;
int NW_FLAG_SPELL_CAST_AT_EVENT = 0x00001000;
int NW_FLAG_DISTURBED_EVENT = 0x00002000;
int NW_FLAG_END_COMBAT_ROUND_EVENT = 0x00004000;
int NW_FLAG_ON_DIALOGUE_EVENT = 0x00008000;
int NW_FLAG_RESTED_EVENT = 0x00010000;
int NW_FLAG_DEATH_EVENT = 0x00020000;
int NW_FLAG_HEARTBEAT_EVENT = 0x00100000;
// This will make the creature never fight against impossible odds.
int NEVER_FIGHT_IMPOSSIBLE_ODDS = 0x00000010;
// This reflects the boss' power. All allies in 6 tiles will come.
int BOSS_MONSTER_SHOUT = 0x00000020;
// This will make the creature a "leader" to command the help, and genrally command others.
// Also, any creature that can see the leader will not flee except on command, although the
// leader may flee, and order others to.
int GROUP_LEADER = 0x00000040;
// This will make the creature defined as an Archer only. They will either:
// a. Use a missile weapon with pointblankshot.
// b. Move back, best they can, if allies are there to help, then carry on shooting.
int ARCHER_ATTACKING = 0x00000080;
// This will make the creature never flee at all.
int FEARLESS = 0x00000100;
// If they are damaged a lot, they may spawn a critical wounds potion and use it.
int CHEAT_MORE_POTIONS = 0x00080000;
// This will make the creature summon thier respective familiars/animal companions.
int SUMMON_FAMILIAR = 0x00200000;
// This will make the creature cheat by using some instant death spells on low save enemies
// Its not that powerful at all, really, but might as well be toggelable.
int IMPROVED_INSTANT_DEATH_SPELLS = 0x00800000;
// This will let the cleric use the raising spells in battle.
int WILL_RAISE_ALLIES_IN_BATTLE = 0x01000000;
// This will make the creature use ranged spells, before moving in bit by bit.
// Ranges of spells are 40, then 20, 8, 2.5 and then 0 (or self! hehe)
int ATTACK_FROM_AFAR_FIRST = 0x02000000;
// There will be a chance each round to try and pickpocket the enemy. This toggles it.
// It will only use it if it's skills are at least 1 every 4 levels.
int USE_PICKPOCKETING = 0x08000000;
// This will store thier starting location, and then move back there after combat
// Will turn off if there are waypoints.
int RETURN_TO_SPAWN_LOCATION = 0x10000000;
// Tracks day/night.
int TRACK_DAY_NIGHT = 0x20000000;
// This will affect conversations - will they clear all actions before hand?
int NO_CLEAR_ACTIONS_BEFORE_CONVERSATION = 0x40000000;
// Last one! This stops all polymorphing by spells/feats
int NO_POLYMORPHING = 0x80000000;
// Animations:
// Randomwalk normally, or move to nearest ally.
int AMBIENT_ANIMATIONS = 1;
// These will face nearest ally, and talk or laugh. If no ally then look right/left.
int IMMOBILE_AMBIENT_ANIMATIONS = 2;
// This is the bird animations.
int AMBIENT_ANIMATIONS_AVIAN = 3;
// This will make the creatures "group" and sit, and normally talk.
int AMBIENT_GROUP_ANIMATIONS = 4;
// This will make the creature talk with nearby allies, as to not look dead.
// Also, if alone, it will take drinks, and things like that.
int IMMOBILE_ANIMATIONS_AND_SOLO = 5;
// This is a consitution for just random walking, nothing else.
int AMBIENT_ANIMAL_WALKING = 6;
// This will activare all auras, very quickly.
void AdvancedAuras();
// Activate the aura number, if it is possible. Returns TRUE if so.
int ActivateIfHas(int nAuraNumber);
// Run the circuit.
void RunCircuit(int nTens, int nNum, int nRun = FALSE, float fPause = 1.0);
// Base for moving round thier waypoints
void WalkWayPoints(int nRun = FALSE, float fPause = 1.0);
// Used in walk waypoints
void RunNextCircuit(int nRun = FALSE, float fPause = 1.0);
// Checks which waypoint they are on, if any valid. TRUE if got any waypoints in range.
int CheckWayPoints(object oWalker = OBJECT_SELF);
//Returns true if the object is walking any waypoints.
int GetIsPostOrWalking(object oWalker = OBJECT_SELF);
// Returns the string to use - depending on day or night.
string GetStringPrefix(string sPrefix, object oWalker = OBJECT_SELF);
// Sets up what we will listen to (everything!)
void SetListeningPatterns();
// This sets a spawn in condition.
void SetSpawnInCondition(int nCondition, int bValid = TRUE, string sName = "NW_GENERIC_MASTER");
//Gets the spawn in condition.Can set things to different ints if you like.
int GetSpawnInCondition(int nCondition, string sName = "NW_GENERIC_MASTER");
// This will set a spawn in value. We Use AddOne for things like races, that
// start at value 1 (ouch!)
void SetSpawnInValue(string sNameOfValue, int iValue = TRUE, int iAddOne= FALSE);
// This will set the string, sNameOfValue, to sValue.
void SetSpawnInStringValue(string sNameOfValue, string sValue);
// This will choose a random string, using iRandomness, either value0 - randomness.
void SetSpawnInStringRandomValue(string sNameOfValue, int iRandomness, string sValue0, string sValue1, string sValue2 = "", string sValue3 = "", string sValue4 = "", string sValue5 = "", string sValue6 = "");
// This will alter (magically) an ammount of random stats - iAmount
// by a value within iLowest and iHighest.
void CreateRandomStats(int iLowest, int iHighest, int iAmount);
// This will randomise other stats. Put both numbers to 0 to ignore some.
// iHPMin, iHPMax = HP changes.
// iReflexSaveMin, iReflexSaveMax = Reflex Save changes
// iWillSaveMin, iWillSaveMax = Will Save changes
// iFortSaveMin, iFortSaveMax = Fortitude Save changes
// iACMin, iACMax = AC change.
// Use iACType to define the AC type - default AC_DODGE_BONUS
void CreateRandomOther(int iHPMin, int iHPMax, int iReflexSaveMin = 0, int iReflexSaveMax = 0, int iWillSaveMin = 0, int iWillSaveMax = 0, int iFortSaveMin = 0, int iFortSaveMax = 0, int iACMin = 0, int iACMax = 0, int iACType = AC_DODGE_BONUS);
//::///////////////////////////////////////////////
//:: Master Local Set
//:: FileName
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
All On Spawn in conditions in the game are now
being stored within one local. The get and set
changed or checks the condition of this one
Hex local. The NW_FLAG_XXX variables above
allow for the user of these functions throughout
the generic scripts.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 14, 2001
//:://////////////////////////////////////////////
void SetSpawnInValue(string sNameOfValue, int iValue, int iAddOne)
{
if(iAddOne)
{
int iValueNew = iValue + 1;
SetLocalInt(OBJECT_SELF, sNameOfValue, iValueNew);
}
else
{
SetLocalInt(OBJECT_SELF, sNameOfValue, iValue);
}
}
void SetSpawnInStringValue(string sNameOfValue, string sValue)
{
SetLocalString(OBJECT_SELF, sNameOfValue, sValue);
}
void SetSpawnInStringRandomValue(string sNameOfValue, int iRandomness, string sValue0, string sValue1, string sValue2 = "", string sValue3 = "", string sValue4 = "", string sValue5 = "", string sValue6 = "")
{
// Need a value amount of values!
if(iRandomness > 0)
{
int iRandomNum = Random(iRandomness) -1; // take one, as it is 0 - X, not 1 - X
string sValueToUse;
switch(iRandomNum)
{
case(0):{sValueToUse = sValue0;}break;
case(1):{sValueToUse = sValue1;}break;
case(2):{sValueToUse = sValue2;}break;
case(3):{sValueToUse = sValue3;}break;
case(4):{sValueToUse = sValue4;}break;
case(5):{sValueToUse = sValue5;}break;
case(6):{sValueToUse = sValue6;}break;
}
SetLocalString(OBJECT_SELF, sNameOfValue, sValueToUse);
}
}
void SetSpawnInCondition(int nCondition, int bValid, string sName)
{
int nPlot = GetLocalInt(OBJECT_SELF, sName);
if(bValid == TRUE)
{
nPlot = nPlot | nCondition;
SetLocalInt(OBJECT_SELF, sName, nPlot);
}
else if (bValid == FALSE)
{
nPlot = nPlot & ~nCondition;
SetLocalInt(OBJECT_SELF, sName, nPlot);
}
}
int GetSpawnInCondition(int nCondition, string sName)
{
int nPlot = GetLocalInt(OBJECT_SELF, sName);
if(nPlot & nCondition)
{
return TRUE;
}
return FALSE;
}
////////////////////////////////////////////////////////////////////////////////
// This applies an increase, decrease or no change to the intended stat.
void ApplyStatChange(int iStat, int iAmount)
{
if(iAmount != 0)
{
effect eChange;
if(iAmount < 0)
{
int iNewAmount = abs(iAmount);
eChange = ExtraordinaryEffect(EffectAbilityDecrease(iStat, iNewAmount));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
else
{
eChange = ExtraordinaryEffect(EffectAbilityIncrease(iStat, iAmount));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
}
}
// This will, eventually, choose X number of stats, and change them within the
// range given.
void CreateRandomStats(int iLowest, int iHighest, int iAmount)
{
if(iAmount > 0 && !(iLowest == 0 && iHighest == 0) && iHighest >= iLowest)
{
int iRange = iHighest - iLowest;
int iNumSlots = iAmount;
if(iNumSlots > 6) iNumSlots = 6;
int iNumLeft = 6;
// Walk through each stat and figure out what it's chance of being
// modified is. As an example, suppose we wanted to have 4 randomized
// abilities. We'd look at the first ability and it would have a 4 in 6
// chance of being picked. Let's suppose it was, the next ability would
// have a 3 in 5 chance of being picked. If this next ability wasn't
// picked to be changed, the 3rd ability woud have a 3 in 4 chance of
// being picked and so on.
int iCnt;
int iChange;
for(iCnt = 0; (iNumSlots > 0) && (iCnt < 6); iCnt++)
{
if((iNumSlots == iNumLeft) || (Random(iNumLeft) < iNumSlots))
{
iChange = Random(iRange) + iLowest;
ApplyStatChange(iCnt, iChange);
iNumSlots--;
}
iNumLeft--;
}
}
}
void CreateRandomOther(int iHPMin, int iHPMax, int iReflexSaveMin = 0, int iReflexSaveMax = 0, int iWillSaveMin = 0, int iWillSaveMax = 0, int iFortSaveMin = 0, int iFortSaveMax = 0, int iACMin = 0, int iACMax = 0, int iACType = AC_DODGE_BONUS)
{
int iRange, iChange, iNewChange;
effect eChange;
if(!(iHPMin == 0 && iHPMax == 0) && iHPMax >= iHPMin)
{
iRange = iHPMax - iHPMin;
iChange = Random(iRange) + iHPMin;
if(iChange > 0)
{
eChange = ExtraordinaryEffect(EffectTemporaryHitpoints(iChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
else if(iChange < 0 && GetMaxHitPoints() > 1)
{
eChange = EffectDamage(iChange, DAMAGE_TYPE_DIVINE, DAMAGE_POWER_PLUS_FIVE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
}
if(!(iReflexSaveMin == 0 && iReflexSaveMax == 0) && iReflexSaveMax >= iReflexSaveMin)
{
iRange = iReflexSaveMax - iReflexSaveMin;
iChange = Random(iRange) + iReflexSaveMin;
if(iChange > 0)
{
eChange = ExtraordinaryEffect(EffectSavingThrowIncrease(SAVING_THROW_REFLEX, iChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
else if(iChange < 0 && GetReflexSavingThrow(OBJECT_SELF) > 1)
{
iNewChange = abs(iChange);
eChange = ExtraordinaryEffect(EffectSavingThrowDecrease(SAVING_THROW_REFLEX, iNewChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
}
if(!(iWillSaveMin == 0 && iWillSaveMax == 0) && iWillSaveMax >= iWillSaveMin)
{
iRange = iWillSaveMax - iWillSaveMin;
iChange = Random(iRange) + iWillSaveMin;
if(iChange > 0)
{
eChange = ExtraordinaryEffect(EffectSavingThrowIncrease(SAVING_THROW_WILL, iChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
else if(iChange < 0 && GetWillSavingThrow(OBJECT_SELF) > 1)
{
iNewChange = abs(iChange);
eChange = ExtraordinaryEffect(EffectSavingThrowDecrease(SAVING_THROW_WILL, iNewChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
}
if(!(iFortSaveMin == 0 && iFortSaveMax == 0) && iFortSaveMax >= iFortSaveMin)
{
iRange = iFortSaveMax - iFortSaveMin;
iChange = Random(iRange) + iFortSaveMin;
if(iChange > 0)
{
eChange = ExtraordinaryEffect(EffectSavingThrowIncrease(SAVING_THROW_FORT, iChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
else if(iChange < 0 && GetFortitudeSavingThrow(OBJECT_SELF) > 1)
{
iNewChange = abs(iChange);
eChange = ExtraordinaryEffect(EffectSavingThrowDecrease(SAVING_THROW_FORT, iNewChange));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
}
if(!(iACMin == 0 && iACMax == 0) && iACMax >= iACMin)
{
iRange = iACMax - iACMin;
iChange = Random(iRange) + iACMin;
if(iChange > 0)
{
eChange = ExtraordinaryEffect(EffectACIncrease(iChange, iACType));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
else if(iChange < 0)
{
iNewChange = abs(iChange);
eChange = ExtraordinaryEffect(EffectACDecrease(iNewChange, iACType));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eChange, OBJECT_SELF);
}
}
}
/*::///////////////////////////////////////////////
//:: SetListeningPatterns
//:://////////////////////////////////////////////
Changed a lot. Sets up death destroyable corpse thing,
and added in "**" (all) listening, for hearing enemies.
//::////////////////////////////////////////////*/
void SetListeningPatterns()
{
SetIsDestroyable(FALSE,TRUE,TRUE); // Just handling corpse raising/resurrection/removal
SetListening(OBJECT_SELF, TRUE);
// Anyone that can hear it, and is not fighting, comes and helps
SetListenPattern(OBJECT_SELF, "I_WAS_ATTACKED", 1);
//Set a custom listening pattern for the creature so that placables with
//"NW_BLOCKER" + Blocker NPC Tag will correctly call to their blockers.
string sBlocker = "NW_BLOCKER_BLK_" + GetTag(OBJECT_SELF);
SetListenPattern(OBJECT_SELF, sBlocker, 2);
// Determines combat round, if not fighting
SetListenPattern(OBJECT_SELF, "CALL_TO_ARMS", 3);
// These call to allies, to move them to a battle.
SetListenPattern(OBJECT_SELF, "HELP_MY_FRIEND", 4);
SetListenPattern(OBJECT_SELF, "LEADER_FLEE_NOW", 5);
// This will make the listener hear anything, used to react to enemy talking.
SetListenPattern(OBJECT_SELF, "**", 0);
}
//***************************
//***************************
//
//WAY POINT WALK FUNCTIONS
//
//***************************
//***************************
//::///////////////////////////////////////////////
//:: Walk Way Point Path
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Allows specified person walk a waypoint path
*/
//:://////////////////////////////////////////////
//:: Created By: Aidan Scanlan
//:: Created On: July 10, 2001
//:://////////////////////////////////////////////
void WalkWayPoints(int nRun = FALSE, float fPause = 1.0)
{
// Do we have any? any at all?
if(CheckWayPoints())
{
// If yes, do everything...and first clear all actions.
ClearAllActions();
// We check out waypoints...and set day/night appropriately.
string NightWayString;
string NightPostString;
object oWayNP = GetWaypointByTag("NIGHT_" + GetTag(OBJECT_SELF));
object oWayNW = GetWaypointByTag("WN_" + GetTag(OBJECT_SELF) + "_01");
if(GetIsObjectValid(oWayNP) || GetIsObjectValid(oWayNW))
{
NightWayString = "WN_";
NightPostString = "NIGHT_";
}
else
{
NightWayString = "WP_";
NightPostString = "POST_";
}
// We will set what strings to use.
SetLocalString(OBJECT_SELF, "NW_GENERIC_WALKWAYS_DAY", "WP_");
SetLocalString(OBJECT_SELF, "NW_GENERIC_WALKWAYS_NIGHT", NightWayString);
SetLocalString(OBJECT_SELF, "NW_GENERIC_POSTING_DAY", "POST_");
SetLocalString(OBJECT_SELF, "NW_GENERIC_POSTING_NIGHT", NightPostString);
//I have now determined what the prefixs for the current walkways and postings are and will use them instead
// of POST_ and WP_
if(GetSpawnInCondition(NW_FLAG_STEALTH))
{
// Will hide all the time, when they walk
ActionUseSkill(SKILL_HIDE, OBJECT_SELF);
}
else if(GetSpawnInCondition(NW_FLAG_SEARCH) || GetLocalInt(OBJECT_SELF, "ANIMATIONS") == IMMOBILE_AMBIENT_ANIMATIONS)
{
// Will search all the time, when they walk, or if we are not going to move.
ActionUseSkill(SKILL_SEARCH, OBJECT_SELF);
}
// Which shall we use? Day or night?
string sWay = GetStringPrefix("NW_GENERIC_WALKWAYS");
// Gets if there is a waypoint first...
string sWayTag = GetTag(OBJECT_SELF);
sWayTag = sWay + sWayTag + "_01";
object oWay1 = GetNearestObjectByTag(sWayTag);
// Get the object, if nearest (IE in area one) is not valid.
if(!GetIsObjectValid(oWay1))
{
oWay1 = GetObjectByTag(sWayTag);
}
// If we are going to walk some waypoints, we cannot have animations.
// This script is only activated ONCE, so these are never re-deleted or locations set twice.
if(GetIsObjectValid(oWay1))
{
if(GetLocalInt(OBJECT_SELF, "AI_ANIMATIONS") > 0)
{
//turn off the ambient animations if the creature should walk way points.
DeleteLocalInt(OBJECT_SELF, "AI_ANIMATIONS");
}
if(GetSpawnInCondition(RETURN_TO_SPAWN_LOCATION))
{
//turn off returning to spawn point.
SetSpawnInCondition(RETURN_TO_SPAWN_LOCATION, FALSE);
}
// Way point valid! starta walking
int nNth = 1;
int nTens, nNum;
string sNearestTag, sTens;
object oNearest = GetNearestObject(OBJECT_TYPE_WAYPOINT, OBJECT_SELF, nNth);
while(GetIsObjectValid(oNearest))
{
sNearestTag = GetTag(oNearest);
//removes the first 3 and last three characters from the waypoint's tag
//and checks it against his own tag. Waypoint tag format is WP_MyTag_XX.
if(GetSubString(sNearestTag, 3, GetStringLength(sNearestTag) - 6) == GetTag(OBJECT_SELF))
{
sTens = GetStringRight(sNearestTag, 2);
nTens = StringToInt(sTens)/10;
nNum = StringToInt(GetStringRight(sNearestTag, 1));
oNearest = OBJECT_INVALID;
}
else
{
nNth++;
oNearest = GetNearestObject(OBJECT_TYPE_WAYPOINT, OBJECT_SELF, nNth);
}
}
// Changed internally, to run circuits and so on. Use return; not return TRUE etc.
RunCircuit(nTens, nNum, nRun, fPause);
ActionWait(fPause);
ActionDoCommand(RunNextCircuit(nRun, fPause));
}
else // Else go to the post we have set.
{
sWayTag = GetStringPrefix("NW_GENERIC_POSTING") + GetTag(OBJECT_SELF);
oWay1 = GetNearestObjectByTag(sWayTag);
if(!GetIsObjectValid(oWay1))
{
oWay1 = GetObjectByTag(sWayTag);
}
if(GetIsObjectValid(oWay1) && GetDistanceToObject(oWay1) > 0.0)
{
ActionForceMoveToObject(oWay1, nRun, 1.0, 60.0);
float fFacing = GetFacing(oWay1);
ActionDoCommand(SetFacing(fFacing));
// If it is only a night post, or something, who knows, maybe we want to
// start again?
DelayCommand(100.0, WalkWayPoints());
}
}
}
}
// This just carries on walking around and around...
void RunNextCircuit(int nRun, float fPause)
{
RunCircuit(0, 1, nRun, fPause);
ActionWait(fPause);
ActionDoCommand(RunNextCircuit(nRun, fPause));
}
//::///////////////////////////////////////////////
//:: Run Circuit
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Calculates the proper path to follow along a
predetermined set of way points
*/
//:://////////////////////////////////////////////
//:: Created By: Aidan Scanlan
//:: Created On: July 10, 2001
//:://////////////////////////////////////////////
// Added things from Two's verion - Jasperre
void RunCircuit(int nTens, int nNum, int nRun, float fPause)
{
// starting at a given way point, move sequentialy through incrementally
// increasing points until there are no more valid ones.
// We will check for day/night in these instead of heartbeats.
string sWay = GetStringPrefix("NW_GENERIC_WALKWAYS");
string sNewString;
object oTargetPoint = GetWaypointByTag(sWay + GetTag(OBJECT_SELF) + "_" + IntToString(nTens) + IntToString(nNum));
while(GetIsObjectValid(oTargetPoint))
{
ActionWait(fPause);
ActionMoveToObject(oTargetPoint, nRun);
nNum++;
if (nNum > 9)
{
nTens++;
nNum = 0;
}
// Maybe change string prefix to use.
sNewString = GetStringPrefix("NW_GENERIC_WALKWAYS");
if(sNewString != sWay)
{
sWay == sNewString;
}
oTargetPoint = GetWaypointByTag(sWay + GetTag(OBJECT_SELF) + "_" + IntToString(nTens) + IntToString(nNum));
}
// changes by two.
// once there are no more waypoints available, check if we are at our post
object oCurrentWP = oTargetPoint;
string sWayTag = GetStringPrefix("NW_GENERIC_POSTING") + GetTag(OBJECT_SELF);
oTargetPoint = GetNearestObjectByTag(sWayTag);
if(!GetIsObjectValid(oTargetPoint))
{
oTargetPoint = GetObjectByTag(sWayTag);
}
if(GetIsObjectValid(oTargetPoint) && GetDistanceToObject(oTargetPoint) > 0.0)
{
ActionForceMoveToObject(oTargetPoint, nRun, 1.0, 60.0);
float fFacing = GetFacing(oTargetPoint);
ActionDoCommand(SetFacing(fFacing));
return;
}
// no post, lets check if I shall walk in circles or walk back
else
{
sNewString = GetStringPrefix("NW_GENERIC_WALKWAYS");
if(sNewString != sWay)
{
sWay == sNewString;
}
sWayTag = sWay + GetTag(OBJECT_SELF) + "_01";
oTargetPoint = GetNearestObjectByTag(sWayTag);
if(!GetIsObjectValid(oTargetPoint))
{
oTargetPoint = GetObjectByTag(sWayTag);
}
if(GetIsObjectValid(oTargetPoint))
{
// If the first waypoint is actually nearby...return true to walk it again!
if(GetDistanceBetween(oTargetPoint, oCurrentWP) < 3.0 && GetDistanceBetween(oTargetPoint, oCurrentWP) >= 0.0)
{
return;// Stop and don't walk backwards.
}
else
{
nNum--;
if(nNum < 0)
{
nTens--;
nNum = 9;
}
// start the cycle again going back to point 01
oTargetPoint = GetWaypointByTag(sWay + GetTag(OBJECT_SELF) + "_" + IntToString(nTens) +IntToString(nNum));
while(GetIsObjectValid(oTargetPoint))
{
ActionWait(fPause);
ActionMoveToObject(oTargetPoint, nRun);
nNum--;
if (nNum < 0)
{
nTens--;
nNum = 9;
}
oTargetPoint = GetWaypointByTag(sWay + GetTag(OBJECT_SELF) + "_" + IntToString(nTens) +IntToString(nNum));
}
}
}
}
}
//::///////////////////////////////////////////////
//:: Check Walkways
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This function checks the passed in object to
see if they are supposed to be walking to
day or night postings.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Feb 26, 2002
//:://////////////////////////////////////////////
int CheckWayPoints(object oWalker)
{
object oWay1;
object oWay2;
object oWay3;
object oWay4;
string sTag = GetTag(oWalker);
oWay2 = GetWaypointByTag("NIGHT_" + sTag);
oWay4 = GetWaypointByTag("WN_" + sTag + "_01");
oWay1 = GetWaypointByTag("POST_" + sTag);
oWay3 = GetWaypointByTag("WP_" + sTag + "_01");
if(GetIsObjectValid(oWay1) || GetIsObjectValid(oWay3))
{
return TRUE;
}
return FALSE;
}
// Returns the string to use - depending on day or night.
string GetStringPrefix(string sPrefix, object oWalker)
{
if(GetIsDay() || GetIsDawn())
{
return GetLocalString(OBJECT_SELF, sPrefix + "_DAY");
}
else
{
return GetLocalString(OBJECT_SELF, sPrefix + "_NIGHT");
}
}
// Activate all auras.
int ActivateIfHas(int nAuraNumber)
{
if(GetHasSpell(nAuraNumber) && !GetHasSpellEffect(nAuraNumber))
{
ClearAllActions();
ActionCastSpellAtObject(nAuraNumber, OBJECT_SELF, METAMAGIC_ANY, FALSE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
return TRUE;
}
return FALSE;
}
void AdvancedAuras()
{
if(GetIsTalentValid(GetCreatureTalentBest(TALENT_CATEGORY_PERSISTENT_AREA_OF_EFFECT, 20)))
{
if(ActivateIfHas(SPELLABILITY_DRAGON_FEAR)) return;
if(ActivateIfHas(SPELLABILITY_AURA_UNEARTHLY_VISAGE)) return;
if(ActivateIfHas(SPELLABILITY_AURA_BLINDING)) return;;
if(ActivateIfHas(SPELLABILITY_AURA_OF_COURAGE)) return;
if(ActivateIfHas(SPELLABILITY_AURA_PROTECTION)) return;
if(ActivateIfHas(SPELLABILITY_AURA_STUN)) return;
if(ActivateIfHas(SPELLABILITY_AURA_FIRE)) return;
if(ActivateIfHas(SPELLABILITY_AURA_COLD)) return;
if(ActivateIfHas(SPELLABILITY_AURA_ELECTRICITY)) return;
if(ActivateIfHas(SPELLABILITY_AURA_UNNATURAL)) return;
if(ActivateIfHas(SPELLABILITY_AURA_FEAR)) return;
if(ActivateIfHas(SPELLABILITY_AURA_UNNATURAL)) return;
if(ActivateIfHas(SPELLABILITY_AURA_MENACE)) return;
}
}