Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Easy Mouse Move System for RPG MAKER XP, One Script for moving with click of mouse
skaterdoggy
post Aug 6 2008, 11:17 PM
Post #1


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Easy Mouse Move System


I see at forum with rpg maker xp don't exist script for moving with mouse...i see one but i very very hard to use them;)

i want to show all scripts for moving with mouse!(EASY)

Create 4 new scripts for them below main!


Now Follow This Scripts

Guedez Mouse Use System
CODE
#==================================================================
# GMUS Guedez Mouse Use System
# Version: 1.0
# Released: 26/5/2006 Last Update: 1/6/2006
# Thx to: Cadafalso, Near Fantastica, and some guys from asylum!
# EDITED BY TSUNOKIETTE (to get neccesary parts only)
#==================================================================

$getCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'V')

class Mouse_Coordinates
  
  attr_reader :x
  attr_reader :y
  
  def initialize
    @x = get_pos('x')
    @y = get_pos('y')
  end
  
  def update
    @x = get_pos('x')
    @y = get_pos('y')
  end
  
#==============================Thx to: Cadafalso===================
  def get_pos(coord_type)
    lpPoint = " " * 8 # store two LONGs
    $getCursorPos.Call(lpPoint)
    x,y = lpPoint.unpack("LL") # get the actual values
    if coord_type == 'x'
      return x
    elsif coord_type == 'y'
      return y
    end
  end
#==================================================================

end





Keyboard Script
CODE
#======================================
  # ? Keyboard Script
  #---------------------------------------------------------------------------
  # ?By: Cybersam
  #   Date: 25/05/05
  #   Version 4
  # EDITED BY TSUNOKIETTE (to get neccesary parts only)
  #======================================
  
  module Kboard
   #--------------------------------------------------------------------------
   $RMouse_BUTTON_L = 0x01        # left mouse button
   $RMouse_BUTTON_R = 0x02        # right mouse button
   $RMouse_BUTTON_M = 0x04        # middle mouse button
   $RMouse_BUTTON_4 = 0x05        # 4th mouse button
   $RMouse_BUTTON_5 = 0x06        # 5th mouse button
   #--------------------------------------------------------------------------
   GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
   GetKeyboardState = Win32API.new("user32","GetKeyState",['i'],'i')
   GetSetKeyState = Win32API.new("user32","SetKeyboardState",['i'],'i')
   #--------------------------------------------------------------------------
   module_function
   #--------------------------------------------------------------------------
   def keyb(rkey)
      if GetKeyState.call(rkey) != 0
        return 1
      end
      return 0
   end
    #--------------------------------------------------------------------------
   def keyboard(rkey)
     GetKeyState.call(rkey) & 0x01 == 1  #
   end
   #--------------------------------------------------------------------------
   def key(rkey, key = 0)
     GetKeyboardState.call(rkey) & 0x01 == key #
   end
  end






Path Finding
CODE
#==============================================================================
#  Path Finding
#==============================================================================
# Near Fantastica
# Version 1
# 29.11.05
#==============================================================================
# Lets the Player or Event draw a path from an desonation to the source. This
# method is very fast and because the palthfinding is imbeded into the Game
# Character the pathfinding can be inturputed or redrawn at any time.
#==============================================================================
# Player :: $game_player.find_path(x,y)
# Event Script Call :: self.event.find_path(x,y)
# Event Movement Script Call :: self.find_path(x,y)
#-----
# SDK DEPENDANCY REMOVED BY TSUNOKIETTE (SUE ME)
#==============================================================================
  class Game_Character
    #--------------------------------------------------------------------------
    alias nf_pf_game_character_initialize initialize
    alias nf_pf_game_character_update update
    #--------------------------------------------------------------------------
    attr_accessor :map
    attr_accessor :runpath
    #--------------------------------------------------------------------------
    def initialize
      nf_pf_game_character_initialize
      @map = nil
      @runpath = false
    end
    #--------------------------------------------------------------------------
    def update
      run_path if @runpath == true
      nf_pf_game_character_update
    end
    #--------------------------------------------------------------------------
    def run_path
      return if moving?
      step = @map[@x,@y]
      if step == 1
        @map = nil
        @runpath = false
        return
      end
      dir = rand(2)
      case dir
      when 0
        move_right if @map[@x+1,@y] == step - 1 and step != 0
        move_down if @map[@x,@y+1] == step - 1 and step != 0
        move_left if @map[@x-1,@y] == step -1 and step != 0
        move_up if @map[@x,@y-1] == step - 1 and step != 0
      when 1
        move_up if @map[@x,@y-1] == step - 1 and step != 0
        move_left if @map[@x-1,@y] == step -1 and step != 0
        move_down if @map[@x,@y+1] == step - 1 and step != 0
        move_right if @map[@x+1,@y] == step - 1 and step != 0
      end
    end
    #--------------------------------------------------------------------------
    def find_path(x,y)
      sx, sy = @x, @y
      result = setup_map(sx,sy,x,y)
      @runpath = result[0]
      @map = result[1]
      @map[sx,sy] = result[2] if result[2] != nil
    end
    #--------------------------------------------------------------------------
    def clear_path
      @map = nil
      @runpath = false
    end
    #--------------------------------------------------------------------------
    def setup_map(sx,sy,ex,ey)
      map = Table.new($game_map.width, $game_map.height)
      map[ex,ey] = 1
      old_positions = []
      new_positions = []
      old_positions.push([ex, ey])
      depth = 2
      depth.upto(100){|step|
        loop do
          break if old_positions[0] == nil
          x,y = old_positions.shift
          return [true, map, step] if x == sx and y+1 == sy
          if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
            map[x,y + 1] = step
            new_positions.push([x,y + 1])
          end
          return [true, map, step] if x-1 == sx and y == sy
          if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
            map[x - 1,y] = step
            new_positions.push([x - 1,y])
          end
          return [true, map, step] if x+1 == sx and y == sy
          if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
            map[x + 1,y] = step
            new_positions.push([x + 1,y])
          end
          return [true, map, step] if x == sx and y-1 == sy
          if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
            map[x,y - 1] = step
            new_positions.push([x,y - 1])
          end
        end
        old_positions = new_positions
        new_positions = []
      }
      return [false, nil, nil]
    end
  end
  
  class Game_Map
    #--------------------------------------------------------------------------
    alias pf_game_map_setup setup
    #--------------------------------------------------------------------------
    def setup(map_id)
      pf_game_map_setup(map_id)
      $game_player.clear_path
    end
  end
  
  class Game_Player
    def update_player_movement
      $game_player.clear_path if Input.dir4 != 0
      # Move player in the direction the directional button is being pressed
      case Input.dir4
      when 2
        move_down
      when 4
        move_left
      when 6
        move_right
      when 8
        move_up
      end
    end
  end
  
  class Interpreter
    #--------------------------------------------------------------------------
    def event
      return $game_map.events[@event_id]
    end
  end





Scene_Map
CODE
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#------------------------------------------------------------------------------
#**Version 1.0 repaired by Skaterdoggy
#==============================================================================

class Scene_Map
  include? Kboard
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias main_orig main
  def main
    @mouse_coordinates = Mouse_Coordinates.new
    main_orig
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_orig update
  def update
    update_orig
    # Update Mouse Coordinates
    @mouse_coordinates.update
    if Kboard.keyboard($RMouse_BUTTON_L)
      # Get current coordinates
      real_coord_x = @mouse_coordinates.x
      real_coord_y = @mouse_coordinates.y
      # Get column and row
      tile_coord_x = real_coord_x / 32
      tile_coord_y = real_coord_y / 32
      # Get rid of the variance of 8 * 6
      # ( 0 being the origin )
      tile_coord_x -= 6
      tile_coord_y -= 4
      # If Negative Set to 0 for Safety
      tile_coord_x = 0 unless tile_coord_x > -1
      tile_coord_y = 0 unless tile_coord_y > -1
      # Move
      $game_player.find_path(tile_coord_x,tile_coord_y)
    end
  end
end




Good LuCk!;)
Maybe i upload and one demo;)

This post has been edited by Punk: Aug 14 2008, 05:35 PM
Reason for edit: Wrapping the codes in [CODE] tags as it will make it easier for others to copy/paste.


__________________________
<a href="http://www.pricemyname.net/"><img src="http://www.pricemyname.net/wendigous.jpg" /></a>

[Show/Hide] My Projects
Ages Of Xordia



Go to the top of the page
 
+Quote Post
   
Redd
post Aug 7 2008, 03:32 PM
Post #2


:<
Group Icon

Group: Revolutionary
Posts: 2,312
Type: Developer
RM Skill: Advanced




Um, can you put in some screenshots? Or a demo so we know how it works?


__________________________
Go to the top of the page
 
+Quote Post
   
skaterdoggy
post Aug 7 2008, 11:14 PM
Post #3


Level 2
Group Icon

Group: Member
Posts: 20
Type: Event Designer
RM Skill: Skilled




Demo Uploaded:


HOW TO USE SCRIPT IN GAME:CLICK WITH MOUSE AROUND THE MAP.
thumbsup.gif

===NEXT QUESTION? wink.gif ===


__________________________
<a href="http://www.pricemyname.net/"><img src="http://www.pricemyname.net/wendigous.jpg" /></a>

[Show/Hide] My Projects
Ages Of Xordia



Go to the top of the page
 
+Quote Post
   
Joe
post Aug 18 2008, 03:54 PM
Post #4


Level 29
Group Icon

Group: Revolutionary
Posts: 674
Type: Event Designer
RM Skill: Advanced




This is great.

Would you be able to make the mouse buttons work for clicking on events and menu options?


__________________________
My Games

< OPEN BETA - DOWNLOAD HERE



Go to the top of the page
 
+Quote Post
   
ezequiel
post Nov 13 2008, 09:45 PM
Post #5



Group Icon

Group: Member
Posts: 1
Type: None
RM Skill: Undisclosed





Hello .. put a DEMO ^ ^
better

i am from brasil XD
Go to the top of the page
 
+Quote Post
   
deveon
post Jan 16 2009, 07:00 PM
Post #6



Group Icon

Group: Member
Posts: 4
Type: Developer
RM Skill: Masterful




I like the script...But in fullscreen mode you cant see the mouse pointer sad.gif
Go to the top of the page
 
+Quote Post
   
Mickadell
post Jan 17 2009, 01:26 AM
Post #7


Level 5
Group Icon

Group: Member
Posts: 71
Type: Event Designer
RM Skill: Masterful




Comment

Good, Good.
Go to the top of the page
 
+Quote Post
   
patmi
post Oct 18 2009, 08:22 AM
Post #8


Level 1
Group Icon

Group: Validating
Posts: 7
Type: Event Designer
RM Skill: Beginner




Good, but I´m using Leons Mission script,but these two and Leons doesnt get along. When I go to the mission menu i cant choose between missions, I can only read the description of the first mission... Can someone please help me with this problem? If someone is willing to help please contact me via my mail at rock_tone@azet.sk so I can send my project.
THX
Go to the top of the page
 
+Quote Post
   
zeroyuki
post Jan 9 2010, 10:42 PM
Post #9



Group Icon

Group: Member
Posts: 1
Type: Event Designer
RM Skill: Intermediate




hmm...it's good but I can't use it at full screen, the mouse just did not showing. could you fix it?
Go to the top of the page
 
+Quote Post
   
Taiine
post Jan 24 2010, 11:19 AM
Post #10


Level 17
Group Icon

Group: Revolutionary
Posts: 333
Type: Mapper
RM Skill: Advanced




I tried the demo and it don't do anything. Click around with the mouse and the player stays in place.


__________________________

an RMXP Game utilizing Blizz-ABS


Concept Projects: DASH! The Masters Game | Finny Adventures (temp title)
My first RMXP Script: Taiine's Solo Player Custom Menu System v0.6 (UPDATED 13th of Nov 10)

Go to the top of the page
 
+Quote Post
   
carnie_natas
post Sep 7 2010, 01:31 PM
Post #11


~Noctem~Shinai~
Group Icon

Group: Revolutionary
Posts: 261
Type: Developer
RM Skill: Advanced




if this worked with fullscreen id consider it!


__________________________
Light one up!
You can run.....But you'll only die tired!
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: 22nd May 2013 - 05:37 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker