• 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 0.X Spell that buff your summons hp

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
How to create a spell that when use add 2x more health for all your summons
But can only set 2x MAX HP for each monster, i mean, if u use 2x,3x,4x only set 2x hp monsters to monster that don't have been affected
 
Solution
Untested.

Lua:
-- percentage is a boolean value true/false
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount)
  
    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end
  
    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
  
    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
  
    -- adjust current health of target
    local targetCurrentHealth =...
Untested.

Lua:
-- percentage is a boolean value true/false
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount)
  
    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end
  
    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
  
    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
  
    -- adjust current health of target
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end
    return true
end
Lua:
--[[

Usage

Doubling hp | 1000 -> 2000
adjustMonsterMaxHealthOnceOnly(target, true, 2)

Half hp | 1000 -> 500
adjustMonsterMaxHealthOnceOnly(target, true, 0.5)

Adding 400 hp | 1000 -> 1400
adjustMonsterMaxHealthOnceOnly(target, false, 400)

Removing 600 hp | 1000 -> 400
adjustMonsterMaxHealthOnceOnly(target, false, -600)

]]--
Lua:
-- Example, doubling max hp of all summons of a character
function onCast(cid, target)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2)
    end
    return true
end
 
Last edited:
Solution
Untested.

Lua:
-- percentage is a boolean value true/false
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount)
 
    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end
 
    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
 
    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
 
    -- adjust current health of target
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end
    return true
end
Lua:
--[[

Usage

Doubling hp | 1000 -> 2000
adjustMonsterMaxHealthOnceOnly(target, true, 2)

Half hp | 1000 -> 500
adjustMonsterMaxHealthOnceOnly(target, true, 0.5)

Adding 400 hp | 1000 -> 1400
adjustMonsterMaxHealthOnceOnly(target, false, 400)

Removing 600 hp | 1000 -> 400
adjustMonsterMaxHealthOnceOnly(target, false, -600)

]]--
Lua:
-- Example, doubling max hp of all summons of a character
function onCast(cid, target)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2)
    end
    return true
end

What do i doing wrong?


before use the spell
Code:
23:31 You see a dragon.
Health: [1500 / 1500].
Position: [X: 1034] [Y: 1047] [Z: 6].
23:31 You see a dragon.
Health: [1500 / 1500].
Position: [X: 1036] [Y: 1045] [Z: 6].

When i use the spell
Code:
23:32 You see a dragon.
Health: [3000 / 1500].
Position: [X: 1032] [Y: 1046] [Z: 6].
23:32 You see a dragon.
Health: [3000 / 3000].
Position: [X: 1032] [Y: 1045] [Z: 6].

when the buff over
Code:
23:33 You see a dragon.
Health: [1500 / 1500].
Position: [X: 1032] [Y: 1046] [Z: 6].
23:33 You see a dragon.
Health: [3000 / 3000].
Position: [X: 1032] [Y: 1045] [Z: 6].
 
What do i doing wrong?


before use the spell
Code:
23:31 You see a dragon.
Health: [1500 / 1500].
Position: [X: 1034] [Y: 1047] [Z: 6].
23:31 You see a dragon.
Health: [1500 / 1500].
Position: [X: 1036] [Y: 1045] [Z: 6].

When i use the spell
Code:
23:32 You see a dragon.
Health: [3000 / 1500].
Position: [X: 1032] [Y: 1046] [Z: 6].
23:32 You see a dragon.
Health: [3000 / 3000].
Position: [X: 1032] [Y: 1045] [Z: 6].

when the buff over
Code:
23:33 You see a dragon.
Health: [1500 / 1500].
Position: [X: 1032] [Y: 1046] [Z: 6].
23:33 You see a dragon.
Health: [3000 / 3000].
Position: [X: 1032] [Y: 1045] [Z: 6].
any errors?

try this and find out what prints to the console.
Lua:
-- Example, doubling max hp of all summons of a character
function onCast(cid, target)
    print("Script starting..")
    local summons = getCreatureSummons(cid)
    print("You have " .. #summons " summons.")
    for i = 1, #summons do
        print("Adjusting " .. getCreatureName(summons[i]) .. "'s hp. " .. i)
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2)
    end
    print("Script ended successfully, without errors.")
    return true
end

Nvm, I see you want it to be a temporary adjustment. (aka a buff)

Try this.

Lua:
function resetMonsterMaxHealth(cid)

    -- confirm that creature still exists
    if not isMonster(cid) then
        return true
    end
 
    -- reset maxHealth
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)
 
    -- if current health is above maximum health, reduce current health
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end
Lua:
-- percentage is a boolean value true/false
-- timer in seconds
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)

    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end

    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end

    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)

    -- adjust current health of target
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end

    -- if timer, reset monster health after x seconds.
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end
Lua:
-- resets hp after 5 seconds
function onCast(cid, target)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
    end
    return true
end
 
Last edited:
any errors?

try this and find out what prints to the console.
Lua:
-- Example, doubling max hp of all summons of a character
function onCast(cid, target)
    print("Script starting..")
    local summons = getCreatureSummons(cid)
    print("You have " .. #summons " summons.")
    for i = 1, #summons do
        print("Adjusting " .. getCreatureName(summons[i]) .. "'s hp. " .. i)
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2)
    end
    print("Script ended successfully, without errors.")
    return true
end

Nvm, I see you want it to be a temporary adjustment. (aka a buff)

Try this.

Lua:
function resetMonsterMaxHealth(cid)

    -- confirm that creature still exists
    if not isMonster(cid) then
        return true
    end

    -- reset maxHealth
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)

    -- if current health is above maximum health, reduce current health
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end
Lua:
-- percentage is a boolean value true/false
-- timer in seconds
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)

    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end

    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end

    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)

    -- adjust current health of target
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end

    -- if timer, reset monster health after x seconds.
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end
Lua:
-- resets hp after 5 seconds
function onCast(cid, target)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
    end
    return true
end

This is it?
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SUBID, 69)
setConditionParam(condition, CONDITION_PARAM_STAT_MAXHEALTHPERCENT, -50)
setConditionParam(condition, CONDITION_PARAM_STAT_MAXMANAPERCENT, -50)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

function resetMonsterMaxHealth(cid)

    -- confirm that creature still exists
    if not isMonster(cid) then
        return true
    end
 
    -- reset maxHealth
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)
 
    -- if current health is above maximum health, reduce current health
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end

-- percentage is a boolean value true/false
--[[

Usage

Doubling hp | 1000 -> 2000
adjustMonsterMaxHealthOnceOnly(target, true, 2)

Half hp | 1000 -> 500
adjustMonsterMaxHealthOnceOnly(target, true, 0.5)

Adding 400 hp | 1000 -> 1400
adjustMonsterMaxHealthOnceOnly(target, false, 400)

Removing 600 hp | 1000 -> 400
adjustMonsterMaxHealthOnceOnly(target, false, -600)

]]--
-- percentage is a boolean value true/false
-- timer in seconds
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)

    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end

    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end

    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)

    -- adjust current health of target
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end

    -- if timer, reset monster health after x seconds.
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end











local function checking(cid)
    if isPlayer(cid) then
        if not getCreatureCondition(cid, CONDITION_ATTRIBUTES, 69) then
            -- back to normal
            local summons = getCreatureSummons(cid)
            for i = 1, #summons do
                local target = summons[i]
                -- rateMonsterHealth 1.5
                local maxMonsterHP = getMonsterInfo(getCreatureName(target)).healthMax + (getMonsterInfo(getCreatureName(target)).healthMax / 2)
                setCreatureMaxHealth(target, maxMonsterHP )
                -- adjust current health of target
                local targetCurrentHealth = getCreatureHealth(target)
                if targetCurrentHealth > adjustedAmount then
                    doCreatureAddHealth(target, -(targetCurrentHealth - adjustedAmount))
                else
                    doCreatureAddHealth(target, adjustedAmount)
                end
            end
            setPlayerStorageValue(cid, 669, -1)
            return false
        end
        addEvent(checking, 2000, cid)
    end
end

-- Example, doubling max hp of all summons of a character
-- resets hp after 5 seconds
function onCastSpell(cid, var)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
        doSendMagicEffect(getThingPos(summons[i]), CONST_ME_MAGIC_RED)
    end
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
    return true
end

Its not setting the summons health :S
 
This is it?
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SUBID, 69)
setConditionParam(condition, CONDITION_PARAM_STAT_MAXHEALTHPERCENT, -50)
setConditionParam(condition, CONDITION_PARAM_STAT_MAXMANAPERCENT, -50)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

function resetMonsterMaxHealth(cid)

    -- confirm that creature still exists
    if not isMonster(cid) then
        return true
    end

    -- reset maxHealth
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)

    -- if current health is above maximum health, reduce current health
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end

-- percentage is a boolean value true/false
--[[

Usage

Doubling hp | 1000 -> 2000
adjustMonsterMaxHealthOnceOnly(target, true, 2)

Half hp | 1000 -> 500
adjustMonsterMaxHealthOnceOnly(target, true, 0.5)

Adding 400 hp | 1000 -> 1400
adjustMonsterMaxHealthOnceOnly(target, false, 400)

Removing 600 hp | 1000 -> 400
adjustMonsterMaxHealthOnceOnly(target, false, -600)

]]--
-- percentage is a boolean value true/false
-- timer in seconds
function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)

    -- confirm that it's a monster
    if not isMonster(target) then
        return false
    end

    -- confirm that the monsters health has not been adjusted previously.
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end

    -- calculate and adjust health
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)

    -- adjust current health of target
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end

    -- if timer, reset monster health after x seconds.
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end











local function checking(cid)
    if isPlayer(cid) then
        if not getCreatureCondition(cid, CONDITION_ATTRIBUTES, 69) then
            -- back to normal
            local summons = getCreatureSummons(cid)
            for i = 1, #summons do
                local target = summons[i]
                -- rateMonsterHealth 1.5
                local maxMonsterHP = getMonsterInfo(getCreatureName(target)).healthMax + (getMonsterInfo(getCreatureName(target)).healthMax / 2)
                setCreatureMaxHealth(target, maxMonsterHP )
                -- adjust current health of target
                local targetCurrentHealth = getCreatureHealth(target)
                if targetCurrentHealth > adjustedAmount then
                    doCreatureAddHealth(target, -(targetCurrentHealth - adjustedAmount))
                else
                    doCreatureAddHealth(target, adjustedAmount)
                end
            end
            setPlayerStorageValue(cid, 669, -1)
            return false
        end
        addEvent(checking, 2000, cid)
    end
end

-- Example, doubling max hp of all summons of a character
-- resets hp after 5 seconds
function onCastSpell(cid, var)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
        doSendMagicEffect(getThingPos(summons[i]), CONST_ME_MAGIC_RED)
    end
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
    return true
end

Its not setting the summons health :S
What? no

Literally just copy paste what I put above.
And then run as-is.

Lua:
local function resetMonsterMaxHealth(cid)
    if not isMonster(cid) then
        return true
    end
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end

local function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)
    if not isMonster(target) then
        return false
    end
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end

function onCast(cid, target)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
    end
    return true
end
 
What? no

Literally just copy paste what I put above.
And then run as-is.

Lua:
local function resetMonsterMaxHealth(cid)
    if not isMonster(cid) then
        return true
    end
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end

local function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)
    if not isMonster(target) then
        return false
    end
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end

function onCast(cid, target)
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
    end
    return true
end

Tried the copy paste then:
Code:
local function resetMonsterMaxHealth(cid)
    if not isMonster(cid) then
        return true
    end
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end

local function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)
    if not isMonster(target) then
        return false
    end
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end

function onCastSpell(cid, var)
    print("Script starting..")
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        print("Adjusting " .. getCreatureName(summons[i]) .. "'s hp. " .. i)
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
    end
    print("Script ended successfully, without errors.")
    return true
end

The dragons still with the same health...
 
Tried the copy paste then:
Code:
local function resetMonsterMaxHealth(cid)
    if not isMonster(cid) then
        return true
    end
    local maxHealth = getMonsterInfo(getCreatureName(cid)).healthMax
    setCreatureMaxHealth(cid, maxHealth)
    local targetCurrentHealth = getCreatureHealth(cid)
    if targetCurrentHealth > maxHealth then
        doCreatureAddHealth(cid, -(targetCurrentHealth - maxHealth))
    end
    return true
end

local function adjustMonsterMaxHealthOnceOnly(target, percentage, amount, timer)
    if not isMonster(target) then
        return false
    end
    local targetMaxHealth = getCreatureMaxHealth(target)
    if getMonsterInfo(getCreatureName(target)).healthMax ~= getCreatureMaxHealth(target) then
        return false
    end
    local adjustedAmount = percentage and targetMaxHealth * amount or targetMaxHealth + amount
    setCreatureMaxHealth(target, adjustedAmount)
    local targetCurrentHealth = getCreatureHealth(target)
    if targetCurrentHealth > adjustedAmount then
        doCreatureAddHealth(cid, -(targetCurrentHealth - adjustedAmount))
    else
        doCreatureAddHealth(cid, adjustedAmount)
    end
    if timer > 0 then
        addEvent(resetMonsterMaxHealth, timer * 1000, target)
    end
    return true
end

function onCastSpell(cid, var)
    print("Script starting..")
    local summons = getCreatureSummons(cid)
    for i = 1, #summons do
        print("Adjusting " .. getCreatureName(summons[i]) .. "'s hp. " .. i)
        adjustMonsterMaxHealthOnceOnly(summons[i], true, 2, 5)
    end
    print("Script ended successfully, without errors.")
    return true
end

The dragons still with the same health...
You gotta work with me here.

What happened in console?
Errors?
 
You gotta work with me here.

What happened in console?
Errors?

The problem was that i have
Code:
rateMonsterHealth = 1.5
in my config.lua

i just had to change to targetMaxHealth
Code:
    local targetMaxHealth = getMonsterInfo(getCreatureName(target)).healthMax + (getMonsterInfo(getCreatureName(target)).healthMax / 2)

There is a better way to do that?
So i can not have to get the information from config.lua
I mean, if i had to change the info on config.lua the spell will bug again :S
 
The problem was that i have
Code:
rateMonsterHealth = 1.5
in my config.lua

i just had to change to targetMaxHealth
Code:
    local targetMaxHealth = getMonsterInfo(getCreatureName(target)).healthMax + (getMonsterInfo(getCreatureName(target)).healthMax / 2)

There is a better way to do that?
So i can not have to get the information from config.lua
I mean, if i had to change the info on config.lua the spell will bug again :S
Lua:
getConfigValue("rateMonsterHealth")
 
Back
Top