Kain Nobel
Member
Introduction
First off, I would like to credit 3 people...
punkid89: Created the origional 'event' system I based this script from.
brewmiester: Helped me a LONG time ago on worthless old version of this script, back when I didn't know what the heck I was doing!
and...
Poccil: Although I re-wrote it somewhat, I used one of his scriptlets for the "Priority" function of this script.
Instructions
Comes with a customizable module. You can enable/disable the script by setting 'true' or 'false', set the Offset of the arrow without editing the script, determine your own graphic, etc. Also, there's 3 modes...
"Hold": Must hold the determined button in order for the graphic to appear.
"Toggle": Graphic turns on/off when you press your magic button
"Priority": Graphic will appear only when 'behind' something. This feature needs a tiny bit of modification, I'll fix it later on.
The Script
Filler Graphics
This is what I use...
http://i224.photobucket.com/albums/dd28 ... ouHere.png[/img]
Or you can use punkid89's graphic he uses with his system, somewhere in here.
http://www.rmxp.org/forums/index.php?topic=24456.0
Also, you can use these too for showing entrance ways, or whatever you want.
http://i224.photobucket.com/albums/dd28 ... ocator.png[/img]
They're character graphics, so you can change the hue/opacity for them. I like to animate mine like so...
First off, I would like to credit 3 people...
punkid89: Created the origional 'event' system I based this script from.
brewmiester: Helped me a LONG time ago on worthless old version of this script, back when I didn't know what the heck I was doing!
and...
Poccil: Although I re-wrote it somewhat, I used one of his scriptlets for the "Priority" function of this script.
Instructions
Comes with a customizable module. You can enable/disable the script by setting 'true' or 'false', set the Offset of the arrow without editing the script, determine your own graphic, etc. Also, there's 3 modes...
"Hold": Must hold the determined button in order for the graphic to appear.
"Toggle": Graphic turns on/off when you press your magic button
"Priority": Graphic will appear only when 'behind' something. This feature needs a tiny bit of modification, I'll fix it later on.
The Script
Code:
#===============================================================================
# ~** Check Player/Event Priority **~
#-------------------------------------------------------------------------------
# This scriptlet is used to check player/event priority (is player under a
# tree?)
#===============================================================================
class Bitmap
# Fast methods for retrieving bitmap data
RtlMoveMemory_pii = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
RtlMoveMemory_ipi = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
def set_data(x)
RtlMoveMemory_ipi.call(self.address, x, x.length)
end
def get_data
data = "rgba" * width * height
RtlMoveMemory_pii.call(data, self.address, data.length)
return data
end
def address
if !@address
buffer, ad = "rgba", object_id * 2 + 16
RtlMoveMemory_pii.call(buffer, ad, 4)
ad = buffer.unpack("L")[0] + 8
RtlMoveMemory_pii.call(buffer, ad, 4)
ad = buffer.unpack("L")[0] + 16
RtlMoveMemory_pii.call(buffer, ad, 4)
@address=buffer.unpack("L")[0]
end
return @address
end
end
################################################################################
#===============================================================================
# ** Game_Character
#-------------------------------------------------------------------------------
# Added method to Game_Character to check if they're 'under' an object on map.
#===============================================================================
class Game_Character
#-----------------------------------------------------------------------------
# * Behind Object?
#-----------------------------------------------------------------------------
def behind_object?
return self.screen_z < $game_map.priority(self.x,self.y)
end
end
#===============================================================================
# ** Game_Map
#-------------------------------------------------------------------------------
# Added quick methods to determine if tile is blank, or to determine the
# priority of a certain tile in a 'readable' format.
#===============================================================================
class Game_Map
#-----------------------------------------------------------------------------
# * Tile is Blank?
#-----------------------------------------------------------------------------
def tile_is_blank?(tile_id)
return false unless tile_id > 384
tile = RPG::Cache.tile(@tileset_name, tile_id, 0)
if tile.get_data[/^(...\0)+$/] # Fast way to check whether alpha of all pixels is 0
return true
end
return false
end
#-----------------------------------------------------------------------------
# * Priority
#-----------------------------------------------------------------------------
def priority(x, y)
z_max = 0
unless @map_id == 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
next if tile_id.nil? || tile_id == 0
unless @priorities[tile_id] == 0
ypos = (y * 32) - (self.display_y / 4)
unless tile_is_blank?(tile_id)
z_max = [z_max, ypos + @priorities[tile_id] * 32 + 32].max
end
end
end
end
return z_max
end
end
Code:
#===============================================================================
# ~** Arrow Over Head **~
#-------------------------------------------------------------------------------
# Written by : Kain Nobel (With Help from Brewmiester @ RMXP.org, thanks!)
# Version : 0.2
# Last Update : 2/29/2008
# Created On : 3/5/2008
#-------------------------------------------------------------------------------
# REQUIRES
# Poccil's "Check Priority" scriptlet, which is packaged with this script.
#===============================================================================
module ArrowHead
Enabled = true
Graphic = "YouHere"
Mode = "Priority"
Offset = nil
Opacity = 160
Button = Input::C
SwitchID = nil
XcludeMaps = [3]
end
#===============================================================================
# ** Scene_Map
#-------------------------------------------------------------------------------
# This class has been aliased to include the "Arrow Over Head" script to work.
#===============================================================================
class Scene_Map
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :kn_arrowhead_scene_map_main, :main
alias_method :kn_arrowhead_scene_map_update, :update
#-----------------------------------------------------------------------------
# * Main Method (*Aliased*)
#-----------------------------------------------------------------------------
def main
# If script is enabled
if ArrowHead::Enabled
# Create Arrowhead Sprite
@ah_viewport = Viewport.new(0, 0, 64, 64)
@blank = RPG::Cache.picture("")
@arrowhead = Sprite.new
@arrowhead.bitmap = RPG::Cache.picture(ArrowHead::Graphic) rescue @blank
@arrowhead.x = $game_player.screen_x - 16
unless ArrowHead::Offset.nil?
@arrowhead.y = $game_player.screen_y - ArrowHead::Offset
else
@arrowhead.y = $game_player.screen_y - 72
end
@arrowhead.z = 600
@arrowhead.opacity = ArrowHead::Opacity unless ArrowHead::Opacity.nil?
@arrowhead.visible = true
end
# Call origional method
kn_arrowhead_scene_map_main
# Dispose after loop do stuff if Scene isn't a Scene_Map
@arrowhead.dispose unless @arrowhead.nil?
end
#-----------------------------------------------------------------------------
# * Update Method (*Aliased*)
#-----------------------------------------------------------------------------
def update
kn_arrowhead_scene_map_update
if ArrowHead::Enabled and not ArrowHead::XcludeMaps.include?($game_map.map_id)
# Set Arrow's X/Y Positions
@arrowhead.x = $game_player.screen_x - 16
unless ArrowHead::Offset.nil?
@arrowhead.y = $game_player.screen_y - ArrowHead::Offset
else
@arrowhead.y = $game_player.screen_y - 72
end
# Determine Mode
case ArrowHead::Mode
when "Hold"
@arrowhead.visible = Input.press?(ArrowHead::Button)
when "Toggle"
if Input.trigger?(ArrowHead::Button)
@arrowhead.visible = !@arrowhead.visible
end
when "Priority"
@arrowhead.visible = $game_player.behind_object?
end
# Update Switch (if specified)
if ArrowHead::SwitchID.is_a?(Integer)
$game_switches[ArrowHead::SwitchID] = @arrowhead.visible
end
else
if $game_map.map_id != $game_temp.player_new_map_id
@arrowhead.visible = false unless @arrowhead.nil?
else
@arrowhead.visible = true unless @arrowhead.nil?
end
end
end
end
Filler Graphics
This is what I use...
http://i224.photobucket.com/albums/dd28 ... ouHere.png[/img]
Or you can use punkid89's graphic he uses with his system, somewhere in here.
http://www.rmxp.org/forums/index.php?topic=24456.0
Also, you can use these too for showing entrance ways, or whatever you want.
http://i224.photobucket.com/albums/dd28 ... ocator.png[/img]
They're character graphics, so you can change the hue/opacity for them. I like to animate mine like so...
http://i224.photobucket.com/albums/dd288/Kain_Nobel/KN-Arrow_Over_Head_tut_1.png[/img]