JASS Edit

Karawasa

Element Tower Defense
Reaction score
38
Hey Guys,

I have below a slightly modified version of the "Domino Theory." You will notice when the caster gets attacked, everything gets shuffled. What I need, is for this "shuffle," to occur after the images are created originally. So, spell is cast, images are created in a line and then it shuffles right after the last image is made. So just that addition and I am golden!

Code:
//***************************************************************************************************************
//*                                                                                                             *
//*                                     D O M I N O  T H E O R Y                                                *
//*                                            Actual Code                                                      *
//*                                                v1.0                                                         *
//*                                                                                                             *
//*                                          By: Rising_Dusk                                                    *
//*                                                                                                             *
//***************************************************************************************************************

//***************************************************************************************************************
//*These are the input constants for the spell's use in any given map.
//*
constant function DThe_HeroAbility takes nothing returns integer
    return 'A000'         //Rawcode of the Domino Theory hero ability in your map.
endfunction

constant function DThe_IllusionAbility takes nothing returns integer
    return 'A001'         //Rawcode of the Domino Theory illusion ability in your map.
endfunction

constant function DThe_IllusionDummy takes nothing returns integer
    return 'h000'         //Rawcode of a dummy caster in your map. 
endfunction

constant function DThe_IllusionCount takes integer level returns integer
    return 1+(1*level)    //Count of how many illusions are created in domino fashion. 
endfunction

constant function DThe_IllusionInterval takes integer level returns real
    return .25+(0*level)  //This is the time between illusion spawns.
endfunction

constant function DThe_LevelUpIllusion takes nothing returns boolean
    return true           //If this is true, the illusion spell on the dummy units will 
                          //level with the hero spell. If false it simply will not.
endfunction

constant function DThe_MaxDistOfIllu takes integer level returns real
    return 100.0+(0*level)//This returns the distance between the caster and the illusions spawned.
endfunction

constant function DThe_CasterFX takes nothing returns string
    return "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
                          //This is the FX played on the caster when images are being made.
endfunction

constant function DThe_IlluFX takes nothing returns string
    return "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
                          //This is the FX played on the illusions when summoned.
endfunction

constant function DThe_ShuffleFX takes nothing returns string
    return "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl"
                          //This is the FX played when the images and caster are shuffled.
endfunction

//***************************************************************************************************************
//*                                                                                                             *
//*                                       Custom Functions [MISC]                                               *
//*                                                                                                             *
//***************************************************************************************************************

//***************************************************************************************************************
//*                                                                                                             *
//*                                     End Custom Functions [MISC]                                             *
//*                                                                                                             *
//***************************************************************************************************************

function DThe_Base_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == DThe_HeroAbility()
endfunction

function DThe_IlluCast_Conditions takes nothing returns boolean
    return IsUnitIllusion(GetSummonedUnit()) and GetUnitTypeId(GetSummoningUnit()) == DThe_IllusionDummy() and GetHandleInt(GetSummoningUnit(), "r") == 1
endfunction

function DThe_Shuffle_Death_Actions takes nothing returns nothing
    local trigger death = GetTriggeringTrigger()
    local triggeraction deatha = GetHandleTriggerAction(death, "deatha")
    local trigger dmg = GetHandleTrigger(death, "dmg")
    local triggeraction dmga = GetHandleTriggerAction(death, "dmga")
    local group g = GetHandleGroup(death, "g")
    local unit u = GetDyingUnit()
    local integer count
    
    if IsUnitInGroup(u, g) then
        call GroupRemoveUnit(g, u)
        set bj_groupCountUnits = 0
        call ForGroup(g, function CountUnitsInGroupEnum)
        set count = bj_groupCountUnits
        if count <= 0 then
            call FlushLocals(death)
            call TriggerRemoveAction(death, deatha)
            call DestroyTrigger(death)
            call FlushLocals(dmg)
            call TriggerRemoveAction(dmg, dmga)
            call GroupClear(g)
            call DestroyGroup(g)
        endif
    endif
    
    set deatha = null
    set death = null
    set dmga = null
    set dmg = null
    set g = null
