romanandre
New Member
- Reaction score
- 2
Whenever I use this coded spell twice it doesnt deal damage, but however if I remove the line: DestroyGroup(grp);
It works normaly, how bad are group leaks? and anyone knows how to fix it? (sorry for zinc coding I just cant with vjass)
It works normaly, how bad are group leaks? and anyone knows how to fix it? (sorry for zinc coding I just cant with vjass)
JASS:
// CHANGE ANIMATION SCALING VALUE
//! zinc
library FireImpulsion requires DummyCaster
{
constant integer SPELL_ID = 039;A003039;;
constant string SPELLFX1 = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl";
constant string ATTACH = "origin";
constant real DAMAGE = 100;
constant real RADIUS = 85;
constant real DISTANCE = 75;
constant attacktype AT = ATTACK_TYPE_NORMAL;
constant damagetype DT = DAMAGE_TYPE_NORMAL;
constant weapontype WT = WEAPON_TYPE_WHOKNOWS;
boolexpr b;
real x2[10][10];
real y2[10][10];
location loc[10][10];
unit u;
group grp = CreateGroup();
function SpellIdMatch() -> boolean
{
return (GetSpellAbilityId() == SPELL_ID);
}
function Targets(unit target) -> boolean
{
return (GetWidgetLife(target) > 0.405) &&! IsUnitType(target, UNIT_TYPE_STRUCTURE) &&! IsUnitType(target, UNIT_TYPE_FLYING) &&! IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) &&! IsUnitType(target, UNIT_TYPE_MECHANICAL) && IsUnitEnemy(target,GetOwningPlayer(u));
}
function Pick() -> boolean
{
if (Targets(GetFilterUnit()))
{
UnitDamageTarget(u, GetFilterUnit(), DAMAGE, true, true, AT, DT, WT);
}
return false;
}
function onSpellCast()
{
real x1;
real y1;
integer i;
integer j;
real facing;
real x;
real y;
real test;
real test2;
u = GetTriggerUnit();
facing = GetUnitFacing(u)*bj_DEGTORAD;
x = GetUnitX(u);
y = GetUnitY(u);
for(i=1;i<=4;i+=1) {
x1 = x + DISTANCE*i*Cos(facing);
y1 = y + DISTANCE*i*Sin(facing);
AddSpecialEffectTimed(SPELLFX1, x1, y1, 0.03125);
x2[0]<i> = x1;
y2[0]<i> = y1;
loc[0]<i> = Location(x2[0]<i>, y2[0]<i>);
}
for(i=-2;i<=2;i+=1) {
x1 = x + DISTANCE*5*Cos(facing + 15*i*bj_DEGTORAD);
y1 = y + DISTANCE*5*Sin(facing + 15*i*bj_DEGTORAD);
AddSpecialEffectTimed(SPELLFX1, x1, y1, 0.03125);
x2[1][i+2] = x1;
y2[1][i+2] = y1;
loc[1][i+2] = Location(x2[1][i+2], y2[1][i+2]);
}
for(i=-1;i<=1;i+=1) {
x1 = x + DISTANCE*4*Cos(facing + 30*i*bj_DEGTORAD);
y1 = y + DISTANCE*4*Sin(facing + 30*i*bj_DEGTORAD);
AddSpecialEffectTimed(SPELLFX1, x1, y1, 0.03125);
x2[2][i+1] = x1;
y2[2][i+1] = y1;
loc[2][i+1] = Location(x2[2][i+1], y2[2][i+1]);
}
for(i=-1;i<=1;i+=1) {
if (i!=0) {
x1 = x + DISTANCE*3*Cos(facing + 15*i*bj_DEGTORAD);
y1 = y + DISTANCE*3*Sin(facing + 15*i*bj_DEGTORAD);
AddSpecialEffectTimed(SPELLFX1, x1, y1, 0.03125);
x2[3][i+1] = x1;
y2[3][i+1] = y1;
loc[3][i+1] = Location(x2[3][i+1], y2[3][i+1]);
}
}
for(i=0;i<6;i+=1) {
for(j=0;j<4;j+=1) {
GroupEnumUnitsInRangeOfLoc(grp, loc[j]<i>, RADIUS, b);
}
}
DestroyGroup(grp);
}
function onInit()
{
trigger t = CreateTrigger();
TriggerAddAction(t, function onSpellCast);
TriggerAddCondition(t, Condition(function SpellIdMatch));
TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT);
b = Condition(function Pick);
u = GetTriggerUnit();
Preload(SPELLFX1);
}
}
//! endzinc </i></i></i></i></i></i>