2025-07-18 12:13:13 -04:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////////
|
|
|
|
Script: nw_c2_default6
|
|
|
|
Programmer: Philos
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Monster OnDamaged event script;
|
|
|
|
Does not fire if the creature dies from the damage.
|
|
|
|
Does not fire for plot creatures as they take no damage.
|
|
|
|
May fire before or after OnPhysicalAttacked event.
|
|
|
|
Fires when EffectDamage is applied to oCreature even if 0 damage.
|
|
|
|
Fires when a weapon damages a oCreature, but not if resisted.
|
|
|
|
*///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "0i_actions"
|
2024-08-03 15:05:13 -04:00
|
|
|
void main()
|
|
|
|
{
|
2025-07-18 12:13:13 -04:00
|
|
|
object oCreature = OBJECT_SELF;
|
|
|
|
|
|
|
|
ExecuteScript("prc_npc_damaged", OBJECT_SELF);
|
|
|
|
|
2024-08-03 15:05:13 -04:00
|
|
|
// Send the user-defined event signal
|
|
|
|
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
|
|
|
|
{
|
2025-07-18 12:13:13 -04:00
|
|
|
SignalEvent(oCreature, EventUserDefined(EVENT_DAMAGED));
|
|
|
|
return;
|
2024-08-03 15:05:13 -04:00
|
|
|
}
|
2025-07-18 12:13:13 -04:00
|
|
|
if(ai_Disabled(oCreature)) return;
|
|
|
|
// Make sure to clear wounded shout limit if we take damage. See ai_TryHealing.
|
|
|
|
DeleteLocalInt(oCreature, "AI_WOUNDED_SHOUT_LIMIT");
|
|
|
|
object oDamager = GetLastDamager(oCreature);
|
|
|
|
if(AI_DEBUG) ai_Debug("nw_c2_default6", "23", GetName(oCreature) + " has been damaged by " + GetName(oDamager));
|
|
|
|
if(ai_GetFleeToExit(oCreature)) return;
|
|
|
|
if(GetObjectType(oDamager) == OBJECT_TYPE_AREA_OF_EFFECT &&
|
|
|
|
ai_IsInADangerousAOE(oCreature, AI_RANGE_BATTLEFIELD, TRUE)) return;
|
|
|
|
if(ai_GetIsBusy(oCreature) || ai_GetIsInCombat(oCreature)) return;
|
|
|
|
if(GetDistanceBetween(oCreature, oDamager) < AI_RANGE_CLOSE) ai_DoMonsterCombatRound(oCreature);
|
|
|
|
else ActionMoveToObject(oDamager, TRUE, AI_RANGE_CLOSE - 1.0);
|
2024-08-03 15:05:13 -04:00
|
|
|
}
|