Jump to content
A.

Battle Add On (Very basic)

Recommended Posts

Battle Add On (Very basic)

Version: 1.1

Author: Adrien. (A.)

Usagage: Plug and Play

Blog: http://labs.adambala...-add-on-simple/ (Url's are starting to make me mad....)

 

Descrip: Adds the ability to change the xp, gold and the stats of the enemies.

 

Note: very basic.

Comptaibility: No issue

FAQ: Seriously? If you have issues please ask, but instructions should be clear.

 

Version Notes:

 

Version 1.0 - init release

Version 1.1:

 

Allows you to use the new call methods $battle.mult_val(val) and $battle.div_val(val) to change how the xp is changed, set, given, earned. at the end of each battle the exp is set BACK to what you set in module for the initial xp gain.

 

 

 


#==============================================================================
# â–  Battle Extras
#
#
# Author: Adrien. (A.)
# Version: 1.1
# Comptaibility?: No issue?
#
# This script is used to change the out put of some things in battle its a plug
# and play script which is extremly basic and simply by nature. Read each of the
# module descriptions bellow to understand how to use.
#------------------------------------------------------------------------------
# Credit: Regendo - Idea
#------------------------------------------------------------------------------
#
# Version 1.0 Initial Release
# Version 1.1 
#   - Added new methods that allow better use and ease of use.
#   - Added reset exp method for after the battle regardless the out come
#
#------------------------------------------------------------------------------
# Instructions:
#
#     Check out the module bellow and set your values accordingly.
#     you can now use $battle.mult_val(val) and $battle.div_val(val)
#     to change the exp out put the way you want it out put, this will then
#     reset after battle regardless of the out come.
#
#------------------------------------------------------------------------------
#  Plug and Play
#==============================================================================



module BATTLE

 #--------------------------------------------------------------------------
 # â— Multiply or Divide (or both) the exp gained from enemies.
 #     --> If Divde and Multiply are given a value then
 #         it will multiply and then divide the final total.
 #--------------------------------------------------------------------------
 module EXP
   MULT = 2.6
   DIV = 0.8
 end

 #--------------------------------------------------------------------------
 # â— Multiply or Divide (or both) the gold gained from enemies.
 #     --> If Divde and Multiply are given a value then
 #         it will multiply and then divide the final total.
 #--------------------------------------------------------------------------
 module GOLD
   MULT = 0
   DIV = 0
 end

 #--------------------------------------------------------------------------
 # â— Set Variables.
 #    this will set all variables
 #--------------------------------------------------------------------------
 module STATS
   MULT = 10
   DIV = 11
 end

end

class Battle

 attr_accessor :exp_mult
 attr_accessor :exp_div

 #--------------------------------------------------------------------------
 # â— initialize
 #    set the variables to be used as the default module varibles
 #--------------------------------------------------------------------------
 def initialize
   @exp_mult = BATTLE::EXP::MULT
   @exp_div = BATTLE::EXP::DIV
 end

 #--------------------------------------------------------------------------
 # â— mult_val(val)
 #    val : val
 #--------------------------------------------------------------------------
 def mult_val(val)
   @exp_mult = mult_priv_val * val
 end

 #--------------------------------------------------------------------------
 # â— div_val(val)
 #    val : val
 #--------------------------------------------------------------------------
 def div_val(val)
   @exp_div = div_priv_val * val
 end

 #--------------------------------------------------------------------------
 # â— core_reset
 #    just call initialize re-init the variables.
 #--------------------------------------------------------------------------  
 def core_reset
   initialize
 end

 #--------------------------------------------------------------------------
 # â— mult_priv_val
 #     private method.
 #     sets up the @exp variable for use in exp formula
 #--------------------------------------------------------------------------
 def mult_priv_val
   if @exp_mult
     @exp_mult
   else
     @exp_mult = BATTLE::EXP::MULT
   end
 end

 #--------------------------------------------------------------------------
 # â— div_priv_val
 #    private method.
 #    sets up the @exp variable for use in the exp formula
 #--------------------------------------------------------------------------
 def div_priv_val
   if @exp_div
     @exp_div
   else
     @exp_mult = BATTLE::EXP::DIV
   end
 end

 private :mult_priv_val
 private :div_priv_val

end

module DataManager

 #--------------------------------------------------------------------------
 # â— create_game_objects
 #    $battle is what you will use to call either:
 #       $battle.mult_val(val) or $battle.div_val(val)
 #--------------------------------------------------------------------------
 class<<self; alias adrien_create_game_objects_76yt create_game_objects end
 def self.create_game_objects
   adrien_create_game_objects_76yt
   $battle = Battle.new
 end

end

