The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: zerothedarklord on June 21, 2012, 04:08:46 AM

Title: [VX] Experience gain modifier
Post by: zerothedarklord on June 21, 2012, 04:08:46 AM
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.

Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 21, 2012, 10:39:28 AM
I'll just get my old scripting box out...
Code: [Select]
# 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.
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 21, 2012, 06:42:42 PM
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
Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 21, 2012, 09:12:48 PM
Change that line to
Code: [Select]
n = pac_expmod_exp(*args)
That was a silly mistake.

I'm also really confident those scripts already exist.
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 22, 2012, 12:11:27 AM
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.
Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 22, 2012, 07:06:49 AM
Change line 21 to
Code: [Select]
    $game_party.equips.compact.each {|equip|
That should fix the nil error you're getting.

As for your other thing, IUNNO.
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 22, 2012, 05:34:50 PM
unfortunately it didn't man, still says undefined.
Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 22, 2012, 11:20:23 PM
Code: [Select]
    $game_party.equips.each {|equip| next if equip.nil?
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 22, 2012, 11:57:52 PM
you guessed it! still saying it's undefined.

"NoMethodError occured"
"undefined method 'equips' for # <Game_Party:0x2ac1ed0>"
Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 23, 2012, 07:32:10 AM
Code: [Select]
# 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
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 23, 2012, 06:24:51 PM
# 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_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

Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 25, 2012, 05:15:16 AM
line 26: name error occured.
undefined local variable or method expp_mod for #<Game_Enemy:0x287a960>
Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 25, 2012, 11:28:16 AM
Change that to state.expp_mod
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 25, 2012, 05:32:41 PM
Alright, it isn't crashing anymore, but the experience gain is unchanged. (Testing it using equipment to modify it)
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 28, 2012, 05:14:26 PM
Any ideas Pac?
Title: Re: [VX] Experience gain modifier
Post by: pacdiggity on June 29, 2012, 07:09:39 AM
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 :)
Title: Re: [VX] Experience gain modifier
Post by: zerothedarklord on June 29, 2012, 05:46:38 PM
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.
Title: Re: [VX] Experience gain modifier
Post by: D&P3 on July 05, 2012, 03:55:39 PM
Feel free to do that.

It saves a lot of hassle if you can do things yourself.