PoA_PRC8/_module/nss/spelldefender.nss

52 lines
2.3 KiB
Plaintext
Raw Normal View History

2022-10-07 14:20:31 -04:00
void main()
{
int a = (GetLocalInt(GetObjectByTag("Defender"),"counter"));
if (a >= 20){
SendMessageToAllDMs("Tell Tres the spelldefender trigger is leaking in house Gur'atsz");
a = 0 ;
}
if (a <=0){
SetLocalInt(GetObjectByTag("Defender"),"iStart",FALSE);
}
int iStart = GetLocalInt(OBJECT_SELF,"iStart"); // Defender can be Started by someone entering the trigger around the Defender.
if (iStart == TRUE)
{
location lDefender = GetLocation(OBJECT_SELF); // Defender will be our spellcaster.
object oTarget = GetNearestCreatureToLocation // Find Creature ...
( // ...which is...
CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC, // (Undead)
lDefender,1, // (1st Closest to Defender object)
CREATURE_TYPE_IS_ALIVE,TRUE // (Still 'alive')
);
if (GetIsObjectValid(oTarget) && (GetDistanceBetween(OBJECT_SELF,oTarget) < 75.0 ))
{
// Proceed to launch an attack - there is a valid target in range.
int iSpellToUse;
string sSpellName;
switch (d6())
{
// randomly pick a spell to cast at the oTarget
case 1: iSpellToUse = SPELL_ICE_STORM; break;
case 2: iSpellToUse = SPELL_SEARING_LIGHT; break;
case 3: iSpellToUse = SPELL_NEGATIVE_ENERGY_BURST; break;
case 4: iSpellToUse = SPELL_METEOR_SWARM; break;
case 5: iSpellToUse = SPELL_HORRID_WILTING; break;
case 6: iSpellToUse = SPELL_DELAYED_BLAST_FIREBALL; break;
}
// Make "Defender" cast spell instantly, regardless of whether "Defender" object can legally cast the spell.
// Debugging Message
AssignCommand(
OBJECT_SELF,
ActionCastSpellAtObject(iSpellToUse,oTarget,METAMAGIC_EMPOWER,TRUE,40,PROJECTILE_PATH_TYPE_DEFAULT,TRUE)
);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect( VFX_FNF_SUMMON_MONSTER_3),OBJECT_SELF, 2.0);
} else {
// No valid target - turn defender off.
SetLocalInt(OBJECT_SELF,"iStart",FALSE);
}
}
}