endfunction

function DThe_Shuffle_Actions takes nothing returns nothing
    local trigger trg = GetTriggeringTrigger()
    local group g = GetHandleGroup(trg, "g")
    local group g2 = CreateGroup()
    local group g3 = CreateGroup()
    local unit u = GetHandleUnit(trg, "u")
    local unit s
    local unit d
    local real x1
    local real x2
    local real y1
    local real y2
        
    set bj_groupAddGroupDest = g2
    call ForGroup(g, function GroupAddGroupEnum)
    call GroupAddUnit(g2, u)
    set bj_groupAddGroupDest = g3
    call ForGroup(g2, function GroupAddGroupEnum)
    loop
        set s = FirstOfGroup(g2)
        exitwhen s == null
        set d = GroupPickRandomUnit(g3)
        set x1 = GetUnitX(s)
        set y1 = GetUnitY(s)
        set x2 = GetUnitX(d)
        set y2 = GetUnitY(d)
        call SetUnitX(d, x1)
        call SetUnitY(d, y1)
        call ShowUnit(d, false)
        call ShowUnit(d, true)
        if GetLocalPlayer() == GetOwningPlayer(d) then
            call SelectUnit(d, true)
        endif
        call DestroyEffect(AddSpecialEffectTarget(DThe_ShuffleFX(), d, "chest"))
        call SetUnitX(s, x2)
        call SetUnitY(s, y2)
        call ShowUnit(s, false)
        call ShowUnit(s, true)
        if GetLocalPlayer() == GetOwningPlayer(s) then
            call SelectUnit(s, true)
        endif
        call DestroyEffect(AddSpecialEffectTarget(DThe_ShuffleFX(), s, "chest"))
        call GroupRemoveUnit(g2, s)
    endloop
    
    call GroupClear(g2)
    call DestroyGroup(g2)
    call GroupClear(g3)
    call DestroyGroup(g3)
    set trg = null
    set g2 = null
    set g3 = null
    set d = null
    set s = null
    set g = null
    set u = null
endfunction

function DThe_IlluSpawn_Timer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local trigger trg = GetHandleTrigger(t, "trg")
    local unit u = GetHandleUnit(t, "u")
    local unit d = CreateUnit(GetOwningPlayer(u), DThe_IllusionDummy(), GetUnitX(u)+300, GetUnitX(u)+300, 0)
    local integer lvl = GetHandleInt(t, "lvl")
    local integer i = GetHandleInt(trg, "i")
    
    if i > 1 then
        call UnitAddAbility(d, 'Aloc')
        call UnitAddAbility(d, 'Avul')
        call UnitAddAbility(d, DThe_IllusionAbility())
        if DThe_LevelUpIllusion() then
            call SetUnitAbilityLevel(d, DThe_IllusionAbility(), lvl)
        endif
        call SetHandleInt(d, "r", 1)
        call IssueTargetOrderById(d, 852274, u)
        call UnitApplyTimedLife(d, 'BTLF', 1.0)
    endif
    
    set trg = null
    set t = null
    set d = null
endfunction

