• 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 Movement Script - Fall on ice.

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

My idea: When walking over ice you have a chance of 1/748 to fall on your face.
What will happen: your outfit will change into a deadbody for 6 seconds, you will be unable to move/attack/heal for 6 seconds, you will recieve 35 ice damage and gain an extra stack in a player value (to reach an achievement).

I think I'll need to make a movement script for this on the following ids.

Server\data\movements\movements.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<movements>
    <movevent event="StepIn" itemid="671" script="ice.lua"/>
    <movevent event="StepIn" fromid="6683" toid="6686" script="ice.lua"/>
</movements>


Server\data\movements\scripts\ice.lua
Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 6000)
local outfit =
    {
        lookType = 2317,
        lookHead = 0,
        lookBody = 0,
        lookLegs = 0,
        lookFeet = 0,
        lookAddons = 0
    }
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE then
        local rand = math.random(1, 748)
        if rand < 2 then
            doTargetCombatHealth(0, cid, COMBAT_ICEDAMAGE, -35, -35, CONST_ME_NONE)
            doSendMagicEffect(position, CONST_ME_DRAWBLOOD)
        doAddCondition(cid, condition)
     setPlayerStorageValue(cid,getPlayerStorageValue(cid,11000),+1)
    end
return true
end

This is how far I got, not sure if everything is correct though.

Any help is welcome.
Thanks in advance.
 
Well, you might want to lower that chances to test the script huh? :)
1 in 748 is a very very little chance btw.
 
Ofc I set the chance to "local rand = math.random(1, 1)" while testing.
Secondly the point is that there is a very low chance, otherwise it would become annoying while hunting in ice areas.

But thx for the headsup anyways. :)
 
Well the script is done, maybe doPlayerSetNoMove? Other than that it's done mate.

I fear it's far from done because once I implement all the above absolutetly nothing happens when I walk over ice. (chance set to 100%)

Got the following error while reloading the script:
Code:
[31/07/2015 11:36:34] Warning: [Event::checkScript] Can not load script. /scripts/ice.lua
[31/07/2015 11:36:35] data/movements/scripts/ice.lua:19: unexpected symbol near '+'
[31/07/2015 11:36:35] Warning: [Event::checkScript] Can not load script. /scripts/ice.lua
[31/07/2015 11:36:35] data/movements/scripts/ice.lua:19: unexpected symbol near '+'
[31/07/2015 11:36:35] Reloaded movements.

So chance the script to this (also included a msg to see if it works):
Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 6000)
local outfit =
    {
        lookType = 2317,
        lookHead = 0,
        lookBody = 0,
        lookLegs = 0,
        lookFeet = 0,
        lookAddons = 0
    }
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE then
        local rand = math.random(1, 2)
        if rand < 2 then
                doTargetCombatHealth(0, cid, COMBAT_ICEDAMAGE, -35, -35, CONST_ME_NONE)
                doSendMagicEffect(position, CONST_ME_DRAWBLOOD)
            doAddCondition(cid, condition)
        doPlayerSendTextMessage(cid,MESSAGE_EVENT_ADVANCE,'TEST')
    end
end
return true
end

Restarted the server and nothing still happens when I walk over ice. I also don't recieve the 'Test' msg.
 
Last edited by a moderator:
Changed up a couple things and got it to work partly.

Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 6000)
local outfit =
    {
        lookType = 2317,
        lookHead = 0,
        lookBody = 0,
        lookLegs = 0,
        lookFeet = 0,
        lookAddons = 0
    }
function onStepIn(cid, item, position, fromPosition)
    if isPlayer(cid) == TRUE and item.itemid == 671 or (item.itemid >= 6683 and item.itemid <= 6686)then
        local rand = math.random(1, 1)
        if rand < 2 then
                doTargetCombatHealth(0, cid, COMBAT_ICEDAMAGE, -35, -35, CONST_ME_NONE)
            doAddCondition(cid, exhaust)

    end
end
return true
end

Once I add the following line:
Code:
        doSetCreatureOutfit(cid, outfit, -1)
My character debugs and everyone who enters into its screen.

Great I can't login to one of my characters anymore due to the bug I made before with the outfit.

I changed the outfit back to a normal one in phpmyadmin, teleported the character back to normal ground floor. But each time I login on it I get debugged and the looktype changes back to 2317 which causes the client to crash.

So maybe anyone knows how to fix this also? :p

Nvm the last part, deleted the char :D was the faster solution.

I think that the only things I didn't fix yet are the outfit change + change back and the stop moving + allow moving again.
If someone could help me out with those that would be awesome :)


Edit: also that the effect doesn't affect my creatures or npcs because there also seems to excist a problem atm.
 
Last edited by a moderator:
What's your idea behind setting the outfit to -1??
The stop moving part will do with doPlayerSetNoMove or doPlayerChangeSpeed to 0 maybe(?, I'm sure the first one will work because I have done scripts with it myself.
Your creatures and npcs aren't players are they :p
 
What's your idea behind setting the outfit to -1??
The stop moving part will do with doPlayerSetNoMove or doPlayerChangeSpeed to 0 maybe(?, I'm sure the first one will work because I have done scripts with it myself.
Your creatures and npcs aren't players are they :p

Well the idea with outfit set to -1 I got from the swimming script where you change the outfit to the swimming outfit during your time in the water as I want to change the outfit to a dead body for the time being.
But I just realized I should check out a chameleon rune script for that part because that actually changes your outfit to an item which we are trying todo here.
 
Back
Top