TE
movements

Diving/Mergulho.

Por Testing111, 01 de set. de 2016 em CreatureScripts e Movements

dxp
mergulho
diving
6
4.8k
Testing111T
01 de setembro de 2016 às 23:59

Fiz um script simples para quando o player andar em baixo da água. O script troca a Outfit do personagem para o de mergulhador e altera a velocidade do mesmo.

Adicione em data/movements/movements.xml

    <movevent type="StepIn" fromid="5405" toid="5410" event="script" value="diving.lua"/>    <movevent type="StepOut" fromid="5405" toid="5410" event="script" value="diving.lua"/>

Agora vá em data/movements/scripts, crie o arquivo diving.lua e adicione:

function onStepIn(cid, item, position, fromPosition)    if getPlayerStorageValue(cid, 30211) == 1 then        return true    end    if isPlayer(cid) then        local outfit = getCreatureOutfit(cid)        local out = getPlayerSex(cid) == 0 and 1035 or 1034        setPlayerStorageValue(cid, 30211, 1)        doChangeSpeed(cid, -getCreatureSpeed(cid))        doChangeSpeed(cid, 1000)        doSetCreatureOutfit(cid, {lookType = out, lookHead = outfit.lookHead, lookBody = outfit.lookBody, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)        endendfunction onStepOut(cid, item, position, fromPosition)    if isPlayer(cid) then        setPlayerStorageValue(cid, 30211, -1)        doChangeSpeed(cid, -getCreatureSpeed(cid))        doRegainSpeed(cid)        doRemoveCondition(cid, CONDITION_OUTFIT)    endend

OBS: Testado no DxP.

JosegvbJ
02 de setembro de 2016 às 00:20

essa storage é oq?

 

esquece ja vi q vc seta essa storage no stepin, só nao entendi pra oq kk

 

Editado Setembro 2 por Josegvb

Testing111T
02 de setembro de 2016 às 09:20

O Storage é pro código não ficar se repetindo e setar a velocidade apenas uma vez.

Luga03L
05 de setembro de 2016 às 08:58
Em 02/09/2016 at 09:20, Testing111 disse:

O Storage é pro código não ficar se repetindo e setar a velocidade apenas uma vez.

Acho que o melhor seria no onStepIn verificar se fromPos é algum dos configurado no script, se sim, não executa o onStepIn e digo o mesmo sobre o onStepOut só que ao invés do fromPos usaria o toPos.

 

Bom, mesmo assim toma aí seu rep++ que essse script ficou legal :D

10 meses depois...
Punchlines NemmoP
19 de julho de 2017 às 04:24

achei um erro nesse script quando voce sai de cima do tile ele continua com o outfit quando vai mudar ele n muda ai reloga fica invisivel reloga dnv volta com outfit padrao ai volta para o tile que muda a outfit e nao acontece nada

Editado Julho 19 por Punchlines Nemmo

2 anos depois...
KaboFlowK
25 de janeiro de 2020 às 22:27
Em 01/09/2016 em 21:59, Testing111 disse:

Fiz um script simples para quando o player andar em baixo da água. O script troca a Outfit do personagem para o de mergulhador e altera a velocidade do mesmo.

Adicione em data/movements/movements.xml

    <movevent type="StepIn" fromid="5405" toid="5410" event="script" value="diving.lua"/>    <movevent type="StepOut" fromid="5405" toid="5410" event="script" value="diving.lua"/>

Agora vá em data/movements/scripts, crie o arquivo diving.lua e adicione:

function onStepIn(cid, item, position, fromPosition)    if getPlayerStorageValue(cid, 30211) == 1 then        return true    end    if isPlayer(cid) then        local outfit = getCreatureOutfit(cid)        local out = getPlayerSex(cid) == 0 and 1035 or 1034        setPlayerStorageValue(cid, 30211, 1)        doChangeSpeed(cid, -getCreatureSpeed(cid))        doChangeSpeed(cid, 1000)        doSetCreatureOutfit(cid, {lookType = out, lookHead = outfit.lookHead, lookBody = outfit.lookBody, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)        endendfunction onStepOut(cid, item, position, fromPosition)    if isPlayer(cid) then        setPlayerStorageValue(cid, 30211, -1)        doChangeSpeed(cid, -getCreatureSpeed(cid))        doRegainSpeed(cid)        doRemoveCondition(cid, CONDITION_OUTFIT)    endend

OBS: Testado no DxP.

 

 

[25/01/2020 19:26:28] [Error - LuaScriptInterface::loadFile] data/movements/scripts/diving.lua:1: '=' expected near 'onStepOut'
[25/01/2020 19:26:28] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/diving.lua)
[25/01/2020 19:26:28] data/movements/scripts/diving.lua:1: '=' expected near 'onStepOut'
[25/01/2020 19:26:28] [Error - LuaScriptInterface::loadFile] data/movements/scripts/diving.lua:1: '=' expected near 'onStepOut'
[25/01/2020 19:26:28] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/diving.lua)
[25/01/2020 19:26:28] data/movements/scripts/diving.lua:1: '=' expected near 'onStepOut'