Wiki Relocation

With the upcoming Wikispaces site closure, this site will be decommissioned on 30th September 2018.
This page has been relocated to: http://victorian-nordock.com/wiki/pmwiki.php?n=Main.BallistaScript

//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);
}
}
}