Olá, amigos. Hoje é terça, portanto, venho trazer mais um script do SDT, para ver todos os scripts, clique aqui.
Sistema de Cultivo
Vídeo de como o sistema funciona:
Resumindo: Você ara o solo com uma enchada e depois planta uma semente no solo arado. A semente brota e pode crescer, virando uma planta que dará origem a um fruto, ou morrer. As plantas também podem ser removidas usando a enchada. Eu me certifiquei de não deixar nenhum bug, como: plantar uma semente em cima da outra, arar solo com item em cima, remover plantas fora dos solos e etc. Ainda assim, caso encontrar algum bug, poste aqui.
Crie cultivo.lua em data/actions/scripts e coloque:
--- Sistema de cultivo feito por Killua, XTibia.com local usableDirt = 103 -- Terra que pode ser arada local mustBeInHouse = "yes" -- Só pode usar dentro de house [yes/no] local fruits = {8843, 8845, 8838, 2683, 2682, 2684, 8842} -- Frutas que podem nascer local failChance = 50 -- Chande em % de falhar e a arvore morrer. function transformGround(pos, id) pos.stackpos = 0 return doTransformItem(getThingFromPos(pos).uid, id) end function getUnwantedItem(pos) for i = 1, 5 do pos.stackpos = i if getThingFromPos(pos).itemid > 0 and getThingFromPos(pos).itemid ~= 7732 then return true end end return false end function transformTo(pos, fromid, toid) for s = 1, 5 do pos.stackpos = s local item = getThingFromPos(pos) if item.itemid == fromid then doTransformItem(item.uid, toid) end end end function doRemoveMe(pos, id) for stackpos = 1, 5 do pos.stackpos = stackpos local item = getThingFromPos(pos) if item.itemid == id then doRemoveItem(item.uid) end end end function onUse(cid, item, fromPosition, itemEx, toPosition) if mustBeInHouse == "yes" and not getHouseFromPos(toPosition) then return doPlayerSendCancel(cid, "Voce so pode plantar dentro de houses.") end toPosition.stackpos = 0 local tile = getThingFromPos(toPosition) if tile.itemid == usableDirt and not getUnwantedItem(toPosition) and itemEx.itemid ~= 7732 then if item.itemid == 2552 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce arou o solo") doTransformItem(tile.uid, 804) addEvent(transformGround, math.random(54600, 68600), toPosition, usableDirt) end elseif item.itemid == 7732 and tile.itemid == 804 and not getUnwantedItem(toPosition) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce plantou a semente.") doRemoveItem(item.uid, 1) doCreateItem(6216, 1, toPosition) doSendMagicEffect(toPosition, CONST_ME_SMALLPLANTS) local chance = math.random(1, 100) local time1 = math.random(8500, 12600) local time2 = math.random(24500, 28600) if chance <= failChance then addEvent(transformTo, time1, toPosition, 6216, 2784) addEvent(doSendMagicEffect, time1, toPosition, 7) addEvent(doRemoveMe, time2, toPosition, 2784) addEvent(doSendMagicEffect, time2, toPosition, CONST_ME_POFF) else addEvent(transformTo, time1, toPosition, 6216, 2779) addEvent(doSendMagicEffect, time1, toPosition, CONST_ME_SMALLPLANTS) addEvent(doSendMagicEffect, time2, toPosition, CONST_ME_PLANTATTACK) addEvent(transformTo, time2, toPosition, 2779, fruits[math.random(1, #fruits)]) end elseif itemEx.itemid == 2784 or itemEx.itemid == 2779 then if tile.itemid == 804 or tile.itemid == 103 then doRemoveItem(itemEx.uid, 1) doSendMagicEffect(toPosition, 3) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce removeu planta") end else doPlayerSendCancel(cid, "Voce nao pode preparar este solo.") end return true end
Em data/actions/actions.xml, coloque essas TAGs:
<action itemid="2552" event="script" value="cultivo.lua"/> <action itemid="7732" event="script" value="cultivo.lua"/>
Para configurar, basta editar as variáveis de acordo com os comentários dentro do script.
Abraços e continuem acompanhando o SDT.