Added PRC

Added PRC & imported new Level 2 WIP.  Slightly renamed module.  Full compile.
This commit is contained in:
Jaysyn904
2023-03-19 16:54:45 -04:00
parent 4c8755299f
commit e22f1e1bb8
106 changed files with 271260 additions and 23 deletions

View File

@@ -0,0 +1,13 @@
// prc_ondeath,nw_o0_death
/////////////////////////////////////////////////////////////////////
//
// This script has been auto-generated by HakInstaller to call
// multiple handlers for the onplayerdeath event.
//
/////////////////////////////////////////////////////////////////////
void main()
{
ExecuteScript("prc_ondeath", OBJECT_SELF);
ExecuteScript("nw_o0_death", OBJECT_SELF);
}

View File

@@ -0,0 +1,13 @@
// prc_ondying,nw_o0_dying
/////////////////////////////////////////////////////////////////////
//
// This script has been auto-generated by HakInstaller to call
// multiple handlers for the onplayerdying event.
//
/////////////////////////////////////////////////////////////////////
void main()
{
ExecuteScript("prc_ondying", OBJECT_SELF);
ExecuteScript("nw_o0_dying", OBJECT_SELF);
}

View File

@@ -0,0 +1,13 @@
// prc_onrespawn,nw_o0_respawn
/////////////////////////////////////////////////////////////////////
//
// This script has been auto-generated by HakInstaller to call
// multiple handlers for the onplayerrespawn event.
//
/////////////////////////////////////////////////////////////////////
void main()
{
ExecuteScript("prc_onrespawn", OBJECT_SELF);
ExecuteScript("nw_o0_respawn", OBJECT_SELF);
}

View File

@@ -0,0 +1,60 @@
//::///////////////////////////////////////////////
//:: NW_C2_BOSSDIE
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script fires when the boss monster dies.
It creates boss monster treasure on the creature.
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
#include "NW_O2_CONINCLUDE"
void main()
{
ExecuteScript("prc_npc_death", OBJECT_SELF);
ExecuteScript("prc_pwondeath", OBJECT_SELF);
object oKiller = GetLastKiller();
if (GetIsObjectValid(oKiller) == TRUE)
{
// * If I have a master then use him to determine the treasure
if (GetIsObjectValid(GetMaster(oKiller)) == TRUE)
{
oKiller = GetMaster(oKiller);
}
// * generate boss treasure
// * May 13 2002: For some reason death seems able to happen multiple
// * times. Made it so that the treasure will only spawn once
if (GetLocalInt(OBJECT_SELF, "NW_L_SPAWNTREASURE1X") == 0)
{
GenerateNPCTreasure(4, OBJECT_SELF, oKiller);
SetLocalInt(OBJECT_SELF, "NW_L_SPAWNTREASURE1X", 1);
}
}
else
AssignCommand(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC), SpeakString("No Killer!"));
int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
if(nClass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
{
object oKiller = GetLastKiller();
AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
}
SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}
}

View File

@@ -0,0 +1,80 @@
//::///////////////////////////////////////////////
//:: Custom On Spawn In
//:: nw_c2_bossspawn
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
This is the basic On Spawn Script for boss
monsters. This script allows bosses to
buff themselves before a PC can actually see
them.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: March 18, 2002
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
void main()
{
// OPTIONAL BEHAVIORS (Comment In or Out to Activate ) ****************************************************************************
//SetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION);
//SetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION);
// This causes the creature to say a special greeting in their conversation file
// upon Perceiving the player. Attach the [NW_D2_GenCheck.nss] script to the desired
// greeting in order to designate it. As the creature is actually saying this to
// himself, don't attach any player responses to the greeting.
//SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);
// This will set the listening pattern on the NPC to attack when allies call
//SetSpawnInCondition(NW_FLAG_STEALTH);
// If the NPC has stealth and they are a rogue go into stealth mode
//SetSpawnInCondition(NW_FLAG_SEARCH);
// If the NPC has Search go into Search Mode
//SetSpawnInCondition(NW_FLAG_SET_WARNINGS);
// This will set the NPC to give a warning to non-enemies before attacking
SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY);
//SetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING);
//SetSpawnInCondition(NW_FLAG_APPEAR_SPAWN_IN_ANIMATION);
//SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
//SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
//This will play Ambient Animations until the NPC sees an enemy or is cleared.
//NOTE that these animations will play automatically for Encounter Creatures.
// NOTE: ONLY ONE OF THE FOLOOWING ESCAPE COMMANDS SHOULD EVER BE ACTIVATED AT ANY ONE TIME.
//SetSpawnInCondition(NW_FLAG_ESCAPE_RETURN); // OPTIONAL BEHAVIOR (Flee to a way point and return a short time later.)
//SetSpawnInCondition(NW_FLAG_ESCAPE_LEAVE); // OPTIONAL BEHAVIOR (Flee to a way point and do not return.)
//SetSpawnInCondition(NW_FLAG_TELEPORT_LEAVE); // OPTIONAL BEHAVIOR (Teleport to safety and do not return.)
//SetSpawnInCondition(NW_FLAG_TELEPORT_RETURN); // OPTIONAL BEHAVIOR (Teleport to safety and return a short time later.)
// CUSTOM USER DEFINED EVENTS
/*
The following settings will allow the user to fire one of the blank user defined events in the NW_D2_DefaultD. Like the
On Spawn In script this script is meant to be customized by the end user to allow for unique behaviors. The user defined
events user 1000 - 1010
*/
//SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1001
//SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1002
//SetSpawnInCondition(NW_FLAG_ATTACK_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1005
//SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1006
//SetSpawnInCondition(NW_FLAG_DISTURBED_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1008
//SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1003
//SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1004
//SetSpawnInCondition(NW_FLAG_DEATH_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1007
// DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) *****************************************************************************************
SetListeningPatterns(); // Goes through and sets up which shouts the NPC will listen to.
WalkWayPoints(); // Optional Parameter: void WalkWayPoints(int nRun = FALSE, float fPause = 1.0)
// 1. Looks to see if any Way Points in the module have the tag "WP_" + NPC TAG + "_0X", if so walk them
// 2. If the tag of the Way Point is "POST_" + NPC TAG the creature will return this way point after
// combat.
// Boss monsters spawn treasure On Death not OnSpawn.
// GenerateNPCTreasure(); //* Use this to create a small amount of treasure on the creature
ExecuteScript("prc_pwonspawn", OBJECT_SELF);
ExecuteScript("prc_npc_spawn", OBJECT_SELF);
}

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));
}
}

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()
{
ExecuteScript("prc_npc_percep", OBJECT_SELF);
// * 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;
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));
}
}

View File

@@ -0,0 +1,92 @@
//:://////////////////////////////////////////////////
//:: 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()
{
ExecuteScript("prc_npc_conv", OBJECT_SELF);
// * 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();
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,71 @@
//::///////////////////////////////////////////////
//:: 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
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified On: Jan 4th, 2008
//:: Added Support for Mounted Combat Feat Support
//:://////////////////////////////////////////////
#include "nw_i0_generic"
void main()
{
ExecuteScript("prc_npc_physatt", OBJECT_SELF);
if (!GetLocalInt(GetModule(),"X3_NO_MOUNTED_COMBAT_FEAT"))
{ // set variables on target for mounted combat
SetLocalInt(OBJECT_SELF,"bX3_LAST_ATTACK_PHYSICAL",TRUE);
SetLocalInt(OBJECT_SELF,"nX3_HP_BEFORE",GetCurrentHitPoints(OBJECT_SELF));
} // set variables on target for mounted combat
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));
}
}

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;
}

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);
}
}
}