• 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.X+ TFS 1.2 Looking for monster heal monster spell

henkas

Active Member
Joined
Jul 8, 2015
Messages
912
Solutions
4
Reaction score
45
Hello looking for monster heal monster spell what i tried

1. This one heals players too and has no effects so its not perfection
<attack name="healing" interval="2000" min="100" max="100" min="5" max="5" range="8" radius="10" target="1"/>

2. This one doesnt work
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_LIGHTING61)
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local healMonsters = true

function onTargetCreature(creature, target)
    local player = creature:getPlayer()
    local min = (getLevel() / 5) + (getMagicLevel() * 4.6) + 100
    local max = (getLevel() / 5) + (getMagicLevel() * 9.6) + 125

    if not healMonsters then
        local master = target:getMaster()
        if target:isMonster() and not master or master and master:isMonster() then
            return true
        end
    end

    doTargetCombatHealth(creature:getId(), target, COMBAT_HEALING, min, max, CONST_ME_NONE)
    return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,073
Solutions
107
Reaction score
1,142
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
Monsters are not players, that means they have no level, nor magic level, you must change the formula and calculate the healing with other variables of the monster or simply some configuration defined in the script with constants

example:
data/spells/scripts/spell.lua
Lua:
local config = {
    level = 100,
    magicLevel = 50
}
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))
function onTargetCreature(creature, target)
    if creature:isPlayer() or target:isPlayer() or not creature:isFriend(target) then
        return false
    end
    local min = (config.level / 5) + (config.magicLevel * 4.6) + 100
    local max = (config.level / 5) + (config.magicLevel * 9.6) + 125
    doTargetCombatHealth(creature, target, COMBAT_HEALING, min, max, CONST_ME_HEARTS)
    return true
end
combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
data/spells/spells.xml
XML:
<instant name="testhealing" words="###100" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="spell.lua" />

monster.xml
XML:
<attack name="testhealing" interval="1000" chance="100" range="6" target="0" />
 
Last edited:
OP
OP
H

henkas

Active Member
Joined
Jul 8, 2015
Messages
912
Solutions
4
Reaction score
45
Monsters are not players, that means they have no level, nor magic level, you must change the formula and calculate the healing with other variables of the monster or simply some configuration defined in the script with constants

example:
data/spells/scripts/spell.lua
Lua:
local config = {
    level = 100,
    magicLevel = 50
}
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HEARTS)
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))
function onTargetCreature(creature, target)
    if creature:isPlayer() or target:isPlayer() then
        return false
    end
    local min = (config.level / 5) + (config.magicLevel * 4.6) + 100
    local max = (config.level / 5) + (config.magicLevel * 9.6) + 125
    doTargetCombatHealth(creature, target, COMBAT_HEALING, min, max, CONST_ME_HEARTS)
    return true
end
combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
data/spells/spells.xml
XML:
<instant name="testhealing" words="###100" aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="spell.lua" />

monster.xml
XML:
<attack name="testhealing" interval="1000" chance="100" range="6" target="0" />
No errors, it cast spell fine but it doesnt heal at all
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,073
Solutions
107
Reaction score
1,142
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
This is a visual example:
When a monster is your summons, therefore hostile monsters will not be able to heal your summons.
however if any of your summons has this spell, then it will heal your other summons.
GIF 18-11-2021 03-35-36 p. m..gif
I already edited the code again and added an if that I needed to add, try and tell me how it went
 
OP
OP
H

henkas

Active Member
Joined
Jul 8, 2015
Messages
912
Solutions
4
Reaction score
45
This is a visual example:
When a monster is your summons, therefore hostile monsters will not be able to heal your summons.
however if any of your summons has this spell, then it will heal your other summons.
View attachment 63508
I already edited the code again and added an if that I needed to add, try and tell me how it went
Doesnt work, not even casting a spell. You see this entire stuff suppose to work like this

There is two monsters

Monster Boss (He summons Monster Priest at X time)
and
Monster Priest

so Monster Priest suppose to heal that boss because hes in healing range.
 
Last edited:
Top