Advertisement
gerkrt

Class changuing new command

Sep 14th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 45.13 KB | None | 0 0
  1. #==============================================================================
  2. # Class changuing new command
  3. # By gerkrt/gerrtunk
  4. # Version: 1.3
  5. # License: MIT, credits
  6. # Date: 22/01/2011
  7. # IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
  8. # script check here: http://usuarios.multimania.es/kisap/english_list.html
  9. #==============================================================================
  10.  
  11. =begin
  12.  
  13. -----INTRODUCTION-----
  14.  
  15. This script adds a new command in battle and menu that functions to switch
  16. classes in menu or battle using skills. It also adds a simple class description
  17. window that is shown in the battle and menu.
  18. You can also configure font, vocabulary, and if you want to show sp or not.
  19.  
  20. -----INSTRUCTIONS-----
  21.  
  22. You have to define two basic things:
  23.  
  24. 1- What skills are class changuing skills. To do this you have to modify
  25. this method:
  26.  
  27.   #--------------------------------------------------------------------------
  28.   # * Class changing skills
  29.   #--------------------------------------------------------------------------
  30.   def self.cambia_clases(skill_id)
  31.     case skill_id
  32.       # If skill id 1--->  Return class 3
  33.       when 1; return 3
  34.       when 6; return 1
  35.       else; return 0
  36.     end
  37.   end
  38.  
  39. You can add any number of new lines like when 6; return 1. The syntax is:
  40.  
  41. skill id 1 changue to class 3
  42.  
  43. when 1; return 3
  44.  
  45. 2- You have to define class descriptions.
  46.   #--------------------------------------------------------------------------
  47.   # * Class descriptions
  48.   #--------------------------------------------------------------------------
  49.   def self.descripcion_clase(class_id)
  50.     case class_id
  51.     # Class id  1---------->  Returns description
  52.     when 3; return "Bonus \n ·Great aglity \n" +
  53.     " ·It consumes less sp" +
  54.      "\n Handicaps \n ·Bad for range attacks"
  55.       else; return "Error. The class dont exist"
  56.     end  
  57.   end
  58.  
  59. This is somewhat harder. Now the 3 is the class that you are defining and we
  60. are now creating a description for it.
  61.  
  62. You have to write the bonus and handicaps using two text marks. These marks
  63. tell the script that he is drawing bonus or handicaps so it can use one
  64. or other font color, for example.
  65.  
  66. The marks are defined in these variables:
  67.   Class_bonus = "Bonus \n"              
  68.   Class_handicaps = " Handicaps \n"        
  69.  
  70. Then you have to return a text that have class bonus after the bonus mark
  71. and class handicaps after the handicaps mark. So imagine that you want to write:
  72.  
  73. Bonus
  74.   ·Great aglity
  75.   ·It consumes less sp
  76. Handicaps
  77.   ·Bad for range attacks
  78.  
  79. You have to write in the return:
  80.  
  81. when 3; return "Bonus \n ·Great aglity \n" +
  82. " ·It consumes less sp" +
  83.  "\n Handicaps \n ·Bad for range attacks"
  84.  
  85. Also, else; return "Error. The class dont exist" These shows an error message when
  86. the class dont exist.
  87.  
  88. 3- Note that this script dont changue the classes for you. You have to create
  89. a common event for such skills to changue they and add the animation you want or
  90. whatever.
  91.  
  92. -----OTHER THINGS----
  93.  
  94. You can control de font size, color and bold for normal, bonus or handicap text.
  95. Set bold to false if you dont want it.
  96.  
  97. The hard thing to understand is the color. You have to set the values rgb + alpha.
  98.     Handicap_font_color = Color.new(r,g,b,a)
  99. Note that the handicap and bonus fonts are applied to the starting words Bonus
  100. and Handicaps only.
  101.  
  102. For last, you can set the command name that is the description of the command
  103. you are adding and if you turn off show_sp makig it = false it wont draw
  104. the class changuing skills sp.
  105.  
  106. ------SYNTAX AND TEXT FORMAT NOTES------
  107.  
  108. -Never erase the else in the methods.
  109. -You must respect the "" for the text
  110. -The spaces are also characters so you can use this to align better your text.
  111. Also the spaces are fixed in the mark workds, so, if you write them or the \n
  112. you will have to respect that.
  113. -The \n character means newline. It will draw the next text in a newline and you
  114. have to write \n for each line.
  115.  
  116. -Rpg Maker XP sucks for long lines so you have to understand this syntax of the +:
  117.         when 3; return "Bonus \n ·Great aglity \n" +
  118.         " ·It consumes less sp" +
  119.         "\n Handicaps \n ·Bad for range attacks"
  120. The + concatenates two or more phrases so they convert to one. The nice thing
  121. is that also after the + you can create a newline so its more organitzated.
  122.  
  123. Anyway you can do this like you want. You can also write these lines in a better
  124. editor and jst paste it here.
  125.  
  126. =end
  127.  
  128. module Wep
  129.   Command_name = "Special"
  130.   Show_sp = true
  131.   Class_bonus = "Bonus \n"              
  132.   Class_handicaps = " Handicaps \n"      
  133.  
  134.     # Bonus font
  135.     Bonus_font_bold = true
  136.     Bonus_font_size = 25
  137.     Bonus_font_color = Color.new(192, 224, 255, 255)
  138.     # Handicap font
  139.     Handicap_font_bold = true
  140.     Handicap_font_size = 25
  141.     Handicap_font_color = Color.new(255, 255, 64, 255)
  142.     # Normal font
  143.     Normal_font_bold = false
  144.     Normal_font_size = 25
  145.     Normal_font_color = Color.new(255,255,255,255)
  146.  
  147.   #--------------------------------------------------------------------------
  148.   # * Class descriptions
  149.   #--------------------------------------------------------------------------
  150.   def self.descripcion_clase(class_id)
  151.     case class_id
  152.     # Class id  1---------->  Returns description
  153.         when 3; return "Bonus \n ·Great aglity \n" +
  154.         " ·It consumes less sp" +
  155.         "\n Handicaps \n ·Bad for range attacks"
  156.         else; return "Error. The class dont exist"
  157.     end  
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # * Class changing skills
  161.   #--------------------------------------------------------------------------
  162.   def self.cambia_clases(skill_id)
  163.     case skill_id
  164.       # If skill id 1--->  Return class 3
  165.       when 1; return 3
  166.       when 6; return 1
  167.       else; return 0
  168.     end
  169.   end
  170.  
  171. end
  172.  
  173. #==============================================================================
  174. # ** Window_OrbeRM
  175. #------------------------------------------------------------------------------
  176. #  Esta ventana muestra los OrbeRM a equipar
  177. #==============================================================================
  178.  
  179. class Window_OrbeRM < Window_Selectable
  180.   #--------------------------------------------------------------------------
  181.   # * Object Initialization
  182.   #     actor : personaje del cual estas examinando sus orbeRM
  183.   #--------------------------------------------------------------------------
  184.   def initialize(actor)
  185.     #     X  Y Amplitud Altura respectivamente. Valores para el menu principal.
  186.     super(0, 64, 270, 416)
  187.     @actor = actor
  188.     @column_max = 1
  189.     refresh
  190.     $scene.activar_descripcion(Wep.cambia_clases(skill.id))
  191.     self.index = 0
  192.     # Si esta en la batalla modifica la posicion, tamaño y transparencia.
  193.     if $game_temp.in_battle
  194.       # La mueve hacia arriva del todo.
  195.       self.y = 0
  196.       # Reduce su altura
  197.       self.height = 320
  198.       # Cambia la transparencia del fondo
  199.       self.back_opacity = 160
  200.     end
  201.   end
  202.  
  203.   #--------------------------------------------------------------------------
  204.   # * Acquiring Skill
  205.   #--------------------------------------------------------------------------
  206.   def skill
  207.     return @data[self.index]
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # * Frame Update
  211.   #--------------------------------------------------------------------------
  212.   def update
  213.     # Modifica la id de la clase a describir en la ventana de descripcion
  214.     $scene.activar_descripcion(Wep.cambia_clases(skill.id))
  215.    
  216.     # If cursor is movable
  217.     if self.active and @item_max > 0 and @index >= 0
  218.       # If pressing down on the directional buttons
  219.       if Input.repeat?(Input::DOWN)
  220.         # If column count is 1 and directional button was pressed down with no
  221.         # repeat, or if cursor position is more to the front than
  222.         # (item count - column count)
  223.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  224.            @index < @item_max - @column_max
  225.           # Move cursor down
  226.           $game_system.se_play($data_system.cursor_se)
  227.           @index = (@index + @column_max) % @item_max
  228.           $scene.refrescar_descripcion
  229.         end
  230.       end
  231.       # If the up directional button was pressed
  232.       if Input.repeat?(Input::UP)
  233.         # If column count is 1 and directional button was pressed up with no
  234.         # repeat, or if cursor position is more to the back than column count
  235.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  236.            @index >= @column_max
  237.           # Move cursor up
  238.           $game_system.se_play($data_system.cursor_se)
  239.           @index = (@index - @column_max + @item_max) % @item_max
  240.           # Refresca ventana para dibujar una unica vez la descripcion
  241.           $scene.refrescar_descripcion
  242.         end
  243.       end
  244.       # If the right directional button was pressed
  245.       if Input.repeat?(Input::RIGHT)
  246.         # If column count is 2 or more, and cursor position is closer to front
  247.         # than (item count -1)
  248.         if @column_max >= 2 and @index < @item_max - 1
  249.           # Move cursor right
  250.           $game_system.se_play($data_system.cursor_se)
  251.           @index += 1
  252.           # Refresca ventana para dibujar una unica vez la descripcion
  253.           $scene.refrescar_descripcion
  254.         end
  255.       end
  256.       # If the left directional button was pressed
  257.       if Input.repeat?(Input::LEFT)
  258.         # If column count is 2 or more, and cursor position is more back than 0
  259.         if @column_max >= 2 and @index > 0
  260.           # Move cursor left
  261.           $game_system.se_play($data_system.cursor_se)
  262.           @index -= 1
  263.           # Refresca ventana para dibujar una unica vez la descripcion
  264.           $scene.refrescar_descripcion
  265.         end
  266.       end
  267.       # If R button was pressed
  268.       if Input.repeat?(Input::R)
  269.         # If bottom row being displayed is more to front than bottom data row
  270.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  271.           # Move cursor 1 page back
  272.           $game_system.se_play($data_system.cursor_se)
  273.           @index = [@index + self.page_item_max, @item_max - 1].min
  274.           self.top_row += self.page_row_max
  275.           # Refresca ventana para dibujar una unica vez la descripcion
  276.           $scene.refrescar_descripcion
  277.         end
  278.       end
  279.       # If L button was pressed
  280.       if Input.repeat?(Input::L)
  281.         # If top row being displayed is more to back than 0
  282.         if self.top_row > 0
  283.           # Move cursor 1 page forward
  284.           $game_system.se_play($data_system.cursor_se)
  285.           @index = [@index - self.page_item_max, 0].max
  286.           self.top_row -= self.page_row_max
  287.           # Refresca ventana para dibujar una unica vez la descripcion
  288.           $scene.refrescar_descripcion
  289.         end
  290.       end
  291.     end
  292.     # Update cursor rectangle
  293.     update_cursor_rect
  294.   end
  295.  
  296.   #--------------------------------------------------------------------------
  297.   # * Refresh
  298.   #--------------------------------------------------------------------------
  299.   def refresh
  300.     if self.contents != nil
  301.       self.contents.dispose
  302.       self.contents = nil
  303.     end
  304.     @data = []
  305.     for i in 0...@actor.skills.size
  306.       skill = $data_skills[@actor.skills[i]]
  307.        # Comprueva si la habilidad es cambia-clases
  308.           class_id = Wep.cambia_clases(skill.id)
  309.             if class_id != 0
  310.               if skill != nil
  311.                # Si lo es la añade al array de orbesRM
  312.                @data.push(skill)
  313.               end
  314.             end
  315.     end
  316.     # If item count is not 0, make a bit map and draw all items
  317.     @item_max = @data.size
  318.     if @item_max > 0
  319.       self.contents = Bitmap.new(width - 32, row_max * 32)
  320.       for i in 0...@item_max
  321.         draw_item(i)
  322.       end
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # * Draw Item
  327.   #     index : item number
  328.   #--------------------------------------------------------------------------
  329.   def draw_item(index)
  330.     skill = @data[index]
  331.     if @actor.skill_can_use?(skill.id)
  332.       self.contents.font.color = normal_color
  333.     else
  334.       self.contents.font.color = disabled_color
  335.     end
  336.     x = 4
  337.     y = index * 32
  338.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  339.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  340.     bitmap = RPG::Cache.icon(skill.icon_name)
  341.     opacity = self.contents.font.color == normal_color ? 255 : 128
  342.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  343.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  344.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2) if Wep::Show_sp
  345.  
  346.   end
  347. end
  348.  
  349. #==============================================================================
  350. # ** Window_DescripcionClase
  351. #------------------------------------------------------------------------------
  352. #  Esta ventana muestra informacion sobre la clase (OrbeRM)
  353. #==============================================================================
  354. class Window_DescripcionClase < Window_Base
  355.   attr_accessor :class_id
  356.   #--------------------------------------------------------------------------
  357.   # * Object Initialization
  358.   #--------------------------------------------------------------------------
  359.   def initialize
  360.     #     X   Y  Amplitud Altura respectivamente. Valores para el menu principal.
  361.     super(270, 64, 370, 416)
  362.     self.contents = Bitmap.new(width-32, height-32)
  363.     @class_id
  364.     @s1 = Wep::Class_bonus             # Palabra para la linea de ventajas
  365.     @s2 = Wep::Class_handicaps        # Palabra para la liea de desventajas
  366.     # Cuidado. El programa buscara exactamente la palabra que escribas.
  367.     # Esto incluye tanto espacios en blanco o el mismo caracter de saltar linea \n
  368.     self.z = 254
  369.     # Si esta en la batalla modifica la posicion, tamaño y transparencia.
  370.     if $game_temp.in_battle
  371.       # La situa arriva del todo
  372.       self.y = 0
  373.       # Reduce su altura
  374.       self.height = 320
  375.       # Cambia la transparencia del fondo
  376.       self.back_opacity = 160
  377.     end
  378.   end
  379.  
  380.   #--------------------------------------------------------------------------
  381.   # * comprovar_linea ( Comprueva si la linea es alguno de las palabras
  382.   #   definidas y cambia su estilo.)
  383.   #--------------------------------------------------------------------------
  384.   def comprovar_linea(linea)
  385.       # Si son bonificaciones
  386.       if linea == @s1
  387.             # Cambia los atributos de la fuente
  388.             self.contents.font.bold = Wep::Bonus_font_bold
  389.             self.contents.font.size = Wep::Bonus_font_size
  390.             self.contents.font.color = Wep::Bonus_font_color
  391.       # Si son handicaps
  392.       elsif linea == @s2
  393.             # Cambia los atributos de la fuente
  394.             self.contents.font.bold = Wep::Handicap_font_bold
  395.             self.contents.font.size = Wep::Handicap_font_size
  396.             self.contents.font.color = Wep::Handicap_font_color
  397.             # Si no se esta en batalla suma +2 al indice para dejar espacio entre los bloques
  398.             if not $game_temp.in_battle
  399.               @i+=2
  400.             end
  401.       # Si se ha cambiado algun atributo de la fuente
  402.       elsif self.contents.font.bold != false or self.contents.font.color != normal_color or self.contents.font.size !=  Font.default_size
  403.            # Revierte los cambios en la fuente para dibujarla normal
  404.             self.contents.font.bold = Wep::Normal_font_bold
  405.             self.contents.font.size = Wep::Normal_font_size
  406.             self.contents.font.color = Wep::Normal_font_color
  407.       end
  408.     end
  409.    
  410.   #--------------------------------------------------------------------------
  411.   # * Refresh
  412.   #--------------------------------------------------------------------------
  413.   def refresh
  414.     self.contents.clear
  415.     descripcion = Wep.descripcion_clase(@class_id)
  416.     @i = 0
  417.     # Dibuja las lineas segun el algoritmo
  418.     descripcion.each_line {|linea| comprovar_linea(linea) ;  self.contents.draw_text(0, 32*@i, self.contents.width, 32, linea) ;@i+=1 }
  419.   end
  420. end
  421.  
  422. #==============================================================================
  423. # ** Scene_Skill
  424. #------------------------------------------------------------------------------
  425. #  This class performs skill screen processing.
  426. #==============================================================================
  427.  
  428. class Scene_OrbeRM
  429.   #--------------------------------------------------------------------------
  430.   # * Object Initialization
  431.   #     actor_index : actor index
  432.   #--------------------------------------------------------------------------
  433.   def initialize(actor_index = 0, equip_index = 0)
  434.     @actor_index = actor_index
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # * Main Processing
  438.   #--------------------------------------------------------------------------
  439.   def main
  440.     # Get actor
  441.     @actor = $game_party.actors[@actor_index]
  442.     # Crea ventana de descripcion
  443.     @ventana_descripcion = Window_DescripcionClase.new
  444.     # Make help window, status window, and skill window
  445.     #@help_window = Window_Help.new
  446.     @status_window = Window_SkillStatus.new(@actor)
  447.     @status_window.y = 0
  448.     @skill_window = Window_OrbeRM.new(@actor)
  449.     @ventana_descripcion.refresh
  450.     # Associate help window
  451.     #@skill_window.help_window = @help_window
  452.     # Make target window (set to invisible / inactive)
  453.     @target_window = Window_Target.new
  454.     @target_window.visible = false
  455.     @target_window.active = false
  456.     # Execute transition
  457.     Graphics.transition
  458.     # Main loop
  459.     loop do
  460.       # Update game screen
  461.       Graphics.update
  462.       # Update input information
  463.       Input.update
  464.       # Frame update
  465.       update
  466.       # Abort loop if screen is changed
  467.       if $scene != self
  468.         break
  469.       end
  470.     end
  471.     # Prepare for transition
  472.     Graphics.freeze
  473.     # Dispose of windows
  474.     #@help_window.dispose
  475.     @status_window.dispose
  476.     @skill_window.dispose
  477.     @target_window.dispose
  478.     @ventana_descripcion.dispose
  479.   end
  480.   #--------------------------------------------------------------------------
  481.   # * Refrescar ventana descripcion optimizada
  482.   #--------------------------------------------------------------------------
  483.   def refrescar_descripcion
  484.     @ventana_descripcion.refresh
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # * Frame Update
  488.   #--------------------------------------------------------------------------
  489.   def update
  490.     # Update windows
  491.     #@help_window.update
  492.     @status_window.update
  493.     @skill_window.update
  494.     @target_window.update
  495.     # Si la ventana de descripcion esta visible, actualizarla.
  496.     if @ventana_descripcion.visible
  497.       @ventana_descripcion.update
  498.     end
  499.     # If skill window is active: call update_skill
  500.     if @skill_window.active
  501.       update_skill
  502.       return
  503.     end
  504.     # If skill target is active: call update_target
  505.     if @target_window.active
  506.       update_target
  507.       return
  508.     end
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # * Frame Update (if skill window is active)
  512.   #--------------------------------------------------------------------------
  513.   def update_skill
  514.     # If B button was pressed
  515.     if Input.trigger?(Input::B)
  516.       # Play cancel SE
  517.       $game_system.se_play($data_system.cancel_se)
  518.       # Switch to menu screen
  519.       $scene = Scene_Menu.new(1)
  520.       return
  521.     end
  522.     # If C button was pressed
  523.     if Input.trigger?(Input::C)
  524.       # Get currently selected data on the skill window
  525.       @skill = @skill_window.skill
  526.       # If unable to use
  527.       if @skill == nil or not @actor.skill_can_use?(@skill.id)
  528.         # Play buzzer SE
  529.         $game_system.se_play($data_system.buzzer_se)
  530.         return
  531.       end
  532.       # Play decision SE
  533.       $game_system.se_play($data_system.decision_se)
  534.       # If effect scope is ally
  535.       if @skill.scope >= 3
  536.         # Activate target window
  537.         @skill_window.active = false
  538.         @target_window.x = (@skill_window.index + 1) % 2 * 304
  539.         @target_window.visible = true
  540.         @target_window.active = true
  541.         # Set cursor position to effect scope (single / all)
  542.         if @skill.scope == 4 || @skill.scope == 6
  543.           @target_window.index = -1
  544.         elsif @skill.scope == 7
  545.           @target_window.index = @actor_index - 10
  546.         else
  547.           @target_window.index = 0
  548.         end
  549.       # If effect scope is other than ally
  550.       else
  551.         # If common event ID is valid
  552.         if @skill.common_event_id > 0
  553.           # Common event call reservation
  554.           $game_temp.common_event_id = @skill.common_event_id
  555.           # Play use skill SE
  556.           $game_system.se_play(@skill.menu_se)
  557.           # Use up SP
  558.           @actor.sp -= @skill.sp_cost
  559.           # Remake each window content
  560.           @status_window.refresh
  561.           @skill_window.refresh
  562.           @target_window.refresh
  563.           # Switch to map screen
  564.           $scene = Scene_Map.new
  565.           return
  566.         end
  567.       end
  568.       return
  569.     end
  570.     # If R button was pressed
  571.     if Input.trigger?(Input::R)
  572.       # Play cursor SE
  573.       $game_system.se_play($data_system.cursor_se)
  574.       # To next actor
  575.       @actor_index += 1
  576.       @actor_index %= $game_party.actors.size
  577.       # Switch to different skill screen
  578.       $scene = Scene_Skill.new(@actor_index)
  579.       return
  580.     end
  581.     # If L button was pressed
  582.     if Input.trigger?(Input::L)
  583.       # Play cursor SE
  584.       $game_system.se_play($data_system.cursor_se)
  585.       # To previous actor
  586.       @actor_index += $game_party.actors.size - 1
  587.       @actor_index %= $game_party.actors.size
  588.       # Switch to different skill screen
  589.       $scene = Scene_Skill.new(@actor_index)
  590.       return
  591.     end
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # * Activar descripcion
  595.   # Modifica la id de la clase a describir en la ventana de descripcion
  596.   #--------------------------------------------------------------------------
  597.   def activar_descripcion(class_id)
  598.     @ventana_descripcion.class_id = class_id
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # * Frame Update (when target window is active)
  602.   #--------------------------------------------------------------------------
  603.   def update_target
  604.     # If B button was pressed
  605.     if Input.trigger?(Input::B)
  606.       # Play cancel SE
  607.       $game_system.se_play($data_system.cancel_se)
  608.       # Erase target window
  609.       @skill_window.active = true
  610.       @target_window.visible = false
  611.       @target_window.active = false
  612.       return
  613.     end
  614.     # If C button was pressed
  615.     if Input.trigger?(Input::C)
  616.       # If unable to use because SP ran out
  617.       unless @actor.skill_can_use?(@skill.id)
  618.         # Play buzzer SE
  619.         $game_system.se_play($data_system.buzzer_se)
  620.         return
  621.       end
  622.       # If target is all
  623.       if @target_window.index == -1
  624.         # Apply skill use effects to entire party
  625.         used = false
  626.         for i in $game_party.actors
  627.           used |= i.skill_effect(@actor, @skill)
  628.         end
  629.       end
  630.       # If target is user
  631.       if @target_window.index <= -2
  632.         # Apply skill use effects to target actor
  633.         target = $game_party.actors[@target_window.index + 10]
  634.         used = target.skill_effect(@actor, @skill)
  635.       end
  636.       # If single target
  637.       if @target_window.index >= 0
  638.         # Apply skill use effects to target actor
  639.         target = $game_party.actors[@target_window.index]
  640.         used = target.skill_effect(@actor, @skill)
  641.       end
  642.       # If skill was used
  643.       if used
  644.         # Play skill use SE
  645.         $game_system.se_play(@skill.menu_se)
  646.         # Use up SP
  647.         @actor.sp -= @skill.sp_cost
  648.         # Remake each window content
  649.         @status_window.refresh
  650.         @skill_window.refresh
  651.         @target_window.refresh
  652.         # If entire party is dead
  653.         if $game_party.all_dead?
  654.           # Switch to game over screen
  655.           $scene = Scene_Gameover.new
  656.           return
  657.         end
  658.         # If command event ID is valid
  659.         if @skill.common_event_id > 0
  660.           # Command event call reservation
  661.           $game_temp.common_event_id = @skill.common_event_id
  662.           # Switch to map screen
  663.           $scene = Scene_Map.new
  664.           return
  665.         end
  666.       end
  667.       # If skill wasn't used
  668.       unless used
  669.         # Play buzzer SE
  670.         $game_system.se_play($data_system.buzzer_se)
  671.       end
  672.       return
  673.     end
  674.   end
  675. end
  676.  
  677. #==============================================================================
  678. # ** Scene_Battle (part 3)
  679. #------------------------------------------------------------------------------
  680. #  This class performs battle screen processing.
  681. #==============================================================================
  682.  
  683. class Scene_Battle
  684.  
  685.   #--------------------------------------------------------------------------
  686.   # * Frame Update (actor command phase)
  687.   #--------------------------------------------------------------------------
  688.   def update_phase3
  689.     # If enemy arrow is enabled
  690.     if @enemy_arrow != nil
  691.       update_phase3_enemy_select
  692.     # If actor arrow is enabled
  693.     elsif @actor_arrow != nil
  694.       update_phase3_actor_select
  695.     # If skill window is enabled
  696.     elsif @skill_window != nil
  697.       update_phase3_skill_select
  698.     # If orbeRM window is enabled
  699.     elsif @orberm_window != nil
  700.       update_phase3_orberm_select
  701.     # If item window is enabled
  702.     elsif @item_window != nil
  703.       update_phase3_item_select
  704.     # If actor command window is enabled
  705.     elsif @actor_command_window.active
  706.       update_phase3_basic_command
  707.     end
  708.   end
  709.  
  710.   #--------------------------------------------------------------------------
  711.   # * Frame Update (actor command phase : orbeRM selection)
  712.   #--------------------------------------------------------------------------
  713.   def update_phase3_orberm_select
  714.     # Make OrbeRM window visible
  715.     @orberm_window.visible = true
  716.     # Update OrbeRM window
  717.     @orberm_window.update
  718.     # If B button was pressed
  719.     if Input.trigger?(Input::B)
  720.       # Play cancel SE
  721.       $game_system.se_play($data_system.cancel_se)
  722.       # End skill selection
  723.       end_orberm_select
  724.       return
  725.     end
  726.     # If C button was pressed
  727.     if Input.trigger?(Input::C)
  728.       # Get currently selected data on the orbeRM window
  729.       @orberm = @orberm_window.skill
  730.       # If it can't be used
  731.       if @orberm == nil or not @active_battler.skill_can_use?(@orberm.id)
  732.         # Play buzzer SE
  733.         $game_system.se_play($data_system.buzzer_se)
  734.         return
  735.       end
  736.       # Play decision SE
  737.       $game_system.se_play($data_system.decision_se)
  738.       # Set action            ##################################33333 IMP !!!!!
  739.       @active_battler.current_action.skill_id = @orberm.id
  740.       # Make skill window invisible
  741.       @orberm_window.visible = false
  742.       # If effect scope is single enemy
  743.       if @orberm.scope == 1
  744.         # Start enemy selection
  745.         start_enemy_select
  746.       # If effect scope is single ally
  747.       elsif @orberm.scope == 3 or @orberm.scope == 5
  748.         # Start actor selection
  749.         start_actor_select
  750.       # If effect scope is not single
  751.       else
  752.         # End skill selection
  753.         end_orberm_select
  754.         # Go to command input for next actor
  755.         phase3_next_actor
  756.       end
  757.       return
  758.     end
  759.   end
  760.  
  761.   #--------------------------------------------------------------------------
  762.   # * Start OrbeRM Selection
  763.   #--------------------------------------------------------------------------
  764.   def start_orberm_select
  765.     # Crea ventana de descripcion
  766.     @ventana_descripcion = Window_DescripcionClase.new
  767.     # Make OrbeRM window
  768.     @orberm_window = Window_OrbeRM.new(@active_battler)
  769.     refrescar_descripcion
  770.     # Desactiva temporalmente ventana de ayuda
  771.     @help_window.visible = false
  772.     # Disable actor command window
  773.     @actor_command_window.active = false
  774.     @actor_command_window.visible = false
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # * End OrbeRM selection
  778.   #--------------------------------------------------------------------------
  779.   def end_orberm_select
  780.     # Dispose of orbeRM window
  781.     @orberm_window.dispose
  782.     @ventana_descripcion.dispose
  783.     @orberm_window = nil
  784.     @ventana_descripcion = nil
  785.     # Hide help window
  786.     @help_window.visible = false
  787.     # Enable actor command window
  788.     @actor_command_window.active = true
  789.     @actor_command_window.visible = true
  790.   end
  791. end
  792.  
  793. #==============================================================================
  794. # ** Scene_Battle (part 1)
  795. #------------------------------------------------------------------------------
  796. #  This class performs battle screen processing.
  797. #==============================================================================
  798.  
  799. class Scene_Battle
  800.   #--------------------------------------------------------------------------
  801.   # * Main Processing
  802.   #--------------------------------------------------------------------------
  803.   def main
  804.     # Initialize each kind of temporary battle data
  805.     $game_temp.in_battle = true
  806.     $game_temp.battle_turn = 0
  807.     $game_temp.battle_event_flags.clear
  808.     $game_temp.battle_abort = false
  809.     $game_temp.battle_main_phase = false
  810.     $game_temp.battleback_name = $game_map.battleback_name
  811.     $game_temp.forcing_battler = nil
  812.     # Initialize battle event interpreter
  813.     $game_system.battle_interpreter.setup(nil, 0)
  814.     # Prepare troop
  815.     @troop_id = $game_temp.battle_troop_id
  816.     $game_troop.setup(@troop_id)
  817.     # Make actor command window
  818.     s1 = $data_system.words.attack
  819.     s2 = $data_system.words.skill
  820.     s3 = Wep::Command_name
  821.     s4 = $data_system.words.guard
  822.     s5 = $data_system.words.item
  823.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
  824.     @actor_command_window.y = 128
  825.     @actor_command_window.back_opacity = 160
  826.     @actor_command_window.active = false
  827.     @actor_command_window.visible = false
  828.     # Make other windows
  829.     @party_command_window = Window_PartyCommand.new
  830.     @help_window = Window_Help.new
  831.     @help_window.back_opacity = 160
  832.     @help_window.visible = false
  833.     @status_window = Window_BattleStatus.new
  834.     @message_window = Window_Message.new
  835.     # Crea ventana de descripcion
  836.     # @ventana_descripcion = Window_DescripcionClase.new(x=320, y=128, amplitud=320, altura=352)
  837.     # @ventana_descripcion.visible = false
  838.     # Make sprite set
  839.     @spriteset = Spriteset_Battle.new
  840.     # Initialize wait count
  841.     @wait_count = 0
  842.     # Execute transition
  843.     if $data_system.battle_transition == ""
  844.       Graphics.transition(20)
  845.     else
  846.       Graphics.transition(40, "Graphics/Transitions/" +
  847.         $data_system.battle_transition)
  848.     end
  849.     # Start pre-battle phase
  850.     start_phase1
  851.     # Main loop
  852.     loop do
  853.       # Update game screen
  854.       Graphics.update
  855.       # Update input information
  856.       Input.update
  857.       # Frame update
  858.       update
  859.       # Abort loop if screen is changed
  860.       if $scene != self
  861.         break
  862.       end
  863.     end
  864.     # Refresh map
  865.     $game_map.refresh
  866.     # Prepare for transition
  867.     Graphics.freeze
  868.     # Dispose of windows
  869.     @actor_command_window.dispose
  870.     @party_command_window.dispose
  871.     @help_window.dispose
  872.     @status_window.dispose
  873.     @message_window.dispose
  874.     if @skill_window != nil
  875.       @skill_window.dispose
  876.     end
  877.     if @orberm_window != nil
  878.       @orberm.dispose
  879.     end
  880.     if @ventana_descripcion != nil
  881.       @ventana_descripcion.dispose
  882.     end
  883.     if @item_window != nil
  884.       @item_window.dispose
  885.     end
  886.     if @result_window != nil
  887.       @result_window.dispose
  888.     end
  889.     # Dispose of sprite set
  890.     @spriteset.dispose
  891.     # If switching to title screen
  892.     if $scene.is_a?(Scene_Title)
  893.       # Fade out screen
  894.       Graphics.transition
  895.       Graphics.freeze
  896.     end
  897.     # If switching from battle test to any screen other than game over screen
  898.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  899.       $scene = nil
  900.     end
  901.   end
  902.  
  903.   #--------------------------------------------------------------------------
  904.   # * Activar descripcion
  905.   # Modifica la id de la clase a describir en la ventana de descripcion
  906.   #--------------------------------------------------------------------------
  907.   def activar_descripcion(class_id)
  908.     @ventana_descripcion.class_id = class_id
  909.   end
  910.   #--------------------------------------------------------------------------
  911.   # * Refrescar ventana descripcion optimizada
  912.   #--------------------------------------------------------------------------
  913.   def refrescar_descripcion
  914.     @ventana_descripcion.refresh
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # * Frame Update
  918.   #--------------------------------------------------------------------------
  919.   def update
  920.     # If battle event is running
  921.     if $game_system.battle_interpreter.running?
  922.       # Update interpreter
  923.       $game_system.battle_interpreter.update
  924.       # If a battler which is forcing actions doesn't exist
  925.       if $game_temp.forcing_battler == nil
  926.         # If battle event has finished running
  927.         unless $game_system.battle_interpreter.running?
  928.           # Rerun battle event set up if battle continues
  929.           unless judge
  930.             setup_battle_event
  931.           end
  932.         end
  933.         # If not after battle phase
  934.         if @phase != 5
  935.           # Refresh status window
  936.           @status_window.refresh
  937.         end
  938.       end
  939.     end
  940.     # Update system (timer) and screen
  941.     $game_system.update
  942.     $game_screen.update
  943.     # If timer has reached 0
  944.     if $game_system.timer_working and $game_system.timer == 0
  945.       # Abort battle
  946.       $game_temp.battle_abort = true
  947.     end
  948.     # Update windows
  949.     @help_window.update
  950.     @party_command_window.update
  951.     @actor_command_window.update
  952.     @status_window.update
  953.     @message_window.update
  954.     if @ventana_descripcion != nil
  955.       @ventana_descripcion.update
  956.     end
  957.     # Update sprite set
  958.     @spriteset.update
  959.     # If transition is processing
  960.     if $game_temp.transition_processing
  961.       # Clear transition processing flag
  962.       $game_temp.transition_processing = false
  963.       # Execute transition
  964.       if $game_temp.transition_name == ""
  965.         Graphics.transition(20)
  966.       else
  967.         Graphics.transition(40, "Graphics/Transitions/" +
  968.           $game_temp.transition_name)
  969.       end
  970.     end
  971.     # If message window is showing
  972.     if $game_temp.message_window_showing
  973.       return
  974.     end
  975.     # If effect is showing
  976.     if @spriteset.effect?
  977.       return
  978.     end
  979.     # If game over
  980.     if $game_temp.gameover
  981.       # Switch to game over screen
  982.       $scene = Scene_Gameover.new
  983.       return
  984.     end
  985.     # If returning to title screen
  986.     if $game_temp.to_title
  987.       # Switch to title screen
  988.       $scene = Scene_Title.new
  989.       return
  990.     end
  991.     # If battle is aborted
  992.     if $game_temp.battle_abort
  993.       # Return to BGM used before battle started
  994.       $game_system.bgm_play($game_temp.map_bgm)
  995.       # Battle ends
  996.       battle_end(1)
  997.       return
  998.     end
  999.     # If waiting
  1000.     if @wait_count > 0
  1001.       # Decrease wait count
  1002.       @wait_count -= 1
  1003.       return
  1004.     end
  1005.     # If battler forcing an action doesn't exist,
  1006.     # and battle event is running
  1007.     if $game_temp.forcing_battler == nil and
  1008.        $game_system.battle_interpreter.running?
  1009.       return
  1010.     end
  1011.     # Branch according to phase
  1012.     case @phase
  1013.     when 1  # pre-battle phase
  1014.       update_phase1
  1015.     when 2  # party command phase
  1016.       update_phase2
  1017.     when 3  # actor command phase
  1018.       update_phase3
  1019.     when 4  # main phase
  1020.       update_phase4
  1021.     when 5  # after battle phase
  1022.       update_phase5
  1023.     end
  1024.   end
  1025. end
  1026.  
  1027. #==============================================================================
  1028. # ** Window_Skill
  1029. #------------------------------------------------------------------------------
  1030. #  This window displays usable skills on the skill and battle screens.
  1031. #==============================================================================
  1032.  
  1033. class Window_Skill < Window_Selectable
  1034.  
  1035.   #--------------------------------------------------------------------------
  1036.   # * Refresh
  1037.   #--------------------------------------------------------------------------
  1038.   def refresh
  1039.     if self.contents != nil
  1040.       self.contents.dispose
  1041.       self.contents = nil
  1042.     end
  1043.     @data = []
  1044.     for i in 0...@actor.skills.size
  1045.       skill = $data_skills[@actor.skills[i]]
  1046.        # Comprueva que la habilidad no sea cambia-clases
  1047.           class_id = Wep.cambia_clases(skill.id)
  1048.             if class_id == 0
  1049.               # Añade las habilidades no cambia-clases
  1050.                 if skill != nil
  1051.                   @data.push(skill)
  1052.                 end
  1053.             end
  1054.  
  1055.     end
  1056.     # If item count is not 0, make a bit map and draw all items
  1057.     @item_max = @data.size
  1058.     if @item_max > 0
  1059.       self.contents = Bitmap.new(width - 32, row_max * 32)
  1060.       for i in 0...@item_max
  1061.         draw_item(i)
  1062.       end
  1063.     end
  1064.   end
  1065. end
  1066.  
  1067. #==============================================================================
  1068. # ** Scene_Menu
  1069. #------------------------------------------------------------------------------
  1070. #  This class performs menu screen processing.
  1071. #==============================================================================
  1072. # ** Scene_Menu
  1073. #------------------------------------------------------------------------------
  1074. #  This class performs menu screen processing.
  1075. #==============================================================================
  1076. class Scene_Menu
  1077. #==============================================================================
  1078. # ** Scene_Menu
  1079. #------------------------------------------------------------------------------
  1080. #  This class performs menu screen processing.
  1081. #==============================================================================
  1082.   #--------------------------------------------------------------------------
  1083.   # * Main Processing
  1084.   #--------------------------------------------------------------------------
  1085.   def main
  1086.     # Make command window
  1087.     s1 = $data_system.words.item
  1088.     s2 = $data_system.words.skill
  1089.     s3 = $data_system.words.equip
  1090.     s4 = "Status"
  1091.     s5 = Wep::Command_name
  1092.     s6 = "Save"
  1093.     s7 = "Exit"
  1094.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
  1095.     @command_window.index = @menu_index
  1096.     # If number of party members is 0
  1097.     if $game_party.actors.size == 0
  1098.       # Disable items, skills, equipment, and status
  1099.       @command_window.disable_item(0)
  1100.       @command_window.disable_item(1)
  1101.       @command_window.disable_item(2)
  1102.       @command_window.disable_item(3)
  1103.     end
  1104.     # If save is forbidden
  1105.     if $game_system.save_disabled
  1106.       # Disable save
  1107.       @command_window.disable_item(5)
  1108.     end
  1109.     # Make play time window
  1110.     @playtime_window = Window_PlayTime.new
  1111.     @playtime_window.x = 0
  1112.     @playtime_window.y = 256
  1113.     # Make steps window
  1114.     @steps_window = Window_Steps.new
  1115.     @steps_window.x = 0
  1116.     @steps_window.y = 352
  1117.     # Make gold window
  1118.     @gold_window = Window_Gold.new
  1119.     @gold_window.x = 0
  1120.     @gold_window.y = 416
  1121.     # Make status window
  1122.     @status_window = Window_MenuStatus.new
  1123.     @status_window.x = 160
  1124.     @status_window.y = 0
  1125.     # Execute transition
  1126.     Graphics.transition
  1127.     # Main loop
  1128.     loop do
  1129.       # Update game screen
  1130.       Graphics.update
  1131.       # Update input information
  1132.       Input.update
  1133.       # Frame update
  1134.       update
  1135.       # Abort loop if screen is changed
  1136.       if $scene != self
  1137.         break
  1138.       end
  1139.     end
  1140.     # Prepare for transition
  1141.     Graphics.freeze
  1142.     # Dispose of windows
  1143.     @command_window.dispose
  1144.     @playtime_window.dispose
  1145.     @steps_window.dispose
  1146.     @gold_window.dispose
  1147.     @status_window.dispose
  1148.   end
  1149.   #--------------------------------------------------------------------------
  1150.   # * Frame Update (when command window is active)
  1151.   #--------------------------------------------------------------------------
  1152.   def update_command
  1153.     # If B button was pressed
  1154.     if Input.trigger?(Input::B)
  1155.       # Play cancel SE
  1156.       $game_system.se_play($data_system.cancel_se)
  1157.       # Switch to map screen
  1158.       $scene = Scene_Map.new
  1159.       return
  1160.     end
  1161.     # If C button was pressed
  1162.     if Input.trigger?(Input::C)
  1163.       # If command other than save or end game, and party members = 0
  1164.       if $game_party.actors.size == 0 and @command_window.index < 4
  1165.         # Play buzzer SE
  1166.         $game_system.se_play($data_system.buzzer_se)
  1167.         return
  1168.       end
  1169.       # Branch by command window cursor position
  1170.       case @command_window.index
  1171.       when 0  # item
  1172.         # Play decision SE
  1173.         $game_system.se_play($data_system.decision_se)
  1174.         # Switch to item screen
  1175.         $scene = Scene_Item.new
  1176.       when 1  # skill
  1177.         # Play decision SE
  1178.         $game_system.se_play($data_system.decision_se)
  1179.         # Make status window active
  1180.         @command_window.active = false
  1181.         @status_window.active = true
  1182.         @status_window.index = 0
  1183.       when 2  # equipment
  1184.         # Play decision SE
  1185.         $game_system.se_play($data_system.decision_se)
  1186.         # Make status window active
  1187.         @command_window.active = false
  1188.         @status_window.active = true
  1189.         @status_window.index = 0
  1190.       when 3  # status
  1191.         # Play decision SE
  1192.         $game_system.se_play($data_system.decision_se)
  1193.         # Make status window active
  1194.         @command_window.active = false
  1195.         @status_window.active = true
  1196.         @status_window.index = 0
  1197.       when 4  # newCommand
  1198.         # Play decision SE
  1199.         $game_system.se_play($data_system.decision_se)
  1200.         # Make status window active
  1201.         @command_window.active = false
  1202.         @status_window.active = true
  1203.         @status_window.index = 0
  1204.       when 5  # save
  1205.         # If saving is forbidden
  1206.         if $game_system.save_disabled
  1207.           # Play buzzer SE
  1208.           $game_system.se_play($data_system.buzzer_se)
  1209.           return
  1210.         end
  1211.         # Play decision SE
  1212.         $game_system.se_play($data_system.decision_se)
  1213.         # Switch to save screen
  1214.         $scene = Scene_Save.new
  1215.       when 6  # end game
  1216.         # Play decision SE
  1217.         $game_system.se_play($data_system.decision_se)
  1218.         # Switch to end game screen
  1219.         $scene = Scene_End.new
  1220.       end
  1221.       return
  1222.     end
  1223.   end
  1224.   #--------------------------------------------------------------------------
  1225.   # * Frame Update (when status window is active)
  1226.   #--------------------------------------------------------------------------
  1227.   def update_status
  1228.     # If B button was pressed
  1229.     if Input.trigger?(Input::B)
  1230.       # Play cancel SE
  1231.       $game_system.se_play($data_system.cancel_se)
  1232.       # Make command window active
  1233.       @command_window.active = true
  1234.       @status_window.active = false
  1235.       @status_window.index = -1
  1236.       return
  1237.     end
  1238.     # If C button was pressed
  1239.     if Input.trigger?(Input::C)
  1240.       # Branch by command window cursor position
  1241.       case @command_window.index
  1242.       when 1  # skill
  1243.         # If this actor's action limit is 2 or more
  1244.         if $game_party.actors[@status_window.index].restriction >= 2
  1245.           # Play buzzer SE
  1246.           $game_system.se_play($data_system.buzzer_se)
  1247.           return
  1248.         end
  1249.         # Play decision SE
  1250.         $game_system.se_play($data_system.decision_se)
  1251.         # Switch to skill screen
  1252.         $scene = Scene_Skill.new(@status_window.index)
  1253.       when 2  # equipment
  1254.         # Play decision SE
  1255.         $game_system.se_play($data_system.decision_se)
  1256.         # Switch to equipment screen
  1257.         $scene = Scene_Equip.new(@status_window.index)
  1258.       when 3  # status
  1259.         # Play decision SE
  1260.         $game_system.se_play($data_system.decision_se)
  1261.         # Switch to status screen
  1262.         $scene = Scene_Status.new(@status_window.index)
  1263.       when 4  # newCommand
  1264.         # If this actor's action limit is 2 or more
  1265.         if $game_party.actors[@status_window.index].restriction >= 2
  1266.           # Play buzzer SE
  1267.           $game_system.se_play($data_system.buzzer_se)
  1268.           return
  1269.         end
  1270.         # Play decision SE
  1271.         $game_system.se_play($data_system.decision_se)
  1272.         # Canvia a la escena de OrbeRM
  1273.         $scene = Scene_OrbeRM.new(@status_window.index)
  1274.       return
  1275.       end    
  1276.     end
  1277.   end
  1278. end
  1279.  
  1280. #==============================================================================
  1281. # ** Window_Steps
  1282. #------------------------------------------------------------------------------
  1283. #  This window displays step count on the menu screen.
  1284. #==============================================================================
  1285.  
  1286. class Window_Steps < Window_Base
  1287.   #--------------------------------------------------------------------------
  1288.   # * Object Initialization
  1289.   #--------------------------------------------------------------------------
  1290.   def initialize
  1291.     super(0, 0, 160, 64)
  1292.     self.contents = Bitmap.new(width - 32, height - 32)
  1293.     refresh
  1294.   end
  1295. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement