Destroying Group makes spell unusuable twice.

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)

JASS:
 // CHANGE ANIMATION SCALING VALUE
//! zinc
library FireImpulsion requires DummyCaster
{
    constant integer SPELL_ID = 'A003';
    
    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&lt;=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&lt;=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&lt;=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&lt;6;i+=1) {
            for(j=0;j&lt;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>
 

Dirac

22710180
Reaction score
147
1. You only initialize the group once, in the globals, so destroying it makes it null. Instead try [ljass]GroupClear(grp)[/ljass]
2. You're using lots of 2d arrays which are terrible
3. You leak lots of locations which are completely useless. (Instead of [ljass]GroupEnumUnitsInRangeOfLoc()[/ljass] use [ljass]GroupEnumUnitsInRange()[/ljass])
4. You should use libraries such as SpellEffectEvent to register spell calls
5. At the init function [ljass]GetTriggerUnit()[/ljass] returns null, since there isnt one.
6. There's no need to store [ljass]Condition(function Pick)[/ljass] inside a varaible
 

romanandre

New Member
Reaction score
2
Why 2d arrays are that bad? they are like 1d array compiled, and using GroupEnumUnitsInRange() makes a lot harder to code the spell, but I will try , Thanks a lot.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top