//:: trampler_hb.nss //:: //:: Makes a creature pick a target & run DoTrample 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("trampler_hb: Starting script on "+sName+"."); // Check if the cooldown is active if (GetLocalInt(oNPC, "TrampleCooldown") == 1) { if(DEBUG) DoDebug("trampler_hb: "+sName+" can't use Trample while it is on cooldown."); return; // Exit if cooldown is active } if (GetLocalInt(oNPC, "GrappleOriginator") == 1) { if(DEBUG) DoDebug("trampler_hb: "+sName+" can't use Trample while grappling."); return; // Exit } if (GetLocalInt(oNPC, "GrappleTarget") == 1) { if(DEBUG) DoDebug("trampler_hb: "+sName+" can't use Trample while 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) { // Get the location of the target location lTarget = GetLocation(oTarget); // Set cooldown flag SetLocalInt(oNPC, "TrampleCooldown", 1); // Create a message using the names of the creatures string sMessage = GetName(oNPC) + " is trampling " + GetName(oTarget) + "!"; // Show floating text message FloatingTextStringOnCreature(sMessage, oNPC, FALSE); SendMessageToPC(oTarget, sMessage); // Call the DoTrample function DoTrample(oNPC, oTarget, lTarget); // Delay removal of the cooldown after 6-18 seconds (1-3 rounds) DelayCommand(RoundsToSeconds(d3(1)), DeleteLocalInt(oNPC, "TrampleCooldown")); break; // Exit the loop after trampling } // Select the next target within the spell shape oTarget = MyNextObjectInShape(SHAPE_SPHERE, fRange, GetLocation(oNPC), TRUE, OBJECT_TYPE_CREATURE); } } else if(DEBUG) DoDebug("trampler_hb: "+sName+" skipped Trample"); }