Icon Display 1.0 scripts makes events impossible to go to events, which are passable
#1
First of all. Hi there :))
Normalerweise kann ein Event durch den Held hindurch gehen, wenn das Event mit der Eigenschaft "through" belegt wurde.
Normally, en event can go through another event incase the event is assigned with the "through" property.
So for example: If event number 1 is assigned the through property, an event should go through him, incase he he his in his way.

Es gibt da ein Icon display skript von Mr.Mo "Muhammet Sivri, welches es erlaubt icons über NPCS laufen zu lasssen.
Theres an icon display script vom Mr. Mo muhammed sivri, which alones one to display icons above NPCS, which is very useful.
Das Skript besteht aus zwei Skripte. Einmal das Icon Overhead Display und
einmal das Module UCoders.
The scripts consists of two scripts. First one is Icon overhead display and module UCoders.

The Problem is:
Once the script is added, it works quite fine. But theres only one bug. If the script is added, somehow events can't go through another evens which are assigned with the "through" property. Normally they should be.

Can someone look at the two scripts? I believe this must be a bug, which should not be part of the script.


First the Icon Display 1.0 Script:



Code:
#===============================================================================
# ** Icon Display 1.0 - www.unknowncoders.com
#-------------------------------------------------------------------------------
# Author Mr.Mo "Muhammet Sivri"
# Version 1.0
# Date 12/04/07 (m/d/y)
#===============================================================================
# Introduction
#===============================================================================
# Displays an icon over events or the player. You can choose for how long.
# You can also display without triggering the event by using comments on events.
#
# To display over an event, call this script:
#
# $game_map.events[EVENT_ID].display_icon("icon_name")
#
# EVENT_ID = the ID of the event, can be found on the left top corner of the
# event editor. Make sure to remove any 0 that are up front.
# For exmple: 001 = 1 or 010 = 10
#
# To display over an event without triggers using comments:
#
# IconD icon_name frames
#
# You do not need frames if you want to display non-stop. Examples:
#
# IconD 049-Skill06
# IconD 049-Skill06 30
#
# The first one displays forever, the second displays for 3 seconds.
#
# To display over a player, call this script:
#
# $game_player.display_icon("icon_name")
#
# NOTE: You can also add how long it should be shown, default is until map change.
# To add the lenght of display do this:
#
# .display_icon("icon_name",FRAMES)
#
# FRAMES = number of frames(10=1) that the icon will be displayed.
#
# Exmaples:
#
# $game_map.events[EVENT_ID].display_icon("icon_name",100) > 10 seconds
# $game_player.display_icon("icon_name",40) > 4 seconds
#===============================================================================
UCoders.include('Icon Display', ['Mr.Mo','1.0'])
class Game_Character
attr_accessor :icon, :icon_frames, :displaying_icon, :current_icon
#--------------------------------------------------------------------------
alias mrmo_icond_game_character_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@icon = @displaying_icon = @current_icon = ""
@icon_frames = 0
mrmo_icond_game_character_initialize
end
#--------------------------------------------------------------------------
# * Display Icon
#--------------------------------------------------------------------------
def display_icon(icon,frames=0)
@icon = icon
@icon_frames = frames
end
#--------------------------------------------------------------------------
# * Setup Icon
#--------------------------------------------------------------------------
def setup_icond(event,list)
parameters = UCoders.event_comment_input(event,1,"IconD"); return false if parameters.nil?
# Get Icon
@icon = parameters[0].split[1].to_s
@icon_frames = (parameters[0].split[2].to_i)
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display the character.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < RPG::Sprite
alias mrmo_icond_sprite_character_int initialize
alias mrmo_icond_sprite_character_update update
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
mrmo_icond_sprite_character_int(viewport, character)
show_icon unless (@character.icon=@character.current_icon).empty?
#@character.displaying_icon = ""
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
@icon_sprite.dispose if !@icon_sprite.nil? && !@icon_sprite.disposed?
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
mrmo_icond_sprite_character_update
# Check if an icon needs to be displayed
if @character.icon == "r"
@icon_sprite.dispose unless @icon_sprite.nil?
@icon_sprite = nil
@character.icon = @character.current_icon = @character.displaying_icon = ""
end
if !@character.icon.empty?
show_icon
@character.icon = ""
end
if !@icon_sprite.nil?
@icon_sprite.x = self.x-(@icon_sprite.bitmap.width/2)
@icon_sprite.y = (self.y-@icon_sprite.bitmap.height)-self.bitmap.height/4 + 4
@character.icon_frames -= 1 if @character.icon_frames > 1
if @character.icon_frames == 1
@icon_sprite.dispose
@icon_sprite = nil
@character.current_icon = @character.displaying_icon = ""
end
end
end
#--------------------------------------------------------------------------
# * Show Icon
#--------------------------------------------------------------------------
def show_icon
@character.current_icon = @character.displaying_icon = @icon = @character.icon
# Create Sprite
@icon_sprite = Sprite.new if @icon_sprite.nil?
@icon_sprite.bitmap = RPG::Cache.icon("#{@icon}")
end
end

