Updated for NWNEE 37-13. Updated NWNxEE scripts. CODI Core AI tweaks. Added Diamond Golem AI. Full compile. Updated release archive.
204 lines
6.4 KiB
Plaintext
204 lines
6.4 KiB
Plaintext
//:://////////////////////////////////////////////////
|
|
//:: 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 "prc_inc_spells"
|
|
#include "nw_i0_generic"
|
|
|
|
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);
|
|
|
|
//:: Run Special AIs
|
|
//:: Diamond Golem AI
|
|
int nDiamondGolem = GetStringLeft(GetTag(OBJECT_SELF), 13) == "WT_DIAMONDGOL" ? TRUE : FALSE;
|
|
if(nDiamondGolem)
|
|
{
|
|
ExecuteScript("diamond_golem_hb",OBJECT_SELF);
|
|
|
|
// Send the user-defined event signal if specified
|
|
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
|
|
{
|
|
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_HEARTBEAT));
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
|
|
//:: Declare major variables
|
|
|
|
object oNPC = OBJECT_SELF;
|
|
object oArea = GetArea(oNPC);
|
|
|
|
string sResRef = GetResRef(oNPC);
|
|
string sAreaResRef = GetResRef(oArea);
|
|
|
|
int nTrampleScore = (GetLocalInt(oNPC, "TRAMPLER") + GetHasFeat(FEAT_CENTAUR_TRAMPLE, oNPC));
|
|
|
|
int nChargeScore = (GetLocalInt(oNPC, "CHARGER") +
|
|
GetLocalInt(oNPC, "POUNCER") +
|
|
GetHasFeat(FEAT_MINOTAUR_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_ACROBATIC_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_SHIELD_CHARGE ,oNPC) +
|
|
GetHasFeat(FEAT_POWERFUL_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_GREATER_POWERFUL_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_RHINO_TRIBE_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_FURIOUS_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_RECKLESS_CHARGE, oNPC) +
|
|
GetHasFeat(FEAT_COBALT_CHARGE, oNPC));
|
|
|
|
int nBullRushScore = (GetLocalInt(oNPC, "BULLRUSHER") +
|
|
GetHasFeat(FEAT_IMPROVED_BULLRUSH, oNPC) +
|
|
GetHasFeat(FEAT_RAMPAGING_BULL_RUSH, oNPC) +
|
|
GetHasFeat(5241, oNPC) + //:: Expert Bull Rush
|
|
GetHasFeat(5247, oNPC)); //:: Superior Bull Rush
|
|
|
|
int iAwesomeBlow = GetHasFeat(FEAT_AWESOME_BLOW, oNPC);
|
|
|
|
int iOverrun = GetHasFeat(FEAT_IMPROVED_OVERRUN, oNPC);
|
|
|
|
if(GetHasEffect(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();
|
|
}
|
|
}
|
|
}
|
|
|
|
//:: Run Various Combat Maneuver Heartbeats
|
|
if(iOverrun)
|
|
{
|
|
if (GetLocalInt(oNPC, "OverrrunCooldown") != 1)
|
|
{
|
|
if(DEBUG) DoDebug( "x2_def_heartbeat: Creature w/ Overrun Detected");
|
|
DelayCommand(0.0f, ExecuteScript("overrunner_hb", oNPC));
|
|
}
|
|
else
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Overrun is on cooldown.");
|
|
}
|
|
if(iAwesomeBlow)
|
|
{
|
|
if (GetLocalInt(oNPC, "AwesomeBlowCooldown") != 1)
|
|
{
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Creature w/ Awesome Blow Detected");
|
|
DelayCommand(0.0f, ExecuteScript("awesomeblow_hb", oNPC));
|
|
}
|
|
else
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Awesome Blow is on cooldown.");
|
|
}
|
|
if(nTrampleScore)
|
|
{
|
|
if (GetLocalInt(oNPC, "TrampleCooldown") != 1)
|
|
{
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Trampler Detected");
|
|
DelayCommand(0.0f, ExecuteScript("trampler_hb", oNPC));
|
|
}
|
|
else
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Trample is on cooldown.");
|
|
}
|
|
if(nChargeScore)
|
|
{
|
|
if (GetLocalInt(oNPC, "ChargeCooldown") != 1)
|
|
{
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Charger Detected");
|
|
DelayCommand(0.0f, ExecuteScript("charger_hb", oNPC));
|
|
}
|
|
else
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Charge is on cooldown.");
|
|
}
|
|
if(nBullRushScore)
|
|
{
|
|
if (GetLocalInt(oNPC, "BullRushCooldown") != 1)
|
|
{
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Bull Rusher Detected");
|
|
DelayCommand(0.0f, ExecuteScript("bullrusher_hb", oNPC));
|
|
}
|
|
else
|
|
if(DEBUG) DoDebug("x2_def_heartbeat: Bull Rush is on cooldown.");
|
|
}
|
|
|
|
// Send the user-defined event signal if specified
|
|
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
|
|
{
|
|
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_HEARTBEAT));
|
|
}
|
|
} |