adiktuzmiko

Custom Attributes v1.31

Oct 10th, 2014
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 22.78 KB | None | 0 0
  1. =begin
  2.  ==============================================================================
  3.  
  4.  Custom Attributes v1.31
  5.  by AdiktuzMiko
  6.  --- Date Created: 10/10/2014
  7.  --- Last Date Updated: 06/20/2015
  8.  --- Level: Easy
  9.  
  10.  ==============================================================================
  11.  Overview
  12.  ==============================================================================
  13.  
  14.  This script provides the ability to create your own custom attributes for your
  15.  actors, together with it's own scene which allows you to increase the
  16.  attributes. It has enough features for a basic attribute system, and can also
  17.  be used as a base for a more complex attribute sysyem.
  18.  
  19.  ==============================================================================
  20.  Set-Up
  21.  ==============================================================================
  22.  
  23.  Just put this script into a blank slot above main but below materials
  24.  (see compatibility section) and modify the settings below
  25.  
  26.  To increase an actor's attribute points
  27.  
  28.  actor_object.add_custom_attribute_points(value)
  29.  
  30.  To determine how much attribute points the actor has
  31.  
  32.  actor_object.get_custom_attribute_points
  33.  
  34.  To get the value of an attribute of an actor (base + bonus)
  35.  
  36.  actor_object.custom_attribute(index)
  37.  
  38.  To get the base value of an attribute of an actor
  39.  
  40.  actor_object.custom_attribute_no_bonus(index)
  41.  
  42.  To get the bonus value of an attribute of an actor
  43.  
  44.  actor_object.custom_attribute_bonus(index)
  45.  
  46.  To increase the base value of an attribute of an actor
  47.  
  48.  actor_object.add_custom_attribute(index,value)
  49.  
  50.  To increase the bonus value of an attribute of an actor
  51.  
  52.  actor_object.add_custom_attribute_bonus(index,value)
  53.  
  54.  To get the name of a custom attribute
  55.  
  56.  actor_object.custom_attribute_name(index)
  57.  
  58.  ----------------------------------------------------
  59.  The following is for locking and unlocking attributes.
  60.  To learn more about lock/unlock, go to the attribute list
  61.  set-up portion below
  62.  ----------------------------------------------------
  63.  
  64.  To unlock an attribute
  65.  
  66.  actor_object.unlock_custom_attribute(index)
  67.  
  68.  To lock a previously unlocked attribute
  69.  (only works on attributes added via the unlock call)
  70.  
  71.  actor_object.lock_custom_attribute(index)
  72.  
  73.  ----------------------------------------------------
  74.  ----------------------------------------------------
  75.  
  76.  To add a button for the attribute scene to your main menu:
  77.  
  78.  make a command that uses this method as a handler
  79.  
  80.  :command_attribute
  81.  
  82.  To call it from somewhere else
  83.  
  84.  SceneManager.call(Scene_CustomParam)
  85.  
  86.  ==============================================================================
  87.  Compatibility
  88.  ==============================================================================
  89.  
  90.  This script aliases Game_Actor's initialize method
  91.  
  92.  ==============================================================================
  93.  Notes
  94.  ==============================================================================
  95.  
  96.  The bonus value means values that won't be included in checking if you can
  97.  still increase the value of the attribute using the attribtue scene. Using
  98.  that, you can have equipments for example that gives bonus value to an
  99.  attribute that can make your attribute go past the limit, assuming you have
  100.  a script that allows running events or rgss3 methods upon equip/unequip like
  101.  my equip extension script.
  102.  
  103.  Example:
  104.  
  105.  If I already have 9/10 of an attribute then I equip an item that adds 1 to that
  106.  attribute's bonus value, it becomes 10/10. But since the 1 is added as a bonus
  107.  instead of directly to the base value of the attribute, I can still increase
  108.  that attribute on the scene so I can have 11/10.
  109.  
  110.  The custom attributes do nothing by default. It's all up to you to decide on
  111.  how to use them.
  112.  
  113.  If you want to increase the attribute points per level up of the actor,
  114.  you would use something like my Level Extension script.
  115.  
  116.  If you want to use them as a custom condition for equipments, you can use
  117.  my Custom Equip Requirements script.
  118.  
  119.  If you want them to be used in damage calculation, you can use the damage
  120.  formula for that.
  121.  
  122.  If you want them to increase a certain parameter with every point you
  123.  use on them, find this method below:
  124.  
  125.   def on_custom_attribute_increase(index,value)
  126.   end
  127.  
  128.   def on_custom_attribute_decrease(index,value)
  129.   end
  130.  
  131.  where index is the index of the custom attribute, and value is the
  132.  added/subtracted amount to it's level
  133.  
  134.  and edit it accordingly, use self to denote the actor
  135.  
  136.  Example: If I want attribute 2 to increase mhp by 10
  137.  
  138.    def on_custom_attribute_increase(index,value)
  139.     if index == 2
  140.       self.add_param(0,10)
  141.     end
  142.    end
  143.  
  144.  You can now also set specific methods to be run when a certain attribute is
  145.  increased/decreased instead of the global one. More info on the following
  146.  modules below. The global evaluation is done first before the specific
  147.    
  148.  ==============================================================================
  149.  Terms and Conditions
  150.  ==============================================================================
  151.  
  152.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  153.  
  154.  ==============================================================================
  155. =end
  156.  
  157. $imported = {} if $imported.nil?
  158. $imported["AdikCustomAttributes"] = 1.31
  159.  
  160. module ADIK
  161.   module ATTRIBUTES
  162.    
  163.     #Important: Do not remove
  164.     LIST = []
  165.     #List down your custom attributes here
  166.     #LIST[index] = Attribute Name
  167.     LIST[0] = "Sniper Rifle"
  168.     LIST[1] = "Rifle"
  169.     LIST[2] = "Handgun"
  170.     LIST[3] = "Energy Sniper Rifle"
  171.     LIST[4] = "Energy Rifle"
  172.     LIST[5] = "Energy Handgun"
  173.     LIST[6] = "Physical Bullets"
  174.     LIST[7] = "Energy Bullets"
  175.     LIST[8] = "Strength"
  176.     LIST[9] = "Speed"
  177.    
  178.     #List of custom attributes each actor has access to
  179.     #This just determines which attributes are shown on the
  180.     #attributes page for each actor, you can still use the
  181.     #script calls to modify the attribute of the actor even
  182.     #if it's not on the actor's specific list
  183.    
  184.     #If an actor doesn't have a specific list, he will have all
  185.     #attributes visible
  186.    
  187.     #You could also unlock an attribute using a script call stated on the
  188.     #notes above. You can also lock a previously unlocked attribute.
  189.    
  190.     #ACTOR_LIST[index] = [attribute1,attribute2,...,and so on]
  191.     ACTOR_LIST = []
  192.     ACTOR_LIST[1] = []
  193.    
  194.     #Important: Do not remove
  195.     #List down the descriptions for your custom attributes here
  196.     #DESCRIPTION[index] = Description
  197.     DESCRIPTION = []
  198.     DESCRIPTION[0] = "Increases proficiency with physical sniper rifles. Decreases reload speed and shot variance."
  199.     DESCRIPTION[1] = "Increases proficiency with physical rifles. Decreases reload speed and shot variance."
  200.     DESCRIPTION[2] = "Increases proficiency with physical handguns. Decreases reload speed and shot variance."
  201.     DESCRIPTION[3] = "Increases proficiency with energy sniper rifles. Decreases shot variance."
  202.     DESCRIPTION[4] = "Increases proficiency with energy rifles. Decreases shot variance."
  203.     DESCRIPTION[5] = "Increases proficiency with energy handguns. Decreases shot variance."
  204.     DESCRIPTION[6] = "Increases damage dealt with physical guns."
  205.     DESCRIPTION[7] = "Increases damage dealt with energy guns."
  206.     DESCRIPTION[8] = "Increases body strength to equip heavy equipment."
  207.     DESCRIPTION[9] = "Increases speed allowing you to move and reload faster."
  208.    
  209.     #Important: Do not remove
  210.     #List down the maximum points each attributes can reach
  211.     #MAX[index] = value
  212.     MAX = []
  213.     MAX[0] = 10
  214.     MAX[1] = 10
  215.     MAX[2] = 10
  216.     MAX[3] = 10
  217.     MAX[4] = 10
  218.     MAX[5] = 10
  219.     MAX[6] = 10
  220.     MAX[7] = 10
  221.     MAX[8] = 10
  222.     MAX[9] = 10
  223.    
  224.     #Important: Do not remove
  225.     #List down methods that will be run if the corresponding
  226.     #attribute is increased
  227.     #The methods should be created in the next module
  228.    
  229.     #format is: METHODS_INCREASE[index] = :method_name
  230.     METHODS_INCREASE = {}
  231.     METHODS_INCREASE[0] = :zero_inc
  232.    
  233.     #Important: Do not remove
  234.     #List down methods that will be run if the corresponding
  235.     #attribute is decreased
  236.     #The methods should be created in the next module
  237.    
  238.     #format is: METHODS_INCREASE[index] = :method_name
  239.     METHODS_DECREASE = {}
  240.     METHODS_DECREASE[0] = :zero_dec
  241.    
  242.     #Windowskin for the attribute window
  243.     MAIN_SKIN = "Window.png"
  244.     #X position of attribute window
  245.     MAIN_X = 240
  246.     #Y position of attribute window
  247.     MAIN_Y = 96
  248.     #Width of attribute window
  249.     MAIN_W = 544
  250.     #Height of attribute window
  251.     MAIN_H = 264
  252.    
  253.     #Windowskin for the description window
  254.     DESCRIPTION_SKIN = "Window.png"
  255.     #X position of attribute window
  256.     DESCRIPTION_X = 0
  257.     #Y position of attribute window
  258.     DESCRIPTION_Y = 24
  259.     #Width of attribute window
  260.     DESCRIPTION_W = 1024
  261.    
  262.     #Windowskin of actor window
  263.     ACTOR_SKIN = "Window.png"
  264.     #X position of actor window
  265.     ACTOR_X = 0 #220
  266.     #Y position of actor window
  267.     ACTOR_Y = 408
  268.     #Width of actor window
  269.     ACTOR_W = 1024
  270.    
  271.     #Background image for the scene
  272.     #Needs to be inside Graphics\System
  273.     #Set to nil if you want to use the default menu
  274.     #background
  275.     BACKGROUND = nil
  276.    
  277.     #X position of the value of the attribute
  278.     #relative to X of attribute window
  279.     VALUE_X = 24
  280.     #X position of the name of the attribute
  281.     #relative to X of attribute window
  282.     NAME_X = 96
  283.     #Font of the attribute name
  284.     #[Font name, font size, normal color, disabled color, max color]
  285.     NAME_FONT = [Font.default_name,18,Color.new(255,255,255),Color.new(100,100,100),Color.new(200,200,50)]
  286.     #Font of the attribute value
  287.     #[Font name, font size, normal color, disabled color, max color]
  288.     VALUE_FONT = [Font.default_name,18,Color.new(0,255,200),Color.new(0,255,200),Color.new(255,0,0)]
  289.     #Font of the description window
  290.     #[Font name, font size, normal color]
  291.     DESC_FONT = [Font.default_name,24,Color.new(255,255,255)]
  292.     #Font of the actor window
  293.     #[Font name, font size, normal color]
  294.     ACTOR_FONT = [Font.default_name,24,Color.new(255,255,255)]
  295.    
  296.     #Show max value beside the current value
  297.     SHOW_MAX = true
  298.    
  299.     #Separate the attribute bonus from the total?
  300.     SEPARATE_BONUS = false
  301.  
  302.   end
  303. end
  304.  
  305. module ADIK
  306.   module CA_METHODS
  307.    
  308.     #add the methods for specific increase/decrease here
  309.     #format is:
  310.    
  311.     #def self.method_name(actor,index,value)
  312.     # do things here
  313.     #end
  314.    
  315.     #actor is the actor which increased the attribute
  316.     #index is the index of the custom attribute modified
  317.     #value is the added/subtracted amount
  318.    
  319.     #example
  320.     def self.zero_inc(actor,index,value)
  321.       p "This is a test, it should only appear for attribute 0."
  322.     end
  323.    
  324.     def self.zero_dec(actor,index,value)
  325.       p "This is a test, it should only appear for attribute 0."
  326.     end
  327.    
  328.   end
  329. end
  330.  
  331. class Scene_CustomParam < Scene_Base
  332.  
  333.   #Text shown on actor window
  334.   def actor_text(actor)
  335.     return actor.name + " The " + actor.nickname + " - Attribute Points: " + actor.get_custom_attribute_points.to_s
  336.   end
  337.  
  338. end
  339.  
  340. class Game_Actor
  341.  
  342.   #Contains the global attribute increase/decrease methods
  343.  
  344.   #Edit this to do custom things when an attribute is increased
  345.   def on_custom_attribute_increase(index,value)
  346.     p "System Message: Increased " + custom_attribute_name(index)
  347.   end
  348.  
  349.   #Edit this to do custom things when an attribute is decreased
  350.   def on_custom_attribute_decrease(index,value)
  351.   end
  352.  
  353. end
  354.  
  355. #==================================================================
  356. #DO NOT EDIT BEYOND THIS POINT
  357. #==================================================================
  358.  
  359.  
  360. #==================================================================
  361. #I SAID DO NOT EDIT BEYOND THIS POINT
  362. #==================================================================
  363.  
  364. class Game_Actor
  365.  
  366.   alias initialize_custom_attributes_adik initialize
  367.   def initialize(actor_id)
  368.     initialize_custom_attributes_adik(actor_id)
  369.     load_custom_attributes
  370.     load_custom_attributes_bonus
  371.     load_custom_attributes_list(actor_id)
  372.     @custom_attribute_points = 0 if @custom_attribute_points.nil?
  373.   end
  374.  
  375.   def load_custom_attributes
  376.     @custom_attribute = []
  377.     ADIK::ATTRIBUTES::LIST.each_index do |index|
  378.       @custom_attribute[index] = [0,ADIK::ATTRIBUTES::LIST[index]]
  379.     end
  380.   end
  381.  
  382.   def load_custom_attributes_bonus
  383.     @custom_attribute_bonus = []
  384.     ADIK::ATTRIBUTES::LIST.each_index do |index|
  385.       @custom_attribute_bonus[index] = 0
  386.     end
  387.   end
  388.  
  389.   def load_custom_attributes_list(actor_id)
  390.     @custom_attribute_list = []
  391.     if ADIK::ATTRIBUTES::ACTOR_LIST[actor_id].nil?
  392.       ADIK::ATTRIBUTES::LIST.each_index do |index|
  393.         @custom_attribute_list.push(index)
  394.       end
  395.     else
  396.       ADIK::ATTRIBUTES::ACTOR_LIST[actor_id].each do |index|
  397.         @custom_attribute_list.push(index)
  398.       end
  399.     end
  400.   end
  401.  
  402.   def get_custom_attribute_list_base
  403.     load_custom_attributes_list(@actor_id) if @custom_attribute_list.nil?
  404.     return @custom_attribute_list
  405.   end
  406.  
  407.   def get_custom_attribute_list_unlocked
  408.     @custom_attribute_list_ul = [] if @custom_attribute_list_ul.nil?
  409.     return @custom_attribute_list_ul
  410.   end
  411.  
  412.   def get_custom_attribute_list
  413.     return get_custom_attribute_list_base + get_custom_attribute_list_unlocked
  414.   end
  415.  
  416.   def get_custom_attribute_points
  417.     @custom_attribute_points = 0 if @custom_attribute_points.nil?
  418.     return @custom_attribute_points
  419.   end
  420.  
  421.   def add_custom_attribute_points(value)
  422.     @custom_attribute_points = 0 if @custom_attribute_points.nil?
  423.     @custom_attribute_points += value
  424.   end
  425.  
  426.   def custom_attributes
  427.     return @custom_attribute
  428.   end
  429.  
  430.   def custom_attributes_bonus
  431.     return @custom_attribute_bonus
  432.   end
  433.  
  434.   def custom_attribute(index)
  435.     load_custom_attributes if @custom_attribute.nil?
  436.     load_custom_attributes_bonus if @custom_attribute_bonus.nil?
  437.     return @custom_attribute[index][0] + @custom_attribute_bonus[index]
  438.   end
  439.  
  440.   def custom_attribute_no_bonus(index)
  441.     load_custom_attributes if @custom_attribute.nil?
  442.     return @custom_attribute[index][0]
  443.   end
  444.  
  445.   def custom_attribute_bonus(index)
  446.     load_custom_attributes_bonus if @custom_attribute_bonus.nil?
  447.     return @custom_attribute_bonus[index]
  448.   end
  449.  
  450.   def add_custom_attribute(index,value)
  451.     load_custom_attributes if @custom_attribute.nil?
  452.     @custom_attribute[index][0] += value
  453.     if value > 0
  454.       on_custom_attribute_increase(index,value)
  455.       if ADIK::ATTRIBUTES::METHODS_INCREASE.keys.include?(index)
  456.         ADIK::CA_METHODS.method(ADIK::ATTRIBUTES::METHODS_INCREASE[index]).call(self,index,value)
  457.       end
  458.     elsif value < 0
  459.       on_custom_attribute_decrease(index,value)
  460.       if ADIK::ATTRIBUTES::METHODS_DECREASE.keys.include?(index)
  461.         ADIK::CA_METHODS.method(ADIK::ATTRIBUTES::METHODS_DECREASE[index]).call(self,index,value)
  462.       end
  463.     end
  464.   end
  465.  
  466.   def add_custom_attribute_bonus(index,value)
  467.     load_custom_attributes_bonus if @custom_attribute_bonus.nil?
  468.     @custom_attribute_bonus[index] += value
  469.     if value > 0
  470.       on_custom_attribute_increase(index,value)
  471.     elsif value < 0
  472.       on_custom_attribute_decrease(index,value)
  473.     end
  474.   end
  475.  
  476.   def custom_attribute_name(index)
  477.     load_custom_attributes if @custom_attribute.nil?
  478.     return @custom_attribute[index][1]
  479.   end
  480.  
  481.   def lock_custom_attribute(index)
  482.     @custom_attribute_list_ul = [] if @custom_attribute_list_ul.nil?
  483.     @custom_attribute_list_ul.delete(index) if @custom_attribute_list_ul.include?(index)
  484.   end
  485.  
  486.   def unlock_custom_attribute(index)
  487.     @custom_attribute_list_ul = [] if @custom_attribute_list_ul.nil?
  488.     @custom_attribute_list_ul.push(index) unless @custom_attribute_list_ul.include?(index)
  489.   end
  490.  
  491. end
  492.  
  493. class Window_CustomParam < Window_Command
  494.  
  495.   def initialize(x,y)
  496.     super
  497.     self.windowskin = Cache.system(ADIK::ATTRIBUTES::MAIN_SKIN)
  498.     @actor = $game_party.members[0]
  499.     create_help_window
  500.     refresh
  501.     update_help
  502.   end
  503.  
  504.   def create_help_window
  505.     @help_window = Window_CustomParamDesc.new(1)
  506.     @help_window.x = ADIK::ATTRIBUTES::DESCRIPTION_X
  507.     @help_window.y = ADIK::ATTRIBUTES::DESCRIPTION_Y
  508.     @help_window.width = ADIK::ATTRIBUTES::DESCRIPTION_W
  509.     @actor_window = Window_CustomParamActor.new(1)
  510.     @actor_window.x = ADIK::ATTRIBUTES::ACTOR_X
  511.     @actor_window.y = ADIK::ATTRIBUTES::ACTOR_Y
  512.     @actor_window.width = ADIK::ATTRIBUTES::ACTOR_W
  513.   end
  514.  
  515.   def window_width
  516.     return ADIK::ATTRIBUTES::MAIN_W
  517.   end
  518.  
  519.   def window_height
  520.     return ADIK::ATTRIBUTES::MAIN_H
  521.   end
  522.  
  523.   def set_actor(actor)
  524.     @actor = actor
  525.     refresh
  526.   end
  527.  
  528.   def actor
  529.     return @actor
  530.   end
  531.  
  532.   def get_index
  533.     return current_ext
  534.   end
  535.  
  536.   def can_increase(index,value)
  537.     return false if @actor.nil?
  538.     return @actor.get_custom_attribute_points > 0 && (value < ADIK::ATTRIBUTES::MAX[index])
  539.   end
  540.    
  541.   def make_command_list
  542.     return if @actor.nil?
  543.     return if @actor.get_custom_attribute_list.empty?
  544.     @actor.get_custom_attribute_list.each do |index|
  545.       cparam = @actor.custom_attributes[index]
  546.       add_command(cparam[1], cparam[1].to_sym,can_increase(index,cparam[0]), index)
  547.     end
  548.   end
  549.  
  550.   def refresh
  551.     super
  552.     return if @actor.nil?
  553.     @actor_window.set_text(SceneManager.scene.actor_text(@actor))
  554.   end
  555.  
  556.   def draw_item(index)
  557.     change_color(normal_color, command_enabled?(index))
  558.     rect = item_rect_for_text(index)
  559.     rect = Rect.new(rect.x + ADIK::ATTRIBUTES::NAME_X,rect.y,rect.width,rect.height)
  560.     contents.font.name = ADIK::ATTRIBUTES::NAME_FONT[0]
  561.     contents.font.size = ADIK::ATTRIBUTES::NAME_FONT[1]
  562.     if @actor.custom_attribute_no_bonus(index) >= ADIK::ATTRIBUTES::MAX[index]
  563.       contents.font.color = ADIK::ATTRIBUTES::NAME_FONT[4]
  564.     elsif @list[index][:enabled]
  565.       contents.font.color = ADIK::ATTRIBUTES::NAME_FONT[2]
  566.     else
  567.       contents.font.color = ADIK::ATTRIBUTES::NAME_FONT[3]
  568.     end
  569.     draw_text(rect, command_name(index), alignment)
  570.     rect = item_rect_for_text(index)
  571.     rect = Rect.new(rect.x + ADIK::ATTRIBUTES::VALUE_X,rect.y,rect.width,rect.height)
  572.     contents.font.name = ADIK::ATTRIBUTES::VALUE_FONT[0]
  573.     contents.font.size = ADIK::ATTRIBUTES::VALUE_FONT[1]
  574.     if @actor.custom_attribute_no_bonus(index) >= ADIK::ATTRIBUTES::MAX[index]
  575.       contents.font.color = ADIK::ATTRIBUTES::VALUE_FONT[4]
  576.     elsif @list[index][:enabled]
  577.       contents.font.color = ADIK::ATTRIBUTES::VALUE_FONT[2]
  578.     else
  579.       contents.font.color = ADIK::ATTRIBUTES::VALUE_FONT[3]
  580.     end
  581.     if ADIK::ATTRIBUTES::SHOW_MAX
  582.       if ADIK::ATTRIBUTES::SEPARATE_BONUS
  583.         tx1 = @actor.custom_attribute_bonus(index).to_s
  584.         tx2 = @actor.custom_attribute_no_bonus(index).to_s
  585.         draw_text(rect, tx1 + " + " + tx2 + " / " + ADIK::ATTRIBUTES::MAX[index].to_s,alignment)
  586.       else
  587.         draw_text(rect,@actor.custom_attribute(index).to_s + " / " + ADIK::ATTRIBUTES::MAX[index].to_s,alignment)
  588.       end
  589.     else
  590.       if ADIK::ATTRIBUTES::SEPARATE_BONUS
  591.         tx1 = @actor.custom_attribute_bonus(index).to_s
  592.         tx2 = @actor.custom_attribute_no_bonus(index).to_s
  593.         draw_text(rect, tx1 + " + " + tx2,alignment)
  594.       else
  595.         draw_text(rect,@actor.custom_attribute(index),alignment)
  596.       end
  597.     end
  598.   end
  599.  
  600.   def update_help
  601.     if current_ext.nil?
  602.       @help_window.set_text("")
  603.     else
  604.       @help_window.set_text(ADIK::ATTRIBUTES::DESCRIPTION[current_ext])
  605.     end
  606.   end
  607.  
  608.   def dispose
  609.     @actor_window.dispose
  610.     @help_window.dispose
  611.     super
  612.   end
  613.  
  614. end
  615.  
  616. class Window_CustomParamDesc < Window_Help
  617.  
  618.   def initialize(line_height=1)
  619.     super
  620.     self.windowskin = Cache.system(ADIK::ATTRIBUTES::DESCRIPTION_SKIN)
  621.     contents.font.name = ADIK::ATTRIBUTES::DESC_FONT[0]
  622.     contents.font.size = ADIK::ATTRIBUTES::DESC_FONT[1]
  623.     contents.font.color = ADIK::ATTRIBUTES::DESC_FONT[2]
  624.   end
  625.  
  626.  def draw_text_ex(x, y, text)
  627.     #reset_font_settings
  628.     text = convert_escape_characters(text)
  629.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  630.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  631.   end
  632.  
  633. end
  634.  
  635. class Window_CustomParamActor < Window_Help
  636.  
  637.   def initialize(line_height=1)
  638.     super
  639.     self.windowskin = Cache.system(ADIK::ATTRIBUTES::ACTOR_SKIN)
  640.     contents.font.name = ADIK::ATTRIBUTES::ACTOR_FONT[0]
  641.     contents.font.size = ADIK::ATTRIBUTES::ACTOR_FONT[1]
  642.     contents.font.color = ADIK::ATTRIBUTES::ACTOR_FONT[2]
  643.   end
  644.  
  645.   def draw_text_ex(x, y, text)
  646.     #reset_font_settings
  647.     text = convert_escape_characters(text)
  648.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  649.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  650.   end
  651.  
  652. end
  653.  
  654. class Scene_CustomParam < Scene_Base
  655.  
  656.   def start
  657.     super
  658.     create_background
  659.     create_attribute_window
  660.   end
  661.  
  662.   def create_background
  663.     @background_sprite = Sprite.new
  664.     @background_sprite.bitmap = Cache.system(ADIK::ATTRIBUTES::BACKGROUND)
  665.     return unless @background_sprite.bitmap.nil?
  666.     @background_sprite.bitmap = SceneManager.background_bitmap
  667.     @background_sprite.color.set(16, 16, 16, 128)
  668.   end
  669.  
  670.   def create_attribute_window
  671.     @attribute_window = Window_CustomParam.new(ADIK::ATTRIBUTES::MAIN_X,ADIK::ATTRIBUTES::MAIN_Y)
  672.     @attribute_window.set_handler(:ok, method(:increase_custom_attribute))
  673.     @attribute_window.set_handler(:cancel, method(:return_scene))
  674.     @attribute_window.set_handler(:pagedown, method(:next_actor))
  675.     @attribute_window.set_handler(:pageup,   method(:prev_actor))
  676.   end
  677.  
  678.   def increase_custom_attribute
  679.     @attribute_window.actor.add_custom_attribute_points(-1)
  680.     @attribute_window.actor.add_custom_attribute(@attribute_window.get_index,1)
  681.     @attribute_window.refresh
  682.     @attribute_window.activate
  683.   end
  684.  
  685.   def next_actor
  686.     index = $game_party.members.index(@attribute_window.actor)
  687.     index += 1
  688.     if index == $game_party.members.size
  689.       index = 0
  690.     end
  691.     @attribute_window.set_actor($game_party.members[index])
  692.     @attribute_window.activate
  693.   end
  694.  
  695.   def prev_actor
  696.     index = $game_party.members.index(@attribute_window.actor)
  697.     index -= 1
  698.     if index < 0
  699.       index = $game_party.members.size - 1
  700.     end
  701.     @attribute_window.set_actor($game_party.members[index])
  702.     @attribute_window.activate
  703.   end
  704.  
  705.   def terminate
  706.     super
  707.     @attribute_window.dispose
  708.     @background_sprite.dispose
  709.   end
  710.  
  711. end
  712.  
  713. class Scene_Menu
  714.  
  715.   def command_attribute
  716.     SceneManager.call(Scene_CustomParam)
  717.   end
  718.  
  719. end
Advertisement
Add Comment
Please, Sign In to add comment