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.
This commit is contained in:
80
_module/nss/charger_hb.nss
Normal file
80
_module/nss/charger_hb.nss
Normal file
@@ -0,0 +1,80 @@
|
||||
//:: charger_hb.nss
|
||||
//::
|
||||
//:: Makes a creature pick a target & run DoCharge occasionally.
|
||||
//::
|
||||
#include "prc_inc_combmove"
|
||||
#include "prc_inc_spells"
|
||||
|
||||
void main()
|
||||
{
|
||||
object oNPC = OBJECT_SELF;
|
||||
|
||||
string sName = GetName(oNPC);
|
||||
|
||||
int bImpBullRush = GetHasFeat(FEAT_IMPROVED_BULLRUSH, oNPC);
|
||||
int bAcrobaticCharge = GetHasFeat(FEAT_ACROBATIC_CHARGE, oNPC);
|
||||
int bPouncer = GetLocalInt(oNPC, "POUNCER");
|
||||
|
||||
if(DEBUG) DoDebug("charger_hb: Starting script on "+sName+".");
|
||||
|
||||
// Check if the cooldown is active
|
||||
if (GetLocalInt(oNPC, "ChargeCooldown") == 1)
|
||||
{
|
||||
if(DEBUG) DoDebug("charger_hb: "+sName+" can't use Charge while it is on cooldown.");
|
||||
return; // Exit if cooldown is active
|
||||
}
|
||||
if (GetLocalInt(oNPC, "GrappleOriginator") == 1)
|
||||
{
|
||||
if(DEBUG) DoDebug("charger_hb: "+sName+" can't use Charge while grappling.");
|
||||
return; // Exit
|
||||
}
|
||||
if (GetLocalInt(oNPC, "GrappleTarget") == 1)
|
||||
{
|
||||
if(DEBUG) DoDebug("charger_hb: "+sName+" can't use Charge while being grappled.");
|
||||
return; // Exit
|
||||
}
|
||||
|
||||
// Define the minimum and maximum range for target selection
|
||||
float fMinRange = FeetToMeters(20.0); // Minimum range in meters (15 feet)
|
||||
float fMaxRange = FeetToMeters(45.0); // Maximum range in meters (45 feet)
|
||||
|
||||
// Randomly decide whether to trigger the charge effect (e.g., 20% chance)
|
||||
if (1 + Random(100) <= 25) // 25% chance
|
||||
{
|
||||
object oTarget = MyFirstObjectInShape(SHAPE_SPHERE, fMaxRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
|
||||
|
||||
// If we find a valid target, proceed
|
||||
while (GetIsObjectValid(oTarget))
|
||||
{
|
||||
// Calculate the distance to the target
|
||||
float fDistance = GetDistanceBetween(oNPC, oTarget);
|
||||
|
||||
// Check if the target is a valid enemy, alive, and within the distance constraints
|
||||
if (oTarget != oNPC && GetIsEnemy(oTarget, oNPC) && !GetIsDead(oTarget) && fDistance > fMinRange && fDistance <= fMaxRange)
|
||||
{
|
||||
// Create a message using the names of the creatures
|
||||
string sMessage = GetName(oNPC) + " is charging " + GetName(oTarget) + "!";
|
||||
|
||||
// Show floating text message
|
||||
FloatingTextStringOnCreature(sMessage, oNPC, FALSE);
|
||||
SendMessageToPC(oTarget, sMessage);
|
||||
|
||||
// Call the DoCharge function
|
||||
DoCharge(oNPC, oTarget, TRUE, bAcrobaticCharge, 0, -1, bImpBullRush, 0, bPouncer);
|
||||
|
||||
// Set cooldown flag
|
||||
SetLocalInt(oNPC, "ChargeCooldown", 1);
|
||||
|
||||
// Delay removal of the cooldown after 6-18 seconds (1-3 rounds)
|
||||
DelayCommand(RoundsToSeconds(d3(1)), DeleteLocalInt(oNPC, "ChargeCooldown"));
|
||||
|
||||
break; // Exit the loop after charging
|
||||
}
|
||||
|
||||
// Select the next target within the shape
|
||||
oTarget = MyNextObjectInShape(SHAPE_SPHERE, fMaxRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
if(DEBUG) DoDebug("charger_hb: "+sName+" skipped Charging");
|
||||
}
|
Reference in New Issue
Block a user