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.

Difficulty effects v2

This script gives a complete control of the game challengue, not only with a
initial decision. Now it also let you create a menu in scene title to
select the difficulty to use.

menudiff.png


Code:
#==============================================================================

# Difficulty effects

# By gerkrt/gerrtunk, Dargor(used his difficulty script for scene title 

# modification)

# Version: 2

# License: GPL, credits

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

 

=begin

 

This script gives a complete control of the game challengue, not only with a

initial decision. Now it also let you create a menu in scene title to

select the difficulty to use.

 

Features:

 

-You can create all the difficulty effects you want and active and desactive

at your will. Each effect can changue some nemy atributes based in %.

The effects are accumulative and saved when quit the game.

 

4 ways of choosing what enemies are using the effects:

 

-By enemies ids

-By maps ids

-Using the map tree system. You only have to write the name of the parent map

and all the others are included in rhe effect.

-Global

 

-All the atributes are optional.

 

-You can use the value in a event variable to control all the values of a effect

in real time.

 

-HP, SP, ATK, PDEF, PMAG, EVS, STR, DEX, AGI, INT, EXPERIENCIE, GOLD and DROP

 

-You can optionally create a menu in the scene title with each number of difficulty

options, names,  descriptions, switch and difficulty effects that they active.

 

-Vocabulary control

 

############ Values and sintaxis #########

 

Enemies atributes are calculated in %. Each atribute you add to a effect to

modify starts wuth a value of 100% and then you can sum or rest to it.

 

Example:

      Difficulty_effects[5] = {  

    :active  => false,            

    :type  => 3,                  

    :base_map_name  => 'Forest',  

    :hp => 50,                    

    :sp =>-30            

    }

 

This makes that the hp is 150 and sp 70.

 

:x => value of x,

 

You must respect :  before x name, the => separating them and the final ,

 

-Each new effect must have a new and unique number ID in Difficulty_effects[ID]

-Dont touch the {}. They mean start and end and have to be in that positions.

-You can add or remove any values, just use the same sintaxis.

-The last value dont use the  final ,

 

 

############ Option types #########

 

 

Obligatory:

 

active: If you give this a true value the script will start actived.

 

type: Define how is going to know the script wich enemies affect.

Values:

  1.By enemies ids

  2.By maps ids

  3.By map tree

  4.Global

 

enemies_ids: Obligatory when type is 1. Define wich enemies are affected.

  :enemies_ids => [1,2,3]

 

maps_ids: Obligatory when type is 2. Define wich maps are affected.

  :maps_ids => [1,2,3]

 

base_map_name: Obligatory when type is 3. Define the parent map name.

 

Optionals:

 

variable: Makes that all values of the effect depend of that event variable value.

value*event_variable/100

 

hp  

sp  

 

atk  

pdef  

mdef

evs  

 

str   STRENGTH

dex   DEXTERITY

agi   AGILITY

int   INTELIGENCE

 

exp   EXPERIENCIE

gold  MONEY

drop  % OF ITEMS

 

Note that you can erase the example effects.

 

############ Select wich enemies will use the effect #########

 

 

-Global. All combats

 

-By enemies: Only the enemies that you add to the list.

 

-By maps: All combats in the maps that you add to the list.

 

-By map tree: With this you only have to define a parent map and write its name in

the effect. All the maps and combats under it will have the effect.

 

The map tree is show under the tileset tool. If you doubleclick to - or + you will

see that the maps are shown in groups that depend in parent maps.

 

Note: I recomend having the maps having the maps ordered and directly relationed with

its parent map to have optimal performance.

 

Use example:

 

Mapamundi

  Forest

    Mapa3

    Mapa4

    Mapa5

      Mapa6

      Mapa7

     

  Pantano del Wep

    Mapa9

   

Ex:

   

      Difficulty_effects[2] = {

    :active  => false,

    :hp => 50,

    :sp => 30,

    :atk   => 20,

    :spi   => 20,

    :agi   => 10,

    :drop  => -20,

    :variable  => 6,

    :type  => 3,

    :base_map_name  => 'Forest'

  }

 

 

Maps 3,4,5,6,7, and Forest have that effect.

 

 

############ Activating effects #########

 

Activate: start_difficulty_effect(effect number)

 

Desactivate: stop_difficulty_effect(effect number)

 

Ex: start_difficulty_effect(1)

 

########### Difficulties menu ##########

 

I have comented in the module itself what is what. Anyway, the main thing 

is to define what number of difficluties, etc, want to use, and then, create

a entry in the same order and position for each one, so:

 

  # For each difficulty, his command name

  Names = [

            'Loser',   # 1

            'Medium',  # 2

            'Hard', # 3

            'Game Master' # 4

          ]

          

  # For each difficulty, his description 

  Descriptions = [

                  'Only a loser take this mode.', # 1

                  'Medium difficulty, standard way', # 2

                  'You rules!', # 3

                  'Killing a slime in this mode is a miracle'   # 4

                ]

 

Each time the first named loser have the 1  name, the 1 description, etc

 

############ Last notes #########

 

-All the effects to an enemy are sumed and then applied.

 

-You can create large number groups with this:

 

  :enemies_ids => (1..25).to_a

 

  This is like putting the enemies ids 1-25

 

-Creditss: this script have been created studying  KGC

BattleDifficuly

 

 

=end

 

 

module Wep

  # Dont touch this

  Difficulty_effects = []

 

 

  Difficulty_effects[1] = {

    :active  => false,

    :hp => 50,

    :mp => 30,

    :atk   => 20,

    :agi   => 10,

    :drop  => 20,

    :variable  => 4,

    :type  => 1,

    :enemies_ids  => [2,3]

  }

    Difficulty_effects[2] = {

    :active  => false,

    :hp => 50,

    :mp =>30,

    :atk   => 20,

    :agi   => 10,

    :drop  => 20,

    :gold => 20,

    :exp => 20,

    :variable  => 5,

    :type  => 2,

    :maps_ids  => [1,2,3,4,6,7]

  }

      Difficulty_effects[3] = {

    :active  => false,

    :hp => 50,

    :mp => 30,

    :atk   => 20,

    :dex   => 20,

    :agi   => 10,

    :drop  => -20,

    :variable  => 6,

    :type  => 3,

    :base_map_name  => 'Forest'

  }

        Difficulty_effects[4] = {

    :active  => false,

    :hp => 50,

    :mp => 30,

    :atk   => 20,

    :agi   => 10,

    :drop  => -20,

    :variable  => 6,

    :type  => 4

  }

  

  # Desactive this, = false, if you dont want to modify the scene title and only

  # wanto to use the geneal difficulty effects

  Diff_modify_scene_title = true

end

 

 

 

# The configuration of the title modification.

module Difficulty

  # Default difficulty used in the list

  Default = 1 # medium

  

  # For each difficulty, his command name

  Names = [

            'Loser',

            'Medium',

            'Hard',

            'Game Master'

          ]

          

  # For each difficulty, his description 

  Descriptions = [

                  'Only a loser take this mode.',

                  'Medium difficulty, standard way',

                  'You rules!',

                  'Killing a slime in this mode is a miracle'

                ]

                

  # For each difficulty, the game switch they active 

  Switches = [

    2,

    3,

    4,

    5

    

  ]

  

  # For each difficulty, the difficulty effect they active

  Effects = [

    1,

    2,

    3,

    4

    

  ]

  

  # Vicabulary words used in default menu

  Diff_new_game_word = 'New'

  Diff_load_game_word = 'Load'

  Diff_exit_game_word = 'Exit'

end

 

class Game_System

  attr_accessor :difficulty_effects

  alias gs_wep_cc_init initialize

  def initialize

    @difficulty_effects = Wep::Difficulty_effects

    gs_wep_cc_init

  end

 

end

 

class Interpreter

 

  def start_difficulty_effect(num)

     $game_system.difficulty_effects[num][:active] = true

  end

 

  def stop_difficulty_effect(num)

     $game_system.difficulty_effects[num][:active] = false

  end

 

