• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Spell that heals mana but uses caster health to cast TFS 1.3

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hello guys,

I would like a spell that heals the caster mana for 5% of max mana, but to cast it, the caster loses 10% of max life. The spell also applies "utura gran" to the caster for 10 seconds.

I will be glad if someone can do that for me, thanks
 
Solution
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_TICKS, 10000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 40)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
combat:addCondition(condition)

function onCastSpell(creature, variant)
    local maxHealth = creature:getMaxHealth()
    local currentHealth = creature:getHealth()
    local healthCost = math.floor((maxHealth / 100) * 10)
    if currentHealth <= healthCost then
        return false
    end
    creature:addHealth(-healthCost)...
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_TICKS, 10000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 40)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
combat:addCondition(condition)

function onCastSpell(creature, variant)
    local maxHealth = creature:getMaxHealth()
    local currentHealth = creature:getHealth()
    local healthCost = math.floor((maxHealth / 100) * 10)
    if currentHealth <= healthCost then
        return false
    end
    creature:addHealth(-healthCost)
    local maxMana = creature:getMaxMana()
    local currentMana = creature:getMana()
    local manaChange = math.floor(((maxMana / 100) * 5) + 0.5)
    manaChange = currentMana + manaChange <= maxMana and currentMana + manaChange or manaChange
    player:addMana(manaChange)
    return combat:execute(creature, variant)
end
 
Solution
local combat = Combat() combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN) combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false) local condition = Condition(CONDITION_REGENERATION) condition:setParameter(CONDITION_PARAM_TICKS, 10000) condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 40) condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000) condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true) combat:addCondition(condition) function onCastSpell(creature, variant) local maxHealth = creature:getMaxHealth() local currentHealth = creature:getHealth() local healthCost = math.floor((maxHealth / 100) * 10) if currentHealth <= healthCost then return false end creature:addHealth(-healthCost) local maxMana = creature:getMaxMana() local currentMana = creature:getMana() local manaChange = math.floor(((maxMana / 100) * 5) + 0.5) manaChange = currentMana + manaChange <= maxMana and currentMana + manaChange or manaChange player:addMana(manaChange) return combat:execute(creature, variant) end
I got this error on TFS
Lua Script Error: [Spell Interface]
data/spells/scripts/healing/manaheal.lua:eek:nCastSpell
data/spells/scripts/healing/manaheal.lua:24: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/spells/scripts/healing/manaheal.lua:24: in function <data/spells/scripts/healing/manaheal.lua:12>
The solution would be change this
Lua:
player:addMana(manaChange)

for this?
Code:
creature:addMana(manaChange)
Post automatically merged:

I got this error on TFS

The solution would be change this
Lua:
player:addMana(manaChange)

for this?
Code:
creature:addMana(manaChange)
Yeah, it works perfectly, thanks @Xikini
 
I got this error on TFS

The solution would be change this
Lua:
player:addMana(manaChange)

for this?
Code:
creature:addMana(manaChange)
Post automatically merged:


Yeah, it works perfectly, thanks @Xikini
oops yeah. forgot to change that one. xD
 
Back
Top