Spell Blink Move

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
What is it?

"Blink Move" is a passive ability that automagically blinks you to some target point when you order your unit to move or attack-move.

Why would I want that?

- It's fun.
- It makes all the sense on epic maps :p
- You get the fastest unit around.
- Just because.

GUI

Trigger:
  • Blink Move GUI
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Level of Blink for (Triggering unit)) Greater than 0
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(attack))
    • Actions
      • Set Point1 = (Position of (Triggering unit))
      • Set Point2 = (Target point of issued order)
      • Set Distance = (Distance between Point1 and Point2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Distance Greater than 500.00
        • Then - Actions
          • Special Effect - Create a special effect at Point1 using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect at Point2 using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set Distance = (Distance - 200.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Distance Greater than 2000.00
            • Then - Actions
              • Set Distance = 2000.00
            • Else - Actions
          • Set Point3 = (Point1 offset by Distance towards (Angle from Point1 to Point2) degrees)
          • Unit - Move (Triggering unit) instantly to Point3
          • Custom script: call RemoveLocation( udg_Point3 )
          • Trigger - Turn off (This trigger)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(smart))
            • Then - Actions
              • Unit - Order (Triggering unit) to Move To Point2
            • Else - Actions
              • Unit - Order (Triggering unit) to Attack-Move To Point2
          • Trigger - Turn on (This trigger)
        • Else - Actions
      • Custom script: call RemoveLocation( udg_Point1 )
      • Custom script: call RemoveLocation( udg_Point2 )


Usage:
Either enter the trigger yourself, or copy&paste it from the attached map.
For copy&paste to work correctly, make sure to have a check on "auto-create unknown variables" in menu: File / Preferences.
Edit the condition as needed.

JASS

JASS:
scope BlinkMove initializer Init
globals
    // Order ID of your ability
    private constant integer SPELL_ID = 'AEbl'
    // Adjust to taste
    private constant real MIN_DISTANCE = 500.0 // No blink if less than this
    private constant real MAX_DISTANCE = 2000.0 // Set to 99999.0 if you want this to work across the entire map
    private constant real END_DISTANCE = 200.0 // Blink this close to the end point
    // Effects to show on start and end points
    private constant string EFFECT_START = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    private constant string EFFECT_END = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"

    // Leave as is
    private trigger t = CreateTrigger()
    private integer ORDER_SMART
    private integer ORDER_ATTACK
endglobals

// The unit needs the spell and must have been ordered to move or attack-move (Right-click or "A")
private function Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID) > 0 and (GetIssuedOrderId() == ORDER_SMART or GetIssuedOrderId() == ORDER_ATTACK)
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit() // Caster
    local real x1 = GetUnitX(u) // Position of caster
    local real y1 = GetUnitY(u)
    local real x2 = GetOrderPointX() // Point we want to go to
    local real y2 = GetOrderPointY()
    local real d = SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) // Distance from caster to target point
    local real a = Atan2(y2 - y1, x2 - x1) // Angle from caster's position to target point

    if d > MIN_DISTANCE then // Don't blink for too short a distance
        call DestroyEffect(AddSpecialEffect(EFFECT_START, x1, y1)) // Eye-candy starting point
        set d = d - END_DISTANCE // This close to the end point
        if d > MAX_DISTANCE then // but respect the maximum distance
            set d = MAX_DISTANCE
        endif
        set x1 = x1 + d * Cos(a) // Point that is nearly there
        set y1 = y1 + d * Sin(a)
        call DestroyEffect(AddSpecialEffect(EFFECT_END, x1, y1)) // Eye-candy target point
        call SetUnitX(u, x1) // Move caster "almost" there...
        call SetUnitY(u, y1)
        call DisableTrigger(t)
        if GetIssuedOrderId() == ORDER_SMART then // ...and order the unit to (attack-)move the rest
            call IssuePointOrder(u, "move", x2, y2)
        else
            call IssuePointOrder(u, "attack", x2, y2)
        endif
        call EnableTrigger(t)
    endif

    set u = null // Done
endfunction

private function Init takes nothing returns nothing
    set ORDER_SMART = OrderId("smart")
    set ORDER_ATTACK = OrderId("attack")
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER) // A unit is issued an order targeting a point
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
endfunction
endscope


Usage:
Create a new trigger, convert to custom script.
Replace whatever shows there with the above.
Adjust constants as needed.
Requires NewGen.


Enjoy.

Yours,
AceHart


Q: OMG, this has been done 1000003 times already!
A: So?

Q: It's MUI I take it?
A: Yep.

Q: The GUI version too?
A: Yep.

Q: Why is there a GUI version actually???
A: Yep.

Q: Looks simple...
A: Yep.

Q: Would be good to have a different max distance per level
A: Well, then get busy.

Q: My unit ended up in some weird spot!
A: Well, it has Blink Move, doesn't it?

Q: I WAITS JUST FOR TAHT!!!1one1LOL!
A: Coincidence

Q: Are there any leaks?
A: ...

Q: Why do you turn the trigger off near the end?
A: If remaining distance greater than minimum distance then call trigger again automatically

Q: ...
A: Me too



The map:
 

Attachments

  • BlinkMove_Demo_AceHart.w3x
    15.2 KB · Views: 605

D.V.D

Make a wish
Reaction score
73
I remember when I just got TFT and tried to make this spell. It worked but it leaked quite a bit. Anyways nice spell + rep. I don't see any mistakes or ways to improve.
 

saw792

Is known to say things. That is all.
Reaction score
280
If you are going to make them blink when they right-click and when they attack, why not when they move as well?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Well, I guess you have your reasons for actually using "move".
I don't really see how you could use it by accident...

But, if you really want to, just add an extra test to the conditions.
 

emjlr3

Change can be a good thing
Reaction score
395
what if my passive ability has a cooldown?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Approved.

Another simple function done perfectly and with all contingencies considered by AceHart.

Way to go Ace! :thup:
 

Romek

Super Moderator
Reaction score
964
JASS:
private integer ORDER_SMART
private integer ORDER_ATTACK

Can't you make these constant, with initial values? Would be faster.

Q: Why is there a GUI version actually???
A: Yep.
I lol'd :p
 

Romek

Super Moderator
Reaction score
964
> Anman64

JASS:
constant function Blink_Move_ID takes nothing returns integer
    return 'AEbl'
endfunction

constant function Blink_Move_MIN_DISTANCE takes nothing returns real
    return 500.0
endfunction

constant function Blink_Move_MAX_DISTANCE takes nothing returns real
    return 2000.
endfunction

constant function Blink_Move_END_DISTANCE takes nothing returns real
    return 200.
endfunction

constant function Blink_Move_EFFECT_START takes nothing returns string
    return "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
endfunction

constant function Blink_Move_EFFECT_END takes nothing returns string
    return "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
endfunction

function Blink_Move_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(), Blink_Move_ID()) > 0 and (GetIssuedOrderId() == OrderId("smart") or GetIssuedOrderId() == OrderId("attack"))
endfunction

function Blink_Move_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit() // Caster
    local real x1 = GetUnitX(u) // Position of caster
    local real y1 = GetUnitY(u)
    local real x2 = GetOrderPointX() // Point we want to go to
    local real y2 = GetOrderPointY()
    local real d = SquareRoot((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) // Distance from caster to target point
    local real a = Atan2(y2 - y1, x2 - x1) // Angle from caster's position to target point
    local trigger t = GetTriggeringTrigger()

    if d > Blink_Move_MIN_DISTANCE() then // Don't blink for too short a distance
        call DestroyEffect(AddSpecialEffect(Blink_Move_EFFECT_START(), x1, y1)) // Eye-candy starting point
        set d = d - Blink_Move_END_DISTANCE() // This close to the end point
        if d > Blink_Move_MAX_DISTANCE() then // but respect the maximum distance
            set d = Blink_Move_MAX_DISTANCE()
        endif
        set x1 = x1 + d * Cos(a) // Point that is nearly there
        set y1 = y1 + d * Sin(a)
        call DestroyEffect(AddSpecialEffect(Blink_Move_EFFECT_END(), x1, y1)) // Eye-candy target point
        call SetUnitX(u, x1) // Move caster "almost" there...
        call SetUnitY(u, y1)
        call DisableTrigger(t)
        if GetIssuedOrderId() == OrderId("smart") then // ...and order the unit to (attack-)move the rest
            call IssuePointOrder(u, "move", x2, y2)
        else
            call IssuePointOrder(u, "attack", x2, y2)
        endif
        call EnableTrigger(t)
    endif

    set t = null
    set u = null // Done
endfunction

function InitTrig_Blink_Move takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER) // A unit is issued an order targeting a point
    call TriggerAddCondition(t, Condition(function Blink_Move_Conditions))
    call TriggerAddAction(t, function Blink_Move_Actions)
endfunction


An easy conversion. :p
The vJass one is obviously neater, nicer and more efficient. (Much less function calls)

Edit: Trigger must be called "Blink Move"
 

Builder Bob

Live free or don't
Reaction score
249
Issuing new orders in an order event actually doesn't do anything.

JASS:
call DisableTrigger(t)
if GetIssuedOrderId() == ORDER_SMART then // ...and order the unit to (attack-)move the rest
    call IssuePointOrder(u, "move", x2, y2)
else
    call IssuePointOrder(u, "attack", x2, y2)
endif
call EnableTrigger(t)


The spell functions exactly the same with this part removed.

It works very well already, so there's no problem really. Just unnecessary.
 

w00t22

CSS L4D DoD? Steam ID = w00t22
Reaction score
43
everytime i see a post from aceheart involing a system or spell i go straight to Q&A its fucking hilarous

Q: Would be good to have a different max distance per level
A: Well, then get busy.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Can't you make these constant, with initial values? Would be faster.

If OrderId("order") worked in a globals block, I would have used it...
It doesn't though, so it's set in "Init".
Which is nearly the same after all. You lose a bit on readability.

As for faster, looking up an integer variable is just the same as looking up an integer variable.
 

vinkia

New Member
Reaction score
0
Vinkia

Nice spell..umm i just signed up for this site and wad is GUI??does it mean that spells are made of triggers?
 

emjlr3

Change can be a good thing
Reaction score
395
say I wanted my hero to blink instead of moving, but only once every X seconds....there is no contingency plan for that...
 

Kazuga

Let the game begin...
Reaction score
110
Ontopic:
Nice spell Ace, simple but yet useful. ^^

Offtopic:
Nice spell..umm i just signed up for this site and wad is GUI??does it mean that spells are made of triggers?
GUI = Graphical User Interface, it's the code where you select and click around instead of typing your code. Compare the codes in the first post, the upper one is in GUI.

Trigger = The file that contains the code. It can be either GUI, Jass (Blizzard's programming language) or vJass (a new and improved version of Jass).
 

Romek

Super Moderator
Reaction score
964
As for faster, looking up an integer variable is just the same as looking up an integer variable.

I believe constants are inlined into the code. (At either saving, or optimizing). So it does end up faster.
But, seeing as the function doesn't work at Map Init. I guess there isn't much we can do about that. :rolleyes:
 

Flare

Stops copies me!
Reaction score
662
Nice idea to actually post something like this, I recall seeing this (well, some variation of it) in a DnD map, much fun to be had fleeing from everyone and everything :D
If OrderId("order") worked in a globals block, I would have used it...
Works for me (well, at least it saves without any errors, not sure if there are any in-game effects) :p

But, seeing as the function doesn't work at Map Init.
But, ahm... aren't initializers called at Map Init? :p

Would be faster.
So it does end up faster.
Hmmm, seems I was misinformed when you said you didn't care about speed :D
 

Romek

Super Moderator
Reaction score
964
Hmmm, seems I was misinformed when you said you didn't care about speed :D

Well, if there's the option of increasing the speed of something by adding a single word, then why not? :D
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> aren't initializers called at Map Init?

Yep. That's why the OrderId calls are there; not in the globals block where it saves just fine, but doesn't work.
And, yes, the entire point of having those order constants is speed.
It's faster to get them once than to convert those orders on every move.
After all, right-clicking somewhere tends to happen rather often...
('course, we're talking micro-seconds here... :p)

> I believe constants are inlined into the code.

'hfoo'? Yes. That's a true, real constant.
OrderId("smart")? That's a function call... if you inline that, you miss the entire point of just calling it once.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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

      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