[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > JASS Resources


JASS Resources Find JASS code snippets and functions here or write your own and post it on the Submissions sub-forum.

Reply
 
Thread Tools
Old 03-02-2011, 03:11 PM   #1 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
[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
Bribe is offline   Reply With Quote
Old 03-02-2011, 04:09 PM   #2 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
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.

Bribe is offline   Reply With Quote
Old 03-02-2011, 04:40 PM   #3 (permalink)
Registered User Nestharus
User
 
Nestharus's Avatar
 
Join Date: Jul 2007
Posts: 4,906
Nestharus has disabled reputation
Add thanks to azlier for finding that number as well (I got it from him).

Otherwise looks a lot better =)
__________________

Anime-Planet.com - anime | manga | reviews
Nestharus is online now   Reply With Quote
Old 06-04-2011, 05:57 PM   #4 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,699
Magtheridon96 has a brilliant future (1808)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
0XD00000? :D
I was trying to find that number for days :D
This snippet is very useful ^^
__________________
Magtheridon96 is offline   Reply With Quote
Old 10-03-2011, 10:49 AM   #5 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
Updated to use RegisterPlayerUnitEvent.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline   Reply With Quote
Old 10-03-2011, 03:19 PM   #6 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,699
Magtheridon96 has a brilliant future (1808)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
*Votes for approval*
__________________
Magtheridon96 is offline   Reply With Quote
Old 10-04-2011, 06:44 PM   #7 (permalink)
Registered User Dirac
Beware the Ides of March
 
Dirac's Avatar
 
Join Date: Jun 2011
Posts: 248
Dirac is on a distinguished road (84)Dirac is on a distinguished road (84)
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."
Dirac is offline   Reply With Quote
Old 10-04-2011, 06:50 PM   #8 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
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.

Bribe is offline   Reply With Quote
Old 10-04-2011, 08:04 PM   #9 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,699
Magtheridon96 has a brilliant future (1808)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
LastOrder? :D
I have been inspired ^^
__________________
Magtheridon96 is offline   Reply With Quote
Old 10-07-2011, 07:34 PM   #10 (permalink)
Registered User azlier
aзлиэр - уофлиян
 
azlier's Avatar
 
Join Date: Oct 2008
Posts: 349
azlier is a jewel in the rough (150)
Like RegisterPlayerUnitEvent, I think this can benefit from this post.
azlier is offline   Reply With Quote
Old 11-02-2011, 12:31 PM   #11 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
Updated, code is much shorter now.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline   Reply With Quote
Old 11-29-2011, 12:46 PM   #12 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
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.

Bribe is offline   Reply With Quote
Old 11-29-2011, 02:01 PM   #13 (permalink)
Registered User watermelon_1234
User
 
watermelon_1234's Avatar
 
Join Date: Nov 2007
Posts: 1,055
watermelon_1234 is a glorious beacon of light (502)watermelon_1234 is a glorious beacon of light (502)watermelon_1234 is a glorious beacon of light (502)watermelon_1234 is a glorious beacon of light (502)
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
watermelon_1234 is offline   Reply With Quote
Old 11-29-2011, 03:18 PM   #14 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
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.

Bribe is offline   Reply With Quote
Old 11-29-2011, 03:32 PM   #15 (permalink)
Registered User Troll-Brain
cool != useful
 
Troll-Brain's Avatar
 
Join Date: Apr 2008
Posts: 1,937
Troll-Brain is just really nice (371)Troll-Brain is just really nice (371)Troll-Brain is just really nice (371)Troll-Brain is just really nice (371)
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
Troll-Brain is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 05:27 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle