[XP] Global Switches and Variables for RMX-OS

Started by Blizzard, January 07, 2010, 02:25:30 pm

Previous topic - Next topic

stripe103

If you mean the .dat file, I don't know what program I need to use to open it, but if I open it with NotePad, all I get is
{ii

Nothing more.

And the Script version is the newest. 1.01

Blizzard

That seems that the extension did not save the variables. Can you post your configurations?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

stripe103

Here is the RMXP script: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Global Switches and Variables for RMX-OS by Blizzard
# Version: 1.01
# Type: RMX-OS Add-on
# Date: 7.1.2010
# Date: 22.2.2010
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#  This script is to be distributed under the same terms and conditions like
#  the script it was created for: RMX-OS.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Information:
#
#   This script must be placed below RMX-OS and requires RMX-OS v1.09 or
#   higher to work properly. This script will allow to have global switches and
#   variables on your server.
#   
#   
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

if !defined?(RMXOS) || RMXOS::VERSION < 1.09
  raise 'ERROR: The "Global Switches and Variables" requires RMX-OS 1.09 or higher.'
end

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

GLOBAL_SWITCHES = [1, 2] # make sure this matches the extension configuration
GLOBAL_VARIABLES = [1, 2, 3, 4, 5, 6] # make sure this matches the extension configuration

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# Game_Temp
#==============================================================================

class Game_Temp
 
  attr_accessor :disable_global
 
end
 
#==============================================================================
# Game_Switches
#==============================================================================

class Game_Switches
 
  alias set_gswivar_later []=
  def []=(id, value)
    if !$game_temp.disable_global && GLOBAL_SWITCHES.include?(id)
      $network.send_switch(id, value)
    else
      set_gswivar_later(id, value)
    end
  end
 
end
 
#==============================================================================
# Game_Switches
#==============================================================================

class Game_Variables
 
  alias set_gswivar_later []=
  def []=(id, value)
    if !$game_temp.disable_global && GLOBAL_VARIABLES.include?(id)
      $network.send_variable(id, value)
    else
      set_gswivar_later(id, value)
    end
  end
 
end
 
#==============================================================================
# RMXOS::Network
#==============================================================================

class RMXOS::Network
 
  alias check_game_gswivar_later check_game
  def check_game(message)
    case message
    when /\AGSW(.+)\t(.+)/
      $game_temp.disable_global = true
      $game_switches[$1.to_i] = ($2 != '0')
      $game_temp.disable_global = false
      $game_map.need_refresh = true
      return true
    when /\AGVA(.+)\t(.+)/
      $game_temp.disable_global = true
      $game_variables[$1.to_i] = $2.to_i
      $game_temp.disable_global = false
      $game_map.need_refresh = true
      return true
    end
    return check_game_gswivar_later(message)
  end
 
  alias check_loading_gswivar_later check_loading
  def check_loading(message)
    result = check_loading_gswivar_later(message)
    if result
      if @messages.include?(RMXOS::LOADING_END)
        @messages.delete(RMXOS::LOADING_END)
        self.send('LGD')
      end
    else
      case message
      when /\ALGS(.+)/ # load global switches
        hash = eval($1)
        $game_temp.disable_global = true
        hash.each_key {|id| $game_switches[id] = hash[id]}
        $game_temp.disable_global = false
        return true
      when /\ALGV(.+)/ # load global variables
        hash = eval($1)
        $game_temp.disable_global = true
        hash.each_key {|id| $game_variables[id] = hash[id]}
        $game_temp.disable_global = false
        $game_map.need_refresh = true
        @messages.push(RMXOS::LOADING_END)
        return true
      end
    end
    return result
  end
 
  def send_switch(id, value)
    self.send("GSW#{id}\t#{value ? 1 : 0}")
  end
 
  def send_variable(id, value)
    self.send("GVA#{id}\t#{value}")
  end
 
end
And then the extension:: ShowHide
module RMXOS
 
  def self.load_current_extension
    return GlobalSwitchesVariables
  end
 
  module Data
    GlobalSwitchChange    = 'Client \'CLIENT\' changed switch \'ID\' to \'STATE\'.'
    GlobalVariableChange  = 'Client \'CLIENT\' changed variable \'ID\' to \'STATE\'.'
  end
 
end

#======================================================================
# module GlobalSwitchesVariables
#======================================================================

module GlobalSwitchesVariables
 
  VERSION = 1.01
  RMXOS_VERSION = 1.09
  SERVER_THREAD = false
 
  # START Configuration
  GLOBAL_SWITCHES = [1, 2] # make sure this matches the configuration in the client
  GLOBAL_VARIABLES = [1, 2, 3, 4, 5, 6] # make sure this matches the configuration in the client
  SWITCHES_FILENAME = './gswitches.dat' # filename for global switch saving
  VARIABLES_FILENAME = './gvariables.dat' # filename for global variable saving
  SERVER_DISPLAY = true # show log in command prompt screen
  LOG_FILENAME = './logs/gswivar.log' # leave empty if no log file should be created
  DELETE_LOG_ON_START = false
  # END Configuration
 
  def self.initialize
    @switches = {}
    GLOBAL_SWITCHES.each {|id| @switches[id] = false}
    if FileTest.exist?(SWITCHES_FILENAME)
      file = File.open(SWITCHES_FILENAME, 'r')
      ids = Marshal.load(file)
      file.close
      (ids & GLOBAL_SWITCHES).each {|id| @switches[id] = true}
    end
    @variables = {}
    GLOBAL_VARIABLES.each {|id| @variables[id] = 0}
    if FileTest.exist?(VARIABLES_FILENAME)
      file = File.open(VARIABLES_FILENAME, 'r')
      hash = Marshal.load(file)
      file.close
      (hash.keys & GLOBAL_VARIABLES).each {|id| @variables[id] = hash[id]}
    end
    File.delete(LOG_FILENAME) if LOG_FILENAME != '' && DELETE_LOG_ON_START && FileTest.exist?(LOG_FILENAME)
  end
 
  def self.main
    while RMXOS.server.running
      self.server_update
      sleep(0.1)
    end
  end
 
  def self.server_update
  end
 
  def self.client_update(client)
    case client.message
    when /\ALGD\Z/ # load global data
      client.send("LGS#{@switches.inspect.sub(' ') {''}}")
      client.send("LGV#{@variables.inspect.sub(' ') {''}}")
      return true
    when /\AGSW(.+)\t(.+)/ # global switch change
      id = $1.to_i
      value = ($2 != '0')
      Thread.exclusive {
        @switches[id] = value
        self.save_switches
        client.sender.send_to_all(client.message, true)
      }
      message = RMXOS::Data::GlobalSwitchChange.sub('CLIENT', client.player.username).sub('ID', id.to_s).sub('STATE', value.to_s)
      self.log(message)
      return true
    when /\AGVA(.+)\t(.+)/ # global variable change
      id = $1.to_i
      value = $2.to_i
      Thread.exclusive {
        @variables[id] = value
        self.save_variables
        client.sender.send_to_all(client.message, true)
      }
      message = RMXOS::Data::GlobalVariableChange.sub('CLIENT', client.player.username).sub('ID', id.to_s).sub('STATE', value.to_s)
      self.log(message)
      return true
    end
    return false
  end
 
  def self.save_switches
    ids = @switches.keys.find_all {|id| @switches[id]}
    file = File.open(SWITCHES_FILENAME, 'w')
    Marshal.dump(ids, file)
    file.close
  end
 
  def self.save_variables
    hash = {}
    @variables.each_key {|id| hash[id] = @variables[id] if @variables[id] != 0}
    file = File.open(VARIABLES_FILENAME, 'w')
    Marshal.dump(hash, file)
    file.close
  end
 
  def self.log(message)
    puts message if SERVER_DISPLAY
    if LOG_FILENAME != ''
      file = File.open(LOG_FILENAME, 'a')
      file.write(message + "\n")
      file.close
    end
  end
 
end

Blizzard

I'm sorry, I'm unable to look into the problem now. Your configuration seems fine and the file to which the server saved the the global data seems to be ok as well so the problem is probably with the plugin or the extension or RMX-OS.
I hope you can continue to work on your game for a few weeks until I can look into the problem and fix it.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

stripe103

July 01, 2010, 01:09:44 pm #24 Last Edit: July 01, 2010, 01:11:00 pm by stripe103
Sure I can. The only thing that I currently need the global variables script is for the global tint that I have made. I've made so that every moderator or administrator can change the tint through the global variables and a parallel process event on each map. So that is the only thing that I currently need that for. I'll probably find out more later, but we'll see.
Oh, and I thought that you had retired from this. :???: But I'm glad it is you who are answering the question and not someone else.   :)

Blizzard

I promised that I will finish a few things regarding RMX-OS regardless of my retirement.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

stripe103

Oh. Yea that is a good idea. But when you have finished those things, please teach someone else about RMX-OS so that we even after you're gone can get support about it.:P

Unleashed


ojp2010

I am having a problem, not an error however.

Here are the scripts I am using and their order.

Spoiler: ShowHide

MAW 1.2
Mouse Map Menu
Skill Shop
Advance GameOver Script
Final Fantasy Tactics Advance Shop System
MOG - Location_Name
MOG - Treasure_Name
MOG - Item Limit
Ton 0f Addons (1)
Ton 0f Addons (2)
Ton 0f Addons (3)
RMX-OS Options
RMX-OS Script
Global Switches and Variables
Versioning
Blizz ABS (1)
Blizz ABS (2)
Blizz ABS (3)
ABS HUD made
Blizz ABS Controller
Critical Sounds for ABS
Auto-Targeting for ABS
Advanced Time and Environment
Global Day-Night System
Mouse Controller
Mouse Controller Enhancement
Mouse Drop Down Menu
RMX-OS Main


My problem is that whenever I open a Scene, rather Scene_Item or Scene_Equip, even shop interfaces Switches and Variables are change to from true back to false automatically. Basically, reseting all my events that aren't using self-switches. I didn't know where to post the my problem I am sorry if this isn't the best place. Thank you for any help.

stripe103

Seems as the same problem I have. As Blizz said earlier, he i looking into it.

ojp2010

Quote from: stripe103 on August 31, 2010, 10:37:37 am
Seems as the same problem I have. As Blizz said earlier, he i looking into it.


Ah, I see. Thanks. I need to troll more to find out if someone has already addressed my issues. lol :)

