# 末影弓

首先我们先尝试在 EcoItems 中还原 MMOItems 的属性。

MMOItems 是一款优秀的 RPG 属性插件，我们尝试在 EcoItems 插件还原其中的一些属性吧。

## 任务 1

按照 [**这个页面**](https://gitlab.com/phoenix-dvpmt/mmoitems/-/wikis/Item-Stats-and-Options) 尽可能的还原 **MMOItems** 插件中的物品属性。

## 分析任务 1

### 暴击率 & 暴击伤害值

一方面，我们可以简单的使用 `crit_multiplier` 技能实现暴击伤害加倍。

另外一方面，我们可以使用 `damage_multiplier` 配合 `chance` 参数实现伪暴击率和暴击伤害。

### 闪避率 & 闪避减少伤害值

我们配合 `take_damage` 触发器、`damage_multiplier` 技能（加倍值改为0）和 `chance` 参数实现。

### 所需职业 & 等级

使用 `placeholder_contains、placeholder_greater_than` 等条件。

### 宝石

配合重铸系统使用，可惜的是每个物品只能一个重铸词条。

### 血量增加 & 恢复速度加快

分别为 `bonus_health` 和 `regen_multiplier` 技能。

不再一一列举，这么写的意义在与告诉您：绝大多数的 MMOItems 的属性都可以在 EcoItems 巧妙的通过各种技能、参数、条件配合实现。

不聊这些了，我们的 **EcoX** 实战之旅从一把弓开始。

## 任务 2

按照下面物品配置的 Lore 的描述制作一把末影弓。

```
- id: ender_bow
  baseAttackSpeed: 1
  baseDamage: 1
  item:
    item: bow unbreakable hide_attributes
    lore:
    - '&7伤害: &c12❤'
    - ''
    - '&6&l技能: 末影之箭 &e(左键)'
    - '&7进入末影之箭状态后你接下来发射的一支箭将会'
    - '&7有范围伤害效果，伤害固定为 &c10 &7点.'
    - '&8冷却时间: &b15秒'
    - ''
    - '&9&l超稀有'
    displayName: '&9末影弓'
    recipe: []
    craftable: false
  fuels: []
  effects: 请自行编写。
  conditions: []
```

### 任务提示

使用 `shoot_arrow 和 damage_nearby_entities` 技能实现“末影之箭”。

## 逐步分析任务 2

很显然我们通过 **EcoItems** 插件实现该物品。

### 伤害: 12❤

在 物品 一节，我们已经知道每个物品都有 `baseDamage` 选项修改它的攻击伤害，但它只作用于近战伤害，对于远程伤害，我们需要使用 `damage_multiplier` 技能来实现修改。

回顾 `damage_multiplie`r 的介绍内容：

```
damage_multiplier（触发技能）
该技能作用是加倍玩家的原版伤害属性。
- id: damage_multiplier
  args:
    multiplier: 0.5
其中：
args.multiplier：加倍值。
```

我们得知该技能是一个触发技能，它需要一个触发器才能触发，所以在实际使用中，我们还需要为它添加一个触发器。

{% hint style="info" %}
请再回顾 **触发器列表** 一节所介绍内容，想一想，我们应该选用什么触发器？
{% endhint %}

由于是修改弓造成的伤害，我们很轻松的就可以在触发器列表中选择 `bow_attack` 触发器。弓的默认伤害是 **6** 点伤害。于是，我们编写了 `effects` 选项下的第一个技能如下：

```
  - id: damage_multiplier
    args:
      multiplier: 2.0
    triggers:
    - bow_attack
```

### 技能: 末影之箭

#### 左键

技能后的左键已经非常明显的提示你“末影之箭”技能的触发方式，由于是左键触发技能，我们同样很轻松的就可以在触发器列表中选择 `alt_click` 触发器。我们的 `effects` 下的第二个技能目前就长这样了：

```
  - id: 我们还不知道呢
    args:
      我们还不知道呢
    triggers:
      - alt_click
```

#### shoot\_arrow 和 damage\_nearby\_entities 技能

我们已经提示了“末影之箭”的实现是基于这两个技能，我们再回顾技能列表即可发现它们的实际作用。

首先我们需要射箭，这就是 `shoot_arrow` 的作用，其次这个箭在击中或者落地后造成范围伤害，这就是 `damage_nearby_entities` 的作用。

等等，这是两个技能，可这里我只预留了一个技能id和参数供填写，怎么办？

#### run\_chain\_inline 技能

我们再次回顾技能列表，是不是想起来你曾经看到过一个可以一次作用多个技能的技能，没错，就是它！

我们将该技能的 id 填写为 `run_chain_inline`，并按照当时的介绍填写技能参数：就是新的子技能，配合上面我们将要使用两个技能，效果就像这样：

```
  - id: run_chain_inline
    args:
      chain:
        effects:
          - id: shoot_arrow
            args:
              我们还不知道呢
          - id: damage_nearby_entities
            args:
              我们还不知道呢
          - id: send_message
            args:
              message: "&e你发动了技能: &6&l末影之箭!"
            action_bar: false
          - id: send_message
            args:
              message: "&e你接下来使用末影之弓发射的一支箭将有范围伤害效果!"
              action_bar: false
      cooldown: 15
    triggers:
      - alt_click
```

#### 冷却时间

你在跟着我写的同时对照上面所给示例时是不是发现少写了什么？没错，就是冷却时间！在 **通用技能参数** 一节我们已经介绍了技能冷却时间，别忘记它哦！

#### 技能参数填写

我们需要知道，这是一个特殊的技能，我们不能将这些技能对应发射的箭（shoot\_arrow）、造成的伤害（damage\_nearby\_entities）归源于由玩家造成的，否则这会造成在技能发送同时，发射的箭、造成的伤害由同时再次触发了 `bow_attack` 和 `melee_attack` 触发器，有时会造成无限循环。

因此这些技能参数，配合 Lore 的实际填写如下：

```
  - id: run_chain_inline
    args:
      chain:
        effects:
          - id: shoot_arrow
            args:
              inherit_velocity: true 
              no_source: false
          - id: damage_nearby_entities
            args:
              damage: 11
              radius: 8 
              damage_as_player: false
              damage_self: false
          - id: send_message
            args:
              message: "&e你发动了技能: &6&l末影之箭!"
            action_bar: false
          - id: send_message
            args:
              message: "&e你接下来使用末影之弓发射的一支箭将有范围伤害效果!"
              action_bar: false
      cooldown: 15
    triggers:
      - alt_click 
```

#### BUG 发现

我们再次回顾目前所填写的技能，实际测试下来将会发现一个 BUG：造成范围伤害是在玩家周围产生的，而不是箭的周围。

我们回顾技能列表可以得知，我们所使用的两个技能都是触发技能，也就说它们需要触发器。那为什么这里却没有写呢？原因在于它们是子技能，子技能触发的前提是母技能（run\_chain\_inline）被触发，它们默认情况下已经有一个触发器了。

母技能触发器 `alt_click` 的对象其实还是玩家本身，因而 `damage_nearby_entities` 在对象（玩家）周围产生也是默认情况下的结果，但这不是我们想要的结果。

这时，我们需要对 `damage_nearby_entities` 技能的触发器再单独设置，我们理想结果是该技能在箭射击到方块或者实体上时触发，目标自然就变成了被箭击中的方块或者实体周围。我们很轻松可以发现 `projectile_hit` 是我们想要的触发器，综合下来，该物品的 `effects` 最终像这个样子：

```
  - id: run_chain_inline
    args:
      chain:
        effects:
          - id: shoot_arrow
            args:
              inherit_velocity: true 
              no_source: false
          - id: damage_nearby_entities
            args:
              damage: 11
              radius: 8 
              damage_as_player: false
              damage_self: false
            triggers:
              - projectile_hit
          - id: send_message
            args:
              message: "&e你发动了技能: &6&l末影之箭!"
            action_bar: false
          - id: send_message
            args:
              message: "&e你接下来使用末影之弓发射的一支箭将有范围伤害效果!"
              action_bar: false
      cooldown: 15
    triggers:
      - alt_click
```

## 参考答案

### EcoItems

```
- id: ender_bow
  baseAttackSpeed: 1
  baseDamage: 1
  item:
    item: bow unbreakable hide_attributes
    lore:
    - '&7伤害: &c12❤'
    - ''
    - '&6&l技能: 末影之箭 &e(左键)'
    - '&7进入末影之箭状态后你接下来发射的一支箭将会'
    - '&7有范围伤害效果（8格），伤害固定为 &c10 &7点.'
    - '&8消耗法力: &b15'
    - '&8冷却时间: &b15秒'
    - ''
    - '&9&l超稀有'
    displayName: '&9末影弓'
    recipe: []
    craftable: false
  fuels: []
  effects:
  - id: damage_multiplier
    args:
      multiplier: 2.0
    triggers:
    - bow_attack
  - id: run_chain_inline
    args:
      chain:
        effects:
          - id: shoot_arrow
            args:
              inherit_velocity: true 
              no_source: false
          - id: damage_nearby_entities
            args:
              damage: 10
              radius: 8 
              damage_as_player: false
              damage_self: false
            triggers:
              - projectile_hit
          - id: send_message
            args:
              message: "&e你发动了技能: &6&l末影之箭!"
            action_bar: false
          - id: send_message
            args:
              message: "&e你接下来使用末影之弓发射的一支箭将有范围伤害效果!"
              action_bar: false
      cooldown: 15
    triggers:
      - alt_click
  conditions: []
```


---

# 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://docs.superiormc.cn/ecox-doc/shi-zhan-xun-lian/mo-ying-gong.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.
