> For the complete documentation index, see [llms.txt](https://docs.infimagames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infimagames.com/product/tactical-fps-animation-packs/guides-and-tutorials/editor/your-own-actions-and-weapon-logic.md).

# Advanced: Your Own Actions and Weapon Logic (If You Reuse the Demo Setup)

Advanced, for readers who reuse our demo showcase setup: give a weapon new moves with the data asset's Actions list, and give a weapon logic of its own.

{% hint style="warning" %}
This guide is for readers who chose to reuse our demo showcase Blueprints, such as the Weapon Component, on their own character. The Blueprints are mainly meant for showcase purposes, and aren't intended to be used as an FPS template out of the box.
{% endhint %}

#### Table of Contents

* [Introduction](#introduction)
* [Before You Start](#before-you-start)
* [Make R Play the Quick Reload](#make-r-play-the-quick-reload)
* [Add a New Action to Your Character](#add-a-new-action-to-your-character)
* [Give Your Own Montages the Idle Offset Curve](#give-your-own-montages-the-idle-offset-curve)
* [Give a Weapon Its Own Fire Logic](#give-a-weapon-its-own-fire-logic)
* [Parts and Idle Variations](#parts-and-idle-variations)

***

### Introduction

***

In this guide, I'll show you how to give a weapon new moves with the data asset's **Actions** list, and logic of its own. I'll use the Pistol.

An action is a set of synced montages, character and weapon, first and third person, that the Weapon Component plays as one move, such as Reload, Inspect or Melee.

***

### Before You Start

***

{% hint style="warning" %}
Work in your own copy of the data asset, such as `DA_MyPistol`. An update can replace the original.
{% endhint %}

* Make your copy with [How to Customize a Weapon's Settings and Fit a Scope](https://docs.infimagames.com/product/tactical-fps-animation-packs/guides-and-tutorials/editor/add-a-weapon-and-scopes.md#customize-a-weapons-settings).
* The second task needs your own character with the Weapon Component, from [How to Use the Weapons on Your Own Character](https://docs.infimagames.com/product/tactical-fps-animation-packs/guides-and-tutorials/editor/use-the-weapons-on-your-own-character.md).

***

### Make R Play the Quick Reload

***

An Actions entry with the name of a built-in action replaces its montages. Here you'll make R play the Pistol's quick reload, right in the showcase.

{% stepper %}
{% step %}

#### Add an Entry Named Reload

1. Open your copy of the data asset.
2. Under **Animation > Actions**, add an entry to **Actions**.
3. Set its **Name** to `Reload`.

<div align="left" data-with-frame="true"><figure><img src="https://3271331258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuuZjeeFspZ4mvcxHpS6M%2Fuploads%2FOUNRh5ecMJmfHPalNA46%2FSL-ACT-01.png?alt=media&amp;token=0c575f4c-cbb7-43b5-9367-314f819cfdfc" alt="" width="470"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### Set Its Montages

Add one montage to each of its lists:

* **FP\_CharacterMontages**: `AM_TFA_FP_Pistol_Reload_Quick`
* **TP\_CharacterMontages**: `AM_TFA_TP_Pistol_Reload_Quick`
* **FP\_WeaponMontages**: `AM_TFA_FP_WEP_Pistol_Reload_Quick`
* **TP\_WeaponMontages**: `AM_TFA_TP_WEP_Pistol_Reload_Quick`
  {% endstep %}

{% step %}

#### Test It in Play

1. In `L_TFA_Pistol_Showcase`, set the demo character's **WeaponComponent**'s **Weapon Config** to your copy.
2. Hit **Play** and fire a round.
3. Press **R**.

The quick reload plays instead of the normal one.
{% endstep %}
{% endstepper %}

You can replace Reload, ReloadQuick, ReloadEmpty, ReloadEmptyRetain, MagCheck, Inspect, Equip, Holster, Malfunction, Melee, GrenadeThrow, Interact and Heal the same way.

***

### Add a New Action to Your Character

***

Here you'll add the Pistol's quick draw, which the showcase doesn't play, as an action of its own, and play it from a key on your character.

{% stepper %}
{% step %}

#### Add the Action

1. In your copy, add an entry at the end of **Actions** named `QuickDraw`. It already has a few.
2. Set **FP\_CharacterMontages** to `AM_TFA_FP_Pistol_Equip_Quick`.
3. Set **TP\_CharacterMontages** to `AM_TFA_TP_Pistol_Equip_Quick`.

It needs no weapon montages.

{% hint style="info" %}
The Assault Rifle has quick draw animations but no montages for them. Right-click `A_TFA_FP_AR_Equip_Quick` and `A_TFA_TP_AR_Equip_Quick` and pick **Create > Create AnimMontage**. Then drag the new montages to a folder of your own and pick **Move Here**.
{% endhint %}
{% endstep %}

{% step %}

#### Call It From a Key

1. Open your character's Event Graph.
2. Add a keyboard event for a free key, such as **Z**. Q is the quick reload in `IMC_TFA_Default`.
3. Drag in your Weapon Component.
4. Call **Play Action** with the Action Name `QuickDraw`.

<div align="left" data-with-frame="true"><figure><img src="https://3271331258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuuZjeeFspZ4mvcxHpS6M%2Fuploads%2F2JrVhPaoU9DHRFFxspuc%2FSL-ACT-02.png?alt=media&amp;token=21277e7a-5c71-489e-9c89-74786d47913e" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### Test It in Play

1. Hit **Play** in your own map.
2. Press **Z**.

The quick draw plays.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Play Action** returns **Started**. It's false while another action plays, while running or sprinting, or when there's no action with that name. An action plays only in the views it has a character montage for.
{% endhint %}

<details>

<summary>The fields of an Actions entry</summary>

Each entry is an `S_TFA_ActionData`.

| Field                                                | What it does                                                                            |
| ---------------------------------------------------- | --------------------------------------------------------------------------------------- |
| **Name**                                             | What you call it with, and what the action events report.                               |
| **FP\_CharacterMontages**, **TP\_CharacterMontages** | The body montages. With several, one is picked at random, the same pick for every view. |
| **FP\_WeaponMontages**, **TP\_WeaponMontages**       | The weapon montages, picked the same way.                                               |
| **PlayRate**                                         | 1 plays as authored.                                                                    |
| **StartSection**                                     | A montage section to start in. Left empty, it starts at the beginning.                  |

Two name endings pick a version of an action by the weapon's state. `<Action>_Empty` plays while the slide or bolt is locked, and `<Action>_Scope` while a scope is fitted. The component's **Action Play Rate** multiplies the speed of every action, for example 1.25 for faster reloads.

</details>

<details>

<summary>While an action plays</summary>

| Call or notify                                                | What it does                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Jump To Action Section** (Section Name)                     | Moves the action's montages to a section.                                                                                                                                                                                                                                                                                                                        |
| **Set Next Action Section** (Section Name, Next Section Name) | Chooses what follows a section.                                                                                                                                                                                                                                                                                                                                  |
| **Stop Current Action** (Blend Out Time)                      | Cuts the action short.                                                                                                                                                                                                                                                                                                                                           |
| **`AN_TFA_ActionEvent`** with an Event Name                   | Calls **On Action Event** (Action Name, Event Name), for example a shell going in on a weapon of your own. Our reloads use the name `MagazineSeated`, see [How to Use the Demo Animation Notifies & States](https://docs.infimagames.com/product/tactical-fps-animation-packs/guides-and-tutorials/editor/how-to-use-the-demo-animation-notifies-and-states.md). |
| **`AN_TFA_UnlockActions`**                                    | Ends the action. New actions may start from here. Without one, the action ends with its montage.                                                                                                                                                                                                                                                                 |

A shell-by-shell reload loops a `Loop` section with Set Next Action Section (Loop, Loop) and leaves it with (Loop, End). **On Action Started** reports the start. **On Action Finished** reports the end once, with Interrupted true when it was cut short.

</details>

***

### Give Your Own Montages the Idle Offset Curve

***

Action montages are made on the default pose, so in first person a float curve on the montage, `TFA_IdleOffsetOff`, moves the weapon's idle offset (**Offset Idle Pose**, or **Offset Crouch** while crouched) out of the way. Our montages already have it, so this is only for first person montages of your own.

{% stepper %}
{% step %}

#### Find the Curves Track

Open your montage and find the **Curves** track.
{% endstep %}

{% step %}

#### Create the Curve

1. Open its dropdown.
2. Pick **Add Curve... > Create Curve**.
3. Name it `TFA_IdleOffsetOff`.
   {% endstep %}

{% step %}

#### Key It

Key 0 at the start, 1 once the weapon has left its offset spot, and 0 again by the time it's back.

1. Right-click the curve's row and pick **Edit Selected Curves**.
2. In the Curve Editor, right-click the curve and pick **Add Key** (or middle-click).
3. Type the key's time and value in the boxes at the top.

<div align="left" data-with-frame="true"><figure><img src="https://3271331258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuuZjeeFspZ4mvcxHpS6M%2Fuploads%2FLzcB52nshDqU7OcLY4CS%2Fidle-01.png?alt=media&amp;token=b21e4ea0-7cc0-43e6-b788-1098c86b4230" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### Test It in Play

1. Add the montage to an action, as in [Add a New Action to Your Character](#add-a-new-action-to-your-character).
2. Play it in first person.

The weapon leaves its offset spot and comes back as the curve is shaped.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
Ours have four smooth keys, from 0 to 1 over the first 8 frames and back to 0 over 12 frames, before the weapon has settled. Copying one of ours is a quick start.
{% endhint %}

<details>

<summary>How the curve works</summary>

1 is the default pose, with no offset, and 0 is the full offset. Make the ramps longer for a smoother move, or shorter for a snappier one.

* The curve fades with the montage as it blends in and out, so the offset is always back once the montage is done.
* An animation without the curve keeps the full offset. Our fire, fire mode switch, jump and grip change montages have none.
* Our reloads, magazine checks, inspects, jam clears, equips, holsters, melee, grenade, heal and interact montages ship with one. An equip starts with the offset out and eases it in, and a holster eases it out and keeps it out.
* It's first person only.

The curve's name is the data asset's **Idle Offset Curve** (Procedural Offsets), `TFA_IdleOffsetOff` by default.

<div align="left" data-with-frame="true"><figure><img src="https://3271331258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuuZjeeFspZ4mvcxHpS6M%2Fuploads%2FgQIT6HRliBGE00V7tJyq%2Fidle-02.png?alt=media&amp;token=7f71d0eb-d785-4dd0-89cb-555f6936d139" alt="" width="563"><figcaption></figcaption></figure></div>

If you want a plain on and off instead of a curve, the `ANS_TFA_BlockIdleOffset` notify state turns the idle offset off while it runs. The curve then shapes whatever is left. The notify leaves **Offset Crouch** on, so to take the crouch offset out during an action, use the curve.

</details>

***

### Give a Weapon Its Own Fire Logic

***

A weapon that loads shells one by one, or needs anything more than new animations, gets a Blueprint of its own. Here you'll make one that prints a message instead of firing, to see where its logic goes.

{% stepper %}
{% step %}

#### Make a Child Blueprint

1. In `Common/Framework/Weapons`, right-click `BP_TFA_BaseWeapon` and select **Create Child Blueprint Class**.
2. Name it, such as `BP_MyPistol`.
3. Drag it out of the pack's folders into one of your own and pick **Move Here**.
   {% endstep %}

{% step %}

#### Override Handle Start Fire

1. Open your child Blueprint.
2. In the **My Blueprint** panel, open the **Override** dropdown next to Functions and pick **Handle Start Fire**.
3. Add a **Print String** that prints `Click`.
4. Alt-click the pin between the **Parent: Handle Start Fire** call and Handled to break that link.
5. Tick **Handled** on the Return Node.

<div align="left" data-with-frame="true"><figure><img src="https://3271331258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuuZjeeFspZ4mvcxHpS6M%2Fuploads%2FSijLQkeGqQ4QRZVrD0vG%2FSL-ACT-03.png?alt=media&amp;token=79be856f-69a0-4eaa-af82-6c9e05ad0fdd" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### Set It as the Weapon Class

In your copy, set **Weapon > Weapon Class** to your child Blueprint.
{% endstep %}

{% step %}

#### Test It in Play

1. Point the demo character at your copy.
2. Hit **Play** and pull the trigger.

`Click` shows on screen and no shot fires, because Handled skips the default firing.
{% endstep %}
{% endstepper %}

<details>

<summary>The overrides</summary>

| Override                                              | Runs when                                                                                                                                    | Return Handled to                           |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| **Handle Start Fire**                                 | the trigger is pulled                                                                                                                        | skip the default firing                     |
| **Handle Stop Fire**                                  | the trigger is released                                                                                                                      | skip the default, which ends automatic fire |
| **Handle Action** (Action Name)                       | any action is asked for                                                                                                                      | skip the default action                     |
| **Handle Action Event** (Action Name, Event Name)     | an `AN_TFA_ActionEvent` fires in one of its actions                                                                                          |                                             |
| **Handle Action Finished** (Action Name, Interrupted) | one of its actions ends. If you override it, right-click the event and pick **Add Call to Parent Function**, or the reload's refill is lost. |                                             |

The weapon's **Weapon Component** variable is set from the moment it spawns, so a hook plays its montages through the component with **Play Action Data** (an action, without the hooks), **Jump To Action Section** and **Set Next Action Section**. Calling Play Action with the same name from inside Handle Action plays the default version. The component keeps everything shared, such as busy, aiming, switching and the events, so a hook only decides what this weapon does.

</details>

***

### Parts and Idle Variations

***

<details>

<summary>Parts</summary>

Extra meshes go in the data asset's **Parts** (Meshes > Parts). Each has a Name, a Mesh, a receiver Socket and a visibility tick box, bVisible. The weapon builds them on its receiver. At runtime **Get Part** (Part Name) and **Set Part Visible** (Part Name, Visible) on the weapon reach them, for example a part of your own weapon that moves or comes off.

</details>

<details>

<summary>Idle Variations</summary>

**Idle Variations** (Animation > Idle Variations) is a list of actions, like Actions entries, for small idle moves such as a re-grip. When the weapon has been idle for the trigger discipline time, one of them plays at random with **Idle Variation Chance** instead of the finger coming off the trigger. Any action, aiming or moving stops it. Our weapons leave it empty. It uses the trigger discipline timer, so the weapon needs its trigger discipline animations too.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.infimagames.com/product/tactical-fps-animation-packs/guides-and-tutorials/editor/your-own-actions-and-weapon-logic.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
