Battledale_PRC8/_module/nss/nw_c2_default6.nss
Jaysyn904 7b9e44ebbb Initial upload
Initial upload.  PRC8 has been added.  Module compiles, PRC's default AI & treasure scripts have been integrated.  Started work on top hak for SLA / Ability / Scripting modifications.
2024-03-11 23:44:08 -04:00

177 lines
4.2 KiB
Plaintext

/////////////////:://////////////////////////////////////////////////
//:: Default On Damaged
//:: NW_C2_DEFAULT6
//:: 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 17th, 2008
//:: Added Support for Mounted Combat Feat Support
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
#include "x3_inc_horse"
#include "jw_privates_inc"
// do the voice
void DoVoice();
// About to die
void DieCall(object oMob = OBJECT_SELF);
void main()
{
ExecuteScript("prc_npc_damaged", OBJECT_SELF);
object oTarget = GetLastDamager();
object oDamager = oTarget;
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
}
SetTarget(oTarget);
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
if (GetStealthMode(OBJECT_SELF)==STEALTH_MODE_ACTIVATED)
{
ActionUseSkill(SKILL_HIDE,OBJECT_SELF);
}
if (GetDetectMode(OBJECT_SELF))
{
ActionUseSkill(SKILL_SPOT,OBJECT_SELF);
}
int nCheckHeal=CheckHeal();
if (nCheckHeal==FALSE)
{
DieCall();
}
if (GetObjectType(oTarget)==OBJECT_TYPE_AREA_OF_EFFECT)
{
oTarget=GetAreaOfEffectCreator(oTarget);
}
int nHP=GetMaxHitPoints();
int nDamage=GetTotalDamageDealt();
if ((d2()==1)&&(Random(nHP)<nDamage)&&(GetIsObjectValid(oTarget)))
{
SetVictim(oTarget);
DoVoice();
}
if (!GetIsFighting(OBJECT_SELF))
{
if (GetObjectSeen(oTarget))
{
if ((!GetIsInCombat())&&(d4()==1)&&(GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_FRIEND,OBJECT_SELF,1,CREATURE_TYPE_PERCEPTION,PERCEPTION_SEEN))))
{
PlayVoiceChat(VOICE_CHAT_ATTACK);
}
DetermineCombatRound();
}
else
{
ActionMoveToObject(oTarget,TRUE,3.0);
}
}
// Send the user-defined event signal
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DAMAGED));
}
}
void DoVoice()
{
int nRandom = d3();
if (nRandom == 1)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY1);
}
else if (nRandom == 2)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY2);
}
else if (nRandom == 3)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY3);
}
}
void DieCall(object oMob=OBJECT_SELF)
{
if (d2()==1)
{
// 50 per cent chance of not making the call;
return;
}
if (GetLocalInt(OBJECT_SELF,"diecall"))
{
// if I have called for help once, just return;
return;
}
if(GetCurrentHitPoints(oMob)> (GetMaxHitPoints(oMob)/4))
{
// not near dead
return;
}
PlayVoiceChat(VOICE_CHAT_NEARDEATH);
SetLocalInt(OBJECT_SELF,"diecall",1);
return;
}