Saving cumulative damage done?

Hi, all. At the end of the game, I'd like to show the player all the damage they've inflicted throughout the course of the game. Is there any way to do this?

Additionally, I'd like to be able to show how many turns the player has taken, as well.
some of the data is automatically collected and available through the control variable command, but especially total damage is not.

You can try to store that data by using code in the damage formula, but the number calculated in the damage formula gets modified by both elemental rates and phyisical/magical damage rates.
For true values, that would either require complex mathematics inside the damage formula or a script written to store that info during battle.
Tracking total damage requires scripting. Probably the best place to look to make these changes is execute_damage inside Game_Battler:

Code:
  #--------------------------------------------------------------------------
  # * Damage Processing
  #    @result.hp_damage @result.mp_damage @result.hp_drain
  #    @result.mp_drain must be set before call.
  #--------------------------------------------------------------------------
  def execute_damage(user)
    on_damage(@result.hp_damage) if @result.hp_damage > 0
    self.hp -= @result.hp_damage
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain
  end

You can check that the user is an Actor, and if so add to a variable which is reserved to track total damage. Note that to track things like slip damage (e.g. Poison) you will need some extra scripting in other places, but this should cover almost all instances of direct damage and track it accurately.

To track total turns, I believe that similar changes can be made in increase_turn in Game_Troop (increase a reserved variable by 1 each time this method triggers):

Code:
  #--------------------------------------------------------------------------
  # * Increase Turns
  #--------------------------------------------------------------------------
  def increase_turn
    troop.pages.each {|page| @event_flags[page] = false if page.span == 1 }
    @turn_count += 1
  end
Here.

Code:
module RINOBI module BattleData # DO NOT MODIFY
#==============================================================================
# # BATTLE DATA
# -----------------------------------------------------------------------------
# 1.0 [02/09/2017] Completed
#-
# Only records total damage and turns for now, I may expand it later.
#
#==============================================================================
# # SETTINGS
# -----------------------------------------------------------------------------
# Adjust the below to your liking.
#-

  #------------------------
  # >> Variable IDs
  #------------------------
  TOTAL_DAMAGE  =   101   # Total amount of damage dealt by party members.
  TOTAL_TURNS   =   102   # Total number of turns passed during battle.
 
#==============================================================================
# # TERMS OF USE
#------------------------------------------------------------------------------
# 1. Preserve this header.
# 2. Do not re-upload this script.
# 3. Do not claim this script as your own work.
# 4. Do not release modified versions of this script.
# 5. Free for commercial RPG Maker VX Ace projects.
#==============================================================================
end end # DO NOT MODIFY

$imported = {} if $imported.nil?
$imported[:RIN_BattleData] = true

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Alias Method: Calculate Damage
  #--------------------------------------------------------------------------
  alias :rin_battledata_make_damage_value :make_damage_value
  def make_damage_value(user, item)
    rin_battledata_make_damage_value(user, item)
    return unless @result.hp_damage > 0
    return unless user.is_a?(Game_Actor)
    $game_variables[RINOBI::BattleData::TOTAL_DAMAGE] += @result.hp_damage
  end
end

#==============================================================================
# ** Game_Troop
#------------------------------------------------------------------------------
#  This class handles enemy groups and battle-related data. Also performs
# battle events. The instance of this class is referenced by $game_troop.
#==============================================================================
class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # * Alias Method: Increase Turns
  #--------------------------------------------------------------------------
  alias :rin_battledata_increase_turn :increase_turn
  def increase_turn
    rin_battledata_increase_turn
    $game_variables[RINOBI::BattleData::TOTAL_TURNS] += 1
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/saving-cumulative-damage-done.74679/