Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
83
Reaction score
31
First Language
English
Primarily Uses
RMVXA
Hello people! I was having a problem with a plugin but I finally solved it changing it location.
I'm also using Yanfly Battle Core Script, now the problem is that this script work fines, except that in combination with the yanfly battle core is doing something weird.

The script is supposed to save the damage taken into a variable, now, for some reason, when I use this script and receive damage, the damage is substracted without a problem, BUT the pop-up always show the damage as 0, even if it clearly did 53 damage.

This is the script:
Ruby:
ActorDamageIDStart = 100

class Game_Battler < Game_BattlerBase

  # Make these available to be read by anyone (and set too just in case)
  attr_accessor :hp_damage_last, :hp_damage_turn, :hp_damage_battle
 
  alias :initialize_remember_damage :initialize unless $@
  def initialize(*args)
    initialize_remember_damage(*args)
    # Set our last damage taken arguments to zero
    @hp_damage_last = @hp_damage_turn = @hp_damage_battle = 0
  end
 
  # When the battler takes damage remember that HP damage
  alias :execute_damage_remember_damage :execute_damage unless $@
  def execute_damage(user)
    # Call the original method
    execute_damage_remember_damage(user)
        
    # We want to record damage only, not healing
    return if @result.hp_damage <= 0
    # Remember this actor's last damage taken, override last value
    @hp_damage_last = @result.hp_damage
    # Add to the cumulative turn damage here
    @hp_damage_turn += @result.hp_damage
    # And add to the battle cumulative damage here
    @hp_damage_battle += @result.hp_damage     
  end
end
 
class Game_Actor < Game_Battler

  alias :execute_damage_remember_damage_actor :execute_damage unless $@
  def execute_damage(user)
    # Call the original method so hp damage is applied correctly
    execute_damage_remember_damage_actor(user)
    
    # We want to record damage only, not healing
    return if @result.hp_damage <= 0
    
    # We want to remember the damage taken in variables too, do so here
    index = @actor_id + ActorDamageIDStart
    # Remember this actor's last damage taken, override last value
    $game_variables[index + 0] = @hp_damage_last
    # Add to the cumulative turn damage here
    $game_variables[index + 100] = @hp_damage_turn
    # And add to the battle cumulative damage here
    $game_variables[index + 200] = @hp_damage_battle
  end
 
end

class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------
  # * Battle Start
  #--------------------------------------------------------------------------
  alias :battle_start_remember_damage :battle_start unless $@
  def battle_start
    # Call the original method
    battle_start_remember_damage
    # And wipe everybody's battle-scope damage
    $game_party.members.each { |member| member.hp_damage_battle = 0 }
    $game_troop.members.each { |member| member.hp_damage_battle = 0 }
  end
  #--------------------------------------------------------------------------
  # * Start Turn
  #--------------------------------------------------------------------------
  alias :turn_start_remember_damage :turn_start unless $@
  def turn_start
    # Call the original method
    turn_start_remember_damage
    # And wipe everybody's turn-scope damage
    $game_party.members.each { |member| member.hp_damage_turn = 0 }
    $game_troop.members.each { |member| member.hp_damage_turn = 0 }
  end
end

Now, if I paste this script under the Battle Core, it doesn't save the damage into the variables. If I post it OVER the Battle core, it does store them, but the damage is always shown as 0. Is some way of fixing this? I'm not sure what this script could be interfering with the battle core to show the damage as 0.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,861
First Language
German
Primarily Uses
RMMV
I was having a problem with a plugin
No, you are having a problem with a script - because there is no plugin in VXAce and there never will be.
This might be nitpicking, but there are important differences between a script and a plugin, and mixing them up will only cause confusion.

Is some way of fixing this?
You'll need a compatibility fix between the two scripts.
Yanfly has no problems with patches, so if that other scripter also allows patches, a scripter can write such a patch for you.

however you'll need to provide links to both scripts and need to give an overview what other scripts you have added to the engine for someone to write that patch.
and since most scripters are gone, you might have to pay someone for this patch. But since the script is extremely simple that should be a rather low price if at all.
 

Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
83
Reaction score
31
First Language
English
Primarily Uses
RMVXA
No, you are having a problem with a script - because there is no plugin in VXAce and there never will be.
This might be nitpicking, but there are important differences between a script and a plugin, and mixing them up will only cause confusion.


You'll need a compatibility fix between the two scripts.
Yanfly has no problems with patches, so if that other scripter also allows patches, a scripter can write such a patch for you.

however you'll need to provide links to both scripts and need to give an overview what other scripts you have added to the engine for someone to write that patch.
and since most scripters are gone, you might have to pay someone for this patch. But since the script is extremely simple that should be a rather low price if at all.
I feel so dumb I don't know why every time I post something here I mix Plugins with Scripts.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,258
Reaction score
1,159
First Language
English
Primarily Uses
RMVXA
It took a while. I thought you had something else that was causing the issues.
But it seems that the result value for hp_damage is set to 0 when you call the alias.
So the rest of the script is never run.
How you are getting the values to save in the variables, I have no idea.
Just having yanfly battle core and this script showed the damage numbers, but did not save to variables.
But if I set a local variable before the alias is called, then it runs.
I adjusted the numbers for the test demo I used.
Ruby:
ActorDamageIDStart = 10

class Game_Battler < Game_BattlerBase

  # Make these available to be read by anyone (and set too just in case)
  attr_accessor :hp_damage_last, :hp_damage_turn, :hp_damage_battle
 
  alias :initialize_remember_damage :initialize unless $@
  def initialize(*args)
    initialize_remember_damage(*args)
    # Set our last damage taken arguments to zero
    @hp_damage_last = @hp_damage_turn = @hp_damage_battle = 0
  end
 
  # When the battler takes damage remember that HP damage
  alias :execute_damage_remember_damage :execute_damage unless $@
  def execute_damage(user)
    # Call the original method
    dam = @result.hp_damage
    execute_damage_remember_damage(user)
        
    # We want to record damage only, not healing
    return if dam <= 0
    # Remember this actor's last damage taken, override last value
    @hp_damage_last = dam
    # Add to the cumulative turn damage here
    @hp_damage_turn += dam
    # And add to the battle cumulative damage here
    @hp_damage_battle += dam
  end
end
 
class Game_Actor < Game_Battler

  alias :execute_damage_remember_damage_actor :execute_damage unless $@
  def execute_damage(user)
    # Call the original method so hp damage is applied correctly
    dam = @result.hp_damage
    execute_damage_remember_damage_actor(user)
    # We want to record damage only, not healing
    return if dam <= 0
    # We want to remember the damage taken in variables too, do so here
    index = @actor_id + ActorDamageIDStart
    # Remember this actor's last damage taken, override last value
    $game_variables[index] = @hp_damage_last
    # Add to the cumulative turn damage here
    $game_variables[index + 10] = @hp_damage_turn
    # And add to the battle cumulative damage here
    $game_variables[index + 20] = @hp_damage_battle
  end
 
end

class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------
  # * Battle Start
  #--------------------------------------------------------------------------
  alias :battle_start_remember_damage :battle_start unless $@
  def battle_start
    # Call the original method
    battle_start_remember_damage
    # And wipe everybody's battle-scope damage
    $game_party.members.each { |member| member.hp_damage_battle = 0 }
    $game_troop.members.each { |member| member.hp_damage_battle = 0 }
  end
  #--------------------------------------------------------------------------
  # * Start Turn
  #--------------------------------------------------------------------------
  alias :turn_start_remember_damage :turn_start unless $@
  def turn_start
    # Call the original method
    turn_start_remember_damage
    # And wipe everybody's turn-scope damage
    $game_party.members.each { |member| member.hp_damage_turn = 0 }
    $game_troop.members.each { |member| member.hp_damage_turn = 0 }
  end
end
 

Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
83
Reaction score
31
First Language
English
Primarily Uses
RMVXA
It took a while. I thought you had something else that was causing the issues.
But it seems that the result value for hp_damage is set to 0 when you call the alias.
So the rest of the script is never run.
How you are getting the values to save in the variables, I have no idea.
Just having yanfly battle core and this script showed the damage numbers, but did not save to variables.
But if I set a local variable before the alias is called, then it runs.
I adjusted the numbers for the test demo I used.
Ruby:
ActorDamageIDStart = 10

class Game_Battler < Game_BattlerBase

  # Make these available to be read by anyone (and set too just in case)
  attr_accessor :hp_damage_last, :hp_damage_turn, :hp_damage_battle
 
  alias :initialize_remember_damage :initialize unless $@
  def initialize(*args)
    initialize_remember_damage(*args)
    # Set our last damage taken arguments to zero
    @hp_damage_last = @hp_damage_turn = @hp_damage_battle = 0
  end
 
  # When the battler takes damage remember that HP damage
  alias :execute_damage_remember_damage :execute_damage unless $@
  def execute_damage(user)
    # Call the original method
    dam = @result.hp_damage
    execute_damage_remember_damage(user)
       
    # We want to record damage only, not healing
    return if dam <= 0
    # Remember this actor's last damage taken, override last value
    @hp_damage_last = dam
    # Add to the cumulative turn damage here
    @hp_damage_turn += dam
    # And add to the battle cumulative damage here
    @hp_damage_battle += dam
  end
end
 
class Game_Actor < Game_Battler

  alias :execute_damage_remember_damage_actor :execute_damage unless $@
  def execute_damage(user)
    # Call the original method so hp damage is applied correctly
    dam = @result.hp_damage
    execute_damage_remember_damage_actor(user)
    # We want to record damage only, not healing
    return if dam <= 0
    # We want to remember the damage taken in variables too, do so here
    index = @actor_id + ActorDamageIDStart
    # Remember this actor's last damage taken, override last value
    $game_variables[index] = @hp_damage_last
    # Add to the cumulative turn damage here
    $game_variables[index + 10] = @hp_damage_turn
    # And add to the battle cumulative damage here
    $game_variables[index + 20] = @hp_damage_battle
  end
 
end

class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------
  # * Battle Start
  #--------------------------------------------------------------------------
  alias :battle_start_remember_damage :battle_start unless $@
  def battle_start
    # Call the original method
    battle_start_remember_damage
    # And wipe everybody's battle-scope damage
    $game_party.members.each { |member| member.hp_damage_battle = 0 }
    $game_troop.members.each { |member| member.hp_damage_battle = 0 }
  end
  #--------------------------------------------------------------------------
  # * Start Turn
  #--------------------------------------------------------------------------
  alias :turn_start_remember_damage :turn_start unless $@
  def turn_start
    # Call the original method
    turn_start_remember_damage
    # And wipe everybody's turn-scope damage
    $game_party.members.each { |member| member.hp_damage_turn = 0 }
    $game_troop.members.each { |member| member.hp_damage_turn = 0 }
  end
end
Wow! It's working perfect now! :0
You're my hero man! Thank you very much!
 

Latest Threads

Latest Posts

Latest Profile Posts

I just got all of my wisdom teeth out today, thankfully I have the rest of the week off.
Man I am learning I am bad at naming armor lmao.
The game's opening, now fully polished! :LZScheeze:





Aaand, here's me working on it in today's "Game Making Every Day" video! :LZSooo:

Hello! Can anyone help me? I followed making cooking tutorial for RPG Maker MV. But for some reason buff state that food gives doesn't work in overworld. It disappears. What am I supposed to do?
A shotgun is not a rifle. Huh.

Forum statistics

Threads
124,403
Messages
1,163,366
Members
163,201
Latest member
YoBa
Top