Advertisement
dyalgi

BFK DayNight MoonFase

Apr 24th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.25 KB | None | 0 0
  1.   #--------------------------------------------------------------------------
  2.   # SISTEMA DIA E NOITE AddOn(BY RAVEN) - v1.2 -
  3.   #--------------------------------------------------------------------------
  4.   #--------------------------------------------------------------------------
  5.   # AddOn - Fases da Lua
  6.   #--------------------------------------------------------------------------
  7.   # * COMO USAR O SISTEMA DE DIA E NOITE - Fases da Lua
  8.   # - BASTA QUE ESTE SCRIPT ESTEJA ACIMA DO MAIN E ABAIXO DO SCRIPT DE DIA E NOITE
  9.   #
  10.   #********************************************************************
  11.   # COMANDOS PUBLICOS PARA SEREM USADOS NO MAPA OU EVENTOS
  12.   #********************************************************************
  13.   # <daynight_troop> moonphase = [id_troop, %] </daynight_troop>
  14.   #                   - Se colocado no espaço de notas do mapa fará com que a
  15.   #                   Tropa com o id "id_troop", mude as chances de aparecer para
  16.   #                   a porcentagem (0~100) em "frequencia", durante o periodo
  17.   #                   especificado em "phase" (nota: so serão alterados
  18.   #                   tropas que estiverem na lista de encontros do mapa  
  19.   #
  20.   # <daynight_step> moonphase = nº_step </daynight_step>
  21.   #                   - Se colocado no espaço de notas do mapa fará com que as
  22.   #                   chances de acontecer um encontro "steps" (menor mais chances)
  23.   #                   durante um periodo especifico "phase"
  24.   #                   caso o periodo não seja especificado, o valor de steps (passos)
  25.   #                   será mantido conforme original
  26.   # $game_daynight.which_phase_moon?
  27.   #                 - Retorna em forma te Texto a fase atual da lua
  28.   # $game_daynight.which_phase_moon_id?(phase=atual)
  29.   #                 - Retorna o id da fase atual da lua
  30.   #--------------------------------------------------------------------------
  31.   # COMANDOS PARA MENSAGENS
  32.   #--------------------------------------------------------------------------
  33.   # \Moon   - Exibe na janela a fase da lua
  34.   #--------------------------------------------------------------------------
  35. $registro = [] if $registro.nil?
  36. $registro << ["BFK DayNight MoonFase",1.2]
  37. #==============================================================================
  38. # ** MODULO BKF
  39. #------------------------------------------------------------------------------
  40. #  Este é o modulo principal para scripts feitos por este core
  41. #==============================================================================
  42. module BFK
  43.   self.modular("BFK Core",1.0)
  44.   self.modular("BFK DayNight",3.3)
  45.   #--------------------------------------------------------------------------
  46.   # * Aqui se encontra todas as variaveis para configuração e instalação
  47.   #--------------------------------------------------------------------------
  48.   module DayNight
  49.     PHASE_MOON_PHASE = 2 # variavel que indica em que fase a lua é visivel
  50.     PHASE_MOON_PHASE_INVERT = false  #inverter fase da lua por hemisferio
  51.     PHASE_MOON_CICLO = CICLOS[2] ## O ciclo da lua se completa no ciclo do Mês.
  52.     PHASE_MOON = ["luna nueva", "luna creciente", "luna llena", "luna menguante"]
  53.     PHASE_MOON_SWITCH = [85,86,87,88] ## As outras Switchs de 1 a 4 são para as phases do sol
  54.     #--------------------------------------------------------------------------
  55.   end
  56. end
  57. #==============================================================================
  58. # ** Window_Base
  59. #------------------------------------------------------------------------------
  60. #  Esta é a superclasse para todas as janelas no jogo.
  61. #==============================================================================
  62. class Window_Base < Window
  63.   alias dnmoon_convert_escape_characters convert_escape_characters
  64.   def convert_escape_characters(text)
  65.     result = dnmoon_convert_escape_characters(text)
  66.     result.gsub!(/\eMoon/i)          { $game_daynight.which_phase_moon? }
  67.     result
  68.   end
  69. end
  70. #==============================================================================
  71. # ** DayNight
  72. #------------------------------------------------------------------------------
  73. #  Esta é a superclasse para todo o controle de tempo no jogo
  74. #==============================================================================
  75. class DayNight
  76.   attr_accessor :phase_moon
  77.   #--------------------------------------------------------------------------
  78.   # * Inicializa o processo acrecentando as fases da lua
  79.   #--------------------------------------------------------------------------
  80.   alias initialize_moon initialize
  81.   def initialize
  82.     initialize_moon
  83.     get_phase_moon(day_ingame)
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Faz o calculo da fase lunar e ativa as switchs
  87.   #--------------------------------------------------------------------------
  88.   def get_phase_moon(day)
  89.     fase = day /(BFK::DayNight::PHASE_MOON_CICLO/BFK::DayNight::PHASE_MOON.count)
  90.     @phase_moon = BFK::DayNight::PHASE_MOON[fase-1]
  91.     value = BFK::DayNight::PHASE_MOON.index(@phase_moon)
  92.     switch_refresh(value,BFK::DayNight::PHASE_MOON_SWITCH)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # * Retonra o nome da fase lunar atual
  96.   #--------------------------------------------------------------------------
  97.   def which_phase_moon?
  98.     @phase_moon.capitalize
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * retona o id da fase da lua
  102.   # :ohase_moon = nil para fase atual, outro nome para pegar seu ID
  103.   #--------------------------------------------------------------------------
  104.   def which_phase_moon_id?(phase_moon=nil)
  105.     moon = (phase_moon == nil) ? @phase_moon : phase_moon
  106.     return BFK::DayNight::PHASE_MOON.index(moon)
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * atualiza as fases da lua
  110.   #--------------------------------------------------------------------------
  111.   alias refresh_moon refresh
  112.   def refresh
  113.     refresh_moon
  114.     get_phase_moon(day_ingame)
  115.   end
  116.  
  117.   #--------------------------------------------------------------------------
  118.   # Ajuda na veificação do status dos steps
  119.   #--------------------------------------------------------------------------
  120.   alias index_stst_moon_steps index_stat_steps
  121.   def index_stat_steps(conteudo)
  122.     return conteudo.index{|value|
  123.         if value[0] == "min" || value[0] == "minute"
  124.           min_ingame == value[1].to_i
  125.         elsif value[0] == "hour" || value[0] == "hora"
  126.           hour_ingame == value[1].to_i
  127.         elsif (value[0] == "day" || value[0] == "dia") && value[2]
  128.           day_ingame == value[1].to_i
  129.         elsif value[0] == "month" || value[0] == "mes"
  130.           month_ingame == value[1].to_i
  131.         elsif value[0] == "year" || value[0] == "ano"
  132.           year_ingame == value[1].to_i
  133.         elsif phase_ingame[1] == value[0]  
  134.           phase_ingame[1] == value[0]
  135.         elsif which_phase_moon_id? == value[0]  
  136.           which_phase_moon_id? == value[0]
  137.       end
  138.     }
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Aqui define o index dos comandos que serão executados
  142.   # * Priorisa os comandos de cima para baixo.
  143.   #--------------------------------------------------------------------------
  144.   alias index_stat_moon_troops index_stat_troops
  145.   def index_stat_troops(conteudo)
  146.     i = 0
  147.     ary =[]
  148.     conteudo.each{|value|
  149.       if min_ingame == value[3].to_i && (value[0] == "min" || value[0] == "minute")
  150.         ary << i
  151.       elsif hour_ingame == value[3].to_i && (value[0] == "hour" || value[0] == "hora")
  152.         ary << i
  153.       elsif day_ingame == value[1].to_i && (value[0] == "day" || value[0] == "dia")
  154.         ary << i
  155.       elsif month_ingame == value[1].to_i && (value[0] == "month" || value[0] == "mes")
  156.         ary << i
  157.       elsif year_ingame == value[1].to_i && (value[0] == "year" || value[0] == "ano")
  158.         ary << i
  159.       elsif phase_ingame[1] == value[0]  
  160.         ary << i
  161.       elsif which_phase_moon_id? == value[0]  
  162.         ary << i
  163.       end
  164.       i += 1
  165.     }
  166.     return ary.reverse!
  167.   end
  168. end
  169.  
  170. #==============================================================================
  171. # ** Display_Phase
  172. #------------------------------------------------------------------------------
  173. #  Esta é a classe que controla o grsfico de periodo no relogio.
  174. #==============================================================================
  175.  
  176. class Display_Phase < Sprite_Base
  177.   #--------------------------------------------------------------------------
  178.   # * Atualiza o sprite no mapa
  179.   #--------------------------------------------------------------------------
  180.   alias update_phase_moon update_phase
  181.   def update_phase
  182.     update_phase_moon
  183.     if BFK::DayNight::PHASE_MOON_PHASE == @phase
  184.       @index_phase_picx = $game_daynight.which_phase_moon_id?
  185.     end
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # * Inicializa o sprite
  189.   #--------------------------------------------------------------------------
  190.   alias update_phase_pic_moon update_phase_pic
  191.   def update_phase_pic
  192.     update_phase_pic_moon
  193.     self.mirror = true if BFK::DayNight::PHASE_MOON_PHASE_INVERT
  194.   end
  195. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement