91 lines
3.4 KiB
Plaintext
91 lines
3.4 KiB
Plaintext
|
//:: bullrusher_hb.nss
|
||
|
//::
|
||
|
//:: Makes a creature pick a target & run DoBullrush() 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("bullrusher_hb: Starting script on "+sName+".");
|
||
|
|
||
|
int bImpBullRush = GetHasFeat(FEAT_IMPROVED_BULLRUSH, oNPC);
|
||
|
|
||
|
// Check if the cooldown is active
|
||
|
if (GetLocalInt(oNPC, "BullRushCooldown") == 1)
|
||
|
{
|
||
|
if(DEBUG) DoDebug("bullrusher_hb: "+sName+" can't use Bull Rush while it is on cooldown.");
|
||
|
return; // Exit if cooldown is active
|
||
|
}
|
||
|
if (GetLocalInt(oNPC, "GrappleOriginator") == 1)
|
||
|
{
|
||
|
if(DEBUG) DoDebug("bullrusher_hb: "+sName+" can't use Bull Rush while you are grappling an opponent.");
|
||
|
return; // Exit
|
||
|
}
|
||
|
if (GetLocalInt(oNPC, "GrappleTarget") == 1)
|
||
|
{
|
||
|
if(DEBUG) DoDebug("bullrusher_hb: "+sName+" can't use Bull Rush 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, "BullRushCooldown", 1);
|
||
|
|
||
|
// Create a message using the names of the creatures
|
||
|
string sMessage = GetName(oNPC) + " is bull rushing " + GetName(oTarget) + "!";
|
||
|
SendMessageToPC(oTarget, sMessage);
|
||
|
|
||
|
// Show floating text message
|
||
|
FloatingTextStringOnCreature(sMessage, oNPC, FALSE);
|
||
|
|
||
|
// Call the DoBullRush function
|
||
|
DoBullRush(oNPC, oTarget, 0, bImpBullRush);
|
||
|
|
||
|
// Delay removal of the cooldown after 6-18 seconds (1-3 rounds)
|
||
|
DelayCommand(RoundsToSeconds(d3(1)), DeleteLocalInt(oNPC, "BullRushCooldown"));
|
||
|
|
||
|
break; // Exit the loop after bull rushing
|
||
|
}
|
||
|
|
||
|
// Select the next target within the spell shape
|
||
|
oTarget = MyNextObjectInShape(SHAPE_SPHERE, fRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
if(DEBUG) DoDebug("bullrusher_hb: "+sName+" skipped Bull Rush");
|
||
|
}
|