Jump to content
Sign in to follow this  
Nérylis

[VXAce]Change charge TP by damage suffered

Recommended Posts

Hi, I make a script to change charge TP by damage suffered. When an enemy uses a skill, my actor's TP increase by 1 :

 

 

class Game_Battler

  
  #--------------------------------------------------------------------------
  # * Charge TP by Damage Suffered
  #--------------------------------------------------------------------------
  def charge_tp_by_damage(damage_rate)
    self.tp += 1
  end
end

 
I would like to change this in function of type of attack. Examples : simple skills, TP+1 ; magic skills, TP+2 ; special skills, TP+3.
 
Can you help me, please ?

Share this post


Link to post
Share on other sites

You can do it on make_damage_value.

 

For example:

class Game_Battler < Game_BattlerBase
  alias :game_battler_make_damage_value :make_damage_value
  def make_damage_value(user, item)
    game_battler_make_damage_value(user, item)
    user.tp += 100 if item.physical? and user.is_a?(Game_Actor)
    user.tp += 100 if item.magical? and user.is_a?(Game_Actor)
    user.tp += 100 if item.damage.recover? and user.is_a?(Game_Actor)
  end
end

Share this post


Link to post
Share on other sites

It doesn't work. I configurate as : 

 

user.tp += 1 if item.physical? and user.is_a?(Game_Actor)

user.tp += 2 if item.magical? and user.is_a?(Game_Actor)

 

But my actors win more TP.

 

It's when my actors receive damage that I want they win 1 TP for physical skills or 2 TP for magical skills.

Share this post


Link to post
Share on other sites

Can't you do this by default in the Skills tab?

 

"TP Gain" in the Invocation section applies to the USER of the skill and will add that amount for each target hit by the skill (if it's set to 5, and it hits four targets, the user would gain 20 TP).

 

However, if you use the "Gain TP" EFFECT (on the right side, the same place where you'd add a State, or a Buff), it applies to the TARGET of the action.

 

So you could set the Gain TP as 1 for any skill you'd want to increase TP by 1 when someone is hit by it.

Share this post


Link to post
Share on other sites

It doesn't work. I configurate as : 

 

user.tp += 1 if item.physical? and user.is_a?(Game_Actor)

user.tp += 2 if item.magical? and user.is_a?(Game_Actor)

 

But my actors win more TP.

 

It's when my actors receive damage that I want they win 1 TP for physical skills or 2 TP for magical skills.

 

Sorry I misread your question.

 

Change it to this:

class Game_Battler < Game_BattlerBase
  alias :game_battler_make_damage_value :make_damage_value
  def make_damage_value(user, item)
    game_battler_make_damage_value(user, item)
    user.tp += 1 if item.physical? and user.is_a?(Game_Enemy)
    user.tp += 2 if item.magical? and user.is_a?(Game_Enemy)
    user.tp += 3 if item.damage.recover? and user.is_a?(Game_Enemy)
  end
end

Share this post


Link to post
Share on other sites

Oh yeah, lol.

self.tp += 1 if item.physical? and user.is_a?(Game_Enemy)

Share this post


Link to post
Share on other sites

The Gain TP is a %, not a simple value.

 

And the max TP is 100%, so putting in 5% gets you 5 TP.

 

Trust me, you don't need a script for this. If anything, you can find the Gain TP method in the default scripts and change it from a percentage to a flat integer, if you have a higher max TP than the default 100.0.

Share this post


Link to post
Share on other sites

 

Oh yeah, lol.

self.tp += 1 if item.physical? and user.is_a?(Game_Enemy)
 

 

It doesn't work either.

 

 

 

Trust me, you don't need a script for this. If anything, you can find the Gain TP method in the default scripts and change it from a percentage to a flat integer, if you have a higher max TP than the default 100.0.

 

For the moment, I use the system by default with TP max at 100. But I plan to change that with a script of Tsukihime.

Share this post


Link to post
Share on other sites

Well, you'll have to use self as a variable. I tried it this way, my Level 1 Eric guarded a physical attack from a slime, and I got 100TP, because it says so in the script.

class Game_Battler < Game_BattlerBase
  def make_damage_value(user, item, actor = self)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
    self.tp += 100 if item.physical? and user.is_a?(Game_Enemy)
    self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)
    self.tp += 3 if item.damage.recover? and user.is_a?(Game_Enemy) 
  end
end

Share this post


Link to post
Share on other sites

You could be using some script that changes it. I tried it and it clearly works. Actually, even without using the actor = self, just by using self, you can gain the TP correctly.

Share this post


Link to post
Share on other sites

Interesting, however I tried it on a new project and it works.

Share this post


Link to post
Share on other sites

I make a demo for you : http://www.mediafire.com/download/o7srp2h9yqirtq8/Project1%284%29.exe

 

I configurate :

- 1 TP win for actor targeted when enemies do physical skills

- 2 TP win for actor targeted when enemies do magical skills

 

- Slimes on the map have skills Attack and Fire.

 

Tell me if it works for you.

Edited by Nérylis

Share this post


Link to post
Share on other sites

Ohhh, I see what you mean. We shall remove two functions and rewrite them. Use this:

class Game_Battler < Game_BattlerBase
  def make_damage_value(user, item, actor = self)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
    self.tp += 1 if item.physical? and user.is_a?(Game_Enemy)
    self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)
    self.tp += 3 if item.damage.recover? and user.is_a?(Game_Enemy) 
  end
  #--------------------------------------------------------------------------
  # * [TP Gain] Effect
  #--------------------------------------------------------------------------
  def item_effect_gain_tp(user, item, effect)
    value = effect.value1.to_i
    @result.tp_damage -= value
    @result.success = true if value != 0
  end  
  #--------------------------------------------------------------------------
  # * Charge TP by Damage Suffered
  #--------------------------------------------------------------------------
  def charge_tp_by_damage(damage_rate); end  
