Skip to content

Effect Functions

GetMaxEffect(aIndex)

Returns the maximum number of effect slots an object can have.

local max = GetMaxEffect(player.Index)

AddEffect(lpObj, type, index, count, v1, v2, v3, v4, v5, v6, buffSendValue, attackerIndex, rmv)

Adds a buff/debuff effect to an object.

  • Parameters:
  • lpObj (GameObject) — target object
  • type (number) — effect type (0 or 1)
  • index (number) — effect ID
  • count (number) — duration in seconds or charge count
  • v1..v6 (number) — effect values (damage, defense, etc.)
  • buffSendValue (number) — client buff icon value
  • attackerIndex (number) — index of the effect source
  • rmv (number) — success chance (0-100), or -1 for always
  • Returns: number — 1 on success, 0 on failure
-- Add +50 physical damage buff for 60 seconds, guaranteed
AddEffect(player, 1, 15, 60, 50, 0, 0, 0, 0, 0, 0, player.Index, -1)

DelEffect(lpObj, index)

Removes a specific effect by its ID.

  • Returns: boolean
if DelEffect(player, 1) then
    GCNoticeSend(player.Index, 1, "Poison cured!")
end

DelEffectByGroup(lpObj, group)

Removes all effects belonging to a group.

  • Returns: boolean
DelEffectByGroup(player, 20) -- Remove all scroll buffs

GetEffect(lpObj, index)

Returns the GameCEffect object for the given effect ID, or nil if not found.

local eff = GetEffect(player, 1)
if eff then
    LogAdd(LOG_RED, "Poison remaining: " .. eff.m_time .. "s")
end

GetEffectByGroup(lpObj, group)

Returns the first GameCEffect in the given group, or nil.

local scroll = GetEffectByGroup(player, 20)
if scroll then
    LogAdd(LOG_BLUE, "Scroll value: " .. scroll.m_value[1])
end

CheckEffect(lpObj, index)

Returns true if the object has the effect active.

if CheckEffect(target, 16) then -- Mana Shield
    LogAdd(LOG_BLUE, "Target has Mana Shield active.")
end

CheckEffectByGroup(lpObj, group)

Returns true if the object has any effect from the given group.

if CheckEffectByGroup(player, 35) then
    GCNoticeSend(player.Index, 1, "You already have an event buff.")
end

CheckStunEffect(lpObj)

Returns true if the object is stunned.

if CheckStunEffect(target) then
    LogAdd(LOG_BLUE, "Target is stunned!")
end

CheckImmobilizeEffect(lpObj)

Returns true if the object is immobilized.

if CheckImmobilizeEffect(player) then
    GCNoticeSend(player.Index, 1, "You are frozen and cannot move!")
end

CheckDebuffSend(index)

Returns true if the given effect index is classified as a debuff for client display.

local isDebuff = CheckDebuffSend(5)

ClearAllEffect(lpObj)

Removes all effects from the object.

ClearAllEffect(player)
GCNoticeSend(player.Index, 1, "All effects cleared.")

ClearDebuffEffect(lpObj, count)

Removes up to count debuff effects from the object.

ClearDebuffEffect(player, 3)
GCNoticeSend(player.Index, 1, "Removed 3 debuffs.")

UpgradeDamageByClass(lpObj)

Calculates and returns bonus damage based on the character's class and stats.

  • Returns: number
local bonus = UpgradeDamageByClass(player)
LogAdd(LOG_BLUE, "Class damage bonus: " .. bonus)