PoA_PRC8/_module/nss/overrunner_hb.nss
Jaysyn904 b0a9d7abac Added support for NPCs with Combat Feats
Added support for NPCs with Charge, Pounce, Trample, Overrun, Awesome Blow & Bull Rush.  Full compile.  Updated release archive.
2024-12-13 18:40:31 -05:00

91 lines
3.4 KiB
Plaintext

//:: overruner_hb.nss
//::
//:: Makes a creature pick a target & run DoOverrun() occasionally.
//::
#include "prc_inc_combmove"
#include "prc_inc_spells"
void main()
{
object oNPC = OBJECT_SELF;
string sName = GetName(oNPC);
int nNPCSize = PRCGetCreatureSize(oNPC);
// Define a range for target selection
float fRange;
if (nNPCSize == CREATURE_SIZE_INVALID) fRange = FeetToMeters(10.0);
if (nNPCSize == CREATURE_SIZE_TINY) fRange = FeetToMeters(2.0);
if (nNPCSize == CREATURE_SIZE_SMALL) fRange = FeetToMeters(5.0);
if (nNPCSize == CREATURE_SIZE_MEDIUM) fRange = FeetToMeters(5.0);
if (nNPCSize == CREATURE_SIZE_LARGE) fRange = FeetToMeters(10.0);
if (nNPCSize == CREATURE_SIZE_HUGE) fRange = FeetToMeters(15.0);
if (nNPCSize == CREATURE_SIZE_GARGANTUAN) fRange = FeetToMeters(20.0);
if (nNPCSize == CREATURE_SIZE_COLOSSAL) fRange = FeetToMeters(30.0);
if(DEBUG) DoDebug("overruner_hb: Starting script on "+sName+".");
int bImpOverrun = GetHasFeat(FEAT_IMPROVED_OVERRUN, oNPC);
// Check if the cooldown is active
if (GetLocalInt(oNPC, "OverrunCooldown") == 1)
{
if(DEBUG) DoDebug("overruner_hb: "+sName+" can't use Overrun while it is on cooldown.");
return; // Exit if cooldown is active
}
if (GetLocalInt(oNPC, "GrappleOriginator") == 1)
{
if(DEBUG) DoDebug("overruner_hb: "+sName+" can't use Overrun while you are grappling an opponent.");
return; // Exit
}
if (GetLocalInt(oNPC, "GrappleTarget") == 1)
{
if(DEBUG) DoDebug("overruner_hb: "+sName+" can't use Overrun while you are being grappled.");
return; // Exit
}
// Randomly decide whether to trigger the trample effect (e.g., 33% chance)
if (1 + Random(100) <= 33)
{
object oTarget = MyFirstObjectInShape(SHAPE_SPHERE, fRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
// If we find a valid target, proceed
while (GetIsObjectValid(oTarget))
{
int nNPCSize = PRCGetCreatureSize(oNPC);
int nTargetSize = PRCGetCreatureSize(oTarget);
// Check if the target is a valid enemy, alive, and at least one size smaller
if (oTarget != oNPC && GetIsEnemy(oTarget, oNPC) && !GetIsDead(oTarget) && (nTargetSize <= nNPCSize + 1))
{
// Get the location of the target
location lTarget = GetLocation(oTarget);
// Set cooldown flag
SetLocalInt(oNPC, "OverrunCooldown", 1);
// Create a message using the names of the creatures
string sMessage = GetName(oNPC) + " is overrunning " + GetName(oTarget) + "!";
SendMessageToPC(oTarget, sMessage);
// Show floating text message
FloatingTextStringOnCreature(sMessage, oNPC, FALSE);
// Call the DoOverrun function
DoOverrun(oNPC, oTarget, lTarget, TRUE, 0, bImpOverrun, TRUE);
// Delay removal of the cooldown after 6-18 seconds (1-3 rounds)
DelayCommand(RoundsToSeconds(d3(1)), DeleteLocalInt(oNPC, "OverrunCooldown"));
break; // Exit the loop after overrunning
}
// Select the next target within the spell shape
oTarget = MyNextObjectInShape(SHAPE_SPHERE, fRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
}
}
else
if(DEBUG) DoDebug("overruner_hb: "+sName+" skipped Overrun");
}