Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
116
Reaction score
40
First Language
English
Primarily Uses
RMVXA
Hellu~
I'm using a very old script (2014) I found in google, I don't think the original creator is still online to ask it.
This script store the damage you take in a variable, now, the problem is that I don't get to understand in which variable is storing it:

Code:
   ActorDamageIDStart = 1
  
       # We want to remember the damage taken in variables too, do so here
    index = (@actor_id - 1) * 3 + 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 + 1] = @hp_damage_turn
    # And add to the battle cumulative damage here
    $game_variables[index + 2] = @hp_damage_battle

Let's say my actor ID is 22, so (and I don't understand why to use this equation), so (22 - 1) * 3 + 1 (because actordamageidstart is 1) would be equal to V64, but that variable is always 0.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,926
Reaction score
10,512
First Language
German
Primarily Uses
RMMV
1) how exactly do you use the script?
2) how do you check if variable 64 is zero?
3) can you give a link to the full script? Because what you have above is not the full script.
 

Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
116
Reaction score
40
First Language
English
Primarily Uses
RMVXA
1) how exactly do you use the script?
2) how do you check if variable 64 is zero?
3) can you give a link to the full script? Because what you have above is not the full script.
1) I'm using an state with the Yanfly Lunatic State script. When I'm hit and the state is erased, I get an script call that give me a text with the corresponding variable.
2) With that text in the common event. I tried differents variables too.
3) Sure! Sorry for not doing it before, I didn't wanted to make a long post:

Code:
ActorDamageIDStart = 1

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 - 1) * 3 + 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 + 1] = @hp_damage_turn
    # And add to the battle cumulative damage here
    $game_variables[index + 2] = @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
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
3,020
Reaction score
2,102
First Language
Spanish
Primarily Uses
RMVXA
do a broad search in the editor (ctrl-shift-F by default) for any occurrence of $game_variables[ (with the bracket!), and filter visually by those that = 0.
if you come up with ambiguous or unclear results, post them here.
if you come up with no occurrences of =0 that encompass variable 64, there must be a common event resetting it.
you'll have to go through common events manually, although there is a formula for grabbing all instructions within common events, but I don't remember it ATM.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,926
Reaction score
10,512
First Language
German
Primarily Uses
RMMV
@Mattsuharu
1&2: I asked for exact answer because I wanted details that your short descriptions didn't give.
please give screenshots of the state and the entire event

3: I asked for a link to the website that contains the script, not for the script itself.
that has two different reasons:
a) a lot of scripters forbid reposting of their scripts for a lot of reasons, and here we try to honor their wishes - they did the work after all.
b) often the website contains additional descriptions, manuals or help for the script
 

Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
116
Reaction score
40
First Language
English
Primarily Uses
RMVXA
@Mattsuharu
1&2: I asked for exact answer because I wanted details that your short descriptions didn't give.
please give screenshots of the state and the entire event

3: I asked for a link to the website that contains the script, not for the script itself.
that has two different reasons:
a) a lot of scripters forbid reposting of their scripts for a lot of reasons, and here we try to honor their wishes - they did the work after all.
b) often the website contains additional descriptions, manuals or help for the script
Oh sorry, my bad.

1653685552625.png
This is the State, as you see, with the Lunatic State I call a common event the state is erased, in this case, when damage is inflicted.

1653685680403.png
Now the common event simply show my a text with the value of Variable 64. This is to check if the value changed with the damage I received.

This is where I find the script. It wasn't a proper script release post, it was some one else asking for what I wanted to achiev, and some one made a script for them. There's also a demo, but the demo only show you how to use the script with damage formulas, not variables and how they store.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,926
Reaction score
10,512
First Language
German
Primarily Uses
RMMV
First, I suggest you do not use the state construct for the display. There are too many things that could have gone wrong with that.

instead, make a troop event run once each turn and display variable 65 there (turn damage instead of last damage) and 66 (battle damage) to check if the scripts work at all.

If that still gives zero as a result, then we need to check how and where you installed the script, and how you start the battle (don't use battletest, it needs to be ingame with an event)
 

Mattsuharu

Veteran
Veteran
Joined
Apr 15, 2022
Messages
116
Reaction score
40
First Language
English
Primarily Uses
RMVXA
First, I suggest you do not use the state construct for the display. There are too many things that could have gone wrong with that.

instead, make a troop event run once each turn and display variable 65 there (turn damage instead of last damage) and 66 (battle damage) to check if the scripts work at all.

If that still gives zero as a result, then we need to check how and where you installed the script, and how you start the battle (don't use battletest, it needs to be ingame with an event)
Well, I checked again the demo the scripter leaves and after the battle I opened the Switch and Variable test with F9 to check which variables changed. This script affects variable 1, 2 and 3.
Then I tried the same in my project and all variables stayed the same, which mean that some other script must be reseting any variable that this script touch. Gonna check out if changing the order in the script editor fix it.

EDIT: Okay, the order it did fix it somehow... But now for some reason the pop-ups of damage always show a 0 xD
Scripts... gotta love it.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,926
Reaction score
10,512
First Language
German
Primarily Uses
RMMV
which mean that some other script must be reseting any variable that this script touch.
yes and no

the problem is that this script has a very limited way to configure the variables used.
most scripts only use directly assigned variable IDs, and those go by default in the lower numbers.

this script however only gives a start number and then goes up to your maximum actor number without any care or crosscheck how many actors you really have.
That is a very bad way to configure things, and it means that you have to know how many actors you will have from the very beginning, because you will need variables for other things, and you cannot reserve those variables without knowing the maximum number used by this script.

and that is only made more problematic by the rather high number of actors your ID=22 indicates...

get your numbers correct, decide on how many actors you really need and then reserve a proper range for them, redirecting all other script variables to outside that range.
 

Latest Threads

Latest Posts

Latest Profile Posts

I'm really sorry I haven't done any streams. I actually just got home from the hospital after a week and a half.
I'm not dead - I promise :stickytongue:

Anyway, some pokemon inspired art (dont ask me which one tho xD)
reali.png
Writing boss music for Pale Coins. This is the Goblin Mage's theme!

Caz
I've been trying to upload more video tutorials for RMMZ lately! Does anyone have a topic they'd like to see covered? :ehappy:

Forum statistics

Threads
129,716
Messages
1,204,587
Members
170,790
Latest member
ess_
Top