Tópico original: http://www.xtibia.co...-system-com-ss/
Autor: Kaotar
Editado por: andretoprox
O motivo é que, não funciona em 8.60, eu já testei e talz...
Eu consegui editar e arrumar certinho. Chega de conversa...
é claro que copiei, sim, mas eu estou passando um diferente, e não igual!
Rain System
Nome do Sistema: Rain System
Nome do Autor: Kaotar
Créditos: 99% Kaotar (Por Fazer o Script) / 1% Zakk (Por trazer e conteudo ao XTIBIA e Organizar o Tópico)
Entre em data/globalevents/script/, crie um arquivo com nome rain.lua, cole o código abaixo, salve e feche:
local rain = Rain:new() function onThink(interval, lastExecution) local minX = 0 local minY = 0 local maxX = 183 local maxY = 65 local frompos = {x=math.random(minX, maxX), y=math.random(minY, maxY), z=7} local topos = {x=math.random(frompos.x, maxX), y=math.random(frompos.y, maxY), z=7} local effects = { snow = { disteffect = CONST_ANI_SNOWBALL, effect = CONST_ME_ICETORNADO }, rain = { disteffect = CONST_ANI_ICE, effect = CONST_ME_LOSEENERGY } } rain:start({fromPos = frompos, toPos = topos}, effects.snow, 300) rain.createItem = {chance = math.random(0,1), item = {itemid = 2016, type = 1}} rain:start({fromPos = frompos, toPos = topos}, effects.rain) return TRUE end
Agora vá em data/globalevents/globalevents.xml e adicione essa TAG:
<globalevent name="rain" interval="100" event="script" value="rain.lua"/>
Depois, vá em data/globalevents/lib/, crie um arquivo com nome Rain.lua, cole o código abaixo, salve e feche:
-- Features: -- chance = OBJECT.chance = INT -- createItem = OBJECT.createItem = {chance = INT, item = {itemid = INT, type = INT}} Rain = {ignoreIds = {4526}} function Rain:new() local obj = {} setmetatable(obj, self) self.__index = self return obj end function Rain:getPositionInArea(fromPos, toPos) self.positions = {} for Y = fromPos.y, toPos.y do for X = fromPos.x, toPos.x do if (getTileThingByPos({x=X, y=Y, z=7, stackpos=0}).itemid ~= 0) then if not (string.match(string.lower(getItemNameById(getTileThingByPos({x=X, y=Y, z=7, stackpos=0}).itemid)), "water")) then table.insert(self.positions, {x=X, y=Y, z=Z}) end end end end return true end function Rain:doRain(position, disteffect, effect) if (self.duraction ~= self.executed) then local chance = self.chance or 100 if (math.random(0, 1000) <= chance) then for Z = 0, 7 do if (getTileThingByPos(({x = position.x, y = position.y, z = Z})).itemid ~= 0) then doSendDistanceShoot({x = position.x - 7, y = position.y - 5, z = Z}, {x = position.x, y = position.y, z = Z}, disteffect) doSendMagicEffect({x = position.x, y = position.y, z = Z}, effect) if (self.createItem) then if (math.random(0, 1000) <= self.createItem.chance) then if (isInArray(self.ignoreIds, getTileThingByPos({x=X, y=Y, z=Z, stackpos=0}).itemid) == FALSE) then local item = doCreateItem(self.createItem.item.itemid, self.createItem.item.type, {x=position.x, y=position.y, z=Z}) doDecayItem(item) end end end break end end end return true else return false end end function Rain:start(positions, effects, duraction, delay, var) self:getPositionInArea(positions.fromPos, positions.toPos) if not (self.positions[1]) then return false end self.delay = delay self.var = var or self self.effects = effects self.duraction = duraction self.executed = 0 addEvent(doCallback, self.delay, {var=self.var}) return true end function doCallback(p) for _, v in pairs(p.var.positions) do if not (p.var:doRain(v, p.var.effects.disteffect, p.var.effects.effect)) then return true end end addEvent(doCallback, p.var.delay, {var=p.var}) p.var.executed = p.var.executed+1 end
Agora vá em data/globalevents/lib/globalevents.lua e adicione essa TAG:
dofile(getDataDir() .."globalevents/lib/Rain.lua")
Para aqueles que sabem mexer em script é possível fazer chover meteoros mudando os efeitos e varias outras coisas a sua imaginação.
Para mudar de quanto enquanto tempo a chuva ira acontecer devera mudar a tag do globalevents.xml na parte de interval.
SE ESTIVER DANDO LAG, AUMENTE O INTERVAL NO GLOBALEVENTS.XML. Recomendo aumentar de 60 em 60
60 = 1Minuto
QUALQUER OUTRA DÚVIDA, VEJA SE TEM NO TOPICO QUE POSTEI LÁ EMCIMA
VOCê DEVE EDITAR O MINX, MINY, MAXX E MAXY.
Por exemplo: tem 16 sqm na minha area.
Exemplo: O primeiro da diagonal <+/\ vai ser 20x 20y. Então voce edita e coloca no minx e miny
O ultimo quadrado V+> vai ser o maxx e maxy; por exemplo vai ser 36x 36y
Considerações finais: Não é aconselhável usar a snow do jeito que está configurado, pois está bem feio, também há um erro que sempre que ocorre uma nova chuva se uma antiga esta acontecendo, a velha para, e a novo começa. É fácil arrumar, porém eu só não arrumei pois isso pode acarretar novos bugs.