249 lines
6.4 KiB
Markdown
249 lines
6.4 KiB
Markdown
---
|
||
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")
|
||
```
|
||
|
||
|
||
|