Jump to content
Sign in to follow this  
Nérylis

[VXAce]Change charge TP by damage suffered

Recommended Posts

 

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.

 

 

Ok but I've got a problem. I tested and this is an example (always with self.tp += 1 for physical attacks) :

 

- If my actor has 0 TP and an enemy make a critical hit, he wins 2 TP and has 2 TP (0 + 1 x 2 = 2 : no problem).

- If my actor has 2 TP and an enemy make a critical hit, he wins 4 TP and has 6 TP (2 + 1 x 2 = 4, not 6 : problem).

- If my actor has 6 TP and an enemy make a critical hit, he wins 8 TP and has 14 TP (6 + 1 x 2 = 8, not 14 : problem).

 

To resume, if each physical attack of the enemies is configurate to give 1 TP for the actor targeted, each critical hit must give 1 x 2 = 2 TP.

 

Have you understand the problem ?

 

Edit : In RPG Maker, we can configurate magical attacks which give critical hits, no ? I think we can configurate "Yes" in critical box.

Edited by Nérylis

Share this post


Link to post
Share on other sites

for this problem:

If my actor has 2 TP and an enemy make a critical hit, he wins 4 TP and has 6 TP (2 + 1 x 2 = 4, not 6 : problem).

 

Here's why. Physical Attack = 1 TP, and its a critical, its 1 x 2 which is 2. Now if the actor has 2 TP, 2 x 2 = 4.

 

It gets the current tp, not a static variable. I think you got what I mean. That is because your request was to double the value to get. So current value * 2 = new current tp. 

 

You can create a variable instead to get that current tp, multiply it and add it to the current tp instead.

 

 

 

class Game_Battler < Game_BattlerBase
  attr_accessor :get_current_tp_additive
  alias orpheus_tp_additive_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    orpheus_tp_additive_initialize
    @get_current_tp_additive = 0 # resets to 0 every start of the battler init.
  end  
  #--------------------------------------------------------------------------
  # * 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)
          @get_current_tp_additive = self.tp * 2
          self.tp += @get_current_tp_additive
        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

I don't want the current TP, I want the value that I configurate in the script.

 

If I configure self.tp += a for physical attacks, I want that a critical hit give self.tp += 2 x a.

 

Examples :

 

 with self.tp += 1 for my actor targeted with physical attacks, critical hit with physical attacks must give 2 x 1 = 2 TP to my actor. His TP increase by 2.

 with self.tp += 3 for my actor targeted with physical attacks, critical hit with physical attacks must give 2 x 3 = 6 TP to my actor. His TP increase by 6.

 with self.tp += 12 for my actor targeted with physical attacks, critical hit with physical attacks must give 2 x 12 = 24 TP to my actor. His TP increase by 24.

 

Value's TP gained with critical hit must be based on the value configurated in the script, not the current value of the actor.

Share this post


Link to post
Share on other sites

That's why you can change the variable there, 

 @get_current_tp_additive = self.tp * 2

with anything you want. If you do not want the current tp, you can just change it to 2, 3, etc. That will be the ones added to your tp.

Share this post


Link to post
Share on other sites

Ah ok, I understand now. Yes, it works.

 

But, still a question : why I couldn't do the same thing with magical attacks and critical ? In the database, we can configurate a magical skill with critical.

Share this post


Link to post
Share on other sites

Magical Attacks can't be done with critical hits. Or rather, there is no such thing as Critical Magic Hit. This is because magical attacks are handled differently. This one by default:

item.damage.critical ? user.cri * (1 - cev) : 0

is only applied to physical attacks by default. This makes magical attacks not to be able to apply a critical hit. So you'd have to tap around item_apply and make_damage_value to check if it is a magical attack and make a formula to calculate if it is a critical hit or not.

Share this post


Link to post
Share on other sites

Ok, thanks for your explanations.

 

I would like to make an additional request on the same subject. In my database, This time, we take place on the side of the actors as being the aggressors and as winning TP when they attack the enemy. I configured the skills so that only some of them give TP to the launcher. But I noticed two problems :

 

- When the enemy receive 0 damage, TP of the actor increase normally. Is it possible that TP don't increase ?

- When the enemy receive a critical hit, TP of the actor increase normally too. Is it possible that TP increase in the same way of previous ? I would like that my actors win twice more points. Example : My based skill Attack give 1 TP to the launcher. If a critical hit is done, I would like that my actor win 2 TP (1 x 2).

Share this post


Link to post
Share on other sites

I don't clearly understand as there's too many confusing questions. So far you have:

 

  • x2 TP when actor receives a critical else it will receive 2 TP when its not a critical.
  • +2 TP when actor receives a magical attack.

These are in the premise that the damage is > 0.

 

 

 

