• 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!

[TFS 1.2] Spell to temporarily increase max health

Kenpoaj

New Member
Joined
Nov 24, 2016
Messages
3
Reaction score
0
TFS 1.2, Windows 10.

I cant seem to figure out how to create a spell that when cast:

-Increases the caster's max hitpoints for X seconds, then return to previous max HP value, current hp remains unchanged if possible.
-Shows the buff Icon

Everything I've tinkered with so far increases the max value but doesn't return it to normal after.
 
Solution
Thanks so much for the fast reply! Works fantastic and gives me something to pick apart tonight!

For future people reading this:
Don't forget to set the cooldown length, or Fun things will happen!
Code:
local time = 20 * 1000 -- 20 seconds
local gainedHealth = 3000 -- how much health the player will get

local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, gainedHealth)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
condition:setParameter(CONDITION_PARAM_TICKS, time)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
combat:setCondition(condition)

function onCastSpell(creature...
Code:
local savedTime = {}
local exhaust = 20 -- 20 seconds
local gainedHealth = 3000 -- how much health the player will get

local function rollBackHealth(cid, health)
    local player = Player(cid)
    if not player then
        return
    end
    player:setMaxHealth(health)
end

function onCastSpell(creature, variant)
    local guid = creature:getGuid()
    local tmp = savedTime[guid]
    local maxHealth = creature:getMaxHealth()
    if tmp and (os.time() >= (tmp + exhaust)) or true then
        creature:setMaxHealth(maxHealth + gainedHealth)
        addEvent(rollBackHealth, exhaust * 1000, creature:getId(), maxHealth)
    end
    savedTime[guid] = os.time()
    return true
end
 
Thanks so much for the fast reply! Works fantastic and gives me something to pick apart tonight!

For future people reading this:
Don't forget to set the cooldown length, or Fun things will happen!
 
Thanks so much for the fast reply! Works fantastic and gives me something to pick apart tonight!

For future people reading this:
Don't forget to set the cooldown length, or Fun things will happen!
Code:
local time = 20 * 1000 -- 20 seconds
local gainedHealth = 3000 -- how much health the player will get

local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, gainedHealth)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
condition:setParameter(CONDITION_PARAM_TICKS, time)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
combat:setCondition(condition)

function onCastSpell(creature, variant)
    combat:execute(creature, variant)
    return true
end
this is better for what you're asking for
i completely forgot about conditions for a second and made that script above lol
set the exhaustion as the same as local time in your xml
 
Solution
Back
Top