Different Difficulties problem

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
110
Reaction score
2
First Language
English
Primarily Uses
RMXP
i have this script called Different Difficulties for Tons of Add-ons
Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Different Difficulties by Blizzard
# Version: 1.3b
# Date: 24.3.2007
# Date v1.1b: 27.3.2008
# Date v1.2b: 18.4.2008
# Date v1.3b: 22.4.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Instructions:
#
#   You can always check the current difficulty of the game by using
#   
#     $game_system.difficulty_name == 'NAME'
#   
#   in your conditional branch. The NAMEs are the same as you specify in the
#   configuration below.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

if TONS_OF_ADDONS::DIFFICULTY

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Congfiguration
#
# Use the following template to create difficulties in your game
# ['NAME', EXP_RATE, GOLD_RATE, ACTOR_DAMAGE_RATE, ENEMY_DAMAGE_RATE]
# Note that all the "rates" are in %. Values over 100 will increase, values
# under 100 will decrease the given attribute. Of course you can add/remove
# any difficulties you want, be sure to separate them with commas.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

DIFFICULTIES = [['Peaceful', 250, 250, 200, 50],
                ['Easy', 150, 150, 160, 75],
                ['Normal', 100, 100, 100, 100],
                ['Hard', 80, 80, 80, 160],
                ['Hardcore', 50, 50, 50, 200]]

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Congfiguration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_reader :difficulty_name
  attr_reader :exp_rate
  attr_reader :gold_rate
  attr_reader :actor_rate
  attr_reader :enemy_rate
 
  def init_difficulty(index)
    @difficulty_name, @exp_rate, @gold_rate, @actor_rate, @enemy_rate =
        DIFFICULTIES[index]
  end
 
end

#==============================================================================
# Window_BattleResult
#==============================================================================

class Window_BattleResult
 
  attr_accessor :gold
  attr_accessor :exp
 
end

#==============================================================================
# Window_BattleStatus
#==============================================================================

class Window_BattleStatus
 
  attr_accessor :level_up_flags
 
end

#==============================================================================
# Game_Battler
#==============================================================================

class Game_Battler
 
  alias attack_effect_difficulty_later attack_effect
  def attack_effect(attacker)
    last_sr = self.sr if $crls && self.is_a?(Game_Actor)
    last_hp = self.hp
    result = attack_effect_difficulty_later(attacker)
    if result && self.damage.is_a?(Numeric)
      self.hp = last_hp
      self.hp = self.hp
      if attacker.is_a?(Game_Actor)
        self.sr = last_sr if $crls && self.is_a?(Game_Actor)
        self.damage = self.damage * $game_system.actor_rate / 100
      elsif attacker.is_a?(Game_Enemy)
        self.damage = self.damage * $game_system.enemy_rate / 100
      end
      self.hp -= self.damage
    end
    return result
  end
 
  alias skill_effect_difficulty_later skill_effect
  def skill_effect(user, skill)
    last_sr = self.sr if $crls && self.is_a?(Game_Actor)
    last_hp = self.hp
    result = skill_effect_difficulty_later(user, skill)
    if result && self.damage.is_a?(Numeric)
      self.hp = last_hp
      self.hp = self.hp
      if user.is_a?(Game_Actor)
        self.damage = self.damage * $game_system.actor_rate / 100
        self.sr = last_sr if $crls
      elsif user.is_a?(Game_Enemy)
        self.damage = self.damage * $game_system.enemy_rate / 100
      end
      self.hp -= self.damage
    end
    return result
  end
 
end
 
#==============================================================================
# Scene_Title
#==============================================================================

