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.

[Resolved] Weapons increasing stats by percentages

Status
Not open for further replies.
I not going to be including a whole lot of weapons in the game I am working on, (you don't buy a new set of weapons/armor in every new town) so I want you to be able to choose a weapon based on your fighting style. For example, if you are a heavy fighter, you may buy a great sword, that will double your attack, but half your agility.

So that is basically what I want to do, I want the increases of your weapons to be percentage based as opposed to integers.
 
http://www.rmxpu.net/staff/sephirothspawn/Script Files/Actor Stat Bonuses.txt

My Actor Stat Bonuses Script does this. It's failr simple, yet extremely complex.

It starts off getting each stats original value, then sending it to specialized method in a module of constants.

From there it checks the actors class, equipment, skills etc. and modifies the stat value. Then it sends the bonus gained back to the method.

Your focus needs to be here:
Code:
  #--------------------------------------------------------------------------
  # * Weapon Bonuses
  #
  #  ~ weapon_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  WeaponBonuses_Direct = {
  }
  WeaponBonuses_Percent = {
  }
  #--------------------------------------------------------------------------
  # * Armor Bonuses
  #
  #  ~ armor_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  ArmorBonuses_Direct = {
  }
  ArmorBonuses_Percent = {
  }
 
Alright, I did this:
Code:
   #--------------------------------------------------------------------------
  # * Weapon Bonuses
  #
  #  ~ weapon_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  WeaponBonuses_Direct = {
  }
  WeaponBonuses_Percent = {
  001 => {'str' => 50}
  }
And it work perfectly. Thank you very much. However, afterwards, I added:
Code:
  #--------------------------------------------------------------------------
  # * Weapon Bonuses
  #
  #  ~ weapon_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  WeaponBonuses_Direct = {
  }
  WeaponBonuses_Percent = {
  001 => {'str' => 50, 'agi' => -50}
  }
The nurf to agility, and I recieved and error message. Does the script support negitives?

EDIT: Alas, how silly of me. Forgot the comma. It is working, thanks for your help.
 
Prexus, you missed the 001. 001 converts the number to a different base (octal?).

You need only to have one key for each weapon id.

Code:
  WeaponBonuses_Percent = {
  1 => {'str' => 50, 'agi' => -50}
  }

That should be it.
 
Status
Not open for further replies.

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