end  

 

class Game_Party

  def tree_includes_map? (name)

    # Load mapinfos for map name

    mapinfos = load_data("Data/MapInfos.rxdata")    

    # If his name is the name searched

    if mapinfos[$game_map.map_id].name == name

        return true

    end

 

    map = $game_map.map_id

   

    # Iterate all parents maps

    while mapinfos[map].parent_id != 0

        if mapinfos[mapinfos[map].parent_id].name == name

          return true

        else

          map = mapinfos[map].parent_id

        end

    end

  end

end

 

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

# ¦ Game_Enemy

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

 

class Game_Enemy < Game_Battler

  #--------------------------------------------------------------------------

  # ? MaxHP

  #--------------------------------------------------------------------------

  alias base_maxhp_Challengue_Compensator base_maxhp

  def base_maxhp

    # Gets normal atribute

    n = base_maxhp_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:hp] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:hp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:hp]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:hp] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:hp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:hp]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:hp] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:hp]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:hp]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:hp] != nil

           if effect[:variable] != nil

             total+=effect[:hp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:hp]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? MaxSP

  #--------------------------------------------------------------------------

  alias base_maxsp_Challengue_Compensator base_maxsp

  def base_maxsp

    # Gets normal atribute

    n = base_maxsp_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:sp] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:sp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:sp]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:sp] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:sp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:sp]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:sp] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:sp]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:sp]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:sp] != nil

           if effect[:variable] != nil

             total+=effect[:sp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:sp]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxstr

  #--------------------------------------------------------------------------

  alias base_str_Challengue_Compensator base_str

  def base_str

    # Gets normal atribute

    n = base_str_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:str] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:str]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:str]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:str] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:str]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:str]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:str] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:str]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:str]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:str] != nil

           if effect[:variable] != nil

             total+=effect[:str]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:str]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxdex

  #--------------------------------------------------------------------------

  alias base_dex_Challengue_Compensator base_dex

  def base_dex

    # Gets normal atribute

    n = base_dex_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:dex] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:dex]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:dex]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:dex] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:dex]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:dex]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:dex] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:dex]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:dex]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:dex] != nil

           if effect[:variable] != nil

             total+=effect[:dex]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:dex]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxagi

  #--------------------------------------------------------------------------

  alias base_agi_Challengue_Compensator base_agi

  def base_agi

    # Gets normal atribute

    n = base_agi_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:agi] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:agi]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:agi]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:agi] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:agi]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:agi]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:agi] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:agi]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:agi]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:agi] != nil

           if effect[:variable] != nil

             total+=effect[:agi]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:agi]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxint

  #--------------------------------------------------------------------------

  alias base_int_Challengue_Compensator base_int

  def base_int

    # Gets normal atribute

    n = base_int_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:int] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:int]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:int]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:int] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:int]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:int]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:int] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:int]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:int]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:int] != nil

           if effect[:variable] != nil

             total+=effect[:int]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:int]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxatk

  #--------------------------------------------------------------------------

  alias base_atk_Challengue_Compensator base_atk

  def base_atk

    # Gets normal atribute

    n = base_atk_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:atk] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:atk]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:atk]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:atk] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:atk]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:atk]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:atk] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:atk]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:atk]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:atk] != nil

           if effect[:variable] != nil

             total+=effect[:atk]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:atk]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxpdef

  #--------------------------------------------------------------------------

  alias base_pdef_Challengue_Compensator base_pdef

  def base_pdef

    # Gets normal atribute

    n = base_pdef_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:pdef] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:pdef]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:pdef]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:pdef] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:pdef]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:pdef]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:pdef] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:pdef]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:pdef]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:pdef] != nil

           if effect[:variable] != nil

             total+=effect[:pdef]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:pdef]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxmdef

  #--------------------------------------------------------------------------

  alias base_mdef_Challengue_Compensator base_mdef

  def base_mdef

    # Gets normal atribute

    n = base_mdef_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:mdef] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:mdef]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:mdef]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:mdef] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:mdef]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:mdef]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:mdef] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:mdef]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:mdef]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:mdef] != nil

           if effect[:variable] != nil

             total+=effect[:mdef]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:mdef]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxeva

  #--------------------------------------------------------------------------

  alias base_eva_Challengue_Compensator base_eva

  def base_eva

    # Gets normal atribute

    n = base_eva_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:eva] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:eva]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:eva]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:eva] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:eva]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:eva]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:eva] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:eva]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:eva]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:eva] != nil

           if effect[:variable] != nil

             total+=effect[:eva]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:eva]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxexp

  #--------------------------------------------------------------------------

  alias exp_Challengue_Compensator exp

  def exp

    # Gets normal atribute

    n = exp_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:exp] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:exp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:exp]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:exp] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:exp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:exp]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:exp] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:exp]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:exp]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:exp] != nil

           if effect[:variable] != nil

             total+=effect[:exp]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:exp]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxgold

  #--------------------------------------------------------------------------

  alias gold_Challengue_Compensator gold

  def gold

    # Gets normal atribute

    n = gold_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:gold] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:gold]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:gold]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:gold] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:gold]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:gold]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:gold] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:gold]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:gold]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:gold] != nil

           if effect[:variable] != nil

             total+=effect[:gold]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:gold]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

 

  #--------------------------------------------------------------------------

  # ? Maxdrop

  #--------------------------------------------------------------------------

  alias treasure_prob_Challengue_Compensator treasure_prob

  def treasure_prob

    # Gets normal atribute

    n = treasure_prob_Challengue_Compensator

    # Sets total to a base 100%

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[:drop] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[:drop]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:drop]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[:drop] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[:drop]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:drop]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[:drop] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[:drop]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[:drop]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[:drop] != nil

           if effect[:variable] != nil

             total+=effect[:drop]*$game_variables[effect[:variable]]/100

           else

             total+=effect[:drop]

           end

         end

    end

    n = n * total / 100  

    return n.to_i

  end

end

 

 

 

 

 

 

 

 

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

# ** Difficulties

#------------------------------------------------------------------------------

#  © Dargor, 2008

#  Ported to Xp and Modified by gerkrt to use difficulty effects script

#  24/06/08

#  Version 1.1

#  Pedido do van hellblaze

#  Tradução para português: Rafidelis

#  www.ReinoRpg.com

#------------------------------------------------------------------------------

#  HISTORICO DAS VERSÕES

#   - 1.0 (24/06/08), Versão inicial

#   - 1.1 (24/06/08),Adicionada EXP e Gold modificações

#------------------------------------------------------------------------------

#  INSTRUÇÕES:

#   - Cole Acima do Main

#   - Edit as constates no modulo de Dificuldade 

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

 

 

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

# ** Game_System

#------------------------------------------------------------------------------

# Esta classe manipula dados relacionados com o sistema.Também gerencia veículos e BGM, etc

# A instância desta classe é referenciado por $ game_system.

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

 

class Game_System

  #--------------------------------------------------------------------------

  # * Variaveis de Instacia Publica

  #--------------------------------------------------------------------------

  attr_accessor :difficulty_id

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_difficulty_system_initialize initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    dargor_vx_difficulty_system_initialize

    @difficulty_id = Difficulty::Default

  end

  #--------------------------------------------------------------------------

  # * Get Difficulty

  #--------------------------------------------------------------------------

  def difficulty

    return Difficulty::Modifiers[@difficulty_id]

  end

end

 

 

if Wep::Diff_modify_scene_title

  

 

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

# ** Scene_Title

#------------------------------------------------------------------------------

# Esta classe realiza a tranformação da tela de título.

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

 

class Scene_Title 

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # If battle test

    if $BTEST

      battle_test

      return

    end

    # Load database

    $data_actors        = load_data("Data/Actors.rxdata")

    $data_classes       = load_data("Data/Classes.rxdata")

    $data_skills        = load_data("Data/Skills.rxdata")

    $data_items         = load_data("Data/Items.rxdata")

    $data_weapons       = load_data("Data/Weapons.rxdata")

    $data_armors        = load_data("Data/Armors.rxdata")

    $data_enemies       = load_data("Data/Enemies.rxdata")

    $data_troops        = load_data("Data/Troops.rxdata")

    $data_states        = load_data("Data/States.rxdata")

    $data_animations    = load_data("Data/Animations.rxdata")

    $data_tilesets      = load_data("Data/Tilesets.rxdata")

    $data_common_events = load_data("Data/CommonEvents.rxdata")

    $data_system        = load_data("Data/System.rxdata")

    # Make system object

    $game_system = Game_System.new

    # Make title graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.title($data_system.title_name)

    

    # Make command window

    s1 = Difficulty::Diff_new_game_word 

    s2 = Difficulty::Diff_load_game_word 

    s3 = Difficulty::Diff_exit_game_word 

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.back_opacity = 160

    @command_window.x = 320 - @command_window.width / 2

    @command_window.y = 288

    

    @help_window = Window_Help.new

    @help_window.visible = false

    create_difficulty_window

    

    # Continue enabled determinant

    # Check if at least one save file exists

    # If enabled, make @continue_enabled true; if disabled, make it false

    @continue_enabled = false

    for i in 0..3

      if FileTest.exist?("Save#{i+1}.rxdata")

        @continue_enabled = true

      end

    end

    # If continue is enabled, move cursor to "Continue"

    # If disabled, display "Continue" text in gray

    if @continue_enabled

      @command_window.index = 1

    else

      @command_window.disable_item(1)

    end

    # Play title BGM

    $game_system.bgm_play($data_system.title_bgm)

    # Stop playing ME and BGS

    Audio.me_stop

    Audio.bgs_stop

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of command window

    @command_window.dispose

    # Dispose of title graphic

    @sprite.bitmap.dispose

    @sprite.dispose

  end

  

  

  #--------------------------------------------------------------------------

  # * Create difficulty window: size based in number of dificulties

  #--------------------------------------------------------------------------

  alias dargor_vx_difficulty_title_update update

  def create_difficulty_window

    names = []

    for name in Difficulty::Names

      names << name

    end

    @difficulty_window = Window_Command.new(172, names)

    @difficulty_window.x = @command_window.x

    @difficulty_window.y = @command_window.y

    @difficulty_window.height = @command_window.height

    @difficulty_window.visible = false

    @difficulty_window.active = false

 

    # Set initial dificult text

    @help_window.set_text(Difficulty::Descriptions[0])

    @help_window.visible = false

  end

  

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update command window

    @command_window.update

    @difficulty_window.update

    

    

    if @difficulty_window.active

      @help_window.update

      update_difficulty_window

      return

    end

    

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Branch by command window cursor position

      case @command_window.index

      

      when 0  # New game

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        @difficulty_window.visible = true

        @difficulty_window.active = true

        @help_window.visible = true

        @command_window.visible = false

        @command_window.active = false

        return

 

      when 1  # Continue

        command_continue

        

      when 2  # Shutdown

        command_shutdown

    

      end

    end

    

    if @command_window.methods.include?('selection')

      condition = '@command_window.selection == Vocab::new_game'

    else

      condition = '@command_window.index == 0'

    end

    

    if Input.trigger?(Input::C) && eval(condition)

      if !@difficulty_window.active && Difficulty::In_Title

      end

    end

 

  end

  

  #--------------------------------------------------------------------------

  # * Command: New Game

  # modified to active dif switch when $game is created

  #--------------------------------------------------------------------------

  alias wep_dif_command_new_game command_new_game

  def command_new_game(id)

    wep_dif_command_new_game

    $game_switches[Difficulty::Switches[id]] = true

  end

  

  #--------------------------------------------------------------------------

  # * Frame Update (Difficulty)

  #--------------------------------------------------------------------------

  def update_difficulty_window

    # Diff id = window index

    id = $game_system.difficulty_id = @difficulty_window.index

    

    # Back

    if Input.trigger?(Input::B)

      # Play  SE

      $game_system.se_play($data_system.cancel_se)

      @difficulty_window.visible = false

      @difficulty_window.active = false

      @command_window.visible = true

      @command_window.active = true

      

    # Select diff

    elsif Input.trigger?(Input::C)

      @difficulty_window.dispose

      @help_window.dispose

      # Active difficulty effect and swithch

      $game_system.difficulty_effects[Difficulty::Effects[id]][:active] = true

      

      command_new_game(id)

    else

      @help_window.set_text(Difficulty::Descriptions[id])

    end

    

 

  end

end

 

 

 

end
 

Atoa

Member

Since all the dificult check are the same, differing only the status symbol, you could've it on an single method, with an argument that would be the symbol.

something like

Code:
  def challenge_setting(stat)

    total = 100

    # Search in all effects

    for effect in $game_system.difficulty_effects

         # Effect type 1

         if effect[:active] and effect[:type] == 1  and effect[stat] != nil and  effect[:enemies_ids].include?(@enemy_id)

           if effect[:variable] != nil

             total+=effect[stat]*$game_variables[effect[:variable]]/100

           else

             total+=effect[stat]

           end

         end

         # Effect type 2

         if effect[:active] and effect[:type] == 2  and effect[stat] != nil and  effect[:maps_ids].include?($game_map.map_id)

           if effect[:variable] != nil

             total+=effect[stat]*$game_variables[effect[:variable]]/100

           else

             total+=effect[stat]

           end

         end

         # Effect type 3

         if effect[:active] and effect[:type] == 3  and effect[stat] != nil and $game_party.tree_includes_map? (effect[:base_map_name])

           if effect[:variable] != nil            

             total+=effect[stat]*$game_variables[effect[:variable]].to_f/100

           else

             total+=effect[stat]

           end

         end

         # Effect type 4

         if effect[:active] and effect[:type] == 4 and effect[stat]!= nil

           if effect[:variable] != nil

             total+=effect[stat]*$game_variables[effect[:variable]]/100

           else

             total+=effect[stat]

           end

         end

    end

    return total

  end

  #--------------------------------------------------------------------------

  # ? MaxHP

  #--------------------------------------------------------------------------

  alias base_maxhp_Challengue_Compensator base_maxhp

  def base_maxhp

    # Gets normal atribute

    n = base_maxhp_Challengue_Compensator

    n = n * challenge_setting(:hp) / 100

  end

  #--------------------------------------------------------------------------

  # ? MaSP

  #--------------------------------------------------------------------------

  alias base_maxsp_Challengue_Compensator base_maxsp

  def base_maxsp

    # Gets normal atribute

    n = base_maxsp_Challengue_Compensator

    n = n * challenge_setting(:sp) / 100

  end
 
Nice idea. Although, i created the methods in notepad++ and copy-pasting it... buts true thats better, i will update it some day.
 
Gotta say I love this script to pieces. After playing games like Deus Ex, I want to be able to say "play this one mission in easy mode" and the rest of the game in medium or hard, because sometimes you just get stuck. This script lets you do that which IMO is a great way forward for games.
 
Amy Pond":1i7sznmq said:
Gotta say I love this script to pieces. After playing games like Deus Ex, I want to be able to say "play this one mission in easy mode" and the rest of the game in medium or hard, because sometimes you just get stuck. This script lets you do that which IMO is a great way forward for games.

That was the main idea of my system, i wanted to can completely tweak each challengue without any problem...

Vergessen":1i7sznmq said:
well documented(mostly), id like to see this with your AI script(when you gonna post that btw?)

The AI script is waiting. Thats because is a system for my larger project, that for now, i do some things, but i dont work in a great rate. Im making other systems or independent scripts(and my game in pygame) for my smaller projects that im developing now...

Although i have advanced it somewhat. I see that script as a final challengue for me with RGSS i want to make something very great!
 

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