Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 28.93 KB | None | 0 0
  1. #==============================================================================
  2. #   XaiL System - Attribute System
  3. #   Author: Nicke
  4. #   Created: 01/08/2012
  5. #   Edited: 28/12/2012
  6. #   Version: 1.1b
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ? Materials but above ? Main. Remember to save.
  12. #==============================================================================
  13. # Requires: XS - Core Script.
  14. # Numeric Class by IceDragon.
  15. #==============================================================================
  16. # Attribute system. This script will allow you to gain attribute points each
  17. # time an actor gains a level. Those points can then be spend as the user wish.
  18. # For example, increase the health of the character or the magic resistance.
  19. #
  20. # To call this scene in the menu or any time during the game, use the following
  21. # script call:
  22. # SceneManager.call(Scene_Attribute)
  23. #
  24. # Use the following script calls to reward/remove points.
  25. # $game_party.attribute(actor_id, value, type = :gain)
  26. # $game_party.attribute(1, 5)
  27. # $game_party.attribute(2, 5, :lose)
  28. # This will return nil if the specified actor isn't in the party.
  29. #
  30. # Do this to check how many attribute points an actor have:
  31. # $game_party.attribute?(actor_id)
  32. # $game_party.attribute?(1)
  33. # This will return nil if the specified actor isn't in the party.
  34. #
  35. # You can change the actor points, icons, cost, max stats etc in the settings.
  36. # This script also support own background for the attribute windows.
  37. #
  38. # Note: At the scene you can change actor using Q or W like in the status scene.
  39. #
  40. # *** Only for RPG Maker VX Ace. ***
  41. #==============================================================================
  42. ($imported ||= {})["XAIL-ATTRIBUTE-SYSTEM"] = true
  43.  
  44. module XAIL
  45.   module ATTRIBUTE_SYSTEM
  46.   #--------------------------------------------------------------------------#
  47.   # * Settings
  48.   #--------------------------------------------------------------------------#
  49.     # FONT = name
  50.     FONT = ["Anklada™", "Verdana"]
  51.    
  52.     # ATTRIBUTE LIST:
  53.     # LIST[id] = [symbol, stats_increase, cost, enabled]
  54.     LIST = [] # Don't remove!
  55.     LIST[0]   = [:hp,       25,    1, true]
  56.     LIST[1]   = [:mp,       25,    1, true]
  57.     LIST[2]   = [:atk,      10,    1, true]
  58.     LIST[3]   = [:def,      5,     2, true]
  59.     LIST[4]   = [:magic,    10,    3, true]
  60.     LIST[5]   = [:res,       3,    2, true]
  61.     LIST[6]   = [:agl,      10,    1, true]
  62.     LIST[7]   = [:luk,       2,    5, true]
  63.     LIST[8]   = [:hit,    0.01,   15, true]
  64.     LIST[9]   = [:eva,    0.01,   15, true]
  65.     LIST[10]  = [:cri,    0.01,   15, true]
  66.     LIST[11]  = [:cev,    0.01,   15, true]
  67.     LIST[12]  = [:mev,    0.01,   15, true]
  68.     LIST[13]  = [:mrf,    0.01,   15, true]
  69.  
  70.     # ACTOR_POINTS:
  71.     # Distribute how many starting points each actor should have when the game
  72.     # starts.
  73.     # ACTOR_POINTS[id] => number
  74.     ACTOR_POINTS = {
  75.     1  => 150,
  76.     2  => 5,
  77.     3  => 5,
  78.     4  => 5,
  79.     5  => 5,
  80.     6  => 5,
  81.     7  => 5,
  82.     8  => 5,
  83.     9  => 5,
  84.     10 => 5
  85.     } # Don't remove this line!
  86.    
  87.     # attr_points = formula
  88.     # Attribute points formula.
  89.     # Set how many attribute points an actor should gain per level.
  90.     # Default: Based on actor's luck divided by 2.
  91.     def self.attr_points(actor)
  92.       case $game_actors[actor.id].id
  93.       when 1 ; $game_actors[actor.id].luk / 2
  94.       when 2 ; $game_actors[actor.id].luk / 2
  95.       # // Add more actor_id's here.
  96.       else ; 0 # // Prevent error if nil as in actor id isn't in party.
  97.       end
  98.     end
  99.    
  100.     # attr_max = formula
  101.     # Set the max attribute points an actor can gain.
  102.     # Default: Based on actor's luck times magic attack power.
  103.     def self.attr_max(actor)
  104.       case $game_actors[actor.id].id
  105.       when 1 ; $game_actors[actor.id].luk * $game_actors[actor.id].mat
  106.       when 2 ; $game_actors[actor.id].luk * $game_actors[actor.id].mat
  107.       # // Add more actor_id's here.
  108.       else   ; 0 # // Prevent error if nil as in actor id isn't in party.
  109.       end
  110.     end
  111.    
  112.     # LIST_ICONS[id] = icon_id
  113.     # Set the list icon_id. (optional)
  114.     LIST_ICONS = []
  115.     LIST_ICONS[0] = 32 # HP
  116.     LIST_ICONS[1] = 33 # MP
  117.     LIST_ICONS[2] = 34 # ATK
  118.     LIST_ICONS[3] = 35 # DEF
  119.     LIST_ICONS[4] = 36 # MAGIC
  120.     LIST_ICONS[5] = 37 # RES
  121.     LIST_ICONS[6] = 38 # AGL
  122.     LIST_ICONS[7] = 39 # LUK
  123.     LIST_ICONS[8] = 4141 # HIT
  124.     LIST_ICONS[9] = 4157 # EVA
  125.     LIST_ICONS[10] = 4164 # CRI
  126.     LIST_ICONS[11] = 4170 # CEV
  127.     LIST_ICONS[12] = 4172 # MEV
  128.     LIST_ICONS[13] = 4152 # MRF
  129.    
  130.     # PARAM_ICONS[id] = icon_id
  131.     # Set the param icon_id. (optional)
  132.     PARAM_ICONS = []
  133.     PARAM_ICONS[0] = 4149 # HP
  134.     PARAM_ICONS[1] = 4132 # MP
  135.     PARAM_ICONS[2] = 4145 # ATK
  136.     PARAM_ICONS[3] = 4150 # DEF
  137.     PARAM_ICONS[4] = 4147 # MAGIC
  138.     PARAM_ICONS[5] = 4148 # RES
  139.     PARAM_ICONS[6] = 4140 # AGL
  140.     PARAM_ICONS[7] = 4131 # LUK
  141.     PARAM_ICONS[8] = 4138 # EXP
  142.    
  143.     # XPARAM_ICONS[id] = icon_id
  144.     # Set the xparam icon_id. (optional)
  145.     XPARAM_ICONS = []
  146.     XPARAM_ICONS[0] = 4141 # HIT RATE
  147.     XPARAM_ICONS[1] = 4157 # EVASION RATE
  148.     XPARAM_ICONS[2] = 4164 # CRITICAL RATE
  149.     XPARAM_ICONS[3] = 4170 # CRITICAL EVASION
  150.     XPARAM_ICONS[4] = 4172 # MAGIC EVASION
  151.     XPARAM_ICONS[5] = 4152 # MAGIC REFLECTION
  152.    
  153.     # PARAM_BAR_COLOR = rgba(255,255,255,255)
  154.     # Set the color of the health, mana and parameter bars.
  155.     PARAM_BAR_COLOR = [Color.new(60,60,120,150), Color.new(200,200,200,180)]
  156.     PARAM_BAR_HP = [Color.new(225,50,50,64), Color.new(235,75,75,175)]
  157.     PARAM_BAR_MP = [Color.new(50,50,225,64), Color.new(75,75,235,175)]
  158.    
  159.     # PARAM_TXT_COLOR = rgba(255,255,255,255)
  160.     # Set the color of the parameter text.
  161.     PARAM_TXT_COLOR = [Color.new(255,255,255), Color.new(235,215,0)]
  162.    
  163.     # PARAM_LINE_COLOR = rgba(255,255,255,255)
  164.     # Set the color of the horizontal line.
  165.     PARAM_LINE_COLOR = [Color.new(255,255,255,200), Color.new(0,0,0,128)]
  166.    
  167.     # STAT_GROWTH = true/false
  168.     # Enable/disable the stat growth an actor normally have. i.e when levelling
  169.     # up you gain attributes to each parameter automatically.
  170.     # Note: Bare in mind that you cannot change this settings during the game
  171.     # so make sure you decide if you want this option enabled or not.
  172.     STAT_GROWTH = true
  173.    
  174.     # INITIAL_LEVEL = number
  175.     # Set the initial starting level if stat growth is disabled.
  176.     INITIAL_LEVEL = 1
  177.    
  178.     # ATTR_SWITCH = number
  179.     # Switch to manually disable gaining attributes points on levelling up.
  180.     ATTR_SWITCH = 10
  181.    
  182.     # MENU_CMD = true/false
  183.     # Enable this to create a attribute command to the default menu. (optional)
  184.     MENU_CMD = true
  185.    
  186.     # MENU_NAME = string
  187.     # Set this to the name you want on the command for the default menu. (optional)
  188.     MENU_NAME = "Attribute"
  189.    
  190.     # Transition, nil to use default.
  191.     # TRANSITION [ SPEED, TRANSITION, OPACITY ]
  192.     # TRANSITION = [40, "Graphics/Transitions/1", 50]
  193.     TRANSITION = nil
  194.    
  195.     # Background image (System folder)
  196.     # Note: You might want to decrease the opacity as well as arrange
  197.     # the windows so that you can properly see the background.
  198.     # Set to nil to use default.
  199.     BACK = nil
  200.    
  201.   end
  202. end
  203. # *** Don't edit below unless you know what you are doing. ***
  204. #==============================================================================#
  205. # ** Error Handler
  206. #==============================================================================#
  207. class XS_Error
  208.   unless $imported["XAIL-XS-CORE"]
  209.     # // Error handler when XS - Core is not installed.
  210.     msg = "The script %s requires the latest version of XS - Core in order to function properly."
  211.     name = "XS - Attribute System"
  212.     msgbox(sprintf(msg, name))
  213.     exit
  214.   end
  215. end
  216. #==============================================================================#
  217. # ** Game_BattlerBase
  218. #==============================================================================#
  219. class Game_BattlerBase
  220.  
  221.   alias xail_att_sys_gm_battlerbase_init initialize
  222.   def initialize(*args, &block)
  223.     # // Method to initialize.
  224.     clear_xparam_plus
  225.     xail_att_sys_gm_battlerbase_init(*args, &block)
  226.   end
  227.  
  228.   def xparam(xparam_id)
  229.     # // Method to get xparam.
  230.     (features_sum(FEATURE_XPARAM, xparam_id) + xparam_plus(xparam_id)).clamp(0,100).round_to(2)
  231.   end
  232.  
  233.   def xparam_plus(xparam_id)
  234.     # // Method to get xparam plus.
  235.     @xparam_plus[xparam_id]
  236.   end
  237.  
  238.   def clear_xparam_plus
  239.     # // Method to clear xparam plus.
  240.     @xparam_plus = [0] * 10
  241.   end
  242.  
  243.   def add_xparam(xparam_id, value)
  244.     # // Method to add xparam.
  245.     @xparam_plus[xparam_id] += value
  246.     refresh
  247.   end
  248.  
  249. end
  250. #==============================================================================#
  251. # ** Game_Actor
  252. #==============================================================================#
  253. class Game_Actor < Game_Battler
  254.  
  255.   attr_accessor :attribute_spent
  256.  
  257.   # // Method to initialize the window.
  258.   alias xail_att_sys_gm_actor_init initialize
  259.   def initialize(actor_id)
  260.     xail_att_sys_gm_actor_init(actor_id)
  261.     @attribute_spent = 0
  262.   end
  263.  
  264.   alias xail_att_sys_gm_actor_setup setup
  265.   def setup(actor_id)
  266.     # // Method to setup.
  267.     xail_att_sys_gm_actor_setup(actor_id)
  268.     clear_xparam_plus
  269.   end
  270.  
  271.   alias xail_att_sys_gm_actor_lvl_up level_up
  272.   def level_up(*args, &block)
  273.     # // Method when a actor level up.
  274.     xail_att_sys_gm_actor_lvl_up(*args, &block)
  275.     gain_attribute(actor.id, XAIL::ATTRIBUTE_SYSTEM.attr_points(actor)) unless $game_switches[XAIL::ATTRIBUTE_SYSTEM::ATTR_SWITCH]
  276.   end
  277.  
  278.   def param_base(param_id)
  279.     # // Method override to set param base.
  280.     if XAIL::ATTRIBUTE_SYSTEM::STAT_GROWTH
  281.       self.class.params[param_id, @level]
  282.     else
  283.       self.class.params[param_id, XAIL::ATTRIBUTE_SYSTEM::INITIAL_LEVEL]
  284.     end
  285.   end
  286.  
  287.   def gain_attribute(actor_id, value, type = :gain)
  288.     # // Method to gain attribute.
  289.     points = XAIL::ATTRIBUTE_SYSTEM::ACTOR_POINTS
  290.     case type
  291.     when :gain
  292.       points[actor_id] = (points[actor_id] + value).clamp(0, XAIL::ATTRIBUTE_SYSTEM.attr_max(actor))
  293.     when :lose
  294.       points[actor_id] = (points[actor_id] - value).clamp(0, XAIL::ATTRIBUTE_SYSTEM.attr_max(actor))
  295.     end
  296.   end
  297.  
  298.   def attribute?(actor_id)
  299.     # // Method to check actor's attribute.
  300.     XAIL::ATTRIBUTE_SYSTEM::ACTOR_POINTS[actor_id]
  301.   end
  302.  
  303. end
  304. #==============================================================================#
  305. # ** Game_Party
  306. #==============================================================================#
  307. class Game_Party < Game_Unit
  308.  
  309.   def attribute(actor_id, value, type = :gain)
  310.     # // Method to gain/lose attributes.
  311.     # Will return nil if actor is not in the party.
  312.     return unless members.include?($game_actors[actor_id])
  313.     return $game_actors[actor_id].gain_attribute(actor_id, value, type)
  314.   end
  315.  
  316.   def attribute?(actor_id)
  317.     # // Method to check actor's attribute.
  318.     # Will return nil if actor is not in the party.
  319.     return unless members.include?($game_actors[actor_id])
  320.     return $game_actors[actor_id].attribute?(actor_id)
  321.   end
  322.  
  323. end
  324. #==============================================================================#
  325. # ** Window_Base
  326. #==============================================================================#
  327. class Window_Base < Window
  328.  
  329.   def draw_current_and_max_values_ex(x, y, width, current, max, color1, color2)
  330.     # // New method to draw current and max values.
  331.     change_color(color1)
  332.     xr = x + width
  333.     if width < 96
  334.       draw_text(xr - 40, y, 42, line_height, current, 0)
  335.     else
  336.       draw_text(32, y, 42, line_height, current, 0)
  337.       change_color(color2)
  338.       draw_text(xr - 36, y, 42, line_height, max, 2)
  339.     end
  340.   end
  341.  
  342.   def draw_actor_stats(actor, stat, x, y, color1, color2, width = 339)
  343.     # // New method to draw actor hp & mp.
  344.     case stat
  345.     when :hp
  346.       rate = actor.hp_rate
  347.       vocab = Vocab::hp_a
  348.       values = [actor.hp, actor.mhp]
  349.     when :mp
  350.       rate = actor.mp_rate
  351.       vocab = Vocab::mp_a
  352.       values = [actor.mp, actor.mmp]
  353.     end
  354.     contents.font.name = XAIL::ATTRIBUTE_SYSTEM::FONT
  355.     contents.font.size = 16 # // Override font size.
  356.     contents.font.bold = true
  357.     contents.font.shadow = false
  358.     draw_gauge_ex(x, y - 14, width, 20, rate, color1, color2)
  359.     contents.font.color = XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0]
  360.     draw_text(x, y, contents.width, line_height, vocab, 1)
  361.     draw_current_and_max_values_ex(x - 8, y, width, values[0], values[1],
  362.     XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[1], XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[1])
  363.     reset_font_settings
  364.   end
  365.  
  366. end
  367. #==============================================================================#
  368. # ** Window_Attribute_List
  369. #==============================================================================#
  370. class Window_Attribute_List < Window_Command
  371.  
  372.   def standard_padding
  373.     # // Method to set padding.
  374.     return 8
  375.   end
  376.  
  377.   def window_width
  378.     # // Method to set the window width.
  379.     return 175
  380.   end
  381.  
  382.   def window_height
  383.     # // Method to set the window height.
  384.     return Graphics.height - 104
  385.   end
  386.  
  387.   def menu_color(color, enabled = true)
  388.     # // Method to set the color and alpha if not enabled.
  389.     contents.font.color.set(color)
  390.     contents.font.color.alpha = 100 unless enabled
  391.   end
  392.  
  393.   def draw_item(index)
  394.     # // Method to draw the command item.
  395.     contents.font.name = XAIL::ATTRIBUTE_SYSTEM::FONT
  396.     contents.font.size = 18 # // Override font size.
  397.     menu_color(XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0], menu_enabled?(index))
  398.     contents.font.bold = true
  399.     draw_icons(XAIL::ATTRIBUTE_SYSTEM::LIST_ICONS, :vertical)
  400.     draw_text(item_rect_for_icons(index), command_name(index), alignment)
  401.     reset_font_settings
  402.   end
  403.  
  404.   def item_rect_for_icons(index)
  405.      # // Method to draw the text with icons.
  406.     rect = item_rect(index)
  407.     rect.x += 26
  408.     rect.width -= 8
  409.     rect
  410.   end
  411.  
  412.   def menu_enabled?(index)
  413.     # // Method to check if item is enabled.
  414.     return XAIL::ATTRIBUTE_SYSTEM::LIST[index][3]
  415.   end
  416.  
  417.   alias xail_att_sys_winatt_mk_cmd_list make_command_list
  418.   def make_command_list(*args, &block)
  419.     # // Method to add the commands.
  420.     xail_att_sys_winatt_mk_cmd_list(*args, &block)
  421.     id = 0
  422.     for i in XAIL::ATTRIBUTE_SYSTEM::LIST
  423.       case i[0]
  424.       when :hit ; add_command(Vocab::xparam(0), i[0], i[3])
  425.       when :eva ; add_command(Vocab::xparam(1), i[0], i[3])
  426.       when :cri ; add_command(Vocab::xparam(2), i[0], i[3])
  427.       when :cev ; add_command(Vocab::xparam(3), i[0], i[3])
  428.       when :mev ; add_command(Vocab::xparam(4), i[0], i[3])
  429.       when :mrf ; add_command(Vocab::xparam(5), i[0], i[3])
  430.       else
  431.         add_command(Vocab::param(id), i[0], i[3])
  432.       end
  433.       id += 1
  434.     end
  435.   end
  436.  
  437. end
  438. #==============================================================================#
  439. # ** Window_Attribute_Info
  440. #==============================================================================#
  441. class Window_Attribute_Info < Window_Base
  442.  
  443.   def initialize(x, y, width, height)
  444.     # // Method to initialize the window.
  445.     super(x, y, width, height)
  446.     refresh
  447.   end
  448.  
  449.   def standard_padding
  450.     # // Method to set padding.
  451.     return 16
  452.   end
  453.  
  454.   def set_text(text, color = nil, alignment = 0)
  455.     # // Method to set a text to the window.
  456.     if text != @text
  457.       @text = text
  458.       @color = color
  459.       @alignment = alignment
  460.       refresh
  461.     end
  462.   end
  463.  
  464.   def refresh
  465.     # // Method to refresh the window.
  466.     contents.clear
  467.     contents.font.name = XAIL::ATTRIBUTE_SYSTEM::FONT
  468.     contents.font.size = 17 # // Override font size.
  469.     contents.font.color = @color.nil? ? Color.new(255,255,255) : @color
  470.     draw_text(0, 0, contents.width, line_height, @text, @alignment)
  471.     reset_font_settings
  472.   end
  473.  
  474. end
  475. #==============================================================================#
  476. # ** Window_Attribute_Points
  477. #==============================================================================#
  478. class Window_Attribute_Points < Window_Base
  479.  
  480.   def initialize(actor, x, y, width, height)
  481.     # // Method to initialize the window.
  482.     super(x, y, width, height)
  483.     @actor = actor
  484.     refresh
  485.   end
  486.  
  487.   def standard_padding
  488.     # // Method to set padding.
  489.     return 16
  490.   end
  491.  
  492.   def actor=(actor)
  493.     # // Method to refresh and set actor.
  494.     return if @actor == actor
  495.     @actor = actor
  496.     refresh
  497.   end
  498.  
  499.   def refresh
  500.     # // Method to refresh the window.
  501.     contents.clear
  502.     current = XAIL::ATTRIBUTE_SYSTEM::ACTOR_POINTS[@actor.id].to_s
  503.     max = XAIL::ATTRIBUTE_SYSTEM.attr_max($game_actors[@actor.id]).to_s
  504.     text = "Points: " + current + " / " + max
  505.     contents.font.name = XAIL::ATTRIBUTE_SYSTEM::FONT
  506.     contents.font.size = 20 # // Override font size.
  507.     contents.font.color = Color.new(255,255,255)
  508.     draw_text(0, 0, contents.width, line_height, text)
  509.     reset_font_settings
  510.   end
  511.  
  512. end
  513. #==============================================================================#
  514. # ** Window_Status
  515. #==============================================================================#
  516. class Window_Attribute_Status < Window_Selectable
  517.  
  518.   def initialize(actor)
  519.     # // Method to initialize window.
  520.     super(175, 52, Graphics.width - 175, Graphics.height - 52)
  521.     @actor = actor
  522.     refresh
  523.     activate
  524.   end
  525.  
  526.   def actor=(actor)
  527.     # // Method to refresh and set actor.
  528.     return if @actor == actor
  529.     @actor = actor
  530.     refresh
  531.   end
  532.  
  533.   def refresh
  534.     # // Method to refresh.
  535.     contents.clear
  536.     # Draw icons.
  537.     draw_icons(XAIL::ATTRIBUTE_SYSTEM::PARAM_ICONS, :vertical, 0, line_height * 2, [4138])
  538.     draw_icons(XAIL::ATTRIBUTE_SYSTEM::XPARAM_ICONS, :vertical, 215, line_height * 4)
  539.     # Draw actor details.
  540.     draw_font_text(@actor.name, 0, line_height * 0, 112, 0, XAIL::ATTRIBUTE_SYSTEM::FONT, 22, XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0])
  541.     draw_font_text(@actor.class.name, 0, line_height * 0, contents_width, 1, XAIL::ATTRIBUTE_SYSTEM::FONT, 22, XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0])
  542.     # Draw line.
  543.     draw_line_ex(-48, line_height * 1, XAIL::ATTRIBUTE_SYSTEM::PARAM_LINE_COLOR[0], XAIL::ATTRIBUTE_SYSTEM::PARAM_LINE_COLOR[1])
  544.     # Draw actor stats.
  545.     draw_actor_stats(@actor, :hp, 70, line_height * 2, XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_HP[0], XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_HP[1])
  546.     draw_actor_stats(@actor, :mp, 70, line_height * 3, XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_MP[0], XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_MP[1])
  547.     # Draw actor parameters and xparameters.
  548.     draw_parameters(20, line_height * 4)
  549.     draw_xparameters(199, line_height * 4)
  550.     # Draw line.
  551.     draw_line_ex(48, line_height * 10, XAIL::ATTRIBUTE_SYSTEM::PARAM_LINE_COLOR[0], XAIL::ATTRIBUTE_SYSTEM::PARAM_LINE_COLOR[1])
  552.     # Draw experience info.
  553.     draw_exp_info(20, line_height * 10)
  554.     # Draw line.
  555.     draw_line_ex(-48, line_height * 12, XAIL::ATTRIBUTE_SYSTEM::PARAM_LINE_COLOR[0], XAIL::ATTRIBUTE_SYSTEM::PARAM_LINE_COLOR[1])
  556.     # Draw points spent and actor level.
  557.     draw_font_text("Points spent: " + @actor.attribute_spent.to_s, 0, line_height * 13, 140, 0, XAIL::ATTRIBUTE_SYSTEM::FONT, 22, XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0])
  558.     if $imported["XAIL-LVL-TITLE"]
  559.       lvl = "#{Vocab::level_a}: #{draw_title_level(@actor)}"
  560.     else
  561.       lvl = "#{Vocab::level_a}: #{@actor.level}  /  #{@actor.max_level}"
  562.     end
  563.     draw_font_text(lvl, 0, line_height * 13, contents_width, 2, XAIL::ATTRIBUTE_SYSTEM::FONT, 22, XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0])
  564.   end
  565.  
  566.   def draw_parameters(x, y)
  567.     # // Method to draw parameters.
  568.     font = XAIL::ATTRIBUTE_SYSTEM::FONT
  569.     size = 16 # // Override font size.
  570.     c1 = XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_COLOR[0]
  571.     c2 = XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_COLOR[1]
  572.     c3 = XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0]
  573.     c4 = XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[1]
  574.     6.times {|i| draw_actor_param_gauge(@actor, x + 5, y + line_height * i, 185, i + 2, font, size, c1, c2, c3, c4) }
  575.   end
  576.  
  577.   def draw_xparameters(x, y)
  578.     # // Method to draw xparameters.
  579.     font = XAIL::ATTRIBUTE_SYSTEM::FONT
  580.     size = 16 # // Override font size.
  581.     c1 = XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_COLOR[0]
  582.     c2 = XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_COLOR[1]
  583.     c3 = XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[0]
  584.     c4 = XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[1]
  585.     6.times {|i| draw_actor_xparam_gauge(@actor, x + 45, y + line_height * i, 185, i, font, size, c1, c2, c3, c4) }
  586.   end
  587.  
  588.   def draw_exp_info(x, y)
  589.     # // Method to draw exp details.
  590.     s1 = @actor.max_level? ? "?" : @actor.exp
  591.     s2 = @actor.max_level? ? "?" : @actor.next_level_exp - @actor.exp
  592.     param_rate = @actor.exp / @actor.next_level_exp.to_f
  593.     contents.font.name = XAIL::ATTRIBUTE_SYSTEM::FONT
  594.     contents.font.size = 16 # // Override font size.
  595.     contents.font.color = XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[1]
  596.     contents.font.bold = true
  597.     contents.font.shadow = false
  598.     draw_gauge_ex(x, y + 9, 339, 20, param_rate, XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_COLOR[0], XAIL::ATTRIBUTE_SYSTEM::PARAM_BAR_COLOR[1])
  599.     draw_text(x + 10, y + line_height, 339, line_height, s1, 0)
  600.     draw_text(x + 339 / 2, y + line_height, 339, line_height, "EXP", 0)
  601.     draw_text(x - 2, y + line_height, 339, line_height, s2, 2)    
  602.   end
  603.  
  604. end
  605. #==============================================================================#
  606. # ** Scene_AttributeBase
  607. #==============================================================================#
  608. class Scene_AttributeBase < Scene_Base
  609.  
  610.   alias xail_att_sys_scenebase_start start
  611.   def start(*args, &block)
  612.     # // Method to start the scene
  613.     xail_att_sys_scenebase_start(*args, &block)
  614.     create_background
  615.   end
  616.  
  617.   def create_background
  618.     # // Method to create the background.
  619.     @background_sprite = Sprite.new
  620.     if XAIL::ATTRIBUTE_SYSTEM::BACK.nil?
  621.       @background_sprite.bitmap = SceneManager.background_bitmap
  622.       @background_sprite.color.set(16, 16, 16, 128)
  623.     else
  624.       @background_sprite.bitmap = Cache.system(XAIL::ATTRIBUTE_SYSTEM::BACK)
  625.     end
  626.   end
  627.  
  628.   alias xail_att_sys_scenebase_perf_trans perform_transition
  629.   def perform_transition(*args, &block)
  630.     # // Method to create the transition.´
  631.     XAIL::ATTRIBUTE_SYSTEM::TRANSITION.nil? ? Graphics.transition(15) : Graphics.transition(XAIL::ATTRIBUTE_SYSTEM::TRANSITION[0],XAIL::ATTRIBUTE_SYSTEM::TRANSITION[1],XAIL::ATTRIBUTE_SYSTEM::TRANSITION[2])
  632.     xail_att_sys_scenebase_perf_trans(*args, &block)
  633.   end
  634.  
  635.   def next_actor
  636.     # // Method to go to next actor.
  637.     @actor = $game_party.menu_actor_next
  638.     on_actor_change
  639.   end
  640.  
  641.   def prev_actor
  642.     # // Method to go to previous actor.
  643.     @actor = $game_party.menu_actor_prev
  644.     on_actor_change
  645.   end
  646.  
  647. end
  648. #==============================================================================#
  649. # ** Scene_Attribute
  650. #==============================================================================#
  651. class Scene_Attribute < Scene_AttributeBase
  652.  
  653.   def start
  654.     # // Method to start scene teleport.
  655.     super
  656.     @actor = $game_party.menu_actor
  657.     create_attribute_list
  658.     create_attribute_info
  659.     create_attribute_points
  660.     create_attribute_param
  661.     create_attribute_status
  662.     on_index_change(0)
  663.   end
  664.  
  665.   def create_attribute_list
  666.     # // Method to create attribute window list.
  667.     @attribute_list = Window_Attribute_List.new(0, 0)
  668.     for i in XAIL::ATTRIBUTE_SYSTEM::LIST
  669.       @attribute_list.set_handler(i[0], method(:command_attribute))
  670.     end
  671.     @attribute_list.set_handler(:pagedown, method(:next_actor))
  672.     @attribute_list.set_handler(:pageup,   method(:prev_actor))
  673.     @attribute_list.set_handler(:cancel, method(:return_scene))
  674.   end
  675.  
  676.   def on_actor_change
  677.     # // Method to change actor.
  678.     @attribute_status.actor = @actor
  679.     @attribute_points.actor = @actor
  680.     @attribute_list.activate
  681.     refresh_windows
  682.   end
  683.  
  684.   def refresh_windows
  685.     # // Method to refresh windows.
  686.     @attribute_param.refresh
  687.     @attribute_status.refresh
  688.     @attribute_points.refresh
  689.   end
  690.  
  691.   def create_attribute_info
  692.     # // Method to create attribute info window.
  693.     w = Graphics.width - @attribute_list.width
  694.     x = @attribute_list.width
  695.     @attribute_info = Window_Attribute_Info.new(x, 0, w, 52)
  696.   end
  697.  
  698.   def create_attribute_points
  699.     # // Method to create attribute points window.
  700.     y = @attribute_list.height
  701.     w = @attribute_list.width
  702.     @attribute_points = Window_Attribute_Points.new(@actor, 0, y, w, 52)
  703.   end
  704.  
  705.   def create_attribute_param
  706.     # // Method to create attribute parameter window.
  707.     y = @attribute_list.height + @attribute_points.height
  708.     w = @attribute_list.width
  709.     @attribute_param = Window_Attribute_Info.new(0, y, w, 52)
  710.   end
  711.  
  712.   def create_attribute_status
  713.     # // Method to create attribute status window.
  714.     @attribute_status = Window_Attribute_Status.new(@actor)
  715.   end
  716.  
  717.   alias xail_att_sys_scene_update update
  718.   def update(*args, &block)
  719.     # // Method for updating the scene.
  720.     old_index = @attribute_list.index
  721.     xail_att_sys_scene_update(*args, &block)
  722.     on_index_change(@attribute_list.index) if old_index != @attribute_list.index
  723.   end
  724.  
  725.   def on_index_change(index)
  726.     # // Method when index changes.
  727.     title = Vocab::param(index)
  728.     case index
  729.     when 8  ; title = Vocab::xparam(0)
  730.     when 9  ; title = Vocab::xparam(1)
  731.     when 10 ; title = Vocab::xparam(2)
  732.     when 11 ; title = Vocab::xparam(3)
  733.     when 12 ; title = Vocab::xparam(4)
  734.     when 13 ; title = Vocab::xparam(5)
  735.     end
  736.     stats = XAIL::ATTRIBUTE_SYSTEM::LIST[index][1].to_s
  737.     cost = XAIL::ATTRIBUTE_SYSTEM::LIST[index][2].to_s
  738.     @attribute_param.set_text(title.to_s + " +" + stats, Color.new(150,205,150,225))
  739.     @attribute_info.set_text("Distribute " + title + ". Cost » " + cost + " points", XAIL::ATTRIBUTE_SYSTEM::PARAM_TXT_COLOR[1])
  740.     refresh_windows
  741.   end
  742.  
  743.   def command_attribute
  744.     # // Method to add attribute.
  745.     case @attribute_list.current_symbol
  746.     when :hp    ; change_param(0, :param)
  747.     when :mp    ; change_param(1, :param)
  748.     when :atk   ; change_param(2, :param)
  749.     when :def   ; change_param(3, :param)
  750.     when :magic ; change_param(4, :param)
  751.     when :res   ; change_param(5, :param)
  752.     when :agl   ; change_param(6, :param)
  753.     when :luk   ; change_param(7, :param)
  754.     when :hit   ; change_param(0, :xparam)
  755.     when :eva   ; change_param(1, :xparam)
  756.     when :cri   ; change_param(2, :xparam)
  757.     when :cev   ; change_param(3, :xparam)
  758.     when :mev   ; change_param(4, :xparam)
  759.     when :mrf   ; change_param(5, :xparam)
  760.     end
  761.     @attribute_list.activate
  762.     refresh_windows
  763.   end
  764.  
  765.   def change_param(param_id, type)
  766.     # // Method to change param.
  767.     case type
  768.     when :param
  769.       id = XAIL::ATTRIBUTE_SYSTEM::LIST[param_id]
  770.     when :xparam
  771.       id = XAIL::ATTRIBUTE_SYSTEM::LIST[param_id + 8]
  772.     end
  773.     unless $game_party.attribute?(@actor.id) == 0
  774.       return Sound.play_buzzer if $game_party.attribute?(@actor.id) < id[2]
  775.       $game_party.attribute(@actor.id, id[2], :lose)
  776.       @actor.attribute_spent += id[2]
  777.       @actor.add_param(param_id, id[1]) if type == :param
  778.       @actor.add_xparam(param_id, id[1]) if type == :xparam
  779.     else
  780.       Sound.play_buzzer
  781.     end
  782.   end
  783.  
  784. end
  785. #==============================================================================#
  786. # ** Window_MenuCommand
  787. #==============================================================================#
  788. class Window_MenuCommand < Window_Command
  789.  
  790.   alias xail_att_sys_win_menucmd_add_main_commands add_main_commands
  791.   def add_main_commands(*args, &block)
  792.     xail_att_sys_win_menucmd_add_main_commands(*args, &block)
  793.     add_command(XAIL::ATTRIBUTE_SYSTEM::MENU_NAME, :attribute, true) if XAIL::ATTRIBUTE_SYSTEM::MENU_CMD
  794.   end
  795.    
  796. end
  797. #==============================================================================#
  798. # ** Scene_Menu
  799. #==============================================================================#
  800. class Scene_Menu < Scene_MenuBase
  801.  
  802.   alias xail_att_sys_scenemenu_create_cmd_window create_command_window
  803.   def create_command_window(*args, &block)
  804.     # // Method to create command window.
  805.     xail_att_sys_scenemenu_create_cmd_window(*args, &block)
  806.     @command_window.set_handler(:attribute, method(:command_attribute)) if XAIL::ATTRIBUTE_SYSTEM::MENU_CMD
  807.   end
  808.  
  809.   def command_attribute
  810.     # // Method to call attribute scene.
  811.     SceneManager.call(Scene_Attribute)
  812.   end
  813.  
  814. end # END OF FILE
  815.  
  816. #=*==========================================================================*=#
  817. # ** END OF FILE
  818. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement