Postado Abril 10, 2014 11 anos Olá,Bom vou direto ao pedido. Eu quero um systema de Chuva, de hora em hora ira chover no server,Mas quero que chova penas no andar 7,para nao causar lags,tbm quero q dentro do pz nao chova.Quero q formem umas poças de agua no chao e tals, (Efeitos Configuraveis) Sei que ja tem systemas de rain no Forum,mas um causa muito lag e o outro chove no pz. TFS 0.4 Desculpe o Incomodo.
Postado Abril 11, 2014 11 anos Solução Olá, bom dia. Há várias maneiras, mas para fazer chover em um andar inteiro é interessante vc usar o script do Kaotar (de outro Fórum). Primeiro passo: Vá em Data > Lib > (crie um arquivo chamado rain.lua e cole isto dentro) -- 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 2º Vá na pasta Data > GlobalEvents > (crie um arquivo chamado rain.lua e cole isto dentro) local rain = Rain:new() function onThink(interval, lastExecution) local minX = 990 local minY = 993 local maxX = 1008 local maxY = 1006 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_ENERGYAREA }, rain = { disteffect = CONST_ANI_ICE, effect = CONST_ME_LOSEENERGY } } random = math.random(0, 10) if (random == 0) then rain.chance = math.random(10,50) rain:start({fromPos = frompos, toPos = topos}, effects.snow, 300, math.random(100, 500)) else rain.chance = math.random(40,100) rain.createItem = {chance = math.random(0,10), item = {itemid = 2016, type = 1}} rain:start({fromPos = frompos, toPos = topos}, effects.rain, math.random(300, 1000), math.random(100, 350)) end return TRUE end 3º Vá no arquivo Data > GlobalEvents > globalevents.lua e adicione isto dentro: <globalevent name="rain" interval="200" event="script" value="rain.lua"/> Obs: o interval é o tempo que dura o SEU efeito em milisegundos. Ou seja, se vc cronometrou 3 segundos, vc deve colocar alí 3000. 4º - Vá em sua pasta Data > Lib > (crie um arquivo chamado rain.lua e cole isto: -- 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 seu sistema está montado. A partir de de agora é configurar. Tem que configurar pois o "system" segue coordenadas, logo vc deve inserir as do seu mapa! Assim, vá no arquivo Data > Globalevents > rain.lua e edite o seguinte: local minX = Posição 'x' mínima, ou seja, inferior direita; local minY = Posição 'y' mínima, também inferior direita; local maxX = Posição 'x' máxima, superior esquerda; local maxY = Posição 'y' máxima, superior esquerda tb Não é necessário editar o andar, já está "setado" para o 7. Além de tudo, você ainda pode configurar a "chance" de chover. Pra isto vc pode inserir, dentro do: data > globalevents > globalevents.xml Na linha que comentamos acima o código: rain.chance = Math.random (20.100) Modifique o 20, que é a chance de ocorrer. Bom, penso que é isto. Testei aqui no meu server, funcionou. Maaas... fica a dica, quanto maior foi a área que chovia, maior era o "lag". Eu configurei em áreas remotas (ilhas, cidades, etc.) de tempos em tempos. É um efeito legal, mas pode consumir mais memRam do que imagina. Qualquer coisa volte aqui. The Last Man Standing - 100% funcional
Postado Abril 11, 2014 11 anos Autor Vou Testar e Ja Edito aqui.Quanto ao local onde vai chover vou colocar só na cidade principal. @EDIT Bom,Coloquei Aqui Interval de 10 segundos e nao choveu,mas vou deixar rodando aqui. Vlew mesmo. Rep+ Editado Abril 11, 2014 11 anos por YouTubexD (veja o histórico de edições)
Postado Abril 11, 2014 11 anos Não aparece nenhum erro na Distro? The Last Man Standing - 100% funcional
Postado Abril 11, 2014 11 anos Autor Nao,Acho que funcionou,pq apareceu as poças de agua no chao,nao vi se deu os efeitos da chuva,pois nao fiquei online,mas mais tarde estarei online e, vou ficar de olho. Vlw @Edit Funcionou Perfeitamente Vlw Editado Abril 11, 2014 11 anos por YouTubexD (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.