# Complex Enchantments

## Overview

Using [Placeholders](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders) from [PAPI](https://www.spigotmc.org/resources/placeholderapi.6245/), your able to make extremely complex enchantments that have 1 thing happen when a condition is met and a different thing happen when another condition is met all within one enchant level

Some examples of what you can make:

* Enchant that teleports you in the direction your facing
* Enchant that "marks" a player and deals extra damage to them
* Deal more damage the higher the grade of the opponents armor
* The possibilities are endless

### Placeholders

The main placeholders you'll be using are

| Placeholder                                                                                     | Description                                          |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| [ChangeOutput](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#changeoutput) | Gives you an output depending on another placeholder |
| [Player](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#player)             | Various statistics about a player                    |
| [CheckItem](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#checkitem)       | Checks Items in a players inventory                  |

### Getting Started

First step is to have an idea of what you want to make, in this example we will be making an enchant that increases how much damage you do depending on the type of armor the enemy is wearing.\
Create your basic enchant with the correct information:

```
rampage:
  display: "%group-color%Rampage"
  description: "Deal more damage the higher the grade of enemy armor"
  applies-to: "Weapons"
  type: "ATTACK"
  group: "LEGENDARY"
  applies:
    - ALL_SWORD
    - ALL_AXE
  levels:
    1:
      effects:
        - "INCREASE_DAMAGE:100 @Attacker"
```

### Figure out how to make it

You need to have an idea on how to make it, as in which placeholders to use, how to use it, and where to put it. In this enchant the damage increases depending on the enemy armor, so we'll need to check for the armor of the enemy. To do that we'll use the [CheckItem](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#checkitem) placeholder. We use the [ChangeOutput](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#changeoutput) placeholder so if the enemy is wearing Diamond Armor, we get an output, such as increase damage by 100%, otherwise 0%.

### Placeholders

Most Complex Enchants will need the [ChangeOutput](https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#changeoutput) placeholder, so it's recommended to learn how it works.\
Adding a victim before the checkitem placeholder checks the victim's helmet slot, and we can put that result in the ChangeOutput placeholder and compare it to see if it equals `DIAMOND_HELMET`, and if it does, have the ouput as 100%, and if it doesn't, have the ouput as 0% increased damage.

```
rampage:
  display: "%group-color%Rampage"
  description: "Deal more damage the higher the grade of enemy armor"
  applies-to: "Weapons"
  type: "ATTACK"
  group: "LEGENDARY"
  applies:
    - ALL_SWORD
    - ALL_AXE
  levels:
    1:
      effects:
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:39_mat:}_DIAMOND\_HELMET_100_0% @Attacker"
```

{% hint style="warning" %}
The DIAMOND\_HELMET has an underscore, which would interfere with the changeoutput placeholder, so we add an `\` to escape that
{% endhint %}

### Adding each possibility

Now you have to add each armor piece that the enemy could be wearing and how much increased damage you want to have for those pieces. Also be sure to change anything else such as the slot of the inventory that your checking

```
rampage:
  display: "%group-color%Rampage"
  description: "Deal more damage the higher the grade of enemy armor"
  applies-to: "Weapons"
  type: "ATTACK"
  group: "LEGENDARY"
  applies:
    - ALL_SWORD
    - ALL_AXE
  levels:
    1:
      effects:
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:39_mat:}_LEATHER\_HELMET_10_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:38_mat:}_LEATHER\_CHESTPLATE_30_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:37_mat:}_LEATHER\_LEGGINGS_20_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:36_mat:}_LEATHER\_BOOTS_10_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:39_mat:}_IRON\_HELMET_20_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:38_mat:}_IRON\_CHESTPLATE_50_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:37_mat:}_IRON\_LEGGINGS_30_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:36_mat:}_IRON\_BOOTS_20_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:39_mat:}_DIAMOND\_HELMET_30_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:38_mat:}_DIAMOND\_CHESTPLATE_70_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:37_mat:}_DIAMOND\_LEGGINGS_50_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:36_mat:}_DIAMOND\_BOOTS_30_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:39_mat:}_NETHERITE\_HELMET_40_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:38_mat:}_NETHERITE\_CHESTPLATE_100_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:37_mat:}_NETHERITE\_LEGGINGS_80_0% @Attacker"
        - "INCREASE_DAMAGE:%changeoutput_equals_{victim checkitem_getinfo:36_mat:}_NETHERITE\_BOOTS_40_0% @Attacker"
```

And thats it! Of course, theres a lot more you can do such as adding more checks and other things, but thats the basic structure.

### Other Examples

Here are some other examples made by us:

```
teleport:
  display: '%group-color%Teleport'
  description: 'Teleport 8 blocks into the direction you''re facing'
  applies-to: 'Swords'
  group: 'ULTRA'
  type: 'RIGHT_CLICK'
  applies:
    - ALL_SWORD
  levels:
    1:
      chance: 100
      cooldown: 0
      effects:
        - '%changeoutput_equals_{player_direction}_N_TELEPORT location=~0|0|-8_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_NE_TELEPORT location=~6|0|-6_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_E_TELEPORT location=~8|0|0_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_SE_TELEPORT location=~6|0|6_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_S_TELEPORT location=~0|0|8_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_SW_TELEPORT location=~-6|0|6_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_W_TELEPORT location=~-8|0|0_WAIT:0%'
        - '%changeoutput_equals_{player_direction}_NW_TELEPORT location=~-6|0|-6_WAIT:0%'
```

{% hint style="info" %}
Teleport can be further advanced by checking the players Yaw and Pitch, and teleporting the player upwards
{% endhint %}

Have your own enchantment you want to be showcased here? Let us know on our discord and we'll take a look at it.\
If your interested in having someone make custom enchants for you, contact DuneSciFye on the discord support server


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ae.advancedplugins.net/enchantments/creating-enchantments/effect-info-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