module BattleManager

 #--------------------------------------------------------------------------
 # â— process_victory
 #    $battle.core_reset is called to rest the exp to that of
 #     the module.
 #--------------------------------------------------------------------------  
 class<<self; alias adrien_process_vic_change_uyhgyt6 process_victory end
 def self.process_victory
   adrien_process_vic_change_uyhgyt6
   $battle.core_reset
 end

 #--------------------------------------------------------------------------
 # â— process_abort
 #    $battle.core_reset is called to rest the exp to that of
 #     the module.
 #--------------------------------------------------------------------------  
 class<<self; alias adrien_abort_about_now process_abort end
 def self.process_abort
   adrien_abort_abort_now
   $battle.core_rest
 end

 #--------------------------------------------------------------------------
 # â— process_defeat
 #    $battle.core_reset is called to rest the exp to that of
 #     the module.
 #--------------------------------------------------------------------------  
 class<<self; alias adrien_lose_the_battle_yo process_defeat end
 def self.process_defeat
   adrien_lose_the_battle_yo
   $battle.core_reset
 end

end


class Game_Enemy
 #--------------------------------------------------------------------------
 # â— exp
 #     Used to set up the calculations for exp based on the module
 #     and or the $battle method used.
 #--------------------------------------------------------------------------
 alias adrien_change_enemy_exp exp
 def exp
   if BATTLE::EXP::MULT > 0
     (enemy.exp * $battle.exp_mult).to_i
   elsif BATTLE::EXP::DIV > 0
     (enemy.exp / $battle.exp_div).to_i
   elsif BATTLE::EXP::DIV > 0 && BATTLE::EXP::MULT > 0
     ((enemy.exp * $battle.exp_mult) / $battle.exp_div).to_i
   else
     adrien_change_enemy_exp
   end
 end

 #--------------------------------------------------------------------------
 # â— gold
 #     Uses module set variables to multiply or divide the 
 #     amount of gold given after a battle.
 #--------------------------------------------------------------------------
 alias adrien_change_gold_give gold
 def gold
   if BATTLE::GOLD::MULT > 0
     (enemy.gold * BATTLE::GOLD::MULT).to_i
   elsif BATTLE::GOLD::DIV > 0
     (enemy.gold / BATTLE::GOLD::DIV).to_i
   elsif BATTLE::GOLD::DIV > 0 && BATTLE::GOLD::MULT > 0
     ((enemy.gold * BATTLE::GOLD::MULT) / BATTLE::GOLD::DIV).to_i
   else
     adrien_change_gold_give
   end
 end

 #--------------------------------------------------------------------------
 # â— param_base(param_id)
 #    param_id : id of param
 #     Used to set all the params of a individual enemy based on module
 #     variables.
 #--------------------------------------------------------------------------
 alias adrien_param_base param_base
 def param_base(param_id)
   if BATTLE::STATS::MULT > 0
     (enemy.params[param_id] * $game_variables[bATTLE::STATS::MULT]).to_i
   elsif BATTLE::STATS::DIV > 0
     (enemy.params[param_id] / $game_variables[bATTLE::STATS::DIV]).to_i
   elsif BATTLE::STATS::DIV > 0 && BATTLE::STATS::MULT > 0
     ((enemy.params[param_id] * $game_variables[bATTLE::STATS::MULT]) / $game_vraiables[bATTLE::STATS::DIV]).to_i
   else
     adrien_param_base(param_id)
   end
 end

end

 

 

Edited by A.

Share this post


Link to post
Share on other sites

It'd be easier if there were methods like BATTLE#set_exp_mult(), but there aren't, so you'll just have to set the constants manually like this:

BATTLE::EXP::MULT = 5

Share this post


Link to post
Share on other sites

I don't quite understand this. If the exp, gold, and stats can't be changed during battle, or anytime during the game for that matter, what's the difference from me, the designer, changing the stats, gold, and exp in the database itself?

 

This script can be quite useful in gameplay if you can add some helpful features for the designers. You should look at ways of making it so that the designer can use script-calls to your script in a common event. That way, we can have skills that make changes to our enemy stats, due exp, and gold when used in battle. (Btw, does the stats-changing affect all enemies in the troop or only one enemy?)

Something like this for a skill's common event:

1. Script-call to increase amount of due experience points x2.

2. After 5 turns, reduce amount of due experience points by half using script-call.

 

How cool could that be? Hope you can add such features, or else this script feels pretty much the same as to what can be done easily in the database.

Share this post


Link to post
Share on other sites
1. Script-call to increase amount of due experience points x2.

2. After 5 turns, reduce amount of due experience points by half using script-call.

BATTLE::EXP::MULT *= 2

(after five rounds):

BATTLE::EXP::MULT *= 0.5

This should work ;)

Share this post


Link to post
Share on other sites

@Regendo - Thanks. That's what I was looking for. But then there's still the question by Seiryuki about the ability to change the stats of individual enemies instead of the whole troop. If A. can incorporate that feature somehow, that'll be a kick-ass script. {I actually recently asked for this feature in script requests}

Share this post


Link to post
Share on other sites

I see some people are having some issues:

 

Game_Enemy from my understanding is for one enemy. so my stat changer changes the stats of that enemy not of that troop.

 

