• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Fall damage in tibia.

Andréew

Humble mapper.
Joined
Apr 14, 2015
Messages
844
Solutions
2
Reaction score
1,993
Location
Sweden
Is this possible? doing fall damage?
need to be done in source or is it possible with just LUA functions?
with fall damage i mean if the player falls lets say 3 floors they take damage.

this maybe wrong to post it here maybe since its more of a thought so maybe it should be in discuss section.
but if its possible i want some help with it so i post it here :)


I use TFS 1.1
 
Sure its possible, use a movement script on a stair tile (yellow see through tiles in map editor)..

You can use snow.lua as an example
https://github.com/otland/forgottenserver/blob/master/data/movements/scripts/snow.lua

Its only interface is an onStepOut

When the player steps off the tile of snow, foot prints are created right?

You can use its fromPosition parameter to determine where the play came from, to deduce the damage to give the player.
 
Code:
function onStepOut(creature, item, position, fromPosition)
   if creature:isPlayer() and creature:isInGhostMode() then
     return true
   else (what to write here?)
   
   end
end

whats the function for doing damage? i was looking at the traps.lua in movements but it have something like this

local traps = {
[1510] = {transformTo = 1511, damage = {-50, -100}}

should i just use it as a trap maybe?

Code:
local traps = {
[459] = {damage {-50, - 100}}

function onStepOut(creature, item, position, fromPosition)
  local trap = traps[item.itemid]
   if creature:isPlayer() and creature:isInGhostMode() then
   doTargetCombatHealth(0, ???? )
     return true
   
   end
end

sorry noobish at this, still tryin tho


edit: also if i use it as a "trap" and you fall 3 floors you need to go though 2 tiles of itemID 459 then it means you take 2 times the fall damage?
which is pretty great since the longer you fall the more damage you take :o
 
Last edited:
edit: also if i use it as a "trap" and you fall 3 floors you need to go though 2 tiles of itemID 459 then it means you take 2 times the fall damage?
which is pretty great since the longer you fall the more damage you take :eek:
Quite possibly sure

All scripts start small, lets attempt to construct a basic version, then if it works we can make it more complicated if need be.
Code:
-- do we want monsters also to be effect by this?
local effectAll = true

local damage = {min = -100, max = -500}

function onStepOut(creature, item, position, fromPosition)
    creature = effectAll and creature or Player(creature:getId())
    if not creature then
        return true
    end
   
    doTargetCombatHealth(0, creature, COMBAT_PHYSICALDAMAGE, damage.min, damage.max, CONST_ME_DRAWBLOOD)
    return true
end
 
Check the players z position, for the new tile, and for the tile they were on.

just a quick example
Code:
current_z = fromPosition.z
new_z = position.z
if current_z > new_z then
    return true
end
z_difference = new_z - current_z
if z_difference < 3 then
    return true
end
damage = z_difference * 500
-- hit player health here.
 
Thank you guys! i will try this out when i get back home, got a couple of days off work so im on a road trip for a few days!

but @Codex NG i was thinking, if i use it with the tile id 459, you will take damage walking down mountains even if there is stairs? right?
because "onStepOut" with that particilar tile.
 
Thank you guys! i will try this out when i get back home, got a couple of days off work so im on a road trip for a few days!

but @Codex NG i was thinking, if i use it with the tile id 459, you will take damage walking down mountains even if there is stairs? right?
because "onStepOut" with that particilar tile.
give the item an action id
 
Back
Top