2025/07/21 Update

Added PEPS AI
Full compile.
This commit is contained in:
Jaysyn904
2025-07-21 13:02:25 -04:00
parent 2b252ba382
commit d36f15a2e4
1057 changed files with 45126 additions and 1197 deletions

107
_removed/nw_c2_default1.nss Normal file
View File

@@ -0,0 +1,107 @@
//:://////////////////////////////////////////////////
//:: 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"
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(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();
}
}
}
// Send the user-defined event signal if specified
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_HEARTBEAT));
}
}

166
_removed/nw_c2_default2.nss Normal file
View File

@@ -0,0 +1,166 @@
//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT2
/*
Default OnPerception event handler for NPCs.
Handles behavior when perceiving a creature for the
first time.
*/
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
void main()
{
// * if not runnning normal or better Ai then exit for performance reasons
// * if not runnning normal or better Ai then exit for performance reasons
if (GetAILevel() == AI_LEVEL_VERY_LOW) return;
ExecuteScript("prc_npc_percep", OBJECT_SELF);
object oPercep = GetLastPerceived();
int bSeen = GetLastPerceptionSeen();
int bHeard = GetLastPerceptionHeard();
if (bHeard == FALSE)
{
// Has someone vanished in front of me?
bHeard = GetLastPerceptionVanished();
}
// This will cause the NPC to speak their one-liner
// conversation on perception even if they are already
// in combat.
if(GetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION)
&& GetIsPC(oPercep)
&& bSeen)
{
SpeakOneLinerConversation();
}
// March 5 2003 Brent
// Had to add this section back in, since modifications were not taking this specific
// example into account -- it made invisibility basically useless.
//If the last perception event was hearing based or if someone vanished then go to search mode
if ((GetLastPerceptionVanished()) && GetIsEnemy(GetLastPerceived()))
{
object oGone = GetLastPerceived();
if((GetAttemptedAttackTarget() == GetLastPerceived() ||
GetAttemptedSpellTarget() == GetLastPerceived() ||
GetAttackTarget() == GetLastPerceived()) && GetArea(GetLastPerceived()) != GetArea(OBJECT_SELF))
{
ClearAllActions();
DetermineCombatRound();
}
}
// This section has been heavily revised while keeping the
// pre-existing behavior:
// - If we're in combat, keep fighting.
// - If not and we've perceived an enemy, start to fight.
// Even if the perception event was a 'vanish', that's
// still what we do anyway, since that will keep us
// fighting any visible targets.
// - If we're not in combat and haven't perceived an enemy,
// see if the perception target is a PC and if we should
// speak our attention-getting one-liner.
if (GetIsInCombat(OBJECT_SELF))
{
// don't do anything else, we're busy
//MyPrintString("GetIsFighting: TRUE");
}
// * BK FEB 2003 Only fight if you can see them. DO NOT RELY ON HEARING FOR ENEMY DETECTION
else if (GetIsEnemy(oPercep) && bSeen)
{ // SpawnScriptDebugger();
//MyPrintString("GetIsEnemy: TRUE");
// We spotted an enemy and we're not already fighting
if(!GetHasEffect(EFFECT_TYPE_SLEEP)) {
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
{
//MyPrintString("DetermineSpecialBehavior");
DetermineSpecialBehavior();
} else
{
//MyPrintString("DetermineCombatRound");
SetFacingPoint(GetPosition(oPercep));
SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
DetermineCombatRound();
}
}
}
else
{
if (bSeen)
{
//MyPrintString("GetLastPerceptionSeen: TRUE");
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)) {
DetermineSpecialBehavior();
} else if (GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION)
&& GetIsPC(oPercep))
{
// The NPC will speak their one-liner conversation
// This should probably be:
// SpeakOneLinerConversation(oPercep);
// instead, but leaving it as is for now.
ActionStartConversation(OBJECT_SELF);
}
}
else
// * July 14 2003: Some minor reactions based on invisible creatures being nearby
if (bHeard && GetIsEnemy(oPercep))
{
// SpeakString("vanished");
// * don't want creatures wandering too far after noises
if (GetDistanceToObject(oPercep) <= 7.0)
{
// if (GetHasSpell(SPELL_TRUE_SEEING) == TRUE)
if (GetHasSpell(SPELL_TRUE_SEEING))
{
ActionCastSpellAtObject(SPELL_TRUE_SEEING, OBJECT_SELF);
}
else
// if (GetHasSpell(SPELL_SEE_INVISIBILITY) == TRUE)
if (GetHasSpell(SPELL_SEE_INVISIBILITY))
{
ActionCastSpellAtObject(SPELL_SEE_INVISIBILITY, OBJECT_SELF);
}
else
// if (GetHasSpell(SPELL_INVISIBILITY_PURGE) == TRUE)
if (GetHasSpell(SPELL_INVISIBILITY_PURGE))
{
ActionCastSpellAtObject(SPELL_INVISIBILITY_PURGE, OBJECT_SELF);
}
else
{
ActionPlayAnimation(ANIMATION_FIREFORGET_HEAD_TURN_LEFT, 0.5);
ActionPlayAnimation(ANIMATION_FIREFORGET_HEAD_TURN_RIGHT, 0.5);
ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD, 0.5);
}
}
}
// activate ambient animations or walk waypoints if appropriate
if (!IsInConversation(OBJECT_SELF)) {
if (GetIsPostOrWalking()) {
WalkWayPoints();
} else if (GetIsPC(oPercep) &&
(GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS)
|| GetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS_AVIAN)
|| GetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS)
|| GetIsEncounterCreature()))
{
SetAnimationCondition(NW_ANIM_FLAG_IS_ACTIVE);
}
}
}
// Send the user-defined event if appropriate
if(GetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT) && GetLastPerceptionSeen())
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_PERCEIVE));
}
}

View File

@@ -0,0 +1,58 @@
//::///////////////////////////////////////////////
//:: Default: End of Combat Round
//:: NW_C2_DEFAULT3
//:: Copyright (c) 2008 Bioware Corp.
//:://////////////////////////////////////////////
/*
Calls the end of combat script every round
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 16, 2001
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: Feb 16th, 2008
//:: Added Support for Mounted Combat Feat Support
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
void main()
{
ExecuteScript("prc_npc_combat", OBJECT_SELF);
if (!GetLocalInt(GetModule(),"X3_NO_MOUNTED_COMBAT_FEAT"))
{ // set variables on target for mounted combat
DeleteLocalInt(OBJECT_SELF,"bX3_LAST_ATTACK_PHYSICAL");
DeleteLocalInt(OBJECT_SELF,"nX3_HP_BEFORE");
DeleteLocalInt(OBJECT_SELF,"bX3_ALREADY_MOUNTED_COMBAT");
if (GetHasFeat(FEAT_MOUNTED_COMBAT,OBJECT_SELF))
{ // check for AC increase
int nRoll=d20()+GetSkillRank(SKILL_RIDE);
nRoll=nRoll-10;
if (nRoll>4)
{ // ac increase
nRoll=nRoll/5;
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectACIncrease(nRoll),OBJECT_SELF,8.5);
} // ac increase
} // check for AC increase
} // set variables on target for mounted combat
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
{
DetermineSpecialBehavior();
}
else if(!GetSpawnInCondition(NW_FLAG_SET_WARNINGS))
{
DetermineCombatRound();
}
if(GetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1003));
}
}

108
_removed/nw_c2_default4.nss Normal file
View File

@@ -0,0 +1,108 @@
//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT4
/*
Default OnConversation event handler for NPCs.
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
void main()
{
// * if petrified, jump out
if (GetHasEffect(EFFECT_TYPE_PETRIFY, OBJECT_SELF) == TRUE)
{
return;
}
// * If dead, exit directly.
if (GetIsDead(OBJECT_SELF) == TRUE)
{
return;
}
// See if what we just 'heard' matches any of our
// predefined patterns
int nMatch = GetListenPatternNumber();
object oShouter = GetLastSpeaker();
//DMFI CODE ADDITIONS BEGIN HERE
if (GetIsPC(oShouter))
{
ExecuteScript("dmfi_voice_exe", OBJECT_SELF);
}
if (nMatch == -1 && GetIsPC(oShouter) &&(GetLocalInt(GetModule(), "dmfi_AllMute") || GetLocalInt(OBJECT_SELF, "dmfi_Mute")))
{
SendMessageToAllDMs(GetName(oShouter) + " is trying to speak to a muted NPC, " + GetName(OBJECT_SELF) + ", in area " + GetName(GetArea(OBJECT_SELF)));
SendMessageToPC(oShouter, "This NPC is muted. A DM will be here shortly.");
return;
}
//DMFI CODE ADDITIONS END HERE
if (nMatch == -1)
{
// Not a match -- start an ordinary conversation
if (GetCommandable(OBJECT_SELF))
{
ClearActions(CLEAR_NW_C2_DEFAULT4_29);
BeginConversation();
}
else
// * July 31 2004
// * If only charmed then allow conversation
// * so you can have a better chance of convincing
// * people of lowering prices
if (GetHasEffect(EFFECT_TYPE_CHARMED) == TRUE)
{
ClearActions(CLEAR_NW_C2_DEFAULT4_29);
BeginConversation();
}
}
// Respond to shouts from friendly non-PCs only
else if (GetIsObjectValid(oShouter)
&& !GetIsPC(oShouter)
&& GetIsFriend(oShouter))
{
object oIntruder = OBJECT_INVALID;
// Determine the intruder if any
if(nMatch == 4)
{
oIntruder = GetLocalObject(oShouter, "NW_BLOCKER_INTRUDER");
}
else if (nMatch == 5)
{
oIntruder = GetLastHostileActor(oShouter);
if(!GetIsObjectValid(oIntruder))
{
oIntruder = GetAttemptedAttackTarget();
if(!GetIsObjectValid(oIntruder))
{
oIntruder = GetAttemptedSpellTarget();
if(!GetIsObjectValid(oIntruder))
{
oIntruder = OBJECT_INVALID;
}
}
}
}
// Actually respond to the shout
RespondToShout(oShouter, nMatch, oIntruder);
}
// Send the user-defined event if appropriate
if(GetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DIALOGUE));
}
}

View File

@@ -0,0 +1,93 @@
//::///////////////////////////////////////////////
//:: Default On Attacked
//:: NW_C2_DEFAULT5
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
If already fighting then ignore, else determine
combat round
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 16, 2001
//:://////////////////////////////////////////////
#include "nw_i0_generic"
//DMFI CODE ADDITIONS*****************************
void SafeFaction(object oCurrent, object oAttacker)
{
AssignCommand(oAttacker, ClearAllActions());
AssignCommand(oCurrent, ClearAllActions());
// * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oAttacker) <= 10)
{ SetLocalInt(oAttacker, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oAttacker);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oAttacker) <= 10)
{ SetLocalInt(oAttacker, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oAttacker);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oAttacker) <= 10)
{ SetLocalInt(oAttacker, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oAttacker);
}
}
//END DMFI CODE ADDITIONS*************************
void main()
{
//DMFI CODE ADDITIONS*****************************
if ((GetIsPC(GetLastAttacker()) && (GetLocalInt(GetModule(), "dmfi_safe_factions")==1)))
{
SafeFaction(OBJECT_SELF, GetLastAttacker());
SpeakString("DM ALERT: Default non-hostile faction member attacked. Player: "+GetName(GetLastAttacker()), TALKVOLUME_SILENT_SHOUT);
SendMessageToAllDMs("DMFI Safe Faction setting is currently set to ignore.");
SendMessageToPC(GetLastAttacker(), "Script Fired.");
return;
}
//END DMFI CODE ADDITIONS****************************
if(GetFleeToExit()) {
// Run away!
ActivateFleeToExit();
} else if (GetSpawnInCondition(NW_FLAG_SET_WARNINGS)) {
// We give an attacker one warning before we attack
// This is not fully implemented yet
SetSpawnInCondition(NW_FLAG_SET_WARNINGS, FALSE);
//Put a check in to see if this attacker was the last attacker
//Possibly change the GetNPCWarning function to make the check
} else {
object oAttacker = GetLastAttacker();
if (!GetIsObjectValid(oAttacker)) {
// Don't do anything, invalid attacker
} else if (!GetIsFighting(OBJECT_SELF)) {
// We're not fighting anyone else, so
// start fighting the attacker
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)) {
SetSummonHelpIfAttacked();
DetermineSpecialBehavior(oAttacker);
} else if (GetArea(oAttacker) == GetArea(OBJECT_SELF)) {
SetSummonHelpIfAttacked();
DetermineCombatRound(oAttacker);
}
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
//Shout that I was attacked
SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
}
}
if(GetSpawnInCondition(NW_FLAG_ATTACK_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_ATTACKED));
}
}

109
_removed/nw_c2_default6.nss Normal file
View File

@@ -0,0 +1,109 @@
//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT6
//:: Default OnDamaged handler
/*
If already fighting then ignore, else determine
combat round
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//:://////////////////////////////////////////////////
//:://////////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: Jan 17th, 2008
//:: Added Support for Mounted Combat Feat Support
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
#include "x3_inc_horse"
void main()
{
ExecuteScript("prc_npc_damaged", OBJECT_SELF);
object oDamager = GetLastDamager();
object oMe=OBJECT_SELF;
int nHPBefore;
if (!GetLocalInt(GetModule(),"X3_NO_MOUNTED_COMBAT_FEAT"))
if (GetHasFeat(FEAT_MOUNTED_COMBAT)&&HorseGetIsMounted(OBJECT_SELF))
{ // see if can negate some damage
if (GetLocalInt(OBJECT_SELF,"bX3_LAST_ATTACK_PHYSICAL"))
{ // last attack was physical
nHPBefore=GetLocalInt(OBJECT_SELF,"nX3_HP_BEFORE");
if (!GetLocalInt(OBJECT_SELF,"bX3_ALREADY_MOUNTED_COMBAT"))
{ // haven't already had a chance to use this for the round
SetLocalInt(OBJECT_SELF,"bX3_ALREADY_MOUNTED_COMBAT",TRUE);
int nAttackRoll=GetBaseAttackBonus(oDamager)+d20();
int nRideCheck=GetSkillRank(SKILL_RIDE,OBJECT_SELF)+d20();
if (nRideCheck>=nAttackRoll&&!GetIsDead(OBJECT_SELF))
{ // averted attack
if (GetIsPC(oDamager)) SendMessageToPC(oDamager,GetName(OBJECT_SELF)+GetStringByStrRef(111991));
//if (GetIsPC(OBJECT_SELF)) SendMessageToPCByStrRef(OBJECT_SELF,111992");
if (GetCurrentHitPoints(OBJECT_SELF)<nHPBefore)
{ // heal
effect eHeal=EffectHeal(nHPBefore-GetCurrentHitPoints(OBJECT_SELF));
AssignCommand(GetModule(),ApplyEffectToObject(DURATION_TYPE_INSTANT,eHeal,oMe));
} // heal
} // averted attack
} // haven't already had a chance to use this for the round
} // last attack was physical
} // see if can negate some damage
if(GetFleeToExit()) {
// We're supposed to run away, do nothing
} else if (GetSpawnInCondition(NW_FLAG_SET_WARNINGS)) {
// don't do anything?
} else {
if (!GetIsObjectValid(oDamager)) {
// don't do anything, we don't have a valid damager
} else if (!GetIsFighting(OBJECT_SELF)) {
// If we're not fighting, determine combat round
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)) {
DetermineSpecialBehavior(oDamager);
} else {
if(!GetObjectSeen(oDamager)
&& GetArea(OBJECT_SELF) == GetArea(oDamager)) {
// We don't see our attacker, go find them
ActionMoveToLocation(GetLocation(oDamager), TRUE);
ActionDoCommand(DetermineCombatRound());
} else {
DetermineCombatRound();
}
}
} else {
// We are fighting already -- consider switching if we've been
// attacked by a more powerful enemy
object oTarget = GetAttackTarget();
if (!GetIsObjectValid(oTarget))
oTarget = GetAttemptedAttackTarget();
if (!GetIsObjectValid(oTarget))
oTarget = GetAttemptedSpellTarget();
// If our target isn't valid
// or our damager has just dealt us 25% or more
// of our hp in damager
// or our damager is more than 2HD more powerful than our target
// switch to attack the damager.
if (!GetIsObjectValid(oTarget)
|| (
oTarget != oDamager
&& (
GetTotalDamageDealt() > (GetMaxHitPoints(OBJECT_SELF) / 4)
|| (GetHitDice(oDamager) - 2) > GetHitDice(oTarget)
)
)
)
{
// Switch targets
DetermineCombatRound(oDamager);
}
}
}
// Send the user-defined event signal
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DAMAGED));
}
}

View File

@@ -0,0 +1,30 @@
//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT8
/*
Default OnDisturbed event handler for NPCs.
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
void main()
{
ExecuteScript("prc_npc_disturb", OBJECT_SELF);
object oTarget = GetLastDisturbed();
// If we've been disturbed and are not already fighting,
// attack our disturber.
if (GetIsObjectValid(oTarget) && !GetIsFighting(OBJECT_SELF)) {
DetermineCombatRound(oTarget);
}
// Send the disturbed flag if appropriate.
if(GetSpawnInCondition(NW_FLAG_DISTURBED_EVENT)) {
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DISTURBED));
}
}

View File

@@ -0,0 +1,20 @@
//::///////////////////////////////////////////////
//:: Default: On Rested
//:: NW_C2_DEFAULTA
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
Determines the course of action to be taken
after having just rested.
*/
//:://////////////////////////////////////////////
//:: Created By: Don Moar
//:: Created On: April 28, 2002
//:://////////////////////////////////////////////
void main()
{
ExecuteScript("prc_npc_rested", OBJECT_SELF);
return;
}

