Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] -- ⚔️ COMBAT AND SPELL METHODS

[DiscordArchive] -- ⚔️ COMBAT AND SPELL METHODS

[DiscordArchive] -- ⚔️ COMBAT AND SPELL METHODS

rektbyfaith
Administrator
0
07-28-2025, 06:02 PM
#1
Archived author: Xepic90 • Posted: 2025-07-28T18:02:38.956000+00:00
Original source

-- ⚔️ COMBAT AND SPELL METHODS
local function player_combat_examples(player)
-- Check player states
local in_combat = player:IsInCombat()
local is_alive = player:IsAlive()
local is_dead = player:IsDead()
local full_health = player:IsFullHealth()

-- Health management
player:SetHealth(5000) -- Set specific health value
player:SetMaxHealth(8000) -- Change maximum health
local health_percent = player:GetHealthPct() -- Get health percentage

-- Power management (mana, rage, energy, etc.)
local power_type = player:GetPowerType() -- 0=mana, 1=rage, 2=focus, 3=energy
player:SetPower(0, 5000) -- Set mana to 5000 (type 0)
player:ModifyPower(0, 1000) -- Add 1000 mana

-- Spell methods
local knows_spell = player:HasSpell(133) -- Check if knows Fireball (spell ID 133)
local on_cooldown = player:HasSpellCooldown(133) -- Check if spell is on cooldown
local cooldown_remaining = player:GetSpellCooldownDelay(133) -- Get remaining cooldown

-- Casting spells
player:CastSpell(player, 1126) -- Cast Mark of the Wild on self
-- player:CastSpell(target, 133) -- Cast Fireball on target

-- Cooldown management
player:ResetSpellCooldown(133) -- Reset specific spell cooldown
player:ResetAllCooldowns() -- Reset all cooldowns

-- Learn/forget spells
player:LearnSpell(133) -- Learn Fireball
player:RemoveSpell(133) -- Forget Fireball

return {
in_combat = in_combat,
health_percent = health_percent,
power_type = power_type,
knows_fireball = knows_spell
}
end

<@1350032736546721854> Does it work for you?
rektbyfaith
07-28-2025, 06:02 PM #1

Archived author: Xepic90 • Posted: 2025-07-28T18:02:38.956000+00:00
Original source

-- ⚔️ COMBAT AND SPELL METHODS
local function player_combat_examples(player)
-- Check player states
local in_combat = player:IsInCombat()
local is_alive = player:IsAlive()
local is_dead = player:IsDead()
local full_health = player:IsFullHealth()

-- Health management
player:SetHealth(5000) -- Set specific health value
player:SetMaxHealth(8000) -- Change maximum health
local health_percent = player:GetHealthPct() -- Get health percentage

-- Power management (mana, rage, energy, etc.)
local power_type = player:GetPowerType() -- 0=mana, 1=rage, 2=focus, 3=energy
player:SetPower(0, 5000) -- Set mana to 5000 (type 0)
player:ModifyPower(0, 1000) -- Add 1000 mana

-- Spell methods
local knows_spell = player:HasSpell(133) -- Check if knows Fireball (spell ID 133)
local on_cooldown = player:HasSpellCooldown(133) -- Check if spell is on cooldown
local cooldown_remaining = player:GetSpellCooldownDelay(133) -- Get remaining cooldown

-- Casting spells
player:CastSpell(player, 1126) -- Cast Mark of the Wild on self
-- player:CastSpell(target, 133) -- Cast Fireball on target

-- Cooldown management
player:ResetSpellCooldown(133) -- Reset specific spell cooldown
player:ResetAllCooldowns() -- Reset all cooldowns

-- Learn/forget spells
player:LearnSpell(133) -- Learn Fireball
player:RemoveSpell(133) -- Forget Fireball

return {
in_combat = in_combat,
health_percent = health_percent,
power_type = power_type,
knows_fireball = knows_spell
}
end

<@1350032736546721854> Does it work for you?

rektbyfaith
Administrator
0
07-28-2025, 06:08 PM
#2
Archived author: fred • Posted: 2025-07-28T18:08:57.765000+00:00
Original source

i can't try it right now, but maybe later today or tomorrow
rektbyfaith
07-28-2025, 06:08 PM #2

Archived author: fred • Posted: 2025-07-28T18:08:57.765000+00:00
Original source

i can't try it right now, but maybe later today or tomorrow

rektbyfaith
Administrator
0
07-29-2025, 08:26 AM
#3
Archived author: fred • Posted: 2025-07-29T08:26:29.122000+00:00
Original source

got this error despite being the character being a druid
`lua_scripts/test.lua:51: bad argument #1 to 'SetPower' (valid Powers expected)`
its because you've got the parameters mixed up `player:SetPower(0, 5000)`
should be `player:SetPower(5000,0)`
rektbyfaith
07-29-2025, 08:26 AM #3

Archived author: fred • Posted: 2025-07-29T08:26:29.122000+00:00
Original source

got this error despite being the character being a druid
`lua_scripts/test.lua:51: bad argument #1 to 'SetPower' (valid Powers expected)`
its because you've got the parameters mixed up `player:SetPower(0, 5000)`
should be `player:SetPower(5000,0)`

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)