class Scene_Title
 
  alias main_difficulties_later main
  def main
    main_difficulties_later
    @difficulty_window.dispose if @difficulty_window != nil
  end
 
  alias command_new_game_difficulties_later command_new_game
  def command_new_game
    $game_system.se_play($data_system.decision_se)
    d = []
    DIFFICULTIES.each {|diff| d.push(diff[0])}
    @difficulty_window = Window_Command.new(@command_window.width, d)
    @difficulty_window.x = @command_window.x
    @difficulty_window.y = @command_window.y -
        (@difficulty_window.height - @command_window.height) / 2
    @difficulty_window.back_opacity = @command_window.back_opacity
    @command_window.active = @command_window.visible = false
  end
 
  alias upd_difficulties_later update
  def update
    if @difficulty_window == nil
      upd_difficulties_later
      return
    end
    @difficulty_window.update unless defined?(SDK)
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = @command_window.visible = true
      @difficulty_window.dispose
      @difficulty_window = nil
    elsif Input.trigger?(Input::C)
      command_new_game_difficulties_later
      $game_system.init_difficulty(@difficulty_window.index)
    end
  end
 
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle
 
  alias start_phase5_difficulty_later start_phase5
  def start_phase5
    old_gold, old_exp, old_levels = $game_party.gold, [], []
    $game_party.actors.each {|actor|
        old_exp.push(actor.exp)
        old_levels.push(actor.level)}
    start_phase5_difficulty_later
    new_gold = $game_party.gold - old_gold
    $game_party.lose_gold(new_gold)
    @result_window.gold = new_gold * $game_system.gold_rate / 100
    $game_party.gain_gold(@result_window.gold)
    new_exp = 0
    $game_party.actors.each_index {|i|
        if $game_party.actors[i].exp - old_exp[i] > 0
          new_exp = $game_party.actors[i].exp - old_exp[i]
        end
        $game_party.actors[i].exp = old_exp[i]}
    @result_window.exp = new_exp * $game_system.exp_rate / 100
    @result_window.refresh
    $game_party.actors.each_index {|i|
        @status_window.level_up_flags[i] = false
        unless $game_party.actors[i].cant_get_exp?
          $game_party.actors[i].exp += @result_window.exp
          @status_window.level_up(i) if $game_party.actors[i].level > old_levels[i]
        end}
  end
 
end

end
but it errors at line 98
vvvvvvvv
Code:
self.damage = self.damage * $game_system.actor_rate / 100
do you have any ideas how to fix it?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,439
Reaction score
6,255
First Language
Indonesian
Primarily Uses
RMVXA
I don't do RMXP but if you could at least tell the error message (preferable with a screenshot), it probably easier to figure it out why.
 

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
110
Reaction score
2
First Language
English
Primarily Uses
RMXP
i think here is the difference
Peaceful [AKA n00b as default name]
1591245788804.png

and here is Normal
1591246113943.png

this is an example
 

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
110
Reaction score
2
First Language
English
Primarily Uses
RMXP
@TheoAllen when i enter Battle Test mode
1591246220561.png

and try to attack
1591246287956.png

it errors like this
1591246334456.png

any idea on how to fix it?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,439
Reaction score
6,255
First Language
Indonesian
Primarily Uses
RMVXA
Oh, I see the problem now.
The difficulty setting is not properly initialized.
Everything is set when you start a new game from the title screen. So if you go straight to the battle test, the game doesn't know what kind of difficulty you have.
In my opinion, this isn't a good design for a published script.

Try to put this patch below the script. It will set the default the default setting for the difficulty.
Code:
class Game_System
  alias system_init initialize
  def initialize
    system_init
    init_difficulty(0) # <-- change the difficulty here
  end
end
Go change 0 to the index of the difficulty setting. For example, the default setting has these
Code:
DIFFICULTIES = [['Peaceful', 250, 250, 200, 50],
                ['Easy', 150, 150, 160, 75],
                ['Normal', 100, 100, 100, 100],
                ['Hard', 80, 80, 80, 160],
                ['Hardcore', 50, 50, 50, 200]]
If you put 0, it means it will use 'Peaceful' difficulty setting.
If you put 4, it will use 'Hardcore' difficulty setting.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.
is there a script call that return how much turn has passed in battle?
Does anyone find this hard to read?

Enjoying my weekend at home to stay Covid free. How is everyone else doing?

Forum statistics

Threads
100,603
Messages
977,740
Members
132,216
Latest member
Darkscythe25
Top