159
_removed/nw_c2_defaultb.nss Normal file
View File

@@ -0,0 +1,159 @@
//::///////////////////////////////////////////////
//:: Default: On Spell Cast At
//:: NW_C2_DEFAULTB
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This determines if the spell just cast at the
target is harmful or not.
GZ 2003-Oct-02 : - New AoE Behavior AI. Will use
Dispel Magic against AOES
- Flying Creatures will ignore
Grease
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Dec 6, 2001
//:: Last Modified On: 2003-Oct-13
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: Jan 4th, 2008
//:: Added Support for Mounted Combat Feat Support
//:://////////////////////////////////////////////
#include "nw_i0_generic"
#include "x2_i0_spells"
void main()
{
ExecuteScript("prc_npc_spellat", OBJECT_SELF);
object oCaster = GetLastSpellCaster();
if(GetLastSpellHarmful())
{
SetCommandable(TRUE);
if (!GetLocalInt(GetModule(),"X3_NO_MOUNTED_COMBAT_FEAT"))
{ // set variables on target for mounted combat
DeleteLocalInt(OBJECT_SELF,"bX3_LAST_ATTACK_PHYSICAL");
} // set variables on target for mounted combat
// ------------------------------------------------------------------
// If I was hurt by someone in my own faction
// Then clear any hostile feelings I have against them
// After all, we're all just trying to do our job here
// if we singe some eyebrow hair, oh well.
// ------------------------------------------------------------------
if (GetFactionEqual(oCaster, OBJECT_SELF) == TRUE)
{
ClearPersonalReputation(oCaster, OBJECT_SELF);
ClearAllActions(TRUE);
DelayCommand(1.2, ActionDoCommand(DetermineCombatRound(OBJECT_INVALID)));
// Send the user-defined event as appropriate
if(GetSpawnInCondition(NW_FLAG_SPELL_CAST_AT_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_SPELL_CAST_AT));
}
return;
}
int bAttack = TRUE;
// ------------------------------------------------------------------
// GZ, 2003-Oct-02
// Try to do something smart if we are subject to an AoE Spell.
// ------------------------------------------------------------------
if (MatchAreaOfEffectSpell(GetLastSpell()) == TRUE)
{
int nAI = (GetBestAOEBehavior(GetLastSpell())); // from x2_i0_spells
switch (nAI)
{
case X2_SPELL_AOEBEHAVIOR_DISPEL_L:
case X2_SPELL_AOEBEHAVIOR_DISPEL_N:
case X2_SPELL_AOEBEHAVIOR_DISPEL_M:
case X2_SPELL_AOEBEHAVIOR_DISPEL_G:
case X2_SPELL_AOEBEHAVIOR_DISPEL_C:
bAttack = FALSE;
ActionCastSpellAtLocation(nAI, GetLocation(OBJECT_SELF));
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
break;
case X2_SPELL_AOEBEHAVIOR_FLEE:
ClearActions(CLEAR_NW_C2_DEFAULTB_GUSTWIND);
oCaster = GetLastSpellCaster();
ActionForceMoveToObject(oCaster, TRUE, 2.0);
DelayCommand(1.2, ActionDoCommand(DetermineCombatRound(oCaster)));
bAttack = FALSE;
break;
case X2_SPELL_AOEBEHAVIOR_IGNORE:
// well ... nothing
break;
case X2_SPELL_AOEBEHAVIOR_GUST:
ActionCastSpellAtLocation(SPELL_GUST_OF_WIND, GetLocation(OBJECT_SELF));
ActionDoCommand(SetCommandable(TRUE));
SetCommandable(FALSE);
bAttack = FALSE;
break;
}
}
// ---------------------------------------------------------------------
// Not an area of effect spell, but another hostile spell.
// If we're not already fighting someone else,
// attack the caster.
// ---------------------------------------------------------------------
if( !GetIsFighting(OBJECT_SELF) && bAttack)
{
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
{
DetermineSpecialBehavior(oCaster);
}
else
{
DetermineCombatRound(oCaster);
}
}
// We were attacked, so yell for help
SetCommandable(TRUE);
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
//Shout that I was attacked
SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
}
else
{
// ---------------------------------------------------------------------
// July 14, 2003 BK
// If there is a valid enemy nearby and a NON HARMFUL spell has been
// cast on me I should call DetermineCombatRound
// I may be invisible and casting spells on myself to buff myself up
// ---------------------------------------------------------------------
// Fix: JE - let's only do this if I'm currently in combat. If I'm not
// in combat, and something casts a spell on me, it'll make me search
// out the nearest enemy, no matter where they are on the level, which
// is kinda dumb.
object oEnemy =GetNearestEnemy();
if ((GetIsObjectValid(oEnemy) == TRUE) && (GetIsInCombat() == TRUE))
{
// SpeakString("keep me in combat");
DetermineCombatRound(oEnemy);
}
}
// Send the user-defined event as appropriate
if(GetSpawnInCondition(NW_FLAG_SPELL_CAST_AT_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_SPELL_CAST_AT));
}
}

View File

@@ -0,0 +1,51 @@
//::///////////////////////////////////////////////
//:: Default On Blocked
//:: NW_C2_DEFAULTE
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This will cause blocked creatures to open
or smash down doors depending on int and
str.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 23, 2001
//:://////////////////////////////////////////////
void main()
{
ExecuteScript("prc_npc_blocked", OBJECT_SELF);
object oDoor = GetBlockingDoor();
if (GetObjectType(oDoor) == OBJECT_TYPE_CREATURE)
{
// * Increment number of times blocked
/*SetLocalInt(OBJECT_SELF, "X2_NUMTIMES_BLOCKED", GetLocalInt(OBJECT_SELF, "X2_NUMTIMES_BLOCKED") + 1);
if (GetLocalInt(OBJECT_SELF, "X2_NUMTIMES_BLOCKED") > 3)
{
SpeakString("Blocked by creature");
SetLocalInt(OBJECT_SELF, "X2_NUMTIMES_BLOCKED",0);
ClearAllActions();
object oEnemy = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
if (GetIsObjectValid(oEnemy) == TRUE)
{
ActionEquipMostDamagingRanged(oEnemy);
ActionAttack(oEnemy);
}
return;
} */
return;
}
if(GetAbilityScore(OBJECT_SELF, ABILITY_INTELLIGENCE) >= 5)
{
if(GetIsDoorActionPossible(oDoor, DOOR_ACTION_OPEN) && GetAbilityScore(OBJECT_SELF, ABILITY_INTELLIGENCE) >= 7 )
{
DoDoorAction(oDoor, DOOR_ACTION_OPEN);
}
else if(GetIsDoorActionPossible(oDoor, DOOR_ACTION_BASH))
{
DoDoorAction(oDoor, DOOR_ACTION_BASH);
}
}
}