Blizzard

I tried looking into this, but I couldn't reproduce the problem.

Try turning on message log on the server and reproduce it yourself, then post the message log. Maybe I can figure out what's going on if I see the communication log that went on between server and client.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

stripe103

Well, I can't test it right now as my server is broken and I don't know how long it will take to get it back online again. But before when I used this script and tried to change a global variable, it said on the server that I set it to 0 or False even if I turned it on. So it isn't like it changes it to 1 or true and then change back. It just resets it. Or something like that. But I'll try to get the server running as fast as I can.

Blizzard

Keep in mind that it tells you the ID of the switch and the value it was set to. Immediately after that the data is saved into the files.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ojp2010

Mine has seemed to worked it's self out and is functioning fine now. I don't know what I did. :)

stripe103

Maybe it is a problem with the server machine itself. Or the network.

Blizzard

Network shouldn't cause a problem. At least not in the traditional sense. If the network is down and the connection is down, the game should stop responding completely (you should get a disconnection message).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ojp2010

Everything is working very well with the script, however, I have run into a small problem. I have a quest in my game where players need to collect flowers for NPC. So I made an event, the following:

Page 1 > Action Touch
Change Item: +1 [Flower]
Control Switch: 0001 Flower ON

Page 2 > Parallel Process > Control Switch 0001 Flower
Wait: 20
Control Switch 0001 Flower OFF

