HoS_PRC8/_mod/_module/nss/nw_c2_default2.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

241 lines
9.2 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Default On Percieve
//:: NW_C2_DEFAULT2
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Checks to see if the perceived target is an
enemy and if so fires the Determine Combat
Round function
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 16, 2001
//:://////////////////////////////////////////////
#include "cai_inc_hos"
#include "NW_I0_GENERIC"
#include "inc_utility"
void fnEnemiesAroundStill()
{
object oEn=GetNearestCreature(CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN,OBJECT_SELF,1,CREATURE_TYPE_IS_ALIVE,TRUE);
int nMState=GetLocalInt(OBJECT_SELF,"nMState");
if (oEn==OBJECT_INVALID)
{ // tone the AI level down if no PC is present
oEn=GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC);
if (oEn==OBJECT_INVALID)
{ // no PC present
if((nMState==0||nMState==7)&&GetStringLength(GetLocalString(OBJECT_SELF,"sTeamID"))<2)
SetAILevel(OBJECT_SELF,AI_LEVEL_VERY_LOW);
else if (GetStringLength(GetLocalString(OBJECT_SELF,"sTeamID"))>1)
SetAILevel(OBJECT_SELF,AI_LEVEL_LOW);
} // no PC present
} // tone the AI level down if no PC is present
else
DelayCommand(12.0,fnEnemiesAroundStill());
} // fnEnemiesAroundStill()
void main()
{
//ExecuteScript("prc_npc_percep", OBJECT_SELF);
object oMe=OBJECT_SELF;
string sType;
//This is the equivalent of a force conversation bubble, should only be used if you want an NPC
//to say something while he is already engaged in combat.
if (GetIsEnemy(GetLastPerceived())==TRUE)
{ // enemies only
if(GetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION) && GetIsPC(GetLastPerceived()) && GetLastPerceptionSeen())
{
SpeakOneLinerConversation();
}
//If the last perception event was hearing based or if someone vanished then go to search mode
if (GetIsPC(GetLastPerceived())==TRUE)
{
/*if (GetStringLength(GetLocalString(OBJECT_SELF,"sTeamID"))>1)
{
SetAILevel(OBJECT_SELF,AI_LEVEL_NORMAL);
DelayCommand(12.0,fnEnemiesAroundStill());
} */
}
if ((GetLastPerceptionVanished()) && GetIsEnemy(GetLastPerceived()))
{
object oGone = GetLastPerceived();
if((GetAttemptedAttackTarget() == GetLastPerceived() ||
GetAttemptedSpellTarget() == GetLastPerceived() ||
GetAttackTarget() == GetLastPerceived()) && GetArea(GetLastPerceived()) != GetArea(OBJECT_SELF))
{
ClearAllActions();
/*if (GetStringLength(GetLocalString(OBJECT_SELF,"sTeamID"))>1)
{
SetAILevel(OBJECT_SELF,AI_LEVEL_NORMAL);
DelayCommand(12.0,fnEnemiesAroundStill());
} */
if (GetLocalInt(GetModule(),"bCOMBAT_AI_OFF")!=TRUE&&GetLocalInt(oMe,"bCOMBAT_AI_ON")==TRUE)
{ // Combat AI is turned on for the module and NPC
sType=GetLocalString(oMe,"sCOMBAT_AI_TYPE");
sType=GetStringLowerCase(sType);
if (sType=="melee")
{ // melee combat
ExecuteScript("cai_melee",oMe);
} // melee combat
else if (sType=="ranged")
{ // ranged combat
ExecuteScript("cai_ranged",oMe);
} // ranged combat
else if (sType=="stealth")
{ // stealth combat
ExecuteScript("cai_stealth",oMe);
} // stealth combat
else if (sType=="support")
{ // support role such as healing and buffing
ExecuteScript("cai_support",oMe);
} // support role such as healing and buffing
else if (sType=="summon")
{ // summoner type caster
ExecuteScript("cai_summon",oMe);
} // summoner type caster
else if (sType=="caster")
{ // spell caster
ExecuteScript("cai_caster",oMe);
} // spell caster
else if (sType=="flee")
{ // try not to get hurt under any circumstance
ExecuteScript("cai_flee",oMe);
} // try not to get hurt under any circumstance
else if (sType=="hold")
{ // hold where you are
ExecuteScript("cai_hold",oMe);
} // hold where you are
else
{ // based on weapon holding and skill
if (GetSkillRank(SKILL_HIDE,oMe)>10)
{ // stealth
ExecuteScript("cai_stealth",oMe);
} // stealth
else if (caiGetEquippedWeaponType(oMe,INVENTORY_SLOT_RIGHTHAND)==CAI_WEAPON_RANGED)
{ // ranged
ExecuteScript("cai_ranged",oMe);
} // ranged
else if (caiGetIsArcane(oMe))
{ // caster - wizard/sorcerer
ExecuteScript("cai_caster",oMe);
} // caster - wizard/sorcerer
else if (caiGetIsCleric(oMe))
{ // support - cleric
ExecuteScript("cai_support",oMe);
} // support - cleric
else
{ // melee
ExecuteScript("cai_melee",oMe);
} // melee
} // based on weapon holding and skill
} // Combat AI is turned on for the module and NPC
else
{ // standard combat
DetermineCombatRound();
} // standard combat
}
}
//Do not bother checking the last target seen if already fighting
else if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
{
//Check if the last percieved creature was actually seen
if(GetLastPerceptionSeen())
{
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
{
DetermineSpecialBehavior();
}
else if(GetIsEnemy(GetLastPerceived()))
{
/*if (GetStringLength(GetLocalString(OBJECT_SELF,"sTeamID"))>1)
{
SetAILevel(OBJECT_SELF,AI_LEVEL_NORMAL);
DelayCommand(12.0,fnEnemiesAroundStill());
} */
if(!PRCGetHasEffect(EFFECT_TYPE_SLEEP))
{
SetFacingPoint(GetPosition(GetLastPerceived()));
SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
if (GetLocalInt(GetModule(),"bCOMBAT_AI_OFF")!=TRUE&&GetLocalInt(oMe,"bCOMBAT_AI_ON")==TRUE)
{ // Combat AI is turned on for the module and NPC
sType=GetLocalString(oMe,"sCOMBAT_AI_TYPE");
sType=GetStringLowerCase(sType);
if (sType=="melee")
{ // melee combat
ExecuteScript("cai_melee",oMe);
} // melee combat
else if (sType=="ranged")
{ // ranged combat
ExecuteScript("cai_ranged",oMe);
} // ranged combat
else if (sType=="stealth")
{ // stealth combat
ExecuteScript("cai_stealth",oMe);
} // stealth combat
else if (sType=="support")
{ // support role such as healing and buffing
ExecuteScript("cai_support",oMe);
} // support role such as healing and buffing
else if (sType=="summon")
{ // summoner type caster
ExecuteScript("cai_summon",oMe);
} // summoner type caster
else if (sType=="caster")
{ // spell caster
ExecuteScript("cai_caster",oMe);
} // spell caster
else if (sType=="flee")
{ // try not to get hurt under any circumstance
ExecuteScript("cai_flee",oMe);
} // try not to get hurt under any circumstance
else if (sType=="hold")
{ // hold where you are
ExecuteScript("cai_hold",oMe);
} // hold where you are
else
{ // based on weapon holding and skill
if (GetSkillRank(SKILL_HIDE,oMe)>10)
{ // stealth
ExecuteScript("cai_stealth",oMe);
} // stealth
else if (caiGetEquippedWeaponType(oMe,INVENTORY_SLOT_RIGHTHAND)==CAI_WEAPON_RANGED)
{ // ranged
ExecuteScript("cai_ranged",oMe);
} // ranged
else if (caiGetIsArcane(oMe))
{ // caster - wizard/sorcerer
ExecuteScript("cai_caster",oMe);
} // caster - wizard/sorcerer
else if (caiGetIsCleric(oMe))
{ // support - cleric
ExecuteScript("cai_support",oMe);
} // support - cleric
else
{ // melee
ExecuteScript("cai_melee",oMe);
} // melee
} // based on weapon holding and skill
} // Combat AI is turned on for the module and NPC
else
{ // standard combat
DetermineCombatRound();
} // standard combat
}
}
//Linked up to the special conversation check to initiate a special one-off conversation
//to get the PCs attention
else if(GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION) && GetIsPC(GetLastPerceived()))
{
ActionStartConversation(OBJECT_SELF);
}
}
}
if(GetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT) && GetLastPerceptionSeen())
{
SignalEvent(OBJECT_SELF, EventUserDefined(1002));
}
} // enemies only
}