end

Share this post


Link to post
Share on other sites

It works better.

 

Is it possible to don't count the increase of TP :

- with "damage.recover" type skills ?

- with the fact that the actors don't receive damage (0 damage) ?

 

Is it possible to double value's TP when the actors receive a critical hit ?

Share this post


Link to post
Share on other sites


class Game_Battler < Game_BattlerBase

#--------------------------------------------------------------------------

# * Make Damage Value : Aliased

#--------------------------------------------------------------------------

def make_damage_value(user, item)

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

value *= item_element_rate(user, item)

value *= pdr if item.physical?

value *= mdr if item.magical?

value *= rec if item.damage.recover?

value = apply_critical(value) if @result.critical

value = apply_variance(value, item.damage.variance)

value = apply_guard(value)

@result.make_damage(value.to_i, item)

if user.is_a?(Game_Enemy) and value > 0

self.tp += 1 if item.physical? and user.is_a?(Game_Enemy)

self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)

self.tp *= 2 if @result.critical and user.is_a?(Game_Enemy)

end

end

#--------------------------------------------------------------------------

# * [TP Gain] Effect : Modified

#--------------------------------------------------------------------------

def item_effect_gain_tp(user, item, effect)

value = effect.value1.to_i

@result.tp_damage -= value

@result.success = true if value != 0

end

#--------------------------------------------------------------------------

# * Charge TP by Damage Suffered : Modified

#--------------------------------------------------------------------------

def charge_tp_by_damage(damage_rate); end

end

Edited by SoulPour777

Share this post


Link to post
Share on other sites

I found a small bug with criticals. When my actors receive a critical hit, the value's TP increase more faster because the system count *2 each time. My actors win 2 TP, then 4 TP, then 8 TP, etc...

Share this post


Link to post
Share on other sites

That is because a critical attack is still considered a physical attack. So if you have 0 tp and you got hit by a critical attack, it counts. For example, we have 0 TP at the beginning of the battle. Slime hits Eric. Physical, that's 1. It's critical, so that would be 2. I don't really know what you mean by doubled, because that means current tp * 2.

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Make Damage Value : Aliased
  #--------------------------------------------------------------------------  
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
    if user.is_a?(Game_Enemy) and value > 0
      if item.physical? and user.is_a?(Game_Enemy)
        if @result.critical and user.is_a?(Game_Enemy)
          self.tp *= 2 
        else
          self.tp += 2
        end
      end
      self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)
    end    
  end
  #--------------------------------------------------------------------------
  # * [TP Gain] Effect : Modified
  #--------------------------------------------------------------------------
  def item_effect_gain_tp(user, item, effect)
    value = effect.value1.to_i
    @result.tp_damage -= value
    @result.success = true if value != 0
  end  
  #--------------------------------------------------------------------------
  # * Charge TP by Damage Suffered : Modified
  #--------------------------------------------------------------------------
  def charge_tp_by_damage(damage_rate); end   
end

Only physical attacks have their own critical shots by default.

Share this post


Link to post
Share on other sites

I maybe badly expressed myself.

 

What I wanted was that when an enemy makes me a critical hit, the values programmed in the script are doubled.

 

Example :

 

self.tp += 1 if item.physical? and user.is_a?(Game_Enemy)
self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)

 

If an enemy makes me a critical hit with physical attack, my actor targeted win 1 TP * 2.

If an enemy makes me a critical hit with magical attack, my actor targeted win 2 TP * 2.

Share this post


Link to post
Share on other sites

One problem is there's no such thing critical magical attack. I have a script called Magic Critical Orpheus which does that. The part for the physical, 

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Make Damage Value : Aliased
  #--------------------------------------------------------------------------  
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
    if user.is_a?(Game_Enemy) and value > 0
      if item.physical? and user.is_a?(Game_Enemy)
        if @result.critical and user.is_a?(Game_Enemy)
          self.tp += 1
          self.tp *= 2 
        else
          self.tp += 2
        end
      end
      self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)
    end    
  end
  #--------------------------------------------------------------------------
  # * [TP Gain] Effect : Modified
  #--------------------------------------------------------------------------
  def item_effect_gain_tp(user, item, effect)
    value = effect.value1.to_i
    @result.tp_damage -= value
    @result.success = true if value != 0
  end  
  #--------------------------------------------------------------------------
  # * Charge TP by Damage Suffered : Modified
  #--------------------------------------------------------------------------
  def charge_tp_by_damage(damage_rate); end   
end

Share this post


Link to post
Share on other sites

It doesn't work. My actors targeted win 2 TP when enemies makes physical attacks but I think there is a mistake in the script :

 

if @result.critical and user.is_a?(Game_Enemy)
self.tp += 1
self.tp *= 2
else
self.tp += 2 self.tp += 1

 

Right ?

 

The bug with critical hits is still here, the current value of TP is counted and the calculation is done on it, not on the value configurated in the script.

 

This system of critical hits with physical attacks, it doesn't work with magical attacks ?

Share this post


Link to post
Share on other sites

Well you can change it to any amount you want it to be there, not really a fault of the script. The critical is not also a bug. This is what happens, Physical Damage does the Critical Hit, not the magical hits. Therefore, Physical Effects is carried by Critical Damages. So if you gain 1 TP by Physical Attack and you said you wanted the value to be doubled when it is critical and since physical gives you 1... 1 x 2 = 2. That's why you get 2.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted