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

MoveEvent [TFS 1.2] - Regen tile

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,643
Solutions
559
Reaction score
3,949
tile that you walk in and regens health
though you can edit this to regen whatever you want
useless but someone might find a use for it

video

add this to your player lib
Code:
function Player:getMissingHealth()
    return self:getMaxHealth() - self:getHealth()
end

function Player:addPercentHealth(value)
    local health = math.floor(self:getMissingHealth() * value+0.5)
    local final = (health > 0 and health) or 1
    if value <= 1.0 and self:getHealth() ~= self:getMaxHealth() then
        self:addHealth(final)
        return final
    end
    return 0
end

movement lua
Code:
local dirs = {
    [0] = {x = 0,  y = -1, nx = 7},  -- North
    [1] = {x = 1,  y = 0,  nx = 5},   -- East
    [2] = {x = 0,  y = 1,  nx = 4},   -- South
    [3] = {x = -1, y = 0,  nx = 6},  -- West
    [4] = {x = -1, y = 1,  nx = 3},  -- Southwest
    [5] = {x = 1,  y = 1,  nx = 2},   -- Southeast
    [6] = {x = -1, y = -1, nx = 0}, -- Northwest
    [7] = {x = 1,  y = -1, nx = 1}   -- Northeast
}

local function executeShit(name, areaEffect, distEffect, percent, delay, currDir, totalHealth, n)
    -- currDir, totalHealth, n args are for internal usage
    local player = Player(name)
    if not player then
        return
    end
    if (n == nil or n <= 7) then
        local pos = player:getPosition()
        local off = dirs[currDir or 0]
        local position = Position(pos.x+off.x, pos.y+off.y, pos.z)
        local health = player:addPercentHealth(percent)
        local add = totalHealth and totalHealth + health or health
        position:sendMagicEffect(areaEffect)
        position:sendDistanceEffect(pos, distEffect)
        pos:sendMagicEffect(CONST_ME_HOLYAREA)
        player:sendTextMessage(MESSAGE_STATUS_SMALL, string.format('Total health added: %d', add))
        addEvent(executeShit, delay, name, areaEffect, distEffect, percent, delay, off.nx, add, not n and 1 or n+1)
    end
end

-------------------------------------------------------------------------------------------------------------------

local wait = {}

local cfg = {
    percent = 10, -- percent of health to be added back to the player each tick
    time = 60, -- seconds to use tile again
    delay = 650, -- milliseconds (tick delay)
    areaEffect = CONST_ME_HOLYDAMAGE,
    distanceEffect = CONST_ANI_HOLY
}

function onStepIn(creature, item, position, fromPosition)
    local p = creature:getPlayer()
    if p then
        local getwait = wait[p:getName()]
        if getwait and getwait - os.time() > 0 then
            return p:sendTextMessage(MESSAGE_STATUS_SMALL, string.format('You must wait %d seconds to use this again.', getwait - os.time())), creature:teleportTo(fromPosition, true)
        end
        executeShit(p:getName(), cfg.areaEffect, cfg.distanceEffect, cfg.percent/100, cfg.delay)
        wait[p:getName()] = os.time() + cfg.time
        return
    end
    return creature:teleportTo(fromPosition, true)
end
 
Hey,

You use this table to store cd, right?

Code:
 wait[p:getName()] = os.time() + cfg.time

Trying to apply your algorithm to something a bit similar.

PS: Loved the name of the function xD
 
Hey,

You use this table to store cd, right?

Code:
 wait[p:getName()] = os.time() + cfg.time

Trying to apply your algorithm to something a bit similar.

PS: Loved the name of the function xD
yes that stores exhaustion to player name since player id changes each time they log in, if they log back in you can create userdata again with the name

i thought hard for the name of that function thanks
 
obviously not because i said it works with health
though it is not hard to change to stamina regen, and no i will not do it for you

ok, thanks anyways
this script works really good to make players get out of trainers, when u change the time to use tile ^^

edit: cant locate player lib :s using OTX server 2
 
Last edited:
ok, thanks anyways
this script works really good to make players get out of trainers, when u change the time to use tile ^^

edit: cant locate player lib :s using OTX server 2

Just use any global file or put inside the lua file where you are adding the functions... They are just functions.
 
Hi! it sounds very cool, Im looking for a script that makes players without infight condition regen health and mana faster, can I have some help??
 
Back
Top