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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top