Thread: LastOrder
View Single Post
Old 01-19-2009, 07:39 AM   #1
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default LastOrder

LastOrder Library

Background:
This library of code allows lots of cool interfacing with the last orders of a unit. The main point of the library is to maintain an organized list of up to N of any given unit's last issued orders. The value of this is that you can recall those orders at any time and reissue them if the need arises. (Such as if those orders were lost to the unit by a pause/stop/pause or something similar) Thanks to ToukoAozaki for giving me the motivation to package and release it.

Requirements:
  • None
Code:
Expand Library:

Function List:
This library gives the following interfacing options with last orders. It contains the following functions for use with interfacing last orders given to a unit.
  • function GetPastOrder takes unit u, integer whichOrder returns order
  • function GetPastOrderId takes unit u, integer whichOrder returns integer
  • function GetPastOrderString takes unit u, integer whichOrder returns string
  • function GetPastOrderType takes unit u, integer whichOrder returns integer
  • function GetPastOrderX takes unit u, integer whichOrder returns real
  • function GetPastOrderY takes unit u, integer whichOrder returns real
  • function GetPastOrderTarget takes unit u, integer whichOrder returns widget
  • ----
  • function GetLastOrder takes unit u returns order
  • function GetLastOrderId takes unit u returns integer
  • function GetLastOrderString takes unit u returns string
  • function GetLastOrderType takes unit u returns integer
  • function GetLastOrderX takes unit u returns real
  • function GetLastOrderY takes unit u returns real
  • function GetLastOrderTarget takes unit u returns widget
  • function IsLastOrderFinished takes unit u returns boolean
  • ----
  • function IssuePastOrder takes unit u, integer whichOrder returns boolean
  • function IssueLastOrder takes unit u returns boolean
  • function IssueSecondLastOrder takes unit u returns boolean
  • function IssueArbitraryOrder takes unit u, order o returns boolean
  • function AbortOrder takes unit u returns boolean
In the documentation, I explain a lot about why a user wants to store the last 3 orders a unit has received. The second and third orders are particularly useful for use with spells that target either units or locations and need to be intercepted. These spells are 'interrupted' on the SPELL_CAST event to prevent cooldown/mana cost, but that fires after the order events. This means that in the case where you want to reissue the order before you cast storm bolt, you need to now issue your second to last order. If you issue the very last order, you run into spell recursion, which is a whole bunch of nastiness that no one wants to look at.

Attached to this post is a demo map showing you how the system works. You can hit escape to view the last order details for your blademaster at any given time. Additionally, you can issue orders around the map and then use the "Demo Spell" with the cancel icon. That spell does nothing, but it is intercepted by an example code in the demo map and takes advantage of the following AbortSpell library, which was designed to be used with the LastOrder library. This should be a sufficient example for anyone to figure out how to use it in their maps to its fullest extent.

_______________________________________________________________________

AbortSpell Supplementary Library

Requirements:
Expand Supplementary Library:

Function List:
This library gives the following function to the user.
  • function AbortSpell takes unit u, string msg, string key returns boolean
This expands upon SimError to fully simulate WC3 spellcasting errors. When you try to cast a spell in WC3 and you can't, you keep following your last order and the AOE indicator and so forth don't go away. If you used only the normal SimError, you couldn't fully simulate this special case, but with AbortSpell you can. AbortSpell also takes a 'key' argument, which corresponds to the hotkey associated with your spell.

Thanks guys, comments are welcome!
Attached Files
File Type: w3x LastOrderTestMap.w3x (38.3 KB, 99 views)
__________________
Rising_Dusk is offline   Reply With Quote
Sponsored Links - Login to hide this ad!