> For the complete documentation index, see [llms.txt](https://roogame.gitbook.io/roogame/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roogame.gitbook.io/roogame/ultimate-stats-framework/creating-your-dynamic-gameplay-formulas/quick-start.md).

# Quick Start

This chapter shows you how to create a damage formula for a normal attack.

Before starting this chapter, make sure you have completed the [Attribute System](/roogame/ultimate-stats-framework/creating-your-attribute-system.md) chapter and understand how to configure and use Stats and Attributes.

### Create a Formula

First, open the **Stat Designer** and switch to **Formula** in the top-left corner.

<figure><img src="https://2218703886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4YPyrdOyfjDGtlxlvjSd%2Fuploads%2Fff4JJp0CWjp2s2JR6O9Z%2Fimage.png?alt=media&amp;token=50594b1f-afb9-4b2b-a4dd-3f0f2d969acf" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2218703886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4YPyrdOyfjDGtlxlvjSd%2Fuploads%2FsNmweXLGZDWnOvOjA723%2Fimage.png?alt=media&amp;token=1a632353-bda3-482e-befd-516301c2bb9e" alt=""><figcaption></figcaption></figure>

Next, add an **Attack** category in the **Category** panel.

Select the **Attack** category, then add a **BasicAttackDamage** formula in the **Formula** panel.

<figure><img src="https://2218703886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4YPyrdOyfjDGtlxlvjSd%2Fuploads%2FKBJ67ldlVkLkopKTMQze%2Fimage.png?alt=media&amp;token=bc2f59b5-bb17-44f2-8010-ce5b43535115" alt=""><figcaption></figcaption></figure>

Select the **BasicAttackDamage** formula you just created. In the **Formula** properties panel on the right, enter:

`-1 * max(0, self.stat.Attack - target.stat.Defense)`

This formula calculates the damage based on the attacker’s **Attack** and the target’s **Defense**.

* `self.stat.Attack` represents the attacker’s Attack value.
* `target.stat.Defense` represents the target’s Defense value.
* `max(0, ...)` ensures the calculated damage will never be less than `0`.
* `-1 *` converts the result into a negative value, allowing it to be applied directly as a reduction to the target’s HP.

<figure><img src="https://2218703886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4YPyrdOyfjDGtlxlvjSd%2Fuploads%2FIvVxWWr5ufN7rZDltA7g%2Fimage.png?alt=media&amp;token=47b83b4a-05e8-4960-af3a-1b9f79653882" alt=""><figcaption></figcaption></figure>

Click **Use** in the top-right corner to save your changes. The formula is now ready to use.

To calculate the formula, use the **Calculate Formula** node from Ultimate Stats Framework Component  and select the formula tag you just created:

`MyRPGGame.Formula.Attack.BasicAttackDamage`

Then, pass in the Ultimate Stats Framework Component for both **Self** and **Target**.

The node will evaluate the formula using these two components and return the calculated result.

> **Note:** All formulas are automatically created under the `Namespace.Formula` tag path.

<figure><img src="https://2218703886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4YPyrdOyfjDGtlxlvjSd%2Fuploads%2FEw94JAVPiaTbHYfIsBMS%2Fimage.png?alt=media&amp;token=f60f5d69-7896-4ccd-9560-3ee566401035" alt=""><figcaption></figcaption></figure>
