Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

Basicamente é um sistema onde permite chuva e solte raios em determinado local do mapa, use sua criatividade ao usar o sistema.

 

Porém eu gostaria da ajuda da comunidade pos o script está muito bruto, (chove o tempo todo) 

Queria saber se alguém da comunidade ajudasse a botar uma variavel 

EX: 10% de chance de chover a cada 1 hora

Ajudaria a por mais realidade ao sistema.

Agora vamos ao Script!

 

rain1.thumb.png.f42fb0b716dfb7ca2add3bce4cbc71d0.png

 

Features :

 

Spoiler

 

Chuva só nos jogadores, para economizar memória do servidor, em vez de enviar todo o mapa.

Se não tiver um telhado, vai enviar o efeito dentro do local mesmo.

Assim, se você estiver sob um teto, vai enviar para fora do local.

Quando água bate no chão, envia o efeito de splash.

Efeito do trovão causa dano.

 

Em global.lua adicione :

 

Spoiler

weatherConfig = {

    groundEffect = CONST_ME_LOSEENERGY,

    fallEffect = CONST_ANI_ICE,

    thunderEffect = true,

    minDMG = 5,

    maxDMG = 10

}

 

function Player.sendWeatherEffect(self, groundEffect, fallEffect, thunderEffect)

    local position, random = self:getPosition(), math.random

    position.x = position.x + random(-4, 4)

      position.y = position.y + random(-4, 4)

 

    local fromPosition = Position(position.x + 1, position.y, position.z)

       fromPosition.x = position.x - 7

       fromPosition.y = position.y - 5

 

    local tile, getGround

    for Z = 1, 7 do

        fromPosition.z = Z

        position.z = Z

 

        tile = Tile(position)

        if tile then -- If there is a tile, stop checking floors

            fromPosition:sendDistanceEffect(position, fallEffect)

            position:sendMagicEffect(groundEffect, self)

 

            getGround = tile:getGround()

            if getGround and ItemType(getGround:getId()):getFluidSource() == 1 then

                position:sendMagicEffect(CONST_ME_WATERSPLASH, self)

            end

            break

        end

    end

 

    if thunderEffect and tile then

        if random(2) == 1 then

            local topCreature = tile:getTopCreature()

 

            if topCreature and topCreature:isPlayer() then

                position:sendMagicEffect(CONST_ME_BIGCLOUDS, self)

                doTargetCombatHealth(0, self, COMBAT_ENERGYDAMAGE, -weatherConfig.minDMG, -weatherConfig.maxDMG, CONST_ME_NONE)

                self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You were hit by lightning and lost some health.")

            end

        end

    end

end

globalevents.xml :

 

<globalevent name="Weather" interval="200" script="Weather.lua" />

 

globalevents/scripts :

 

Crie um arquivo chamado "Weather.lua"

 

 
function onThink(interval, lastExecution)
 local players = Game.getPlayers()
 if #players == 0 then
 return true
 end
 
 local player
 for i = 1, #players do
 player = players[i]
 player:sendWeatherEffect(weatherConfig.groundEffect, weatherConfig.fallEffect, weatherConfig.thunderEffect)
 end
 return true
end
 

Pronto :D

 

Creditos: Printer e Eldin

 

tumblr_o70wteR8521r9n6kzo1_400.gif

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo