Spell Elemental Tri Fury

Tom Jones

N/A
Reaction score
437
Yes you can simply check for the casters current order everytime the timer runs, it just as efficient. The only thing is that'll require you to have another constant function that returned the order string. Or store the current order string on the unit.
 

Tinki3

Special Member
Reaction score
418
Sorry to double post, but after I finished editing the trigger, and tested it, most of the time, only the Create_Fire function worked.

This is what I've got atm:
Code:
function Create_Ice takes nothing returns nothing
    local timer ttt         = GetExpiredTimer()
    local unit cast         = GetHandleUnit(ttt, "cast")
    local real offset       = GetHandleReal(ttt, "offset")
    local real count        = GetHandleReal(ttt, "count")
    local location cast_loc = GetUnitLoc(cast)
    local integer i         = 0
    local unit array dum           
    local location array l
    set l[1]                = PolarProjectionBJ(cast_loc, offset, 0)
    set l[2]                = PolarProjectionBJ(cast_loc, offset, 45)
    set l[3]                = PolarProjectionBJ(cast_loc, offset, 90)
    set l[4]                = PolarProjectionBJ(cast_loc, offset, 135)
    set l[5]                = PolarProjectionBJ(cast_loc, offset, 180)
    set l[6]                = PolarProjectionBJ(cast_loc, offset, 225)
    set l[7]                = PolarProjectionBJ(cast_loc, offset, 270)
    set l[8]                = PolarProjectionBJ(cast_loc, offset, 315)

    loop
        set i = i + 1
        exitwhen i > 8
        set dum[i]          = CreateUnitAtLoc(GetOwningPlayer(cast), Ice_Caster_Dummy_ID(),l[i] ,0)
        call SetUnitAbilityLevel(dum[i], Ice_Dummy_Ability_ID(),(GetUnitAbilityLevel(cast, ETF_Ability_ID())))
    endloop
    set i = 0

    if GetWidgetLife(cast) > 0.405 and count < 3 then
        loop
            set i = i + 1
            exitwhen i > 8
            call IssueImmediateOrder(dum[i], "thunderclap")
        endloop
        set i = 0
    elseif GetHandleBoolean(cast,"Stop_Timer") == true then
        call PauseTimer(ttt)
        call SetHandleBoolean(cast,"Stop_Timer", false)
        call FlushHandleLocals(ttt)
        call DestroyTimer(ttt)
    else
        call FlushHandleLocals(ttt)
        call PauseTimer(ttt)
        call DestroyTimer(ttt)
    endif

    call SetHandleReal(ttt, "count", GetHandleReal(ttt, "count") + 1)
    call SetHandleReal(ttt, "offset", GetHandleReal(ttt, "offset") + Ice_Dummy_Unit_Offset_Increase_Value()) 

    call RemoveLocation(cast_loc)
    loop
       set i = i + 1
       exitwhen i > 8
           call RemoveLocation (l[i])          
    endloop
    set i = 0

    set ttt = null
    set cast = null
    set cast_loc = null
    loop
       set i = i + 1
       exitwhen i > 8
           set l[i] = null
           set dum[i] = null
    endloop
endfunction

