84 lines
2.5 KiB
Plaintext
84 lines
2.5 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Name ra_ai_heartbeat
|
|
//:: Copyright (c) 2022 Project RATDOG
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
NPC Heartbeat event script caller to run CODI
|
|
AI & PRC events.
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: Jaysyn
|
|
//:: Created On: 20221201
|
|
//:://////////////////////////////////////////////
|
|
|
|
void main()
|
|
{
|
|
object oNPC = OBJECT_SELF;
|
|
object oAttacker;
|
|
|
|
string sResRef = GetResRef(oNPC);
|
|
|
|
effect eSleep = EffectSleep();
|
|
|
|
//:: Handles troll regen
|
|
if(sResRef == "ra_troll001"
|
|
|| sResRef == "ra_troll002"
|
|
|| sResRef == "TROLL_FEDORLA")
|
|
{
|
|
if(GetLocalInt(oNPC, "nSubDual") > 0)
|
|
{
|
|
SetLocalInt(oNPC, "nSubDual", GetLocalInt(oNPC, "nSubDual") - 5);
|
|
|
|
if(GetLocalInt(oNPC, "nSubDual") < GetCurrentHitPoints(oNPC))
|
|
{
|
|
RemoveEffect(oNPC, eSleep);
|
|
}
|
|
|
|
if(GetLocalInt(oNPC, "nSubDual") > GetCurrentHitPoints(oNPC))
|
|
{
|
|
SpeakString("I am still unconscious!");
|
|
SetIsDestroyable(FALSE, TRUE, TRUE);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleep, OBJECT_SELF, 6.5f);
|
|
}
|
|
|
|
//SpeakString("My Subdual is now " + IntToString(GetLocalInt(oNPC, "nSubDual")));
|
|
|
|
}
|
|
}
|
|
|
|
//:: Equips best armor
|
|
if ((!GetIsInCombat(oNPC) && (GetItemInSlot(INVENTORY_SLOT_CHEST) == OBJECT_INVALID)))
|
|
DelayCommand(0.5f, ActionEquipMostEffectiveArmor());
|
|
|
|
//:: Handles Vampire's Gaseous form death.
|
|
if(sResRef == "ra_vamp_gas_form")
|
|
{
|
|
//:: Get nearest alive PC.
|
|
oAttacker = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oNPC, 1, CREATURE_TYPE_IS_ALIVE, TRUE);
|
|
|
|
//:: Set destroyable.
|
|
SetIsDestroyable(TRUE, FALSE, FALSE);
|
|
|
|
//:: Remove plot/immoral/lootable flags JUST in case.
|
|
SetPlotFlag(oNPC, FALSE);
|
|
SetImmortal(oNPC, FALSE);
|
|
SetLootable(oNPC, FALSE);
|
|
|
|
//:: Clear Actions & run away
|
|
ClearAllActions();
|
|
ActionMoveAwayFromObject(oAttacker, TRUE, 300.0f);
|
|
|
|
//:: Destroy ourselves after fleeing the scene
|
|
DelayCommand(10.0f, DestroyObject(oNPC));
|
|
}
|
|
|
|
//:: Execute the CODI NPC OnHeartbeat script
|
|
ExecuteScript("no_ai_hrt", oNPC);
|
|
|
|
//:: Execute the default NPC OnHeartbeat script
|
|
//ExecuteScript("nw_c2_default1", oNPC);
|
|
|
|
//:: Execute the PRC NPC OnHeartbeat script
|
|
ExecuteScript("prc_npc_hb", oNPC);
|
|
}
|