Skip to content

状态模块管理接口 Buff

具体函数名及描述如下:

序号函数名函数描述
1AddBuff(...)附加效果
2RemoveBuff(...)移除效果
3ClearAllBuff(...)清除所有效果
4ClearAllBadBuff(...)清除所有负面效果
5ClearAllGoodBuff(...)清除所有有益效果
6HasBuff(...)判断是否有效果
7GetBuffList(...)获取效果列表
8GetBuffNumByBuffid(...)获取效果数量
9GetBuffLeftTime(...)获取效果剩余时间
10GetBuffDefName(...)获取效果名称
11GetBuffDefDesc(...)获取效果描述
12ReplaceBuff(...)替换效果

AddBuff

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
    • customticks:number效果持续时间(-1表示默认配置,0表示无限)
  • 返回值及类型:
  • 该方法的其他说明: 给对象附加指定效果
  • 具体使用案例如下:
lua
    Buff:AddBuff(playerId,4001, 20)

RemoveBuff

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
  • 返回值及类型:
  • 该方法的其他说明: 给对象移除指定效果
  • 具体使用案例如下:
lua
    local isRemoveSuccess = Buff:RemoveBuff(playerId, "r5_7483041204932402166_23045")

ClearAllBuff

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 给对象清除所有效果
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ClearAllBuff(playerId)

ClearAllBadBuff

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 为对象清除所有负面效果
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ClearAllBadBuff(playerId)

ClearAllGoodBuff

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 为对象清除所有有益效果
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ClearAllGoodBuff(playerId)

HasBuff

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
  • 返回值及类型:
  • 该方法的其他说明: 判断对象身上是否有指定效果
  • 具体使用案例如下:
lua
    local isHasBuff = Buff:HasBuff(playerId, 4001)

GetBuffList

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 获取对象身上所有效果的列表
  • 具体使用案例如下:
lua
    local num,arr = Buff:GetBuffList(playerId)

    print("num = ",num)

    print("arr = ",arr)

GetBuffNumByBuffid

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
  • 返回值及类型:
  • 该方法的其他说明: 获取对象身上指定效果的数量
  • 具体使用案例如下:
lua
    local num = Buff:GetBuffNumByBuffid(playerId,4001)

    print("num = ",num)

GetBuffLeftTime

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
  • 返回值及类型:
    • num:number剩余时间(秒,0表示永久)
  • 该方法的其他说明: 获取对象身上指定效果的剩余时间
  • 具体使用案例如下:
lua
    local time = Buff:GetBuffLeftTime(playerId, 4001)

GetBuffDefName

  • 参数及类型:
    • buffid:number,string效果ID
  • 返回值及类型:
  • 该方法的其他说明: 获取状态效果的名称
  • 具体使用案例如下:
lua
    local name = Buff:GetBuffDefName(4001)

GetBuffDefDesc

  • 参数及类型:
    • buffid:number,string效果ID
  • 返回值及类型:
    • value:string状态效果描述
  • 该方法的其他说明: 获取状态效果的描述
  • 具体使用案例如下:
lua
    local desc = Buff:GetBuffDefDesc(4001)

ReplaceBuff

  • 参数及类型:
    • objid:number对象ID
    • buffsrc:number,string源状态ID
    • buffdst:number,string目标状态ID
    • customticks:number持续时间(默认-1)
  • 返回值及类型:
  • 该方法的其他说明: 将对象身上的源状态替换为目标状态(保持数量一致)
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ReplaceBuff(playerId, 4001, "r5_7483041204932402166_23045", 10)