> For the complete documentation index, see [llms.txt](https://fantacode.gitbook.io/melee-combat-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fantacode.gitbook.io/melee-combat-system/weapon.md).

# Weapon

The WeaponData ScriptableObject is a comprehensive data container designed to manage all aspects of a weapon. This centralizes the configuration of weapon properties, animations, and behaviors, providing a flexible way to define and control weapon functionality

## Create Weapons

You can create a **weapon** by going to <mark style="color:green;">Create > Combat System > Create Weapon</mark>.

<div align="left"><figure><img src="https://3464424545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuYXVsBPBq71gIDr5Gb7g%2Fuploads%2F2iadD1hZsfvkKLG654Vg%2FWeapon.png?alt=media&amp;token=1106c1be-77ad-48e4-876f-5532201b5f63" alt=""><figcaption></figcaption></figure></div>

**Weapon Data**

<div align="left"><figure><img src="https://3464424545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuYXVsBPBq71gIDr5Gb7g%2Fuploads%2FzXNR8wEpJHR3tGbtGcKT%2FScreenshot%202024-07-18%20133248.png?alt=media&amp;token=554076e6-9d19-417e-a520-0b2e6556ee5f" alt=""><figcaption></figcaption></figure></div>

**General Weapon Settings:**

* **Spawn Weapon:** A boolean that determines if the weapon should be instantiated and attached to the character.
* **Weapon Holder:** Specifies the bone in the character's skeleton (e.g., `RightHand`) where the weapon will be attached.
* **Local Position & Rotation:** The position and rotation of the weapon relative to the weapon holder, allowing for precise placement and orientation.

**Attack Data:**

* **Attacks:** A list of `Attacks,` each defining an attack's data and conditions.
* **Heavy Attacks:** A separate list for attacks that are categorized as heavy

<figure><img src="https://3464424545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuYXVsBPBq71gIDr5Gb7g%2Fuploads%2FUpJaDUhD2AnSFsDqrTbx%2Fimage.png?alt=media&amp;token=9d92df98-bbe3-403f-a289-8e0a62403799" alt=""><figcaption></figcaption></figure>

* **Attack Type:** The type of the attack (e.g., Single, Combo, Stealth, Grounded).

Conditions:

* **Minimum Distance:** The minimum distance for the attack to be effective.
* **Maximum Distance:** The maximum distance for the attack to be effective.
* **Health Threshold:** The attack will only be triggered if the target's health is below this threshold, expressed as a percentage.
* **Rootmotion Distance:** Click this button to get the attack root motion distance, which helps set the minimum and maximum distance for the attack.

Attack:

* **Attack:** Data for the specific attack.
* **Can Be Charged:** Indicates if this attack can be charged.
* **Charged Attack:** Data for the charged version of the attack.

**Reaction Data:**

* **Reaction Data:** Handles the responses triggered by specific tags or directions with the weapon
* **Block Reaction Data:** Separate data for reactions specific to blocking, ensuring that the weapon responds appropriately in defensive scenarios.

**Blocking Mechanics:**

* **Can Block:** A boolean indicating if the weapon can block incoming attacks.
* **Blocking Animation:** The animation clip used when blocking.
* **Blocked Damage:** A float value that defines the percentage of damage taken while blocking.
* **Block Reaction Data:** Data for the reactions that occur when the weapon is used to block.
* **Block Mask:**`AvatarMask` to use during blocking.

**Counter Mechanics:**

* **Can Counter:** Indicates if the weapon can perform counterattacks.
* **Play Action If Counter Misused:** If true, the fighter will play a taunt action if the counter input is pressed while the enemy is not attacking. This can be used to prevent the misuse of the counter input.
* **Counter Misused Action:** Animation clip of the action to play if the counter is pressed while the enemy is not attacking.

**Equip Weapon:**

* **Weapon Equip Animation:** Defines the animation that plays when the weapon is equipped
* **Weapon Activation Time:** The time taken to activate the weapon.
* **Weapon Equip Sound:** The sound effect that plays when the weapon is equipped.

**Unequip Weapon:**

* **Weapon Unequip Animation:** Defines the animation that plays when the weapon is unequipped.
* **Weapon Deactivation Time:** The time taken to deactivate the weapon.
* **Weapon Unequip Sound:** The sound effect that plays when the weapon is unequipped.

**Advanced:**

* **Animator Override Controller:** Manages different movement animations specific to the weapon, allowing for customized animation transitions based on the weapon equipped.
* **Use Rootmotion:** When enabled, root motion drives the character’s movement animation data. This only works if the player is in a combat stance
* **Override Move Speed:** Indicates if the locomotion movement speed should be overridden.
* **Walk Speed, Run Speed, Sprint Speed:** Configure these speeds to control how the character moves at different paces.
* **Combat Move Speed:** Adjusts the speed specifically for combat mode, influencing how the character circles a target when in a locked-on combat stance.
* **Weapon Holding Clip:** Animation that keeps the weapon correctly positioned during movement.
* **Weapon Holder Mask:** Applies an `AvatarMask` to focus the holding animation on the relevant parts of the character’s body, ensuring that the weapon appears correctly during all movements
* **Min Attack Distance:** Minimum distance required for the weapon to effectively engage and impact targets during an attack.
