118 lines
4.4 KiB
Plaintext
118 lines
4.4 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Name x2_def_ondamage
|
|
//:: Copyright (c) 2001 Bioware Corp.
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
Default OnDamaged script
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: Keith Warner
|
|
//:: Created On: June 11/03
|
|
//:://////////////////////////////////////////////
|
|
|
|
#include "quest_inc"
|
|
#include "nw_i0_plot"
|
|
void main()
|
|
{
|
|
//--------------------------------------------------------------------------
|
|
// GZ: 2003-10-16
|
|
// Make Plot Creatures Ignore Attacks
|
|
//--------------------------------------------------------------------------
|
|
if (GetPlotFlag(OBJECT_SELF))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------
|
|
// Execute old NWN default AI code
|
|
//--------------------------------------------------------------------------
|
|
|
|
string sString;
|
|
if (GetLocalInt(OBJECT_SELF, "KidnapTarget") == TRUE && GetCurrentHitPoints() < GetMaxHitPoints()/5 && GetIsDead(OBJECT_SELF) == FALSE && GetLocalInt(OBJECT_SELF, "FightToDeath") == FALSE)
|
|
{
|
|
SetLocalInt(OBJECT_SELF, "FightToDeath", TRUE);
|
|
if (Random(2) == 0)
|
|
{
|
|
SetPlotFlag(OBJECT_SELF, TRUE);
|
|
ClearAllActions();
|
|
object oCreature = GetFirstObjectInArea(GetArea(OBJECT_SELF));
|
|
while (oCreature != OBJECT_INVALID)
|
|
{
|
|
if (GetObjectType(oCreature) == OBJECT_TYPE_CREATURE && oCreature != OBJECT_SELF)
|
|
{
|
|
SetIsTemporaryNeutral(oCreature, OBJECT_SELF);
|
|
SetIsTemporaryNeutral(OBJECT_SELF, oCreature);
|
|
AssignCommand(oCreature, ClearAllActions());
|
|
}
|
|
oCreature = GetNextObjectInArea(GetArea(OBJECT_SELF));
|
|
}
|
|
switch (Random(3))
|
|
{
|
|
case 0: sString = "Uh... I yield!"; break;
|
|
case 1: sString = "Stop! I give up!"; break;
|
|
case 2: sString = "No... please, don't kill me!"; break;
|
|
}
|
|
SpeakString(sString);
|
|
SetLocalInt(OBJECT_SELF, "Pacified", TRUE);
|
|
}
|
|
}
|
|
|
|
if (GetLocalInt(OBJECT_SELF, "WillRun") == TRUE && GetCurrentHitPoints() < GetMaxHitPoints()/5 && GetIsDead(OBJECT_SELF) == FALSE)
|
|
{
|
|
SetPlotFlag(OBJECT_SELF, TRUE);
|
|
SetLocalInt(OBJECT_SELF, "Running", TRUE);
|
|
DeleteLocalInt(GetArea(OBJECT_SELF), "NO_ESCAPE");
|
|
switch (Random(3))
|
|
{
|
|
case 0: sString = "Arrgh! This will not... end like this!"; break;
|
|
case 1: sString = "No! No! No!"; break;
|
|
case 2: sString = "I must... run..."; break;
|
|
}
|
|
SpeakString(sString);
|
|
if (GetLocalInt(OBJECT_SELF, "Quest_Target") == FALSE)
|
|
{
|
|
ClearAllActions(TRUE);
|
|
EscapeArea();
|
|
DelayCommand(25.0, DestroyObject(OBJECT_SELF));
|
|
}
|
|
else
|
|
{
|
|
object oPC = GetLocalObject(OBJECT_SELF, "oPC");
|
|
int nInitiative = 0;
|
|
if (GetHasFeat(FEAT_BLOODED, oPC) == TRUE) nInitiative = 2;
|
|
if (GetHasFeat(FEAT_THUG, oPC) == TRUE) nInitiative = nInitiative + 2;
|
|
if (GetHasFeat(FEAT_IMPROVED_INITIATIVE, oPC) == TRUE) nInitiative = nInitiative + 4;
|
|
if (GetHasFeat(FEAT_EPIC_SUPERIOR_INITIATIVE, oPC) == TRUE) nInitiative = nInitiative + 4;
|
|
int nRandom = d20();
|
|
|
|
if (GetArea(OBJECT_SELF) == GetArea(oPC))
|
|
{
|
|
if (nRandom+nInitiative >= 15)
|
|
{
|
|
SendMessageToPC(oPC, "Initiative check: " + IntToString(nInitiative) + " + " + IntToString(nRandom) + " = " + IntToString(nRandom+nInitiative) + " *SUCCESS*");
|
|
SetPlotFlag(OBJECT_SELF, FALSE);
|
|
DeleteLocalInt(OBJECT_SELF, "Running");
|
|
}
|
|
else
|
|
{
|
|
SendMessageToPC(oPC, "Initiative check: " + IntToString(nInitiative) + " + " + IntToString(nRandom) + " = " + IntToString(nRandom+nInitiative) + " *FAILURE*");
|
|
StoreQuestNPC(OBJECT_SELF);
|
|
ClearAllActions(TRUE);
|
|
EscapeArea();
|
|
DelayCommand(25.0, DestroyObject(OBJECT_SELF));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ClearAllActions(TRUE);
|
|
EscapeArea();
|
|
DelayCommand(25.0, DestroyObject(OBJECT_SELF));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if(GetLocalInt(OBJECT_SELF, "X4_VANILLA_AI") == TRUE) ExecuteScript("nw_c2_default6_v", OBJECT_SELF);
|
|
else ExecuteScript("nw_c2_default6", OBJECT_SELF);
|
|
}
|