Modifying Game_Battler for TP gain on evade

Zenfinity

Villager
Member
Joined
Dec 30, 2014
Messages
13
Reaction score
1
First Language
English
Primarily Uses
I have effectively no experience scripting with ruby, save for the reading of a few tutorials about it.

I'm comfortable enough modifying the existing default game scripts. 

Here's the existing game battler script area I want to modify.

def item_effect_gain_tp(user, item, effect) value = effect.value1.to_i @result.tp_damage -= value @result.success = true if value != 0 self.tp += valueendI added this line : @result.evaded = true

in an attempt to increase TP gain on a successful evade. In my first attempt at doing so, with a test in combat, it had no effect. So I'm guessing that isn't how I go about it, however I think I do need to add in some line in this section since I want the TP gain for an evade to be a minimum amount of 1, and up to some percentage of the amount of damage the attack would have inflicted had it hit. This gain is meant to represent a relevance to the chosen attack option of the enemy. For example, a standard attack during testing seems to do about 14-17 damage, so the TP gain should be at least 1, and rarely 2. While a strong attack during testing does 40-50 damage, so the TP gain should be at least 1, possibly as much as 5, however the tp gain should be quite minuscule compared to the gain presented on an actual hit.

The area I think I need to modify to enact a TP gain for an evade is in this section.

  def item_apply(user, item)

    @result.clear

    @result.used = item_test(user, item)

    @result.missed = (@result.used && rand >= item_hit(user, item))

    @result.evaded = (!@result.missed && rand < item_eva(user, item))

    if @result.hit?

      unless item.damage.none?

        @result.critical = (rand < item_cri(user, item))

        make_damage_value(user, item)

        execute_damage(user)

      end

      item.effects.each {|effect| item_effect_apply(user, item, effect) }

      item_user_effect(user, item)

    end

  end

 

because of the if branch,  item.effects.each{ } only fires on a hit, so how do I modify 'if@result.hit?' to be an or that includes @result.evaded?

or should I just put 

 

if@result.evaded

   item.effects.each {|effect| item_effect_apply(user, item, effect) }

   item_user_effect(user, item)

end

 

I know with programming there are often a lot of ways to accomplish the same thing, and some are more effective than others, and some are just downright ignorant. I'm hoping I can implement this leaning more toward elegant rather than ignorant. 

 

After a lot of experimentation, I've added this to the end of item_apply:

 

else if @result.evaded

   self.tp += 1 + rand(4)

end


Although this does generate the effect I want, It's not the way I want to go about it. 
 
Last edited by a moderator:

Zenfinity

Villager
Member
Joined
Dec 30, 2014
Messages
13
Reaction score
1
First Language
English
Primarily Uses
Yanfly's TP manager script only allows a fixed amount increase on an evade. 
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
Well in the Game_Battler in item_apply I think you can add the line to the end :

self.tp += <something> unless @result.hit?

You say that you don't want fixed increase on evade?

Does that mean you want random increase?

If so, you can set the <something> in the script above to :

rand(<the maximum number of how many can TP increase on evade>).to_i
 

Zenfinity

Villager
Member
Joined
Dec 30, 2014
Messages
13
Reaction score
1
First Language
English
Primarily Uses
If you read to the end of my original post, I added a line that randomly increases the TP on a character evade between 1-5 points. However, What I'd really like to do is add a percentage of the damage that would have been inflicted had it hit the character. That will allow a more steady generation. For example, for a very weak attack, when it is evaded, the max gain should be 1, so for a much stronger attack, it should be more. Obviously I'd have to play with the percentages to get it just right. So this is the exact line I'm looking to add.

self.tp += 1+(formula to add amount based on damage avoided)

How do I figure that out?
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
Then I think, BUT I JUST THINK, since I'm writing this post over my mobile phone, without looking at the default scripts, that you replace <something> with :

Code:
@result.hp_damage / 100 * your_percent
So, example would look like
Code:
self.tp += @result.hp_damage / 100 * 20 unless @result.hit?
If the percentage is 20%
 

Zenfinity

Villager
Member
Joined
Dec 30, 2014
Messages
13
Reaction score
1
First Language
English
Primarily Uses
When I do self.tp += @result.hp_damage / 100 * 5% 

the game won't even start.

Instead I set it up like

@MyVar = @result.hp_damage / 100

@MyVar *= 5%

self.tp += 1 + @MyVar

this way the game does start and run, However, the formula appears to be bunk. I tested combat with level 20 enemies, and on evade the gain is still only 1TP, when the enemies are hitting in the 400-600 range. Therefore the value in @result.hp_damage is 0, so I need to write a formula to calculate what that damage would have been, and just not apply it. the existing function appears to assign the damage. I'll poke at it awhile and see what I come up with.

 

else if @result.evaded

      @zenTPadjust = item.damage.eval(user, self, $game_variables)

      @zenTPadjust /= 100

      @zenTPadjust += 5%

      self.tp += 1 + @zenTPadjust

    end

 

This is the code I've entered in. At lower levels, the TP gain for evade is a minimum of 1. At higher levels, I hope with further testing I can get the TP gain tweaked to provide the right balance. 

 

Thank you to KockaAdmiralac_FINALLY, for the information that helped me solve this issue!
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
Oh, yeah, I forgot that hp_damage is 0 XD.

Also, I don't know how 5% thing works.

The % sign is an operator for modulo, so that's why I divided the value by 100 and then multiplied it by 20, and not 20%

I'm glad you found a way yourself to resolve the hp_damage issue :)
 

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,050
Members
137,571
Latest member
grr
Top