Lucofthewind
Sponsor
Just when I thought I had everything running, I ofcourse had to break something else. You know not a good day unless I break a code! Ok so in any case I am using this wonderful code as a bonus level up system
Everything is working just great, except the code only works on certain maps. Funny ant it? I have an event that calls this script (so they can assign points and such) and it works fine. But when I copy the same bloody event onto another map, it crashes the game! Any help would be great considering its 4am and I think I am just stupid now.
Thanks guys!
Code:
#============================================================================
# Actor Customization!
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 5.00
# July 28, 2007
# Tested with SDK 2.2
#============================================================================
#--------------------------------------------------------------------------
# * Begin Actor Customization modification section*
# Use this section to control many aspects of the script.
# May it be from Message display to Custom Actor Statistic growth
#--------------------------------------------------------------------------
module Customize
# *General Settings*
Points_Gained = 3 # Amount of points gained upon leveling up.
Map_bg = true # Display the map as the BG? true = yes. false = no; display a picture instead
Draw_display = true # Display Statistic advancement preview?
Draw_face = false # Draw Face or Character Sprite?. True= face, false; sprite
Error_sound = '057-Wrong01' # Change the sound effect when insufficient supply
Picture_name = 'sky' # Name of your background. Leave blank if not used.
#----
# *Messages Control Center*
# There are a total of seven messages, below you can customize each one
Messages = ['HP has Increased', 'SP has Increased', 'Strength has Increased',
'Dexterity has Increased', 'Agility has Increased', "Intellegence has Increased",
"Please distribute your points", "Not Enough Points"]
# Define the messages. 0=HP, 1=SP, 2=STR, 3=DEX, 4=AGI,
# 5=INT, 6=Default, 7=Not enough Points
#----
# This area allows you to define custom Statistic Advancement.
# Example, have Actor 1 get 7 HP and 3 STR but have Actor 2 receive 3 HP and 7 STR
# Define the Custom Stat actors below.
Actor_HP = {1 => 10
} # Define the amount of HP an actor gets per point. {actor_id => amount}.
# Seperate Actors with a comma (,).
Actor_HP.default = 3 # Change this to set the default growth
Actor_SP = {1 => 10
} # Define the Amount of SP an actor gets per point. {actor_id => amount}
# Seperate Actors with a comma(,)
Actor_SP.default = 3 # Change this to set the default growth
Actor_STR = {1 => 1
} # Define the Amount of STR an actor gets per point. {actor_id => amount}
# Seperate Actors with a comma(,)
Actor_STR.default = 1 # Change this to set the default growth
Actor_DEX = {1 => 1
} # Define the Amount of DEX an actor gets per point. {actor_id => amount}
# Seperate Actors with a comma(,)
Actor_DEX.default = 1 # Change this to set the default growth
Actor_AGI = {1 => 1
} # Define the Amount of AGI an actor gets per point. {actor_id => amount}
# Seperate Actors with a comma(,)
Actor_AGI.default = 1 # Change this to set the default growth
Actor_INT = {1 => 1
} # Define the Amount of INT an actor gets per point. {actor_id => amount}
# Seperate Actors with a comma(,)
Actor_INT.default = 1 # Change this to set the default growth
# Note: To use the Default statistic growth simply leave an actor value blank.
end
#--------------------------------------------------------------------------
# * Create Upgrade Points & Add Points on Level-up
#--------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Begin Game_Actor Edit
#----------------------------------------------------------------------------
class Game_Actor < Game_Battler
# Make Upgrade Points
attr_accessor :upgrade_points
alias synthesize_upgrade_points setup
# Distribute Points among Actors
def setup(actor_id)
synthesize_upgrade_points(actor_id)
# Starting amount of points
@upgrade_points = 3
end
# Begin Level-up process
alias synthesize_upgrade_points_exp exp
def exp=(exp)
@exp = [[exp, 9999999].min, 0].max
# Level up
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
# Add an additional level
@level += 1
# Add Upgrade Points to the actor that leveled
@upgrade_points += Customize::Points_Gained
# Learn skill
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
end
# End Class
end
#----------------------------------------------------------------------------
# End Game_Actor Edit
#----------------------------------------------------------------------------
#--------------------------------------------------------------------------
# Scene_Upgrade
# This is the main scene of 'Actor Customization!'
# Editing not recommended.
#--------------------------------------------------------------------------
class Scene_Upgrade
#--------------------------------------------------------------------------
# Object Initalize
#--------------------------------------------------------------------------
def initialize(actor_index = 0)
# Define Actor_index. Used to draw actors and for multiple actor support
@actor_index = actor_index
# Define Actor Data
@actor = $game_party.actors[@actor_index]
@hp = Customize::Actor_HP[@actor.id]
@sp = Customize::Actor_SP[@actor.id]
@str = Customize::Actor_STR[@actor.id]
@dex = Customize::Actor_DEX[@actor.id]
@agi = Customize::Actor_AGI[@actor.id]
@int = Customize::Actor_INT[@actor.id]
@syn_message = Customize::Messages[6] # The Default Message
end
#--------------------------------------------------------------------------
# * Main Window Initialize
#--------------------------------------------------------------------------
def main
# Draw background
main_spriteset
# Make Commands
s1 = "Increase #{$data_system.words.hp} by #{@hp}"
s2 = "Increase #{$data_system.words.sp} by #{@sp}"
s3 = "Increase #{$data_system.words.str} by #{@str}"
s4 = "Increase #{$data_system.words.dex} by #{@dex}"
s5 = "Increase #{$data_system.words.agi} by #{@agi}"
s6 = "Increase #{$data_system.words.int} by #{@int}"
# Define Command Window
@command_window = Window_Command.new(275, [s1, s2, s3, s4, s5, s6])
@command_window.x = 343
@command_window.y = 56
@command_window.z = 9998
@command_window.opacity = 200
# Turn the Command Window On
@command_window.active = true
@upgrade_status_window = Window_UpgradeStatus.new(@actor, @hp, @sp, @str, @dex, @agi, @int)
@upgrade_status_window.opacity= 200
@upgrade_status_window.x = 18
@upgrade_status_window.y = 112
@upgrade_status_window.z = 9998
# Set Raise Window Data
@raise_window = Window_Feedback.new(@syn_message)
@raise_window.x = 18
@raise_window.y = 56
@raise_window.z = 9998
@raise_window.opacity = 200
# Set Actor Swap Window
@actor_window = Window_ActorList.new
@actor_window.x = 344
@actor_window.y = 277
@actor_window.z = 9998
@actor_window.opacity = 200
@actor_window.active = false
@actor_window.index = 0
# Graphics Transition
Graphics.transition
# Main Loop
loop do
# Update Graphics
Graphics.update
# Update Input
Input.update
# Renew
update
# Discontinue Loop
if $scene != self
break
end
end
# Prepare Transition
Graphics.freeze
# Dispose Windows
@command_window.dispose
@upgrade_status_window.dispose
@raise_window.dispose
@actor_window.dispose
if Customize::Draw_face == true
@face.dispose
end
end
#--------------------------------------------------------------------------
# * Spriteset Initialize
#--------------------------------------------------------------------------
def main_spriteset
# Draw either the Map or a Background Image
if Customize::Map_bg == true
# Draw the Map
@background = Spriteset_Map.new
else
# Define the Background
@background = Sprite.new
@background.bitmap = RPG::Cache.picture(Customize::Picture_name)
end
# Draw Actors Face
if Customize::Draw_face == true
@face = Sprite.new
@face.bitmap = RPG::Cache.picture(@actor.name + "_face")
@face.x = 40
@face.y = 120
@face.z = 9999
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@command_window.update
@actor_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If Actor Window active call update_actor
if @actor_window.active
update_actor
return
end
end
#--------------------------------------------------------------------------
# * Update Command *
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@actor_window.active = true
@command_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # Increase HP
if @actor.upgrade_points >= 1 and @actor.maxhp <= 9998
$game_system.se_play($data_system.decision_se)
@syn_message = Customize::Messages[0]
@actor.upgrade_points -= 1
@actor.hp += @hp
@actor.maxhp += @hp
@upgrade_status_window.refresh
@raise_window.update
else
@syn_message = Customize::Messages[7]
@raise_window.update
$game_system.se_play(RPG::AudioFile.new(Customize::Error_sound))
end
when 1 # # Increase SP
if @actor.upgrade_points >= 1 and @actor.maxsp <= 9998
$game_system.se_play($data_system.decision_se)
@syn_message = Customize::Messages[1]
@actor.upgrade_points -= 1
@actor.sp += @sp
@actor.maxsp += @sp
@upgrade_status_window.refresh
@raise_window.update
else
@syn_message = Customize::Messages[7]
@raise_window.update
$game_system.se_play(RPG::AudioFile.new(Customize::Error_sound))
end
when 2 # # Increase STR
if @actor.upgrade_points >= 1 and @actor.str <= 998
$game_system.se_play($data_system.decision_se)
@syn_message = Customize::Messages[2]
@actor.str += @str
@actor.upgrade_points -= 1
@upgrade_status_window.refresh
@raise_window.refresh
else
@syn_message = Customize::Messages[7]
@raise_window.refresh
$game_system.se_play(RPG::AudioFile.new(Customize::Error_sound))
end
when 3 # # Increase DEX
if @actor.upgrade_points >= 1 and @actor.dex <= 998
$game_system.se_play($data_system.decision_se)
@syn_message = Customize::Messages[3]
@actor.upgrade_points -= 1
@actor.dex += @dex
@upgrade_status_window.refresh
@raise_window.refresh
else
@syn_message = Customize::Messages[7]
@raise_window.refresh
$game_system.se_play(RPG::AudioFile.new(Customize::Error_sound))
end
when 4 # # Increase AGI
if @actor.upgrade_points >= 1 and @actor.agi <= 998
$game_system.se_play($data_system.decision_se)
@syn_message = Customize::Messages[4]
@actor.upgrade_points -= 1
@actor.agi += @agi
@upgrade_status_window.refresh
@raise_window.refresh
else
@syn_message = Customize::Messages[7]
@raise_window.refresh
$game_system.se_play(RPG::AudioFile.new(Customize::Error_sound))
end
when 5 # # Increase INT
if @actor.upgrade_points >= 1 and @actor.int <= 998
$game_system.se_play($data_system.decision_se)
@syn_message = Customize::Messages[5]
@actor.upgrade_points -= 1
@actor.int += @int
@upgrade_status_window.refresh
@raise_window.refresh
else
@syn_message = Customize::Messages[7]
@raise_window.refresh
$game_system.se_play(RPG::AudioFile.new(Customize::Error_sound))
end
end
return
end
end
#--------------------------------------------------------------------------
# * Actor Swap *
#--------------------------------------------------------------------------
def update_actor
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Swap Actors
$game_system.se_play($data_system.decision_se)
@actor_index = @actor_window.index
$scene = Scene_Upgrade.new(@actor_index)
end
end
end
#--------------------------------------------------------------------------
# * Begin Window Data
#--------------------------------------------------------------------------
#=================================
# *Status Window*
#=================================
class Window_UpgradeStatus < Window_Base
# Initiate Actor Data
def initialize(actor, hp, sp, str, dex, agi, int)
# Define Window Reso.
super(32, 32, 330, 300)
# Set Contents
self.contents = Bitmap.new(width - 32, height - 32)
# Define Actor Data
@actor = actor
@hp = hp
@sp = sp
@str = str
@dex = dex
@agi = agi
@int = int
# Jump to Update
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Clear Window Contents
self.contents.clear
# Draw Actor Data
if Customize::Draw_face == false
draw_actor_graphic(@actor, 35, 50)
end
draw_actor_class(@actor, 85, 20)
draw_actor_name(@actor, 80, 0)
draw_actor_level(@actor, 176, 0)
self.contents.font.color = system_color
# Draw Stat Display Preview
if Customize::Draw_display == true
self.contents.draw_text(85, 12, 35, 100, "Before:")
self.contents.draw_text(200, 12, 35, 100, "After:")
if @actor.upgrade_points >= 1 and @actor.maxhp <= 9998
draw_synac_preview(@actor,176, 34, 0, @hp)
end
if @actor.upgrade_points >= 1 and @actor.maxsp <= 9998
draw_synac_preview(@actor,176, 56, 1, @sp)
end
if @actor.upgrade_points >= 1 and @actor.str <= 998
draw_synac_preview(@actor,176, 98, 2, @str)
end
if @actor.upgrade_points >= 1 and @actor.dex <= 998
draw_synac_preview(@actor,176, 123, 3, @dex)
end
if @actor.upgrade_points >= 1 and @actor.agi <= 998
draw_synac_preview(@actor,176, 148, 4, @agi)
end
if @actor.upgrade_points >= 1 and @actor.int <= 998
draw_synac_preview(@actor,176, 173, 5, @int)
end
end
# Draw additional Stats
draw_actor_hp(@actor, 4, 68, 172)
draw_actor_sp(@actor, 4, 90, 172)
draw_actor_parameter(@actor, 4, 132, 3)
draw_actor_parameter(@actor, 4, 156, 4)
draw_actor_parameter(@actor, 4, 180, 5)
draw_actor_parameter(@actor, 4, 204, 6)
# Draw Point Data
self.contents.font.color = system_color
self.contents.draw_text(175, 205, 100, 100, "Points:")
self.contents.font.color = normal_color
self.contents.draw_text(165, 205, 100, 100, @actor.upgrade_points.to_s, 2)
end
#=======================================================
# Draw SC Preview
#=======================================================
def draw_synac_preview(actor,x, y, stat, value)
if stat == 0
minpreview = actor.hp + value
maxpreview = actor.maxhp + value
elsif stat == 1
minpreview = actor.sp + value
maxpreview = actor.maxsp + value
elsif stat == 2
maxpreview = actor.str + value
elsif stat == 3
maxpreview = actor.dex + value
elsif stat == 4
maxpreview = actor.agi + value
elsif stat == 5
maxpreview = actor.int + value
end
if stat > 1
self.contents.font.color = crisis_color
self.contents.draw_text(x, y, 12, 100, "=>")
self.contents.font.color = system_color
self.contents.draw_text(x+24, y, 100, 100, "#{maxpreview}")
else
self.contents.font.color = crisis_color
self.contents.draw_text(x, y, 12, 100, "=>")
self.contents.font.color = system_color
self.contents.draw_text(x+24, y, 100, 100, "#{minpreview}/#{maxpreview}")
end
end
end
#--------------------------------------------------------------------------
# Raise Window
#--------------------------------------------------------------------------
class Window_Feedback < Window_Base
def initialize(syn_message)
super(0, 0, 330, 60)
@syn_message = syn_message
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
# Clear the Window
self.contents.clear
# Draw the Message ID
self.contents.draw_text(0, 0, 300, 34, @syn_message)
end
end
#--------------------------------------------------------------------------
# Actor Window
#--------------------------------------------------------------------------
class Window_ActorList < Window_Selectable
def initialize
super(0, 0, 275, 85)
self.contents = Bitmap.new(width - 32, height - 32)
self.active = false
self.index = -1
@item_max = $game_party.actors.size
@column_max = 2
draw_actor
self.active = false
self.index = 0
end
def draw_actor
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
x = i * 65
y = 50
draw_actor_graphic(actor, x + 20, y)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(0 + index * 65, 0, 40, 54)
end
end
#
#----------------------------------------------------------------------------
# Written by Synthesize
# Additional Thanks: Icedmetal57 (Custom Stat Progression), Trickster (Bug smashing)
# DerVVulfman (SDK Module detection idea). Community for reporting bugs and support ^-^
#----------------------------------------------------------------------------
# Actor Customization!
#============================================================================
Everything is working just great, except the code only works on certain maps. Funny ant it? I have an event that calls this script (so they can assign points and such) and it works fine. But when I copy the same bloody event onto another map, it crashes the game! Any help would be great considering its 4am and I think I am just stupid now.
Thanks guys!