ballista_script

//Goes on creature's OnHeartbeat. Fires when not fighting or talking. void main { object oTarget; object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1); if (GetDistanceBetweenLocations(GetLocation(GetNearestObjectByTag("BallistaGuard", OBJECT_SELF, 1)), GetLocation(OBJECT_SELF)) < 5.0) { if (GetCurrentHitPoints(GetNearestObjectByTag("BallistaGuard", OBJECT_SELF, 1)) > 0) { oTarget = oPC; ActionCastSpellAtObject(SPELL_FIREBALL, oTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);

effect eEffect; eEffect = EffectDamage(50, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_ENERGY); ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC); } } }