actor - MSUTeam/MSU GitHub Wiki
- Unique ID
- Modified functions
-
New functions
- getMaxMoraleState
-
Get items
- getMainhandItem
- getOffhandItem
- getHeadItem
- getBodyItem
-
Check equipment
- isArmedWithOneHandedWeapon
- isArmedWithTwoHandedWeapon
- getRemainingArmorFraction
-
Check situation
- isEngagedInMelee
- isDoubleGrippingWeapon
- isDisarmed
In vanilla all entities have an entity.getID()
function which returns an integer. However, this ID is not persistent and is changed every time you load a game. MSU adds unique IDs to all entities which are serialized and therefore remain the same when saving/loading the saved files of a campaign.
<entity>.getUID()
Returns the UID of the entity. Note that it is not allowed to fetch the UID of an entity while a saved game is being loaded, so calling this function during a deserialization process will throw an exception.
It is possible to globally fetch an entity by its UID using the ::MSU.getEntityByUID
function. Documentation for that is available here.
MSU modifies the vanilla getActionPointsMax
function of actor
to now return a floored value.
MSU adds several convenience functions to actor which allow for cleaner code and a faster modding experience.
<actor>.getMaxMoraleState()
Vanilla has a setter for the MaxMoraleState
of an actor but not a getter. MSU adds the getter. Returns this.m.MaxMoraleState
by default.
<actor>.getMainhandItem()
Returns the item currently equipped by <actor>
in the Mainhand item slot. Returns null if no item is found in that slot.
<actor>.getOffhandItem()
Returns the item currently equipped by <actor>
in the Offhand item slot. Returns null if no item is found in that slot.
<actor>.getHeadItem()
Returns the item currently equipped by <actor>
in the Head item slot. Returns null if no item is found in that slot.
<actor>.getBodyItem()
Returns the item currently equipped by <actor>
in the Body item slot. Returns null if no item is found in that slot.
<actor>.isArmedWithOneHandedWeapon()
Returns true if <actor>
is currently holding a One-Handed item in their Mainhand, otherwise returns false.
<actor>.isArmedWithTwoHandedWeapon()
Returns true if <actor>
is currently holding a Two-Handed item in their Mainhand, otherwise returns false.
<actor>.getRemainingArmorFraction( _bodyPart = null )
// _bodyPart is a key in ::Const.BodyPart
Returns a float which is the current remaining armor durability as a fraction of the maximum durability. If _bodyPart
is null then it returns the total remaining armor fraction calculated using both head and body armor, otherwise only returns the fraction calculated for the specified slot.
<actor>.isEngagedInMelee()
Returns true only if <actor>
is placed on the tactical map and there is an enemy who is exerting zone of control on <actor>
. Otherwise returns false.
<actor>.isDoubleGrippingWeapon()
Returns true if <actor>
has access to the special.double_grip
skill and the skill is not hidden. Otherwise returns false.
<actor>.isDisarmed()
Returns true if <actor>
has the effects.disarmed
effect. This function should be used whenever you want to check for an actor being disarmed, because it is expected that mods will hook and extend this function to include any other conditions which may lead to an actor being considered disarmed.