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] Eventer's Toolbox

Eventer's Toolbox
by Hevendor of rmxp.org, version 0.2.2

Introduction
Just a simple script to make eventing life easier for you.

Instructions/Features
Paste in the appropriate spot, above "Main" and below "Materials".
Copied from the script:
Code:
#==============================================================================
# * INSTRUCTIONS
# Remember when you had to set player coords, event coords to variables
# just to check where your events were, where rocks were etc.?
# Not anymore! Rock-pushing puzzles? Made easy!
# Use each of these commands wherever you want, though they are designed to use
# in a conditional branch event command. An example follows:
# @>Conditional Branch: $game_map.standing_on_tile?(5, 13)
#     @> Do stuff, will happen if you ARE standing on the coords 5,13
#   Else
#     @> Do the rest of stuff, will happen if you ARE NOT standing on 5,13
#------------------------------------------------------------------------------
# * COMMANDS
# $game_map.standing_on_tile?(x, y)
#   - checks if player is standing on map coordinates (x, y)
#
# $game_map.standing_on_event?(id)
#   - checks if player is standing on event (id)
#
# $game_map.adjacent_tile?(x, y, standing)
#   - checks if player is adjacent to tile (x, y).
#   - if standing = false, it will check only if you are adjacent
#   - if standing = true, it will check if you are adjacent OR standing on tile
#
# $game_map.cross_adjacent_event?(id, n)
#   - checks if player is in a cross range of event ID, where n is the radius
# of the cross. To check if player is adjacent to event, use n=1
#
# $game_map.event_adjacent_event?(id, id2, n)
#   - checks if event (id) is adjacent to event (id2), where n is the radius
# of the cross. To check if the events are directly adjacent, use n=1.
#
# $game_map.event_standing_coords?(id, x, y)
#   - checks if event (id) is standing on map coordinates (x, y).
#==============================================================================

Screenshots
N/A

Script
Code:
#==============================================================================
# ** RMVX Eventer's Toolbox
#------------------------------------------------------------------------------
# * Includes several different utilities to make eventing easier.
# 10-03-2008 (dd-mm-yyyy) © Hevendor of rmxp.org
# Version 0.2.2
# Latest update: N/A
#==============================================================================

#==============================================================================
# * INSTRUCTIONS
# Remember when you had to set player coords, event coords to variables
# just to check where your events were, where rocks were etc.?
# Not anymore! Rock-pushing puzzles? Made easy!
# Use each of these commands wherever you want, though they are designed to use
# in a conditional branch event command. An example follows:
# @>Conditional Branch: $game_map.standing_on_tile?(5, 13)
#     @> Do stuff, will happen if you ARE standing on the coords 5,13
#   Else
#     @> Do the rest of stuff, will happen if you ARE NOT standing on 5,13
#------------------------------------------------------------------------------
# * COMMANDS
# $game_map.standing_on_tile?(x, y)
#   - checks if player is standing on map coordinates (x, y)
#
# $game_map.standing_on_event?(id)
#   - checks if player is standing on event (id)
#
# $game_map.adjacent_tile?(x, y, standing)
#   - checks if player is adjacent to tile (x, y).
#   - if standing = false, it will check only if you are adjacent
#   - if standing = true, it will check if you are adjacent OR standing on tile
#
# $game_map.cross_adjacent_event?(id, n)
#   - checks if player is in a cross range of event ID, where n is the radius
# of the cross. To check if player is adjacent to event, use n=1
#
# $game_map.event_adjacent_event?(id, id2, n)
#   - checks if event (id) is adjacent to event (id2), where n is the radius
# of the cross. To check if the events are directly adjacent, use n=1.
#
# $game_map.event_standing_coords?(id, x, y)
#   - checks if event (id) is standing on map coordinates (x, y).
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :px
  attr_accessor :py
  #--------------------------------------------------------------------------
  # * Alias Definitions
  #--------------------------------------------------------------------------
  alias hev_rmvx_toolbox_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    hev_rmvx_toolbox_initialize
    @px = 0
    @py = 0
  end
  #--------------------------------------------------------------------------
  # * Player standing on map coords (x, y)?
  #--------------------------------------------------------------------------  
  def standing_on_tile?(x, y)
   if $game_player.x == x and $game_player.y == y
     return true
   else 
     return false
    end
  end
  #--------------------------------------------------------------------------
  # * Player standing on event (id)?
  #--------------------------------------------------------------------------  
  def standing_on_event?(id)
    if $game_player.x == @events[id].x && $game_player.y == @events[id].y
      return true
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
  # * Is player adjacent (or standing on) to tile (x, y)?
  #--------------------------------------------------------------------------  
  def adjacent_tile?(x, y, standing)
     @px = $game_player.x
     @py = $game_player.y
    if standing = false
     if (@px != x && @py != y) || (@px == x && @py == y)
      return false
     end
    end
    if standing = true
     if (@px != x && @py != y)
       return false
     end
    end
    if @px < x 
      if (x - @px) <= 1
        return true
      end
    end
    if @px > x 
      if (@px - x) - @px <= 1
        return true
      end
    end
    if @py > y 
      if (@py - y) <= 1
        return true
      end
    end
    if @py < y
      if (y - @py) <= 1
        return true
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Is player (n) tiles adjacent to event (id) [in a cross pattern]?
  #--------------------------------------------------------------------------  
  def cross_adjacent_event?(id, n)
     @px = $game_player.x
     @py = $game_player.y
    if (@px != @events[id].x && @py != @events[id].y) || (@px == @events[id].x && @py == @events[id].y)
      return false
    end
    if @px < @events[id].x 
      if (@events[id].x - @px) <= n
        return true
      end
    end
    if @px > @events[id].x 
      if (@px - @events[id].x) - @px <= n
        return true
      end
    end
    if @py > @events[id].y 
      if (@py - @events[id].y) <= n
        return true
      end
    end
    if @py < @events[id].y
      if (@events[id].y - @py) <= n
        return true
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Is event (id) adjacent to event (id2?)
  #--------------------------------------------------------------------------  
  def event_adjacent_event?(id, id2, n)
    if @events[id].x != @events[id2].x && @events[id].y != @events[id2].y
      return false
    end
    if @events[id].x == @events[id2].x && @events[id].y == @events[id2].y
      return false
    end
    if @events[id].x < @events[id2].x 
      if (@events[id2].x - @events[id].x) <= n
        return true
      end
    end
    if @events[id].x > @events[id2].x 
      if (@events[id].x - @events[id2].x) - @events[id].x <= n
        return true
      end
    end
    if @events[id].y > @events[id2].y 
      if (@events[id].y - @events[id2].y) <= n
        return true
      end
    end
    if @events[id].y < @events[id2].y
      if (@events[id2].y - @events[id].y) <= n
        return true
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Is event (id) standing on map coords. (x, y)?
  #--------------------------------------------------------------------------    
  def event_standing_coords?(id, x, y)
    if @events[id].x == x && @events[id].y == y
      return true
    else
      return false
    end
  end
end

Notes
Usable everywhere with credit to Hevendor.

Author's Notes
I'll be adding to this script as ideas come. Feel free to suggest your own :)

Older Versions
N/A
 
Ehm, I'm sorry, but WHAT does this Script do?, I haven't tried it, 'cause I never test stuff, when its no " This script does..."
Describtion please :)
 
Ehm, did you even bother reading the instructions..? They contain an example, each one of the commands and what it does.

Anyway

You probably know those rock-pushing puzzles where you have a bunch of rocks and have to push them onto switches. To do this on RPG maker you'll have to set a couple variables to the rock's X and Y (each one of them) and compare all the pairs of X/Y rock coordinates. That's a lot of work.

Using this script, you can just make a couple conditional branches with Script: $game_map.event_standing_coords?(id, x, y) as the conditions, where event ID is the ID of the rock, X, Y is where you want it to be. Saves you a lot of time/variables in the long run. Read the instructions for further commands. This script doesn't "do" anything, it just makes it easier for you to do stuff.
 
@_@ Dude, this is ful of win.

I could hug you, but I kinda can't.

*runs off with script*

NO MORE ANNOYING PUSH PUZZLES!!! ^_^
 
@xephyr
Glad you find it useful.

Update: minor changes. Probably insignificant but I made them anyway.

I'm working on a couple more methods, these are mainly for use in my project but I'll post them as soon as they're finished. I'm also running low on ideas, suggestions would be highly appreciated :smile:
 
@Regimos
Thanks. I'm just working with VX at the moment. Maybe when I have some free time :)

@rikuken
Copy the script into an empty project and test it yourself, if you will. What you do with each command is completely up to you.
 

Taylor

Sponsor

Am I right in thinking that:

$game_map.cross_adjacent_event?(id, n) set to a range of 3 makes
Code:
...o..
...o...
...o...
oooEooo
...o...
...o...
...o...
rather than
Code:
...o...
..ooo..
.ooooo.
oooEooo
.ooooo.
..ooo..
...o...
?

o represents areas the script checks

E represents the event.

It would be awesome if you could make an option to check a more circular range as in the second example, them I could maybe make a mouse-like pointer system (sadly with the arrows and hero) and maybe my first person adventure game~ X3
 

prepe

Member

As I have been messing around with VX, I noticed some scripts are easily just plug and play to make them work on XP, or vice versa. What I want to know is, Is this script like that?, I mean dose it work in XP, or do I have to convert it?, because I could defanetly use this in my game!
 

e

Sponsor

I've copy pasted this into VX, and it seems to work. I haven't tried all the functions, but I don't see why it wouldn't; seems pretty standard to me.
 

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