Added support for NPCs with Charge, Pounce, Trample, Overrun, Awesome Blow & Bull Rush. Full compile. Updated release archive.
116 lines
4.4 KiB
Plaintext
116 lines
4.4 KiB
Plaintext
//:: awesomeblow_hb.nss
|
|
//::
|
|
//:: Makes a creature pick a target & run DoAwesomeBlow() occasionally.
|
|
//::
|
|
#include "prc_inc_combmove"
|
|
#include "prc_inc_spells"
|
|
|
|
void DoAwesomeBlow(object oTarget, object oNPC = OBJECT_SELF)
|
|
{
|
|
int nHP = GetCurrentHitPoints(oTarget);
|
|
int nSizeBonus;
|
|
effect eNone;
|
|
|
|
// Apply the VFX
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_REFLEX_SAVE_THROW_USE), oTarget);
|
|
|
|
PerformAttack(oTarget, oNPC, eNone, 0.0, -4);
|
|
|
|
if (GetLocalInt(oTarget, "PRCCombat_StruckByAttack"))
|
|
{
|
|
int nDC = nHP - GetCurrentHitPoints(oTarget); // This should be the amount caused by the attack
|
|
|
|
if ((PRCGetCreatureSize(oNPC) + nSizeBonus) > PRCGetCreatureSize(oTarget))
|
|
{
|
|
if (!PRCMySavingThrow(SAVING_THROW_REFLEX, oTarget, nDC, SAVING_THROW_TYPE_NONE))
|
|
{
|
|
_DoBullRushKnockBack(oTarget, oNPC, 10.0);
|
|
|
|
// Apply knockdown effect after the knockback with a slight delay
|
|
DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectKnockdown(), oTarget, 6.0));
|
|
|
|
// Trigger dust explosion when the target stops moving
|
|
DelayCommand(0.6, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DUST_EXPLOSION), oTarget));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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("awesomeblow_hb: Starting script on "+sName+".");
|
|
|
|
// Check if the cooldown is active
|
|
if (GetLocalInt(oNPC, "AwesomeBlowCooldown") == 1)
|
|
{
|
|
if(DEBUG) DoDebug("awesomeblow_hb: "+sName+" can't use Awesome Blow while it is on cooldown.");
|
|
return; // Exit if cooldown is active
|
|
}
|
|
if (GetLocalInt(oNPC, "GrappleOriginator") == 1)
|
|
{
|
|
if(DEBUG) DoDebug("awesomeblow_hb: "+sName+" can't use Awesome Blow while you are grappling an opponent.");
|
|
return; // Exit
|
|
}
|
|
if (GetLocalInt(oNPC, "GrappleTarget") == 1)
|
|
{
|
|
if(DEBUG) DoDebug("awesomeblow_hb: "+sName+" can't use Awesome Blow while you are being grappled.");
|
|
return; // Exit
|
|
}
|
|
|
|
// Randomly decide whether to trigger an Awesome Blow (e.g., 33% chance)
|
|
if (1 + Random(100) <= 33)
|
|
{
|
|
object oTarget = MyFirstObjectInShape(SHAPE_SPHERE, fRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
|
|
int nTargetSize = PRCGetCreatureSize(oTarget);
|
|
|
|
// If we find a valid target, proceed
|
|
while (GetIsObjectValid(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)
|
|
{
|
|
// Call the DoAwesomeBlow function
|
|
DoAwesomeBlow(oTarget, oNPC);
|
|
|
|
// Create a message using the names of the creatures
|
|
string sMessage = GetName(oNPC) + " assaults " + GetName(oTarget) + " with an Awesome Blow!";
|
|
|
|
// Show floating text message
|
|
FloatingTextStringOnCreature(sMessage, oNPC, FALSE);
|
|
SendMessageToPC(oTarget, sMessage);
|
|
|
|
// Set cooldown flag
|
|
SetLocalInt(oNPC, "AwesomeBlowCooldown", 1);
|
|
|
|
// Delay removal of the cooldown after 1-4 rounds
|
|
DelayCommand(RoundsToSeconds(d4(1)), DeleteLocalInt(oNPC, "AwesomeBlowCooldown"));
|
|
|
|
break; // Exit the loop after using Awesome Blow
|
|
}
|
|
|
|
// Select the next target within the spell shape
|
|
oTarget = MyNextObjectInShape(SHAPE_SPHERE, fRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE);
|
|
}
|
|
}
|
|
else
|
|
if(DEBUG) DoDebug("awesomeblow_hb: "+sName+" skipped Awesome Blow");
|
|
}
|