Skip to content

状态模块管理接口 Buff

具体函数名及描述如下:

序号函数名函数描述
1AddBuff(...)给对象附加效果
2RemoveBuff(...)给对象移除指定效果
3ClearAllBuff(...)给对象清除所有效果
4ClearAllBadBuff(...)为对象清除所有负面效果
5ClearAllGoodBuff(...)为对象清除所有有益效果
6HasBuff(...)判断对象身上是否有指定效果
7GetBuffLeftTime(...)获取对象身上指定效果剩余时间
8GetBuffDefName(...)获取状态效果名称
9GetBuffDefDesc(...)获取状态效果描述
10ReplaceBuff(...)替换已有状态

AddBuff

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
    • bufflv:number效果等级
    • customticks:number效果持续时间(-1表示默认配置,0表示无限)
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 给对象附加效果
  • 具体使用案例如下:
lua
    Buff:AddBuff(playerId,4001, 20)

RemoveBuff

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

ClearAllBuff

  • 参数及类型:
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 给对象清除所有效果
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ClearAllBuff(playerId)

ClearAllBadBuff

  • 参数及类型:
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 为对象清除所有负面效果
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ClearAllBadBuff(playerId)

ClearAllGoodBuff

  • 参数及类型:
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 为对象清除所有有益效果
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ClearAllGoodBuff(playerId)

HasBuff

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
    • bufflv:number效果等级
  • 返回值及类型:
    • ret:bool成功(true)
  • 该方法的主要作用: 判断对象身上是否有指定效果
  • 具体使用案例如下:
lua
    local isHasBuff = Buff:HasBuff(playerId, 4001)

GetBuffLeftTime

  • 参数及类型:
    • objid:number对象ID
    • buffid:number,string效果ID
  • 返回值及类型:
    • ret: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
  • 返回值及类型:
  • 该方法的主要作用: 获取状态效果描述
  • 具体使用案例如下:
lua
    local desc = Buff:GetBuffDefDesc(4001)

ReplaceBuff

  • 参数及类型:
    • objid:number对象ID
    • buffsrc:number,string源状态 ID
    • buffsrclv:number源状态等级
    • buffdst:number,string目标状态
    • buffdstlv:number目标状态等级
    • customticks:number持续时间
  • 返回值及类型:
    • ret:boolean替换成功(true)或失败(false)
  • 该方法的主要作用: 替换已有状态
  • 具体使用案例如下:
lua
    local isSuccess = Buff:ReplaceBuff(playerId, 4001, "r5_7483041204932402166_23045", 10)