Initial Commit
Initial Commit [v1.32PRC8]
This commit is contained in:
207
_module/nss/nw_c2_default1.nss
Normal file
207
_module/nss/nw_c2_default1.nss
Normal file
@@ -0,0 +1,207 @@
|
||||
//:://////////////////////////////////////////////////
|
||||
//:: NW_C2_DEFAULT1
|
||||
/*
|
||||
Default OnHeartbeat script for NPCs.
|
||||
|
||||
This script causes NPCs to perform default animations
|
||||
while not otherwise engaged.
|
||||
|
||||
This script duplicates the behavior of the default
|
||||
script and just cleans up the code and removes
|
||||
redundant conditional checks.
|
||||
|
||||
*/
|
||||
//:://////////////////////////////////////////////////
|
||||
//:: Copyright (c) 2002 Floodgate Entertainment
|
||||
//:: Created By: Naomi Novik
|
||||
//:: Created On: 12/22/2002
|
||||
//:://////////////////////////////////////////////////
|
||||
|
||||
#include "nw_i0_generic"
|
||||
#include "prc_inc_spells"
|
||||
int MaxScoutSpots(string sTag);
|
||||
|
||||
void main()
|
||||
{
|
||||
// * if not runnning normal or better Ai then exit for performance reasons
|
||||
if (GetAILevel() == AI_LEVEL_VERY_LOW) return;
|
||||
|
||||
ExecuteScript("prc_npc_hb", OBJECT_SELF);
|
||||
|
||||
// Buff ourselves up right away if we should
|
||||
if(GetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY))
|
||||
{
|
||||
// This will return TRUE if an enemy was within 40.0 m
|
||||
// and we buffed ourselves up instantly to respond --
|
||||
// simulates a spellcaster with protections enabled
|
||||
// already.
|
||||
if(TalentAdvancedBuff(40.0))
|
||||
{
|
||||
// This is a one-shot deal
|
||||
SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY, FALSE);
|
||||
|
||||
// This return means we skip sending the user-defined
|
||||
// heartbeat signal in this one case.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(PRCGetHasEffect(EFFECT_TYPE_SLEEP))
|
||||
{
|
||||
// If we're asleep and this is the result of sleeping
|
||||
// at night, apply the floating 'z's visual effect
|
||||
// every so often
|
||||
|
||||
if(GetSpawnInCondition(NW_FLAG_SLEEPING_AT_NIGHT))
|
||||
{
|
||||
effect eVis = EffectVisualEffect(VFX_IMP_SLEEP);
|
||||
if(d10() > 6)
|
||||
{
|
||||
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we have the 'constant' waypoints flag set, walk to the next
|
||||
// waypoint.
|
||||
else if ( GetWalkCondition(NW_WALK_FLAG_CONSTANT) )
|
||||
{
|
||||
WalkWayPoints();
|
||||
}
|
||||
|
||||
// Check to see if we should be playing default animations
|
||||
// - make sure we don't have any current targets
|
||||
else if ( !GetIsObjectValid(GetAttemptedAttackTarget())
|
||||
&& !GetIsObjectValid(GetAttemptedSpellTarget())
|
||||
// && !GetIsPostOrWalking())
|
||||
&& !GetIsObjectValid(GetNearestSeenEnemy()))
|
||||
{
|
||||
if (GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL) || GetBehaviorState(NW_FLAG_BEHAVIOR_OMNIVORE) ||
|
||||
GetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE))
|
||||
{
|
||||
// This handles special attacking/fleeing behavior
|
||||
// for omnivores & herbivores.
|
||||
DetermineSpecialBehavior();
|
||||
}
|
||||
else if (!IsInConversation(OBJECT_SELF))
|
||||
{
|
||||
if (GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS)
|
||||
|| GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN)
|
||||
|| GetIsEncounterCreature())
|
||||
{
|
||||
PlayMobileAmbientAnimations();
|
||||
}
|
||||
else if (GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS))
|
||||
{
|
||||
PlayImmobileAmbientAnimations();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send the user-defined event signal if specified
|
||||
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
|
||||
{
|
||||
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_HEARTBEAT));
|
||||
}
|
||||
|
||||
location lLoc;
|
||||
int iRandom;
|
||||
int iRandom2;
|
||||
int iSpawnType;
|
||||
int iScouting;
|
||||
int iScoutSpots;
|
||||
string sTag;
|
||||
string sSubTag;
|
||||
|
||||
if (GetLocalInt(OBJECT_SELF,"Wander") > 0)
|
||||
{
|
||||
if (!(GetIsInCombat()))
|
||||
{
|
||||
iRandom = Random(10);
|
||||
if (iRandom < GetLocalInt(OBJECT_SELF,"Wander"))
|
||||
{
|
||||
iRandom2 = Random(10);
|
||||
if (GetLocalInt(OBJECT_SELF,"SpawnType") == 0)
|
||||
iRandom2++;
|
||||
if (iRandom2>0)
|
||||
{
|
||||
ActionRandomWalk();
|
||||
DelayCommand(6.0f,ClearAllActions());
|
||||
//SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF) + " moving random.");
|
||||
} else {
|
||||
sTag = GetTag(OBJECT_SELF);
|
||||
sSubTag=GetSubString(sTag,0,FindSubString(sTag,"_S"));
|
||||
lLoc = GetLocation(GetObjectByTag(sSubTag));
|
||||
ActionMoveToLocation(lLoc);
|
||||
//SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF) + " moving home.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GetLocalInt(OBJECT_SELF,"Scout") > 0)
|
||||
{
|
||||
if (!(GetIsInCombat()))
|
||||
{
|
||||
iRandom = Random(10);
|
||||
if (iRandom < GetLocalInt(OBJECT_SELF,"Scout"))
|
||||
{
|
||||
iScouting = GetLocalInt(OBJECT_SELF,"Scouting");
|
||||
sTag = GetTag(OBJECT_SELF);
|
||||
sSubTag=GetSubString(sTag,0,FindSubString(sTag,"_T"));
|
||||
iScoutSpots = MaxScoutSpots(sSubTag);
|
||||
if (iScoutSpots > 0)
|
||||
{
|
||||
iScouting++;
|
||||
if (iScouting > iScoutSpots + 2)
|
||||
iScouting = 1;
|
||||
|
||||
if (iScouting <= iScoutSpots)
|
||||
{
|
||||
sTag = sSubTag + "_Scout_" + IntToString(iScouting);
|
||||
}
|
||||
else if (iScouting = iScoutSpots+1)
|
||||
{
|
||||
sTag = GetTag(OBJECT_SELF);
|
||||
sSubTag=GetSubString(sTag,0,FindSubString(sTag,"_T"));
|
||||
sTag = sSubTag + "_Boss";
|
||||
}
|
||||
else
|
||||
{
|
||||
sTag = GetTag(OBJECT_SELF);
|
||||
sSubTag=GetSubString(sTag,0,FindSubString(sTag,"_S"));
|
||||
sTag = sSubTag;
|
||||
}
|
||||
|
||||
lLoc = GetLocation(GetObjectByTag(sTag));
|
||||
ActionMoveToLocation(lLoc);
|
||||
//SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF) + " is scouting.");
|
||||
SetLocalInt(OBJECT_SELF,"Scouting",iScouting);
|
||||
} else {
|
||||
ActionRandomWalk();
|
||||
DelayCommand(6.0f,ClearAllActions());
|
||||
//SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF) + " has no place to scout so is moving random.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MaxScoutSpots(string sTag)
|
||||
{
|
||||
int iCount;
|
||||
string sTagTest;
|
||||
|
||||
iCount = 0;
|
||||
sTag = sTag + "_Scout_";
|
||||
sTagTest = sTag + IntToString(iCount+1);
|
||||
|
||||
while (GetIsObjectValid(GetObjectByTag(sTagTest)))
|
||||
{
|
||||
iCount++;
|
||||
sTagTest = sTag + IntToString(iCount+1);
|
||||
}
|
||||
|
||||
return iCount;
|
||||
}
|
Reference in New Issue
Block a user