Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Editing GTBS and Blizzards difficulty script

Untra

Sponsor

At the moment I'm trying to mod the fuck out of a bunch of gubids and blizzards scripts. As a result, Ive come across a few problems where me and my ameteur ability to script have run into problems.


Secondly, I'm editing blizzards Difficulty system to make it so the difficulties are interchangeable through the menu.
Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# Different Difficulties by Blizzard

# Version: 1.1b

# Date: 24.3.2007

# Date: 27.3.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.

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

 

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# 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 = [['Pussy', 70, 50, 120, 70],

                ['Easier', 85, 90, 110, 85],

                ['Normal', 100, 100, 100, 100],

                ['Harder', 115, 110, 90, 115],

                ['Brutal', 130, 150, 80, 130]]

 

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# 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)

    unless TONS_OF_ADDONS::DIFFICULTY

      return attack_effect_difficulty_later(attacker)

    end

    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)

    unless TONS_OF_ADDONS::DIFFICULTY

      return skill_effect_difficulty_later(user, skill)

    end

    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_Diff

#==============================================================================

 

class Scene_Diff

  

  def main

    $game_system.se_play($data_system.decision_se)

    d = []

    DIFFICULTIES.each {|diff| d.push(diff[0])}

    @difficulty_window = Window_Command.new(192, d)

    @difficulty_window.x = 320

    @difficulty_window.y = 280 -

        (@difficulty_window.height - 280) / 2

    @difficulty_window.back_opacity = 160

  end

  def update

    if @difficulty_window == nil

    else

      @difficulty_window.update

      if Input.trigger?(Input::B)

        $game_system.se_play($data_system.cancel_se)

        @difficulty_window.dispose

        @difficulty_window = nil

      elsif Input.trigger?(Input::C)

        $game_system.init_difficulty(@difficulty_window.index)

      end

    end

  end

  

end

 

#==============================================================================

# Scene_Battle

#==============================================================================

 

class Scene_Battle

  

  alias start_phase5_difficulty_later start_phase5

  def start_phase5

    unless TONS_OF_ADDONS::DIFFICULTY

      start_phase5_difficulty_later

      return

    end

    old_gold, old_exp = $game_party.gold, []

    $game_party.actors.each {|actor| old_exp.push(actor.exp)}

    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|

        new_exp = $game_party.actors[i].exp - old_exp[i]

        $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?

          last_level = $game_party.actors[i].level

          $game_party.actors[i].exp += @result_window.exp

          @status_window.level_up(i) if $game_party.actors[i].level > last_level

        end}

  end

  

end
Look for Scene_Diff on line 30. Whenever I call Scene_Diff, the script gets depressed and hangs itself. I can't figure out why and its driving me nuts. Thoughts?
 
For your first question, just telling by the code because I don't get your description at all there, it should be pretty simple to fix. What you have is
Code:
def self.move_range(actor_int)
Meaning you call a method named 'move_range' and want to pass a value with that (hence the brackets). Now here seems to be what you got wrong, because you're using 'actor_int' here as instance name. As soon as you do that, that means whatever other scripts call that method as argument within the brackets, it's now named 'actor_int' (just for that method, though - it won't overwrite the original variable).
In other words: You probably call it somewhat like this:
Code:
GTBS.move_range(@actor.int)
In the method itself, you pass it as 'actor_int' though, which means you have to either rename 'actor_int' in the definition line to 'int' to match your content's expression, or vice versa: Change the 'case int' to 'case actor_int'. Either way doesn't matter because it's just a method-internal handler and won't affect anything outside, but I personally like the shorter version better because I'm sure it calculates the enemies' ranges as well and therefore, actor_int would be misleading.
On a side note, Gubid's TBS isn't exactly nicely scripted and has some heavy formatting issues, so it's probably not a script a beginner should start learning to script here...
 

Untra

Sponsor

That did the trick for the first one! thanks!

And yeah, Ive noticed; GTBS is incredibly poorly scripted and navigating the entire system is like going through a rat maze. But it works so well, and so far Ive trimmed 20% of the 'fat' all throughout it. When it comes to doing its job, his script gets it done. But if you want to customize it, then you're up shit creek.
 
I hate to break it to you, but that Scene_Diff is never going to work the way you coded it. Here is a template for creating scenes:

[rgss] 
class Scene_Whatever
  def initialize(arg) # only needed if your scene uses arguments
    @arg = arg # This is where you store your arguments in variables
  end
  def main
    # This is where you make your windows and sprites and stuff
    Graphics.transition # Transitions the graphics
    loop do
      Graphics.update # Update the graphics *needed*
      Input.update # Updates button presses *needed*
      update # calls your frame update method
      break if $scene != self # disposes scene if it is changed
    end
    # This is where you dispose your windows and sprites
  end
  def update
    # put all your update stuff in here.
    if Input.trigger?(Input::A) # example
      p @arg
    end
  end
end
 
[/rgss]

There's a basic template, try using that to code your scene.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top