Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- HBK Basic v0.60
- created 2013.01.31
- class Integer
- <Integer>.factorial
- Will return the factorial value of self.
- Example:
- 5.factorial
- will return 5 * 4 * 3 * 2 * 1 #=> 120
- <Integer>.sum_to(target)
- Will return the sum value of self increased or decreased by 1 until self
- reach target.
- Example:
- 3.sum_to(5)
- will return 3 + 4 + 5 #=> 12
- <Integer>.sum_down
- Will return the sum value of self increased or decreased by 1 until self
- reach 0.
- Example:
- -3.sumdown
- will return (-3) + (-2) + (-1) + 0 #=> - 6
- class Array
- <Array>.random
- <Array>.random!
- Will result on random member. random! will remove the returned value from
- Array.
- <Array>.sum
- Returns the sum of all numeric values.
- <Array>.average(float = false)
- float : float flag
- Returns the average of all numeric values, if float is true, the value
- returned is a float, otherwise it's a integer.
- class Game_Unit
- New method: lowest(method_name)
- New method: highest(method_name)
- Will return the member with lowest/highest value of (method_name)
- Method name could be on symbol or string. For example :hp or "hp" will be
- considered as valid argument.
- Example:
- $game_troop.lowest(:hp)
- will return alive member with lowest HP
- New method: lowest_by_index(method_name)
- New method: highest_by_index(method_name)
- Will return the index of member which has lowest/highest attribute declared
- on method name.
- Method name could be on symbol or string. For example :hp or "hp" will be
- considered as valid argument.
- class Game_Battler
- New method: lowest?(method_name)
- Method name could be on symbol or string. For example :hp or "hp" will be
- considered as valid argument.
- Example:
- $game_actors[1].lowest?(:hp)
- will return true if he/she is alive & has lowest HP on party.
- *Credits (from me)
- - Victor Sant
- - Tsukihime
- *Note:
- I found that some of the method here were already written on Victor's Basic
- Module. But since it just modify the basic objects like Array and Integer,
- I think it's okay to copy it on my basic module. Please give credit to him
- if you feel like to.
- =end
- #===============================================================================
- # ■ Skip Title
- #==============================================================================
- module SkipTitle
- Skip = true # <= Set to false if you don't want to skip intro
- Width = 544
- Height = 416
- Framerate = 60
- end
- #===============================================================================
- # ■ Array
- #===============================================================================
- class Array
- def sum
- return self.inject(0) {|r, n| r += (n.is_a?(Numeric) ? n : 0)}
- end
- def random
- return self[rand(size)]
- end
- def random!
- return self.delete_at(rand(size))
- end
- def average(float = false)
- return self.sum / [(float ? size.to_f : size.to_i), 1].max
- end
- end
- #===============================================================================
- # ■ Integer
- #===============================================================================
- class Integer
- #--------------------------------------------------------------------------
- # * New method: factorial
- #--------------------------------------------------------------------------
- def factorial
- return if self <= 0
- return (1..self).inject(1) {|r,n| r *= n}
- end
- #--------------------------------------------------------------------------
- # * New method: sum_to
- #--------------------------------------------------------------------------
- def sum_to(v)
- if v > self
- (self..v).inject(0) {|r,n| r += n}
- elsif v < self
- (v..self).inject(0) {|r,n| r += n}
- else
- self
- end
- end
- #--------------------------------------------------------------------------
- # * New method: sum_down
- #--------------------------------------------------------------------------
- def sum_down
- sum_to(0)
- end
- end
- #===============================================================================
- # ■ SceneManager
- #==============================================================================
- module SceneManager
- class << self
- alias skiptitle_run run
- end
- def self.run
- DataManager.init
- Graphics.frame_rate = SkipTitle::Framerate
- Graphics.resize_screen(SkipTitle::Width, SkipTitle::Height)
- Audio.setup_midi if use_midi?
- if SkipTitle::Skip
- if $BTEST
- SceneManager.goto(Scene_Battle)
- elsif not DataManager.save_file_exists?
- DataManager.setup_new_game
- $game_map.autoplay
- SceneManager.goto(Scene_Map)
- else
- @scene = first_scene_class.new
- end
- @scene.main while @scene
- else
- skiptitle_run
- end
- end
- end
- #==============================================================================
- # ■ Game_Unit
- #==============================================================================
- class Game_Unit
- # Just for compatibility reason for Game_Troop
- def battle_members
- return members
- end
- def lowest(name)
- m = alive_members.min_by{|member|
- member.send(name)
- }
- return m
- end
- def highest(name)
- m = alive_members.max_by{|member|
- member.send(name)
- }
- return m
- end
- def lowest_by_index(name)
- return members.index(lowest(name))
- end
- def highest_by_index(name)
- return members.index(highest(name))
- end
- end
- #==============================================================================
- # ■ Game_BattlerBase
- #==============================================================================
- class Game_BattlerBase
- # TP Rate fix, in case you modified max_tp
- def tp_rate
- @tp.to_f / max_tp
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- def lowest?(name)
- return self == friends_unit.lowest(name)
- return false
- end
- def highest?(name)
- return self == friends_unit.highest(name)
- return false
- end
- end
- $imported = {} if $imported.nil?
- $imported["HBK Basic"] = 0.60
Advertisement
Add Comment
Please, Sign In to add comment