• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Efficiently differ between different types of orders

Status
Not open for further replies.

Ardenian

A

Ardenian

Hello, I would like to achieve an efficient way to differ between different kinds of orders, like 'No Target', 'Targeting a Unit' and so on.

My problem is, I have indexed abilities of different kinds, one for 'A Point', one for 'A Unit' and one for 'No Target'.

Is there a way in GUI/ GUIJASS to order a unit to cast these abilities without looping through all abilities and manually adding the right type of ordering ?

A solution could be to save the order in an additional indexed variable, but how do I add the different kinds of 'No Target', 'Targeting a Unit' and 'A Point' into the order action then ?
 

Ardenian

A

Ardenian

Hashtable using specific ability order as one of the keys and save/load one of the three types of orders should work?

Is there a way to save the order/ custom script/ indexed variable instead ?
I would like to not use hashtable for my spell ( this time).
 
Level 12
Joined
Nov 3, 2013
Messages
989
There should be a fairly easy way to do it, and from the looks of it you wouldn't even need a 2nd key either (Just knowing the ability order would let you know what type it is.).

However I'm kind of noob at programming so the only way I could think of off the top of my head to directly translate an order into one out of three numbers would be something like when you divide a number and either it will break even and you get a 0 or there'll be a 1 as remainder (Or something like that I think.).

So you'd make something similar to that; 0, 1 and 2 and have them as the index of a single variable. I.E. orderVar[0] would be no target, orderVar[1] target point, and orderVar[2] target unit.

Sadly I'm not really that good at this stuff so although I can think of how you'd kind of do it I honestly don't really know. :p
 

Ardenian

A

Ardenian

I would like to not use hashtable since I don't use one for anything else in this spell.

About the solution you speak about, how would the order look like ?
I don't think I can do it fully with GUI only, can I ?

For example, if I have something like this:
  • Custom script: call IssueTargetOrderById (udg_DummyUnit, udg_OrderId, udg_Target)
How would I save this in a variable ?

I cannot visualize your solution, although I understand what you mean.
You mean like having the different kinds of orders saved in the indexed variables and then pick the right one ?
How would I do that ?
 
Level 12
Joined
Nov 3, 2013
Messages
989
What I thought of is that you'd have 3 variables saved from the start and then make the modulo division right inside the brackets, basically right where there would be a 0, 1 or 2 you'd have a number, representing your ability/ies, divided by some other number and the remainder would directly give you the right option like when you'd load from a hashtable.

Again I haven't really done it though so I'm not that keen on the details...
 

Ardenian

A

Ardenian

Hm, I see. I just wondered, why doesn't this work ?

  • Set MT_TrackOrder[MT_TempInteger] = (String((Issued order)))
  • Custom script: call IssueOrder(udg_MT_TrackOrder[udg_MT_TempInteger])
The custom script is wrong, but wouldn't this work in some way, if the right custom script is used ?
 
JASS:
//Configure:

call SaveInteger(udg_AbilHash, udg_AbilID, 0, orderID)
call SaveInteger(udg_AbilHash, orderID, 1, orderType)

//Use:
set orderID = LoadInteger(udg_AbilHash, udg_AbilID, 0)
set orderType = LoadInteger(udg_AbilHash, orderID, 1)
if orderType != 0 then //avoid unregistered abilities
    if orderType == 1 then
        call IssueImmediateOrderById...
    elseif orderType == 2 then
        call IssuePointOrderById...
    else
        call IssueTargetOrderById...
    endif
endif
 
Level 12
Joined
Nov 3, 2013
Messages
989
Hm, I see. I just wondered, why doesn't this work ?

  • Set MT_TrackOrder[MT_TempInteger] = (String((Issued order)))
  • Custom script: call IssueOrder(udg_MT_TrackOrder[udg_MT_TempInteger])
The custom script is wrong, but wouldn't this work in some way, if the right custom script is used ?

The integers of order ID's can be used as array references if you subtract 0xD00000 from them.

:thumbs_up:

And this should probably be useful to know to even consider my "solution": http://www.thehelper.net/threads/order-ids.148097/
 

Ardenian

A

Ardenian

Alright, I get it, thank you!

If I do not want to use hashtables, couldn't I save an integer with the variable ?

If I would like to save a current order, like 'attack' or 'move', how would I do it ?

  • Set MT_TrackOrder[MT_TempInteger] = (String((Issued order)))
  • Set MT_TrackOrderType[MT_TempInteger] = ???
How would I differ here between the different kinds ?
I would set the MT_TrackOrderType[MT_TempInteger] to another integer variable like MT_AbilityOrderType[ARRAY] if ti is an ability,
but for common orders, like 'attack' or 'move', what about them ? How do I get them ?
Do I need a long ITE checking for every order I would like to take in consideration ?

( So basically simulating as if the unit casts Windwalk, making a dummy unit cast the spell instead and making the original caster unit continuing its previous order)
 
Level 12
Joined
Nov 3, 2013
Messages
989
Yeah I don't see how else you'd do it than bribe's way (Besides substituting the save/load with hashtable to the array) considering that it's three different functions you can't go without any "else if" at all...
 

Ardenian

A

Ardenian

Yes, it is quite complicated, as I need to different orders at once.
I need the previous order of Unit A, which can be a lot of different things, thanks for the link!, and I need the ability that is casted, transferring the order to Unit B.

I think I got an idea know how to do it, thank you!
 
Status
Not open for further replies.
Top