Page 1 of 1

Unit abilitiy

Posted: Mon Sep 17, 2012 4:41 pm
by enric
I managed to use several new abilities copying the work of others as many are doing, but I would like to understand how to do, how it works.

In Unit Ability Functions there are some descriptions on how to be done:
ALL_CHECK_<name>
UISETUP_ALL_<name>
ALL_<name>

Merr used this approach when doing the smoke
CHECK_ALL_INDIRECT_SMOKE
UISETUP_ALL_INDIRECT_SMOKE
ALL_INDIRECT_SMOKE

But as you see the ALL_CHECK as become CHECK_ALL.... which seems more logical following the convention of first the ALL_ or TILE_ or INIT_

And look at the Merge ability (using UNIT_ in place of ALL_ but also using CHECK_prefix_action, not prefix_CHECK_action:

CHECK_UNIT_MERGE
UISETUP_UNIT_MERGE
UNIT_MERGE

Re: Unit abilitiy

Posted: Mon Sep 17, 2012 5:53 pm
by pipfromslitherine
It uses the prefix to find the functions that do the various things. The ALL_, TILE_ and UNIT_ prefixes tell the system that a given order is only applicable depending on what is on the tile (in reality it would probably have been simpler to just handle the situations in each function and clean up the function names, but it's too late to change it now!).

It uses the name of this main function (which actually does the action) to build the various CHECK_, UISETUP_ etc functions. ALL_CHECK is incorrect and won't work properly - but checking the docs you are correct that they are wrong. Sorry about that - fixed now! That would definitely have been confusing.

Cheers

Pip

Re: Unit abilitiy

Posted: Mon Sep 17, 2012 7:19 pm
by enric
I supposed it was a manual mistake.

Can you tell me the events handler order, e.i when a unit is selected what of the function is called first
CHECK_UNIT_attribute
UISETUP_UNIT_attribute
UNIT_attribute

And how to discriminate a unit to do or not an ability, where should the code be put.
When the cursor is moved over another tile which is the calling order of Functions?, I'm a little confused with the event handler in BA.

Re: Unit abilitiy

Posted: Mon Sep 17, 2012 9:27 pm
by pipfromslitherine
The CHECK function is called to determine whether to show the order at all, and whether it is disabled or not (so you also build any tooltips in there). The actual function (e.g. UNIT_) is called when you action an order. The UISETUP_ function determines how the button looks when it is displayed.

Cheers

Pip