function DThe_IlluCast_Actions takes nothing returns nothing
    local trigger trg = GetTriggeringTrigger()
    local triggeraction ta = GetHandleTriggerAction(trg, "ta")
    local triggercondition tc = GetHandleTriggerCondition(trg, "tc")
    local timer t = GetHandleTimer(trg, "t")
    local unit sd = GetSummonedUnit()
    local unit lc = GetHandleUnit(trg, "lc")
    local unit u = GetHandleUnit(trg, "u")
    local integer i = GetHandleInt(trg, "i")
    local integer lvl = GetUnitAbilityLevel(u, DThe_HeroAbility())
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real a = 57.29582 * Atan2(GetUnitY(lc) - y, GetUnitX(lc) - x)
    local real d = DThe_MaxDistOfIllu(lvl)
    local group g = GetHandleGroup(trg, "g")
    
    local trigger dmg
    local triggeraction dmga
    local trigger death
    local triggeraction deatha
    
    if lc == null then
        set a = GetUnitFacing(u)+90
    else
        set x = GetUnitX(lc)
        set y = GetUnitY(lc)
    endif
    set x = x + d * Cos(a * 0.01745)
    set y = y + d * Sin(a * 0.01745)
    call SetUnitPosition(sd, x, y)
    call SetUnitFacing(sd, GetUnitFacing(u))
    if GetLocalPlayer() == GetOwningPlayer(u) then
        call SelectUnit(sd, true)
    endif
    call DestroyEffect(AddSpecialEffect(DThe_CasterFX(), GetUnitX(u), GetUnitY(u)))
    call DestroyEffect(AddSpecialEffect(DThe_IlluFX(), GetUnitX(sd), GetUnitY(sd)))
    call GroupAddUnit(g, sd)
    call SetHandleInt(trg, "i", i-1)
    call SetHandleHandle(trg, "lc", sd)
    set i = i-1
    if i == 0 then
        call FlushLocals(trg)
        call TriggerRemoveAction(trg, ta)
        call TriggerRemoveCondition(trg, tc)
        call DestroyTrigger(trg)
        
        call FlushLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
       
        set dmg = CreateTrigger()
        set dmga = TriggerAddAction(dmg, function DThe_Shuffle_Actions)
        set death = CreateTrigger()
        set deatha = TriggerAddAction(death, function DThe_Shuffle_Death_Actions)
        call TriggerRegisterUnitEvent(dmg, u, EVENT_UNIT_ATTACKED)
        call TriggerRegisterAnyUnitEventBJ(death, EVENT_PLAYER_UNIT_DEATH)
        call SetHandleHandle(dmg, "g", g)
        call SetHandleHandle(dmg, "u", u)
        call SetHandleHandle(death, "g", g)
        call SetHandleHandle(death, "dmg", dmg)
        call SetHandleHandle(death, "dmga", dmga)
        call SetHandleHandle(death, "deatha", deatha)
    endif
    
    set deatha = null
    set death = null
    set dmga = null
    set dmg = null
    set trg = null
    set ta = null
    set tc = null
    set sd = null
    set lc = null
    set g = null
    set t = null
    set u = null
endfunction

function DThe_Base_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local timer t = CreateTimer()
    local integer lvl = GetUnitAbilityLevel(u, DThe_HeroAbility())
    local group g = CreateGroup()
    local boolexpr b = Condition(function DThe_IlluCast_Conditions)
    
    local trigger trg = CreateTrigger()
    local triggeraction ta = TriggerAddAction(trg, function DThe_IlluCast_Actions)
    local triggercondition tc = TriggerAddCondition(trg, b)
    call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_SUMMON)
    
    call SetHandleHandle(trg, "u", u)
    call SetHandleHandle(trg, "ta", ta)
    call SetHandleHandle(trg, "tc", tc)
    call SetHandleHandle(trg, "lc", null)
    call SetHandleHandle(trg, "t", t)
    call SetHandleHandle(trg, "g", g)
    call SetHandleInt(trg, "i", DThe_IllusionCount(lvl))
    
    call SetHandleInt(t, "lvl", lvl)
    call SetHandleHandle(t, "u", u)
    call SetHandleHandle(t, "trg", trg)
    call TimerStart(t, DThe_IllusionInterval(lvl), true, function DThe_IlluSpawn_Timer)
    
    call DestroyBoolExpr(b)
    set trg = null
    set b = null
    set g = null
    set t = null
    set u = null
endfunction

//******************************************************************************
//*This is the InitTrig. Hooray, InitTrig!
//*
function InitTrig_DThe takes nothing returns nothing
    set gg_trg_DThe = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_DThe, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_DThe, Condition(function DThe_Base_Conditions))
    call TriggerAddAction(gg_trg_DThe, function DThe_Base_Actions)
endfunction

Also, this spell uses a modified Handle Variable system. If possible, could someone convert it over to use the standard Kattana's Handle Variable system?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top