Gain certain stats from certain enemies?

Disarmed

Villager
Member
Joined
Dec 6, 2014
Messages
29
Reaction score
1
First Language
English
Primarily Uses
Is it possible to fight enemies and when you kill it, you earn certain stats? For example:

I would fight a Snake

The snake is really fast, so every time I kill a snake, I gain 3 agility. Like, killing certain enemies as in you're training to be faster.

Is this possible?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
if the battle is evented, this will be easy to do using event commands
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
It's certainly possible, and I'm working on and off on a script that allows you to set up all different kinds of similar effects (gain stats when you KO a certain foe, gain items when you Crit a foe with a certain skill, have a certain enemy stun you if you hit them with an Element they are Immune to, etc.).  But due to its complexity, this script is still probably several months off.

For now, the easiest way to do it would probably be to modify the Damage Processing method.  Check to see whether an enemy's HP has been reduced to zero or less, and if so, award the character that KO'ed that enemy some bonus stats.  Here's the original method:

#-------------------------------------------------------------------------- # * Damage Processing # @result.hp_damage @result.mp_damage @result.hp_drain # @result.mp_drain must be set before call. #-------------------------------------------------------------------------- def execute_damage(user) on_damage(@result.hp_damage) if @result.hp_damage > 0 self.hp -= @result.hp_damage self.mp -= @result.mp_damage user.hp += @result.hp_drain user.mp += @result.mp_drain endHere's a rewrite that would grant stats based on the enemy you KO'd.  In the example below, enemies 1, 2, and 3 are slimes that increase your Attack by 10 when you defeat them, and enemies 4, 5, and 6 are snakes that increase your Agility by 10.

#--------------------------------------------------------------------------# * Damage Processing# @result.hp_damage @result.mp_damage @result.hp_drain# @result.mp_drain must be set before call.#--------------------------------------------------------------------------def execute_damage(user)on_damage(@result.hp_damage) if @result.hp_damage > 0self.hp -= @result.hp_damageif (self.enemy? and user.actor? and self.hp <= 0) case self.enemy_id when 1, 2, 3 user.add_param(2, 10) when 4, 5, 6 user.agi += (6, 10) endendself.mp -= @result.mp_damageuser.hp += @result.hp_drainuser.mp += @result.mp_drainendThis does not cover a few fringe cases, such as an enemy that is KO'ed by Slip Damage, or an enemy that KO's itself (how would it know who to award the Kill to?).

Hope this helps!  Let me know if you try it and it doesn't work - I haven't tested it myself.  But I'm confident in the general concept, so if there's anything awry, it's probably just a single incorrect property or something.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,203
First Language
Binary
Primarily Uses
RMMZ
user.atk += 2 user.agi += 3
These will not work. There is no way to just add onto a stat using that method. You would have to increase the param_plus value - which is an array of param id's and their bonus values.

Something like this is more appropriate:

#===============================================================================# Notetag: <pargain: param_id, value># param_id = 0..7 || value = amount to increase#===============================================================================class Game_Battler#=============================================================================== #----------------------------------------------------------------------------- # #----------------------------------------------------------------------------- alias :exe_dmg_par_gain :execute_damage def execute_damage(user) exe_dmg_par_gain(user) if enemy? && dead? && user.actor? if enemy.note =~ /<pargain:(.*),(.*)>/i user.add_param($1.to_i,$2.to_i) end end end #----------------------------------------------------------------------------- # #-----------------------------------------------------------------------------endAnd that also allows you to notetag the enemies to give a different gain for each enemy ^_^
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
These will not work. There is no way to just add onto a stat using that method. You would have to increase the param_plus value - which is an array of param id's and their bonus values.
Ah, yeah, that was sloppy of me.  Thanks for the catch, Dekita.  Like I had mentioned, I had not tested it.  Modified my approach above to use "add_param" instead of "+=" .

if enemy? && dead? && user.actor?if enemy.note =~ /<pargain:(.*),(.*)>/i

user.add_param($1.to_i,$2.to_i)
This is great!  Honestly, I've struggled in trying to incorporate notetags into my scripts.  (I've seen Galv's tutorial and it was a good start but I was still completely in the dark about how to use the concepts in more advanced ways.)  If you'd be up for making a tutorial on searching notetags for information (like the way you searched two different fields at once above, I assume looking for the comma as a separator), and how to associate that information to the actual game objects, I'm sure it would be a popular read on your website!
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Personally I would avoid loading everything into param_plus because you have no idea which bonuses are coming from what.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top