The event works however when looking at the server log after a player clicks on the flower, I am using Mouse Controller, the flower is set to true. But the event doesn't go away in the Map Scene. When I click on it again it is set to true again then disappears for the 20 then reappears and it set to true again. So bacially a player has to click it twice before it will "despawn" giving the player a chance to collect two flowers from one "node". Can anyone help me with this? I don't want them to be able to do that just one click and one flower.

Blizzard

I don't think you did this right if you need to click twice or the script utilizing the mouse controller doesn't work very well. Try removing RMX-OS for the time being and see if it works normally if you don't have RMX-OS installed.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ojp2010

I tested it, I am using blizzard's (your) mouse controller script, and the event works fine with your script. I am assuming it is either the Enchance mouse controller and mouse controller drop down menu by Nathmatt is causing the problem.

Here are both scripts, if anyone has any ideas.

Enhance mouse controller
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Mouse Controller Enhancement Script by Nathmatt
# Version: 1.44
# Type: Add On
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Instrutions:
#
#  To use the event effects in this script you will need to name the following.
#
#  defenitions
#  w    = the events width must be atleast 1
#  h    = the events height must be atleast 1
#  d    = 2 down, 4 left 6, right, or 8 up
#  right click to acess an events command list
#
#  \direction[d]          If an event has no graphic or isn't direction specific
#                         they must be named this d as the open direction
#
#  \commands[w,h]         This will create a command list for each page with the
#                         name of the first avalible comment
#
#  \curser[w,h,graphic]   This will change the graphic of the curser while
#                         over that event
#
#  \auto[w,h]             This will start the event as soon as you click it
#
#  \door[w,h,id]          This will run the pages of an event as the following
#                         id is the item id needed to unlock the door
#                         first   page when door is locked
#                         secound page when unlocking the door
#                         third   page any time after being unlocked
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Script Calls:
#
#  $MCES.disabled = true/false           whether or not this script is disabled
#
#  $MCES.movement_disabled = true/false  whether or not movement is disabled
#
#  $MCES.pick_up(id)                     is the id of the item that is picked up
#
#  $MCES.drop                            drops the item
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module Mouse_Controller_Enhancement_Script
 
  Version = 1.44
 
  module Config
    Cant_go  = 7                      # The terrain tag for unreachable locations
    Size     = 20                     # The size of the event name text
    Color    = Color.new(0,0,160,255) # The color of the event name text
    Grab     = false                  # false or the graphic for when you have
                                      # an item in hand
  end
  #============================================================================
  # ** Processor
  #----------------------------------------------------------------------------
  #  This class performs the mouse processing.
  #============================================================================
  class Processor
   
    attr_accessor :disabled,:movement_disabled,:wait
    attr_reader   :event_start,:item
   
    def initialize
      @disabled = false
      @movement_disabled = false
      @event_start = false
      @unlock = []
      @wait = 5
    end
   
    def update
      return if @disabled
      if !$scene.is_a?(Scene_Map)
        @wait = 5
        return
      end
      @int = $game_system.map_interpreter
      @wait -= 1 if @wait > 0
      @x,@y = $mouse.pos
      if Input.trigger?(Input::Key['Mouse Right']) &&
          !$game_temp.message_window_showing && @wait == 0
        @wait = 5
        check_right
      elsif Input.trigger?(Input::Key['Mouse Left']) &&
          !$game_temp.message_window_showing && @wait == 0
        @wait = 5
        check_left
      end
      force_moving if !$game_player.moving?
      @commands.update if @commands != nil
      check_mouse
      check_item
      check_finished
      get_path
    end
   
    def check_left
      check_events_left
      check_tile
      check_command
    end
   
    def check_right
      check_events_right
    end
   
    def check_finished
      return if @request == nil
      if $game_player.x == @request.tx &&
          $game_player.y == @request.ty
        if @id != nil
          turn_toward_event
          @event_start = true
          $game_map.events[@id].start
          @event_start = false
        end
        @result = nil
        @get_path = false
        @id = nil
        @request = nil
      end
     
    end
   
    def check_events_left
      $game_map.events.each_value{|event|
      check_auto(event)
      check_door(event)
      check_event(event)}
    end
   
    def check_command
      return if @commands == nil || @command_event == nil
      if @commands.indexes >= 0 && @commands.index >= 0
        event = @command_event
        i = @commands.indexes
        @int.setup(event.rpg_event.pages[i].list,event.id)
      end
      @commands.dispose
      @commands = nil
      @movement_disabled = false
    end
       
     
   
    def check_commands(event)
      return if $game_map.commands[event.id] == nil || @commands != nil
      if event.x == @x && event.y == @y || get_size(event)
        @commands = Event_Command.new(event.commands)
        @commands.x = event.screen_x
        @commands.y = event.screen_y
        @commands.z = 5000
        @command_event = event
        @movement_disabled = true
      end
    end
     
   
    def check_events_right
      $game_map.events.each_value{|event|
      check_commands(event)}
    end
     
    def check_auto(event)
      return if event.character_name == '' || !$game_map.auto[event.id]
      if event.x == @x && event.y == @y || get_size(event)
        @event_start = true
        event.start
        @event_start = false
      end
    end
   
    def check_event(event)
      return if $game_map.auto[event.id] || @movement_disabled
      if event.x == @x && event.y == @y
        @id = event.id
        @d = ($game_map.event_direction[@id] != nil ?
          $game_map.event_direction[@id]: $game_map.events[@id].direction)
        case @d
        when 2 then @y += 1
        when 4 then @x -= 1
        when 6 then @x += 1
        when 8 then @y -= 1
        end
        request_path(@x, @y)
        @result = nil
        @get_path = true
      end
    end
   
    def check_tile
      return if @get_path || !$game_map.passable?(@x,@y,0) ||
                @movement_disabled || check_terrain_tag || get_size
      request_path(@x, @y)
      @result = nil
      @get_path = true
    end
   
    def check_door(event)
      return if $game_map.door[event.id] == nil
      if $game_map.door[event.id] == @item.id
        @int.setup(event.rpg_event.pages[1].list,event.id)
        $game_party.gain_item(@item.id, -1)
        change_graphic
        @unlock[event.id] = true
      elsif @unlock[id]
        @int.setup(event.rpg_event.pages[2].list,event.id)
      else
        @int.setup(event.rpg_event.pages[0].list,event.id)
      end
      return
    end
   
    def check_mouse
      $game_map.events.each_value{|event|
      if @x == event.x && @y == event.y || get_size(event)
        $mouse.change_graphic($game_map.mouse_over_icons[event.id])
        check_message(event)
      else
        $mouse.change_graphic
      end}
     
    end
   
    def check_message(event)
      if $game_map.msg[event.id] != nil
        if @sprite == nil || @map != $game_map.map_id || @last_id != event.id
          @map = $game_map.map_id
          @last_id = event.id
          @sprite = Sprite.new
          @sprite.z = 1000
          @sprite.bitmap = Bitmap.new(640,32)
          @sprite.bitmap.font.size = Config::Size
          @sprite.bitmap.font.color = Config::Color
          @w = @sprite.bitmap.text_size($game_map.msg[id]).width
          h = @sprite.bitmap.text_size($game_map.msg[id]).height
          @sprite.bitmap.draw_text(0,0,@w,h,$game_map.msg[id].to_s)
        end
        @sprite.x = $game_map.events[id].screen_x - (@w / 2)
        @sprite.y =  $game_map.events[id].screen_y - 64
      elsif @sprite != nil
        @sprite.dispose
        @sprite = nil
      end
    end
 
   
    def check_item
      if @item != nil
        if @cursor == nil
          @cursor = Sprite.new
          @cursor.z = 1000000
          @cursor.bitmap = RPG::Cache.icon(@item.icon_name)
        end
        @cursor.x , @cursor.y = $mouse.position
        @cursor.x -= 5
        @cursor.y += 5
      elsif @cursor != nil
        @cursor.dispose
        @cursor = nil
      end
    end
   
    def check_terrain_tag
      if $game_map.terrain_tag(@x, @y) == Config::Cant_go
        return true
      end
    end
   
    def get_size(event = nil)
      if event == nil
        $game_map.events.each_value{|event|
        return $game_map.size[event.id] != nil &&
               $game_map.size[event.id]['X'].include?(@x) &&
               $game_map.size[event.id]['Y'].include?(@y)}
      end
      return $game_map.size[event.id] != nil &&
             $game_map.size[event.id]['X'].include?(@x) &&
             $game_map.size[event.id]['Y'].include?(@y)
    end
   
    def get_path
      if @get_path && @result == nil
        @result = find_path
      end
    end
     
    def pick_up(id)
      @item = $data_items[id]
      $mouse.change_graphic(Config::Grab) if Config::Grab != false
    end
   
    def drop
      @item = nil
      $mouse.change_graphic
    end
   
    def force_moving
      return if @result == nil || @result == []
      $network.send_player_data if $network != nil
      case @result[0][0]
      when 2 then $game_player.move_down
      when 4 then $game_player.move_left
      when 6 then $game_player.move_right
      when 8 then $game_player.move_up
      end
      @result.shift
    end
   
    def turn_toward_event
      case @d
      when 2 then $game_player.turn_up
      when 4 then $game_player.turn_right
      when 6 then $game_player.turn_left
      when 8 then $game_player.turn_down
      end
    end
   
   
    def request_path(x, y = nil)
      # if request does not exist yet
      if x != nil && y != nil && @request == nil
        # add request
        @request = PathRequest.new(x, y)
      end
    end
 
    def find_path
      char = $game_player
      # get pixel movement rate
      pix = 1
      # use request
      request = @request
      # if no nodes to test
      if request.open.size == 0
        # abort testing for this character
        @request = nil
        # stop execution
        return []
      end
      # found
      found = false
      # find minimal key
      key = request.open.keys.min {|a, b|
      Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>
      Math.hypot(b[0] - request.tx, b[1] - request.ty)}
      # this node is now logged as checked
      request.closed[key[0], key[1]] = request.open[key]
      # remove this node from the pending array
      request.open.delete(key)
      # iterate through all possible directions with relative offsets
      pathDirs = [[0, 1, 2], [-1, 0, 4], [1, 0, 6], [0, -1, 8]]
      pathDirs.each {|dir|
      # coordinates of new position
      kx, ky = key[0] + dir[0], key[1] + dir[1]
      # if new coordinates are destination
      if kx == request.tx && ky == request.ty
        # the new node was checked
        request.closed[kx, ky] = dir[2]
        # path was found
        found = true
        # stop checking
        break
      # if new node not checked yet and coordinates are passable
      elsif request.closed[kx, ky] == 0 &&
        char.passable?(key[0] * pix, key[1] * pix, dir[2])
        # add new node to be checked
        request.open[[kx, ky]] = dir[2]
      end}
      # stop execution except if found path
      return nil unless found
      # backtrack the path
      result = request.backtrack
      # finish testing for this character
      return result
    end
   
  end
 
  class PathRequest
   
    # setting all accessible variables
    attr_reader :open
    attr_reader :closed
    attr_reader :sx
    attr_reader :sy
    attr_reader :tx
    attr_reader :ty
   
    def initialize(tx, ty)
      a = $game_player
      @sx, @sy, @tx, @ty = a.x, a.y, tx, ty
      @x_off, @y_off = a.x - @sx, a.y - @sy
      @open = {[@sx, @sy] => -1}
      @closed = Table.new($game_map.width, $game_map.height)
    end
   
    def backtrack
      pix = 1
      tdirs = [[0, true], [1, true], [2, true], [3, true], [4, true], [5, true],
          [6, true], [7, true], [8, true], [9, true]]
      dirOffsets = [[0, 0], [-1, 1], [0, 1], [1, 1], [-1, 0], [0, 0], [1, 0],
                [-1, -1], [0, -1], [1, -1]]
      cx, cy, x, y, result = @tx, @ty, 0, 0, []
      loop do
        cx, cy = cx - x, cy - y
        break if cx == @sx && cy == @sy
        pix.times {result.unshift(tdirs[@closed[cx, cy]])}
        x, y = dirOffsets[@closed[cx, cy]]
      end
      return result
    end
 
  end
   
end

class Mouse
 
  def pos
    return if $game_map.display_x == nil
    x, y = self.position
    x = ( x + $game_map.display_x / 4) / 32
    y = ( y + $game_map.display_y / 4) / 32
    return x, y
  end
 
  def change_graphic(graphic = nil)
    if graphic != nil
      @cursor.bitmap = RPG::Cache.picture(graphic)
      @graphic = graphic
    elsif @cursor.bitmap != RPG::Cache.picture(MOUSE_ICON)
      @cursor.bitmap = RPG::Cache.picture(MOUSE_ICON)
    end
  end
   
end

class Event_Command < Window_Command
 
  def initialize(commands)
    @size = 0
    @main_commands = commands
    @array = []
    commands.each{|command|
    @array.push(command) if command != nil
    @size = (commands.size * 32) if (commands.size * 32) > @size}
    super(@size,@array)
  end
 
  def indexes
    return @main_commands.index(@array[self.index])
  end
 
end
   

class Game_Event < Game_Character
 
  attr_reader :first
 
  alias page_name initialize
  def initialize(m,e)
    @first = {}
    page_name(m,e)
  end
 
  def start
    return if @trigger == 0 && !$MCES.event_start
    if @list.size > 1
      @starting = true
    end
  end
 
  def rpg_event
    return @event
  end
 
  def commands
    com = []
    @event.pages.each{|page|
    page.list.each{|list|
    @last_list = list if @last_list == nil
    if list.code == 108
      if check_condition(@last_list)
        com[@event.pages.index(page)] = list.parameters[0]
      end
    end
    @last_list = list}}
    return com
  end
 
  def check_condition(list)
    return false if list.code == 411 && @result
    return true if list.code != 111
    result = false
    par = list.parameters
    case par[0]
    when 0
      result = ($game_switches[par[1]] == (par[2] == 0))
    when 1
      value1 = $game_variables[par[1]]
      value2 = (par[2] == 0 ? par[3] : $game_variables[par[3]])
      case par[4]
      when 0 
        result = (value1 == value2)
      when 1 
        result = (value1 >= value2)
      when 2 
        result = (value1 <= value2)
      when 3 
        result = (value1 > value2)
      when 4 
        result = (value1 < value2)
      when 5 
        result = (value1 != value2)
      end
    when 2 
      if @id > 0
        key = [$game_map.map_id, @id, par[1]]
        if par[2] == 0
          result = ($game_self_switches[key] == true)
        else
          result = ($game_self_switches[key] != true)
        end
      end
    when 3 
      if $game_system.timer_working
        sec = $game_system.timer / Graphics.frame_rate
        if par[2] == 0
          result = (sec >= par[1])
        else
          result = (sec <= par[1])
        end
      end
    when 4 
      actor = $game_actors[par[1]]
      if actor != nil
        case par[2]
        when 0 
          result = ($game_party.actors.include?(actor))
        when 1
          result = (actor.name == parameters[3])
        when 2 
          result = (actor.skill_learn?(parameters[3]))
        when 3 
          result = (actor.weapon_id == parameters[3])
        when 4 
          result = (actor.armor1_id == par[3] || actor.armor2_id == par[3] ||
                    actor.armor3_id == par[3] || actor.armor4_id == par[3])
        when 5 
          result = (actor.state?(par[3]))
        end
      end
    when 5 
      enemy = $game_troop.enemies[par[1]]
      if enemy != nil
        case par[2]
        when 0 
          result = (enemy.exist?)
        when 1 
          result = (enemy.state?(par[3]))
        end
      end
    when 6 
      character = get_character(par[1])
      if character != nil
        result = (character.direction == par[2])
      end
    when 7 
      if parameters[2] == 0
        result = ($game_party.gold >= par[1])
      else
        result = ($game_party.gold <= par[1])
      end
    when 8 
      result = ($game_party.item_number(par[1]) > 0)
    when 9 
      result = ($game_party.weapon_number(par[1]) > 0)
    when 10 
      result = ($game_party.armor_number(par[1]) > 0)
    when 11 
      result = (Input.press?(par[1]))
    when 12 
      result = eval(par[1])
    end
    @result = result
    return result
  end
 
