Advertisement
neonblack

F/E Module

Feb 26th, 2013
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.43 KB | None | 0 0
  1. ##-----------------------------------------------------------------------------
  2. ## Effects and Features names module v1.0a
  3. ## Created by Neon Black
  4. ##
  5. ## For both commercial and non-commercial use as long as credit is given to
  6. ## Neon Black and any additional authors.  Licensed under Creative Commons
  7. ## CC BY 3.0 - http://creativecommons.org/licenses/by/3.0/.
  8. ##-----------------------------------------------------------------------------
  9.  
  10. ## Imported ID.  Revision 3.9.2013.
  11. $imported ||= {}
  12. $imported["CP_FEATURES_EFFECTS"] = 1.0
  13. module CP
  14. module VOCAB
  15.  
  16. ##-----------------------------------------------------------------------------
  17. ## This module is a scripter's resource to easily access names of features and
  18. ## effects.  It does some general handling of features and such is meant to
  19. ## provide a single config option for the user end rather than requiring them
  20. ## to redo vocab options for features in numerous scripts.
  21. ##-----------------------------------------------------------------------------
  22.  
  23. ##-----------------------------------------------------------------------------
  24. ## Has not been tested with and may not be compatible with Tsukihime's Effects
  25. ## Manager and Features Manager.  Compatability and use with them is planned in
  26. ## the future.
  27. ##-----------------------------------------------------------------------------
  28.  
  29. ##-----------------------------------------------------------------------------
  30. ##    Config:
  31. ## Below is where you can name the different features.  There are several tags
  32. ## that will change automatically when a script calls the vocab option.  These
  33. ## are as follows:
  34. ##
  35. ##  <i> - Changes into a term used by the feature or effect.  For example, it
  36. ##        would change into the name of an element for an element related
  37. ##        feature.
  38. ##  <n> - Displays a number as either a normal positive number, or a negative
  39. ##        number.  Used for non-percentage values.
  40. ##  <+n> - Displays a number the same as above, but always displays the
  41. ##         operator.  In other words a positive number will display with a + in
  42. ##         front of it.
  43. ##  <n%> - Displays a number as a percentage.  If this is used on a normal
  44. ##         number, the number will be multiplied by 100, so avoid this.
  45. ##  <+n%> - Same as above but always displays the operator.
  46. ##  <+an%> - Displays the number as an "adjusted percent" based on a default
  47. ##           value of 100%.  This takes the base percentage and subtracts 100
  48. ##           from it, for example, 120% would display as +20% when using this.
  49. ##  <in%> - Similar to <+an%> except it increases the number by 100%.  This can
  50. ##          be used in cases where an item decreases a stat from a base of 100%
  51. ##          and you want it to display a flat percentage rather than a negative
  52. ##          value.  As an example, a value of -10% would become 90%.
  53. ##
  54. ## NOTE: For features you can also use the tags <n2>, <+n2>, <n2%>, <+n2%>,
  55. ##       <+an2%>, and <in2%>.  These are used for features which can have 2
  56. ##       values instead of just one.  It's important to note that if an effect
  57. ##       does not have a second value, nothing will be shown, not even 0.
  58. ##------
  59. ## The following hashes have a 4 digit method of identifying the vocab to use
  60. ## for base features and effects.  From the user's point of view:
  61. ##
  62. ##  12003
  63. ##      1 - This number is the PAGE the feature or effect appears on.
  64. ##      2 - This number is the RADIO BUTTON of the effect on it's page.
  65. ##    003 - If the feature has a drop down menu, this is it's position in the
  66. ##          menu starting with 1.  You can use 000 instead as a catch-all for
  67. ##          the feature.  Vocabs that end in numbers other than 000 have
  68. ##          priority over vocabs that end in 000. (See effect 21001 for an
  69. ##          example of this)
  70. ##          NOTE: For drop downs that reference skills or states, the drop down
  71. ##          actually starts at 2 instead of 1 in my listing, so if you want a
  72. ##          special vocab for a certain skill or state, add 1 to the item's ID
  73. ##          when determining the number for the vocab in the hash.  Avoid using
  74. ##          skill/state 999 and over because this will cause issues.
  75. ##-----------------------------------------------------------------------------
  76.  
  77. Features ={
  78.  
  79. # NEW FEATURES - Base Stats
  80. #  These are not actually in the engine by default.  These are used by certain
  81. #  of Neon Black's script for features that add an exact number of a parameter.
  82.  1000 => "<+n> <i>",
  83.  
  84. # Page 1 - Resistances
  85. 11000 => "<i> Resist <n%>",
  86. 12000 => "<i> Sturdy <n%>",
  87. 13000 => "<i> Resist <n%>",
  88. 14000 => "<i> Immune",
  89.  
  90. # Page 2 - Parameters
  91. #  The second and third options (EX-Parameters and XP-Parameters) have terms not
  92. #  defined in the database.  They may be defeined here.
  93. 21000 => "<i> <+an%>",
  94. 22001 => "Hit Rate <+n%>",
  95. 22002 => "Evasion <+n%>",
  96. 22003 => "Critical <+n%>",
  97. 22004 => "Crit Evade <+n%>",
  98. 22005 => "Magic Evade <+n%>",
  99. 22006 => "Magic Reflect <+n%>",
  100. 22007 => "Counter <+n%>",
  101. 22008 => "HP Regen <+n%>",
  102. 22009 => "MP Regen <+n%>",
  103. 22010 => "TP Regen <+n%>",
  104. 23001 => "Agro <n%>",
  105. 23002 => "Guard Effect <n%>",
  106. 23003 => "Recovery Effect <n%>",
  107. 23004 => "Alchemy <n%>",
  108. 23005 => "MP Cost <n%>",
  109. 23006 => "TP Charge <n%>",
  110. 23007 => "Physical Rate <n%>",
  111. 23008 => "Magical Rate <n%>",
  112. 23009 => "Floor Damage <n%>",
  113. 23010 => "EXP Rate <n%>",
  114.  
  115. # Page 3 - Attack Effects
  116. 31000 => "<i> Strike",
  117. 32000 => "<i> Strike <+n%>",
  118. 33000 => "Speed <n>",
  119. 34000 => "Hits <n>",
  120.  
  121. # Page 4 - Skills
  122. 41000 => "<i> Caster",
  123. 42000 => "<i> Seal",
  124. 43000 => "Cast <i>",
  125. 44000 => "Seal <i>",
  126.  
  127. # Page 5 - Equips
  128. 51000 => "Equip <i>",
  129. 52000 => "Equip <i>",
  130. 53000 => "Lock <i>",
  131. 54000 => "Seal <i>",
  132. 55000 => "Dual-wield",
  133.  
  134. # Page 6 - Special
  135. #  These have special types of terms that cannot be defined in the database.
  136. #  Define them here.  NOTE: There is no 6301 (page 6, feature 3, option 1)
  137. #  because it is the default death animation.  The drop down menu starts at
  138. #  2 instead of 1 (6302).
  139. 61000 => "Added Action <n%>",
  140. 62001 => "Auto-fight",
  141. 62002 => "Strong Guard",
  142. 62003 => "True Knight",
  143. 62004 => "Save TP",
  144. 63002 => "Boss Collapse",
  145. 63003 => "Instant Collapse",
  146. 63004 => "Don't Collapse",
  147. 64001 => "Sneaking",
  148. 64002 => "Warding",
  149. 64003 => "Prevention",
  150. 64004 => "Surprising",
  151. 64005 => "x2 Gold",
  152. 64006 => "x2 Drop",
  153. }
  154.  
  155. Effects ={
  156.  
  157. # Page 1 - Recovery
  158. #  This is the only page that by default has 2 values.  Remember to use <n2%>
  159. #  or a similar tag with 2 for these.
  160. 11000 => "Recover <n%><n2> <i>",
  161. 12000 => "Recover <n%><n2> <i>",
  162. 13000 => "Gain <n> <i>",
  163.  
  164. # Page 2 - States
  165. #  Option 2101 is slightly different.  If you do not have a line 21001 here, you
  166. #  will get a crash.  The "Normal Attack" state is used to reference all states
  167. #  that can be applied by features and is option 1 in this case.
  168. 21000 => "Add <i> <n%>",
  169. 21001 => "Add Weapon States",
  170. 22000 => "Remove <i> <n%>",
  171.  
  172. # Page 3 - Buffs
  173. 31000 => "Buff <i> <n> turns",
  174. 32000 => "Debuff <i> <n> turns",
  175. 33000 => "Remove <i> buff",
  176. 34000 => "Remove <i> debuff",
  177.  
  178. # Page 4 - Special
  179. #  Note that effect 44000 is used to call a common event.  In this case <i>
  180. #  designates the common event's name.
  181. 41000 => "Escape Battle",
  182. 42000 => "<+n> <i>",
  183. 43000 => "Learn <i>",
  184. 44000 => "<i>",
  185. }
  186. ##-----------------------------------------------------------------------------
  187.  
  188. ##-----------------------------------------------------------------------------
  189. ##    For Scripters:
  190. ## This module currently only has a single real use.  You can quickly get the
  191. ## name of the effect or feature you're looking at by using the .vocab method.
  192. ## This will return a string similar to one of the strings above with the user's
  193. ## desired information.
  194. ##
  195. ## There are planned to be several other features, but they are not currently
  196. ## implimented.
  197. ##-----------------------------------------------------------------------------
  198.  
  199.  
  200. ###--------------------------------------------------------------------------###
  201. #  The following lines are the actual core code of the script.  While you are  #
  202. #  certainly invited to look, modifying it may result in undesirable results.  #
  203. #  Modify at your own risk!                                                    #
  204. ###--------------------------------------------------------------------------###
  205.  
  206.  
  207.   def self.feformat(voc, item = "", num = 0, num2 = 0)
  208.     vp = num >= 0 ? '+' : ''
  209.     vp2 = num2 >= 0 ? '+' : ''
  210.     voc.gsub!(/<i>/i,     item)                                      #  <i>
  211.     voc.gsub!(/<n>/i,     num == 0 ? "" : "#{num.to_i.to_s}")        #  <n>
  212.     voc.gsub!(/<\+?n>/i,  "#{vp}#{num.to_i.to_s}")                   #  <+n>
  213.     voc.gsub!(/<n\%>/i,   num == 0 ? "" : "#{(num * 100).to_i}%")    #  <n%>
  214.     voc.gsub!(/<\+n\%>/i, "#{vp}#{(num * 100).to_i}%")               #  <+n%>
  215.     voc.gsub!(/<n2>/i,     num2 == 0 ? "" : "#{num2.to_i.to_s}")     #  <n2>
  216.     voc.gsub!(/<\+?n2>/i,  "#{vp2}#{num2.to_i.to_s}")                #  <+n2>
  217.     voc.gsub!(/<n2\%>/i,   num2 == 0 ? "" : "#{(num2 * 100).to_i}%") #  <n%2>
  218.     voc.gsub!(/<\+n2\%>/i, "#{vp2}#{(num2 * 100).to_i}%")            #  <+n%2>
  219.     vp = num >= 1 ? '+' : ''
  220.     vp2 = num2 >= 1 ? '+' : ''
  221.     voc.gsub!(/<\+an\%>/i, "#{vp}#{(num * 100 - 100).to_i}%")        #  <+an%>
  222.     voc.gsub!(/<\+an2\%>/i, "#{vp2}#{(num2 * 100 - 100).to_i}%")     #  <+an2%>
  223.     voc.gsub!(/<\in\%>/i, "#{(num * 100 + 100).to_i}%")              #  <in%>
  224.     voc.gsub!(/<\in2\%>/i, "#{(num2 * 100 + 100).to_i}%")            #  <in2%>
  225.     voc
  226.   end
  227.  
  228. end # VOCAB
  229.  
  230. module Features
  231.   def self.get_feature(name, perc = "")
  232.     case name.downcase
  233.     when "mhp", "hp"; return perc != '%' ? [1, 0] : [21, 0]
  234.     when "mmp", "mp"; return perc != '%' ? [1, 1] : [21, 1]
  235.     when "atk"; return perc != '%' ? [1, 2] : [21, 2]
  236.     when "def"; return perc != '%' ? [1, 3] : [21, 3]
  237.     when "mat"; return perc != '%' ? [1, 4] : [21, 4]
  238.     when "mdf"; return perc != '%' ? [1, 5] : [21, 5]
  239.     when "agi"; return perc != '%' ? [1, 6] : [21, 6]
  240.     when "luk"; return perc != '%' ? [1, 7] : [21, 7]
  241.     when "hit"; return [22, 0]
  242.     when "eva"; return [22, 1]
  243.     when "cri"; return [22, 2]
  244.     when "cev"; return [22, 3]
  245.     when "mev"; return [22, 4]
  246.     when "mrf"; return [22, 5]
  247.     when "cnt"; return [22, 6]
  248.     when "hrg"; return [22, 7]
  249.     when "mrf"; return [22, 8]
  250.     when "trg"; return [22, 9]
  251.     when "tgr"; return [23, 0]
  252.     when "grd"; return [23, 1]
  253.     when "rec"; return [23, 2]
  254.     when "pha"; return [23, 3]
  255.     when "mcr"; return [23, 4]
  256.     when "tcr"; return [23, 5]
  257.     when "pdr"; return [23, 6]
  258.     when "mdr"; return [23, 7]
  259.     when "fdr"; return [23, 8]
  260.     when "exr"; return [23, 9]
  261.     else
  262.       return nil unless $imported["Feature_Manager"]
  263.       code = FeatureManager.get_feature_code(code.to_sym) rescue code = nil
  264.       return code ? [code, 0] : nil
  265.     end
  266.   end
  267.  
  268.   def self.term_name(code, data_id)
  269.     case code
  270.     when 1, 12, 21
  271.       return Vocab.param(data_id) || ""
  272.     when 11, 31
  273.       return $data_system.elements[data_id] || ""
  274.     when 13, 14, 32
  275.       return $data_states[data_id].name || ""
  276.     when 43, 44
  277.       return $data_skills[data_id].name || ""
  278.     when 41, 42
  279.       return $data_system.skill_types[data_id] || ""
  280.     when 51
  281.       return $data_system.weapon_types[data_id] || ""
  282.     when 52
  283.       return $data_system.armor_types[data_id] || ""
  284.     when 53, 54
  285.       return Vocab.etype(data_id) || ""
  286.     else
  287.       return ""
  288.     end
  289.   end
  290. end # Features
  291.  
  292. module Effects
  293.   def self.term_name(code, data_id)
  294.     case code
  295.     when 11
  296.       return Vocab::hp_a
  297.     when 12
  298.       return Vocab::mp_a
  299.     when 13
  300.       return Vocab::tp_a
  301.     when 21, 22
  302.       return data_id == 0 ? "Normal Attack" : $data_states[data_id].name || ""
  303.     when 31, 32, 33, 34, 42
  304.       return Vocab.param(data_id) || ""
  305.     when 43
  306.       return $data_skills[data_id].name || ""
  307.     when 44
  308.       return $data_common_events[data_id].name || ""
  309.     else
  310.       return ""
  311.     end
  312.   end
  313. end # Effects
  314. end # CP
  315.  
  316. class RPG::BaseItem::Feature
  317.   def vocab
  318.     if @code.is_a?(Fixnum)
  319.       n = @code * 1000 + (data_id + 1)
  320.       i = @code * 1000
  321.     else
  322.       n = i = @code
  323.     end
  324.     voc = nil
  325.     voc = CP::VOCAB::Features[n].dup if CP::VOCAB::Features.include?(n)
  326.     voc ||= CP::VOCAB::Features[i].dup if CP::VOCAB::Features.include?(i)
  327.     return "" if voc.nil?
  328.     term = CP::Features.term_name(@code, @data_id)
  329.     result = CP::VOCAB.feformat(voc, term, @value)
  330.     return result
  331.   end
  332. end
  333.  
  334. class RPG::UsableItem::Effect
  335.   def vocab
  336.     if @code.is_a?(Fixnum)
  337.       n = @code * 1000 + (@data_id + 1)
  338.       i = @code * 1000
  339.     else
  340.       n = i = @code
  341.     end
  342.     voc = nil
  343.     voc = CP::VOCAB::Effects[n].dup if CP::VOCAB::Effects.include?(n)
  344.     voc ||= CP::VOCAB::Effects[i].dup if CP::VOCAB::Effects.include?(i)
  345.     return "" if voc.nil?
  346.     term = CP::Effects.term_name(@code, @data_id)
  347.     result = CP::VOCAB.feformat(voc, term, @value1, @value2)
  348.   end
  349. end
  350.  
  351. class Game_BattlerBase
  352.   FEATURE_BASE_PARAM = 1
  353.  
  354.   alias cp_featurevocab_param_plus param_plus
  355.   def param_plus(param_id)
  356.     cp_featurevocab_param_plus(param_id) +
  357.     features_sum(FEATURE_BASE_PARAM, param_id)
  358.   end
  359. end
  360.  
  361.  
  362. ###--------------------------------------------------------------------------###
  363. #  End of script.                                                              #
  364. ###--------------------------------------------------------------------------###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement