Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
QuesTMajoR

Mouse Controller HELP Please!

Question

I want to Create a Conditional Brach where if the Mouse Left-clicks the Player's current position on the map, It will display a message.

 

Here's the Mouse Script:

 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# Mouse Controller by Blizzard

# Version: 2.0b

# Type: Custom Input System

# Date: 9.10.2009

# Date v2.0b: 22.7.2010

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#

# 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.

# #

# #----------------------------------------------------------------------------

#

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#

# Compatibility:

#

# 90% compatible with SDK v1.x. 80% compatible with SDK v2.x. May cause

# incompatibility issues with other custom input Systems. Works with "Custom

# Game Controls" from Tons of Add-ons and Blizz-ABS's custom controls.

# This script is not meant to be used as a standalone but rather in

# combination with special menus that are properly adapted to support a mouse

# controller system.

#

#

# Features:

#

# - fully automated mouse control in game

# - can be enhanced with "Custom Game Controls" from Tons of Add-ons

# - can be enhanced with "Blizz-ABS Controls"

# - can be enhanced with "RMX-OS"

#

# new in 2.0b:

#

# - added option to hide Windows' cursor

# - added possibility to hide and show the ingame cursor during the game

# - added possibility to change the cursor icon

# - added several new options

# - optimized

#

#

# Instructions:

#

# - Explanation:

#

# This script can work as a stand-alone for window option selections. To be

# able to use the mouse buttons, you need a custom Input module. The

# supported systems are "Custom Game Controls" from Tons of Add-ons,

# Blizz-ABS Custom Controls and RMX-OS Custom Controls. This script will

# automatically detect and apply the custom input modules' configuration

# which is optional.

#

# - Configuration:

#

# MOUSE_ICON - the default filename of the icon located in the

# Graphics/Pictures folder

# APPLY_BORDERS - defines whether the ingame cursor can go beyond the

# game window borders

# WINDOW_WIDTH - defines the window width, required only when using

# APPLY_BORDER

# WINDOW_HEIGHT - defines the window height, required only when using

# APPLY_BORDER

# HIDE_WINDOWS_CURSOR - hides the Windows Cursor on the window by default

# AUTO_CONFIGURE - when using "Custom Game Controls" from Tons of

# Add-ons, Blizz-ABS or RMX-OS, this option will

# automatically add the left mouse button as

# confirmation button

#

# - Script Calls:

#

# You can use a few script calls to manipulate the cursor. Keep in mind that

# these changes are not being saved with the save file.

#

# To hide the ingame Mouse Cursor, use following call.

#

# $mouse.hide

#

# To show the ingame Mouse Cursor, use following call.

#

# $mouse.show

#

# To change the cursor image, use following call. Make sure your image is

#

# $mouse.set_cursor('IMAGE_NAME')

#

#

# Additional Information:

#

# Even though there is an API call to determine the size of the window, API

# calls are CPU expensive so the values for the window size need to be

# configured manually in this script.

#

#

# If you find any bugs, please report them here:

# http://forum.chaos-project.com

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

 

$mouse_controller = 2.0

 

#===============================================================================

# Mouse

#===============================================================================

 

class Mouse

 

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# START Configuration

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

MOUSE_ICON = 'cursor'

AUTO_CONFIGURE = true

APPLY_BORDERS = true

WINDOW_WIDTH = 640

WINDOW_HEIGHT = 480

HIDE_WINDOWS_CURSOR = false

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# END Configuration

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

if HIDE_WINDOWS_CURSOR

Win32API.new('user32', 'ShowCursor', 'i', 'i').call(0)

end

 

SCREEN_TO_CLIENT = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')

READ_INI = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')

FIND_WINDOW = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')

CURSOR_POSITION = Win32API.new('user32', 'GetCursorPos', 'p', 'i')

 

def initialize

@cursor = Sprite.new

@cursor.z = 1000000

self.set_cursor(MOUSE_ICON)

update

end

 

def update

@cursor.x, @cursor.y = self.position

end

 

def x

return @cursor.x

end

 

def y

return @cursor.y

end

 

def position

x, y = self.get_client_position

if APPLY_BORDERS

if x < 0

x = 0

elsif x >= WINDOW_WIDTH

x = WINDOW_WIDTH - 1

end

if y < 0

y = 0

elsif y >= WINDOW_HEIGHT

y = WINDOW_HEIGHT - 1

end

end

return x, y

end

 

def get_client_position

pos = [0, 0].pack('ll')

CURSOR_POSITION.call(pos)

SCREEN_TO_CLIENT.call(WINDOW, pos)

return pos.unpack('ll')

end

 

def set_cursor(image)

@cursor.bitmap = RPG::Cache.picture(image)

end

 

def show

@cursor.visible = true

end

 

def hide

@cursor.visible = false

end

 

def self.find_window

game_name = "\0" * 256

READ_INI.call('Game', 'Title', '', game_name, 255, '.\\Game.ini')

game_name.delete!("\0")

return FIND_WINDOW.call('RGSS Player', game_name)

end

 

WINDOW = self.find_window

 

end

 

$mouse = Mouse.new

 

#==============================================================================

# module Input

#==============================================================================

 

module Input

 

class << Input

alias update_mousecontroller_later update

end

 

def self.update

$mouse.update

update_mousecontroller_later

end

 

if Mouse::AUTO_CONFIGURE

if $BlizzABS

C.push(Input::Key['Mouse Left']) if !C.include?(Input::Key['Mouse Left'])

if !Attack.include?(Input::Key['Mouse Right'])

Attack.push(Input::Key['Mouse Right'])

end

elsif $tons_version != nil && $tons_version >= 6.4 &&

TONS_OF_ADDONS::CUSTOM_CONTROLS || defined?(RMXOS)

C.push(Input::Key['Mouse Left']) if !C.include?(Input::Key['Mouse Left'])

end

end

 

end

 

#===============================================================================

# Rect

#===============================================================================

 

class Rect

 

def covers?(x, y)

return !(x < self.x || x >= self.x + self.width ||

y < self.y || y >= self.y + self.height)

end

 

end

 

#===============================================================================

# Sprite

#===============================================================================

 

class Sprite

 

def mouse_in_area?

return false if self.bitmap == nil

return ($mouse.x >= self.x && $mouse.x < self.x + self.src_rect.width &&

$mouse.y >= self.y && $mouse.y < self.y + self.src_rect.height)

end

 

end

 

#===============================================================================

# Window_Base

#===============================================================================

 

class Window_Base

 

def mouse_in_area?

return ($mouse.x >= self.x && $mouse.x < self.x + self.width &&

$mouse.y >= self.y && $mouse.y < self.y + self.height)

end

 

def mouse_in_inner_area?

return ($mouse.x >= self.x + 16 && $mouse.x < self.x + self.width - 16 &&

$mouse.y >= self.y + 16 && $mouse.y < self.y + self.height - 16)

end

 

end

 

#===============================================================================

# Window_Selectable

#===============================================================================

 

class Window_Selectable

 

alias contents_is_mousecontroller_later contents=

def contents=(bitmap)

contents_is_mousecontroller_later(bitmap)

begin

update_selections

update_mouse if self.active

rescue

end

end

 

alias index_is_mousecontroller_later index=

def index=(value)

index_is_mousecontroller_later(value)

update_selections

end

 

alias active_is_mousecontroller_later active=

def active=(value)

active_is_mousecontroller_later(value)

update_cursor_rect

end

 

def update_selections

@selections = []

index, ox, oy = self.index, self.ox, self.oy

(0...@item_max).each {|i|

@index = i

update_cursor_rect

rect = self.cursor_rect.clone

rect.x += self.ox

rect.y += self.oy

@selections.push(rect)}

@index, self.ox, self.oy = index, ox, oy

self.cursor_rect.empty

end

 

alias update_mousecontroller_later update

def update

update_mouse if self.active

update_mousecontroller_later

end

 

def update_mouse

if self.mouse_in_inner_area?

update_mouse_selection

return

end

self.index = -1

if self.contents != nil && @selections.size > 0 && self.mouse_in_area?

update_mouse_scrolling

end

end

 

def update_mouse_selection

update_selections if @selections.size != @item_max

@selections.each_index {|i|

if @selections.covers?($mouse.x - self.x - 16 + self.ox,

$mouse.y - self.y - 16 + self.oy)

self.index = i if self.index != i

return

end}

self.index = -1

end

 

def update_mouse_scrolling

if Input.repeat?(Input::C)

if $mouse.x < self.x + 16

if self.ox > 0

$game_system.se_play($data_system.cursor_se)

self.ox -= @selections[0].width

self.ox = 0 if self.ox < 0

end

elsif $mouse.x >= self.x + self.width - 16

max_ox = self.contents.width - self.width + 32

if self.ox <= max_ox

$game_system.se_play($data_system.cursor_se)

self.ox += @selections[0].width

self.ox = max_ox if self.ox >= max_ox

end

elsif $mouse.y < self.y + 16

if self.oy > 0

$game_system.se_play($data_system.cursor_se)

self.oy -= @selections[0].height

self.oy = 0 if self.oy < 0

end

elsif $mouse.y >= self.y + self.height - 16

max_oy = self.contents.height - self.height + 32

if self.oy <= max_oy

$game_system.se_play($data_system.cursor_se)

self.oy += @selections[0].height

self.oy = max_oy if self.oy >= max_oy

end

end

end

end

 

end

 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# Mouse Controller Enhancement Script by Nathmatt

# Version: 1.73

# 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.

# #

# #----------------------------------------------------------------------------

#

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# Instructions:

#

# To use the event effects in this script you will need to name the following.

#

# definitions

# d = 2 down, 4 left 6, right, or 8 up

# right click to access an events command list

#

# \ignore Use on events you want to be walkable

#

# \msg[message] This will add the message above the highlighted event

#

# \directionfix[d] If an event has a graphic and needs a specific direction

# they must be named this d as the open direction

#

# \direction[d] If an event has no graphic or isn't direction specific

# they must be named this d as the open direction

#

# \commands This will create a command list for each page with the

# name of the first avalible comment

#

# \curser[graphic] This will change the graphic of the curser while

# over that event

#

# \auto This will start the event as soon as you click it

#

# \door[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

# second 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

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module MCES

 

Version = 1.73

#============================================================================

# MCES::Config

#----------------------------------------------------------------------------

# The configuration for $MCES

#============================================================================

module Config

No_Walk_Tag = 7 # The terrain tag for unreachable locations

Text_Size = 20 # The size of the event name text

Text_Color = [0,0,160] # The color of the event name text

Click_Graphic = true # The sprite placed for move target

Range = 30 # The range for allows click movement

end

 

#============================================================================

# MCES::Cache

#----------------------------------------------------------------------------

# Stores data for use throughout $MCES

#============================================================================

module Cache

PathDirs = [[0, 1, 2], [-1, 0, 4], [1, 0, 6], [0, -1, 8]]

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]]

Direction = 0

Commands = 1

Curser = 2

Auto = 3

Door = 4

Msg = 5

Ignore = 6

end

 

#============================================================================

# MCES::Processor

#----------------------------------------------------------------------------

# This class performs the $MCES's processing.

#============================================================================

class Processor

 

attr_accessor :item,:curser_lock,:disabled,:movement_disabled,:location

attr_reader :event_start

 

def initialize

@disabled,@movement_disabled,@location = false,false,[]

@lwait,@rwait,curser_lock,@carry_sprite = 0,0,false,Sprite.new

@carry_sprite.z = 999999;@carry_sprite.bitmap = Bitmap.new(24, 24)

@mouse_set = true

end

 

def update

if @lwait > 0;@lwait-= 1;end

if @rwait > 0;@rwait-= 1;end

@item = $data_items[@item] if @item.is_a?(Numeric)

return if @disabled

if !$scene.is_a?(Scene_Map);@lwait = 5;return;end

if Input.trigger?(Input::Key['Mouse Left']) &&

!$game_temp.message_window_showing && @lwait == 0

@lwait = 5

check_left

elsif Input.trigger?(Input::Key['Mouse Right']) && @rwait == 0

@rwait = 5

check_right

end

check_player

check_carry

check_mouse

if @command_window != nil && !@command_window.disposed?

@command_window.update

end

end

 

def check_left

x,y = mouse_tile

return if check_event || !$game_map.passable?(x,y,0) || @movement_disabled ||

check_terrain_tag(x,y) || check_range(x,y,MCES::Config::Range)

return if @command_window != nil && !@command_window.disposed?

