185 lines
5.6 KiB
Plaintext
185 lines
5.6 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Name ra_ai_userdef
|
|
//:: Copyright (c) 2022 Project RATDOG
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
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: 20221201
|
|
//:://////////////////////////////////////////////
|
|
|
|
const int EVENT_USER_DEFINED_PRESPAWN = 1510;
|
|
const int EVENT_USER_DEFINED_POSTSPAWN = 1511;
|
|
|
|
|
|
void main()
|
|
{
|
|
//:: Declare major variables
|
|
object oSelf = OBJECT_SELF;
|
|
int nUser = GetUserDefinedEventNumber();
|
|
int nFireDamage = 0;
|
|
int nAcidDamage = 0;
|
|
int nTotalHP = GetMaxHitPoints(oSelf);
|
|
|
|
string sResRef = GetResRef(oSelf);
|
|
|
|
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
|
|
{
|
|
if (sResRef == "ra_ghast002")
|
|
{
|
|
SpeakString("Well hello to you, my first meal in a century!", TALKVOLUME_TALK);
|
|
}
|
|
|
|
}
|
|
else if(nUser == EVENT_END_COMBAT_ROUND) // END OF COMBAT
|
|
{
|
|
if (sResRef == "ra_ghast002")
|
|
{
|
|
// Randomly choose a threat message
|
|
int threatChoice = Random(4) + 1; // You can adjust the number of threats as needed
|
|
|
|
// Depending on the threatChoice, the NPC will say different things
|
|
string threatMessage = "";
|
|
switch (threatChoice)
|
|
{
|
|
case 1:
|
|
threatMessage = "You look delicious!!";
|
|
break;
|
|
case 2:
|
|
threatMessage = "Thank you so much!!";
|
|
break;
|
|
case 3:
|
|
threatMessage = "FREEEDOM!!";
|
|
break;
|
|
case 4:
|
|
threatMessage = "So sorry, I can't help it you see?";
|
|
break;
|
|
}
|
|
|
|
// Get the nearest enemy and make the NPC say the threat
|
|
object oNearestEnemy = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, PLAYER_CHAR_IS_PC, oSelf);
|
|
if (GetIsObjectValid(oNearestEnemy))
|
|
{
|
|
SpeakString(threatMessage, TALKVOLUME_TALK);
|
|
}
|
|
|
|
}
|
|
}
|
|
else if(nUser == EVENT_DIALOGUE) // ON DIALOGUE
|
|
{
|
|
|
|
}
|
|
else if(nUser == EVENT_ATTACKED) // ATTACKED
|
|
{
|
|
|
|
}
|
|
else if(nUser == EVENT_DAMAGED) // DAMAGED
|
|
{
|
|
/* if(sResRef == "ra_troll001" || sResRef == "TROLL_FEDORLA")
|
|
{
|
|
int nTotalDamage = GetTotalDamageDealt();
|
|
|
|
if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) >= 1)
|
|
{
|
|
nFireDamage = GetDamageDealtByType(DAMAGE_TYPE_FIRE);
|
|
SpeakString("Fire Damage: " + IntToString(nFireDamage));
|
|
}
|
|
|
|
if(GetDamageDealtByType(DAMAGE_TYPE_ACID) >= 1)
|
|
{
|
|
nAcidDamage = GetDamageDealtByType(DAMAGE_TYPE_ACID);
|
|
SpeakString("Acid Damage: " + IntToString(nAcidDamage));
|
|
}
|
|
|
|
|
|
int nSubDmg = nTotalDamage - (nFireDamage + nAcidDamage);
|
|
int nActDmg = nFireDamage + nAcidDamage;
|
|
SpeakString("Real damage this attack: " + IntToString(nActDmg));
|
|
|
|
SetLocalInt(OBJECT_SELF, "nActDmg", nActDmg + GetLocalInt(OBJECT_SELF, "nActDmg"));
|
|
|
|
effect eHeal = EffectHeal(nSubDmg);
|
|
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, OBJECT_SELF, 0.0f);
|
|
|
|
|
|
if(GetLocalInt(OBJECT_SELF, "nSubDual") <= GetCurrentHitPoints(OBJECT_SELF))
|
|
{
|
|
SetLocalInt(OBJECT_SELF, "nSubDual", nSubDmg + GetLocalInt(OBJECT_SELF, "nSubDual"));
|
|
}
|
|
|
|
int nSD = GetLocalInt(OBJECT_SELF, "nSubDual");
|
|
int nCurrentHP = GetCurrentHitPoints(OBJECT_SELF);
|
|
|
|
SpeakString("SD: " + IntToString(nSD));
|
|
SpeakString("CH: " + IntToString(nCurrentHP));
|
|
SpeakString("ActDmg: " + IntToString(nActDmg));
|
|
|
|
if(nSD > nCurrentHP)
|
|
{
|
|
SpeakString("I am unconscious!");
|
|
SetIsDestroyable(FALSE, TRUE, TRUE);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleep, OBJECT_SELF, 6.0f);
|
|
}
|
|
else if(nSD == nCurrentHP)
|
|
{
|
|
SpeakString("I am staggered!");
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSlow, OBJECT_SELF, 6.0f);
|
|
}
|
|
|
|
if ((nTotalHP - nActDmg) < nCurrentHP)
|
|
{
|
|
nCurrentHP = nTotalHP - nActDmg;
|
|
SpeakString("Setting HP to: " + IntToString(nCurrentHP));
|
|
SetCurrentHitPoints(OBJECT_SELF, nCurrentHP);
|
|
}
|
|
} */
|
|
}
|
|
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);
|
|
|
|
}
|