Welcome Guest [Log In] [Register]
Welcome to Olympian. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
[-Scripting-] Do things on Level Up; Stolen.
Topic Started: Jun 29 2010, 11:30 PM (357 Views)
Cylindrical
Member Avatar
Member Lv. 1
Do things on Level Up
by Cylindrical



I was looking for some things to somehow "remove" the Level Up system for my game. Ironically, I found this stuff out, and I'll be teaching you how to do things when an actor levels up.

First of all, we will go to the Script Editor. Now, press Ctrl+Shift+F to search all of your scripts. You will be prompted to enter your keywords. In it, type in:

Code:
 
def level_up


If you have no other scripts messing with the Level Ups, you'll see just one line:

Code:
 
Game_Actor (539): def level_up


Double-click on it and you will be sent directly on that line. What we will do is copy it from the def until the second end. Create a new blank space in the editor and paste your copied text. It shoul look like this now:

Code:
 
def level_up
@level += 1
for learning in self.class.learnings
learn_skill(learning.skill_id) if learning.level == @level
end
end


Then, on the beginning of the text, add this:

Code:
 
class Game_Actor < Game_Battler


Then add some spaces on the last line and type in end.Your script should look like this:

Code:
 
class Game_Actor < Game_Battler

def level_up
@level += 1
for learning in self.class.learnings
learn_skill(learning.skill_id) if learning.level == @level
end
end

end


Now, we're ready to mess with it!

Lesson 1 - Recovery
This is the most commonly sought after feature. This part will allow you to restore the actor when he/she levels up.

Code:
 
@hp = maxhp # This line will restore the levelling character's HP to 100%
@mp = maxmp # This line will restore the levelling character's MP to 100%
@states -= [X, Y, Z] # This will remove the state in the brackets. X Y and Z are the state IDs


As quoted by Mithran, you can easily remove the states using the function remove_state(), like this:
Code:
 
for i in 1..3 do remove_state(i) end



I think that's all of it for recovery.

Lesson 2 - Control Switch/Variable

Code:
 
$game_switches[XX] = true/false # This line will flip switch XX. If set to true, it'll be ON.
$game_variables[YY] += ZZ # This line will increase variable. Change + into - to subtract



Lesson 3 - Call Common Event

Code:
 
$game_temp.common_event_id = XX # This line will call Common Event XX, checking conditions


Lesson 4 - Advanced

You can also check if the who is the levelling character. For example, you want to give [0001: Ralph] 6 points to [0081: Skill Points]. You would need to check if Ralph was the one levelling up, like so:

Code:
 
if @actor_id == 1 # The 1 here means the actor ID of the actor
$game_variables[81] += 6 # Here, 81 is the variable and 6 is the value
end


An easier way to do this is this:

Code:
 
$game_variables[@actor_id + 80] += 6


Or this:

Code:
 
$game_variables[81] += 6 if @actor_id == XX

(Thanks to Mithos, corrected now dude)

Of course, this will mean that if [0002: Ulrika] levels up, the variable [0082] will have its value increased by 6, too. If you want to do something only when a certain actor levels up:

Code:
 
if @actor_id == XX # XX = Actor ID
# Any of the above
end


For multiple actors, you can do this:

Code:
 
if @actor_id == XX # XX/YY = Actor ID
# Do stuff
end
if @actor_id == YY
# Do stuff
end


or this:

Code:
 
if @actor_id == XX
# Do stuff
elsif @actor_id == YY
# Do stuff
end



I think that's the rest of it!
Have fun with your own level up system!

Just for reference, your script should look like this:

Code:
 
class Game_Actor < Game_Battler

def level_up
@level += 1
for learning in self.class.learnings
learn_skill(learning.skill_id) if learning.level == @level
end

#
# Additional features go here. The following is just an example.
#

# Restore to full HP
@hp = maxhp
# Restore to full MP
@mp = maxmp
# Remove all states except Incapacitated
@states -= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
# Increase variables
$game_variables[@actor_id + 80] += 8
# Level Up graphics
$game_temp.common_event_id = 1

# Level Up chit chat
if @actor_id == 1
$game_temp.common_event_id = 6
elsif @actor_id == 3
$game_temp.common_event_id = 7
end

end

end
Cylindrical ****s this place.
Offline Profile Quote Post Goto Top
 
Dawningstar
Member Avatar
Pet me!
Exellent! I esecially enjoyed the fact that you can get you person to recover after a level up! I have been looking for something like that!
Don't walk in my footsteps, I walk into walls...

Posted Image
Offline Profile Quote Post Goto Top
 
Hyde
Member Avatar
Administrator

Ever find out how to remove leveling?
I have the script for my game if you would like it.
Offline Profile Quote Post Goto Top
 
Dawningstar
Member Avatar
Pet me!
ACtually, could I have that? It would fix some of the problems im running into with my OTHER script! :D
Don't walk in my footsteps, I walk into walls...

Posted Image
Offline Profile Quote Post Goto Top
 
Identity_Crisis
Member Avatar
LIKE A MODERATOR

*Bother Bother*
Posted ImageIntelligence is not to make no mistakes, but quickly to see how to make them good.
Posted ImagePosted ImagePosted ImagePosted Image
Offline Profile Quote Post Goto Top
 
Dawningstar
Member Avatar
Pet me!
WHAT? I could use it! :P
Don't walk in my footsteps, I walk into walls...

Posted Image
Offline Profile Quote Post Goto Top
 
Identity_Crisis
Member Avatar
LIKE A MODERATOR

Sure.. ..Has Hyde sent you it?
Posted ImageIntelligence is not to make no mistakes, but quickly to see how to make them good.
Posted ImagePosted ImagePosted ImagePosted Image
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Tutorials · Next Topic »
Add Reply