This isn't exactly a script request, but this is the only place that I could think of putting it. I've seen it floating around, but couldn't think of what it's name was. Basically, I need a script that removes the pre-defined RMXP experience tables with one that I fully define myself. It doesn't need to be custom to exactly what I'm asking, and if you have one already and are willing to share, that'd be the best.
Thanks for helping!
# Manual Experience Table Enumeration
# by RPG Advocate
=begin
To create customized xp tables for a character, make a txt document and
devise numbers for the experience.
Note: The numbers you put in are the Total experience for that level.
ie=
0
20
55
125
260
would really be this:
0 xp at level 1
20 xp to level 2
35 xp to level 3
70 xp to level 4
135 xp to level 5
Make sense?
If you don't fill in enough numbers, it will replace the numbers with the
default experience equivelant for that level.
If you put too many levels worth of experience, it will just cut off wherever
you set the max level at.
=end
# Displays error messages
# if set to true
METE_ERROR_SHOW = true
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Calculate EXP
#--------------------------------------------------------------------------
alias mete_make_exp_list make_exp_list
def make_exp_list
# The original call
mete_make_exp_list
# Obtain actor and read outside experience chart if available
actor = $data_actors[@actor_id]
fname = "Data\\actor" + actor.id.to_s + "exp.rxdata"
if FileTest.exist?(fname)
get_exp_list_from_file(fname)
if @exp_file_error
@exp_list = Array.new(101)
else
return
end
end
end
#--------------------------------------------------------------------------
# * Obtain experience table from file
#--------------------------------------------------------------------------
def get_exp_list_from_file(filename)
begin
if @exp_file_error
return
end
f = File.open(filename)
list = f.readlines
list = correct_malformed_input(list)
if @exp_file_error
return
end
for i in 0..list.size - 1
list[i] = list[i].to_i
end
list = correct_erroneous_data(list)
for i in list.size..100
list[i] = 0
end
list.unshift(0)
@exp_list = list
rescue StandardError
s1 = "Unrecoverable error while reading " + @name + "'s EXP list.\n"
s2 = "Experience curve declared in the database will be used instead."
print(s1 + s2) if METE_ERROR_SHOW
@exp_file_error = true
retry
ensure
if f != nil
f.close
end
end
end
#--------------------------------------------------------------------------
# * Delete and repair experience table
#--------------------------------------------------------------------------
def correct_malformed_input(list)
lines_to_delete = []
if list.size == 0
s1 = "Warning: " + @name + "'s experience requirement file is empty. "
s2 = "Experience curve declared in the database will be used instead."
print(s1 + s2) if METE_ERROR_SHOW
@exp_file_error = true
return
end
for i in 0..list.size - 1
delflag = false
for j in 0..list[i].size - 1
if list[i][j] != 10 && list[i][j] != 32 &&
!(list[i][j] >= 48 && list[i][j] <= 57)
delflag = true
end
end
if list[i].size == 1 && list[i][0] == 10
delflag = true
end
if delflag
lines_to_delete.push(list[i])
end
end
if lines_to_delete != []
for i in 0..lines_to_delete.size - 1
list.delete(lines_to_delete[i])
end
end
for i in 0..list.size - 1
while list[i].include?(32)
list[i].slice!(0)
end
end
return list
end
#--------------------------------------------------------------------------
# * Correct the new experience table
#--------------------------------------------------------------------------
def correct_erroneous_data(list)
warnings = ""
wrong_exp = false
if list[0] != 0
list[0] = 0
s1 = "Warning: " + @name + "'s experience requirement for level 1 "
s2 = "must be zero. Automatically correcting error.\n"
warnings += s1 + s2
end
if list.size < $data_actors[@actor_id].final_level
if list.size >= 2
value = list[list.size - 1] - list[list.size - 2]
for i in list.size..$data_actors[@actor_id].final_level - 1
list[i] = list[i-1] + value
end
else
list = []
for i in 0..$data_actors[@actor_id].final_level - 1
list[i] = i
end
end
s1 = "Warning: Fewer levels than " + @name + "'s maximum level have "
s2 = "been declared. Creating temporary substitute values.\n"
warnings += s1 + s2
end
if list.size > $data_actors[@actor_id].final_level
new_list = []
for i in 0..$data_actors[@actor_id].final_level - 1
new_list[i] = list[i]
end
list = new_list
s1 = "Warning: More levels than " + @name + "'s maximum level have "
s2 = "been declared. Ignoring excess declarations.\n"
warnings += s1 + s2
end
for i in 1..list.size - 1
if list[i] <= list[i-1]
if i == list.size - 1 && list.size != 2
diff = list[i-1] - list[i-2]
list[i] = list[i-1] + diff
elsif i == list.size - 1 && list.size == 2
list[i] = 10
else
if list[i+1] > list[i-1]
diff = list[i+1] - list[i-1]
list[i] = list[i-1] + diff / 2
else
list[i] = list[i-1] + 10
end
end
wrong_exp = true
end
end
if wrong_exp
s1 = "Warning: One or more experience requirements for " + @name + " "
s2 = "is less than or equal to the previous level's requirement. "
s3 = "Creating temporary substitute values."
warnings += s1 + s2 + s3
end
if warnings != ""
print(warnings) if METE_ERROR_SHOW
end
return list
end
end
I think the txt document has to be named 'actor#exp.rxdata', where # is the ID in the database of the actor.
Quote from: "I like surprises" on May 11, 2011, 09:42:48 pm
I think the txt document has to be named 'actor#exp.rxdata', where # is the ID in the database of the actor.
Most certainly not. Stick in your script editor. .rxdata files are Marshaled Ruby objects. It wouldn't do a thing saved as one, and if you did add a few lines of code to your game and attempted to load it, you would just raise an Exception.
fname = "Data\\actor" + actor.id.to_s + "exp.rxdata"
if FileTest.exist?(fname)
get_exp_list_from_file(fname)
if @exp_file_error
@exp_list = Array.new(101)
else
return
end
Then what does this mean?
I don't /really/ know, I'm just guessing in an attempt to be useful..
I haven't used this script in a long while. :x
The script saves/loads data from an external file. It is not really necessary for them to have done this, but the author chose to do it this way. It has absolutely nothing to do with where the script is placed.
Scripts are placed in the editor.
How would you have done it then? >.<
It really doesn't matter either way, but I would have just created a new variable in a class that is already saved, like Game_Party or something. Then you don't need any of the extra saving loading. Its done automatically since the class is already saved by default.
"make a txt document"
Means actor#exp.txt >.> I think... <.< Anyway, thanks for the help! That's exactly the one I was looking for!