Item Actions - MSUTeam/MSU GitHub Wiki
Item Action refers to swapping/equipping/removing items on a character during combat. MSU completely overhauls how the action point costs for this are handled. Now you can add skills that modify how many Action Points it costs to swap items, depending on what kind of items they are. This is accomplished via three things:
ItemActionOrder
getItemActionCost( _items )
onPayForItemAction( _skill, _items )
The ItemActionOrder
field of a skill defines the priority in which a skill is consumed for changing the AP cost of an item action. The possible values are defined in a table ::Const.ItemActionOrder
and can be expanded by modders. A skill's order can then be defined during the create()
function by an expression such as this.m.ItemActionOrder = ::Const.ItemActionOrder.First
.
By default all skills are assigned this.m.ItemActionOrder = ::Const.ItemActionOrder.Any
.
getItemActionCost( _items )
// _items is an array
_items
contains the items involved in the item action.
This function can be defined in a skill, and programmed to suit the needs and effects of that skill. The function returns either null
or an integer
. If it returns null, this means that this skill does not change the Action Point cost of this item action. Returning an integer means that this skill will make this item action's Action Point cost equal to the returned value. By default it returns null for all skills.
onPayForItemAction( _skill, _items )
// _skill is a BB object
// _items is an array
_skill
is the skill chosen for determining the Action Point cost of the item action. _items
contains the items involved in the item action.
This function is called on all skills after an item action.
Using this new system, Quick Hands is now implemented as follows:
this.m.IsSpent = false;
this.m.ItemActionOrder = this.Const.ItemActionOrder.Any;
function getItemActionCost( _items )
{
return this.m.IsSpent ? null : 0;
}
function onPayForItemAction( _skill, _items )
{
if ( _skill == this)
{
this.m.IsSpent = true;
}
}
function onTurnStart()
{
this.m.IsSpent = false;
}
If a skill was designed to only allow 0 Action Point cost swapping between two one-handed items, the getItemActionCost
function could be coded as follows:
function getItemActionCost( _items )
{
local count = 0;
foreach (item in _items)
{
if (item != null && item.isItemType(::Const.Items.ItemType.OneHanded))
{
count++;
}
}
return count == 2 ? 0 : null;
}