A sorta Final Fantasy 2/SaGa stat leveling system.
Here is a little script I was working on for my test game made to count tallies when each stat is used and randomly raise them after battle. It's kinda like the stat leveling system in Final Fantasy 2(j) and the SaGa series, but it works a bit differently.
Mostly it is different in that experience levels still exist and are used both to determine your max over all stat level, and whenever you gain a level you get a big random boost to your stat tallies. The actor class's stat growth curves also determines how much each stat level is worth.
Anyway the basic idea for how it works is stat tallies are used as percent chance that that stat will level up after battle, so if a stat is tallied 100 times it will always level up, but if it is tallied only 10 times you have a 10% chance. Tallies are remembered across battles but the level up chance only happens at a battle's conclusion. If a stat is leveled up a flat 100 is subtracted from the tally, and it can go into the negative. This practically means stat increases are random but predictable over a large period of time, and since your level acts as a cap for how many stat increases you can have and your class acts to show how many each are worth, the fact that the stats always grow at the same rate is not as important.
It's probably not going to be useful for most people's needs since it doesn't try to exactly match the system used in the old games, and is mostly me just experimenting with the mechanics. It might be useful as a base if anyone wants to do something similar though!
Here is the script:
module BattleManager #-------------------------------------------------------------------------- # * EXP Acquisition and Level Up Display #-------------------------------------------------------------------------- def self.gain_exp $game_party.all_members.each do |actor| actor.gain_exp($game_troop.exp_total) actor.param_level_up wait_for_message end end end class Game_Battler < Game_BattlerBase alias_method :use_item_tally_base, :use_item def use_item(item) self.pre_tally use_item_tally_base(item) self.post_tally end alias_method :item_apply_tally_base, :item_apply def item_apply(user, item) self.pre_tally user.pre_tally item_apply_tally_base(user, item) self.post_tally user.post_tally end def pre_tally return end def post_tally return end end class Game_Actor attr_reader :total_tally alias :th_param_level_setup_actor :setup def setup(actor_id) th_param_level_setup_actor(actor_id) @param_growths = [0] * 8 @param_levels = [@level] * 8 end def pre_tally @old_hp = @hp @old_mp = @mp @total_tally = 0 @param_tally = true end def average_param_level @param_levels.inject(0) { |sum, el| sum + el } / 8.0 end def grow_param(param_id, amount) x = amount * (@level / @param_levels[param_id].to_f) if @param_growths[param_id] < 0 || average_param_level <= @level puts(self.name + ":" + Vocab::param(param_id) + ":" + x.to_s) if $TEST @param_growths[param_id] += x end @total_tally += x end def post_tally x = ([(@old_hp - @hp) / self.mhp.to_f, 0].max * 5).ceil grow_param(0, x) x = ([(@old_mp - @mp) / self.mmp.to_f, 0].max * 5).ceil grow_param(1, x) @param_tally = false end def param_base(param_id) self.class.params[param_id, @param_levels ? @param_levels[param_id] : @level] end alias_method :param_tally_base, :param def param(param_id) if @param_tally && param_id > 1 grow_param(param_id, 1) end return param_tally_base(param_id) end alias :th_param_level_level_up_actor :level_up def level_up th_param_level_level_up_actor 8.times do |i| @param_growths[i] += rand(100) end end Param_Message = "%s's %s has increased by %s points!" def param_level_up puts self.name + " growth:" if $TEST avr = average_param_level puts "level: " + @level.to_s if $TEST puts "average param level: " + avr.to_s if $TEST return unless avr <= @level 8.times do |i| #next unless @param_levels[i] <= @level if @param_growths[i] > 0 && (rand(100) - @param_growths[i]) <= 0 @param_levels[i] += 1 @param_growths[i] -= 100 difference = self.class.params[i, @param_levels[i]] - self.class.params[i, @param_levels[i]-1] $game_message.add(sprintf(Param_Message, self.name, Vocab::param(i), difference)) end puts(Vocab::param(i) + " Level:" + @param_levels[i].to_s + " Growth:" + @param_growths[i].to_s) if $TEST end end end
-
4



27 Comments
Recommended Comments