rain.lua data/globalevents/scripts
local rain = Rain:new()
function onThink(interval, lastExecution)
local minX = 1062
local minY = 1140
local maxX = 1076
local maxY = 1150
local frompos = {x=1, y=1, z=7}
local topos = {x=1000, y=1000, z=7}
local effects = {
snow = {
disteffect = CONST_ANI_SNOWBALL,
effect = CONST_ME_ICETORNADO
},
rain = {
disteffect = CONST_ANI_ICE,
effect = CONST_ME_LOSEENERGY
}
}
random = math.random(0, 10)
if (random == 0) then
rain.chance = 1000
rain:start({fromPos = frompos, toPos = topos}, effects.snow, 300, math.random(100, 500))
else
rain.chance = 1000
rain.createItem = {chance = math.random(0,10), item = {itemid = 2016, type = 1}}
rain:start({fromPos = frompos, toPos = topos}, effects.rain, math.random(100, 1000), math.random(100, 350))
end
return TRUE
end
Rain.lua data/globalevents/lib
-- 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
edite as areas nessas linhas
local frompos = {x=1, y=1, z=7}
local topos = {x=1000, y=1000, z=7}






info
Grupo: Campones
Registrado: 22/11/13
Posts: 25
Reputação: 0
Galera, to com um script Rain system (globalevent) do Kaotar aki e esse script ele pede uma área á vc para realizar a chuva, só que ai com essa área ele faz a função math.random então ele escolhe uma sqm dessa área e faz chover por vez. Eu gostaria que alguém editasse pra mim, para que pedisse a área e chovesse nela toda, o tempo todo, durante um determinado tempo.
Certo da ajuda , agradeço desde já ! vlw !
rain.lua data/globalevents/scripts
local rain = Rain:new()
Editado Janeiro 1 por Geraldoida