M3rein

Easy Intro Script

May 26th, 2017
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.67 KB | None | 0 0
  1. # The path to the Pokémon that will be shown at the near-ending of the intro.
  2. POKEMON_PATH = "Pictures/introMarill"
  3.  
  4. # The background of the main part of the intro.
  5. BACKGROUND_PATH = "Pictures/introbg"
  6.  
  7. # The path to the Professor's sprite.
  8. PROFESSOR_PATH = "Pictures/introOak"
  9. # The path to the base the Professor and the Pokémon stand on.
  10. PROFESSOR_BASE_PATH = "Pictures/introbase"
  11.  
  12. # The path to the music played during the intro. Located in Audio/BGM.
  13. INTRO_MUSIC_PATH = "begin"
  14.  
  15. # What the Professor says at the start of the intro.
  16. PROFESSOR_SPEECH_START = [
  17.    "Hello! Sorry to keep you waiting!",
  18.    :WAIT_20,
  19.    "Welcome to the world of Pokémon!",
  20.    "My name is Oak.",
  21.    "People call me the Pokémon Professor.",
  22.    :WAIT_16
  23. ]
  24.  
  25. # The gender choices along with their sprites.
  26. GENDERS = [
  27.    ["a", "boy", "Pictures/introBoy"],
  28.    ["a", "girl", "Pictures/introGirl"]
  29. ]
  30.  
  31. # Whether the Professor should offer basic help to the Player or not.
  32. PROFESSOR_SPEECH_OFFER_HELP = true
  33.  
  34. # The path to the background that will be shown in the "Adventure" help option.
  35. PROFESSOR_SPEECH_HELP_BACKGROUND = "Pictures/helpadventurebg"
  36. # The text that will be displayed over the background above.
  37. PROFESSOR_SPEECH_ADVENTURE = [
  38.    "You are about to enter a world where you will embark on a grand adventure of your very own.",
  39.    "Speak to people and check things wherever you go, be it in towns, roads or caves.",
  40.    "Gather information and hints from every possible source.",
  41.    "New paths will open to you when you help people in need, overcome challenges, and solve mysteries.",
  42.    "At times, you will be challenged by others to a battle.",
  43.    "At other times, wild creatures may stand in your way. By overcoming such hurdles, you will gain great power.",
  44.    "However, your adventure is not solely about becoming powerful.",
  45.    "On your travels, we hope that you will meet countless people and, through them, achieve personal growth.",
  46.    "This is the most important objective of this adventure."
  47. ]
  48.  
  49. # What the Professor says at the end of his speech.
  50. PROFESSOR_SPEECH_END = [
  51.    "This world is widely inhabited by creatures we call Pokémon.",
  52.    "People and Pokémon live together by supporting each other.",
  53.    "At times, we play with Pokémon, and at other times, we battle with them.",
  54.    :FADE_OUT_POKEMON,
  55.    :WAIT_4,
  56.    "But despite our closeness, we don't know everything about Pokémon yet.",
  57.    "There are still many mysteries to solve.",
  58.    "That's why I study Pokémon every day.",
  59.    :WAIT_10,
  60.    :ASK_GENDER,
  61.    :WAIT_20,
  62.    "\\PN, are you ready?",
  63.    "Your very own Pokémon story is about to unfold.",
  64.    "You'll face fun times and tough challenges.",
  65.    "A world of dreams and adventures with Pokémon awaits! Let's go!",
  66.    :WAIT_30,
  67.    "\\bEnjoy the Starter Kit. Give credit when using it." # = Essentials!
  68. ]
  69.  
  70. #Miscellaneous text messages
  71. PROFESSOR_SPEECH_NEED_HELP = "If you need help, I am certainly capable of giving it."
  72. ASK_NAME_MESSAGE = "Now what did you say your name was?"
  73. CONFIRM_PLAYER_MESSAGE = "So this is you, \\PN?"
  74.  
  75.  
  76. def pbIntro
  77.   raise _INTL("Cannot have less than two genders as option") if GENDERS.size < 2
  78.   pbToneChangeAll(Tone.new(0,0,0,0),20)
  79.   viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  80.   viewport.z = 99999
  81.   sprites = {}
  82.   sprites[:BG] = Sprite.new(viewport)
  83.   bg = sprites[:BG]
  84.   bg.bitmap = Bitmap.new("Graphics/#{BACKGROUND_PATH}")
  85.   bg.opacity = 0
  86.   bg.z = -1
  87.  
  88.   sprites[:BASE] = Sprite.new(viewport)
  89.   base = sprites[:BASE]
  90.   base.bitmap = Bitmap.new("Graphics/#{PROFESSOR_BASE_PATH}")
  91.   base.opacity = 0
  92.   base.ox = base.bitmap.width / 2
  93.   base.x = Graphics.width / 2
  94.   base.y = Graphics.height / 2 + 40
  95.   base.z = 0
  96.  
  97.   sprites[:PROF] = Sprite.new(viewport)
  98.   prof = sprites[:PROF]
  99.   prof.bitmap = Bitmap.new("Graphics/#{PROFESSOR_PATH}")
  100.   prof.opacity = 0
  101.   prof.ox = prof.bitmap.width / 2
  102.   prof.oy = prof.bitmap.height
  103.   prof.x = Graphics.width / 2 - 8
  104.   prof.y = Graphics.height / 2 + 64
  105.   prof.z = 1
  106.   pbBGMFade(2.0)
  107.   pbBGMPlay(INTRO_MUSIC_PATH)
  108.   10.times do
  109.     Graphics.update
  110.     bg.opacity += 25.5
  111.   end
  112.   32.times { Graphics.update }
  113.   32.times { Graphics.update; base.opacity += 8; prof.opacity += 8 }
  114.   32.times { Graphics.update }
  115.  
  116.   for msg in PROFESSOR_SPEECH_START
  117.     if msg.to_s.include?("WAIT")
  118.       pbWait(msg.to_s.split('_')[1].to_i)
  119.     else
  120.       Kernel.pbMessage(_INTL(msg))
  121.     end
  122.   end
  123.   loop do
  124.     break if !PROFESSOR_SPEECH_OFFER_HELP
  125.     choice = Kernel.pbMessage(_INTL(PROFESSOR_SPEECH_NEED_HELP),[_INTL("Controls"),
  126.                 _INTL("Adventure"),_INTL("No Info Needed")])
  127.     if choice == 0
  128.       pbControlHelp
  129.     elsif choice == 1
  130.       Kernel.pbMessage(_INTL("Well then, without further ado..."))
  131.       sprites[:BG_2] = Sprite.new(@viewport)
  132.       bg2 = sprites[:BG_2]
  133.       bg2.bitmap = Bitmap.new("Graphics/#{PROFESSOR_SPEECH_HELP_BACKGROUND}")
  134.       bg2.opacity = 0
  135.       16.times {
  136.          Graphics.update
  137.          bg.opacity -= 16
  138.          bg2.opacity += 16
  139.          prof.opacity -= 16
  140.          base.opacity -= 16
  141.       }
  142.       $game_system.message_position = 1
  143.       $game_system.message_frame = 1
  144.       for msg in PROFESSOR_SPEECH_ADVENTURE
  145.         if msg.to_s.include?("WAIT")
  146.           pbWait(msg.to_s.split('_')[1].to_i)
  147.         else
  148.           Kernel.pbMessage(_INTL("<ac>#{msg}</ac>"))
  149.         end
  150.       end
  151.       $game_system.message_position = 2
  152.       $game_system.message_frame = 0
  153.       16.times {
  154.          Graphics.update
  155.          bg.opacity += 16
  156.          bg2.opacity -= 16
  157.          prof.opacity += 16
  158.          base.opacity += 16
  159.       }
  160.     else
  161.       break
  162.     end
  163.   end
  164.   20.times { Graphics.update }
  165.  
  166.   sprites[:POKE] = Sprite.new(viewport)
  167.   poke = sprites[:POKE]
  168.   poke.bitmap = Bitmap.new("Graphics/#{POKEMON_PATH}")
  169.   poke.ox = poke.bitmap.width / 2
  170.   poke.oy = poke.bitmap.height
  171.   poke.x = Graphics.width / 2
  172.   poke.y = Graphics.height / 2 + 64
  173.   poke.z = 2
  174.   poke.opacity = 0
  175.  
  176.   16.times { Graphics.update; prof.opacity -= 16}
  177.   16.times { Graphics.update; poke.opacity += 16 }
  178.  
  179.   for msg in PROFESSOR_SPEECH_END
  180.     if msg.to_s.include?("WAIT")
  181.       pbWait(msg.to_s.split('_')[1].to_i)
  182.     elsif msg == :FADE_OUT_POKEMON
  183.       16.times {
  184.          Graphics.update
  185.          prof.opacity += 16
  186.          poke.opacity -= 16
  187.       }
  188.     elsif msg == :ASK_GENDER
  189.       sprites[:CHAR] = Sprite.new(viewport)
  190.       char = sprites[:CHAR]
  191.       genders = []
  192.       for gender in GENDERS
  193.         genders.push(_INTL(gender[1].capitalize))
  194.       end
  195.       msg = "Are you "
  196.       if GENDERS.size > 2
  197.         for i in 0...GENDERS.size
  198.           if i != GENDERS.size - 1
  199.             msg += "#{GENDERS[i][0]} #{GENDERS[i][1]}, "
  200.           else
  201.             msg += "or #{GENDERS[i][0]} #{GENDERS[i][1]}?"
  202.           end
  203.         end
  204.       else
  205.         msg += "#{GENDERS[0][0]} #{GENDERS[0][1]} or #{GENDERS[1][0]} #{GENDERS[1][1]}?"
  206.       end
  207.       32.times {
  208.          Graphics.update
  209.          prof.opacity -= 8
  210.          base.opacity -= 8
  211.       }
  212.       loop do
  213.         pbWait(4)
  214.         gender = Kernel.pbMessage(_INTL(msg), genders)
  215.         pbChangePlayer(gender)
  216.         char.bitmap = Bitmap.new("Graphics/#{GENDERS[gender][2]}")
  217.         char.ox = char.bitmap.width / 2
  218.         char.oy = char.bitmap.height
  219.         char.x = Graphics.width / 2
  220.         char.y = Graphics.height / 2 + 64
  221.         char.opacity = 0
  222.         16.times { Graphics.update; char.opacity += 16; base.opacity += 16 }
  223.         Kernel.pbMessage(_INTL(ASK_NAME_MESSAGE))
  224.         pbTrainerName
  225.         if Kernel.pbConfirmMessage(_INTL(CONFIRM_PLAYER_MESSAGE))
  226.           break
  227.         else
  228.           32.times { Graphics.update; char.opacity -= 8; base.opacity -= 8}
  229.         end
  230.       end
  231.     else
  232.       Kernel.pbMessage(_INTL(msg))
  233.     end
  234.   end
  235.   pbFadeOutAndHide(sprites) { pbBGMFade(2.0) }
  236.   pbDisposeSpriteHash(sprites)
  237.   viewport.dispose
  238. end
  239.  
  240. def pbControlHelp
  241.   vp=Viewport.new(0,0,Graphics.width,Graphics.height)
  242.   vp.z=99999; sp={}
  243.   sp[:bg]=Sprite.new(vp)
  244.   sp[:bg].bitmap=Bitmap.new("Graphics/Pictures/helpbg")
  245.   sp[:bg].opacity=0
  246.   sp[:bmp]=BitmapSprite.new(Graphics.width, Graphics.height, vp)
  247.   sp[:bmp].opacity=0
  248.   bmp=sp[:bmp].bitmap
  249.   pbSetSystemFont(bmp)
  250.   b=Color.new(255,255,255)
  251.   s=Color.new(166,166,166)
  252.   drawTextEx(bmp,112,32,400,2,"Moves the main character. Also used to scroll through list entries.",b,s)
  253.   sp[:dir]=Sprite.new(vp)
  254.   sp[:dir].bitmap=Bitmap.new("Graphics/Pictures/helpArrowKeys")
  255.   sp[:dir].x = 18;sp[:dir].y=42;sp[:dir].opacity=0
  256.   drawTextEx(bmp,112,110,400,2,"Used to confirm a choice, check things, and talk to people.",b,s)
  257.   sp[:c]=Sprite.new(vp)
  258.   sp[:c].bitmap=Bitmap.new("Graphics/Pictures/helpCkey")
  259.   sp[:c].x=34;sp[:c].y=120;sp[:c].opacity=0
  260.   drawTextEx(bmp,112,188,400,2,"Used to exit, cancel a choice or mode, and open the pause menu.",b,s)
  261.   sp[:x]=Sprite.new(vp)
  262.   sp[:x].bitmap=Bitmap.new("Graphics/Pictures/helpXkey")
  263.   sp[:x].x=34;sp[:x].y=198;sp[:x].opacity=0
  264.   drawTextEx(bmp,112,266,400,2,"Hold down while walking to run.",b,s)
  265.   sp[:z]=Sprite.new(vp)
  266.   sp[:z].bitmap=Bitmap.new("Graphics/Pictures/helpZkey")
  267.   sp[:z].x=34;sp[:z].y=262;sp[:z].opacity=0
  268.   drawTextEx(bmp,112,320,400,2,"Press to use a registered Key Item.",b,s)
  269.   sp[:f5]=Sprite.new(vp)
  270.   sp[:f5].bitmap=Bitmap.new("Graphics/Pictures/helpF5key")
  271.   sp[:f5].x=34;sp[:f5].y=316;sp[:f5].opacity=0
  272.   16.times{Graphics.update;sp.each{|k,v|v.opacity+=16}}
  273.   loop {
  274.     Input.update
  275.     Graphics.update
  276.     if Input.trigger?(Input::C) || Input.trigger?(Input::B)
  277.       16.times{Graphics.update;sp.each{|k,v|v.opacity-=16}}
  278.       pbDisposeSpriteHash(sp)
  279.       vp.dispose
  280.       break
  281.     end
  282.   }
  283. end
Add Comment
Please, Sign In to add comment