HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell Desyncs

03-22-2010, 03:45 AM#1
Saishy
If I cast this spell on multiplayer games, it will do a fatal error:

Collapse JASS:
scope KakeruRyu initializer Init_Kakeru

globals
    private constant integer ID = 'A036'
    private constant integer EFFECT = 'h003'
    private constant integer GUST = 'h00M'
    private constant real RADIUS1 = 300
    private constant real RADIUS2 = 700
    private constant string SOUND1 = "Sound\\Units\\Combat\\MetalLightSliceFlesh2.wav"
    private constant string SOUND2 = "Sound\\Units\\Combat\\MetalHeavySliceFlesh1.wav"
    private constant string MESSAGE1 = "Hiten Mitsurugi Ryu"
    private constant string MESSAGE2 = "Amakakeru Ryu no Hirameki!"
    private constant real TIMER = 0.65
endglobals

private struct kakeru_data
    unit caster
    real damage1
    real damage2
    real tx
    real ty
    integer count
endstruct

function Kakeru_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == ID)
endfunction

function Kakeru_Finish takes nothing returns nothing
    local kakeru_data k = GetTimerData(GetExpiredTimer())
    local group ngroup = CreateGroup()
    local unit tu
    
    set k.count = k.count + 1
    
    if (k.count == 1) then
        call SetUnitTimeScale(k.caster, 1.)
        call SetUnitAnimationByIndex(k.caster, 2)
    else
        call RunSoundOnUnit(DefineSoundEx(SOUND2, 2000, false, true, true, 1, 1, "CombatSoundsEAX"), k.caster)
        call DisplayText(k.caster, MESSAGE2, 1)
        call DestroyTree(k.tx, k.ty, RADIUS2)
        call GroupEnumUnitsInRange(ngroup, k.tx, k.ty, RADIUS1, null)
        loop
            set tu = FirstOfGroup(ngroup)
            exitwhen (tu == null)
            if TargetCheck(k.caster, tu) then
                call UnitDamageTargetEx(k.caster, tu, k.damage2, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_SPELL, false, true)
            endif
            call GroupRemoveUnit(ngroup, tu)
        endloop
    
        call PauseUnit(k.caster, false)
        call SetUnitInvulnerable(k.caster, false)
        call DestroyGroup(ngroup)
        set ngroup = null
        set k.caster = null
        call k.destroy()
        call ReleaseTimer(GetExpiredTimer())
    endif
endfunction

function Kakeru_Actions takes nothing returns nothing
    local kakeru_data k = GetTimerData(GetExpiredTimer())
    local timer t
    local integer level
    local group ngroup = CreateGroup()
    local unit tu
    local real dist
    local real dx
    local real dy
    local real angle
    
    set k.caster = GetTriggerUnit()
    set level = GetUnitAbilityLevel(k.caster, ID)
    set k.tx = GetSpellTargetX()
    set k.ty = GetSpellTargetY()
    set k.damage1 = 50 * level
    set k.damage2 = 20 + (50 * level) + GetHeroAgi(k.caster, true)
    set k.count = 0
    
    call PauseUnit(k.caster, true)
    call SetUnitInvulnerable(k.caster, true)
    call SetUnitTimeScale(k.caster, 0.7)
    call SetUnitAnimationByIndex(k.caster, 1)
    call DisplayText(k.caster, MESSAGE1, 1)
    call RunSoundOnUnit(DefineSoundEx(SOUND1, 2000, false, true, true, 1, 1, "CombatSoundsEAX"), k.caster)
    
    call GroupEnumUnitsInRange(ngroup, k.tx, k.ty, RADIUS1, null)
    loop
        set tu = FirstOfGroup(ngroup)
        exitwhen (tu == null)
        if TargetCheck(k.caster, tu) then
            call UnitDamageTargetEx(k.caster, tu, k.damage1, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_SPELL, false, true)
        endif
        call GroupRemoveUnit(ngroup, tu)
    endloop
    
    call GroupEnumUnitsInRange(ngroup, k.tx, k.ty, RADIUS2, null)
    loop
        set tu = FirstOfGroup(ngroup)
        exitwhen (tu == null)
        if TargetCheck(k.caster, tu) then
            set dx = GetUnitX(tu) - k.tx
            set dy = GetUnitY(tu) - k.ty
            set dist = SquareRoot(dx * dx + dy * dy)
            set angle = bj_RADTODEG * Atan2(-dy, -dx)
            call KnockbackTarget(k.caster, tu, angle, dist+100, dist+1, false, false, false)
        endif
        call GroupRemoveUnit(ngroup, tu)
    endloop
    
    set tu = CreateUnit(GetOwningPlayer(k.caster), EFFECT, k.tx, k.ty, 0)
    call SetUnitScale(tu, 3., 3., 1.)
    call SetUnitVertexColor(tu, 0, 50, 255, 190)
    call UnitApplyTimedLife(tu, 'BTLF', 1.2)
    call SetUnitX(tu, k.tx)
    call SetUnitY(tu, k.ty)
    
    set tu = CreateUnit(GetOwningPlayer(k.caster), GUST, k.tx, k.ty, 0)
    call UnitApplyTimedLife(tu, 'BTLF', 1.2)
    call SetUnitVertexColor(tu, 255, 255, 255, 100)
    call SetUnitX(tu, k.tx)
    call SetUnitY(tu, k.ty)
    
    call DestroyGroup(ngroup)
    set ngroup = null
    set tu = null
    set t = NewTimer()
    call SetTimerData(t, k)
    call TimerStart(t, TIMER, true, function Kakeru_Finish)
endfunction

//===========================================================================
function Init_Kakeru takes nothing returns nothing
    local trigger trg_Kakeru = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trg_Kakeru, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trg_Kakeru, Condition(function Kakeru_Conditions))
    call TriggerAddAction(trg_Kakeru, function Kakeru_Actions )
    set trg_Kakeru = null
endfunction

endscope

I wonder why.
(It could also be because its not player(0) casting it).
03-22-2010, 04:18 AM#2
DioD
call TriggerAddAction(trg_Kakeru, function Kakeru_Actions )
function Kakeru_Actions takes nothing returns nothing
local kakeru_data k = GetTimerData(GetExpiredTimer())

LOL???
03-22-2010, 01:42 PM#3
Saishy
Quote:
Originally Posted by DioD
call TriggerAddAction(trg_Kakeru, function Kakeru_Actions )
function Kakeru_Actions takes nothing returns nothing
local kakeru_data k = GetTimerData(GetExpiredTimer())

LOL???


Thanks kind sir.