wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
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)
__________________

Last edited by Rising_Dusk : 05-30-2010 at 09:09 PM. Reason: Updated
Rising_Dusk is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-19-2009, 10:17 AM   #2
C2H3NaO2
User
 
Join Date: May 2008
Posts: 80

C2H3NaO2 is on a distinguished road (17)

Default

That a really greet idea!

But on my pc (wc3 1.21b) it tells me about hit op limit in the init function.
For me it works without the initialization loop exactly the same like before.

+Rep
Attached Images
File Type: jpg hitoplimit.JPG (27.4 KB, 180 views)
C2H3NaO2 is offline   Reply With Quote
Old 01-19-2009, 01:06 PM   #3
Iron_Doors
User
 
Join Date: Aug 2007
Posts: 50

Submissions (1)

Iron_Doors will become famous soon enough (31)Iron_Doors will become famous soon enough (31)

Default

I found two problems using the cancel spell in your test map. First was that if you cast Mirror Image and then do nothing until its cooldown wears off and then use the cancel spell, the hero recasts Mirror Image. Second was that shift orders are forgotten when the error spell is used.

Also, I would name those ORDER_TYPE_ constants according to the Issue(Target|Point|Immediate)Order functions that they are associated with.
Iron_Doors is offline   Reply With Quote
Old 01-19-2009, 01:17 PM   #4
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

I think SimErrorEx should be separated in another module, mostly because I think that the current method is not the best possible, but the alternative requires more code, pausing units is a little problematic, often I prefer to give the correct order after a 0.0 seconds timer rather than pause the unit.

edit: Making SimErrorEx a separate thing will also allow the main library to get rid of the SimError requirement.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 01-19-2009, 01:29 PM   #5
Here-b-Trollz
Corkscrew Chainsaw!!!
 
Join Date: Jun 2006
Posts: 711

Here-b-Trollz has a spectacular aura about (149)

Hero Contest #2 - 2nd Place

Default

Fuck yes. You rule Dusk. I've been meaning to do something like this for a long time, and now I don't have to. Pro.
__________________
By reading this signature, you agree that I cannot be held accountable for anything that I might say or do.
Here-b-Trollz is offline   Reply With Quote
Old 01-19-2009, 04:38 PM   #6
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

Quote:
Originally Posted by Iron_Doors
I found two problems using the cancel spell in your test map. First was that if you cast Mirror Image and then do nothing until its cooldown wears off and then use the cancel spell, the hero recasts Mirror Image. Second was that shift orders are forgotten when the error spell is used.
Ah yes, shift orders. Queued orders are forgotten no matter what, it's an inevitability. Also, the Mirror Image recast just means I forgot a check in the LastOrderFilter function. I guess I should have it disallow INSTANT orders as well.

EDIT:
Actually, thanks for the report. It seems I was checking Order and not P_Order, the second to last order. Fixing that bug now.
Quote:
Originally Posted by Vexorian
I think SimErrorEx should be separated in another module, mostly because I think that the current method is not the best possible, but the alternative requires more code, pausing units is a little problematic, often I prefer to give the correct order after a 0.0 seconds timer rather than pause the unit.

edit: Making SimErrorEx a separate thing will also allow the main library to get rid of the SimError requirement.
Okay, I will make it a separate module, then. But your note about the pausing not being the best way troubles me. I thought pause/stop/unpause was the only known way to fully stop a unit from losing mana/etc. on casting a spell? If there's a better way that doesn't involve the use of pause, lay it on me and I'll use it. I've just always used it because I know it works.

Let me split the library up a bit, I'll update shortly.
Quote:
Originally Posted by Here-b-Trollz
Fuck yes. You rule Dusk. I've been meaning to do something like this for a long time, and now I don't have to. Pro.
<3
__________________

Last edited by Rising_Dusk : 01-19-2009 at 05:04 PM.
Rising_Dusk is offline   Reply With Quote
Old 01-19-2009, 05:42 PM   #7
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,186

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Is it really required to initialize all those array values? Aren't uninitialized arrays effectively the same as initial values of 0/null as far as comparisons go?

While not a requirement, it is my suggestion that you make an additional "flavour" of this library using table; in any case this can wait until the end of the review process when the indexing version of the library will be finalised.
__________________
Anitarf is offline   Reply With Quote
Old 01-19-2009, 06:27 PM   #8
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

This is the sort of thing in which I wouldn't use Table, It would at least need a unit group trick to be safe.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 01-19-2009, 07:47 PM   #9
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

Okay, I split them up and fixed all of the documentation. I also removed those array initializations, since Ani cleared up that one for me.
__________________
Rising_Dusk is offline   Reply With Quote
Old 01-21-2009, 02:17 PM   #10
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

I think it is a good thing. Though I suggest you to make a UnitIndexingutilities that doesn't use user data so that people are not disallowed to use it if user data is used by something else. hmnn.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 01-21-2009, 02:34 PM   #11
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

Quote:
Originally Posted by Vexorian
Though I suggest you to make a UnitIndexingutilities that doesn't use user data so that people are not disallowed to use it if user data is used by something else. hmnn.
Okay, I'll look into making a flavor of UnitIndexingUtils that doesn't require UserData sometime. I really think that UserData should be reserved for unit indexing anyways, since once you index the unit you have a port with which to associate infinite data to that unit.
__________________
Rising_Dusk is offline   Reply With Quote
Old 01-21-2009, 02:50 PM   #12
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

It kind of becomes an issue when there are thousands of different indexing systems.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 01-21-2009, 03:11 PM   #13
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

That's certainly true. I wish we could streamline the use of userdata (like with UnitIndexingUtils) like you did timers (with TimerUtils) and gamecache (with Table); it would remove the fuzziness in that sort of thing.
__________________
Rising_Dusk is offline   Reply With Quote
Old 02-11-2009, 08:19 AM   #14
Av3n
Roar!
 
Av3n's Avatar


Project Leader: TBR
Project Member: PoC
 
Join Date: May 2006
Posts: 1,853

Submissions (7)

Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)

Hero #4 extra-official winner2008 Spell olympics - Fire - BronzeHero Contest #3 - 3rd Place

Default

Just to remind you from my PM.

Is it possible that you can create a "flavor" which uses Table instead of your own system Unit Indexing Utilities.

I reckon Table has a higher (I don't think it is the right term oh well) re-use-ability rate. So I highly suggest that you do.

-Av3n
__________________

Thanks to FatherTime for the sig
.:
Current ProjectsSubmissions
Power of CorruptionMy Terrain
The Black RoadMy Resources
Strikeforce
Twitter
Av3n is offline   Reply With Quote
Old 02-11-2009, 11:50 AM   #15
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

I thought about this. The problem with having two versions requiring different libraries is that then it becomes absolutely critical which version of the library users are using. It may as well be like having two entirely different libraries, since they are not interchangeable with each other at all.

I'll ask Vex/Ani about it and then go from there, more than likely.
__________________
Rising_Dusk is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 12:45 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services