Files
netease-modsdk-wiki/docs/mcdocs/1-ModAPI/接口/实体/状态效果.md
2025-03-18 14:46:12 +08:00

249 lines
6.4 KiB
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.

---
sidebarDepth: 1
---
# 状态效果
## AddEffectToEntity
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.effectCompServer.EffectComponentServer
- 描述
为实体添加指定状态效果如果添加的状态已存在则有以下集中情况1、等级大于已存在则更新状态等级及持续时间2、状态等级相等且剩余时间duration大于已存在则刷新剩余时间3、等级小于已存在则不做修改4、粒子效果以新的为准
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| effectName | str | 状态效果名称字符串包括自定义状态效果和原版状态效果原版状态效果可在wiki查询 |
| duration | int | 状态效果持续时间,单位秒 |
| amplifier | int | 状态效果的额外等级。必须在0至255之间。若未指定默认为0。注意状态效果的第一级如生命恢复 I对应为0因此第二级状态效果如生命回复 II应指定强度为1。部分效果及自定义状态效果没有强度之分如夜视 |
| showParticles | bool | 是否显示粒子效果True显示False不显示 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | True表示设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateEffect(entityId)
res = comp.AddEffectToEntity("speed", 30, 2, True)
```
## GetAllEffects
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
### 服务端接口
<span id="s0"></span>
method in mod.server.component.effectCompServer.EffectComponentServer
- 描述
获取实体当前所有状态效果
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(dict)或None | 状态效果信息字典的list。无状态效果时返回None |
- 备注
- 状态效果信息字典 effectDict
| 关键字 | 数据类型 | 说明 |
| ----------| --------------------- | ---------|
| effectName | str | 状态效果名称 |
| duration | int | 状态效果剩余持续时间,单位秒 |
| duration_f | float | 状态效果剩余持续时间(浮点型),单位秒 |
| amplifier | int | 状态效果额外等级 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateEffect(entityId)
effectDictList = comp.GetAllEffects()
```
### 客户端接口
<span id="c0"></span>
method in mod.client.component.effectCompClient.EffectComponentClient
- 描述
获取实体当前所有状态效果
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(dict)或None | 状态效果信息字典的list。无状态效果时返回None |
- 备注
- 状态效果信息字典 effectDict
| 关键字 | 数据类型 | 说明 |
| ----------| --------------------- | ---------|
| effectName | str | 状态效果名称 |
| duration | int | 状态效果剩余持续时间,单位秒 |
| duration_f | float | 状态效果剩余持续时间(浮点型),单位秒 |
| amplifier | int | 状态效果额外等级 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateEffect(entityId)
effectDictList = comp.GetAllEffects()
```
## GetLoadEffects
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.effectCompServer.EffectComponentServer
- 描述
获取所有已加载的状态效果
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(str) | 返回状态效果列表 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateEffect(entityId)
effectList = comp.GetLoadEffects()
```
## HasEffect
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
### 服务端接口
<span id="s0"></span>
method in mod.server.component.effectCompServer.EffectComponentServer
- 描述
获取实体是否存在当前状态效果
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| effectName | str | 状态效果名称字符串包括自定义状态效果和原版状态效果原版状态效果可在wiki查询 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 返回是否存在状态效果 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateEffect(entityId)
effectRes = comp.HasEffect(effectName)
```
### 客户端接口
<span id="c0"></span>
method in mod.client.component.effectCompClient.EffectComponentClient
- 描述
获取实体是否存在当前状态效果
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| effectName | str | 状态效果名称字符串包括自定义状态效果和原版状态效果原版状态效果可在wiki查询 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 返回是否存在状态效果 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateEffect(entityId)
effectRes = comp.HasEffect(effectName)
```
## RemoveEffectFromEntity
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.effectCompServer.EffectComponentServer
- 描述
为实体删除指定状态效果
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| effectName | str | 状态效果名称字符串包括自定义状态效果和原版状态效果原版状态效果可在wiki查询 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | True表示删除成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateEffect(entityId)
res = comp.RemoveEffectFromEntity("speed")
```