iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Recommended Levels, Show the player a recommended minimum level upon entering a room.
Kilin
post Mar 22 2009, 04:26 AM
Post #1



Group Icon






Hey guys, first post and first real script.

So I was messing around with Mog's Map Location HUD script a bit ago and I decided it would be great if it had the same effect for showing a recommended level for a new room or area a player entered. That way, the player could decide whether he could live or survive in the area.
Just a note: recommending a level is based on what level the player must be in order to take on the area's monsters without dying.

I wanted this to be able to work right with Mog's script, so I pretty much used the same functions and transformed it a bit. The reason behind making this script was to teach myself about RGSS, since I'm very new to it. Sure it's probably simple for all you experts out there, but it was mostly modification and adding a few newer things.

Instructions:
The number that it pulls out is from a variable (11 in the script). When you change that variable, the number that appears is changed as well. However, it isn't derived from the difficulty of the monsters in that area. It's also only decided upon entering the room, so you may want to set it before entering. My recommended place is in the transfer event that you'll most likely have before an area. Also, you only need to change the variable on transfer events if your minimum changes (e.g. You typically won't need to set a level for a town). Also remember to change the variable before changing rooms. =)
Last bit, you can easily switch the level minimum off for...say...when you're entering a town where it's useless to have one.

Issues:
This system ONLY works if the variable is changed before the player enters the room, and even if you change the variable in the middle of the room, the script won't be recalled (my bad for not figuring that part out yet, even in the [Call Script] event). This doesn't make the script bugged, but it would be more capable if someone who knew RGSS made a suggestion for it.

Remember, the idea was to have this work in synchronization with Mog's Map Location script. The effect is the same, though they both work alone.

Here's the script. Enjoy. But please remember that with many other scripts, this one will not work with a previously saved game. You would need to create a new file first before it will work.

Oh, and obviously the graphic is terrible, but all you have to do to change it is to make one yourself (try to use the current dimensions) and import it into your Graphics\System folder with the name "Lvname.png".
Oh, and before you say how amateurishly put together this was, I already know. Thanks.

CODE
#--------------------------------------------------------------
# [VX] Level Range Indicator
#--------------------------------------------------------------
# by Kilin (kilin08@hotmail.com)
# Shaltix Games
# Version: 1.0
# Notes: This was written to work next to Mog's Map Location
# HUD script. This script can be used with or without it, but
# the basic layout is pretty much the same, with altered
# variable names.
#--------------------------------------------------------------
# The idea of this script is to display a recommended level
# value upon entering a map. The range is determined by one
# variable which can be changed through a call script. The
# script is useful for letting players know when they're in
# an area that they won't be able to survive in.
# You will need to declare the variable BEFORE you enter the
# map in order for it to work. A good place to change it is in
# the Transfer Player event.
#--------------------------------------------------------------
# REQUIREMENTS BEFORE USE:
# Set aside a switch and a variable for this script. The default
# number for both the switch and variable are 11. Let's say you
# already have a switch or variable in slot 11. Simply change the
# value in SWITCH_LEVELRANGE_OFF or LVVAR to match the slots you're
# using. Then when your player is changing rooms, change the
# level variable to whatever you wish and it will show in the
# next room.
#--------------------------------------------------------------
module LevelRange
#==============================================================
# SCRIPT SETUP - Declares customizable variables (You can change
# any of these values and the script will still run.
#==============================================================
SWITCH_LEVELRANGE_OFF = 11 # Turn this switch (default slot 11) on to stop showing the level range
LVVAR = 11 # This is the editable variable (default slot 11) that you'll change through variable actions
# - it signifies the level indication
LVFONT = "Georgia" # Text font
LVFADE = true # Fading on or off - This lets you keep it on the screen at all times if set to false
LVFADETIME = 10 # Fading time - This has no effect if LVFADE is set to false
LVWPOS = 2 # Window Position. 0 - Top Left, 1 - Bottom Left, 2 - Top Right, 3 - Bottom Right
end
#==============================================================
# Game_System - Declares secondary variables.
#==============================================================
class Game_System
attr_accessor :fadetm
attr_accessor :lvrn_x
attr_accessor :lvrn_y
alias lvrn_ini initialize
def initialize
lvrn_ini
@fadetm = 255 + 40 * LevelRange::LVFADETIME
if LevelRange::LVWPOS == 0
@lvrn_x = -300
@lvrn_y = 48
elsif LevelRange::LVWPOS == 1
@lvrn_x = -300
@lvrn_y = 272
elsif LevelRange::LVWPOS == 2
@lvrn_x = 640
@lvrn_y = 48
else
@lvrn_x = 640
@lvrn_y = 272
end
end
def lvrn_x
return @lvrn_x
end
def lvrn_y
return @lvrn_y
end
def fadetm
if @fadetm <= 0
@fadetm = 0
end
return @fadetm
end
end
#==============================================================
# Window_Base - Controls text and icon drawing.
#==============================================================
class Window_Base < Window
def nd_lvpic
lvic = Cache.system("")
end
def draw_lvname(x,y)
lvic = Cache.system("Lvname") rescue nd_lvic
cw = lvic.width
ch = lvic.height
sr_rec = Rect.new(0, 0, cw, ch)
self.contents.blt(x , y - ch + 65, lvic, sr_rec)
self.contents.font.name = LevelRange::LVFONT
self.contents.font.size = 16
self.contents.font.bold = true
self.contents.font.shadow = true
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x - 12, y + 32, 160, 32, "Level " + $game_variables[LevelRange::LVVAR].to_s,1)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x - 11, y + 31, 160, 32, "Level " + $game_variables[LevelRange::LVVAR].to_s,1)
end
end
#==============================================================
# Lvname - Declares a final class.
#==============================================================
class Lvname < Window_Base
def initialize(x , y)
super($game_system.lvrn_x, $game_system.lvrn_y, 250, WLH + 70)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
draw_lvname(10,0)
end
end
#~ #==============================================================
# Scene_Map - Does all the drawing.
#==============================================================
class Scene_Map
alias lvrn_start start
def start
@lvrn = Lvname.new($game_system.lvrn_x, $game_system.lvrn_y)
@lvrn.contents_opacity = $game_system.fadetm
if $game_switches[LevelRange::SWITCH_LEVELRANGE_OFF] == false
@lvrn.visible = true
else
@lvrn.visible = false
end
lvrn_start
end
alias lvrn_term terminate
def terminate
lvrn_term
@lvrn.dispose
end
alias lvrn_upd update
def update
lvrn_upd
$game_system.lvrn_x = @lvrn.x
$game_system.lvrn_y = @lvrn.y
if $game_switches[LevelRange::SWITCH_LEVELRANGE_OFF] == true or $game_system.fadetm <= 0
@lvrn.visible = false
else
@lvrn.visible = true
end
if LevelRange::LVWPOS == 0 or LevelRange::LVWPOS == 1
if @lvrn.x < -50
@lvrn.x += 5
elsif @lvrn.x >= -50
@lvrn.x = -50
end
else
if @lvrn.x > 400
@lvrn.x -= 5
elsif @lvrn.x <= 400
@lvrn.x = 400
end
end
@lvrn.contents_opacity = $game_system.fadetm
if LevelRange::LVFADE == true
$game_system.fadetm -= 3
end
end
alias lvrn_upd_trans_player update_transfer_player
def update_transfer_player
return unless $game_player.transfer?
@lvrn.contents_opacity = 0
lvrn_upd_trans_player
if LevelRange::LVWPOS == 0
$game_system.lvrn_x = -340
$game_system.lvrn_y = 48
elsif LevelRange::LVWPOS == 1
$game_system.lvrn_x = -340
$game_system.lvrn_y = 320
elsif LevelRange::LVWPOS == 2
$game_system.lvrn_x = 640
$game_system.lvrn_y = 48
else
$game_system.lvrn_x = 640
$game_system.lvrn_y = 320
end
@lvrn.y = $game_system.lvrn_y
@lvrn.x = $game_system.lvrn_x
$game_system.fadetm = 255 + 60 * LevelRange::LVFADETIME
@lvrn.refresh
end
end


Screenshot

Let me know if problems come up.

This post has been edited by Kilin: Mar 22 2009, 04:27 AM


--------------------
Projects List:
Spoiler:

RPG Maker VX:
Spoiler:
Alkid Legends - RPG - In Development - 20%

Game Maker:
Spoiler:
Lixies Adventures - Action Platformer - In Development - 25%
Lixim - Life Simulation - In Development - 15%
Legend of the Dark Moon - Action RPG - In Development - 5%
Code Omega - 3D Space Shooter - In Development - 15%


Playable and Finished Games:
Spoiler:


A space shoot-em-up with basic elements and a mild story. Still a work in progress, but fully playable. 85% - Just let me download the game!
- Temporary banner by BannerBreak.com
Go to the top of the page
 
+Quote Post
   
RequiemDissidia
post Mar 22 2009, 05:27 AM
Post #2


Requiem Et Reminiscence
Group Icon


Type: Spriter




not bad, it's easier with Conditional branch but that works too..


--------------------
Spoiler:
Go to the top of the page
 
+Quote Post
   
Senapho
post Mar 22 2009, 06:03 AM
Post #3


Jack in, Mega-Man!
Group Icon


Type: Designer
Alignment: True Neutral




Nice ~ ^__^.
- Sen.


--------------------


My project:

Go to the top of the page
 
+Quote Post
   
Kilin
post Mar 22 2009, 02:12 PM
Post #4



Group Icon






QUOTE
not bad, it's easier with Conditional branch but that works too..

I haven't messed around with Conditional Branch enough to know if it draws on the screen. However, I'm sure you could easily color-code the display based on what level your actor is versus the level you set for the area. For example, it could be red when ten levels over and green when ten levels under.
If people are still looking for more customization in it, let me know and I'll work with it.


--------------------
Projects List:
Spoiler:

RPG Maker VX:
Spoiler:
Alkid Legends - RPG - In Development - 20%

Game Maker:
Spoiler:
Lixies Adventures - Action Platformer - In Development - 25%
Lixim - Life Simulation - In Development - 15%
Legend of the Dark Moon - Action RPG - In Development - 5%
Code Omega - 3D Space Shooter - In Development - 15%


Playable and Finished Games:
Spoiler:


A space shoot-em-up with basic elements and a mild story. Still a work in progress, but fully playable. 85% - Just let me download the game!
- Temporary banner by BannerBreak.com
Go to the top of the page
 
+Quote Post
   
Dariathan
post Mar 22 2009, 03:16 PM
Post #5


Ignorance is Bliss, Arrogance is Blind
Group Icon


Type: Designer




this is a good idea, i like it. I think the changing colors
idea is a good idea to, one thing i would like tho is instead
of having to change the variable everytime you transer, just
have it so we only need to put something like "Lvl 1" in th map
name and then that map would be recommened Lvl1, do you
get what i'm saying? I understand if you cant do it tho. Anyways
great script, i'm definatley using it.


--------------------


Want some Mack Characters? Come here
Who wants to understand the basics behind making Tankentai skills? I do!
Go to the top of the page
 
+Quote Post
   
Kilin
post Mar 22 2009, 03:47 PM
Post #6



Group Icon






QUOTE
one thing i would like tho is instead
of having to change the variable everytime you transer, just
have it so we only need to put something like "Lvl 1" in th map
name and then that map would be recommened Lvl1

I've actually thought about doing that just by parsing out the rest of the map name. However, the only thing that kept me from doing that is the fact that it will clash with Mog's script. And the whole idea of this was to work alongside it. I'll give it a shot though, when I finish some other things.


--------------------
Projects List:
Spoiler:

RPG Maker VX:
Spoiler:
Alkid Legends - RPG - In Development - 20%

Game Maker:
Spoiler:
Lixies Adventures - Action Platformer - In Development - 25%
Lixim - Life Simulation - In Development - 15%
Legend of the Dark Moon - Action RPG - In Development - 5%
Code Omega - 3D Space Shooter - In Development - 15%


Playable and Finished Games:
Spoiler:


A space shoot-em-up with basic elements and a mild story. Still a work in progress, but fully playable. 85% - Just let me download the game!
- Temporary banner by BannerBreak.com
Go to the top of the page
 
+Quote Post
   
woratana
post Mar 23 2009, 12:41 AM
Post #7


*O* ~(>_<)~
Group Icon


Type: Coder




Good idea! ^o^b

Though, I don't like the fact that it needs new save file. D:
You might want to look into this. ^^


--------------------
Check out my new blog!!!

Go to the top of the page
 
+Quote Post
   
Kilin
post Mar 23 2009, 04:10 AM
Post #8



Group Icon






Heh, yeah. I'm working on that. But so did Mog's, if I remember correctly, and I don't get why. I know all of yours seem to work well with saved games, Wora, but this one seems to have a bit of a problem with it. Otherwise it seems to work pretty well.

QUOTE (error)
Script 'Window_Base' line 22: TypeError occurred.
no implicit conversion from nil to integer


That's the error you'd get. I'm new to scripting so why it's getting a window problem like THAT has really got me.


--------------------
Projects List:
Spoiler:

RPG Maker VX:
Spoiler:
Alkid Legends - RPG - In Development - 20%

Game Maker:
Spoiler:
Lixies Adventures - Action Platformer - In Development - 25%
Lixim - Life Simulation - In Development - 15%
Legend of the Dark Moon - Action RPG - In Development - 5%
Code Omega - 3D Space Shooter - In Development - 15%


Playable and Finished Games:
Spoiler:


A space shoot-em-up with basic elements and a mild story. Still a work in progress, but fully playable. 85% - Just let me download the game!
- Temporary banner by BannerBreak.com
Go to the top of the page
 
+Quote Post
   
MasterX8
post May 3 2009, 05:52 PM
Post #9



Group Icon


Type: Designer
Alignment: Lawful Neutral




Can you send me the map name script


--------------------


I support..
Spoiler:


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 1st August 2014 - 06:54 AM

RPGMakerVX.net is an Privacy Policy, Legal.