Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Waypoints VX

Waypoints VX
Ver. 1.6
By Mundane

Introduction
This is my first script. Waypoints VX is a portal system similar to that of the Diablo games. When the scene is called it gives you a list of places to go. Simple as that.

History
• 8/17/08 #2: Updated script to Version 1.6; added an optional Point Spending System and removed bugged window position option
• 8/17/08: Updated script to Version 1.5; adds MUCH simpler Waypoint addition


Features
• Simple menu design
• Pre-activated waypoints
• Activation controlled by switches
• Configurable sounds and animations
• Optional Points Spending System - allows teleporting only if you have points to spend


Script
I highly recommend downloading the demo. The events in the demo will make it easier for you to implement this script as easily as possible.
Code:
#===============================================================================
# * [VX] Waypoints VX
#   Ver. 1.6
#   By Mundane, mundane92@gmail.com
#-------------------------------------------------------------------------------
# Special thanks to:
#  • Yeyinde, for helping me improve the script
#
# History:
#  • 8/17/08 #2 - Updated script to Ver. 1.6 which added optional Points System
#                 and removed window position option
#  • 8/17/08 - Updated script to Ver. 1.5 which added easier Waypoint addition
#-------------------------------------------------------------------------------
module WayVX
#-------------------------------------------------------------------------------
# * CONFIGURATION
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Waypoint Set-Up:
#-------------------------------------------------------------------------------
# To add a Waypoint make a new line based on the following template:
# WAYPOINTS = [
#               [C, S, M, X, Y, N],
#               [C, S, M, X, Y, N]
#             ]
# •C: Corresponds to the command number. Starts at '0' and counts up.
# •W: Corresponds to the switch number that that point needs on to activate.
#     Set to '0' for pre-activated waypoints.
# •M: Corresponds to the ID of the map you are porting to.
# •X: Corresponds to the X coordinate on the map you are porting to, that you
#     want the user to appear at.
# •Y: Corresponds to the Y coordinate on the map you are pointing to, that you
#     want the user to appear at.
# •N: Sets the name of the Waypoint.
#-------------------------------------------------------------------------------
 WAYPOINTS = [ #C  S  M  X  Y     N
               [0, 0, 1, 8, 6, "Garden"],
               [1, 1, 2, 8, 6, "Plains"],
               [2, 2, 3, 8, 6, "Tundra"]
             ]
 NOSHOW = false          # Set to true if you wish unactivated points to not
                         # show instead of graying out
                         
# Point System Set-Up:
 ENABLEPTS = true        # Points enabled?
 POINTVAR = 1            # Variable assigned to points
              
# Optional Aesthetic and Audio Configuration:
 TELEPORT_SE = "/Audio/SE/Teleport"    # Name of Teleport sound in Audio/SE/
 TELEPORT_ANIM = 41                    # ID of Teleport animation in the Database
#-------------------------------------------------------------------------------
end
#-------------------------------END CONFIG--------------------------------------

#-------------------------------------------------------------------------------
# * Window_WaypointHelp
#-------------------------------------------------------------------------------
class Window_WaypointHelp < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 258, 60)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_text(4, 0, 250, 24, 'Select a Waypoint')
  end
end

#==============================================================================
# ** Window_Waypoints
#------------------------------------------------------------------------------
#  This window deals with Waypoint selection.
#==============================================================================

class Window_Waypoints < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :commands                 # command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width      : window width
  #     commands   : command string array
  #     column_max : digit count (if 2 or more, horizontal selection)
  #     row_max    : row count (0: match command count)
  #     spacing    : blank space when items are arrange horizontally
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, row_max * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index   : item number
  #     enabled : enabled flag. When false, draw semi-transparently.
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
end

#-------------------------------------------------------------------------------
# * Window_WaypointHelp
#-------------------------------------------------------------------------------
class Window_Points < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 160, 60)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_text(4, 0, 250, 24, 'Points:')
    self.contents.draw_text(70, 0, 150, 24, $game_variables[WayVX::POINTVAR].to_s)
  end
end

#===============================================================================
# ** Scene_Waypoints
#===============================================================================
class Scene_Waypoints < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #-----------------------------------------------------------------------------
  # * Start processing
  #-----------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_command_window
    @wayhelp_window = Window_WaypointHelp.new(0,0)
    if WayVX::ENABLEPTS == true
      @pts_window = Window_Points.new(258,0)
    end
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @wayhelp_window.dispose
    if WayVX::ENABLEPTS == true
      @pts_window.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window.update
    @wayhelp_window.update
    if WayVX::ENABLEPTS == true
      @pts_window.update
    end
    update_command_selection
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  # * Add your waypoints here! 
  #--------------------------------------------------------------------------
  def create_command_window
    commands = WayVX::WAYPOINTS.collect{|waypoint| waypoint[5]}
    @command_window = Window_Waypoints.new(258, commands)
    waypoint = WayVX::WAYPOINTS[@command_window.index]
    @command_window.index = @menu_index
    @command_window.y = 60
WayVX::WAYPOINTS.each do |waypoint|
   if waypoint[1] > 0 && !$game_switches[waypoint[1]]
    @command_window.draw_item(waypoint[0], false)
  end
end
  #-----------------------------------------------------------------------------
  # * Update Command Selection
  #-----------------------------------------------------------------------------
def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      waypoint = WayVX::WAYPOINTS[@command_window.index]
      if waypoint[1] > 0 && !$game_switches[waypoint[1]]
        Sound.play_buzzer
      elsif WayVX::ENABLEPTS and $game_variables[WayVX::POINTVAR] == 0
        Sound.play_buzzer
        return
      else
        if WayVX::ENABLEPTS == true
          $game_variables[WayVX::POINTVAR] -= 1
        end
        Audio.se_play(WayVX::TELEPORT_SE)    
        $game_player.animation_id = WayVX::TELEPORT_ANIM 
        $game_map.setup(waypoint[2])                  
        $game_player.moveto(waypoint[3], waypoint[4])
        $game_player.refresh
        $scene = Scene_Map.new
        RPG::BGM.fade(120)
        RPG::BGS.fade(120)
        Graphics.fadeout(30)
        Graphics.wait(40)
        Graphics.frame_count = 0
        RPG::BGM.stop
        $game_map.autoplay
      end
    end
  end
end
end


Downloads
I have a demo available for your convenience. It features all the events you'll ever need built in. If the mirrors below don't work for you, request another one and I'll put it up.
MSN SkyDrive Mirror: Download
MediaFire Mirror: Download


Screenshots
http://img520.imageshack.us/img520/7593/wayvxra1.png[/img]


Instructions
Instructions on how to add waypoints are provided in the script.

To call the Waypoint window put this line in a 'Script...' event command:
Code:
$scene = Scene_Waypoints.new

The Point Spending System only takes away points upon transfering. You will need to give the party/player points(by adding to your designated variable) on your own.

NOTE: Waypoints VX DOES NOT stop weather or reset screen tones! You must set your maps to change that up on arriving on it. Future versions may support weather and tone features.


FAQ
Q: Can I request add-ons for this script?
A: Don't PM me with requests for add-ons. If you mention it in here and I can do it - I will.

Q: Can I use the events in the demo in my games?
A: Yes. Feel free to just copy those events over to your games.


Compatibility
There are no known compatibility issues. Report any you may find here.


Credits and Usage
You can use this in any non-commercial project. If you wish to use it for a commercial project, please contact me before doing so. Please credit me if you use the script; it may be a cluster-fuck of default scripts, but I worked hard on it.

Special tanks to:
-Yeyinde, for helping me improve the script
-Enterbrain

Thanks for your interest in Waypoints VX!

Mundane
 
Instead of having a huge case statement with several repeated things, why not have a customizable hash to store the map id and coordinates?  Something like this:

Code:
WAYPOINTS = {0=>[2, 8, 6, 1], 1=>[3, 8, 6, 2], 2=>[1, 8, 6, 0]}
class Scene_Waypoints
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      waypoint = WAYPOINTS[@command_window.index]
      if waypoint[3] > 0 && !$game_switches[waypoint[3]]
        Sound.play_buzzer
        return
      else
        Audio.se_play(WayVX::TELEPORT_SE)    
        $game_player.animation_id = WayVX::TELEPORT_ANIM 
        $game_map.setup(waypoint[0])                   # Pointed Map ID
        $game_player.moveto(waypoint[1], waypoint[2])            # Pointed Map Coordinates
        $game_player.refresh
        $scene = Scene_Map.new
        RPG::BGM.fade(120)
        RPG::BGS.fade(120)
        Graphics.fadeout(30)
        Graphics.wait(40)
        Graphics.frame_count = 0
        RPG::BGM.stop
        $game_map.autoplay
      end
    end
  end
end
 
I'll give that a try and update it when I get it working. Thanks Yey!

What about the commands though. Like the s1, s2, s3 business?
 
They can also be added to the WAYPOINTS hash.  Actually, WAYPOINTS might work better as an array for this script.  Now, for adding them to the command (assuming WAYPOINTS is now an array), all you would have to do is this:

Code:
commands = WAYPOINTS.collect{|array| array[index of waypoint name]}
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top