//::////////////////////////////////////////////////// //:: NW_C2_DEFAULT6 //:: Default OnDamaged handler /* If already fighting then ignore, else determine combat round */ //::////////////////////////////////////////////////// //:: Copyright (c) 2002 Floodgate Entertainment //:: Created By: Naomi Novik //:: Created On: 12/22/2002 //::////////////////////////////////////////////////// #include "nw_i0_generic" void main() { if (GetCurrentHitPoints() <= 2000 && GetLocalInt(OBJECT_SELF, "di_surrender") != TRUE) { SpeakString("Okay, okay! Let's talk about this.", TALKVOLUME_TALK); object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_IS_ALIVE, TRUE); //SetLocalInt(OBJECT_SELF, "di_surrender", TRUE); SurrenderToEnemies(); ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(2001-GetCurrentHitPoints()), OBJECT_SELF); //DelayCommand(0.5, ActionStartConversation(oPC, "dreadpdread", TRUE, FALSE)); return; } else if(GetCurrentHitPoints() <= 1 && GetLocalInt(OBJECT_SELF, "di_surrender") == TRUE) { SpeakString("Well, how interesting. You managed to defeat me... for now.", TALKVOLUME_TALK); location lLoc = GetLocation(OBJECT_SELF); DestroyObject(OBJECT_SELF); int x = Random(30); if(x==1) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_a", lLoc, TRUE); } else if(x==2) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_b", lLoc, TRUE); } else if(x==3) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_c", lLoc, TRUE); } else if(x==4) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_r", lLoc, TRUE); } else if(x==5) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_s", lLoc, TRUE); } else if(x==6) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_h", lLoc, TRUE); } else if(x==7) { CreateObject(OBJECT_TYPE_ITEM, "di_blackpearl_bo", lLoc, TRUE); } else if(x==8) { CreateObject(OBJECT_TYPE_ITEM, "di_black_pearl_g", lLoc, TRUE); } else { CreateObject(OBJECT_TYPE_ITEM, "nw_it_msmlmisc13", lLoc, TRUE); } ExecuteScript("di_dooropener", GetObjectByTag("di_doortoship")); return; } if(GetFleeToExit()) { // We're supposed to run away, do nothing } else if (GetSpawnInCondition(NW_FLAG_SET_WARNINGS)) { // don't do anything? } else { object oDamager = GetLastDamager(); if (!GetIsObjectValid(oDamager)) { // don't do anything, we don't have a valid damager } else if (!GetIsFighting(OBJECT_SELF)) { // If we're not fighting, determine combat round if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)) { DetermineSpecialBehavior(oDamager); } else { if(!GetObjectSeen(oDamager) && GetArea(OBJECT_SELF) == GetArea(oDamager)) { // We don't see our attacker, go find them ActionMoveToLocation(GetLocation(oDamager), TRUE); ActionDoCommand(DetermineCombatRound()); } else { DetermineCombatRound(); } } } else { // We are fighting already -- consider switching if we've been // attacked by a more powerful enemy object oTarget = GetAttackTarget(); if (!GetIsObjectValid(oTarget)) oTarget = GetAttemptedAttackTarget(); if (!GetIsObjectValid(oTarget)) oTarget = GetAttemptedSpellTarget(); // If our target isn't valid // or our damager has just dealt us 25% or more // of our hp in damager // or our damager is more than 2HD more powerful than our target // switch to attack the damager. if (!GetIsObjectValid(oTarget) || ( oTarget != oDamager && ( GetTotalDamageDealt() > (GetMaxHitPoints(OBJECT_SELF) / 4) || (GetHitDice(oDamager) - 2) > GetHitDice(oTarget) ) ) ) { // Switch targets DetermineCombatRound(oDamager); } } } // Send the user-defined event signal if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT)) { SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DAMAGED)); } }