#============================================================================
# * Game Event
#============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
alias mrmo_icon_game_event_refresh refresh
#--------------------------------------------------------------------------
# * Refreshes Page
#--------------------------------------------------------------------------
def refresh
mrmo_icon_game_event_refresh
setup_icond(self,@list)
endend









And there the second Script:




Code:
#===============================================================================# ** Module UCoders - Contains Methods used by Unknown Coders' scripts
#
# Visit Us:
# www.unknowncoders.com
#
#-------------------------------------------------------------------------------
# Authors Mr.Mo "Muhammet Sivri" | Trebor777
# Version 1.2
# Date 11/24/07 (m/d/y)
#===============================================================================
module UCoders
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
Object = {}
Scripts = {}
#--------------------------------------------------------------------------
# * Include Script
#--------------------------------------------------------------------------
def UCoders.include(name,args)
Scripts[name] = args
end
#--------------------------------------------------------------------------
# * Include Script
#--------------------------------------------------------------------------
def UCoders.has?(name)
return !Scripts[name].nil?
end
#--------------------------------------------------------------------------
# * Returns a list of parameters from an event's comments
#--------------------------------------------------------------------------
def UCoders.event_comment_input(*args)
parameters = []; list = *args[0].list; lines = *args[1]; trigger = *args[2]
return nil if list.nil? || !list.is_a?(Array)
list.each { |o|
next if o.code != 108 || !(o.parameters[0].to_s).include?(trigger)
start = list.index(o)
finish = start + lines
for id in start...finish
next if !list[id]; parameters.push(list[id].parameters[0])
end
return parameters
}
return nil
end
#--------------------------------------------------------------------------
# * Returns the event comment with the needed key
#--------------------------------------------------------------------------
def UCoders.event_comment(*args)
parameters = []; list = *args[0].list; trigger = *args[1]
return nil if list.nil? || !list.is_a?(Array)
list.each { |o| next if o.code != 108 || !(o.parameters[0].to_s).include?(trigger)
parameters.push(o.parameters)
}
return parameters unless parameters.empty?
return nil
end
#--------------------------------------------------------------------------
# * Log Error - Records and Saves all errors.
#--------------------------------------------------------------------------
def UCoders.log_error
# Record Error
k = 0
time = Time.now.strftime("%a %d %b %Y, %X")
log = File.open("ErrorLog.rxdata","a+")
log.write("[ #{time} ]\n")
# Write Message and Type
log.write("'#{$!.message}' Type #{$!.class}\n")
for i in 0..$!.backtrace.size
e = $!.backtrace
/Section(.*):(.*):in (.*)/.match(e)
space = " "*(i*2)
log.write(space+" <>Script '#{$RGSS_SCRIPTS[$1.to_i][1]}' | Line #{$2} | Method #{$3}\n")
# Don't list more then 4 backtraces to make it simpler, can be changed!
break if i >= 4
next if k == 1
# Get the first trace
script = "#{$RGSS_SCRIPTS[$1.to_i][1]}"
line = $2
method = $3
k = 1
end
log.write("\n")
log.close
# Make some sense
if $DEBUG
print "#{$!.message} \nScript '#{script}' \nLine '#{line}' \nMethod '#{method}' \nType '#{$!.class}'"
else
print "Unexpected Error! The ErrorLog is in folder:\n #{File.expand_path('.')}"
end
end
#--------------------------------------------------------------------------
# * Checks the object range
#--------------------------------------------------------------------------
def UCoders.in_screen?(object)
scene_x = $game_map.display_x - 256
scene_y = $game_map.display_y - 256
scene_width = $game_map.display_x + 2816
scene_height = $game_map.display_y + 2176
return (object.real_x.between?(scene_x, scene_width) and object.real_y.between?(scene_y,scene_height))
end
#--------------------------------------------------------------------------
# * Get Events In (range of element)
#--------------------------------------------------------------------------
def UCoders.get_events_in(range,element)
objects = []
$game_map.events.each_value { |e| objects.push(e) if UCoders.in_range?(element, e, range) }
return objects
end
#--------------------------------------------------------------------------
# * Get Range(Element, Object)
#--------------------------------------------------------------------------
def UCoders.get_range(element, object)
x = (element.x - object.x)**2
y = (element.y - object.y)**2
r = x + y
return Math.sqrt(r).to_i
end
#--------------------------------------------------------------------------
# * In Range?(Element, Object, Range)
#--------------------------------------------------------------------------
def UCoders.in_range?(element, object, range)
x = (element.x - object.x)**2
y = (element.y - object.y)**2
return x + y <= (range * range)
end
#--------------------------------------------------------------------------
# * In Direction?(Element, Object)
#--------------------------------------------------------------------------
def UCoders.in_direction?(event,object)
return true if event.direction == 2 && object.y >= event.y && object.x == event.x
return true if event.direction == 4 && object.x <= event.x && object.y == event.y
return true if event.direction == 6 && object.x >= event.x && object.y == event.y
return true if event.direction == 8 && object.y <= event.y && object.x == event.x
return false
end
end
#==============================================================================
# ** Multi-Dimensional Array
# Creates a MultiD array. When value not specified, returns nil.
#==============================================================================
class MultiArray
#--------------------------------------------------------------------------
# * Initialize
# d : number of dimensions(x,y,z)
#--------------------------------------------------------------------------
def initialize(*dimensions)
@dimensions=Array.new(dimensions.size)
@factors=Array.new(dimensions.size)
product=1
i=dimensions.size-1
while i >= 0
@dimensions=dimensions
@factors=product
product*=@dimensions
i-=1
end
@data=Array.new(product)
end
#--------------------------------------------------------------------------
# * X Size
#--------------------------------------------------------------------------
def xsize
return @dimensions[0]
end
#--------------------------------------------------------------------------
# * Y Size
#--------------------------------------------------------------------------
def ysize
return 1 if @dimensions.size<2
return @dimensions[1]
end
#--------------------------------------------------------------------------
# * Z Size
#--------------------------------------------------------------------------
def zsize
return 1 if @dimensions.size<3
return @dimensions[2]
end
#--------------------------------------------------------------------------
# * NSize
#--------------------------------------------------------------------------
def nsize(n)
raise IndexError if @dimensions.size<n
return @dimensions[n-1]
end
#--------------------------------------------------------------------------
# * Get ID
#--------------------------------------------------------------------------
def get_id(indices)
raise IndexError if indices.size != @dimensions.size
offset=0
for i in 0 ... @dimensions.size
raise IndexError if indices < 0 or indices>=@dimensions
offset += @factors*indices
end
return offset
end
#--------------------------------------------------------------------------
# * Get []
#--------------------------------------------------------------------------
def [](*indices)
@data[self.get_id(indices)]
end
#--------------------------------------------------------------------------
# * Set []=
#--------------------------------------------------------------------------
def []=(*indicesAndValue)
value = indicesAndValue.pop
@data[self.get_id(indicesAndValue)]=value
end
end
#==============================================================================
# ** 2-Dimensional Array
# Creates a 2D array. When value not specified, returns 0.
#==============================================================================
class Array2D
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
# Create Data Array
@data = {}
end
#--------------------------------------------------------------------------
# * Get
#--------------------------------------------------------------------------
def [](i,j)
@data = {} if @data.nil?
@data[j] = 0 if @data[j].nil?
return @data[j]
end
#--------------------------------------------------------------------------
# * Set
#--------------------------------------------------------------------------
def []=(i,j,v)
@data = {} if @data.nil?
@data[j] = v
return v
end
end
#==============================================================================
# ** RPG::Event::Page::Condition
#==============================================================================

class RPG::Event::Page::Condition
#--------------------------------------------------------------------------
# * Conditions Met?
#--------------------------------------------------------------------------
def conditions_met?(map_id, event_id)
# Switch 1 condition confirmation
if @switch1_valid && $game_switches[@switch1_id] == false
return false
end
# Switch 2 condition confirmation
if @switch2_valid && $game_switches[@switch2_id] == false
return false
end
# Variable condition confirmation
if @variable_valid && $game_variables[@variable_id] < @variable_value
return false
end
# Self switch condition confirmation
if @self_switch_valid
key = [map_id, event_id, @self_switch_ch]
if $game_self_switches[key] == false
return false
end
end
# Returns True
return true
end
end

#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
attr_reader :real_x, :real_y, :event
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
new_page = refresh_new_page # Get New Page
return if refresh_page_change?(new_page) # Return if No Page Change
clear_starting # Clear starting flag
return if refresh_page_reset? # Return if Nil Page Reset
refresh_set_page # Set page variables
refresh_check_process # Check parallel processing
check_event_trigger_auto # Auto event start determinant
end
#--------------------------------------------------------------------------
# * Refresh : New Page
#--------------------------------------------------------------------------
def refresh_new_page
return @erased ? nil : refresh_trigger_conditions
end
#--------------------------------------------------------------------------
# * Refresh Trigger Conditions
#--------------------------------------------------------------------------
def refresh_trigger_conditions
# Check in order of large event pages
for page in @event.pages.reverse
# Skips If Page Conditions Not Met
next unless page.condition.conditions_met?(@map_id, @id)
# Set local variable: new_page
new_page = page
# Remove loop
break
end
# Return new page
return new_page
end
#--------------------------------------------------------------------------
# * Refresh : Page Change
#--------------------------------------------------------------------------
def refresh_page_change?(new_page)
# If event page is the same as last time
if new_page == @page
# End method
return true
end
# Set @page as current event page
@page = new_page
return false
end
#--------------------------------------------------------------------------
# * Refresh : Page Reset
#--------------------------------------------------------------------------
def refresh_page_reset?
# If no page fulfills conditions
if @page == nil
# Reset values
refresh_reset
# End method
return true
end
return false
end
#--------------------------------------------------------------------------
# * Refresh Reset
#--------------------------------------------------------------------------
def refresh_reset
# Set each instance variable
@tile_id = 0
@character_name = ""
@character_hue = 0
@move_type = 0
@through = true
@trigger = nil
@list = nil
@interpreter = nil
end
#--------------------------------------------------------------------------
# * Refresh Set Page
#--------------------------------------------------------------------------
def refresh_set_page
# Set each instance variable
@tile_id = @page.graphic.tile_id
@character_name = @page.graphic.character_name
@character_hue = @page.graphic.character_hue
if @original_direction != @page.graphic.direction
@direction = @page.graphic.direction
@original_direction = @direction
@prelock_direction = 0
end
if @original_pattern != @page.graphic.pattern
@pattern = @page.graphic.pattern
@original_pattern = @pattern
end
@opacity = @page.graphic.opacity
@blend_type = @page.graphic.blend_type
@move_type = @page.move_type
@move_speed = @page.move_speed
@move_frequency = @page.move_frequency
@move_route = @page.move_route
@move_route_index = 0
@move_route_forcing = false
@walk_anime = @page.walk_anime
@step_anime = @page.step_anime
@direction_fix = @page.direction_fix
@through = @page.through
@always_on_top = @page.always_on_top
@trigger = @page.trigger
@list = @page.list
@interpreter = nil
end
#--------------------------------------------------------------------------
# * Refresh Check Process
#--------------------------------------------------------------------------
def refresh_check_process
# If trigger is [parallel process]
if @trigger == 4
# Create parallel process interpreter
@interpreter = Interpreter.new
end
end
end

class Interpreter
#--------------------------------------------------------------------------
# * Script
#--------------------------------------------------------------------------
def command_355
# Set first line to script
script = @list[@index].parameters[0] + "\n"
# Loop
loop do
# If next event command is second line of script || after
if @list[@index+1].code == 655
# Add second line || after to script
script += @list[@index+1].parameters[0] + "\n"
# If event command is not second line || after
else
# Abort loop
break
end
# Advance index
@index += 1
end
# Evaluation
result = eval(script)
# Continue
return true
end
#--------------------------------------------------------------------------
# * In Range?(Element, Object, Range)
#--------------------------------------------------------------------------
def in_range?(element, object, range)
x = (element.x - object.x)**2
y = (element.y - object.y)**2
return x + y <= (range * range)
end
end

#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================

class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Remake temporary object
$game_temp = Game_Temp.new
# Timestamp selects new file
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Which file would you like to load?")
end
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(filename)
# If file doesn't exist
unless FileTest.exist?(filename)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play load SE
$game_system.se_play($data_system.load_se)
# Read save data
file = File.open(filename, "rb")
read_save_data(file)
file.close
# Restore BGM and BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to title screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
read_characters(file)
read_frame(file)
read_data(file)
read_edit
read_refresh
end
#--------------------------------------------------------------------------
# * Read Character Data
#--------------------------------------------------------------------------
def read_characters(file)
# Read character data for drawing save file
characters = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Frame Count
#--------------------------------------------------------------------------
def read_frame(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Data
#--------------------------------------------------------------------------
def read_data(file)
# Read each type of game object
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Edit
#--------------------------------------------------------------------------
def read_edit
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
# Load map
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
#--------------------------------------------------------------------------
# * Refresh Game Party
#--------------------------------------------------------------------------
def read_refresh
# Refresh party members
$game_party.refresh
end
end

#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player && Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Follow_Path
#--------------------------------------------------------------------------
def follow_path(x,y,&block)
node = Node.new(x, y)
path = A_Star_Pathfinder.new(node, self)
path.reach_method = block
end
#--------------------------------------------------------------------------
# * Turn Towards B
#--------------------------------------------------------------------------
def turn_to(b)
# Get difference in player coordinates
sx = @x - b.x
sy = @y - b.y
# If coordinates are equal
if sx == 0 && sy == 0
return
end
# If horizontal distance is longer
if sx.abs > sy.abs
# Turn to the right || left towards player
sx > 0 ? turn_left : turn_right
# If vertical distance is longer
else
# Turn up || down towards player
sy > 0 ? turn_up : turn_down
end
end
#--------------------------------------------------------------------------
# * Move toward B
#--------------------------------------------------------------------------
def move_towards(b,ran=true)
return if in_range2?(b,1) || !@a_star_path.nil?
# Get difference in player coordinates
sx = @x - b.x
sy = @y - b.y
@target = b
# If coordinates are equal
return if sx == 0 && sy == 0
# Get absolute value of difference
abs_sx = sx.abs
abs_sy = sy.abs
# If horizontal && vertical distances are equal
if abs_sx == abs_sy
# Increase one of them randomly by 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# If horizontal distance is longer
if abs_sx > abs_sy
# Move towards player, prioritize left && right directions
if sx > 0
return move_left if passable?(@x, @y, 4)
else
return move_right if passable?(@x, @y, 6)
end
if not moving? && sy != 0
if sy > 0
return move_up if passable?(@x, @y, 8)
else
return move_down if passable?(@x, @y, 2)
end
end
# If vertical distance is longer
else
# Move towards player, prioritize up && down directions
if sy > 0
return move_up if passable?(@x, @y, 8)
else
return move_down if passable?(@x, @y, 2)
end
if not moving? && sx != 0
if sx > 0
return move_left if passable?(@x, @y, 4)
else
return move_right if passable?(@x, @y, 6)
end
end
end
=begin
# Can't find the path, Try pathfidning
if self.respond_to?(:a_star_path) && @a_star_path.nil?
# Get X,Y
x,y=b.x,b.y
# Follow Path
nx = x + (passable?(x-1,y,0) ? -1 : passable?(x+1,y,0) ? 1 : 0)
ny = y + (passable?(x,y-1,0) ? -1 : passable?(x,y+1,0) ? 1 : 0)
self.follow_path(nx,ny)
# Return if Path success
return if !@a_star_path.nil? && @a_star_path.found
end
=end
if ran
move_random
turn_to(b)
end
end
#--------------------------------------------------------------------------
# * Move toward Pos XY
#--------------------------------------------------------------------------
def move_towards_pos(x,y,ran=true)
# Get difference in player coordinates
sx = @x - x
sy = @y - y
# If coordinates are equal
return if sx == 0 && sy == 0
# Get absolute value of difference
abs_sx = sx.abs
abs_sy = sy.abs
# If horizontal && vertical distances are equal
if abs_sx == abs_sy
# Increase one of them randomly by 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# If horizontal distance is longer
if abs_sx > abs_sy
# Move towards player, prioritize left && right directions
if sx > 0
return move_left if passable?(@x, @y, 4)
else
return move_right if passable?(@x, @y, 6)
end
if not moving? && sy != 0
if sy > 0
return move_up if passable?(@x, @y, 8)
else
return move_down if passable?(@x, @y, 2)
end
end
# If vertical distance is longer
else
# Move towards player, prioritize up && down directions
if sy > 0
return move_up if passable?(@x, @y, 8)
else
return move_down if passable?(@x, @y, 2)
end
if not moving? && sx != 0
if sx > 0
return move_left if passable?(@x, @y, 4)
else
return move_right if passable?(@x, @y, 6)
end
end
end
if ran
move_random
end
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false if !check_map_pass(new_x,x,new_y,y,d)
return false if !check_event_pass(new_x,new_y,d)
return false if !check_player_pass(new_x,new_y,d)
# passable
return true
end
#--------------------------------------------------------------------------
# * Check Map Pass
#--------------------------------------------------------------------------
def check_map_pass(new_x,x,new_y,y,d)
# If coordinates are outside of map
unless $game_map.valid?(new_x, new_y)
# impassable
return false
end
# If through is ON
if @through
# passable
return true
end
# If unable to leave first move tile in designated direction
unless $game_map.passable?(x, y, d, self)
# impassable
return false
end
# If unable to enter move tile in designated direction
unless $game_map.passable?(new_x, new_y, 10 - d)
# impassable
return false
end
return true
end
#--------------------------------------------------------------------------
# * Check Event Pass
#--------------------------------------------------------------------------
def check_event_pass(new_x,new_y,d)
# Loop all events
for event in $game_map.events.values
# If event coordinates are consistent with move destination
if event.x == new_x and event.y == new_y
# If through is OFF
unless event.through
# If self is event
if self_condition_player
# impassable
return false
end
# With self as the player and partner graphic as character
if event.character_name != ""
# impassable
return false
end
end
end
end
return true
end
#--------------------------------------------------------------------------
# * Self Condition Player
#--------------------------------------------------------------------------
def self_condition_player
bool = (self != $game_player)
return bool
end
#--------------------------------------------------------------------------
# * Check Player Pass
#--------------------------------------------------------------------------
def check_player_pass(new_x,new_y,d)
# If player coordinates are consistent with move destination
if $game_player.x == new_x and $game_player.y == new_y
# If through is OFF
unless $game_player.through
# If your own graphic is the character
if @character_name != ""
# impassable
return false
end
end
end
return true
end
end

#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
def map; return @map; end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8,10)
# * 0,10 = determine if all directions are impassable
# self_event : Self (If event is determined passable)
#--------------------------------------------------------------------------
def passable?(x, y, d, self_event = nil)
# If coordinates given are outside of the map
unless valid?(x, y)
# impassable
return false
end
# Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
bit = (1 << (d / 2 - 1)) & 0x0f
# Pass Events
pe = pass_events(bit,x,y,self_event)
return pe unless pe.nil?
# Loop searches in order from top of layer
for i in [2, 1, 0]
# Get tile ID
tile_id = data[x, y, i]
# Tile ID acquistion failure
if tile_id == nil
# impassable
return false
# If obstacle bit is set
elsif @passages[tile_id] & bit != 0
# impassable
return false
# If obstacle bit is set in all directions
elsif @passages[tile_id] & 0x0f == 0x0f
# impassable
return false
# If priorities other than that are 0
elsif @priorities[tile_id] == 0
# passable
return true
end
end
# passable
return true
end
#--------------------------------------------------------------------------
# * Events
#--------------------------------------------------------------------------
def pass_events(bit,x,y,self_event)
# Loop in all events
for event in events.values
# If tiles other than self are consistent with coordinates
if event.tile_id >= 0 and event != self_event and
event.x == x and event.y == y and not event.through
# If obstacle bit is set
if @passages[event.tile_id] & bit != 0
# impassable
return false
# If obstacle bit is set in all directions
elsif @passages[event.tile_id] & 0x0f == 0x0f
# impassable
return false
# If priorities other than that are 0
elsif @priorities[event.tile_id] == 0
# passable
return true
end
end
end
return nil
end end
Reply }


