Unit abilitiy

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Unit abilitiy

Post 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
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Unit abilitiy

Post 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
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Unit abilitiy

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Unit abilitiy

Post 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
Post Reply

Return to “Battle Academy : Modders Corner ”