Ok, Try This. It compiles, but I haven't tested it.
// Aura for lightning Azer, onHeartbeat
vector RandomVector(int iMeterRadius = 5)
{
//OBJECT_SELF should be the bolt creating object
vector vVector = GetPosition(OBJECT_SELF);
// Will generate a value for x anf y between -5.00 to 5.00
// a Value of 0.0, 0.0 should occur only once in a million
float fX = IntToFloat(Random((iMeterRadius*200)+1)-(iMeterRadius*100))/100;
float fY = IntToFloat(Random((iMeterRadius*200)+1)-(iMeterRadius*100))/100;
// This is the new random vector for the strike location up to 5m away and one meter high.
return Vector(vVector.x +fX, vVector.y +fY, 0.0);
}
void main()
{
effect eVFX;
location lSelf = GetLocation(OBJECT_SELF);
{
int iCount=0;
object oZap = GetFirstObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
eVFX = EffectVisualEffect(VFX_BEAM_LIGHTNING);
while(GetIsObjectValid(oZap))
{
if(oZap == OBJECT_SELF)
{
oZap = GetNextObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
continue;
}
++iCount;
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oZap, 1.0);
effect eElectric = EffectDamage(d6(2), DAMAGE_TYPE_ELECTRICAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eElectric, oZap);
oZap = GetNextObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
}
int i;
object oRandomTarget = OBJECT_INVALID;
for(i=0; i<(-iCount+3); i++)
{
oRandomTarget = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", Location(GetArea(OBJECT_SELF), RandomVector(), 0.0));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oRandomTarget, 1.0);
SetIsDestroyable(1,0,0);
DestroyObject(oRandomTarget, 1.0);
}
}
}