Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

KLUD Bonus Points

KLUD Bonus Points
(Kyonides's Level Up / Down Bonus Points)
Version: 0.1.0
By Kyonides-Arkanthos


Introduction

This script allows your heroes to earn stats bonus points after leveling up (or lose them if leveling down).

Features

* Semi Plug & Play (You still need to define what kind of stats bonus points each selected hero class will get if any. The rest will be executed automatically.)
* Your heroes may get stats bonus points (if that's what you want).
* They can get their hp and sp points replenished (if allowed).
* It works both ways, it doesn't matter if your hero is leveling up and down. (You can disable the latter if deemed necessary.)

Screenshots

Since it works only with your hero's stats, there's no such a thing as a screenshot to show the changes, just check your stats before and after you level up or down in the menu window.

Demo

<NONE is required anyway.>

Script

[rgss]#  KLUD Bonus Points - KLUD BP - XP
#    from : Kyonides's Level Up or Down Bonus Points for XP
#  version 0.1.0 - 08.02.2010
 
# Usage:
 
# Hero's Class ID => HP, SP, STR, DEX, AGI, INT, Replenish HP & SP?
 
# You can leave a 0 (number zero) in any of those slots
#   if you don't want them to earn that kind of stats bonus points
 
# Delete or Comment Out (Put a # before the code line) a Class ID
#   if you don't want that hero class to earn any bonus points at all
 
# Keep in mind that this script adds and substracts the bonus points
#   if you level up or down.
 
# If you don't want to ever lose them, delete or comment out this line:
#   lose_extra_stats_points
module Stats
  CLASS_BONUS_POINTS = {
  # Hero's Class ID => HP, SP, STR, DEX, AGI, INT, Replenish HP & SP?
    1 => [12, 7, 10, 0, 0, 0, true],
    2 => [0, 0, 0, 0, 0, 0, false],
    3 => [0, 0, 0, 0, 0, 0, true],
    4 => [0, 0, 0, 0, 0, 0, true],
    5 => [0, 0, 0, 0, 0, 0, false],
    6 => [0, 0, 0, 0, 0, 0, true],
    7 => [0, 0, 0, 0, 0, 0, true],
    8 => [0, 0, 0, 0, 0, 0, false],
  }
end
 
class Game_Actor
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      get_extra_stats_points
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
      lose_extra_stats_points
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
    # If Replenishing Actor's HP & SP is allowed
    if Stats::CLASS_BONUS_POINTS[@class_id][6]
      @hp, @sp = self.maxhp, self.maxsp
    end
  end
 
  def get_extra_stats_points(plus=true)
    return if !Stats::CLASS_BONUS_POINTS.keys.include? @class_id
    sign = plus ? 1 : -1
    @maxhp_plus += sign * Stats::CLASS_BONUS_POINTS[@class_id][0]
    @maxsp_plus += sign * Stats::CLASS_BONUS_POINTS[@class_id][1]
    @str_plus   += sign * Stats::CLASS_BONUS_POINTS[@class_id][2]
    @dex_plus   += sign * Stats::CLASS_BONUS_POINTS[@class_id][3]
    @agi_plus   += sign * Stats::CLASS_BONUS_POINTS[@class_id][4]
    @int_plus   += sign * Stats::CLASS_BONUS_POINTS[@class_id][5]
  end
 
  def lose_extra_stats_points
    get_extra_stats_points(false)
  end
end
[/rgss]

Instructions

Read the comments included in my script.

FAQ

None yet.

Compatibility

For XP only.

Terms and Conditions

Not intended for Commercial Use and you should always include my name and/or url.
 
Ok you made it and its good and let me give you a bit of advice...

Just because your using an Array/Hash (yes they are different in definition but in concept, they are the same) doesn't mean it will use less memory than a normal variable. In fact its same if you do:

@variable1 = 2
@variable2 = 6
@variable3 = 9

It takes same amount of memory (and more because array is treated as an object in Ruby) if you do it with an array.

@variable_array = [2, 6, 9]

or a hash of yours

@variable_hash = {0=>2, 1=>6, 2=>9}

They are taking same amount of memory the only difference is how they are actually stored in memory.

So you should consider this when using arrays and/or hashes. In other words my point is that you could remake a script to only increase SOME of the status IF not all of them are needed. That way you can save memory. Sure now it takes a silly amount but image if a person has a class custom title kind of rpg where he has 50 or more classes and like only 10 of them get all bonuses.

Your script is ok and all, I'm just giving you a hint to know something. ;)
 
Do you think I care about that Drago? Really, I don't see why you had to comment anything about it but I still remember anyone is free to do so. I just posted my script because I think it's better for common people to read my code even if I may be wrong. And I'm not planning to change it unless I were planning to include new features.
 
Dude, neither I care will you change it or not. I'm simply giving you some free advice on what's smart to do in this or next of your scripts.

If you don't want to be better then sorry for posting anything. Just to tell you, when you post a script here, your automatically giving support for it. So well, if I don't tell you, somebody might, your going to say that you don't care to them?

Well, I'll stop going off topic here.

As for improvements. Here's a feature which might come in handy.
How about making special bonuses feature as an option so that they will give bonuses to some spells/skills? Or maybe that a character class will get a bonus to a weapon and/or armor it is wielding? :smile:
 
Please keep your advice for yourself. I better think on what's easier for a forumer than on just trying to make script "run faster" (if really possible). Thanks anyway for the last suggestions for new features.
 
Now I don't know who of you shot the other's girlfriend or whatever, but I think you, kyo, are a little overreacting here, as it seems quite aggressively unfriendly. As for the discussed topic, I think the arrays are justified in the sense that everything else would be a mess of a bazillion variables, or at least that's my opinion (especially as a thousand unique variables don't necessarily save the processing power you need for an array or hash... which are a bit different in concept really ;) ). Still, efficiency is something most people in here like advice on, so yeah...

Either way, please try to keep this on a somewhat non-angry level. Thanks, back to topic.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top