75
_removed/nw_ch_ac4.nss Normal file
View File

@@ -0,0 +1,75 @@
//::///////////////////////////////////////////////
//:: Associate: On Dialogue
//:: NW_CH_AC4
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Determines the course of action to be taken
by the generic script after dialogue or a
shout is initiated.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 24, 2001
//:://////////////////////////////////////////////
#include "x0_inc_henai"
// * This function checks to make sure no
// * dehibilating effects are on the player that should
// * Don't use getcommandable for this since the dying system
// * will sometimes leave a player in a noncommandable state
int AbleToTalk(object oSelf)
{
if (GetCommandable(oSelf) == FALSE)
{
if (GetHasEffect(EFFECT_TYPE_CONFUSED, oSelf) || GetHasEffect(EFFECT_TYPE_DOMINATED, oSelf) ||
GetHasEffect(EFFECT_TYPE_PETRIFY, oSelf) || GetHasEffect(EFFECT_TYPE_PARALYZE, oSelf) ||
GetHasEffect(EFFECT_TYPE_STUNNED, oSelf) || GetHasEffect(EFFECT_TYPE_FRIGHTENED, oSelf)
)
{
return FALSE;
}
}
return TRUE;
}
void main()
{
object oMaster = GetMaster();
int nMatch = GetListenPatternNumber();
object oShouter = GetLastSpeaker();
object oIntruder;
//DMFI CODE ADDITIONS BEGIN HERE
if (!GetIsInCombat(OBJECT_SELF))
ExecuteScript("dmfi_voice_exe", OBJECT_SELF);
//DMFI CODE ADDITIONS END HERE
if (nMatch == -1) {
if(AbleToTalk(OBJECT_SELF) || GetCurrentAction() != ACTION_OPENLOCK)
{
ClearActions(CLEAR_NW_CH_AC4_28);
// * if in XP2, use an alternative dialog file
string sDialog = "";
if (GetLocalInt(GetModule(), "X2_L_XP2") == 1)
{
sDialog = "x2_associate";
}
BeginConversation(sDialog);
}
} else {
// listening pattern matched
if (GetIsObjectValid(oShouter) && oMaster == oShouter)
{
SetCommandable(TRUE);
bkRespondToHenchmenShout(oShouter, nMatch, oIntruder, TRUE);
}
}
// Signal user-defined event
if(GetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT)) {
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DIALOGUE));
}
}

View File

@@ -0,0 +1,67 @@
//::///////////////////////////////////////////////
//:: Associate: On Spawn In
//:: NW_CH_AC9
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This must support the OC henchmen and all summoned/companion
creatures.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 19, 2001
//:://////////////////////////////////////////////
//:: Updated By: Georg Zoeller, 2003-08-20: Added variable check for spawn in animation
#include "X0_INC_HENAI"
#include "x2_inc_switches"
void main()
{
//Sets up the special henchmen listening patterns
SetAssociateListenPatterns();
// Set additional henchman listening patterns
bkSetListeningPatterns();
//DMFI CODE ADDITIONS BEGIN HERE
SetListening(OBJECT_SELF, TRUE);
SetListenPattern(OBJECT_SELF, "**", 20600); //listen to all text
SetLocalInt(OBJECT_SELF, "hls_Listening", 1); //listen to all text
//DMFI CODE ADDITIONS END HERE
// Default behavior for henchmen at start
SetAssociateState(NW_ASC_POWER_CASTING);
SetAssociateState(NW_ASC_HEAL_AT_50);
SetAssociateState(NW_ASC_RETRY_OPEN_LOCKS);
SetAssociateState(NW_ASC_DISARM_TRAPS);
SetAssociateState(NW_ASC_MODE_DEFEND_MASTER, FALSE);
//Use melee weapons by default
SetAssociateState(NW_ASC_USE_RANGED_WEAPON, FALSE);
// Distance: make henchmen stick closer
SetAssociateState(NW_ASC_DISTANCE_4_METERS);
if (GetAssociate(ASSOCIATE_TYPE_HENCHMAN, GetMaster()) == OBJECT_SELF) {
SetAssociateState(NW_ASC_DISTANCE_2_METERS);
}
// * If Incorporeal, apply changes
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_IS_INCORPOREAL) == TRUE)
{
effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
eConceal = ExtraordinaryEffect(eConceal);
effect eGhost = EffectCutsceneGhost();
eGhost = ExtraordinaryEffect(eGhost);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eConceal, OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGhost, OBJECT_SELF);
}
// Set starting location
SetAssociateStartLocation();
}