Amon_PRC8/_module/nss/nw_c2_default6.nss

91 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

2025-04-03 19:00:46 -04:00
//::///////////////////////////////////////////////
//:: 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
//:://////////////////////////////////////////////
#include "hench_i0_ai"
#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())
{
}
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 ((GetLocalInt(OBJECT_SELF, HENCH_HEAL_SELF_STATE) == HENCH_HEAL_SELF_WAIT) &&
(GetPercentageHPLoss(OBJECT_SELF) < 30))
{
// force heal
HenchDetermineCombatRound(OBJECT_INVALID, TRUE);
}
else if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
{
// Jug_Debug(GetName(OBJECT_SELF) + " responding to damage");
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
{
HenchDetermineSpecialBehavior(oDamager);
}
else
{
HenchDetermineCombatRound(oDamager);
}
}
}
}
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DAMAGED));
}
}