• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

GetLastOrder

Status
Not open for further replies.
Is there a way to retrieve the last order given to a unit? I'm making this spell that should target one specific unit type only, but several other units have the same targeting parameters, so I can basically cast the spell on any of those units. If I can get the last order given to the casting unit, I can tell it to pause/'stunself'/unpause and then resume last order (like say the cast order was given as the unit was moving. With just the pase/'stunself'/unpause it would just stop moving).

Is that possible?
 
Could you tell me how to write that in GUI form (with the custom script trigger). I'm afraid I don't understand JASS very well. I'm also trying to use SimError, could you add a line for this as well, please? I tried downloading the TestMap to see how it was done, but the link must be broken.

PS: I see there's a complementary AbortSpell library, but that bugs out whenever I tell the unit to use it and keeps trying to rescast the spell on the same unit over and over again. Might have to do with the fact that I don't have a clue what "G" is supposed to be in call AbortSpell(MyUnit, "Error Message", "G")
 
In your trigger, declare these locals at the top of your script:
  • Custom script: local order o
  • Custom script: local boolean finished
  • Set Caster = (Triggering unit)
  • ----- execute whatever actions you need to -----
  • ----- when you're preparing for pausing -----
  • Custom script: set finished = IsLastOrderFinished(udg_Caster)
  • Custom script: if not finished then
  • Custom script: set o = GetLastOrder(udg_Caster)
  • Custom script: endif
  • ----- the above will save the order if necessary -----
  • ----- you can pause the unit etc. -----
  • Custom script: if not finished then
  • Custom script: call IssueArbitraryOrder(udg_Caster, o)
  • Custom script: endif
If I'm not mistaken, that should work. Idk. I've been up too long. Let me know if it doesn't work.

About the AbortSpell--the "G" is the hotkey of the spell you want to abort.
 
Doesn't seem to work. When I tell it to target a similar unit, nothing happens, but then the spell can't be used anymore. I click on it to re-cast, but the targeting reticule thing doesn't appear, as thought the spell is still being cast?

I've given the AbortSpell another bash, but the same problem persist. Would be great to get a fix for that since it's exactly what I need.
 
Can you show your abort spell trigger? It should look something like this:
  • Abort
    • Events
      • Unit - A unit is issued an order targeting an object
      • ---- or whatever order corresponds to your spell order ----
    • Conditions
      • ---- check if it is the spell order ----
    • Actions
      • Set Caster = (Triggering unit)
      • Custom script: call AbortSpell(udg_Caster, "Error", "A")
 
  • Events
    • Unit - A Unit is Issued an Order targeting an Object
  • Conditions
    • --- check unit type ---
    • --- check spell order id ---
    • --- check target of order ---
  • Actions
    • Custom script: call AbortSpell(GetTriggerUnit(), "Can only target Gold Mines", "G")
Edit: Just saw this in the AbortSpell code:
JASS:
function AbortSpell takes unit u, string msg, string key returns boolean
    local boolean b = false
    local real    a = 0.
    if AbortOrder(u) then
        call SimError(GetOwningPlayer(u), "\n"+msg)
        if GetLocalPlayer() == GetOwningPlayer(u) and StringLength(key) == 1 and key != " " then
            call ForceUIKey(key)
        endif
        set b = IssueSecondLastOrder(u)
        if not b and GetPastOrder(u, 2) != 0 then
            //Failed, have to issue a dummy order to prevent spell recursion
            //Have to project a point a fraction of a space ahead of the unit,
            //otherwise it will turn to 0 degrees facing because Blizzard sucks
            set a = GetUnitFacing(u)*bj_DEGTORAD
            call IssuePointOrderById(u, 851971, GetUnitX(u)+0.01*Cos(a), GetUnitY(u)+0.01*Sin(a))
        endif
    endif
    return b
endfunction
endlibrary

Dummy order? How would I do this? (I mean how would I trigger that?)
 
Last edited:
Status
Not open for further replies.
Top