It'd be easier if there were methods like BATTLE#set_exp_mult(), but there aren't, so you'll just have to set the constants manually like this:

BATTLE::EXP::MULT = 5

 

Could you clarify this? I might be able to incorporate it.

 

if you guys have any other features you would like to see incorporated please list them in detail.

Edited by A.

Share this post


Link to post
Share on other sites

For example, you could add an method to BATTLER module:

def set_exp_mult(value)
 BATTLE::EXP::MULT = value
end

 

However, imo it would be a good idea to make another set of variables and take those constants as a default value, like this:

module BATTLE
 module EXP
MULT = 2.6 #default multiplier
DIV = 0.8 #default divident
 end
 def self.exp_mult
@exp_mult ? @exp_mult : reset_exp_mult
 end
 def self.reset_exp_mult
@exp_mult = BATTLE::EXP::MULT
 end
 def self.exp_mult*(value)
@exp_mult = exp_mult * value
 end
end

 

(Note that you have to use self. for defining methods inside of modules)

That way (if I take TheChancellor's example), you could use

BATTLE.exp_mult*(2)

and five rounds later

BATTLE.exp_mult*(0.5)

 

also, you could use

BATTLE.reset_exp_mult

at the end of the battle. You can't do this the way your code is right now.

(Obviously, you'd have to change your formulas as well, so that they use BATTLE.exp_mult instead of BATTLE::EXP::MULT)

Edited by regendo

Share this post


Link to post
Share on other sites

I will get to work on this right away. Your code my be implemented as is (with credits) after changes and tests. I have a few other ideas. if any one else has any other features please request.

Share this post


Link to post
Share on other sites

Basically, you need to make for each constant:

  • one instance variable (@exp_mult)
  • one getter method (exp_mult)
  • one reset method (reset_exp_mult)
  • one multiply method (exp_mult*(value))
  • one add method (exp_mult+(value))

If you want to, you can of course also make a method

exp_mult-(value); exp_mult+(-value); end

and

exp_mult/(value); exp_mult*(1/value); end

, but those aren't necessary.

Credits actually aren't necessary either, but I won't complain.

 

Also, because it may be confusing to read if you're not familar with the shortened if:

Above mentioned method #exp_mult's code is short for

if @exp_mult
 @exp_mult
else
 @exp_mult = BATTLE::EXP::MULT
end

 

Edit: Also, it would be nice if you called every reset method at the end of battle, regardless of the type of end (win, lose, escape).

For this, a method

def reset
 reset_exp_mult
 reset_exp_div
 reset_gold_mult
 #(...)
end

would be appreciated.

Edited by regendo

Share this post


Link to post
Share on other sites

@regendo, @A.

Ah, I forgot that you can change constants in the game. My bad.

Also, once those features regendo mentioned are implemented, this would be one boss script.

Thanks A., I'll see how I can implement it into my game once those methods are in.

Share this post


Link to post
Share on other sites

Everything Regendo said ;) At the moment it sounds like a really cool script, but looking at it it seems to difficult for me (a non-coder) to use. I am too frightened that I might forget to reset a multiplier after battle and have the party get 1.2x experience for the rest of the game, which could be very hard to pick up during playtesting (for example).

 

But I love the idea of getting bonus EXP dependant on your performance against a boss :)

Edited by Tobyej

Share this post


Link to post
Share on other sites
I am too frightened that I might forget to reset a multiplier after battle and have the party get 1.2x experience for the rest of the game

If A. implements the reset method (that is called at the end of battle in the script itself), you won't have to worry about doing the reset manually for each battle.

Edited by Seiryuki

Share this post


Link to post
Share on other sites

Exactly. By adding BATTLE.reset_all (or what A will call the method) to BattleManager#process_abort, #process_victory, #process_escape and #process_defeat, all values will be reset to default at battle end, no matter how it ends.

 

(like this:)

alias a_battle_victory process_victory

def process_victory

BATTLE.reset_all

a_battle_victory

end

Share this post


Link to post
Share on other sites

Script is updated to version 1.1 Feature request has been met. If you have any questions please ask. you have any more feature requests please be detailed in your response.

Share this post


Link to post
Share on other sites

The class Battle is a nice idea, I didn't think of that.

I would've done everything from the module, but I if this makes a difference, it is an improval.

Now you just have to do the same you did with exp with stats and gold as well (and maybe add an additional reset method per variable, e.g. to reset exp only) :)

Although I'd have done the formula different:

alias adrien_change_enemy_exp exp
def exp
 e = adrien_change_enemy_exp
 e *= $battle.exp_mult if $battle.exp_mult > 0
 e *= 1/$battle.exp_div if $battle.exp_div > 0
 e.to_i
end

There is no difference in the outcome, since both methods calculate with the exact values and only round them in the end, but I personally like this style better.

Share this post


Link to post
Share on other sites

I don't know of there is need to do gold or stats. Is every one else wanting that?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted