EXP GAIN BASED ON CHARACTER LEVEL SCRIPT (NEED HELP)
Posts
Pages:
1
i am sorry if it was answered before, but is it possible to change the linear mechanic of XP of monsters?
for example if i am level 1 and kill a level 20 monster i get 10000 xp but if i am lvl 20 and kill the same monster i get 500
for now (monster level/player level) * base monster experience.
thanks in advance.
edit: i forgot, i am using RPG maker VX ace.
for example if i am level 1 and kill a level 20 monster i get 10000 xp but if i am lvl 20 and kill the same monster i get 500
for now (monster level/player level) * base monster experience.
thanks in advance.
edit: i forgot, i am using RPG maker VX ace.
Not by default since monsters don't have levels. If you have a script that gives enemies levels, you can change self.gain_exp to add the exp from your formula rather than just $game_troop.exp_total, but that would require looping through $game_troop to check the monster levels before adding them to the cumulative total.
All in all, it wouldn't be that hard to do but you'd probably require a bit of scripting jiggery-pokery to make it work the way you want. I could do this for you but it's not the kind of work I'd normally do for free these days.
All in all, it wouldn't be that hard to do but you'd probably require a bit of scripting jiggery-pokery to make it work the way you want. I could do this for you but it's not the kind of work I'd normally do for free these days.
Since I'm feeling generous, here you go. I've only tested this insofar as the function you asked for so it may have bugs I haven't discovered yet, but it seems to work okay. Note that it replaces a few methods in BattleManager so it may cause compatibility issues if you're using other custom battle scripts.
module TRI
module REGEX
LEVEL = /<level: (\d+)>/i
end
end
module DataManager
class << self
alias_method(:tri_load_database, :load_database)
end
def self.load_database
tri_load_database
load_level_notetags
end
def self.load_level_notetags
for obj in $data_enemies
next if obj.nil?
obj.load_level_notetags
end
puts "Read: Level notetags"
end
end
module BattleManager
def self.gain_exp
$game_party.all_members.each do |actor|
exp_total = 0
$game_troop.dead_members.each do |enemy|
exp_total += ((enemy.get_level.to_f / actor.level.to_f) * enemy.exp).to_i
end
display_exp(actor, exp_total)
actor.gain_exp(exp_total)
wait_for_message
end
end
def self.process_victory
play_battle_end_me
replay_bgm_and_bgs
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
#display_exp
gain_gold
gain_drop_items
gain_exp
SceneManager.return
battle_end(0)
return true
end
def self.display_exp(actor, exp)
if exp > 0
text = sprintf(Vocab::ObtainExp, exp)
$game_message.add("#{actor.name} " + text)
end
end
end
class Game_Enemy < Game_Battler
def get_level
if enemy.level
enemy.level
else
1
end
end
end
class RPG::Enemy < RPG::BaseItem
attr_accessor :level
def load_level_notetags
@note.split(/[\r\n]+/).each do |line|
case line
when TRI::REGEX::LEVEL
@level = $1.to_i
end
end
end
end
many thanks, to be honest i dunno how I can use it (where and with what format i should put notetage) but i learned a lot by trying to understand it :). i know some very basic programming knowledge.
you dunno how much you helped me. thanks again.
you dunno how much you helped me. thanks again.
All you need to do is add <level: number> to an enemy's notetag to give it a level. The battle script automatically lowers/raises the exp given after battle dependent on the difference between the enemy's levels and the character's (since different people will get different amounts of experience I rewrote the exp display method to do it for each actor rather than display the total once).
If you need to reference an enemy's level elsewhere, I could write you an Interpreter command to do so, but for the purposes of what you asked for here this should be sufficient.
If you need to reference an enemy's level elsewhere, I could write you an Interpreter command to do so, but for the purposes of what you asked for here this should be sufficient.
hmm well, it dose not work, it says's "no method Error occurred. unidentified method '/' for nil:Nilclass"
i can use EXP variable for the same purpose, EXP determine level of creature, and every enemy will have a fix experience value.
thanks :)
i can use EXP variable for the same purpose, EXP determine level of creature, and every enemy will have a fix experience value.
thanks :)
Are you using any other scripts in the project?
Edit: Silly me, I missed something obvious. Hang on and I'll get an updated version up.
Edit 2: There, it should work now.
Edit: Silly me, I missed something obvious. Hang on and I'll get an updated version up.
Edit 2: There, it should work now.
yes, that worked, thanks man :)
edit: well there is one more problem, it seems the divide function return an integer. so if you are level 9 and enemy is level 10 you get the same exp as if you were level 10 , although i can counter it by multiplying enemy level *100 so it always return something.
edit: well there is one more problem, it seems the divide function return an integer. so if you are level 9 and enemy is level 10 you get the same exp as if you were level 10 , although i can counter it by multiplying enemy level *100 so it always return something.
oh thanks again, so when integers are in a equation it will return an integer automatically, i guess i get it :).
Yeah, Ruby doesn't use typecasting and by default assumes any value you're using is an integer unless you tell it otherwise using to_f or make the variable a Float.new when you create it.
Pages:
1














