HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JASS: Frost Nova - Difficulties

10-04-2006, 04:46 PM#1
Fulla
I thought id try to make a version with globals first to c if I could get it fully working.

Then upgrade to tables (learn how to use that as well).

Collapse JASS:
function Trig_frostnova_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A0CU'
endfunction

function frostnova_Conditions_alive takes nothing returns boolean
    return (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.) and IsUnitEnemy(GetFilterUnit(), udg_tempplayer)
endfunction

function Trig_frostnova_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy
    local group pause = CreateGroup()
    local group unpause = CreateGroup()
    local real newx = GetUnitX(caster)
    local real newy = GetUnitY(caster)
    local real damage
    local real duration
    local integer counter = 0
    local integer level = GetUnitAbilityLevel(caster, 'A0CU')
    local boolexpr b  = Condition(function frostnova_Conditions_alive)
    set damage = (50 * (I2R(level)))
    set duration = (1 * (I2R(level)))
    set udg_tempplayer = GetOwningPlayer(caster)
    call DestroyEffect(AddSpecialEffect("war3mapImported\\FrostNova.mdx", newx, newy))
    call GroupEnumUnitsInRange(pause, newx, newy, 300, b)
    call GroupEnumUnitsInRange(unpause, newx, newy, 300, b)
        loop
        set dummy = FirstOfGroup(pause)
        exitwhen dummy == null
        call UnitDamageTargetBJ(caster, dummy, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
        set counter = (counter +1)
        set newx = GetUnitX(dummy)
        set newy = GetUnitY(dummy)
        call PauseUnit(dummy, true)
        call AddSpecialEffectLocBJ( Location(newx, newy), "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl")
        set udg_tempeffect[counter] = GetLastCreatedEffectBJ()
        call GroupRemoveUnit(pause, dummy)
        endloop
    call TriggerSleepAction(duration)
        loop
        call DestroyEffectBJ(udg_tempeffect[counter])
        set counter = (counter -1)
        endloop
        loop
        set dummy = FirstOfGroup(unpause)
        exitwhen dummy == null
        call PauseUnit(dummy, false)
        call GroupRemoveUnit(unpause, dummy)
        endloop
    call DestroyGroup(pause)
    call DestroyGroup(unpause)
    set pause = null
    set unpause = null
    set caster = null
    set dummy = null
    set b = null
endfunction

//===========================================================================
function InitTrig_frostnova takes nothing returns nothing
    set gg_trg_frostnova = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_frostnova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_frostnova, function Trig_frostnova_Actions )
    call TriggerAddCondition( gg_trg_frostnova, Condition( function Trig_frostnova_Conditions ) )
endfunction

It doesnt unpause the units, I cant understand or see a reason why?

I also need to add the special effect to the units instead of points, but got stuck there.
10-04-2006, 05:10 PM#2
Captain Griffen
Collapse JASS:
        loop
        call DestroyEffectBJ(udg_tempeffect[counter])
        set counter = (counter -1)
        endloop

Hits execution limit.

You also randomly use BJs, and stuff like that. Rather than enuming the unpause group, adding them in the first loop would work better. I2R isn't needed in JASS. Use GetWidgetLife(unit) > 0.405 to tell if a unit is alive (faster and more accurate), small changes like that would be good.
10-04-2006, 05:23 PM#3
Vexorian
Quote:
I2R isn't needed in JASS
it is, on some return values...

Collapse JASS:
function Trig_frostnova_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A0CU'
endfunction

function frostnova_Conditions_alive takes nothing returns boolean
    return (GetWidgetLife(GetFilterUnit)>0.405) and IsUnitEnemy(GetFilterUnit(), udg_tempplayer)
endfunction

function Trig_frostnova_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy
    local group pause = CreateGroup()
    local group unpause = CreateGroup()
    local real newx = GetUnitX(caster)
    local real newy = GetUnitY(caster)
    local real damage
    local real duration
    local integer counter = 0
    local integer level = GetUnitAbilityLevel(caster, 'A0CU')
    local boolexpr b  = Condition(function frostnova_Conditions_alive) //must use DestroyBoolExpr later
    set damage = 50.0 * level
    set duration = 1.0 * level
    set udg_tempplayer = GetOwningPlayer(caster)
    call DestroyEffect(AddSpecialEffect("war3mapImported\\FrostNova.mdx", newx, newy))
    call GroupEnumUnitsInRange(pause, newx, newy, 300, b)
    call GroupEnumUnitsInRange(unpause, newx, newy, 300, b)
        loop
        set dummy = FirstOfGroup(pause)
        exitwhen dummy == null
        call UnitDamageTargetBJ(caster, dummy, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
        set counter = (counter +1)
        set newx = GetUnitX(dummy)
        set newy = GetUnitY(dummy)
        call PauseUnit(dummy, true)
        call AddSpecialEffectLocBJ( Location(newx, newy), "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl") //BJ and memory leak
        set udg_tempeffect[counter] = GetLastCreatedEffectBJ() //BJ use bj_lastCreatedEffect instead
        call GroupRemoveUnit(pause, dummy)
        endloop
    call TriggerSleepAction(duration)
        loop
        call DestroyEffectBJ(udg_tempeffect[counter])
        set counter = (counter -1)
        missing exitwhen
        endloop
        
        //Add:
        call GroupAddUnit(unpause,null)
        // although ForGroup might work the same

        
        loop
        set dummy = FirstOfGroup(unpause)
        exitwhen dummy == null
        call PauseUnit(dummy, false)
        call GroupRemoveUnit(unpause, dummy)
        endloop
    call DestroyGroup(pause)
    call DestroyGroup(unpause)
    set pause = null
    set unpause = null
    set caster = null
    set dummy = null
    set b = null
endfunction

//===========================================================================
function InitTrig_frostnova takes nothing returns nothing
    set gg_trg_frostnova = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_frostnova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_frostnova, function Trig_frostnova_Actions )
    call TriggerAddCondition( gg_trg_frostnova, Condition( function Trig_frostnova_Conditions ) )
endfunction
10-04-2006, 07:48 PM#4
Fulla
Thx alot guys, it now works fine, I also fixed/redid the recommendations.

Now I need to begin using the dreaded tables, I need advice/help here .

Ill need to store the 2nd group and the SFX's to make it fully multi-instanceable.

Current Code:
Collapse JASS:
function Trig_frostnova_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A0CU'
endfunction

function frostnova_Conditions_alive takes nothing returns boolean
    return (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.) and IsUnitEnemy(GetFilterUnit(), udg_tempplayer)
endfunction

function Trig_frostnova_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit dummy
    local effect ice
    local group pause = CreateGroup()
    local group unpause = CreateGroup()
    local real newx = GetUnitX(caster)
    local real newy = GetUnitY(caster)
    local real damage
    local real duration
    local integer counter = 0
    local integer level = GetUnitAbilityLevel(caster, 'A0CU')
    local boolexpr b  = Condition(function frostnova_Conditions_alive)
    set damage = (50 * (I2R(level)))
    set duration = (1 * (I2R(level)))
    set udg_tempplayer = GetOwningPlayer(caster)
    call DestroyEffect(AddSpecialEffect("war3mapImported\\FrostNova.mdx", newx, newy))
    call GroupEnumUnitsInRange(pause, newx, newy, 300, b)
    call GroupEnumUnitsInRange(unpause, newx, newy, 300, b)
        loop
        set dummy = FirstOfGroup(pause)
        exitwhen dummy == null
        call UnitDamageTargetBJ(caster, dummy, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
        set counter = (counter +1)
        call PauseUnit(dummy, true)
        call AddSpecialEffectTargetUnitBJ( "origin", dummy, "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl")
        set udg_tempeffect[counter] = bj_lastCreatedEffect
        call GroupRemoveUnit(pause, dummy)
        endloop
    call TriggerSleepAction(duration)
        loop
        exitwhen counter == 0
        call DestroyEffectBJ(udg_tempeffect[counter])
        set counter = (counter -1)
        endloop
        loop
        set dummy = FirstOfGroup(unpause)
        exitwhen dummy == null
        call PauseUnit(dummy, false)
        call GroupRemoveUnit(unpause, dummy)
        endloop
    call DestroyBoolExpr(b)
    call DestroyGroup(pause)
    call DestroyGroup(unpause)
    set pause = null
    set unpause = null
    set caster = null
    set dummy = null
    set b = null
endfunction

//===========================================================================
function InitTrig_frostnova takes nothing returns nothing
    set gg_trg_frostnova = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_frostnova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_frostnova, function Trig_frostnova_Actions )
    call TriggerAddCondition( gg_trg_frostnova, Condition( function Trig_frostnova_Conditions ) )
endfunction

PS: I tried the (GetWidgetLife(GetFilterUnit)>0.405), it didnt like that, and wouldnt complie :/
10-05-2006, 12:04 AM#5
The_AwaKening
GetWidgetLife(GetFilterUnit)>0.405

would need to be

GetWidgetLife(GetFilterUnit())>0.405
10-05-2006, 12:09 PM#6
Chuckle_Brother
Why do you need tables? As it stands this is fully MUI, since you used no globals.

Edit: Since this is going in DoD, for my sanity I would like for you to use a better naming standard(for functions)

Trig_frostnova_Conditions becomes FrostNova_CastCons
frostnova_Conditions_alive becomes FrostNova_ValidTargs
Trig_frostnova_Actions becomes FrostNova_CastActs

Again, purely for my sanity when it comes to reading the code so I needn't wade through badly named code.
10-05-2006, 12:18 PM#7
Fulla
Yea I did use globals to save the Special effects then destroy them after the 'duration'

Would tables not be needed for them?
10-05-2006, 02:03 PM#8
Chuckle_Brother
Oh my you did, well just use a local array for them instead of a global.

Collapse JASS:
local effect array SFX