|
|
|
|
| JASS Resources Find JASS code snippets and functions here or write your own and post it on the Submissions sub-forum. |
 |
|
03-02-2011, 03:11 PM
|
#1 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
[Snippet] Order Event
Like SpellEffectEvent, but this one is for catching orders. Also like SpellEffectEvent, this is pretty much as lightweight as it gets.
Thanks to Azlier for the number 0xD0000.
Jass:
//============================================================================
// OrderEvent by Bribe, special thanks to Nestharus and Azlier, version 2.1.0.0
//
// API
// ---
// RegisterOrderEvent(integer orderId, code eventFunc)
// RegisterAnyOrderEvent(code eventFunc) //Runs for point/target/instant for any order
//
// Requires
// --------
// RegisterPlayerUnitEvent: hiveworkshop.com/forums/showthread.php?t=203338
//
library OrderEvent requires RegisterPlayerUnitEvent
globals
private trigger array t
endglobals
//============================================================================
function RegisterOrderEvent takes integer orderId, code c returns nothing
set orderId = orderId - 851968
if t[orderId] == null then
set t[orderId] = CreateTrigger()
endif
call TriggerAddCondition(t[orderId], Filter(c))
endfunction
//============================================================================
function RegisterAnyOrderEvent takes code c returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, c)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, c)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, c)
endfunction
//============================================================================
private function OnOrder takes nothing returns nothing
call TriggerEvaluate(t[GetIssuedOrderId() - 851968])
endfunction
//============================================================================
private module M
private static method onInit takes nothing returns nothing
call RegisterAnyOrderEvent(function OnOrder)
endmethod
endmodule
private struct S extends array
implement M
endstruct
endlibrary
Last edited by Bribe; 11-30-2011 at 07:41 AM.
Reason: Updated a bit
|
|
|
03-02-2011, 04:09 PM
|
#2 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
Made this thing really tight and added in Nestharus' wise input that I can just subtract 0xD0000 instead of hashing the values in a hashtable.
Shortened the API significantly and this should be very easy to pick up on.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.
|
|
|
03-02-2011, 04:40 PM
|
#3 (permalink)
|
|
User
Join Date: Jul 2007
Posts: 4,906
|
Add thanks to azlier for finding that number as well (I got it from him).
Otherwise looks a lot better =)
|
|
|
06-04-2011, 05:57 PM
|
#4 (permalink)
|
|
JESUS MAN
Resource Moderator
Join Date: Dec 2008
Posts: 5,699
|
0XD00000? :D
I was trying to find that number for days :D
This snippet is very useful ^^
|
|
|
10-03-2011, 10:49 AM
|
#5 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
Updated to use RegisterPlayerUnitEvent.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.
|
|
|
10-03-2011, 03:19 PM
|
#6 (permalink)
|
|
JESUS MAN
Resource Moderator
Join Date: Dec 2008
Posts: 5,699
|
*Votes for approval*
|
|
|
10-04-2011, 06:44 PM
|
#7 (permalink)
|
|
Beware the Ides of March
Join Date: Jun 2011
Posts: 248
|
It would be great if this library provided with something such as GetUnitCurrentOrderX() and Y() to know where the unit is heading.
__________________
Check out my TD
Originally Posted by GetTriggerUnit-
" There should be a section in World Editor designated to Nestharus."
|
|
|
10-04-2011, 06:50 PM
|
#8 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
That has nothing to do with this library. That has more to do with the LastOrder library on wc3c.net.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.
|
|
|
10-04-2011, 08:04 PM
|
#9 (permalink)
|
|
JESUS MAN
Resource Moderator
Join Date: Dec 2008
Posts: 5,699
|
LastOrder? :D
I have been inspired ^^
|
|
|
10-07-2011, 07:34 PM
|
#10 (permalink)
|
|
aзлиэр - уофлиян
Join Date: Oct 2008
Posts: 349
|
Like RegisterPlayerUnitEvent, I think this can benefit from this post.
|
|
|
11-02-2011, 12:31 PM
|
#11 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
Updated, code is much shorter now.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.
|
|
|
11-29-2011, 12:46 PM
|
#12 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
Re-Added RegisterAnyOrderEvent. Is this fit for approval?
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.
|
|
|
11-29-2011, 02:01 PM
|
#13 (permalink)
|
|
User
Join Date: Nov 2007
Posts: 1,055
|
I can't think of a situation when I want to have an event detecting a specific order for all three cases of being immediate, point, or target and making me have to manually differentiate between them.
Because of this, I'm not sure when I would want to use this over
RegisterPlayerUnitEvent
and just filter out specific order ids.
Of course, I would be open to suggestions. :P
|
|
|
11-29-2011, 03:18 PM
|
#14 (permalink)
|
|
Keep it simple
Spells, Help Zones & JASS Moderator
Join Date: Sep 2009
Posts: 5,581
|
What if you only wanted to detect Undefend, or only detect a "stop" or "attack" order?
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.
|
|
|
11-29-2011, 03:32 PM
|
#15 (permalink)
|
|
cool != useful
Join Date: Apr 2008
Posts: 1,937
|
I don't get why you talked about the stop and undefend order, i mean they obviously are a not target order.
Now, it quite makes sense for the attack order, since it can be a target or point order.
Or am i missing something ?
__________________
- There are bugs with wc3, but most of time, the bug is between the keyboard and the chair.
- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.
You spam "...", "lol", and smilies such as "; p", "^)^",">.>"? You think you're the best and all other ones are stupids or at least less clever than you ? You think your errors are funny, while the other ones are incredibly lame ?
Maybe you've too much ego,or worse, you're a douchebag
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|
All times are GMT. The time now is 05:27 AM.
|