Messages In This Thread
Icon Display 1.0 scripts makes events impossible to go to events, which are passable - by Djigit - 01-03-2015, 09:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Mr. Mo v 5.5 + Immense Events Tepe 22 1,114 11-03-2024, 05:57 PM
Last Post: Tepe
   Display some uncommon values Mel 6 8,508 08-15-2017, 05:38 PM
Last Post: Mel
   Multi Attack & Combo Display Keeroh 9 13,994 05-15-2017, 06:39 PM
Last Post: DerVVulfman
   Display State Ranks in Status Screen Mel 3 7,417 04-02-2017, 12:46 AM
Last Post: marketing small business ideas
Question  Lycan ABS - Weapon display Jetboy 4 7,181 07-14-2015, 06:02 AM
Last Post: DerVVulfman
   in FPLE touching events after battle causes rpg maker to crash ThePrinceofMars 1 5,506 11-27-2014, 09:11 PM
Last Post: MechanicalPen
   How to get class name from Scripts.rxdata? MechanicalPen 2 6,708 08-13-2013, 05:50 PM
Last Post: MechanicalPen
   looking for day/night/weather scripts: Ahzoh 2 5,022 07-31-2013, 05:25 AM
Last Post: Ahzoh
   MrMo's ABS Ultimate and Other Scripts Erechel 6 9,571 05-07-2012, 03:37 AM
Last Post: Erechel
   [Resolved] Shrinking an Icon Yin 6 9,146 01-26-2012, 11:48 PM
Last Post: Yin



Users browsing this thread: 1 Guest(s)