//:://///////////////////////////////////////////// //:: Name codi_userdef //:: //::////////////////////////////////////////////// /* NPC OnUserDefined event script caller to run CODI AI & PRC events. May need to actually disable most of this for the CODI AI. */ //::////////////////////////////////////////////// //:: Created By: Jaysyn //:: Created On: 20240331 //::////////////////////////////////////////////// const int EVENT_USER_DEFINED_PRESPAWN = 1510; const int EVENT_USER_DEFINED_POSTSPAWN = 1511; void main() { //:: Declare major variables int nUser = GetUserDefinedEventNumber(); int nFireDamage = 0; int nAcidDamage = 0; int nColdDamage = 0; int nDivineDamage = 0; int nElectricalDamage = 0; int nPositiveDamage = 0; int nNegativeDamage = 0; int nMagicalDamage = 0; int nSonicDamage = 0; string sResRef = GetResRef(OBJECT_SELF); effect eSleep = EffectSleep(); effect eSlow = EffectSlow(); if(nUser == EVENT_HEARTBEAT ) //HEARTBEAT { if(sResRef == "ra_troll001" || sResRef == "TROLL_FEDORLA") { if(GetLocalInt(OBJECT_SELF, "nSubDual") > 0) { SetLocalInt(OBJECT_SELF, "nSubDual", GetLocalInt(OBJECT_SELF, "nSubDual") - 5); if(GetLocalInt(OBJECT_SELF, "nSubDual") < GetCurrentHitPoints(OBJECT_SELF)) { RemoveEffect(OBJECT_SELF, eSleep); } //SpeakString("My Subdual is now " + IntToString(GetLocalInt(OBJECT_SELF, "nSubDual"))); } } } else if(nUser == EVENT_PERCEIVE) // PERCEIVE { } else if(nUser == EVENT_END_COMBAT_ROUND) // END OF COMBAT { } else if(nUser == EVENT_DIALOGUE) // ON DIALOGUE { } else if(nUser == EVENT_ATTACKED) // ATTACKED { } else if(nUser == EVENT_DAMAGED) // DAMAGED { //:: Handles swarm immunity to physical weapons if(sResRef == "ds_minkankswrm01" || sResRef == "ds_locustswarm01") { int nTotalDamage = GetTotalDamageDealt(); if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) > 0) { nFireDamage = GetDamageDealtByType(DAMAGE_TYPE_FIRE); } if(GetDamageDealtByType(DAMAGE_TYPE_ACID) > 0) { nAcidDamage = GetDamageDealtByType(DAMAGE_TYPE_ACID); } if(GetDamageDealtByType(DAMAGE_TYPE_COLD) > 0) { nColdDamage = GetDamageDealtByType(DAMAGE_TYPE_COLD); } if(GetDamageDealtByType(DAMAGE_TYPE_DIVINE) > 0) { nDivineDamage = GetDamageDealtByType(DAMAGE_TYPE_DIVINE); } if(GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL) > 0) { nElectricalDamage = GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL); } if(GetDamageDealtByType(DAMAGE_TYPE_MAGICAL) > 0) { nMagicalDamage = GetDamageDealtByType(DAMAGE_TYPE_MAGICAL); } if(GetDamageDealtByType(DAMAGE_TYPE_NEGATIVE) > 0) { nNegativeDamage = GetDamageDealtByType(DAMAGE_TYPE_NEGATIVE); } if(GetDamageDealtByType(DAMAGE_TYPE_POSITIVE) > 0) { nPositiveDamage = GetDamageDealtByType(DAMAGE_TYPE_POSITIVE); } if(GetDamageDealtByType(DAMAGE_TYPE_SONIC) > 0) { nSonicDamage = GetDamageDealtByType(DAMAGE_TYPE_SONIC); } int nSubDmg = nTotalDamage - (nFireDamage + nAcidDamage + nColdDamage + nDivineDamage + nElectricalDamage + nMagicalDamage + nNegativeDamage + nPositiveDamage + nSonicDamage); int nActDmg = (nFireDamage + nAcidDamage + nColdDamage + nDivineDamage + nElectricalDamage + nMagicalDamage + nNegativeDamage + nPositiveDamage + nSonicDamage); effect eHeal = EffectHeal(nSubDmg); ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, OBJECT_SELF, 0.0f); } } else if(nUser == 1007) // DEATH - do not use for critical code, does not fire reliably all the time { } else if(nUser == EVENT_DISTURBED) // DISTURBED { } else if (nUser == EVENT_USER_DEFINED_PRESPAWN) { } else if (nUser == EVENT_USER_DEFINED_POSTSPAWN) { } //:: Execute the PRC NPC OnUserDef script ExecuteScript("prc_npc_userdef", OBJECT_SELF); }