$game_player.set(x,y)

end

 

def check_event

$game_map.events.each_value{|event|

next if event.erased

if event.mouse_in_area?

if event.type.include?(MCES::Cache::Ignore)

return false

end

if event.type.include?(MCES::Cache::Auto)

event.start_event

return true

elsif event.type.include?(MCES::Cache::Door)

event.check_door

return true

else

$game_player.set(event) if !@movement_disabled

return true

end

end}

return false

end

 

 

def check_right

$game_map.events.each_value{|event|

next if event.erased

if event.mouse_in_area?

if event.type.include?(MCES::Cache::Commands)

return if @command_window != nil && !@command_window.disposed?

@command_window = Event_Command.new(event)

return

end

end}

end

 

def mouse_tile

x,y = $mouse.x,$mouse.y

return (x+$game_map.display_x/4)/32,(y+$game_map.display_y/4)/32

end

 

 

def check_terrain_tag(x,y)

return ($game_map.terrain_tag(x,y) == Config::No_Walk_Tag)

end

 

def check_target(x,y=0)

if x.is_a?(Game_Character)

c = x

d = (x.direction_fixed != nil ? x.direction_fixed : x.direction)

x,y = c.x,c.y

x += (d == 4 ? -1 : 1) if d != (2 || 8)

y += (d == 8 ? -1 : 1) if d != (4 || 6)

end

return x,y

end

 

def check_player

return if @request == nil

count = 4

characters = [$game_player]

while characters.size > 0 && count > 0

char = characters.shift

result = find_path

result != nil ? char.force_movement = result : characters.push(char)

count -= 1

end

end

 

def check_carry

@carry_sprite.x,@carry_sprite.y = $mouse.x,$mouse.y

if @item != nil

if @carry_curser != @item.icon_name

@carry_curser = @item.icon_name

@carry_sprite.bitmap.blt(0, 0, RPG::Cache.icon(@carry_curser),

Rect.new(0, 0, 24, 24))

end

else

@carry_curser = nil

@carry_sprite.bitmap.clear

end

end

 

def check_mouse

$game_map.events.each_value{|event|

if event.mouse_in_area?

next if event.erased

if event.type.include?(MCES::Cache::Curser)

$mouse.set_cursor(event.curser)

@mouse_set = false

return

end

end}

if !@mouse_set

return if @curser_lock

@mouse_set = true

$mouse.set_cursor(Mouse::MOUSE_ICON)

end

end

 

def request_path(x, y = nil)

x,y = check_target(x,y)

if x != nil && y != nil && @request == nil

@request = PathRequesting.new(x, y)

end

end

 

def distance(x,y,tx,ty)

return Math.hypot((x - tx),(y - ty))

end

 

def check_range(x,y,range)

pl = $game_player

return (range <= distance(pl.x,pl.y,x,y))

end

 

def find_path

request = @request

if request.open.size == 0;@request = nil;return []end

found = false

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)}

request.closed[key[0], key[1]] = request.open[key]

request.open.delete(key)

Cache::PathDirs.each {|dir|

kx, ky = key[0] + dir[0], key[1] + dir[1]

if kx == request.tx && ky == request.ty

request.closed[kx, ky] = dir[2]

found = true

break

elsif request.closed[kx, ky] == 0 &&

$game_player.passable?(key[0], key[1], dir[2])

request.open[[kx, ky]] = dir[2]

end}

return nil unless found

@request = nil

return request.backtrack

end

 

end

 

#============================================================================

# MCES::Msg_Sprite

#----------------------------------------------------------------------------

# The msg sprite.

#============================================================================

class Msg_Sprite < Sprite

 

def initialize(event)

super()

@event = event

self.z,self.opacity = 1000,0

self.set

@h = MCES::Config::Text_Size

@w = event.msg.size*@h

c = MCES::Config::Text_Color

self.bitmap = Bitmap.new(@w,@h)

self.bitmap.font.size = @h

self.bitmap.font.color = Color.new(c[0],c[1],c[2])

self.bitmap.draw_text(0,0,@w,@h,event.msg,1)

end

 

def set

return if !$scene.is_a?(Scene_Map) || @event.erased

b = @event.get_sprite.inner_bitmap

xs = @event.get_sprite.x-(@event.get_sprite.cw/2)

ys = @event.get_sprite.y-@event.get_sprite.ch

self.x,self.y = xs + (b.width/2)-(@w/2),ys-@h

end

 

def update

self.set

return self.opacity = 0 if @event.erased

if @event.mouse_in_area?

if self.opacity < 255

self.opacity += 25

end

elsif self.opacity > 0

self.opacity -= 25

end

end

end

 

#============================================================================

# MCES::Set_Sprite

#----------------------------------------------------------------------------

# The set sprite.

#============================================================================

class Set_Sprite < Sprite

 

def initialize(v)

super

self.bitmap = RPG::Cache.picture("analyze")

@x,@y,self.opacity,self.z = 0,0,0,1

end

 

def set(x,y)

return if MCES::Config::Click_Graphic == false

@e,x,y = x,x.x,x.y if x.is_a?(Game_Character)

@x,@y,self.opacity = x,y,255

end

 

def update_screen

return if self.opacity == 0

x = ((@x * 128) - $game_map.display_x + 3) / 4

y = ((@y * 128) - $game_map.display_y + 3) / 4

self.x,self.y = x,y

end

 

def update

return if MCES::Config::Click_Graphic == false

update_screen

end

 

end

 

#============================================================================

# MCES::Event_Command

#----------------------------------------------------------------------------

# The event command window.

#============================================================================

class Event_Command < Window_Command

 

def initialize(event)

@size = 0

@event = event

@main_commands = event.commands

@array = []

@main_commands.each{|command|

@array.push(command) if command != nil

@size = (command.size * 32) if (command.size * 32) > @size}

super(@size,@array)

self.x,self.y = $mouse.position

end

 

def indexes

return @main_commands.index(@array[self.index])

end

 

def update

super

if Input.trigger?(Input::Key['Mouse Left'])

if self.index >= 0

@event.start_command(indexes)

self.dispose

else

self.dispose

end

end

end

 

end

 

#============================================================================

# MCES::Pathrequest

#----------------------------------------------------------------------------

# This class preforms the movement requests.

#============================================================================

class PathRequesting

 

attr_reader :open,:closed,:sx,:sy,:tx,:ty,:jd

 

def initialize(tx, ty, jd = 0)

pix = ($BlizzABS != nil ? BlizzABS::Config::PIXEL_MOVEMENT_RATE : 1)

ox,oy = $game_player.location

@sx, @sy, @tx, @ty, @jd = ox, oy, tx, ty, jd

@x_off, @y_off = ox - @sx, oy - @sy

@open = {[@sx, @sy] => -1}

@closed = Table.new($game_map.width, $game_map.height)

end

 

def backtrack

cx, cy, x, y, result = @tx, @ty, 0, 0, []

loop do

cx, cy = cx - x, cy - y

break if cx == @sx && cy == @sy

result.unshift(Cache::TDirs[@closed[cx, cy]])

x, y = Cache::DirOffsets[@closed[cx, cy]]

end

return result

end

 

end

 

end

 

raise('This script requires Mouse Controller by Blizzard to work') if $mouse == nil

$MCES = MCES::Processor.new

 

#============================================================================

# Game_Character

#----------------------------------------------------------------------------

# Adds a mouse_in_area? method to any instance of this class.

#============================================================================

class Game_Character

 

attr_reader :type

attr_accessor :icon_name

 

alias mces_character_initialize initialize

def initialize

@type = []

mces_character_initialize

end

 

def mouse_in_area?

return false if get_sprite == nil || get_sprite.is_a?(Array)

return false if get_sprite.inner_bitmap == nil

return false if get_sprite.cw == nil || get_sprite.ch == nil

return true if [$mouse.x/32,$mouse.y/32] == [self.x,self.y]

b = get_sprite.inner_bitmap

xs = get_sprite.x-(get_sprite.cw/2)

ys = get_sprite.y-get_sprite.ch

return ($mouse.x >= xs && $mouse.x < xs + b.width &&

$mouse.y >= ys && $mouse.y < ys + b.height &&

b.get_pixel($mouse.x-xs, $mouse.y-ys) != Color.new(255,255,255,0))

end

 

 

def get_sprite

return if !$scene.is_a?(Scene_Map)

$scene.spriteset.character_sprites.each{|s|return s if s.character == self}

end

 

end

 

#============================================================================

# Game_Event

#----------------------------------------------------------------------------

# This class sets the events proccesing for MCES.

#============================================================================

class Game_Event < Game_Character

 

attr_accessor :event_start

attr_reader :key,:curser,:msg,:commands,:direction_fixed,:erased

 

alias mces_initialize initialize

def initialize(id,event)

mces_initialize(id,event)

@child_interpeter = Interpreter.new

@event_start = false

@type,@commands, = [],[]

check_name

end

 

alias mces_update update

def update

mces_update

@child_interpeter.update

@msg_sprite.update if @msg_sprite != nil

end

 

alias mces_start start

def start

return if @trigger == 0 && (!@event_start || @commands.size > 0)

mces_start

@event_start = false

end

 

def start_event

@event_start = true

start

end

 

def check_door

if @key == $MCES.item

@child_interpeter.setup(@event.pages[1].list,@id)

$game_party.gain_item($MCES.item.id, -1)

$MCES.item = nil

@key_unlock = true

elsif @key_unlock

@child_interpeter.setup(@event.pages[2].list,@id)

else

@child_interpeter.setup(@event.pages[0].list,@id)

end

return

end

 

def start_command(i)

@child_interpeter.setup(@event.pages.list,@id)

end

 

def check_name

if @event.name.clone.gsub!(/\\[ii]gnore/) {''}

@type.push(MCES::Cache::Ignore)

end

if @event.name.clone.gsub!(/\\[Aa]uto/) {''}

@type.push(MCES::Cache::Auto)

end

if @event.name.clone.gsub!(/\\[Cc]ommands/) {''}

@type.push(MCES::Cache::Commands)

@interpreter = Interpreter.new

@event.pages.each{|page|page.list.each{|list|

@last_list = list if @last_list == nil

if list.code == 108

if @last_list.code == 111

if @interpreter.command_111([@last_list,list])

@commands[@event.pages.index(page)] = list.parameters[0]

end

else

@commands[@event.pages.index(page)] = list.parameters[0]

end

end

@last_list = list}}

@interpreter = nil

end

if @event.name.clone.gsub!(/\\[Dd]irectionfix\[(\d+)\]/) {"#[$1]"}

@type.push(MCES::Cache::Direction)

@direction_fixed = $1.to_i

end

if @event.name.clone.gsub!(/\\[Dd]irection\[(\d+)\]/) {"#[$1]"}

@type.push(MCES::Cache::Direction)

@direction = $1.to_i

end

if @event.name.clone.gsub!(/\\[Ll]ocked\[(\d+)\]/) {"#[$1]"}

@type.push(MCES::Cache::Door)

@key = $data_items[$1.to_i]

end

if @event.name.clone.gsub!(/\\[Cc]urser\[(.+?)\]/) {"#[$1]"}

@type.push(MCES::Cache::Curser)

@curser = $1

end

if @event.name.clone.gsub!(/\\[Mm]sg\[(.+?)\]/) {"#[$1]"}

@type.push(MCES::Cache::Msg)

@msg = $1

@msg_sprite = MCES::Msg_Sprite.new(self)

end

end

 

end

 

#============================================================================

# Game_Player

#----------------------------------------------------------------------------

# Adds force movement.

#============================================================================

class Game_Player

 

attr_accessor :force_movement

 

alias mces_update update

def update

mces_update

if @target_x == nil

@force_movement = []

$MCES.location = []

else

if @force_movement == []

$MCES.request_path(@target_x, @target_y)

end

update_forcemovement if !moving?

if location == $MCES.check_target(@target_x,@target_y)

if @target_x.is_a?(Game_Event)

@target_x.start_event

face_target

end

if $scene.spriteset.set_sprite != nil

$scene.spriteset.set_sprite.opacity = 0

end

@target_x = @target_y = nil

@force_movement = []

$MCES.location = []

end

end

end

 

def face_target

sx = @x - @target_x.x

sy = @y - @target_x.y

return if sx == 0 and sy == 0

sx > 0 ? turn_left : turn_right if sx.abs > sy.abs

sy > 0 ? turn_up : turn_down if sx.abs < sy.abs

end

 

def update_forcemovement

return if @force_movement.size == 0

move = @force_movement.shift

case move[0]

when 1 then move_lower_left

when 2 then move_down(move[1])

when 3 then move_lower_right

when 4 then move_left(move[1])

when 6 then move_right(move[1])

when 7 then move_upper_left

when 8 then move_up(move[1])

when 9 then move_upper_right

end

end

 

def location

return self.x,self.y

end

 

def click_jump(x,y)

new_x,new_y = x-self.y,x-self.y

jump(new_x,new_y)

end

 

def set(x,y=nil)

@force_movement = []

@target_x, @target_y = x,y

$scene.spriteset.set_sprite.set(x,y) if MCES::Config::Click_Graphic != false

end

 

end

 

#============================================================================

# Interpreter

#----------------------------------------------------------------------------

# Allows external use of the condition command.

#============================================================================

class Interpreter

 

alias mces_command_111 command_111

def command_111(list = nil)

if list != nil

@index = 0

@list = list

@list.push(RPG::EventCommand.new(412, list[0].indent, []))

@parameters = list[0].parameters

end

mces_command_111

if list != nil

return @branch[0] == nil

end

end

 

end

#============================================================================

# Input

#----------------------------------------------------------------------------

# Adds the alias methods and updates the processor.

#============================================================================

module Input

 

class << Input

alias mces_trigger? trigger?

alias mces_update update

end

 

def self.update

$MCES.update

mces_update

end

 

end

if ($tons_version || $BlizzABS || $network) == nil

#============================================================================

# Input

#----------------------------------------------------------------------------

# Adds the mouse trigger commands if not using Blizzards input methods.

#============================================================================

module Input

 

Key = {'Mouse Right' => 1, 'Mouse Left' => 2}

C = Key['Mouse Right']

#======================================

# |–> Keyboard Input Module

#======================================

# By: Near Fantastica

# Date: 06.07.05

# Version: 3

#

# Cut down by Zeriab

# Date: 16.08.06

#======================================

def self.trigger?(key)

return false if key == nil

if !Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)

return true

else

return mces_trigger?(key)

end

end

 

end

 

end

#============================================================================

# Sprite_Character

#----------------------------------------------------------------------------

# Creats a inner bitmap for use with the mouse_in_area? method.

#============================================================================

class Sprite_Character

attr_reader :ch,:cw,:inner_bitmap

 

alias mces_initialize initialize

def initialize(viewport,character = nil)

mces_initialize(viewport,character)

end

 

alias mces_update update

def update

mces_update

if $BlizzABS != nil

return if @sprite == nil

return if @sprite.cw == nil || @sprite.ch == nil

@cw,@ch = @sprite.cw, @sprite.ch

end

if @character.icon_name != nil || @character.tile_id >= 384

@inner_bitmap = self.bitmap.clone

return

end

@inner_bitmap = Bitmap.new(@cw,@ch) if @inner_bitmap == nil

if @pattern != @character.pattern

@pattern = @character.pattern

bitmap = ($BlizzABS != nil ? @sprite.bitmap : self.bitmap)

src_rect = ($BlizzABS != nil ? @sprite.src_rect : self.src_rect)

@inner_bitmap.clear

@inner_bitmap.blt(0, 0, bitmap, src_rect)

end

end

 

end

#============================================================================

# Spriteset_Map

#----------------------------------------------------------------------------

# Creats the set_sprite

#============================================================================

class Spriteset_Map

attr_reader :character_sprites,:set_sprite

 

alias mces_initialize initialize

def initialize

mces_initialize

if MCES::Config::Click_Graphic != false

@set_sprite = MCES::Set_Sprite.new(@viewport1)

end

end

 

alias mces_update update

def update

mces_update

@set_sprite.update if @set_sprite != nil

end

 

end

#============================================================================

# Adds eternal reading of methods.

#============================================================================

class Sprite_Character_ABSEAL_ed; attr_reader :ch,:cw end if $BlizzABS != nil

class Scene_Map; attr_reader :spriteset end

if $BlizzABS != nil

class BlizzABS::Processor

 

def pixel

return 1

end

 

end

end

 

 

What Script Call must I use on the Conditional Branch?

 

Thanks in Advance

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...