Advertisement
Vendily

radio

Aug 6th, 2018
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.70 KB | None | 0 0
  1. #===============================================================================
  2. # ** Scene_iPod
  3. # ** Created by xLeD and Harshboy (Scene_Jukebox)
  4. # ** Modified by Mutant Yoshi
  5. #-------------------------------------------------------------------------------
  6. #  This class performs menu screen processing.
  7. #===============================================================================
  8. RADIO_BUENA_SWITCH = 128# Switch if password is unclaimed
  9. RADIO_BUENA_VARIABLE = 101 # variable of password text
  10.  
  11. RADIO_BUENA=[_INTL("Welcome back to Buena's Password!"),
  12.              _INTL("If you're hearing this program, then you're a Trainer looking to get a special prize!"),
  13.              _INTL("All you have to do is remember tonight's password!"),
  14.              _INTL("This week's secret password is..."),
  15.              "",
  16.              _INTL("Now remember that!  All you have to do is head to room 2C of the Neon City Radio Tower and say the password!"),
  17.              _INTL("If you get it right, I'll give you a special prize!"),
  18.              _INTL("Remember to tune in every Saturday, 8 PM!  Don't be late!")]
  19.  
  20. RADIO_LOTTO=[_INTL("Hello once again! Thank-you for tuning into the Lottery Station!"),
  21.              _INTL("If you have a Pokemon with a Trainer ID that matches with our winning Lottery Number, bring it into the Radio Tower in Neon City ASAP."),
  22.              _INTL("This week's winning lottery number is..."),
  23.              "",
  24.              _INTL("Now hurry, because this won't last long. If this is your winning lucky Lottery number, turn it in now before Sunday ends!"),
  25.              _INTL("Thanks, once again, for tuning into the Lottery Station!"),
  26.              _INTL("For those of you that missed it or those just now tuning in, let's repeat this week's winning number."),
  27.              _INTL("Remember: To turn in your winning Lottery number, bring your Pokemon directly to the Radio Tower in Neon City.")]
  28.  
  29. RADIO_MESSAGE_1=[_INTL("almost poisonously"),
  30.                  _INTL("aptly named and"),
  31.                  _INTL("heart-meltingly"),
  32.                  _INTL("provocatively"),
  33.                  _INTL("so flipped out and"),
  34.                  _INTL("so mischievously"),
  35.                  _INTL("so very topically"),
  36.                  _INTL("so unbearably"),
  37.                  _INTL("sure addictively"),
  38.                  _INTL("sweet and adorably"),
  39.                  _INTL("undeniably kind of"),
  40.                  _INTL("wiggly and slickly"),
  41.                  _INTL("well, impressively")]
  42. RADIO_MESSAGE_2=[_INTL("bold, sort of."),
  43.                  _INTL("cute"),
  44.                  _INTL("exciting"),
  45.                  _INTL("friendly."),
  46.                  _INTL("frightening."),
  47.                  _INTL("guarded."),
  48.                  _INTL("hot, hot, hot!"),
  49.                  _INTL("inspiring."),
  50.                  _INTL("lovely."),
  51.                  _INTL("fascinating!"),
  52.                  _INTL("pleasant."),
  53.                  _INTL("powerful."),
  54.                  _INTL("speedy."),
  55.                  _INTL("stimulating."),
  56.                  _INTL("suave & debonair!"),
  57.                  _INTL("weird.")]
  58.  
  59.  
  60. class PokemonGlobalMetadata
  61.   attr_accessor :station
  62.   attr_accessor :dailypkmn
  63. end
  64. class PokemonTemp
  65.   attr_accessor :radioline
  66. end
  67.  
  68. module PBDayNight
  69. # Returns true if it's Time for Buena's show
  70.   class << self
  71.     def isBuenaTime?(time=nil)
  72.       time=pbGetTimeNow if !time
  73.       return (time.hour>=20 and time.wday==6)
  74.     end
  75.   end
  76. end
  77.  
  78. class Scene_Radio
  79.   #-----------------------------------------------------------------------------
  80.   # * Object Initialization
  81.   #     menu_index : command cursor's initial position
  82.   #-----------------------------------------------------------------------------
  83.   def initialize(menu_index = 0)
  84.     @menu_index = menu_index
  85.    
  86.   end
  87.   #-----------------------------------------------------------------------------
  88.   # * Main Processing
  89.   #-----------------------------------------------------------------------------
  90.   def main
  91.     # Make song command window
  92.     fadein = true
  93.     # Makes the text window
  94.     @sprites={}
  95.     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  96.     @viewport.z=99999
  97.     @sprites["background"] = IconSprite.new(0,0)
  98.     @sprites["background"].setBitmap("Graphics/Pictures/radiobg")
  99.     @sprites["background"].z=255
  100.     @sprites["needle"]=IconSprite.new(0,0,@viewport)
  101.     @sprites["needle"].setBitmap("Graphics/Pictures/radioNeedle")
  102.     if !$PokemonGlobal.station
  103.       $PokemonGlobal.station=2
  104.     end
  105.     @sprites["needle"].x=316 + ($PokemonGlobal.station-2)*8
  106.     @sprites["needle"].y=84
  107.     @choices=[
  108.        _INTL("0"),
  109.        _INTL("1"),
  110.        _INTL("2"),
  111.        _INTL("3"),
  112.        _INTL("4"),
  113.        _INTL("5"),
  114.        _INTL("6"),
  115.        _INTL("7"),
  116.        _INTL("8"),
  117.        _INTL("9"),
  118.        _INTL("10")
  119.     ]
  120.     @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Radio"),
  121.        2,-18,128,64,@viewport)
  122.     @sprites["header"].baseColor=Color.new(248,248,248)
  123.     @sprites["header"].shadowColor=Color.new(0,0,0)
  124.     @sprites["header"].windowskin=nil
  125. =begin
  126.     @sprites["command_window"] = Window_CommandPokemon.new(@choices,324)
  127.     @sprites["command_window"].windowskin=nil
  128.     @sprites["command_window"].index = @menu_index
  129.     @sprites["command_window"].height = 64#224
  130.     @sprites["command_window"].width = 324
  131.     @sprites["command_window"].x = 110
  132.     @sprites["command_window"].y = 92
  133.     @sprites["command_window"].z = 256
  134. =end
  135.     @custom=false
  136.     # Execute transition
  137.     Graphics.transition
  138.     # Main loop
  139.     loop do
  140.       # Update game screen
  141.       Graphics.update
  142.       # Update input information
  143.       Input.update
  144.       # Frame update
  145.       update
  146.       # Abort loop if screen is changed
  147.       if $scene != self
  148.         break
  149.       end
  150.     end
  151.     # Prepares for transition
  152.     Graphics.freeze
  153.     # Disposes the windows
  154.     pbDisposeSpriteHash(@sprites)
  155.     @viewport.dispose
  156.   end
  157.   #-----------------------------------------------------------------------------
  158.   # * Frame Update
  159.   #-----------------------------------------------------------------------------
  160.   def update
  161.     # Update windows
  162.     @sprites["needle"].x=316 + ($PokemonGlobal.station-2)*8
  163.     pbUpdateSpriteHash(@sprites)
  164.     update_command
  165.     return
  166.   end
  167.   #-----------------------------------------------------------------------------
  168.   # * Frame Update (when command window is active)
  169.   #-----------------------------------------------------------------------------
  170.   def updateCustom
  171.     if Input.trigger?(Input::B)
  172.       @sprites["command_window"].commands=@choices
  173.       @sprites["command_window"].index=3
  174.       @custom=false
  175.       return
  176.     end
  177.     if Input.trigger?(Input::C)
  178.       $PokemonMap.whiteFluteUsed=false if $PokemonMap
  179.       $PokemonMap.blackFluteUsed=false if $PokemonMap
  180.       if @sprites["command_window"].index==0
  181.         $game_system.setDefaultBGM(nil)
  182.     $game_map.autoplay
  183.       else
  184.         $game_system.setDefaultBGM(
  185.            @sprites["command_window"].commands[@sprites["command_window"].index]
  186.         )        
  187.       end
  188.     end
  189.   end
  190.  
  191.   def update_command
  192.     # If B button was pressed
  193.     if Input.trigger?(Input::B)
  194.       pbPlayCancelSE()
  195.       # Switch to map screen
  196.       $scene = Scene_Pokegear.new
  197.       return
  198.     end
  199.     if Input.trigger?(Input::LEFT)
  200.       $PokemonGlobal.station-=1
  201.       $PokemonGlobal.station = 2 if $PokemonGlobal.station < 2
  202.     end
  203.     if Input.trigger?(Input::RIGHT)
  204.       $PokemonGlobal.station +=1
  205.       $PokemonGlobal.station = 15 if $PokemonGlobal.station >15
  206.     end
  207.     # If C button was pressed
  208.     #if Input.trigger?(Input::C)
  209.     # Branch by command window cursor position
  210.     pbPlayRadioStation($PokemonGlobal.station)
  211.     case $PokemonGlobal.station
  212.     when 4
  213.       @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Oak's Talkshow"),20,104,228,64,@viewport)
  214.     when 7
  215.       if pbIsWeekday(-1,0,2,4,6)
  216.         @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Pokémon March"),20,104,228,64,@viewport)
  217.       else
  218.         @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Pokémon Lullaby"),20,104,228,64,@viewport)
  219.       end
  220.     when 8
  221.       @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Lottery Channel"),20,104,228,64,@viewport)
  222.     when 11
  223.       @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL("Buena's Password"),20,104,228,64,@viewport)
  224.     else
  225.       @sprites["header"]=Window_UnformattedTextPokemon.newWithSize(_INTL(""),20,104,228,64,@viewport)
  226.     end
  227.     return
  228.   end
  229. end
  230.  
  231. def pbPlayRadioStation(stat)
  232.   case stat
  233.   when 4
  234.     pbBGMPlay("Radio - Oak", 100, 100)
  235.     $PokemonMap.whiteFluteUsed=false if $PokemonMap
  236.     $PokemonMap.blackFluteUsed=false if $PokemonMap
  237.     if !$PokemonTemp.radioline or $PokemonTemp.radioline>2
  238.       $PokemonTemp.radioline=0
  239.       $PokemonGlobal.dailypkmn=randpoke
  240.     end
  241.     msgwindow=Kernel.pbCreateMessageWindow
  242.     Kernel.pbMessageDisplay(msgwindow,pokemessage($PokemonGlobal.dailypkmn,$PokemonTemp.radioline)+"\\wtnp[20]")
  243.     Kernel.pbDisposeMessageWindow(msgwindow)
  244.     $PokemonTemp.radioline+=1
  245.   when 7
  246.     if pbIsWeekday(-1,0,2,4,6)
  247.       pbBGMPlay("Radio - March", 100, 100)
  248.       $PokemonMap.whiteFluteUsed=true if $PokemonMap
  249.       $PokemonMap.blackFluteUsed=false if $PokemonMap
  250.     else
  251.       pbBGMPlay("Radio - Lullaby", 100, 100)
  252.       $PokemonMap.blackFluteUsed=true if $PokemonMap
  253.       $PokemonMap.whiteFluteUsed=false if $PokemonMap
  254.     end
  255.   when 8
  256.     pbBGMPlay("DL_Luckyno", 100, 100)
  257.     $PokemonMap.whiteFluteUsed=false if $PokemonMap
  258.     $PokemonMap.blackFluteUsed=false if $PokemonMap
  259.     if !$PokemonTemp.radioline
  260.       $PokemonTemp.radioline=0
  261.     elsif $PokemonTemp.radioline>7
  262.       $PokemonTemp.radioline=2
  263.     end
  264.     pbSetLotteryNumber
  265.     msgwindow=Kernel.pbCreateMessageWindow
  266.     msg=RADIO_LOTTO[$PokemonTemp.radioline]
  267.     if msg==""
  268.       msg = _INTL("{1}!",pbGet(1))
  269.     end
  270.     Kernel.pbMessageDisplay(msgwindow,msg+"\\wtnp[20]")
  271.     Kernel.pbDisposeMessageWindow(msgwindow)
  272.     $PokemonTemp.radioline+=1
  273.   when 11
  274.     pbBGMPlay("pkc_buena", 100, 100)
  275.     $PokemonMap.whiteFluteUsed=false if $PokemonMap
  276.     $PokemonMap.blackFluteUsed=false if $PokemonMap
  277.     if !$PokemonTemp.radioline
  278.       $PokemonTemp.radioline=0
  279.     end
  280.     if $PokemonTemp.radioline<=7 and PBDayNight.isBuenaTime?
  281.       buenapassword
  282.       msgwindow=Kernel.pbCreateMessageWindow
  283.       msg=RADIO_BUENA[$PokemonTemp.radioline]
  284.       if msg==""
  285.         msg = _INTL("{1}!",pbGet(RADIO_BUENA_VARIABLE))
  286.       end
  287.       Kernel.pbMessageDisplay(msgwindow,msg+"\\wtnp[20]")
  288.       Kernel.pbDisposeMessageWindow(msgwindow)
  289.       $PokemonTemp.radioline+=1
  290.     end
  291.   else
  292.     $game_map.autoplay
  293.     $PokemonMap.whiteFluteUsed=false if $PokemonMap
  294.     $PokemonMap.blackFluteUsed=false if $PokemonMap
  295.     if !$PokemonTemp.radioline or $PokemonTemp.radioline>0
  296.       $PokemonTemp.radioline=nil
  297.     end
  298.   end
  299. end
  300.  
  301. def pokemessage(species,line)
  302.   case line
  303.   when 0
  304.     return _INTL("\\xn[Oak]On their travels, some trainers may have seen {1}.",PBSpecies.getName(species))
  305.   when 1 # Location
  306.       encdata=load_data("Data/encounters.dat")
  307.       for enc in encdata.keys.sort_by { rand }
  308.         enctypes=encdata[enc][1]
  309.         if pbFindEncounter(enctypes,species)
  310.           return _INTL("\\xn[Oak]{1} can be found at {2}.",PBSpecies.getName(species),
  311.                                                   pbGetMessage(MessageTypes::MapNames,enc))
  312.         end
  313.       end
  314.       return _INTL("\\xn[Oak]It's not easy to come across {1}.",PBSpecies.getName(species))
  315.   when 2
  316.     return _INTL("\\xn[Oak]In my opinion, {1} is {2} {3}",PBSpecies.getName(species),
  317.                                                   RADIO_MESSAGE_1[rand(RADIO_MESSAGE_1.size)],
  318.                                                   RADIO_MESSAGE_2[rand(RADIO_MESSAGE_2.size)])
  319.   end
  320.  
  321. end
  322.  
  323. def randpoke
  324.   ret=rand(PBSpecies.maxValue - 1) + 1
  325.   # Implement blacklists here
  326.   while !$Trainer.seen[ret]
  327.     ret=rand(PBSpecies.maxValue - 1) + 1
  328.   end
  329.   return ret
  330. end
  331.  
  332. def buenapassword
  333.   if !$game_variables[RADIO_BUENA_VARIABLE] or $game_variables[RADIO_BUENA_VARIABLE].numeric?
  334.     var=nil
  335.     case rand(4)
  336.     when 0 # Pokemon
  337.       var=PBSpecies.getName(rand(PBSpecies.maxValue - 1) + 1)
  338.     when 1 # Types
  339.       var=rand(PBTypes.maxValue)
  340.       while var == 9
  341.         var=rand(PBTypes.maxValue)
  342.       end
  343.       var=PBTypes.getName(var)
  344.     when 2 # Items
  345.       var=PBItems.getName(rand(PBItems.maxValue - 1) + 1)
  346.     when 3 # Abilities
  347.       var=PBAbilities.getName(rand(PBAbilities.maxValue - 1) + 1)
  348.     end
  349.     $game_variables[RADIO_BUENA_VARIABLE]=var
  350.   end
  351. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement