Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- -----------
- - Equipment Parameter Description v1.1
- - Made by: Sixth
- - Requires: Sixth's Negative Bonus Fix for Vlue's W/A Randomizer
- -----------
- - Description:
- Just a small script to show the basic parameters of the equipment in their
- description text. Can be good for lazy people who don't want to type all that
- into their description box, or if a custom script can generate random parameters
- for your equipment.
- The parameters will be displayed next to each other, and they will be separated
- and formatted automatically based on your settings in this script.
- Parameters with 0 value will be skipped from the display!
- -----------
- - Message Codes:
- To show up the equipment's parameters in their description:
- <params>
- That's it. Just enter this message code, and the magic happens. :D
- -----------
- To show only the equipment's base parameters without any bonuses from Vlue's
- script in their description, use this:
- <bparams>
- This requires Vlue's script!
- -----------
- To show only the bonus gotten from the randomized parameters, use this:
- <bonuses>
- This requires Vlue's Weapon/Armor Randomization script!
- If that script is not installed, this message code will be removed
- automatically from your description text!
- -----------
- - Installation:
- Place this script between Materials and Main.
- Don't forget to install the required script or you will get display errors!
- -----------
- - Terms of Usage:
- Credit me (Sixth) in your game, pretty please! :P
- -----------
- =end
- $imported = {} if $imported.nil?
- $imported["SixthStatDescription"] = true
- module StatDisplay
- #-----------------------------------------------------------------------------
- # Settings:
- #-----------------------------------------------------------------------------
- # Here are what each of these options do:
- #
- # :pos = The format used for displaying positive parameter values.
- # Expects one %s in the text, and that will be the actual value of
- # the parameter!
- # :neg = The format used for displaying negative parameter values.
- # Expects one %s in the text, and that will be the actual value of
- # the parameter!
- # :params = The format of the displayed parameter text.
- # Use <value> to display the parameter's value.
- # Use <name> to display the parameter's name.
- # You can also add any other text here.
- # :bparams = Same as :params, but this format is for the base parameter
- # display which requires Vlue's script.
- # :bonus = Same as :params, but this format is for the bonus parameter
- # display which requires Vlue's script.
- # :ptxt = A static text which will appear before the listed parameter data.
- # :bptxt = A static text which will appear before the listed base parameters.
- # :btxt = A static text which will appear before the listed bonus parameter
- # data.
- # :separator = The text used to separate the parameters from each other.
- # :end = The text which appears after the final parameter text.
- # :nparam = If you add something here, this text will be displayed in place of
- # the parameter values if there are no displayable parameter texts
- # (so, all of the parameter values are 0).
- # This one will be displayed for the total parameter display.
- # Set it to "" (so an empty string) and nothing will be shown in the
- # description if all parameter values are 0 for the equipment!
- # :nbparam = Same as above but this one is for the item's base parameter
- # display. Requires Vlue's script!
- # :nbonus = Same as above but this one is for the random bonus display from
- # Vlue's script!
- #
- # Note that in all of these text settings, you can use any message codes
- # you want! You can see I used some color codes in them as well.
- #-----------------------------------------------------------------------------
- Format = {
- :pos => "\ec[3]+%s\ec[0]",
- :neg => "\ec[2]%s\ec[0]",
- :params => "<value> <name>",
- :bparams => "<value> <name>",
- :bonus => "<value> <name>",
- :ptxt => "\ec[17]Stats\ec[0]: ",
- :bptxt => "\ec[18]Base Stats\ec[0]: ",
- :btxt => "\ec[1]Bonuses\ec[0]: ",
- :separator => ", ",
- :end => ".",
- :nparam => "----",
- :nbparam => "----",
- :nbonus => "----",
- }
- #-----------------------------------------------------------------------------
- # No more settings, shoo-shoo! :P
- #-----------------------------------------------------------------------------
- def self.bonus(item,total,pid)
- case item
- when RPG::Weapon; ori = $data_weapons[item.original_id]
- when RPG::Armor; ori = $data_armors[item.original_id]
- when RPG::Item; ori = $data_items[item.original_id]
- end
- diff = total - ori.params[pid]
- return diff
- end
- def self.get_params_txt(item)
- return "" if !item.respond_to?("params")
- txt = ""
- item.params.each_with_index do |val,pid|
- next if val == 0
- vtxt = sprintf(StatDisplay::Format[val > 0 ? :pos : :neg],val.to_s)
- dtxt = StatDisplay::Format[:params].clone
- dtxt.gsub!(/<value>/) { vtxt }
- dtxt.gsub!(/<name>/) { Vocab.param(pid) }
- txt += txt.empty? ? dtxt : (StatDisplay::Format[:separator] + dtxt)
- end
- if txt.empty?
- if !StatDisplay::Format[:nparam].empty?
- txt = StatDisplay::Format[:ptxt] + StatDisplay::Format[:nparam]
- end
- else
- txt += StatDisplay::Format[:end]
- txt = StatDisplay::Format[:ptxt] + txt
- end
- return txt
- end
- def self.get_bparams_txt(it)
- return "" if !it.respond_to?("params") || !$imported[:Vlue_WARandom]
- case it
- when RPG::Weapon; item = $data_weapons[it.original_id]
- when RPG::Armor; item = $data_armors[it.original_id]
- when RPG::Item; item = $data_items[it.original_id]
- end
- txt = ""
- item.params.each_with_index do |val,pid|
- next if val == 0
- vtxt = sprintf(StatDisplay::Format[val > 0 ? :pos : :neg],val.to_s)
- dtxt = StatDisplay::Format[:bparams].clone
- dtxt.gsub!(/<value>/) { vtxt }
- dtxt.gsub!(/<name>/) { Vocab.param(pid) }
- txt += txt.empty? ? dtxt : (StatDisplay::Format[:separator] + dtxt)
- end
- if txt.empty?
- if !StatDisplay::Format[:nbparam].empty?
- txt = StatDisplay::Format[:bptxt] + StatDisplay::Format[:nbparam]
- end
- else
- txt += StatDisplay::Format[:end]
- txt = StatDisplay::Format[:bptxt] + txt
- end
- return txt
- end
- def self.get_bonuses_txt(item)
- return "" if !item.respond_to?("params") || !$imported[:Vlue_WARandom]
- txt = ""
- bonuses = {}
- item.params.each_with_index do |val,pid|
- bonuses[pid] = self.bonus(item,val,pid)
- end
- bonuses.each do |pid,val|
- next if val == 0
- vtxt = sprintf(StatDisplay::Format[val > 0 ? :pos : :neg],val.to_s)
- dtxt = StatDisplay::Format[:bonus].clone
- dtxt.gsub!(/<value>/) { vtxt }
- dtxt.gsub!(/<name>/) { Vocab.param(pid) }
- txt += txt.empty? ? dtxt : (StatDisplay::Format[:separator] + dtxt)
- end
- if txt.empty?
- if !StatDisplay::Format[:nbonus].empty?
- txt = StatDisplay::Format[:btxt] + StatDisplay::Format[:nbonus]
- end
- else
- txt += StatDisplay::Format[:end]
- txt = StatDisplay::Format[:btxt] + txt
- end
- return txt
- end
- end
- class RPG::BaseItem
- def description
- desc = @description.clone
- desc.gsub!(/<bonuses>/i) { StatDisplay.get_bonuses_txt(self) }
- desc.gsub!(/<bparams>/i) { StatDisplay.get_bparams_txt(self) }
- desc.gsub!(/<params>/i) { StatDisplay.get_params_txt(self) }
- return desc
- end
- def description=(txt)
- @description = txt
- end
- end
- #==============================================================================
- # !!END OF SCRIPT!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement