HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why this Summon has First Cast Leak?

03-01-2007, 02:04 AM#1
GALLED
Hello Everybody,

I'm make a summon spell that check the mana of the caster and give this value to the hp of the unit summoned, aditionaly add some abilities for the summon unit, but has the first cast leak. Why?

(I'm using the SetUnitMaxState System's Blade.tk)

Collapse JASS:
function Trig_newguardian_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetSummonedUnit()) == 'n011' 
endfunction

function Trig_newguardian_Actions takes nothing returns nothing
local unit u= GetSummoningUnit()
local unit guardian=GetSummonedUnit()
local integer l1 = GetUnitAbilityLevel(u,'AHwe')
local integer l2 = GetUnitAbilityLevel(u,'AUdd')
local integer l3 = GetUnitAbilityLevel(u,'A07U')
local real mana = GetUnitState(u,UNIT_STATE_MAX_MANA)
local integer newval = R2I(100 + mana)
//Abilities for level of the spell
    call UnitDamageTarget(u,u,25*l1,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,null) 
    call UnitAddAbility(guardian, 'A003')
    call SetUnitAbilityLevel(guardian, 'A003',l1 )
    if(l1>=2)then
        call UnitAddAbility(guardian, 'A09O')    
    endif
    if(l1>=3)then
        call UnitAddAbility(guardian, 'Amed')    
        call UnitAddAbility(guardian, 'Amel')        
        call UnitAddAbility(guardian, 'Sch2')     
    endif
    if(l1>=4)then
        call UnitAddAbility(guardian, 'A080')    
    endif
//Bonus abilties
    set newval = newval+(100*l2)
    call SetUnitMaxState(guardian,UNIT_STATE_MAX_LIFE,newval)
    call UnitAddAbility(guardian, 'A07V')
    call SetUnitAbilityLevel(guardian, 'A07V',l3 )    
    
set u = null
set guardian = null
endfunction

//===========================================================================
function InitTrig_newguardian takes nothing returns nothing
    set gg_trg_newguardian = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_newguardian, EVENT_PLAYER_UNIT_SUMMON )
    call TriggerAddCondition( gg_trg_newguardian, Condition( function Trig_newguardian_Conditions ) )
    call TriggerAddAction( gg_trg_newguardian, function Trig_newguardian_Actions )
endfunction


Thanks in advance
03-01-2007, 02:09 AM#2
Rising_Dusk
See all those UnitAddAbility() calls?
Preload all of those abilities by putting them on a unit that's preplaced on the map and removed at map initialization.

That will remove first cast lag.
03-01-2007, 02:14 AM#3
GALLED
Thanks!