void main()
{
// iDamage is the random amount of damage done to the enemy (2d20)
int iDamage = d20(2);
// oSelf is the catapult (object_self)
object oSelf = OBJECT_SELF;
// fMaxrange is the maximum range for the catapult
float fMaxrange = 25.0;
// eFireball is the damage the cannon does (bludgeoning)
effect eFireball = EffectDamage(iDamage, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_NORMAL);
// oMonster is the nearest enemy creature (reputation dependant on the faction of the catapult)
object oMonster = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, -1, -1, -1, -1);
// This get's the current position of the target to face
vector vMonsterPos = GetPosition(oMonster);
// Check to see if the monster is an enemy of the catapult (not user)
if (GetIsEnemy (oMonster, OBJECT_SELF) == TRUE)
{
// Check to see if monster is in range
if (GetDistanceBetween (oMonster, OBJECT_SELF) < fMaxrange)
// Checks to see if the reload time is finished, or "True"
if ( GetLocalInt(oSelf, "fire") == TRUE)
{
// The actual firing of the cannon, spell effect & damage
SetFacingPoint(vMonsterPos);
DelayCommand(1.5, ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_INSTANT, eFireball, oMonster, 0.0f)));
ActionCastSpellAtObject(SPELL_FIREBALL, oMonster, METAMAGIC_ANY, TRUE, 10, PROJECTILE_PATH_TYPE_BALLISTIC, FALSE);
SetLocalInt(oSelf, "fire", FALSE);
}
}
// Check if monsters are not in range
if (GetDistanceBetween (oMonster, OBJECT_SELF) > fMaxrange)
{
// If no enemies in range, tell player
ActionSpeakString("No enemy objects in range!");
}
if (OBJECT_INVALID == oMonster)
{
// If no enemies in area, tell player
ActionSpeakString("No enemy objects in range!");
}
// Checks to see if the reload time is not finished, or "False"
if ( GetLocalInt(oSelf, "fire") == FALSE)
{
// If still reloading, tell player
ActionSpeakString("Reloading Magipult....");
}
}
Okay i got this one off of NWVault. It just doesn't do as much damage as i want it to do. which pretty much is an instant-kill is what I want. It works perfectly other then that.