khanhdu

$D13x CORE

Jul 6th, 2015
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.82 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - CORE
  5. # -- Author   : Dekita
  6. # -- Version  : 2.0
  7. # -- Level    : Easy
  8. # -- Requires : N/A
  9. # -- Engine   : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:CORE] = true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 27/o5/2o13 - Added $game_party.alive_battle_members Method
  21. # 22/o5/2o13 - Small Bugfix, (fixed max tp gauge bug)
  22. # o4/o5/2o13 - Small Update, (added @database_id)
  23. # 18/o4/2o13 - Bugfixx, (tp gauge),
  24. #            - Added PrtSc Key,
  25. # o4/o4/2o13 - Added more keyboard keys,
  26. #            ^- :S_Colon, :Equal, :Comma, :Minus, :Period, :F_Slash, :HASH,
  27. #            ^- :L_Sqr_Brack, :B_Slash, :R_Sqr_Brack, :S_Quote,
  28. # o3/o4/2o13 - Fixed Keys.trigger? method
  29. #            - Added Keys.release? method
  30. # o1/o4/2o13 - Added More Keyboard Keys,
  31. #            ^- :F1, :F2, :F3, :F4, :F5, :F6, :F7, :F8, :F9, :F10, :F11, :F12
  32. #            ^- :N_0, :N_1, :N_2, :N_3, :N_4, :N_5, :N_6, :N_7, :N_8, :N_9,
  33. #            ^- :ADD, :MUL, :SUB, :DIV, :DECI, :TAB, :BACK, :ENTER, :CAPS,
  34. #            ^- :SPACE, :ESC, :ALT
  35. # 29/o3/2o13 - Added More Keyboard Keys,(Left/Right CTRL)
  36. # 28/o3/2o13 - Improved Customisation Layout,
  37. #            - Removed Some Methods,
  38. #            - Improved Keyboard Code,
  39. # 27/o3/2o13 - Added Keyboard Control,
  40. # 26/o3/2o13 - Compatibility, (Status Scene)
  41. #            - Update, (Icons w/Hue)
  42. # 18/03/2013 - Compatibility, (Skill Scene)
  43. # 23/o2/2o13 - Started, Finished,
  44. #
  45. #===============================================================================
  46. # ☆ Introduction
  47. #-------------------------------------------------------------------------------
  48. # This script simply holds some information and methods used by some other
  49. # scripts in the $D13x system.
  50. # Current Features:
  51. # Fonts,
  52. # Color,
  53. # Vocab,
  54. # Keyboard Control,
  55. # Icons (w/Hue)...
  56. #
  57. # Place above all other $D13x Scripts.
  58. #
  59. #===============================================================================
  60. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  61. #===============================================================================
  62. # 1. You MUST give credit to "Dekita" !!
  63. # 2. You are NOT allowed to repost this script.(or modified versions)
  64. # 3. You are NOT allowed to convert this script.
  65. # 4. You are NOT allowed to use this script for Commercial games.
  66. # 5. ENJOY!
  67. #
  68. # "FINE PRINT"
  69. # By using this script you hereby agree to the above terms and conditions,
  70. #  if any violation of the above terms occurs "legal action" may be taken.
  71. # Not understanding the above terms and conditions does NOT mean that
  72. #  they do not apply to you.
  73. # If you wish to discuss the terms and conditions in further detail you can
  74. # contact me at http://dekitarpg.wordpress.com/ or [email protected]
  75. #
  76. #===============================================================================
  77. # ☆ Instructions
  78. #-------------------------------------------------------------------------------
  79. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  80. # Place Above ALL Other $D13x Scripts.
  81. #
  82. #===============================================================================
  83. # ☆ Notetags
  84. # For use with Weapons / Armors
  85. #-------------------------------------------------------------------------------
  86. # <tcol: red, grn, blu>
  87. # use this notetag to change the color of the items text shown in some of my
  88. # scenes.
  89. #
  90. #===============================================================================
  91. # ☆ HELP
  92. #-------------------------------------------------------------------------------
  93. # Heres a list of :key_symbols ( for use in scripts that require this one )
  94. # F KEYS
  95. # :F1, :F2, :F3, :F4, :F5, :F6, :F7, :F8, :F9, :F10, :F11, :F12
  96. # NUMBER KEYS
  97. # :_1, :_2, :_3, :_4, :_5, :_6, :_7, :_8, :_9, :_0
  98. # LETTERS
  99. # :A, :B, :C, :D, :E, :F, :G, :H, :I, :J, :K, :L, :M, :N,
  100. # :O, :P, :Q, :R, :S, :T, :U, :V, :W, :X, :Y, :Z
  101. # NUM PAD
  102. # :N_0, :N_1, :N_2, :N_3, :N_4, :N_5, :N_6, :N_7, :N_8, :N_9,
  103. # :ADD, :MUL, :SUB, :DIV, :DECI
  104. # ARROWS
  105. # :LEFT, :RIGHT, :UP, :DOWN
  106. # OTHER
  107. # :SHIFT, :LSHIFT, :RSHIFT, :TAB,   :PAUSE, :CTRL, :L_CTRL, :R_CTRL,
  108. # :BACK,  :ENTER,  :CAPS,   :SPACE, :ESC,   :ALT
  109. # :S_Colon, :Equal, :Comma, :Minus, :Period, :F_Slash, :HASH, :L_Sqr_Brack
  110. # :B_Slash, :R_Sqr_Brack, :S_Quote,
  111. #
  112. # To Disable A Key, Make Symbol = :NONE,
  113. #
  114. #===============================================================================
  115. # ☆ For Scripters
  116. #-------------------------------------------------------------------------------
  117. # You can use any of the keys above in your own scripts, simply change the
  118. # default Input.press? / Input.trigger? / Input.repeat? methods with the
  119. # equivalent new method :
  120. # Keys.press?(KEY)
  121. # Keys.repeat?(KEY)
  122. # Keys.trigger?(KEY)
  123. # Keys.release?(KEY)
  124. # KEY should be either the keys 'virtual key code' or you can reference
  125. # the Keys module like so...
  126. # Keys.press?( Keys::Key[:SYMBOL] )
  127. # Keys.repeat?( Keys::Key[:SYMBOL] )
  128. # Keys.trigger?( Keys::Key[:SYMBOL] )
  129. # Keys.release?( Keys::Key[:SYMBOL] )
  130. #
  131. # Keys.press?
  132. # ^- will be triggered if the key is being pressed down
  133. # Keys.repeat?
  134. # ^- will be triggered if the key is in the "on" state (caps lock ect)
  135. # Keys.trigger?
  136. # ^- will be triggered when they key is first pressed
  137. # Keys.release?(KEY)
  138. # ^- will be triggered when they key is de-pressed (let go)
  139. #
  140. #===============================================================================
  141. module Text_Color
  142. #===============================================================================
  143.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  144.   # ☆ Color Settings
  145.   #-----------------------------------------------------------------------------
  146.   # You can use these colors in any of my scripts that offer color customisation.
  147.   # simply put Text_Color::THE_COLOR_YOU_WANT as the setting.
  148.   # eg.
  149.   # Text_Color::Pure_White
  150.   #-----------------------------------------------------------------------------
  151.   # White's
  152.   Pure_White  = Color.new(255,255,255)
  153.   White       = Color.new(222,222,222)
  154.   Grey        = Color.new(111,111,111)
  155.   Black       = Color.new(0  ,0  ,0  )
  156.   #-----------------------------------------------------------------------------
  157.   # Yellow's
  158.   Yellow      = Color.new(255,255,0)
  159.   Gold        = Color.new(212,212,64)
  160.   Orange      = Color.new(255,182,0)
  161.   Deep_Orange = Color.new(212,64,0)
  162.   Dirt_Orange = Color.new(182,64,0)
  163.   Brown       = Color.new(128,32,0)
  164.   #-----------------------------------------------------------------------------
  165.   # Red's
  166.   Red         = Color.new(251,111,111)
  167.   Deep_Red    = Color.new(222,60,60)
  168.   Pure_Red    = Color.new(255,0,0)
  169.   Pink        = Color.new(255,0,255)
  170.   Dark_Pink   = Color.new(182,0,156)
  171.   #-----------------------------------------------------------------------------
  172.   # Blue's
  173.   Sky_Blue    = Color.new(0,182,255)
  174.   Light_Blue  = Color.new(64,128,255)
  175.   Dark_Blue   = Color.new(32,64,255)
  176.   Purple      = Color.new(182,64,255)
  177.   Magenta     = Color.new(156,156,255)
  178.   #-----------------------------------------------------------------------------
  179.   # Green's
  180.   Green       = Color.new(111,251,111)
  181.   Candy_Green = Color.new(0,255,0)
  182.   Dirty_Green = Color.new(128,182,0)
  183.   Khaki_Green = Color.new(111,156,64)
  184.   Turquoise   = Color.new(0,255,182)
  185.   #-----------------------------------------------------------------------------
  186.   # Sets the default equipment text color
  187.   Default_Equip_Color = Black
  188.  
  189. end #===========================================================================
  190. module General
  191. #===============================================================================
  192.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  193.   # ☆ General Settings
  194.   #-----------------------------------------------------------------------------
  195.   # these settings are usined for visual scripts of mine, such as status screen.
  196.   Fonts     = YEA::CORE::FONT_NAME
  197.   Font_Size = YEA::CORE::FONT_SIZE
  198.   Font_Bold = YEA::CORE::FONT_BOLD
  199.   #-----------------------------------------------------------------------------
  200.   # Gauges  = [ Color 1                 , Color 2               ]
  201.   Hp_Colors = [ Text_Color::Dirt_Orange , Text_Color::Gold      ]
  202.   Mp_Colors = [ Text_Color::Dark_Blue   , Text_Color::Sky_Blue  ]
  203.   Tp_Colors = [ Text_Color::Grey        , Text_Color::Pure_Red  ]
  204.   Exp_Color = [ Text_Color::Deep_Red    , Text_Color::Dark_Pink ]
  205.   #-----------------------------------------------------------------------------
  206.   # Show TP as a percentage ?
  207.   # Only works in scripts i have written :p
  208.   Show_Tp_As_Perc = false
  209.  
  210. end #===========================================================================
  211. module Vocab
  212. #===============================================================================
  213.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  214.   # ☆ Vocabulary Settings
  215.   #-----------------------------------------------------------------------------
  216.   # This is where you would adjust the common vocab used in some of my scripts.
  217.   #-----------------------------------------------------------------------------
  218.   # Parameters
  219.   def self.param(param_id)
  220.     $data_system.terms.params[param_id]
  221.   end
  222.   #-----------------------------------------------------------------------------
  223.   # Tp vocab
  224.   Tp = "TP"
  225.   #-----------------------------------------------------------------------------
  226.   # X - Parameters
  227.   def self.x_param(x_param_id)
  228.     case x_param_id
  229.     when 0 then "Accuracy"
  230.     when 1 then "Evasion"
  231.     when 2 then "Critical"
  232.     when 3 then "Crit Eva"
  233.     when 4 then "Mag Eva"
  234.     when 5 then "Mag Ref"
  235.     when 6 then "Counter"
  236.     when 7 then "HP Regen"
  237.     when 8 then "MP Regen"
  238.     when 9 then "TP Regen"
  239.     end
  240.   end
  241.   #-----------------------------------------------------------------------------
  242.   # S - Parameters
  243.   def self.s_param(s_param_id)
  244.     case s_param_id
  245.     when 0 then "Aggro"
  246.     when 1 then "Guard"
  247.     when 2 then "Recovery"
  248.     when 3 then "Pharmacology"
  249.     when 4 then "MP Cost"
  250.     when 5 then "TP Charge"
  251.     when 6 then "P DMG Taken"
  252.     when 7 then "M DMG Taken"
  253.     when 8 then "Floor DMG"
  254.     when 9 then "Exp Rate"
  255.     end
  256.   end
  257.   #-----------------------------------------------------------------------------
  258.   # Specials
  259.   def self.specials(id)
  260.     case id
  261.     when 0 then "Auto-Fight"
  262.     when 1 then "Guard"
  263.     when 2 then "Substitue"
  264.     when 3 then "Preserve TP"
  265.     end
  266.   end
  267.   #-----------------------------------------------------------------------------
  268.   # Collapse Type
  269.   def self.collapse_type(id)
  270.     case id
  271.     when 0 then "Boss"
  272.     when 1 then "Instant"
  273.     when 2 then "No Vanish"
  274.     end
  275.   end
  276.   #-----------------------------------------------------------------------------
  277.   # Party Ability
  278.   def self.party_ability(id)
  279.     case id
  280.     when 0 then "Encounter ½"
  281.     when 1 then "Encounter NA"
  282.     when 2 then "No Surprise"
  283.     when 3 then "Pre-Emptive +"
  284.     when 4 then "Gold Double"
  285.     when 5 then "Double Drops"
  286.     end
  287.   end
  288.   #-----------------------------------------------------------------------------
  289.   # Various Statistics
  290.   Attack_Speed = "Atk Speed"
  291.   Attack_Times = "Atks Per Turn" # "APT"
  292.   Skill_Type   = "Skillset"
  293.   Skill        = "Skills"
  294.   Equip_Type   = "Equipable"
  295.   Action_Times = "Action Time"
  296.   Fixed        = "Fixed "
  297.   Sealed       = "Sealed "
  298.   Slot_Type    = "Slot Type"
  299.   Dual_Slot    = "Dual Wield"
  300.   One__Slot    = "Single"
  301.                             #####################
  302.                             # CUSTOMISATION END #
  303. end                         #####################
  304. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  305. #                                                                               #
  306. #                       http://dekitarpg.wordpress.com/                         #
  307. #                                                                               #
  308. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  309. # The following code is protected under the 2013 Dekita Data Protection Act.    #
  310. # Ie. The “Do Not Fucking Look” Law.                                            #
  311. # Breaking This One And Only Rule May Result In The Following Side Effects :    #
  312. # Eyes Bleeding, Nightmares, Severe Head Ache's AND A Scratch On Your Knee :p   #
  313. # That is all !                                                                 #
  314. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  315. class Object
  316. #===============================================================================
  317.   #-------------------------------------------------------------------------
  318.   # rand_between
  319.   #-------------------------------------------------------------------------
  320.   def rand_between(min, max)
  321.     min + rand(max - min + 1)
  322.   end
  323.  
  324. end
  325.  
  326. #===============================================================================
  327. class Numeric
  328. #===============================================================================
  329.   #---------------------------------------------------------------------------
  330.   # To Float (with limited digits after decimal point)
  331.   #---------------------------------------------------------------------------
  332.   def to_flim(limit = 5, saftey = "0")
  333.     str = self.to_f.to_s + saftey
  334.     new_str = ""
  335.     limit.times do |i|
  336.       break if new_str =~ /[0-9].[0-9][0-9]/
  337.       break if str[i] == nil
  338.       new_str += str[i]
  339.     end
  340.     return new_str
  341.   end
  342.   #---------------------------------------------------------------------------
  343.   # To A Percentage Of (num)
  344.   #---------------------------------------------------------------------------
  345.   def perc_of(num)
  346.     self.to_f / num.to_f * 100.0
  347.   end
  348.   #---------------------------------------------------------------------------
  349.   # Even ?
  350.   #---------------------------------------------------------------------------
  351.   def even?
  352.     e = self.to_s
  353.     e[e.size] == ("0"||"2"||"4"||"6"||"8")
  354.   end
  355.   #---------------------------------------------------------------------------
  356.   # 0dd?
  357.   #---------------------------------------------------------------------------
  358.   def odd?
  359.     o = self.to_s
  360.     o[o.size] == ("1"||"3"||"5"||"7"||"9")
  361.   end
  362.  
  363. end
  364.  
  365. #===============================================================================
  366. module Keys
  367. #===============================================================================
  368.   #---------------------------------------------------------------------------
  369.   # Win32API Information
  370.   #---------------------------------------------------------------------------
  371.   def self.w  ; Win32API           ;  end
  372.   def self.u  ; "user32"           ;  end
  373.   def self.i  ; "i"                ;  end
  374.   def self.gk ; "GetKeyState"      ;  end
  375.   def self.ga ; "GetAsyncKeyState" ;  end
  376.   #---------------------------------------------------------------------------
  377.   # Key Settings
  378.   #---------------------------------------------------------------------------
  379.   Key={
  380.   # Func's
  381.   :F1 => 0x70,:F2 => 0x71,:F3 => 0x72,:F4  => 0x73,:F5  => 0x74,:F6  => 0x75,
  382.   :F7 => 0x76,:F8 => 0x77,:F9 => 0x78,:F10 => 0x7a,:F11 => 0x7b,:F12 => 0x7c,
  383.   # Numbers
  384.   :_0 => 0x30,:_1 => 0x31,:_2 => 0x32,:_3 => 0x33,:_4 => 0x34,
  385.   :_5 => 0x35,:_6 => 0x36,:_7 => 0x37,:_8 => 0x38,:_9 => 0x39,
  386.   # Letters
  387.   :A => 0x41,:B => 0x42,:C => 0x43,:D => 0x44,:E => 0x45,:F => 0x46,:G => 0x47,
  388.   :H => 0x48,:I => 0x49,:J => 0x4A,:K => 0x4B,:L => 0x4C,:M => 0x4D,:N => 0x4E,
  389.   :O => 0x4F,:P => 0x50,:Q => 0x51,:R => 0x52,:S => 0x53,:T => 0x54,:U => 0x55,
  390.   :V => 0x56,:W => 0x57,:X => 0x58,:Y => 0x59,:Z => 0x5A,
  391.   # NumPad
  392.   :N_0   => 0x60, :N_1  => 0x61, :N_2  => 0x62, :N_3  => 0x63, :N_4  => 0x64,
  393.   :N_5   => 0x65, :N_6  => 0x66, :N_7  => 0x67, :N_8  => 0x68, :N_9  => 0x69,
  394.   :ADD   => 0x6b, :MUL  => 0x6a, :SUB  => 0x6d, :DIV  => 0x6f, :DECI => 0x6e,
  395.   # Arrows
  396.   :LEFT => 0x25, :RIGHT => 0x27, :UP => 0x26, :DOWN => 0x28,
  397.   # Symbols
  398.   :S_Colon => 0xBA, :Equal       => 0xBB, :Comma   => 0xBC, :Minus       => 0xBD,
  399.   :Period  => 0xBE, :F_Slash     => 0xBF, :HASH    => 0xDE, :L_Sqr_Brack => 0xDB,
  400.   :B_Slash => 0xDC, :R_Sqr_Brack => 0xDD, :S_Quote => 0xC0,
  401.   # Other
  402.   :SHIFT => 0x10, :LSHIFT   => 0xa0, :RSHIFT   => 0xa1, :TAB    => 0x09,
  403.   :PAUSE => 0x13, :L_CTRL   => 0xa2, :R_CTRL   => 0xa3, :CTRL   => 0x11,
  404.   :BACK  => 0x08, :ENTER    => 0x0D, :CAPS     => 0x14, :SPACE  => 0x20,
  405.   :ESC   => 0x1B, :ALT      => 0x12, :PrtSc    => 0x2c,
  406.   } # << End Key {}
  407.   #---------------------------------------------------------------------------
  408.   # Constants
  409.   #---------------------------------------------------------------------------
  410.   KS = w.new(u,gk,[i],i)
  411.   AK = w.new(u,ga,[i],i)
  412.   #---------------------------------------------------------------------------
  413.   # Variables
  414.   #---------------------------------------------------------------------------
  415.   @trigger  = Array.new(256) { false }
  416.   @presses  = Array.new(256) { false }
  417.   @release  = Array.new(256) { false }
  418.   @repeats  = Array.new(256) { false }
  419.   #---------------------------------------------------------------------------
  420.   # Update All Key's State's
  421.   #---------------------------------------------------------------------------
  422.   def self.update
  423.     @trigger = Array.new(256) { false }
  424.     @release = Array.new(256) { false }
  425.     Key.each do |key|
  426.       akey = AK.call(key[1])
  427.       ktri = KS.call(key[1])
  428.       @trigger[ key[1] ] = true if ((!@presses[key[1]]) && (akey != 0))
  429.       @release[ key[1] ] = true if (( @presses[key[1]]) && (akey == 0))
  430.       @presses[ key[1] ] = (akey != 0) ? true : false
  431.       @repeats[ key[1] ] = (ktri == 1) ? true : false
  432.     end
  433.   end
  434.   #---------------------------------------------------------------------------
  435.   # Key Got Triggered? [ inital key press ]
  436.   #---------------------------------------------------------------------------
  437.   def self.trigger?(key)
  438.     return if key.nil?
  439.     return @trigger[key]
  440.   end
  441.   #---------------------------------------------------------------------------
  442.   # Key Got Released? [ inital key depress ]
  443.   #---------------------------------------------------------------------------
  444.   def self.release?(key)
  445.     return if key.nil?
  446.     return @release[key]
  447.   end
  448.   #---------------------------------------------------------------------------
  449.   # Key Being Pressed Currently ?
  450.   #---------------------------------------------------------------------------
  451.   def self.press?(key)
  452.     return if key.nil?
  453.     return @presses[key]
  454.   end
  455.   #---------------------------------------------------------------------------
  456.   # Key Turned On? [Caps Lock, Num Lock, ect..]
  457.   #---------------------------------------------------------------------------
  458.   def self.repeat?(key)
  459.     return if key.nil?
  460.     return @repeats[key]
  461.   end
  462.  
  463. end
  464.  
  465. #===============================================================================
  466. module Input
  467. #===============================================================================
  468.   #---------------------------------------------------------------------------
  469.   # Alias List
  470.   #---------------------------------------------------------------------------
  471.   class << self
  472.     alias :update_sD13x_Keys :update
  473.   end
  474.   #---------------------------------------------------------------------------
  475.   # Update $D13x Keys
  476.   #---------------------------------------------------------------------------
  477.   def self.update(*args)
  478.     update_sD13x_Keys(*args)
  479.     Keys.update
  480.   end
  481.  
  482. end
  483.  
  484. #===============================================================================
  485. module Cache
  486. #===============================================================================
  487.   #--------------------------------------------------------------------------
  488.   # * Get System Graphic
  489.   #--------------------------------------------------------------------------
  490.   def self.icon(filename = "IconSet", hue = 0)
  491.     load_bitmap("Graphics/System/", filename, hue)
  492.   end
  493.  
  494. end
  495.  
  496. #===============================================================================
  497. module DataManager
  498. #===============================================================================
  499.   #---------------------------------------------------------------------------
  500.   # Alias List
  501.   #---------------------------------------------------------------------------
  502.   class << self
  503.     alias :lbd_unique_shits :load_database
  504.   end
  505.   #---------------------------------------------------------------------------
  506.   # Load Database (alias)
  507.   #---------------------------------------------------------------------------
  508.   def self.load_database
  509.     lbd_unique_shits
  510.     loa_unique_shits
  511.   end
  512.   #---------------------------------------------------------------------------
  513.   # Load Unique Shit
  514.   #---------------------------------------------------------------------------
  515.   def self.loa_unique_shits
  516.     classes = [$data_weapons, $data_armors , $data_items  , $data_skills ,
  517.                $data_actors , $data_classes, $data_enemies, $data_states ]
  518.     for g in classes
  519.       for o in g
  520.         next if o == nil
  521.         o.load_unique_shit
  522.       end
  523.     end
  524.   end
  525.  
  526. end # << DataManager
  527.  
  528. #===============================================================================
  529. class RPG::BaseItem
  530. #===============================================================================
  531.   #--------------------------------------------------------------------------
  532.   # Pi Variables
  533.   #--------------------------------------------------------------------------
  534.   attr_accessor :item_disp_color
  535.   attr_accessor :database_id
  536.   #--------------------------------------------------------------------------
  537.   # Loads Unique Shit
  538.   #--------------------------------------------------------------------------
  539.   def load_unique_shit
  540.     @database_id = @id
  541.     load_item_color
  542.     # << For use in Child Classes
  543.   end  
  544.   #---------------------------------------------------------------------------
  545.   # Load Item Text Color
  546.   #---------------------------------------------------------------------------
  547.   def load_item_color
  548.     @item_disp_color = Text_Color::Default_Equip_Color
  549.     if self.note.match(/<tcol:(.*),(.*),(.*)>/i)
  550.       @item_disp_color = Color.new($1.to_i,$2.to_i,$3.to_i)
  551.     end
  552.   end  
  553.   #--------------------------------------------------------------------------
  554.   # Returns features for item filtered by code (credits Tsukihime)
  555.   #--------------------------------------------------------------------------
  556.   def feature_val(code)
  557.     self.features.select {|ft| ft.code == code}
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # Returns features for item filtered by code and data ID (credits Tsukihime)
  561.   #--------------------------------------------------------------------------
  562.   def feature_val_with_id(code, data_id)
  563.     self.features.select {|ft| ft.code == code && ft.data_id == data_id}
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # Returns sum of all features for item, by code and data ID (credits Tsukihime)
  567.   #--------------------------------------------------------------------------
  568.   def features_sum(code, data_id)
  569.     feature_val_with_id(code, data_id).inject(0.0) {|r, ft| r += ft.value }    
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # Returns features pi
  573.   #--------------------------------------------------------------------------
  574.   def features_pi(code, data_id)
  575.     feature_val_with_id(code, data_id).inject(1.0) {|r, ft| r *= ft.value }    
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # Calculate Set Sum of Features
  579.   #--------------------------------------------------------------------------
  580.   def features_set(code)
  581.     feature_val(code).inject([]) {|r, ft| r |= [ft.data_id] }
  582.   end
  583.  
  584. end
  585.  
  586. #==============================================================================
  587. class Game_Party < Game_Unit
  588. #==============================================================================
  589.   #-----------------------------------------------------------------------------
  590.   # Get Battle Members
  591.   #-----------------------------------------------------------------------------
  592.   def alive_battle_members
  593.     all_members[0, max_battle_members].select {|a| a.exist? && a.hp > 0 }
  594.   end
  595.  
  596. end
  597.  
  598. #==============================================================================
  599. class Window_Base < Window
  600. #==============================================================================
  601.   #--------------------------------------------------------------------------
  602.   # Draw Gauge (w/height)
  603.   #--------------------------------------------------------------------------
  604.   def draw_deki_gauge(gx, gy, gw, gh, rate, color1, color2)
  605.     empty_gauge_color = Color.new(0,0,0,128)
  606.     fill_w = [(gw * rate).to_i, gw].min
  607.     gauge_h = gh
  608.     gauge_y = gy + line_height - 2 - gauge_h
  609.     contents.fill_rect(gx, gauge_y, gw, gauge_h, empty_gauge_color)
  610.     contents.gradient_fill_rect(gx, gauge_y, fill_w, gauge_h, color1, color2)
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # Draw Hp
  614.   #--------------------------------------------------------------------------
  615.   def draw_de_hp(x, y, wid = nil)
  616.     wid = self.width/2 - (standard_padding*2) if wid == nil
  617.     rate = @actor.hp_rate
  618.     color1 = General::Hp_Colors[0]
  619.     color2 = General::Hp_Colors[1]
  620.     draw_deki_gauge(x, y, wid-x-2, 2, rate, color1, color2)
  621.     draw_text(x+4, y, wid, line_height, Vocab::param(0))
  622.     draw_text(x, y, wid-x-6, line_height, "#{@actor.hp}/#{@actor.mhp}",2)
  623.   end
  624.   #--------------------------------------------------------------------------
  625.   # Draw Mp
  626.   #--------------------------------------------------------------------------
  627.     def draw_de_mp(x, y, wid = nil)
  628.     wid = self.width/2 - (standard_padding*2) if wid == nil
  629.     rate = @actor.mp_rate
  630.     color1 = General::Mp_Colors[0]
  631.     color2 = General::Mp_Colors[1]
  632.     draw_deki_gauge(x, y, wid-x-2, 2, rate, color1, color2)
  633.     draw_text(x+4, y, wid, line_height, Vocab::param(1))
  634.     draw_text(x, y, wid-x-6, line_height, "#{@actor.mp}/#{@actor.mmp}",2)
  635.   end
  636.   #--------------------------------------------------------------------------
  637.   # Draw Tp
  638.   #--------------------------------------------------------------------------
  639.     def draw_de_tp(x, y, wid = nil)
  640.     wid = self.width/2 - (standard_padding*2) if wid == nil
  641.     rate = @actor.tp.to_i.to_f / @actor.max_tp.to_i
  642.     color1 = General::Tp_Colors[0]
  643.     color2 = General::Tp_Colors[1]
  644.     draw_deki_gauge(x, y, wid-x-2, 2, rate, color1, color2)
  645.     draw_text(x+4, y, wid, line_height, Vocab::Tp)
  646.     text = "#{(@actor.tp).to_i}/#{@actor.max_tp.to_i}"
  647.     text = "#{(@actor.tp.perc_of(@actor.max_tp)).to_flim}%" if General::Show_Tp_As_Perc
  648.     draw_text(x, y, wid-x-6, line_height, text,2)
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # Draw Exp (w/gauge)
  652.   #--------------------------------------------------------------------------
  653.   def draw_de_xp(x, y, gauge = true)
  654.     s1 = @actor.current_level_exp
  655.     s2 = @actor.next_level_exp
  656.     s1_g = @actor.exp - @actor.current_level_exp
  657.     s2_g = @actor.next_level_exp - @actor.current_level_exp
  658.     wid = self.width/2 - (standard_padding*2)
  659.     wid_b = self.width/2 - (standard_padding)
  660.     rate = (s1_g).to_f / (s2_g)
  661.     color1 = General::Exp_Color[0]
  662.     color2 = General::Exp_Color[1]
  663.     draw_deki_gauge(wid_b, y, wid-x-2, 2, rate, color1, color2) if gauge
  664.     draw_text(wid_b+4, y, wid, line_height, "Exp:")
  665.     draw_text(wid_b, y, wid-x-2, line_height, "#{s1}/#{s2}",2)
  666.   end
  667.   #--------------------------------------------------------------------------
  668.   # Draw Icon (w/Hue)
  669.   #--------------------------------------------------------------------------
  670.   def draw_de_icon(icon_index, x, y, hue = 0, enabled = true)
  671.     bitmap = Cache.icon("IconSet",hue)
  672.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  673.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  674.   end
  675.  
  676. end
  677.  
  678. #==============================================================================
  679. class Deki_Help < Window_Base
  680. #==============================================================================
  681.   #--------------------------------------------------------------------------
  682.   # Object Initialization
  683.   #--------------------------------------------------------------------------
  684.   def initialize(line_number = 2)
  685.     super(0, 0, Graphics.width/4*3, fitting_height(line_number))
  686.     @item = nil
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # Set Text
  690.   #--------------------------------------------------------------------------
  691.   def set_text(text)
  692.     if text != @text
  693.       @text = text
  694.       refresh
  695.     end
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # Clear
  699.   #--------------------------------------------------------------------------
  700.   def clear
  701.     set_text("")
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # Set Item  , item : Skills and items etc.
  705.   #--------------------------------------------------------------------------
  706.   def set_item(item)
  707.     return if @item == item
  708.     @item = item
  709.     refresh
  710.     set_text(item ? item.description : "")
  711.   end
  712.   #--------------------------------------------------------------------------
  713.   # Refresh
  714.   #--------------------------------------------------------------------------
  715.   def refresh
  716.     contents.clear
  717.     draw_text_ex(4, 0, @text)
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # Reset Font Settings
  721.   #--------------------------------------------------------------------------
  722.   def reset_font_settings
  723.     change_color(normal_color)
  724.     self.contents.font.name = General::Fonts
  725.     self.contents.font.size = General::Font_Size
  726.     self.contents.font.bold = General::Font_Bold
  727.   end
  728.  
  729. end
  730.  
  731. #==============================================================================#
  732. #                      http://dekitarpg.wordpress.com/                         #
  733. #==============================================================================#
  734. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment