Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VX] Experience gain modifier

Started by zerothedarklord, June 21, 2012, 04:08:46 AM

0 Members and 1 Guest are viewing this topic.

zerothedarklord

Would very much like to get a script that allows the modification of experience gained through note tags useable on States, Skills, Weapons and Armor. I'm interested in having it able to modify exp gain by a specific amount (like on Diablo 3) as well as a percentage. EXAMPLES:

/modexp [10]       <- this would increase experience gained per enemy killed (which is the preferred method, rather than on a per-battle basis, but per-battle is acceptable if it's significantly easier to do)

/modexp[10%]      <- this would increase experience gained by 10%. IF easier, or for further modification purposes, it could also be written as /modexp[110%] to reflect that you're gaining 10% above normal experience, which would also allow reduced experience gain as well.


pacdiggity

I'll just get my old scripting box out...
# Exp Mod
# Pacman, 21/6/2012
# Use \exp_mod[x] in a weapon, armor or state's notebox to add x to all enemies'
# exp values.
# Use \expp_mod[x] in a weapon, armor or state's notebox to make all enemies'
# exp values x percent of what it was originally.
# Percentages are calculated before additions. Note that you can use negative
# numbers to subtract from the value, or numbers less than 100 to make fractions.

["Weapon", "Armor", "State"].each { |klass| pac_expmod = %Q(
class RPG::#{klass}; def exp_mod
  @exp_mod ||= self.note[/\\mod[_ ]?exp ?\[(\d+)\]/i].nil? ? 0 : $1.to_i
end; def expp_mod
  @expp_mod ||= self.note[/\\mod[_ ]?exp[_ ]?p ?\[(\d+)\]/i].nil? ? 100 : $1.to_i
end; end); eval pac_expmod }

class Game_Enemy < Game_Battler
  alias pac_expmod_exp exp
  def exp(*args)
    n = pac_expmod(*args)
    $game_party.equips.each {|equip|
      n *= equip.expp_mod / 100; n += equip.exp_mod
    }
    $game_party.members.each {|actor|
      actor.states.each {|state|
        n *= expp_mod / 100
        n += state.exp_mod
      }
    }
    return n < 0 ? 0 : n.to_i
  end
end

Note that I didn't really test it, and I'm a little rusty with scripting. Also I didn't make it work with skills because I'm not sure what you wanted with that.
it's like a metaphor or something i don't know

zerothedarklord

#2
that should be fine, worst-case scenario I can just make a skill apply a state for it anyway. Thanks man. Also, while I'm thinking about it, is there a way that you're aware of (without having to build trillions of conditional branches with parallel common events) to make weapons or equipment automatically apply a state to a character for the time that it's equipped? Or a way to hide states? my game includes some passive skills/states so it's a bit cramped having 5 - 10 states active at all times.



Also, it error'd, pointing to the line:
n = pac_expmod(*args)

Error message: line 20: NoMethodError occured. undefined method n = pac_expmod

pacdiggity

Change that line to
n = pac_expmod_exp(*args)
That was a silly mistake.

I'm also really confident those scripts already exist.
it's like a metaphor or something i don't know

zerothedarklord

that fixed that, now it says equip isn't defined or something.

Any idea what those scripts might be called? Those along with that variable state damage script I requested are about all I need to finish my game.

pacdiggity

Change line 21 to    $game_party.equips.compact.each {|equip|That should fix the nil error you're getting.

As for your other thing, IUNNO.
it's like a metaphor or something i don't know

zerothedarklord

unfortunately it didn't man, still says undefined.

pacdiggity

    $game_party.equips.each {|equip| next if equip.nil?
it's like a metaphor or something i don't know

zerothedarklord

#8
you guessed it! still saying it's undefined.

"NoMethodError occured"
"undefined method 'equips' for # <Game_Party:0x2ac1ed0>"

pacdiggity

# Exp Mod
# Pacman, 23/6/2012
# Use \exp_mod[x] in a weapon, armor or state's notebox to add x to all enemies'
# exp values.
# Use \expp_mod[x] in a weapon, armor or state's notebox to make all enemies'
# exp values x percent of what it was originally.
# Percentages are calculated before additions. Note that you can use negative
# numbers to subtract from the value, or numbers less than 100 to make fractions.

["Weapon", "Armor", "State"].each { |klass| pac_expmod = %Q(
class RPG::#{klass}; def exp_mod
  @exp_mod ||= self.note[/\\mod[_ ]?exp ?\[(\d+)\]/i].nil? ? 0 : $1.to_i
end; def expp_mod
  @expp_mod ||= self.note[/\\mod[_ ]?exp[_ ]?p ?\[(\d+)\]/i].nil? ? 100 : $1.to_i
end; end); eval pac_expmod }

class Game_Enemy < Game_Battler
  alias pac_expmod_exp exp
  def exp(*args)
    n = pac_expmod_exp(*args)
    $game_party.members.each {|actor| next if actor.nil?
      actor.equips.each {|equip| next if equip.nil?
        n *= equip.expp_mod / 100; n += equip.exp_nod
      }
      actor.states.each {|state| next if state.nil?
        n *= expp_mod / 100
        n += state.exp_mod
      }
    }
    return n < 0 ? 0 : n.to_i
  end
end
it's like a metaphor or something i don't know

zerothedarklord

#10
# Exp Mod
# Pacman, 23/6/2012
# Use \exp_mod
  • in a weapon, armor or state's notebox to add x to all enemies'
    # exp values.
    # Use \expp_mod
  • in a weapon, armor or state's notebox to make all enemies'
    # exp values x percent of what it was originally.
    # Percentages are calculated before additions. Note that you can use negative
    # numbers to subtract from the value, or numbers less than 100 to make fractions.

    ["Weapon", "Armor", "State"].each { |klass| pac_expmod = %Q(
    class RPG::#{klass}; def exp_mod
      @exp_mod ||= self.note[/\\mod[_ ]?exp ?\[(\d+)\]/i].nil? ? 0 : $1.to_i
    end; def expp_mod
      @expp_mod ||= self.note[/\\mod[_ ]?exp[_ ]?p ?\[(\d+)\]/i].nil? ? 100 : $1.to_i
    end; end); eval pac_expmod }

    class Game_Enemy < Game_Battler
      alias pac_expmod_exp exp
      def exp(*args)
        n = pac_expmod_exp(*args)
        $game_party.members.each {|actor| next if actor.nil?
          actor.equips.each {|equip| next if equip.nil?
            n *= equip.expp_mod / 100; n += equip.exp_mod
          }
          actor.states.each {|state| next if state.nil?
            n *= expp_mod / 100
            n += state.exp_mod
          }
        }
        return n < 0 ? 0 : n.to_i
      end
    end


    error on line 26,  n *= expp_mod / 100


zerothedarklord

line 26: name error occured.
undefined local variable or method expp_mod for #<Game_Enemy:0x287a960>

pacdiggity

it's like a metaphor or something i don't know

zerothedarklord

Alright, it isn't crashing anymore, but the experience gain is unchanged. (Testing it using equipment to modify it)

zerothedarklord


pacdiggity

You should probably learn how to bugfix. It's not very difficult, and it's an incredibly useful skill, especially for someone who requests as much as you.

Maybe I'll make a tutorial :)
it's like a metaphor or something i don't know

zerothedarklord

lol, yeah, true that man. but I'm not the kind of person to half-ass something. If I was going to learn to bugfix, I'd just take it all the way and learn to make my own scripts, lol.

D&P3

Feel free to do that.

It saves a lot of hassle if you can do things yourself.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3