function Create_Electricity takes nothing returns nothing
    local timer tt          = GetExpiredTimer()
    local unit cast         = GetHandleUnit(tt, "cast") 
    local real count        = GetHandleReal(tt, "count")
    local location cast_loc = GetUnitLoc(cast)
    local location l        = PolarProjectionBJ(cast_loc, GetRandomReal(Electricity_Min_Offset(), Electricity_Max_Offset()), GetRandomDirectionDeg())
    local unit dum          = CreateUnitAtLoc(GetOwningPlayer(cast), Electric_Caster_Dummy_ID(),l ,0)
    local group g           = CreateGroup()
    local boolexpr b        = Condition(function ETF_Filter)
    local unit p
    local integer i
    local timer ttt

    call SetUnitAbilityLevel(dum, Electric_Dummy_Ability_ID(),(GetUnitAbilityLevel(cast, ETF_Ability_ID())))

    if GetWidgetLife(cast) > 0.405 and count < 9 then
        call GroupEnumUnitsInRange(g, GetUnitX(dum), GetUnitY(dum), 200, b)
        set i = CountUnitsInGroup(g)
        if i > 0 then
            set p = GroupPickRandomUnit(g)
            call IssueTargetOrder(dum, "chainlightning", p)
            set p = null
        endif
    elseif GetHandleBoolean(cast,"Stop_Timer") == true then
        call SetHandleBoolean(cast,"Stop_Timer", false)
        call FlushHandleLocals(tt)
        call PauseTimer(tt)
        call DestroyTimer(tt)
    else
        set ttt = CreateTimer()
        call SetHandleHandle(ttt, "cast", cast)
        call SetHandleReal(ttt, "offset", 50)
        call SetHandleReal(ttt, "count", 0)
        call TimerStart(ttt, Ice_Timer_Delay(), true, function Create_Ice)
        set ttt = null
        call FlushHandleLocals(tt)
        call PauseTimer(tt)
        call DestroyTimer(tt)
    endif

    call SetHandleReal(tt, "count", GetHandleReal(tt, "count") + 1)

    call RemoveLocation(cast_loc)
    call RemoveLocation(l)
    call DestroyGroup(g)
    call DestroyBoolExpr(b)

    set tt = null
    set cast = null
    set cast_loc = null
    set l = null
    set dum = null
    set g = null
    set b = null
endfunction

function Create_Fire takes nothing returns nothing
    local timer t           = GetExpiredTimer()
    local unit cast         = GetHandleUnit(t, "cast")
    local real angle        = GetHandleReal(t, "angle")
    local real count        = GetHandleReal(t, "count")
    local location cast_loc = GetUnitLoc(cast)
    local location l        = PolarProjectionBJ(cast_loc, Fire_Creation_Base_Offset(), angle)
    local unit dum          = CreateUnitAtLoc(GetOwningPlayer(cast), Fire_Caster_Dummy_ID(),l ,0)
    local timer tt          

    call SetUnitAbilityLevel(dum, Fire_Dummy_Ability_ID(),(GetUnitAbilityLevel(cast, ETF_Ability_ID())))

    if GetWidgetLife(cast) > 0.405 and count < 10 then
        call IssuePointOrderLoc(dum, "flamestrike", l)
    elseif GetHandleBoolean(cast,"Stop_Timer") == true then
        call SetHandleBoolean(cast,"Stop_Timer", false)
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
    else
        set tt = CreateTimer()
        call SetHandleHandle(tt, "cast", cast)
        call SetHandleReal(tt, "count", 0)
        call TimerStart(tt, Electricity_Timer_Delay(), true, function Create_Electricity)
        set tt = null
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)        
    endif
 
    call SetHandleReal(t, "angle", GetHandleReal(t, "angle") + Fire_Creation_Angle_Increase())
    call SetHandleReal(t, "count", GetHandleReal(t, "count") + 1)

    call RemoveLocation(cast_loc)
    call RemoveLocation(l)

    set t = null
    set cast = null
    set cast_loc = null
    set l = null
    set dum = null
endfunction

function Elemental_Tri_Fury_Actions takes nothing returns nothing
    local unit cast         = GetTriggerUnit()
    local location cast_loc = GetUnitLoc(cast)
    local timer t           = CreateTimer()

    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        call SetHandleHandle(t, "cast", cast)
        call SetHandleReal(t, "angle", GetRandomInt(1, 360))
        call SetHandleReal(t, "count", 0)
        call TimerStart(t, Fire_Timer_Delay(), true, function Create_Fire)
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
        call SetHandleBoolean(cast,"Stop_Timer",true)
    endif

    call RemoveLocation(cast_loc)

    set cast = null
    set cast_loc = null
    set t = null    
endfunction

function InitTrig_Elemental_Tri_Fury takes nothing returns nothing    
    set gg_trg_Elemental_Tri_Fury = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Elemental_Tri_Fury, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Elemental_Tri_Fury, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    call TriggerAddCondition( gg_trg_Elemental_Tri_Fury, Condition( function Elemental_Tri_Fury_Conditions ) )
    call TriggerAddAction( gg_trg_Elemental_Tri_Fury, function Elemental_Tri_Fury_Actions )
endfunction
What could be the problem?

Thx for all your help Tom
 

waaaks!

Zinctified
Reaction score
255
nice spell

i dont need to test it cause i know this spell is good

screen shots are good

+rep if i can...
 

Tom Jones

N/A
Reaction score
437
Could you update your attached map? I keep getting syntax errors because the new code have some constant functions which the old code doesn't have.

And you'll need to create Elemental_Tri_Fury_Actions timer inside the if statement, else it'll leak when the event id isn't ..._SPELL_EFFECT.
 

AlicanC

New Member
Reaction score
2
I added this to my map and attached the skill to Beastmaster. I went near some creeps and started clicking the button. I clicked 20 times and realized that no damage was done:) What is happening???
 

Tom Jones

N/A
Reaction score
437
Here's a wild guess:

You haven't modified anything inside the trigger, or haven't even copied the trigger. The spell itself isn't enough, what creates the effect is the trigger. Tinkie included a troughout read me, I'll suggest that you read it :)
 

AlicanC

New Member
Reaction score
2
Trigger is there. I also copied map header (or whatever it is), created the GameCache variable and did something to that variable in "Map Initiation" :)
 

AlicanC

New Member
Reaction score
2
AlicanC:

Sounds like you didn't copy the dummy units and dummy abilities.

Read the ReadMe that I included :)
I read it. I have:
-Dummy units
-Dummy abilities
-ETF ability
-Map header code
-ETF trigger code
-I have modified the trigger (A002->A001, A001->A002, A000->A003, A004->A000, h001->h001, h002->h002, h003->h003)
-Created the GameCache variable and did this:
Code:
Custom script:   set udg_GameCache = InitGameCache("jasslocalvars.w3v")

I think I did everything right. I see fire around my hero, then lightning strikes and ice explosion(!). I think these dummy units think that my enemies are my allies and don't hurt them.

Edit: Added a screenshot:
etfdoesnotworkel9.png
 

Tom Jones

N/A
Reaction score
437
After reading your code trougoutly, I discovered that your using three timers were you might as well use one. Using one timer is more efficient, and will make it easier to stop. The updated code:
Code:
constant function Fire_Timer_Delay takes nothing returns real
    return 0.14
endfunction

constant function Electricity_Timer_Delay takes nothing returns real
    return 0.17
endfunction

constant function Ice_Timer_Delay takes nothing returns real
    return 0.20
endfunction

constant function Fire_Creation_Base_Offset takes nothing returns real
    return 300.0  //How far the fire is from the caster's location
endfunction

constant function Fire_Creation_Angle_Increase takes nothing returns real
    return 40.0   //The angle between 2 fire bursts (from caster loc, to that particular fire)
endfunction

constant function Electricity_Min_Offset takes nothing returns real
    return 150.0  //The minimum offset in which electricity can be created at
endfunction

constant function Electricity_Max_Offset takes nothing returns real
    return 500.0  //The maximum offset in which electricity can be created at
endfunction

constant function Ice_Dummy_Unit_Offset_Increase_Value takes nothing returns real
    return 100.0  //The distance between 2 ice bursts 
endfunction

constant function Electric_Caster_Dummy_ID takes nothing returns integer
    return 'h001' 
endfunction

constant function Fire_Caster_Dummy_ID takes nothing returns integer
    return 'h002'
endfunction

constant function Ice_Caster_Dummy_ID takes nothing returns integer
    return 'h003'
endfunction

constant function Fire_Dummy_Ability_ID takes nothing returns integer
    return 'A001'
endfunction

constant function Electric_Dummy_Ability_ID takes nothing returns integer
    return 'A002'
endfunction

constant function Ice_Dummy_Ability_ID takes nothing returns integer
    return 'A000'
endfunction

constant function ETF_Ability_ID takes nothing returns integer
    return 'A004'
endfunction

function ETF_Filter takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetHandleUnit(GetExpiredTimer(), "cast"))) == true
endfunction

function Elemental_Tri_Fury_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ETF_Ability_ID()         
endfunction

function Create_Ice takes nothing returns nothing
[B]    local timer t           = GetExpiredTimer()[/B]
    local unit cast         = GetHandleUnit(t, "cast")
    local real offset       = GetHandleReal(t, "offset")
    local real count        = GetHandleReal(t, "count")
    local location cast_loc = GetUnitLoc(cast)
    local integer i         = 0
    local unit array dum           
    local location array l
    set l[1]                = PolarProjectionBJ(cast_loc, offset, 0)
    set l[2]                = PolarProjectionBJ(cast_loc, offset, 45)
    set l[3]                = PolarProjectionBJ(cast_loc, offset, 90)
    set l[4]                = PolarProjectionBJ(cast_loc, offset, 135)
    set l[5]                = PolarProjectionBJ(cast_loc, offset, 180)
    set l[6]                = PolarProjectionBJ(cast_loc, offset, 225)
    set l[7]                = PolarProjectionBJ(cast_loc, offset, 270)
    set l[8]                = PolarProjectionBJ(cast_loc, offset, 315)

    loop
        set i = i + 1
        exitwhen i > 8
        set dum[i]          = CreateUnitAtLoc(GetOwningPlayer(cast), Ice_Caster_Dummy_ID(),l[i] ,0)
        call SetUnitAbilityLevel(dum[i], Ice_Dummy_Ability_ID(),(GetUnitAbilityLevel(cast, ETF_Ability_ID())))
    endloop
    set i = 0

    if GetWidgetLife(cast) > 0.405 and count < 3 then
        loop
            set i = i + 1
            exitwhen i > 8
            call IssueImmediateOrder(dum[i], "thunderclap")
        endloop
        set i = 0
    else
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
    endif

    call SetHandleReal([B]t[/B], "count", GetHandleReal(t, "count") + 1)
    call SetHandleReal([B]t[/B], "offset", GetHandleReal(t, "offset") + Ice_Dummy_Unit_Offset_Increase_Value()) 

    call RemoveLocation(cast_loc)
    loop
       set i = i + 1
       exitwhen i > 8
           call RemoveLocation (l[i])          
    endloop
    set i = 0

    set t = null
    set cast = null
    set cast_loc = null
    loop
       set i = i + 1
       exitwhen i > 8
           set l[i] = null
           set dum[i] = null
    endloop
endfunction

function Create_Electricity takes nothing returns nothing
[B]    local timer t          = GetExpiredTimer()[/B]
    local unit cast         = GetHandleUnit(t, "cast") 
    local real count        = GetHandleReal(t, "count")
    local location cast_loc = GetUnitLoc(cast)
    local location l        = PolarProjectionBJ(cast_loc, GetRandomReal(Electricity_Min_Offset(), Electricity_Max_Offset()), GetRandomDirectionDeg())
    local unit dum          = CreateUnitAtLoc(GetOwningPlayer(cast), Electric_Caster_Dummy_ID(),l ,0)
    local group g           = CreateGroup()
    local boolexpr b        = Condition(function ETF_Filter)
    local unit p
    local integer i
[I]    //local timer ttt[/I]

    call SetUnitAbilityLevel(dum, Electric_Dummy_Ability_ID(),(GetUnitAbilityLevel(cast, ETF_Ability_ID())))

    if GetWidgetLife(cast) > 0.405 and count < 9 then
        call GroupEnumUnitsInRange(g, GetUnitX(dum), GetUnitY(dum), 200, b)
        set i = CountUnitsInGroup(g)
        if i > 0 then
            set p = GroupPickRandomUnit(g)
            call IssueTargetOrder(dum, "chainlightning", p)
            set p = null
        endif
    else
        //set ttt = CreateTimer()
[B]        call PauseTimer(t)[/B]
[I]        //call SetHandleHandle(t, "cast", cast)[/I][B]        call SetHandleReal(t, "offset", 50)
        call SetHandleReal(t, "count", 0)
        call TimerStart(t, Ice_Timer_Delay(), true, function Create_Ice)
        set t = null[/B]
[I]        //call FlushHandleLocals(tt)
        //call PauseTimer(tt)
        //call DestroyTimer(tt)[/I]
    endif

    call SetHandleReal([B]t[/B], "count", GetHandleReal(t, "count") + 1)

    call RemoveLocation(cast_loc)
    call RemoveLocation(l)
    call DestroyGroup(g)
    call DestroyBoolExpr(b)

    set t = null
    set cast = null
    set cast_loc = null
    set l = null
    set dum = null
    set g = null
    set b = null
endfunction

function Create_Fire takes nothing returns nothing
    local timer t           = GetExpiredTimer()
    local unit cast         = GetHandleUnit(t, "cast")
    local real angle        = GetHandleReal(t, "angle")
    local real count        = GetHandleReal(t, "count")
    local location cast_loc = GetUnitLoc(cast)
    local location l        = PolarProjectionBJ(cast_loc, Fire_Creation_Base_Offset(), angle)
    local unit dum          = CreateUnitAtLoc(GetOwningPlayer(cast), Fire_Caster_Dummy_ID(),l ,0)
[I]    //local timer tt[/I]          

    call SetUnitAbilityLevel(dum, Fire_Dummy_Ability_ID(),(GetUnitAbilityLevel(cast, ETF_Ability_ID())))

    if GetWidgetLife(cast) > 0.405 and count < 10 then
        call IssuePointOrderLoc(dum, "flamestrike", l)
    else
[B]        call PauseTimer(t)[/B] 
[I]        //set tt = CreateTimer()
        //call SetHandleHandle(t, "cast", cast)[/I]
[B]        call SetHandleReal(t, "count", 0)
        call TimerStart(t, Electricity_Timer_Delay(), true, function Create_Electricity)
        set t = null[/B]
[I]        //call FlushHandleLocals(t)
        //call PauseTimer(t)
        //call DestroyTimer(t)        [/I]
    endif
 
    call SetHandleReal([B]t[/B], "angle", GetHandleReal(t, "angle") + Fire_Creation_Angle_Increase())
    call SetHandleReal([B]t[/B], "count", GetHandleReal(t, "count") + 1)

    call RemoveLocation(cast_loc)
    call RemoveLocation(l)

    set t = null
    set cast = null
    set cast_loc = null
    set l = null
    set dum = null
endfunction

function Elemental_Tri_Fury_Actions takes nothing returns nothing
    local unit cast         = GetTriggerUnit()
    local location cast_loc = GetUnitLoc(cast)
    local timer t         

    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        set t = CreateTimer()
        call SetHandleHandle(t, "cast", cast)
        call SetHandleReal(t, "angle", GetRandomInt(1, 360))
        call SetHandleReal(t, "count", 0)
[B]        call SetHandleHandle(cast,"ElementalTriFury_t",t)[/B]
        call TimerStart(t, Fire_Timer_Delay(), true, function Create_Fire)
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
[B]        set t = GetHandleTimer(cast,"ElementalTriFury_t")
        call PauseTimer(t)
        call DestroyTimer(t)
        call SetHandleHandle(cast,"ElementalTriFury_t",null)[/B]
    endif

    call RemoveLocation(cast_loc)

    set cast = null
    set cast_loc = null
    set t = null    
endfunction

function InitTrig_Elemental_Tri_Fury takes nothing returns nothing    
    set gg_trg_Elemental_Tri_Fury = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Elemental_Tri_Fury, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Elemental_Tri_Fury, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    call TriggerAddCondition( gg_trg_Elemental_Tri_Fury, Condition( function Elemental_Tri_Fury_Conditions ) )
    call TriggerAddAction( gg_trg_Elemental_Tri_Fury, function Elemental_Tri_Fury_Actions )
endfunction
 

Sim

Forum Administrator
Staff member
Reaction score
534
Just tested it.

Works perfectly fine, cleared all the mobs in the map :p

Looks flashy too. Approved.
 
C

Cybah

Guest
great but how can I change that you wont damage yourself with this spell anymore?
 

Tinki3

Special Member
Reaction score
418
Nothing in the trigger is coded to damage the caster, or his allies, so the things you need to change will be in the Object Editor.

You'll need to look for the dummy abilities such as the fire one, and change the field, Stats - Targets Allowed to not include allies.

That's only presuming that I hadn't changed that ability to not damage allies however.

I'll be here if you have any further problems.
 
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