Advertisement
dsiver144

DSI Dungeon Infomation

Mar 11th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.75 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Dungeon Infomation
  3. # -- Last Updated: 2017.03.11
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: DSI-Bitmap
  7. # -- Commission for: MHRob
  8. #==============================================================================
  9. $imported = {} if $imported.nil?
  10. $imported["DSI-DungeonInfo"] = true
  11. #==============================================================================
  12. # + Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2017.02.28 - Finish first version.
  15. # 2017.03.11 - Add an option to hide hard mode
  16. #==============================================================================
  17. # + Instructions
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # To install this script, open up your script editor and copy/paste this script
  20. # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
  21. # Remember to put this script below: DSI-Bitmap.
  22. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. # Script Call:
  24. #  show_dungeon_scene(id) # Open Scene with specific dungeon ID (See below)
  25. #==============================================================================
  26.     module DSIVER144
  27.         module DUNGEON_INFO
  28.      
  29.       COMMANDS = {} # Don't remove this line!
  30.       COMMANDS[1] = ["Enter Dungeon (Normal)", 1606] # [Name, Icon_index]
  31.       COMMANDS[2] = ["Enter Dungeon (Hard)", 1699]    # [Name, Icon_index]
  32.       COMMANDS[3] = ["Exit", 137]                    # [Name, Icon_index]
  33.      
  34.       SWITCH_PAGE_TEXT = "\\i[1609]:Switch Page"
  35.       OTHER_BUTTONS_TEXT = "\\i[1600]:Choose - \\i[1602]:Cancel"
  36.       OTHER_BUTTONS_MARGIN = 170
  37.      
  38.       SWITCH_PAGE_SE = ["Confirm2 (Final Fantasy 7).wav", 100, 100]
  39.       SCENE_BACKGROUND = "StarlitSky" # Located in Parallax Folder. Set to false if don't want to use it.
  40.      
  41.       TEXTS = {} # Don't remove this line!
  42.       TEXTS[:description_header]  = "\\c[5]Dungeon Description: \\c[0]"
  43.       TEXTS[:general_info_header] = "\\c[5]General Infomation: \\c[0]"
  44.      
  45.       DUNGEONS = {} # Don't remove this line!
  46.       #-------------------------------------------------------------------------
  47.       # -> DUNGEONS[dungeon_id] <-
  48.       #-------------------------------------------------------------------------
  49.       DUNGEONS[1] = {} # Don't remove this line!
  50.       DUNGEONS[1][:name] = ["Ice Caves", 3] # [Name , Color Code]
  51.       DUNGEONS[1][:normal_cme] = 25 # Normal Dungeon Common Event
  52.      
  53.       # Delete below line then there is no hard mode for this dungeon!
  54.       DUNGEONS[1][:hard_cme] = 26   # Hard Dungeon Common Event
  55.      
  56.       DUNGEONS[1][:require_item] = [15,5] # [Item_ID, Number]
  57.       DUNGEONS[1][:picture] = "BlueSky" # Located in Parallaxes Folder (226x200). It will automatically resize to 226x200.
  58.       DUNGEONS[1][:description] = "There are a series of Man made Ice Caves that were made long ago in the hopes of finding a path to the
  59. legendary Ice Palace. Though, Deep within the Ice Caves lie the ancient Ice Caverns, said to lead to the Ice Palace of the forgotten Snow Queen."
  60.       DUNGEONS[1][:description_font] = [16,20] # [Font size, Line Height]
  61.       DUNGEONS[1][:gerenal_info] = {} # Don't remove this line!
  62.       DUNGEONS[1][:gerenal_info][:tools] = [13,14,15,16,17,18] # Item ID of Tools
  63.       DUNGEONS[1][:gerenal_info][:font] = [15,18] # [Font size, Line Height]
  64.       DUNGEONS[1][:gerenal_info][:texts] = [ # Don't remove this line!
  65.         ["\\c[5]Expected Monster\\c[0]:", "Ice Slime, Ice Hell Flower, ect"],
  66.         ["\\c[6]Common Element Found\\c[0]:", "Ice Mage Cards"],
  67.         ["\\c[7]Recommended Cards\\c[0]:", "Fire Mage Cards"],
  68.         ["\\c[21]Number of Areas\\c[0]:", "6+"],
  69.         ["\\c[9]Available Altars\\c[0]:", "Ice"],
  70.         ["\\c[10]Save Point\\c[0]:", "Yes"],
  71.         ["\\c[11]Teleportation Allowed\\c[0]:", "Yes"],
  72.         ["\\c[12]Special Monster Encounters\\c[0]:", "Yes"],
  73.         ["\\c[13]Quest Available\\c[0]:", "Yes"],
  74.       ] # Don't remove this line!
  75.       DUNGEONS[2] = {} # Don't remove this line!
  76.       DUNGEONS[2][:name] = ["Earth", 3] # [Name , Color Code]
  77.       DUNGEONS[2][:normal_cme] = 25 # Normal Dungeon Common Event
  78.       DUNGEONS[2][:hard_cme] = 26   # Hard Dungeon Common Event
  79.       DUNGEONS[2][:require_item] = [15,10] # [Item_ID, Number]
  80.       DUNGEONS[2][:picture] = "Dungeon1" # Located in Parallaxes Folder (226x200). It will automatically resize to 226x200.
  81.       DUNGEONS[2][:description] = "Something"
  82.       DUNGEONS[2][:description_font] = [16,20] # [Font size, Line Height]
  83.       DUNGEONS[2][:gerenal_info] = {} # Don't remove this line!
  84.       DUNGEONS[2][:gerenal_info][:tools] = [14,15,16,17,18,19,20] # Item ID of Tools
  85.       DUNGEONS[2][:gerenal_info][:font] = [15,18] # [Font size, Line Height]
  86.       DUNGEONS[2][:gerenal_info][:texts] = [ # Don't remove this line!
  87.         ["\\c[5]Expected Monster\\c[0]:", "Ice Slime, Ice Hell Flower, ect"],
  88.         ["\\c[6]Common Element Found\\c[0]:", "Ice Mage Cards"],
  89.         ["\\c[7]Recommended Cards\\c[0]:", "Fire Mage Cards"],
  90.         ["\\c[21]Number of Areas\\c[0]:", "6+"],
  91.         ["\\c[9]Available Altars\\c[0]:", "Ice"],
  92.         ["\\c[10]Save Point\\c[0]:", "Yes"],
  93.         ["\\c[11]Teleportation Allowed\\c[0]:", "Yes"],
  94.         ["\\c[12]Special Monster Encounters\\c[0]:", "Yes"],
  95.         ["\\c[13]Quest Available\\c[0]:", "Yes"],
  96.       ] # Don't remove this line!
  97.       #-------------------------------------------------------------------------
  98.      
  99.         end # DUNGEON_INFO
  100.    
  101.     end # DSIVER144
  102.  
  103.   class Game_Interpreter
  104.     #-------------------------------------------------------------------------
  105.     # * new method: show_dungeon_scene
  106.     #-------------------------------------------------------------------------
  107.     def show_dungeon_scene(id)
  108.       SceneManager.call(Scene_DungeonInfo)
  109.       SceneManager.scene.prepare(id)
  110.     end
  111.   end # Game_Interpreter
  112.    
  113.     class Scene_DungeonInfo < Scene_Base
  114.         include DSIVER144::DUNGEON_INFO
  115.     #-------------------------------------------------------------------------
  116.     # * new method: prepare
  117.     #-------------------------------------------------------------------------
  118.     def prepare(id)
  119.       @dungeon_id = id
  120.     end
  121.     #-------------------------------------------------------------------------
  122.     # * new method: start
  123.     #-------------------------------------------------------------------------
  124.         def start
  125.       super
  126.       @dungeon_id ||= 1
  127.       create_background_image
  128.       create_main_windows
  129.         end
  130.     #-------------------------------------------------------------------------
  131.     # * new method: create_background_image
  132.     #-------------------------------------------------------------------------
  133.     def create_background_image
  134.       @background_image = Sprite.new
  135.       if SCENE_BACKGROUND != false
  136.         begin
  137.           @background_image.bitmap = Cache.parallax(SCENE_BACKGROUND)
  138.         rescue
  139.           @background_image.bitmap = SceneManager.background_bitmap
  140.           @background_image.color.set(16, 16, 16, 128)
  141.         end
  142.       else
  143.         @background_image.bitmap = SceneManager.background_bitmap
  144.         @background_image.color.set(16, 16, 16, 128)
  145.       end
  146.     end
  147.     #-------------------------------------------------------------------------
  148.     # * new method: create_main_windows
  149.     #-------------------------------------------------------------------------
  150.     def create_main_windows
  151.       @title_window = Window_Base.new(0,0,Graphics.width,48)
  152.       @title_window.change_color(@title_window.text_color(DUNGEONS[@dungeon_id][:name][1]))
  153.       @title_window.draw_text(0,0,@title_window.contents_width,@title_window.contents_height,DUNGEONS[@dungeon_id][:name][0],1)
  154.       @help_window = Window_DungeonInfoHelp.new
  155.       @command_window = Window_DungeonCommand.new(0,0,@dungeon_id)
  156.       @command_window.y = @help_window.y - @command_window.height
  157.       @command_window.set_handler(:normal, method(:process_normal))
  158.       @command_window.set_handler(:hard, method(:process_hard))
  159.       @command_window.set_handler(:cancel, method(:return_scene))
  160.       wh = Graphics.height - @command_window.height - @title_window.height - @title_window.height
  161.       @picture_window = Window_DungeonPicture.new(0,0,@command_window.width,wh) # 226 200
  162.       @picture_window.y = @help_window.height
  163.       wx = @picture_window.width
  164.       wy = @picture_window.y
  165.       ww = Graphics.width - @picture_window.width
  166.       wh = @picture_window.height + @command_window.height
  167.       @description_window = Window_DungeonDescription.new(wx,wy,ww,wh)
  168.       @picture_window.draw_picture(@dungeon_id)
  169.       @description_window.draw_description(@dungeon_id)
  170.       @info_window = Window_DungeonInfo.new(wx,wy,ww,wh)
  171.       @info_window.x = Graphics.width
  172.       @info_window.draw_general_info(@dungeon_id)
  173.       @page = 1
  174.     end
  175.     #-------------------------------------------------------------------------
  176.     # * new method: process_normal
  177.     #-------------------------------------------------------------------------
  178.     def process_normal
  179.       $game_temp.reserve_common_event(DUNGEONS[@dungeon_id][:normal_cme])
  180.       SceneManager.goto(Scene_Map)
  181.     end
  182.     #-------------------------------------------------------------------------
  183.     # * new method: process_hard
  184.     #-------------------------------------------------------------------------
  185.     def process_hard
  186.       item = $data_items[DUNGEONS[@dungeon_id][:require_item][0]]
  187.       num = DUNGEONS[@dungeon_id][:require_item][1]
  188.       $game_party.lose_item(item, num)
  189.       $game_temp.reserve_common_event(DUNGEONS[@dungeon_id][:hard_cme])
  190.       SceneManager.goto(Scene_Map)
  191.     end
  192.     #-------------------------------------------------------------------------
  193.     # * new method: easeInOutQuad
  194.     #-------------------------------------------------------------------------
  195.     def easeInOutQuad(t, b, c, d)
  196.       t = t / (d/2.0)
  197.       if (t < 1)
  198.         return c/2*t*t + b
  199.       end
  200.       t -= 1
  201.       return -c/2.0 * (t*(t-2) - 1) + b
  202.     end
  203.     #-------------------------------------------------------------------------
  204.     # * new method: update_swith_page
  205.     #-------------------------------------------------------------------------
  206.     def update_swith_page
  207.       RPG::SE.new(*SWITCH_PAGE_SE).play
  208.       if @page == 1
  209.         start_x = Graphics.width - @description_window.width
  210.         des_x = Graphics.width - start_x
  211.         start_time = Graphics.frame_count
  212.         while (current_time = Graphics.frame_count - start_time) < 45
  213.           @description_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  214.           Graphics.update
  215.           @command_window.update
  216.         end
  217.         start_x = Graphics.width
  218.         des_x = - @description_window.width
  219.         start_time = Graphics.frame_count
  220.         while (current_time = Graphics.frame_count - start_time) < 45
  221.           @info_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  222.           Graphics.update
  223.           @command_window.update
  224.         end
  225.         @page = 2
  226.       else
  227.         start_x = Graphics.width - @description_window.width
  228.         des_x = Graphics.width - start_x
  229.         start_time = Graphics.frame_count
  230.         while (current_time = Graphics.frame_count - start_time) < 45
  231.           @info_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  232.           Graphics.update
  233.           @command_window.update
  234.         end
  235.         start_x = Graphics.width
  236.         des_x = - @description_window.width
  237.         start_time = Graphics.frame_count
  238.         while (current_time = Graphics.frame_count - start_time) < 45
  239.           @description_window.x = easeInOutQuad(current_time, start_x, des_x, 45)
  240.           Graphics.update
  241.           @command_window.update
  242.         end
  243.         @page = 1
  244.       end
  245.     end
  246.         #-------------------------------------------------------------------------
  247.     # * new method: update
  248.     #-------------------------------------------------------------------------
  249.         def update
  250.             super
  251.       if Input.trigger?(:X)
  252.         update_swith_page
  253.       end
  254.         end
  255.     #-------------------------------------------------------------------------
  256.     # * new method: terminate
  257.     #-------------------------------------------------------------------------
  258.     def terminate
  259.       super
  260.       @background_image.bitmap.dispose
  261.       @background_image.dispose
  262.     end
  263.     end # Scene_DungeonInfo
  264.  
  265.   class Window_DungeonInfoHelp < Window_Base
  266.     include DSIVER144::DUNGEON_INFO
  267.     #-------------------------------------------------------------------------
  268.     # * method: draw_info
  269.     #-------------------------------------------------------------------------
  270.     def initialize
  271.       super(0,Graphics.height-48,Graphics.width,48)
  272.       refresh
  273.     end
  274.     #--------------------------------------------------------------------------
  275.     # * Draw Text with Control Characters
  276.     #--------------------------------------------------------------------------
  277.     def draw_text_ex(x, y, text)
  278.       text = convert_escape_characters(text)
  279.       pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  280.       process_character(text.slice!(0, 1), text, pos) until text.empty?
  281.     end
  282.     #-------------------------------------------------------------------------
  283.     # * new method: refresh
  284.     #-------------------------------------------------------------------------
  285.     def refresh(enable_altar=false)
  286.       contents.clear
  287.       change_color(normal_color,true)
  288.       draw_text_ex(0,0,SWITCH_PAGE_TEXT)
  289.       draw_text_ex(contents_width - OTHER_BUTTONS_MARGIN,0,OTHER_BUTTONS_TEXT)
  290.     end
  291.   end # Window_CursedHelp
  292.  
  293.   class Window_DungeonPicture < Window_Base
  294.     include DSIVER144::DUNGEON_INFO
  295.     #-------------------------------------------------------------------------
  296.     # * new method: terminate
  297.     #-------------------------------------------------------------------------
  298.     def draw_picture(dungeon_id)
  299.       contents.clear
  300.       file_name = DUNGEONS[dungeon_id][:picture]
  301.       pic_bitmap = Cache.parallax(file_name)
  302.       des_rect = Rect.new(0,0,contents_width,contents_height)
  303.       contents.stretch_blt(des_rect,pic_bitmap,pic_bitmap.rect)
  304.     end
  305.   end # Window_DungeonPicture
  306.  
  307.   class Window_DungeonDescription < Window_Base
  308.     include DSIVER144::DUNGEON_INFO
  309.     #-------------------------------------------------------------------------
  310.     # * new method: terminate
  311.     #-------------------------------------------------------------------------
  312.     def draw_description(dungeon_id)
  313.       contents.clear
  314.       desc_text = TEXTS[:description_header]
  315.       desc = DUNGEONS[dungeon_id][:description]
  316.      
  317.       x = 0; y = 0;
  318.       contents.draw_text_ex(x,y,desc_text,false,17)
  319.       y += 20
  320.       contents.fill_rect(x,y,contents_width,1,Color.new(64,64,255))
  321.       y += 5
  322.       contents.turn_on_wordwraping
  323.       contents.font.size = DUNGEONS[dungeon_id][:description_font][0]
  324.       contents.draw_text_ex(x,y,desc,false,DUNGEONS[dungeon_id][:description_font][1])
  325.     end
  326.   end # Window_DungeonDescription
  327.  
  328.   class Window_DungeonInfo < Window_Base
  329.     include DSIVER144::DUNGEON_INFO
  330.     #-------------------------------------------------------------------------
  331.     # * new method: terminate
  332.     #-------------------------------------------------------------------------
  333.     def draw_general_info(dungeon_id)
  334.       contents.clear
  335.       contents.turn_on_wordwraping
  336.       desc_text = TEXTS[:general_info_header]
  337.       general_info = DUNGEONS[dungeon_id][:gerenal_info]
  338.       x = 0; y = 0;
  339.       contents.draw_text_ex(x,y,desc_text,false,17)
  340.       y += 20
  341.       contents.fill_rect(x,y,contents_width,1,Color.new(64,64,255))
  342.       y += 5
  343.       if general_info[:tools]
  344.         contents.draw_text_ex(x,y,"\\c[20]Tools for Full Exploration\\c[0]: ",false,17)
  345.         y += 24
  346.         start_x = 0.5*(contents_width - general_info[:tools].size * 35)
  347.         x = start_x
  348.         general_info[:tools].each_with_index do |id,index|
  349.           draw_icon($data_weapons[id].icon_index, x, y)
  350.           x += 35;
  351.         end
  352.       end
  353.       y += 32
  354.       x = 0
  355.       contents.font.size = general_info[:font][0]
  356.       if general_info[:texts]
  357.         st = ""
  358.         general_info[:texts].each do |line|
  359.           st += line[0] + " " + line[1] + "\n"
  360.         end
  361.         contents.draw_text_ex(x,y,st,false,general_info[:font][1])
  362.       end
  363.     end
  364.   end # Window_DungeonInfo
  365.  
  366.   class Window_DungeonCommand < Window_Command
  367.     include DSIVER144::DUNGEON_INFO
  368.     #--------------------------------------------------------------------------
  369.     # * new method: initialize
  370.     #--------------------------------------------------------------------------
  371.     def initialize(x,y,dungeon_id)
  372.       @dungeon_id = dungeon_id
  373.       super(x,y)
  374.     end
  375.     #--------------------------------------------------------------------------
  376.     # * new method: window_width
  377.     #--------------------------------------------------------------------------
  378.     def window_width
  379.       return 250
  380.     end
  381.     #--------------------------------------------------------------------------
  382.     # * new method: add_command
  383.     #--------------------------------------------------------------------------
  384.     def add_command(name, symbol, icon_index = nil, enabled = true, ext = nil)
  385.       @list.push({:name=>name, :symbol=>symbol, :icon_index=>icon_index, :enabled=>enabled, :ext=>ext})
  386.     end
  387.     #--------------------------------------------------------------------------
  388.     # * new method: add_command
  389.     #--------------------------------------------------------------------------
  390.     def command_name(index)
  391.       @list[index][:name]
  392.     end
  393.     #--------------------------------------------------------------------------
  394.     # * new method: draw_item
  395.     #--------------------------------------------------------------------------
  396.     def draw_item(index)
  397.       change_color(normal_color, command_enabled?(index))
  398.       rect = item_rect_for_text(index)
  399.       if command_icon(index)
  400.         draw_icon(command_icon(index),rect.x, rect.y)
  401.         rect.x += 26
  402.       end
  403.       draw_text(rect, command_name(index), 0)
  404.     end
  405.     #--------------------------------------------------------------------------
  406.     # * new method: command_icon
  407.     #--------------------------------------------------------------------------
  408.     def command_icon(index)
  409.       @list[index][:icon_index]
  410.     end
  411.     #--------------------------------------------------------------------------
  412.     # * Get Window Height
  413.     #--------------------------------------------------------------------------
  414.     def window_height
  415.       fitting_height(3)
  416.     end
  417.     #--------------------------------------------------------------------------
  418.     # * new method: make_command_list
  419.     #--------------------------------------------------------------------------
  420.     def make_command_list
  421.       key = [:normal,:hard,:cancel]
  422.       hide_stt = DUNGEONS[@dungeon_id].has_key?(:hard_cme)
  423.       if DUNGEONS[@dungeon_id].has_key?(:require_item)
  424.         item = $data_items[DUNGEONS[@dungeon_id][:require_item][0]]
  425.         hard_stt = $game_party.item_number(item) >= DUNGEONS[@dungeon_id][:require_item][1]
  426.       else
  427.         hard_stt = false
  428.       end
  429.       COMMANDS.values.each_with_index do |command,index|
  430.         if key[index] != :hard
  431.           add_command(command[0],key[index],command[1])
  432.         elsif hide_stt
  433.           add_command(command[0],key[index],command[1],hard_stt)
  434.         end # end if
  435.       end # end loop
  436.     end # end make_command_list
  437.    
  438.   end # Window_DungeonCommand
  439.  
  440.   class Bitmap
  441.     attr_accessor :last_line_height
  442.     #--------------------------------------------------------------------------
  443.     # * New Line Character Processing
  444.     #--------------------------------------------------------------------------
  445.     def process_new_line(text, pos)
  446.       pos[:x] = pos[:new_x]
  447.       pos[:y] += pos[:height]
  448.       if @last_line_height
  449.         pos[:height] = calc_line_height(text,true,@last_line_height)
  450.       else
  451.         pos[:height] = calc_line_height(text)
  452.       end
  453.     end
  454.     #--------------------------------------------------------------------------
  455.     # * Draw Text with Control Characters
  456.     #--------------------------------------------------------------------------
  457.     def draw_text_ex(x, y, text,reset_font=true,custom_size=false)
  458.       reset_font_settings if reset_font == true
  459.       #self.font.size -= 3
  460.       text = convert_escape_characters(text)
  461.       if !custom_size
  462.         pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  463.       else
  464.         pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text, true, custom_size)}
  465.       end
  466.       process_character(text.slice!(0, 1), text, pos) until text.empty?
  467.     end
  468.     #--------------------------------------------------------------------------
  469.     # * Calculate Line Height
  470.     #     restore_font_size : Return to original font size after calculating
  471.     #--------------------------------------------------------------------------
  472.     def calc_line_height(text, restore_font_size = true, custom_size=false)
  473.       if custom_size
  474.         @last_line_height = custom_size
  475.         return custom_size
  476.       end
  477.       result = [line_height, self.font.size].max
  478.       last_font_size = self.font.size
  479.       text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc|
  480.         make_font_bigger  if esc == "\e{"
  481.         make_font_smaller if esc == "\e}"
  482.         result = [result, self.font.size].max
  483.       end
  484.       self.font.size = last_font_size if restore_font_size
  485.       result
  486.     end
  487.   end
  488. #===============================================================================
  489. # * END OF FILE
  490. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement