• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua TFS 1.3 Monster heal after stepping into fire field

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
369
Solutions
1
Reaction score
49
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()

M0ustafa

1337
Senator
Joined
Mar 4, 2017
Messages
2,681
Solutions
334
Reaction score
1,453
Location
Egypt
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
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
369
Solutions
1
Reaction score
49
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.
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
369
Solutions
1
Reaction score
49
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

M0ustafa

1337
Senator
Joined
Mar 4, 2017
Messages
2,681
Solutions
334
Reaction score
1,453
Location
Egypt
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" />
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
369
Solutions
1
Reaction score
49
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.
 
Top