For the complete documentation index, see llms.txt. This page is also available as Markdown.

🤕MDamageable

Last updated AC v1.5.3

Overview

This component is in charge of connecting the Animal Controller to any Damager Component. It receives the Direction, the Stat to modify and the rest of the hit data, decides whether the hit is accepted, applies the Stat modification and plays an Animal Reaction according to the Damager information.

This Component Requires a reference to the Stats Component

This component can be also used on child colliders to simulate specific damages.

E.g.

  • You can add a MDamageable Component to the Head collider, and add a Multiplier of 2 to simulate Headshots that make twice the damage value.

  • You can add a MDamageable Component to the Chest collider, Shield, or Head Helmet, add a Multiplier of 0.5 to simulate Defense, and only do half the Damage.

Internal MDamageables

The component can also be set inside the Animal Hierarchy. This is very useful to create different damages and reactions to the animal.

For example, you can add an MDamageable component to the Head Collider, with a multiplier of 2 and a Reaction set to Play the Stun Action for 3 Seconds. If the Animal receives direct damage to the head collider, the Damage value will double and it will play a stun animation instead of the Damage Animations.

A child Damageable points to the character's main Damageable through its Root. Every event the child invokes is forwarded to the Root, and the Root's Can Receive Damage conditions apply to the child as well, so a rule such as "no damage while Dodging" is written once on the character and every hit box respects it.

How it Works

Every hit, whatever Damager sent it, goes through the same steps in this order. A step that stops the hit ends it completely: nothing below it runs.

Pure Damage (a Damager option) bypasses every multiplier on this side: the Profile Multiplier and the Element Multipliers. The Stat receives the Damager's value untouched.

Parameters

General

Stats

Reference to the Stats component that receives the modification. Found automatically in the hierarchy when empty.

Root

The root Damageable gameobject, if this is a child gameobject (see Internal MDamageables).

Surface

Type of surface the damageable is e.g. Wood, Flesh, Metal etc. Damagers use it to pick the matching Hit Effect from their Surface Effects asset.

Can Receive Damage

A list of Conditions evaluated before any damage is applied. The conditions target is the Character (the component the Damage Reaction points to, usually the Animal). When the list fails, the hit is rejected: no reaction plays, the Damager receives no reaction, no event fires except On Damage Ignored, and the Stat is not modified.

[Insert Image - MDamageable inspector showing the Can Receive Damage conditions box with an Animal Modes condition inside]

E.g. to make the character invulnerable while it is Dodging, add an Animal ▸ Modes condition with Playing Mode = Dodge and enable Invert on it, so the list is true only while the Dodge Mode is not playing.

The conditions shown here belong to the Default Profile. Every other Profile carries its own list, so a Block or Parry profile can use a different rule (e.g. ignore hits coming from the front) while it is active.

The Damager asks this Damageable first (IMDamage.CanReceiveDamage()), so Attack Triggers and Melee weapons treat a rejected hit like a miss: they skip their Interact, Physics, Stop Animator and Hit Effects. A dodged sword spawns no blood.

Damage Reaction

Reaction to apply on the Animal when receiving Damage. By Default it will apply Mode Damage on the Animal, but you can change it and use any other Animal Reaction.

You can add a MDamageable Component to the Head collider and change the reaction to activate a Stun Animation instead.

Critical Reaction

The reaction to apply to the animal if a critical hit is achieved. It replaces the Damage Reaction and any custom reaction sent by the Damager.

Damager Reaction

The reaction to apply to the one dealing the damage to this gameobject (the Damager's Owner). E.g. a Shield can push back the attacker.

Ignore Damager Reaction

A Damager can bring its own custom reaction with the hit. When this option is enabled, that custom reaction is ignored and this Damageable plays its own Damage Reaction instead. Use it when the character must always react the same way no matter which weapon hit it. Each Profile has its own value.

Multiplier

Value to apply an extra modification to the Stats to make Double Damage, if is set to greater than 1; or acts as Defense value if is set to a value between 0-1.

Elements

A list of elements (Fire, Ice, Rock, Lightning etc.) and their associated damage multipliers that affect the damage values given to this gameobject. When the Damager's element matches an entry, the value is multiplied and On Element Damage is invoked.

Align to Damage

When enabled the animal will rotate toward the damage direction

Only On Movement Zero

Align only when the character is not moving. Enabled by default, so a running character is not spun around by a hit.

Align Time

How long the alignment will last

Align Curve

Curve to smooth the trajectory of the alignment

Align Offset

For Animals in which the pivot may be set in the Hip position you can adjust the Rotation Pivot of the alignment with this value:

Profiles

To Activate a profile, call this function:

MDamageable.Profile_Set(string ``profileName)

To reset to the default values, call:

MDamageable.Profile_Restore();

The damageable can use different profiles to change the way the animal can react to receiving damage.

E.g. You can activate a Profile when the Character has a New Armor, and it changes the way the Damage is done. So the character will receive half the damage.

Or you can change the Profile to Heavy Damage Animations if the Animal is in a Wounded stance.

Name

The name of the profile. Passing "Default" (or an empty name) to Profile_Set restores the Default profile.

Every profile carries its own copy of these General parameters:

Parameter
Notes

Surface

Hit Effect surface while the profile is active

Multiplier

Profile damage multiplier

Align To Damage

Whether the character turns toward the hit

Ignore Damager Reaction

Force this profile's own Damage Reaction

Can Receive Damage

Conditions checked before any damage while this profile is active

Damage / Critical / Damager Reaction

Reactions used while the profile is active

Elements

Element multipliers while the profile is active

On Profile Enter / On Profile Exit

Optional events, shown when Events is enabled on the profile

The values on the General tab are the Default profile. Its Enter and Exit events live on the Events tab as On Profile Default Enter / Exit.

Events

On Receiving Damage (Float)

Invoked when the Damageable receives damage. Sends the final value of the Stat modification, after the Element and Profile multipliers.

On Critical Damage

Invoked if the Damage received is Critical.

On Damager (Gameobject)

This is invoked when a Damage is received. Use it to know who did the Damage.

On Element Damage (Int)

Invoked when receiving elemental damage (Wood, Fire, Ice, Electric etc). Sends the Element ID.

On Stat Empty (Int)

Invoked when the modified Stat reaches its minimum value with this hit. Sends the Stat ID. Use it for kill confirmations from a specific hit box.

On Damage Ignored (Gameobject)

Invoked when the Can Receive Damage conditions reject a hit. Sends the Damager. Use it to play a dodge or parry effect, or to notify the attacker.

On Damage Missed (Gameobject)

Invoked when the attack was rolled as Missed by the Damager's Miss Chance. Sends the Damager. A missed hit plays no reaction and leaves the Stat untouched; the Floating Numbers component listens to this event to show its Missed! text.

On Profile Default Enter / On Profile Default Exit

Invoked when the Default profile becomes active or is replaced by another profile.

All of these events are also invoked on the Root Damageable when they fire on a child Damageable.

Last updated