• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Another spell problem

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
Hey guys, I'm here again. Sorry if I disappoint the people that told me to only use X and Y but I just can't get it working

Here is my code:

JASS:
function Trig_Life_Seed_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A009'
endfunction

function Trig_Life_Seed_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit u
    local group g
    local player p
    local string sfx = "Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl"
    local real int = GetHeroInt(caster,true)
    local real heal = 2 * int
    local location loc = GetSpellTargetLoc()
    local location loc2
    local real X
    local real Y
    local integer x = 0
    //Actions//
    set g = GetUnitsInRangeOfLocAll(250, loc)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if IsUnitAlly(u, p) then
            call SetUnitState(u,UNIT_STATE_LIFE,(GetUnitState(u,UNIT_STATE_LIFE)) + heal)            
        endif
        call GroupRemoveUnit(g,u)
        set u = null
    endloop
    call DestroyGroup(g)
    loop
        exitwhen x > 4
        set loc2 = PolarProjectionBJ(loc, 125,(x * 60))
        set X = GetLocationX(loc2)
        set Y = GetLocationY(loc2)            
        call DestroyEffect(AddSpecialEffect(sfx,X,Y))
        call RemoveLocation(loc2) 
        set loc2 = null                     
        set x = x + 1
    endloop
    call RemoveLocation(loc)        
    //Actions//
    set caster = null
    set g = null
    set sfx = null
    set p = null
    set loc = null
endfunction

//===========================================================================
function InitTrig_Life_Seed takes nothing returns nothing
    set gg_trg_Life_Seed = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Life_Seed, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Life_Seed, Condition( function Trig_Life_Seed_Conditions ) )
    call TriggerAddAction( gg_trg_Life_Seed, function Trig_Life_Seed_Actions )
endfunction

My idea for this spell was that it simply did a AoE heal, but instead it does nothing.

Help would be appreciated

Thanks in advance, Quetzalcotl
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Use a static or constant group. This is to avoid leaks and make the code more efficent as you only ever reference that group once at any point in time. Thus all you do is make a global, create a group for it at map initialization and then sinstead of destroying it, you just clear it. Thus you avoid allocating a group each cast, do not have to null the group as it never gets destroyed and it will always be resuable. The only set above is to use a group recycling system. This is to prevent the memory leaks groups cause due to poor memory management acording to purplepoot.
 
Status
Not open for further replies.
Top