end

module Input
 
  class << Input
    alias update_mouse_enhancement_later update
  end
 
  def self.update
    $MCES.update
    update_mouse_enhancement_later
  end
 
end

$MCES = Mouse_Controller_Enhancement_Script::Processor.new

class Game_Map
  attr_reader   :map
  attr_reader   :mouse_over_icons
  attr_reader   :event_direction
  attr_reader   :commands
  attr_reader   :msg
  attr_reader   :auto
  attr_reader   :info
  attr_reader   :door
  attr_reader   :size
  attr_accessor :event_index
 
  alias setup_mouse_path_finder_later setup
  def setup(map_id)
    setup_mouse_path_finder_later(map_id)
    check_names
  end
 
  def check_names
    @mouse_over_icons = []
    @event_direction  = []
    @commands = []
    @event_index = []
    @msg  = []
    @auto = []
    @door = []
    @size = []
    $game_map.events.each_key {|i|
    check_event_names(i) if $game_map.events[i] != nil}
  end
 
  def check_event_names(event_id)
    event = @map.events[event_id]
    if event.name.clone.gsub!(/\\[Cc]ommands\[([\d, ]+)\]/) {"#[$1]"}
      array = eval("[#{$1}]")
      @commands[event_id] = true
    end
    if event.name.clone.gsub!(/\\[Cc]urser\[([\S, ]+)\]/) {"#[$1]"}
      array = eval("[#{$1}]")
    end
    if event.name.clone.gsub!(/\\[Mm]sg\[(.+?)\]/) {"#[$1]"}
      @msg[event_id] = $1.to_s
    end
    if event.name.clone.gsub!(/\\[Dd]irection\[(\d)\]/) {"#[$1]"}
      @event_direction[event_id] = $1.to_i
    end
    if event.name.clone.gsub!(/\\[Aa]uto\[([\d, ]+)\]/) {"#[$1]"}
      array = eval("[#{$1}]")
      @auto[event_id] = true
    elsif event.name.clone.gsub!(/\\[Dd]oor\[([\d, ]+)\]/) {"#[$1]"}
      array = eval("[#{$1}]")
      @door[event_id] = array[2]
    end
    if array != nil
      @size[event_id] = {}
      @size[event_id]['X'] = []
      @size[event_id]['Y'] = []
      sx = event.x - ((array[0] - 1) / 2)
      sy = event.y - (array[1] - 1)
      ex = ((array[0] - 1) / 2) + event.x
      ey = event.y
      (sx..ex).each {|i| @size[event_id]['X'].push(i)}
      (sy..ey).each {|i| @size[event_id]['Y'].push(i)}
    end
   
  end
 
end

if $network != nil
 
  class Scene_Map
   
    alias mces_create_trade_windows create_trade_windows
    def create_trade_windows
      $MCES.movement_disabled = true
      mces_create_trade_windows
    end
 
    alias mces_dispose_trade_windows dispose_trade_windows
    def dispose_trade_windows
      $MCES.movement_disabled = false
      mces_dispose_trade_windows
    end
   
  end
 
end


Mouse Controller Drop Down Menu

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Character Drop Down Menu by Nathmatt
# Version: 1.15
# Type: Misc System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Character_Drop_Down_Menu
 
  def initialize
    username = ''
    @mini_list_array = ['Add Buddy','Trade']
    @mini_list_array.insert(1,'Add Party') if $blizzabs_rmxos != nil
    if $network.guildleader == $network.username
      @mini_list_array.insert(0,'Guild Invite')
    end
    @mini_list_array.push('Kick','Ban') if $network.usergroup > 0
    @confirm_window = Window_Confirm.new
    @mini_list = Window_Mini_List.new(@mini_list_array)
    @mini_list.visible = false
    @wait = 0
  end

  def update
    @wait -= 1 if @wait > 0
    if Input.trigger?(Input::Key['Mouse Right'])
      return if @wait != 0
      @mx,@my = $mouse.pos
      @sx,@sy = $mouse.position
      @player_username = $network.check_player(@mx,@my)
      @players_info = $network.get_player(@mx,@my)
      if @player_username != nil
        @mini_list.visible = true
        @mini_list.active = true
        @mini_list.x = @sx
        @mini_list.y = @sy
        $MCES.disabled = true
      end
      @wait = 5
    end
   
    if @mini_list.active
      @mini_list.update
      if Input.trigger?(Input::Key['Mouse Left'])
        return if @wait != 0
        if @mini_list.index >= 0
          @confirm_window.set_commands(@mini_list.item,@player_username)
        end
        @mini_list.visible = false
        @mini_list.active = false
        @wait = 5
      end
    end
   
    if @confirm_window.active
      @confirm_window.update
      if Input.trigger?(Input::Key['Mouse Left'])
        return if @wait != 0
        case @confirm_window.index
        when 0
          case @mini_list.item
          when 'Add Buddy'
            $network.command_buddy_add(@player_username)
          when 'Trade'     
            $network.command_trade_request(@player_username)
          when 'Guild Invite'
            $network.command_guild_invite(@player_username)
          when 'Kick'
            $network.command_kick_player(@player_username)
          when 'Ban'
            $network.command_ban_player(@player_username)
          when 'Add Party'
            $network.command_party_invite(@player_username)
          end
          @confirm_window.visible = false
          @confirm_window.active = false
        else
          @confirm_window.visible = false
          @confirm_window.active = false
        end
        $MCES.disabled = false
        $MCES.wait = 5
        @wait = 5
      end
    end
   
  end
   
end
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
 
  alias character_drop_down_menu_main main
  def main
    @mini_menu = Character_Drop_Down_Menu.new
    character_drop_down_menu_main
  end
 
  alias character_drop_down_menu_update update
  def update
    @mini_menu.update
    character_drop_down_menu_update
  end
 
end
#==============================================================================
# Mouse
#==============================================================================
class Mouse
 
  attr_accessor :cursor
 
  def pos
    x, y = self.position
    x = ( x + $game_map.display_x / 4) / 32
    y = ( y + $game_map.display_y / 4) / 32
    return x, y
  end
   
end
#==============================================================================
# Window_list
#==============================================================================
class Window_Mini_List < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(list)
    super(476, 175, 104, 300)
    @list = list
    @column_max = 1
    refresh
    self.index = 0
    self.opacity = 0
    self.active = false
    self.z = 10000
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index] if self.index >= 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    @list.each {|i| @data.push(i)}
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
      @data.each_index {|i| draw_item(i)}
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = index % 1 * (288 + 32)
    y = index / 1 * 32
    self.contents.font.size = 16
    self.contents.draw_text(x, y, width - 32, 32, @data[index].to_s, 1)
  end
end
#==============================================================================
# Window_Confirm
#==============================================================================
class Window_Confirm < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(100, 100, 300, 150)
    @data = ['Yes','No']
    @column_max = 2
    @command = nil
    @user = nil
    refresh
    self.index = 0
    self.opacity = 0
    self.active = false
    self.visible = false
    self.z = 10000
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index] if self.index >= 0
  end
  #--------------------------------------------------------------------------
  # * reset
  #--------------------------------------------------------------------------
  def set_commands(command,user)
    @command = command
    @user = user
    self.visible = true
    self.active  = true
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, 20 + row_max * 32)
      self.contents.font.size = 16
      self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
      self.contents.draw_text(0,0,width,20,
      'Are you sure you want to '+ @command.to_s + ' ' + @user.to_s)
      @data.each_index {|i| draw_item(i)}
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = index * (width - 32) / 2
    self.contents.draw_text(x, 20, (width - 32) / 2, 32, @data[index].to_s, 1)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(self.index * (width - 32) / 2, 25,
     (width - 32) / 2 , 20)
    end
  end
end
#============================================================================
# RMXOS::Network
#============================================================================
class RMXOS::Network
  def check_player(x,y)
    @players.any? {|key, value|
    return value.username if value.x == x && value.y == y}
    return nil
  end
  def get_player(x,y)
    if $blizzabs_rmxos != nil
      @players.any? {|key, value|
      return value.battler if value.x == x && value.y == y}
    end
    return nil
  end
end
# Load the network
$network = RMXOS::Network.new