[DiscordArchive] -- ⚔️ COMBAT AND SPELL METHODS
[DiscordArchive] -- ⚔️ COMBAT AND SPELL METHODS
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?
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
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)`