Need Help Making My Leap Spell MUI

CrackUps

New Member
Reaction score
7
I've created a pretty basic leap spell but I'm not sure on how to make it MUI. I've implemented KaTTaNa's Local Handle Vars into the map which I'm not even sure is required anyway heres the trigger.

JASS:
function MoveFwd takes nothing returns nothing
    local trigger Fwd = GetTriggeringTrigger()
    local unit Caster = GetHandleUnit( udg_Cache, "Caster" )
    local real DistanceMax = 1000.00
    local real DistanceCurrent = GetHandleReal( udg_Cache, "DC" )
    local location TempLoc1 = PolarProjectionBJ(GetUnitLoc(Caster), 20.00, GetUnitFacing(Caster))
    local location TempLoc2 = PolarProjectionBJ(GetUnitLoc(Caster), 200.00, GetUnitFacing(Caster))
    local effect Flame1 = GetHandleEffect( udg_Cache, "Flame1" )
    local effect Flame2 = GetHandleEffect( udg_Cache, "Flame2" )
    local effect Flame3 = GetHandleEffect( udg_Cache, "Flame3" )
    call SetUnitPathing( Caster, false )
    call ClearSelectionForPlayer( GetOwningPlayer(Caster) )
    if DistanceCurrent >= DistanceMax then
        call SetUnitPositionLoc( Caster, TempLoc1 )
        call RemoveLocation(TempLoc1)
        call SelectUnitAddForPlayer( Caster, GetOwningPlayer(Caster) )
        call SetUnitTimeScale( Caster, 1.00 )
        call SetHandleHandle( udg_Cache, "Caster", null )
        call SetHandleReal( udg_Cache, "DC", 0 )
        call SetUnitPathing( Caster, true )
        call IssuePointOrderLoc( Caster, "move", TempLoc2 )
        call RemoveLocation(TempLoc2)
        call DestroyEffect(Flame1)
        call DestroyEffect(Flame2)
        call DestroyEffect(Flame3)
        call DestroyTrigger(Fwd)
    else
        call SetUnitPositionLoc( Caster, TempLoc1 )
        call RemoveLocation(TempLoc1)
        set DistanceCurrent = DistanceCurrent + 20
        call SetHandleReal( udg_Cache, "DC", DistanceCurrent )
    endif
endfunction

function LeapSetup takes nothing returns nothing
    local trigger Fwd = CreateTrigger()
    local timer LeapTimer = CreateTimer()
    local unit Caster = GetTriggerUnit()
    local effect Flame1 = AddSpecialEffectTarget( "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", Caster, "weapon" )
    local effect Flame2 = AddSpecialEffectTarget( "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", Caster, "foot, left" )
    local effect Flame3 = AddSpecialEffectTarget( "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl", Caster, "foot, right" )
    call SetHandleHandle( udg_Cache, "Flame1", Flame1 )
    call SetHandleHandle( udg_Cache, "Flame2", Flame2 )
    call SetHandleHandle( udg_Cache, "Flame3", Flame3 )
    call IssueImmediateOrder( Caster, "stop" )
    call SetUnitAnimation( Caster, "slam" )
    call SetUnitTimeScale( Caster, 0.5 )
    call SetHandleHandle( udg_Cache, "Caster", Caster )
    call TimerStart( LeapTimer, 0.03, true, null )
    call TriggerRegisterTimerExpireEvent( Fwd, LeapTimer )
    call TriggerAddAction( Fwd, function MoveFwd )
endfunction

//===========================================================================
function InitTrig_Leap takes nothing returns nothing
    local trigger Leap = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( Leap, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddAction( Leap, function LeapSetup )
endfunction


Could somebody please explain to me how to make this MUI or even do it for me:p

I can attach the map if necessary
 

Strilanc

Veteran Scripter
Reaction score
42
First, set the timer callback with the StartTimer function. Creating a trigger with events is unnecessary, and destroying the triggering trigger can cause some very serious and difficult to track bugs.

Currently all you've done is replace globals with calls to handle vars, which [perhaps not surprisingly] doesn't make it MUI. You need to include the unit's H2I in the store/load string, so each unit stores in a different place.

Lucky for you, nothing so complicated is required in this case, because the wait time is constant. That means the order you store things is the order you take them out, and makes the problem dead simple. All you need to do is change your globals to arrays, and two indexes [I'll call them pre and post].

To store values:
store in arrays at index 'pre'
increase 'pre' by 1, if 'pre' is greater than 8000, reset it to 0
wait

To retrieve values [after wait]:
retrieve from arrays at index 'post'
increase 'post' by 1, if 'post' is greater than 8000, reset it to 0

The end result is you slowly cycle around the array as the spell is cast, taking things out in the same order you put them in.

http://en.wikipedia.org/wiki/Queue_(data_structure)
http://en.wikipedia.org/wiki/Circular_buffer
 

CrackUps

New Member
Reaction score
7
Ok i'm fairly new with Jass and don't understand some of what you said.

>First, set the timer callback with the StartTimer function.
You want me to use StartTimerBJ() instead of TimerStart() ?

>You need to include the unit's H2I in the store/load string, so each unit stores in a different place.
You want me to store a unit like this?
JASS:
call SetHandleHandle( udg_Cache, "Caster" + I2S(H2I(Caster)), Caster )


>All you need to do is change your globals to arrays, and two indexes
What globals? do you mean locals?

>To store values:
store in arrays at index 'pre'
increase 'pre' by 1, if 'pre' is greater than 8000, reset it to 0
wait

To retrieve values [after wait]:
retrieve from arrays at index 'post'
increase 'post' by 1, if 'post' is greater than 8000, reset it to 0

I don't have a clue what that means, I understand why you reset it to 0 once it reaches 8000 but what do you mean "store in arrays at index 'pre'" and "retrieve from arrays at index 'post'" and whats the wait:confused:

I understand very little in your post sorry
 

Strilanc

Veteran Scripter
Reaction score
42
Ok i'm fairly new with Jass and don't understand some of what you said.

>First, set the timer callback with the StartTimer function.
You want me to use StartTimerBJ() instead of TimerStart() ?
No, the last argument to StartTimer is the function it should call when the timer expires. Just put "function your_function_name" there instead of null.

>You need to include the unit's H2I in the store/load string, so each unit stores in a different place.
You want me to store a unit like this?
JASS:
call SetHandleHandle( udg_Cache, "Caster" + I2S(H2I(Caster)), Caster )
Yes, although I got it a bit backwards.. you have to use the H2I of the timer.

>All you need to do is change your globals to arrays, and two indexes
What globals? do you mean locals?
Dump HandleVars, switch back to globals. Those globals. "udg_Caster", etc.

>To store values:
store in arrays at index 'pre'
increase 'pre' by 1, if 'pre' is greater than 8000, reset it to 0
wait

To retrieve values [after wait]:
retrieve from arrays at index 'post'
increase 'post' by 1, if 'post' is greater than 8000, reset it to 0

I don't have a clue what that means, I understand why you reset it to 0 once it reaches 8000 but what do you mean "store in arrays at index 'pre'" and "retrieve from arrays at index 'post'" and whats the wait:confused:

I understand very little in your post sorry

You can store many values in an array, and you access them by index. array[1] can store a value independently of array[2] and so forth. The reason your spell currently isn't MUI is because when the trigger runs again you overwrite the globals [in gamecache, whatever] and screw up any waiting runs. By keeping a before-wait and after-wait index, you make each call store itself one-higher in the array, so it will not overwrite any waiting calls unless you have 8000 casts at once [technical note: you will not have 8000 casts at once].

Try something like this:
JASS:

set udg_I = udg_I + 1 //pre index
set udg_Array[udg_I] = udg_I
call BJDebugMsg("Before wait, value# " + I2S(udg_I) + " = " + I2S(udg_Array[udg_I]))
call TriggerSleepAction(5.00)
set udg_J = udg_J + 1 //post index
call BJDebugMsg("After wait, value# " + I2S(udg_J) + " = " + I2S(udg_Array[udg_J]))


run it a lot, then compare it to what you currently have:
JASS:

set udg_I = udg_I + 1
set udg_Global = udg_I
call BJDebugMsg("Before wait, value# " + I2S(udg_I) + " = " + I2S(udg_Global))
call TriggerSleepAction(5.00)
set udg_J = udg_J + 1
call BJDebugMsg("After wait, value# " + I2S(udg_J) + " = " + I2S(udg_Global))
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top