• 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 TFS 1.3 Monster heal after stepping into fire field

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hey guys, as the title say, I would like a script where a specific monster will be healed x% amount of max health after stepping into fire field.
 
Solution
Change 1000 to firefield id or you can use aid if it's a specific firefield. and calculate this * 0.1 to be the % you need. Also, don't forget the monster's name "Dragon".
Lua:
local healMonster = MoveEvent()
healMonster:type("stepin")

function healMonster.onStepIn(creature, item, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    local currentMaxHealth = creature:getMaxHealth()
    local healthPercent = currentMaxHealth * 0.1
    if creature:getName() == "Dragon" then
        creature:addHealth(healthPercent)
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end

healMonster:id(1000)
healMonster:register()
Change 1000 to firefield id or you can use aid if it's a specific firefield. and calculate this * 0.1 to be the % you need. Also, don't forget the monster's name "Dragon".
Lua:
local healMonster = MoveEvent()
healMonster:type("stepin")

function healMonster.onStepIn(creature, item, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    local currentMaxHealth = creature:getMaxHealth()
    local healthPercent = currentMaxHealth * 0.1
    if creature:getName() == "Dragon" then
        creature:addHealth(healthPercent)
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end

healMonster:id(1000)
healMonster:register()
 
Last edited:
Solution
Change 1000 to firefield id or you can use aid if it's a specific firefield. and calculate this * 0.1 to be the % you need. Also, don't forget the monster's name "Dragon".
Lua:
local healMonster = MoveEvent()
healMonster:type("stepin")

function healMonster.onStepIn(creature, item, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    local currentMaxHealth = creature:getMaxHealth()
    local healthPercent = currentMaxHealth * 0.1
    if creature:getName() == "Dragon" then
        creature:addHealth(healthPercent)
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end

healMonster:id(1000)
healMonster:register()
It didn't work. No errors shown on TFS either. I add the fire field id and put the script on data/scripts.
 
You must have done something wrong. I just tested it on my test server and it worked.
DragonHeal.gif
 
You must have done something wrong. I just tested it on my test server and it worked.
View attachment 70909
Lua:
local healMonster = MoveEvent()
healMonster:type("stepin")

function healMonster.onStepIn(creature, item, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    local currentMaxHealth = creature:getMaxHealth()
    local healthPercent = currentMaxHealth * 0.1
    if creature:getName() == "Dragon" then
        creature:addHealth(healthPercent)
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end

healMonster:id(1487)
healMonster:register()

1664492316383.png

Everything seems to be in place.
Post automatically merged:

Ok, I think I just saw the error. 1487 it's a duplicated id
 

Attachments

  • WhatsApp-Video-2022-09-29-at-19.44.57.gif
    WhatsApp-Video-2022-09-29-at-19.44.57.gif
    8.8 MB · Views: 1 · VirusTotal
That's why it didn't show for me, I used a different fire field.
Try adding it as a movement script then add it with the existing fire field function.
Lua:
function onStepIn(creature, item, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    local currentMaxHealth = creature:getMaxHealth()
    local healthPercent = currentMaxHealth * 0.1
    if creature:getName() == "Dragon" then
        creature:addHealth(healthPercent)
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end
XML:
<movevent event="StepIn" itemid="1487" function="onStepInField" script="scriptname.lua" />
 
That's why it didn't show for me, I used a different fire field.
Try adding it as a movement script then add it with the existing fire field function.
Lua:
function onStepIn(creature, item, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    local currentMaxHealth = creature:getMaxHealth()
    local healthPercent = currentMaxHealth * 0.1
    if creature:getName() == "Dragon" then
        creature:addHealth(healthPercent)
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end
XML:
<movevent event="StepIn" itemid="1487" function="onStepInField" script="scriptname.lua" />
<movevent event="AddItem" itemid="1487" function="onAddField" script="scriptname.lua" />

I changed the id to anything else and it works, thanks man and sorry for my confusion with id.
 
Back
Top