TheoAllen

Theo - Additional Fixed Param

Dec 1st, 2013
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.21 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Additional (Fixed) Parameters
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_FixedParam] = true
  8. # =============================================================================
  9. # Change Logs:
  10. # -----------------------------------------------------------------------------
  11. # 2013.12.02 - Started and Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Dalam feature default RMVXA kamu hanya bisa mengubah-ubah parameter dalam
  17.   persen. Dengan artian kamu ngga bisa bikin state yang nambah parameter
  18.   dengan nilai yang konstan / fixed. Seperti attack akan ditambah dengan
  19.   nilai konstant seperti +10 atau semacamnya.
  20.  
  21.   Cara penggunaan :
  22.   Pasang script ini di bawah material namun diatas main
  23.   Gunakan notetag seperti di bawah ini pada notebox state
  24.  
  25.   Untuk pertambahan (ganti n dengan angka *udontsay)
  26.   <mhp: +n>
  27.   <mmp: +n>
  28.   <atk: +n>
  29.   <def: +n>
  30.   <mat: +n>
  31.   <mdf: +n>
  32.   <agi: +n>
  33.   <luk: +n>
  34.  
  35.   Untuk pengurangan, ganti + dengan -
  36.   Misalnya
  37.  
  38.   <mdf: +100>
  39.   <atk: -100>
  40.  
  41.   Terms of use :
  42.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  43.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  44.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  45.  
  46. =end
  47. # =============================================================================
  48. # No config ~
  49. # =============================================================================
  50. class RPG::State < RPG::BaseItem
  51.   attr_accessor :fixed_params
  52.  
  53.   def load_fixed_params
  54.     @fixed_params = Array.new(8) {0}
  55.     note.split(/[\r\n]+/).each do |line|
  56.       case line
  57.       when /<mhp\s*:\s*(\+|-)(\d+)>/i
  58.         if $1.to_s == "+"
  59.           @fixed_params[0] = $2.to_i
  60.         else
  61.           @fixed_params[0] = $2.to_i * -1
  62.         end
  63.       when /<mmp\s*:\s*(\+|-)(\d+)>/i
  64.         if $1.to_s == "+"
  65.           @fixed_params[1] = $2.to_i
  66.         else
  67.           @fixed_params[1] = $2.to_i * -1
  68.         end
  69.       when /<atk\s*:\s*(\+|-)(\d+)>/i
  70.         if $1.to_s == "+"
  71.           @fixed_params[2] = $2.to_i
  72.         else
  73.           @fixed_params[2] = $2.to_i * -1
  74.         end
  75.       when /<def\s*:\s*(\+|-)(\d+)>/i
  76.         if $1.to_s == "+"
  77.           @fixed_params[3] = $2.to_i
  78.         else
  79.           @fixed_params[3] = $2.to_i * -1
  80.         end
  81.       when /<mat\s*:\s*(\+|-)(\d+)>/i
  82.         if $1.to_s == "+"
  83.           @fixed_params[4] = $2.to_i
  84.         else
  85.           @fixed_params[4] = $2.to_i * -1
  86.         end
  87.       when /<mdf\s*:\s*(\+|-)(\d+)>/i
  88.         if $1.to_s == "+"
  89.           @fixed_params[5] = $2.to_i
  90.         else
  91.           @fixed_params[5] = $2.to_i * -1
  92.         end
  93.       when /<agi\s*:\s*(\+|-)(\d+)>/i
  94.         if $1.to_s == "+"
  95.           @fixed_params[6] = $2.to_i
  96.         else
  97.           @fixed_params[6] = $2.to_i * -1
  98.         end
  99.       when /<luk\s*:\s*(\+|-)(\d+)>/i
  100.         if $1.to_s == "+"
  101.           @fixed_params[7] = $2.to_i
  102.         else
  103.           @fixed_params[7] = $2.to_i * -1
  104.         end
  105.       end # case
  106.     end # each
  107.   end # load_fixed_params
  108.  
  109. end
  110.  
  111. class << DataManager
  112.  
  113.   alias theo_fixedparam_load_db load_database
  114.   def load_database
  115.     theo_fixedparam_load_db
  116.     $data_states.compact.each do |state|
  117.       state.load_fixed_params
  118.     end
  119.   end
  120.  
  121. end
  122.  
  123. class Game_Battler < Game_BattlerBase
  124.  
  125.   alias theo_fixedparam_param param
  126.   def param(param_id)
  127.     result = theo_fixedparam_param(param_id)
  128.     result += calc_fixed_param(param_id)
  129.     [[result, param_max(param_id)].min, param_min(param_id)].max.to_i
  130.   end
  131.  
  132.   def calc_fixed_param(param_id)
  133.     result = states.inject(0) do |r,state|
  134.       r + state.fixed_params[param_id]
  135.     end
  136.     if $imported[:Theo_PassiveSkill] && actor?
  137.       result += passive_skills.inject(0) do |r,state|
  138.         r + state.fixed_params[param_id]
  139.       end
  140.     end
  141.     return result
  142.   end
  143.  
  144. end
Advertisement
Add Comment
Please, Sign In to add comment