Files
netease-modsdk-wiki/docs/mconline/10-addon教程/第15章:制作更好的装备/课程05.简易教程② 增加武器吸血属性.md
boybook 760c2dd9ad 2.6
2025-12-01 20:59:16 +08:00

31 lines
695 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
front: https://mc.res.netease.com/pc/zt/20201109161633/mc-dev/assets/img/5_2.4fbaff36.jpg
hard: 进阶
time: 20分钟
---
# 简易教程② 增加武器吸血属性
#### 作者:境界
吸血剑示例包下载:下载[示例包](https://g79.gdl.netease.com/guidedemo-case15.zip)。
#### 代码逻辑
![](./images/5_1.jpg)
①监听ServerChatEvent和PlayerAttackEntityEvent通过输入聊天信息“吸血剑”获得带有吸血词缀的钻石剑。
②在玩家攻击实体的事件回调函数内获取手持物品并匹配词缀信息然后通过attr组件来获得玩家生命值并设置新的生命值。
#### 效果图如下:
![](./images/5_2.jpg)