class Game_Battler < Game_BattlerBase
  attr_accessor :get_current_tp_additive
  attr_accessor :get_current_tp_additive_for_enemy
  attr_accessor :gain_normal
  alias orpheus_tp_additive_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    orpheus_tp_additive_initialize
    @get_current_tp_additive = 0 # resets to 0 every start of the battler init.
    @get_current_tp_additive_for_enemy = 0 # resets to 0 every start of the battler init.
    @gain_normal = false
  end  
  #--------------------------------------------------------------------------
  # * 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)
          @get_current_tp_additive = self.tp * 2
          self.tp += @get_current_tp_additive
        else
          self.tp += 2
        end
      end
      self.tp += 2 if item.magical? and user.is_a?(Game_Enemy)
    end    
    if user.is_a?(Game_Actor) and value > 0
      if item.physical? and user.is_a?(Game_Actor)
        if @result.critical and user.is_a?(Game_Actor)
          @get_current_tp_additive_for_enemy = self.tp * 2
          self.tp += @get_current_tp_additive_for_enemy
        else
          self.tp += 2
        end
      end
      self.tp += 2 if item.magical? and user.is_a?(Game_Actor)
    end  
    if user.is_a?(Game_Actor)
      if value <= 0
        @gain_normal = true
      end
    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
    if @gain_normal
      @gain_normal = false
      self.tp += value 
    end
  end  
  #--------------------------------------------------------------------------
  # * Charge TP by Damage Suffered
  #--------------------------------------------------------------------------
  def charge_tp_by_damage(damage_rate) 
    if @gain_normal
      self.tp += 50 * damage_rate * tcr
      @gain_normal = false
    end
  end
end  

 

 

 

The script above makes the following features:

  • Gains TP normally when the actor receives a damage lesser than or equal to 0.
  • Gains x2 TP when the actor deals a critical damage to the enemy, same as the ones with Game Enemy function.

These are in the premise that:

  • Actor's Damage to Enemy is <= 0 or Enemy receives a critical hit.

I don't really understand how you want 

 

 

When the enemy receive a critical hit, TP of the actor increase normally too

 

when you already have this

 

 

 I would like that my actors win twice more points. Example : My based skill Attack give 1 TP to the launcher. If a critical hit is done, I would like that my actor win 2 TP (1 x 2).

 

Because this would go both if this is the case. It would go: Normal TP Gain + x2 TP gain. Therefore what I did was to consider the first premise that it would gain x2 TP when it hits a critical, not go get a normal TP gain.

Edited by SoulPour777

Share this post


Link to post
Share on other sites

No, it's not that. For your script in your previous post (posted 06/04/15 at 4:34 PM), it's perfect.

 

For my additionnal request, it concerns the TP win by the actors when they attack.

 

 

In my database, This time, we take place on the side of the actors as being the aggressors and as winning TP when they attack the enemy. I configured the skills so that only some of them give TP to the launcher. But I noticed two problems :

 

- When the enemy receive 0 damage, TP of the actor increase normally. Is it possible that TP don't increase ?

- When the enemy receive a critical hit, TP of the actor increase normally too. Is it possible that TP increase in the same way of previous ? I would like that my actors win twice more points. Example : My based skill Attack give 1 TP to the launcher. If a critical hit is done, I would like that my actor win 2 TP (1 x 2).

 

Do you understand better my request ?

Share this post


Link to post
Share on other sites

When the enemy receive a critical hit, TP of the actor increase normally too

 

Yes it possible for the tp not to increase. Just basically make it return 0 or just 0 so it won't have any effect at all.

 

That's why I added this:

    if user.is_a?(Game_Actor)
      if value <= 0
        @gain_normal = true
      end
    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
    if @gain_normal
      @gain_normal = false
      self.tp += value 
    end
  end  

because gaining the normal value will only come when the value is < or equal to 0, as you've asked.

 

When the enemy receive a critical hit, TP of the actor increase normally too

 

I just added this on the script.

 

It is possible, I just did it here:

    if user.is_a?(Game_Actor) and value > 0
      if item.physical? and user.is_a?(Game_Actor)
        if @result.critical and user.is_a?(Game_Actor)
          @get_current_tp_additive_for_enemy = self.tp * 2
          self.tp += @get_current_tp_additive_for_enemy
        else
          self.tp += 2
        end
      end
      self.tp += 2 if item.magical? and user.is_a?(Game_Actor)
    end 

The same how the enemy behaved.

Share this post


Link to post
Share on other sites

I tried but I've got a mistake : undefined local variable or method user for main: object. 

 

Where should I place these pieces of script ?

Share this post


Link to post
Share on other sites

These were just an explanation, the whole script can be found from my earlier reply.

Share this post


Link to post
Share on other sites

I tried but it doesn't work. When my actor make a critical hit, he wins 1 TP and not 2. When he makes 0 damage, he wins 1 TP but he should win 0.

Share this post


Link to post
Share on other sites

Up

 

Are you sure that my additionnal request take place in the same part of the script ? My request is about TP win when actors attack, and not when they are attacked by enemies.

Share this post


Link to post
Share on other sites

It is. Look, its checking if the attacker is an actor.

@result.critical and user.is_a?(Game_Actor)

The user of the critical hit is no other than the actor.

Share this post


Link to post
Share on other sites

I confirm : it doesn't work. My actors win TP when they make 0 damage to the enemies. And critical hits give the normal value of TP won.

Share this post


Link to post
Share on other sites

Did you make the TP gain in the skills tab 0 for Attack?

Share this post


Link to post
Share on other sites

Exactly. Then you can configure in the script exactly what tp is gained after.

Share this post


Link to post
Share on other sites

Ok, I tried by configuring Attack skill at 0 TP. But there is a problem : my actors don't win TP when they attack. In the script, I configurated 1 * 2 TP for critical hits, and 1 TP for normal hits.

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