Spell Blink Move

Builder Bob

Live free or don't
Reaction score
249
I like to set the orderId at map init just as Acehart did. It makes it more readable than the alternative in my opinion.

However, if you really want that constant, you can set it to the integer variable directly instead of going via OrderId(). Personally, I think it's overkill.

JASS:
globals
    private constant integer attack = 851983
    private constant integer smart = 851971
endglobals
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
say I wanted my hero to blink instead of moving, but only once every X seconds....there is no contingency plan for that...

Well, in that case you need some kind of "cache" system to keep track of usage over time.
AFAIK, there is no way to set a cooldown or get its current state...

Basic version:
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
    // Will work at most once every this many seconds
    private constant integer COOLDOWN = 4
    // 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
    private group g = CreateGroup()
    private integer array cache
endglobals

private function H2I takes unit u returns integer
    return u
    return 0
endfunction
private function cache_get takes unit u returns integer
    return cache[H2I(u) - 0x100000]
endfunction
private function cache_set takes unit u returns nothing
    set cache[H2I(u) - 0x100000] = COOLDOWN
endfunction

// The unit needs the spell and must have been ordered to move or attack-move (Right-click or "A")
// Additionally, it only works once every COOLDOWN seconds
private function Conditions takes nothing returns boolean
    if IsUnitInGroup(GetTriggerUnit(), g) then
        return cache_get(GetTriggerUnit()) <= 0 // Cooldown check
    endif
    return GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID) > 0 and (GetIssuedOrderId() == ORDER_SMART or GetIssuedOrderId() == ORDER_ATTACK)
endfunction

private function CooldownUnit takes nothing returns nothing
    local integer u = H2I(GetEnumUnit()) - 0x100000
    set cache<u> = cache<u> - 1
endfunction
private function Cooldown takes nothing returns nothing
    call ForGroup(g, function CooldownUnit)
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&#039;s position to target point

    if IsUnitInGroup(u, g) == false then
        call GroupAddUnit(g, u)
    endif
    call cache_set(u)

    if d &gt; MIN_DISTANCE then // Don&#039;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 &gt; 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 &quot;almost&quot; 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, &quot;move&quot;, x2, y2)
        else
            call IssuePointOrder(u, &quot;attack&quot;, x2, y2)
        endif
        call EnableTrigger(t)
    endif

    set u = null // Done
endfunction

private function Init takes nothing returns nothing
    set ORDER_SMART = OrderId(&quot;smart&quot;)
    set ORDER_ATTACK = OrderId(&quot;attack&quot;)
    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)
    call TimerStart(CreateTimer(), 0.95, true, function Cooldown)
endfunction
endscope
</u></u>
 

Trollvottel

never aging title
Reaction score
262
it's solution should be orb of... slow? (+ searing arrows with no damage and with cooldown)
 

Builder Bob

Live free or don't
Reaction score
249
I don't know if you missed my post (#11) or if you just ignored it, but issuing a new order in a function triggered by an order event really doesn't work. The new order is totally ignored.

The reason for it is that the order that triggers the event is actually carried out after the code is run. (This is similar to how in damage events, damage is done after the code in the triggered function has been run.)

You can easily see this by trying to issue a stop order or us using SetUnitPosition(GetTriggerUnit(), x, y) in a function triggered by an order event. The result is that the unit won't stop, even though SetUnitPosition() always stops a unit's orders in other circumstances.
 
J

JaerN

Guest
How can i create so the unit can moveto a higer platform ?? like this

Please response :D

Happy coding :D:shades:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      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