- Joined
- Jan 21, 2006
- Messages
- 2,552
Order Types
In Warcraft III the possibilities for types of orders are limited to 3. They are:
Also worth mentioning is the three different types of targets, which are:
It is often necessary to distinguish between these, for example you want your spell to perform a different set of actions if the target is a unit or a destructable (or if the order-type is a point target as opposed to a unit target) this library efficiently produces a result that can be used as a simple integer.
Initially this was written in zinc, but since I really don't find the zinc language attractive in an environment designed for vJass I converted it to plain ol' vJass.
I think this should be a little more appropriate for the JASS section than my previous two submissions, I thought many would find this useful and I couldn't find anything of the sort already submitted.
In Warcraft III the possibilities for types of orders are limited to 3. They are:
- Point
- Target
- Immediate/None
Also worth mentioning is the three different types of targets, which are:
- Unit
- Destructable
- Item
It is often necessary to distinguish between these, for example you want your spell to perform a different set of actions if the target is a unit or a destructable (or if the order-type is a point target as opposed to a unit target) this library efficiently produces a result that can be used as a simple integer.
JASS:
library OrderTypes
/*******************************
* Order Types Library
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* by: Berb
* Version: 1.0
*
* Description:
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* The purpose of this library is to provide the user with an API function that allows
* them to easily (and efficiently) check which type of order the current event response
* is dealing with. It uses event responses such as "GetOrderPointLoc" so using this
* outside of an event response action will not work.
*
* API:
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* • GetOrderType ~ Returns an integer constant representing the type
* of order that is in-process.
* • GetAbilityOrderType ~ Just like "GetOrderType" except for ability
* events rather than order events.
*
* • GetOrderTargetType ~ Returns an integer constant representing the type
* of target that the order was issued on.
* • GetAbilityOrderTargetType ~ Just like "GetOrderTargetType" except for ability
* events rather than order events.
*
* Constants -------------------------------------------------------------------------------*/
globals
constant integer ORDER_TYPE_NONE = 0
constant integer ORDER_TYPE_POINT = 1
constant integer ORDER_TYPE_TARGET = 2
constant integer TARGET_TYPE_UNIT = 0
constant integer TARGET_TYPE_DEST = 1
constant integer TARGET_TYPE_ITEM = 2
constant integer TARGET_TYPE_NONE = 3
endglobals
/* -----------------------------------------------------------------------------------------
*
*/
globals
private location data__targetLoc = null
endglobals
function GetAbilityOrderTargetType takes nothing returns integer
if GetSpellTargetUnit() != null then
return TARGET_TYPE_UNIT
elseif GetSpellTargetItem() != null then
return TARGET_TYPE_ITEM
elseif GetSpellTargetDestructable() != null then
return TARGET_TYPE_DEST
endif
return TARGET_TYPE_NONE
endfunction
function GetAbilityOrderType takes nothing returns integer
if GetSpellTargetUnit() != null or /*
*/ GetSpellTargetItem() != null or /*
*/ GetSpellTargetDestructable() != null then
return ORDER_TYPE_TARGET
endif
set data__targetLoc = GetSpellTargetLoc()
if data__targetLoc != null then
call RemoveLocation(data__targetLoc)
return ORDER_TYPE_POINT
endif
return ORDER_TYPE_NONE
endfunction
function GetOrderTargetType takes nothing returns integer
if GetOrderTargetUnit() != null then
return TARGET_TYPE_UNIT
elseif GetOrderTargetItem() != null then
return TARGET_TYPE_ITEM
elseif GetOrderTargetDestructable() != null then
return TARGET_TYPE_DEST
endif
return TARGET_TYPE_NONE
endfunction
function GetOrderType takes nothing returns integer
if GetOrderTarget() != null then
return ORDER_TYPE_TARGET
endif
set data__targetLoc = GetOrderPointLoc()
if data__targetLoc != null then
call RemoveLocation(data__targetLoc)
return ORDER_TYPE_POINT
endif
return ORDER_TYPE_NONE
endfunction
/*
*
******************************************************************************************/
endlibrary
Initially this was written in zinc, but since I really don't find the zinc language attractive in an environment designed for vJass I converted it to plain ol' vJass.
I think this should be a little more appropriate for the JASS section than my previous two submissions, I thought many would find this useful and I couldn't find anything of the sort already submitted.
Last edited by a moderator: