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

[lua] increase speed

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
an action for one item to do:

Increase your speed underwater while using a Helmet of the Deep or Depth Galea for 24 hours. Only can use if are using the helmet of the deep or depth galea

like this: Helmet of the deep, update 8.6 (Solved)


tfs 1.2

thanks <3
 
Last edited by a moderator:
I will provide only the scripts for this. Make sure to have the items correctly as in the link you posted.
Create a undewaterhelmets.lua in /data/lib/miscellaneous and put it inside:

LUA:
local COCONUT_SHRIMP_BAKE_STORAGE = 60592
local COCONUT_SHRIMP_BAKE_TIME = 24 * 60 * 60

local DEEP_ID = 0 -- Id of the Helmet of the Deep
local DEEP_ID_BONUS = 0 -- Id of the Helmet of the Deep with the speed bonus
local DEPTH_ID = 0 -- Id of the Depth Galea
local DEEP_ID_BONUS = 0 -- Id of the Depth Galea with the speed bonus

local helmetsMap = {
    [DEEP_ID] = DEEP_ID_BONUS,
    [DEPTH_ID] = DEPTH_ID_BONUS,
    [DEEP_ID_BONUS] = DEPTH_ID,
    [DEPTH_ID_BONUS] = DEPTH_ID
}

function getUndewaterHelmet(player)
    local helmet = player:getSlotItem(CONST_SLOT_HEAD)
    if helmet and isInArray(helmetsMap, helmet:getId()) then
        return helmet, transformId = helmetsMap[helmet:getId()], bonus = isInArray({DEEP_ID_BONUS, DEPTH_ID_BONUS, helmet:getId()})
    end

    return nil
end

function checkUnderwaterHelmet(player)
    local helmet, transformId, bonus = getUndewaterHelmet(player)
    if helmet then
        helmet:transform(transformId)
        if not bonus then
            local time = player:getStorageValue(COCONUT_SHRIMP_BAKE_STORAGE) - os.time()
            if time > 0 then
                helmet:setAttribute('duration', time)
                helmet:decay()
            end
        end
    end
end

Change the ID's as in comment in front of them. You can change the storage too to one that is free in your server.
And register it on miscellaneous.lua as:
dofile('data/lib/miscellaneous/underwaterhelmets.lua')

Create a coconutshrimp.lua in /data/actions/scripts and put it inside:

LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local helmet = getUndewaterHelmet(player)
    if not helmet then
        return false
    end

    player:setStorageValue(COCONUT_SHRIMP_BAKE_STORAGE, os.time() + COCONUT_SHRIMP_BAKE_TIME)
    player:say('Yum.', TALKTYPE_MONSTER_SAY)
    return true
end

Then register it on actions.xml for the itemid of the Coconut Shrimp Bake

Now, open your /movements/scripts/drowning.lua

and before return on function onStepIn put:
checkUnderwaterHelmet(player)

And finally. Create and register a onEquip script and again put on it the:
checkUnderwaterHelmet(player)

Depth Galea now seems to not lose the effect on remove it or step out underwater. But if you want this. make the same as onStepIn in drowning.lua in the onStepOut, and also create a deEquip script to also make the same. If in doubt just ask.

Note: This need to restart the server to the lib functions be available
 
Last edited:
Code:
local condition = Condition(CONDITION_HASTE)
condition:setTicks(-1)
condition:setFormula(0.3, -24, 0.3, -24)

function onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    local helmetSlot = creature:getSlotItem(CONST_SLOT_HEAD)
    if helmetSlot and isInArray({5461, 15408}, helmetSlot.itemid) then
        creature:addCondition(condition)
    end
    return true
end

function onStepOut(creature, item, position, fromPosition)
    if creature:isPlayer() then
        creature:removeCondition(CONDITION_HASTE)
    end
    return true
end
 
thanks guys but

I wanted a script that: If the player has the storage of the use of the item and is in the water using the helmet, it will stay with speed. If it is out of the water the speed comes out.
 
That is What i provided. The Storage thing you can add it on your own.

Let's assume that, the player is with the condition and is already inside the water, how will the condition come out if it continues in the water?
The script you sent is stepIn/Out, as if the player entered some teleport for example, right? We need one to check if player are inside water or not, add condition or not, maybe onThink creaturescripts hmmm
 
Back
Top