//:://///////////////////////////////////////////// //:: Name ra_ai_ondamaged //:: Copyright (c) 2022 Project RATDOG //::////////////////////////////////////////////// /* NPC OnDamaged event script caller to run CODI AI & PRC events. */ //::////////////////////////////////////////////// //:: Created By: Jaysyn //:: Created On: 20221201 //::////////////////////////////////////////////// void main() { int nTotalDamage = GetTotalDamageDealt(); int nFireDamage = 0; int nAcidDamage = 0; int nTotalHP = GetMaxHitPoints(OBJECT_SELF); string sResRef = GetResRef(OBJECT_SELF); effect eSleep = EffectSleep(); effect eSlow = EffectSlow(); //-------------------------------------------------------------------------- // GZ: 2003-10-16 // Make Plot Creatures Ignore Attacks //-------------------------------------------------------------------------- if (GetPlotFlag(OBJECT_SELF)) { return; } //:: Handles troll regen if(sResRef == "ra_troll001" || sResRef == "ra_troll002" || sResRef == "TROLL_FEDORLA") { DelayCommand(0.0f, SpeakString("Max/Total HP: " + IntToString(nTotalHP))); if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) != -1) { nFireDamage = GetDamageDealtByType(DAMAGE_TYPE_FIRE); //DelayCommand(0.0f, SpeakString("Fire Damage: " + IntToString(nFireDamage))); } if(GetDamageDealtByType(DAMAGE_TYPE_ACID) != -1) { nAcidDamage = GetDamageDealtByType(DAMAGE_TYPE_ACID); //DelayCommand(0.0f, SpeakString("Acid Damage: " + IntToString(nAcidDamage))); } int nNoRegen = nFireDamage + nAcidDamage; int nSubDmg = nTotalDamage - nNoRegen; //DelayCommand(0.0f, SpeakString("Real damage this attack: " + IntToString(nNoRegen))); SetLocalInt(OBJECT_SELF, "NoRegen", nNoRegen + GetLocalInt(OBJECT_SELF, "NoRegen")); nNoRegen = GetLocalInt(OBJECT_SELF, "NoRegen"); //DelayCommand(0.0f, SpeakString("Actual Damage Stored: " + IntToString(nNoRegen))); effect eHeal = EffectHeal(nSubDmg); //DelayCommand(0.0f, SpeakString("Subdual damage healed: " + IntToString(nSubDmg))); ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, OBJECT_SELF, 0.0f); int nCurrentHP = GetCurrentHitPoints(OBJECT_SELF); //DelayCommand(0.0f, SpeakString("Current HP: " + IntToString(nCurrentHP))); if ((nTotalHP - nNoRegen) < nCurrentHP) { nCurrentHP = nTotalHP - nNoRegen; //DelayCommand(0.0f, SpeakString("Setting HP to: " + IntToString(nCurrentHP))); SetCurrentHitPoints(OBJECT_SELF, nCurrentHP); } if(GetLocalInt(OBJECT_SELF, "nSubDual") <= GetCurrentHitPoints(OBJECT_SELF)) { SetLocalInt(OBJECT_SELF, "nSubDual", nSubDmg + GetLocalInt(OBJECT_SELF, "nSubDual")); } int nSD = GetLocalInt(OBJECT_SELF, "nSubDual"); //DelayCommand(0.0f, SpeakString("SD: " + IntToString(nSD))); //DelayCommand(0.0f, SpeakString("CH: " + IntToString(nCurrentHP))); //DelayCommand(0.0f, SpeakString("NoRegen: " + IntToString(nNoRegen))); if(nSD > GetCurrentHitPoints(OBJECT_SELF)) { //SpeakString("I am unconscious!"); SetIsDestroyable(FALSE, TRUE, TRUE); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleep, OBJECT_SELF, 6.0f); } else if(nSD == GetCurrentHitPoints(OBJECT_SELF)) { //SpeakString("I am staggered!"); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSlow, OBJECT_SELF, 6.0f); } } //:: Execute the CODI AI NPC OnDamaged script ExecuteScript("no_ai_dam", OBJECT_SELF); //:: Execute the Default NPC OnDamaged script //ExecuteScript("nw_c2_default6", OBJECT_SELF); //:: Execute the PRC NPC OnDamaged script ExecuteScript("prc_npc_damaged", OBJECT_SELF); }