Pleas help me. most of this stuff is still gibberish to me. Can someone help me by transposing this scrip from the RMVX to RMXP note that I'm using the SDK. below is the script hidden in the spoiler.
Thank you for the time you put in, in advance. :D
SDS
#-------------------------------------------------------------------------------#
# Stealth Detection System v 1.0
# code by cmpsr2000 @ rpgrevolution.com/forums
# Released June 11, 2008
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# SDS is an advanced stealth detection system for use in RPG Maker VX games.
# To use the system, you need to build an event that begins with a script call:
#
# $game_stealth.detector(eventID, detectRange, detectAction,
# tunnelVision, trueSight)
#
# eventID: The ID of the event. Use @event_id as it's the easiest way
# detectRange: How far the "guard" is able to see. Higher numbers require
# more CPU time to proccess! Lag increases exponentially if
# you are NOT using tunnel vision.
# detectAction: The action to perform when the guard detects the player
# DEFAULT = 1
# 0: Goto jail event
# 1: Game Over
# 2: Execute common event
# 3: MGS Mode
# tunnelVision: determines whether the guard's field of view cones out or
# goes in a straight line.
# DEFAULT = false
# trueSight: determines whether the guard can see through obstacles
# DEFAULT = false
#
# NOTE: You do NOT have to set parameters that have a default.
#
# MGS MODE EXPLAINATION:
#
# When using detectAction 3 (MGS Mode) guards will be "alerted" if
# they spot the player. The guard will run to the position they spotted
# the player at, then begin to look around for the player again. If the
# guard sees the player a second time, the captureAction is performed.
#
#-------------------------------------------------------------------------------
class Game_Stealth
attr_accessor :common_event_id
def initialize
@checkedTiles = []
@fovPassability = {}
@detectingEvent = nil
@tempInterpreter = nil
@alertedGuards = []
#---------------------------------------------------------------------------
# If you use tunnel vision, set the tunnel width here. It MUST be an ODD
# number or the game will round up to the next odd number! Widths over 3
# are not recomended.
#---------------------------------------------------------------------------
@tunnelWidth = 3
#---------------------------------------------------------------------------
# The common event ID to execute when using the common event detect action
#---------------------------------------------------------------------------
@common_event_id = 1
#---------------------------------------------------------------------------
# The speed and frequency the guards move when they detect the player in
# MGS mode.
# speed: 1: x8 slower,
# 2: x4 slower
# 3: x2 slower
# 4: normal
# 5: x2 faster
# 6: x4 faster
#
# frequency: 1: lowest
# 2: lower
# 3: normal
# 4: higher
# 5: highest
#---------------------------------------------------------------------------
@guardInterceptSpeed = 4
@guardInterceptFrequency = 5
#---------------------------------------------------------------------------
# When in MGS mode, the action to be performed if the guard detects the
# player a second time. This is set by default to game_over since all other
# options require some configuration. Valid values are:
# captureAction: 0: Goto jail event
# 1: Game Over
# 2: Execute common event
#---------------------------------------------------------------------------
@captureAction = 1
#---------------------------------------------------------------------------
# How many frames a guard will wait before executing each turn when
# searching for the player after detecting them in MGS mode.
#---------------------------------------------------------------------------
@waitTime = 60
#---------------------------------------------------------------------------
# Change this to false to disable the detection radius around guards.
# This means the player can safely stand next to a guard as long as he's
# not in the guard's line of sight.
#---------------------------------------------------------------------------
@allowDetectRadius= true
@tunnelWidth += 1 if (@tunnelWidth % 2) == 1
end
#-----------------------------------------------------------------------------
# Standard update method; checks for player detection then handles MGS
# state changes for guards then checks for player detection again
#-----------------------------------------------------------------------------
def update
if $game_player.detected and not $game_player.moving?
doDetectAction
end
for guard in @alertedGuards
case guard.detectState
when nil, 0 #alerted
guard.lock
guard.returnX = guard.x
guard.returnY = guard.y
guard.returnRoute = guard.move_route
guard.returnRouteIndex = guard.move_route_index
guard.returnSpeed = guard.move_speed
guard.returnFrequency = guard.move_frequency
guard.move_speed = @guardInterceptSpeed
guard.move_frequency = @guardInterceptFrequency
guard.isAware = false
guard.detectState = guard.goto($game_player.x, $game_player.y) ? 1 : 3
guard.unlock
when 1 #intercepting
if (guard.move_route_index == guard.move_route.list.length - 1 and
guard.stopping?) or guard.move_failed
guard.lock
guard.isAware = true
guard.spinInPlace(@waitTime)
guard.detectState = 2
guard.unlock
end
when 2 #checking
if guard.move_route_index == guard.move_route.list.length - 1 and
guard.stopping?
guard.lock
guard.isAware = false
go = guard.goto(guard.returnX, guard.returnY)
guard.detectState = 3
guard.unlock
end
when 3 #returning
if guard.move_route_index == guard.move_route.list.length - 1 and not
guard.moving?
guard.lock
guard.isAware = true
guard.move_route = guard.returnRoute
guard.move_route_index = guard.returnRouteIndex
guard.move_speed = guard.returnSpeed
guard.move_frequency = guard.returnFrequency
guard.detectState = 0
@captured = false
@alertedGuards.delete(guard)
guard.unlock
end
end
end
observe
end
#-----------------------------------------------------------------------------
# Runs through the aware events(guards) on the map and tells them to check
# for the player.
#-----------------------------------------------------------------------------
def observe
for event in $game_map.events.values #events is a hash!
if event.isAware
if event.moved? or event.turned? or $game_player.moved?
if checkForDetection(event)
$game_player.detected = true
@detectingEvent = event
return
end
end
end
@checkedTiles = []
@fovPassability = {}
end
end
#-----------------------------------------------------------------------------
# Runs through each tile in the event(guard)'s field of view and checks
# it for the player. RETURNS: Boolean
# event: The guard that is currently checking for the player.
#-----------------------------------------------------------------------------
def checkForDetection(event)
return true if playerInDetectionRadius(event)
return false if playerOutOfRange(event)
fieldOfView = event.tunnelVision ? @tunnelWidth : 1
for distance in 1..event.detectRange
for width in 1..fieldOfView
return true if checkTile(event, width, distance)
end
fieldOfView += 2 unless event.tunnelVision
end
return false
end
#-----------------------------------------------------------------------------
# Checks a tile for the player. RETURNS: Boolean
# event: The guard that is currently checking for the player.
# width: The width-index of the tile being checked
# distance: The depth-index of the tile being checked
#-----------------------------------------------------------------------------
def checkTile(event, width, distance)
if event.tunnelVision
if @tunnelWidth > 1
width = width - ((@tunnelWidth - 1)/2)
else
width = 0
end
else
width -= distance
end
x = event.x
y = event.y
direction = event.direction
case direction
when 2
y += distance
x += width
when 4
y += width
x -= distance
when 6
y += width
x += distance
when 8
y -= distance
x += width
end
return false if @checkedTiles.index([x,y]) != nil
return false if tileHidden?(event, x, y)
return true if $game_player.x == x and $game_player.y == y
return false
end
#-----------------------------------------------------------------------------
# Determines the visibility of a tile to a guard. RETURNS: Boolean
# event: The guard that is currently checking for the player.
# x: The x coordinate of the tile to be checked
# y: The y coordinate of the tile to be checked
#-----------------------------------------------------------------------------
def tileHidden?(event, x, y)
return false if event.trueSight
#check the current tile first
@checkedTiles.push([x,y])
originalX = x
originalY = y
if not $game_map.passable?(x, y)
@fovPassability[[x,y]] = false
return true
end
#now check all adjacent tiles one step closer to the detector
direction = event.direction
case direction
when 2 #down
y -= 1
for i in (x-1)..(x+1)
#if we've checked the tile, then it exists in the FoV
if @checkedTiles.index([i,y]) != nil
if not @fovPassability[[i,y]]
@fovPassability[[originalX,originalY]] = false
return true
end
end
end
when 4 #left
x += 1
for i in (y-1)..(y+1)
#if we've checked the tile, then it exists in the FoV
if @checkedTiles.index([x,i]) != nil
if not @fovPassability[[x,i]]
@fovPassability[[originalX,originalY]] = false
return true
end
end
end
when 6 #right
x -= 1
for i in (y-1)..(y+1)
#if we've checked the tile, then it exists in the FoV
if @checkedTiles.index([x,i]) != nil
if not @fovPassability[[x,i]]
@fovPassability[[originalX,originalY]] = false
return true
end
end
end
when 8 #up
y += 1
for i in (x-1)..(x+1)
#if we've checked the tile, then it exists in the FoV
if @checkedTiles.index([i,y]) != nil
if not @fovPassability[[i,y]]
@fovPassability[[originalX,originalY]] = false
return true
end
end
end
end
#this tile and the blocking tiles must be passable
@fovPassability[[originalX,originalY]] = true
return false
end
#-----------------------------------------------------------------------------
# Guards and other "detector" events have an awareness of their immediate
# surroundings. If the player is adjacent to the event, they will be
# discovered if @allowDetectRadius is true. RETURNS: Boolean
# event: The guard that is currently checking for the player.
#-----------------------------------------------------------------------------
def playerInDetectionRadius(event)
return false unless @allowDetectRadius
adjacentTiles = [ [event.x, event.y - 1],
[event.x + 1, event.y - 1],
[event.x + 1, event.y],
[event.x + 1, event.y + 1],
[event.x, event.y + 1],
[event.x - 1, event.y + 1],
[event.x - 1, event.y],
[event.x - 1, event.y - 1] ]
for tile in adjacentTiles
if $game_player.x == tile[0] and $game_player.y == tile[1]
return true
end
end
return false
end
def playerOutOfRange(event)
direction = event.direction
case direction
when 2 #down
yDifference = event.y - $game_player.y
xDifference = event.x - $game_player.x
coneWidth = event.tunnelVision ? (@tunnelWidth / 2).floor : event.detectRange - 1
if yDifference > event.detectRange or $game_player.y < event.y - 1 or
(xDifference.abs > coneWidth)
return true
end
when 4 #left
yDifference = event.y - $game_player.y
xDifference = event.x - $game_player.x
coneWidth = event.tunnelVision ? (@tunnelWidth / 2).floor : event.detectRange - 1
if xDifference > event.detectRange or $game_player.x > event.x + 1 or
(yDifference.abs > coneWidth)
return true
end
when 6 #right
yDifference = $game_player.y - event.y
xDifference = $game_player.x - event.x
coneWidth = event.tunnelVision ? (@tunnelWidth / 2).floor : event.detectRange - 1
if xDifference > event.detectRange or $game_player.x < event.x - 1 or
(yDifference.abs > coneWidth)
return true
end
when 8 #up
yDifference = event.y - $game_player.y
xDifference = event.x - $game_player.x
coneWidth = event.tunnelVision ? (@tunnelWidth / 2).floor : event.detectRange - 1
if yDifference > event.detectRange or $game_player.y > event.y + 1 or
(xDifference.abs > coneWidth)
return true
end
end
return false
end
#-----------------------------------------------------------------------------
# Called in an event to enable detection for the event (guard).
# eventID: The id of the event. use @event_id in your event call!
# detectRange: How far away the guard can see
# detectAction: What happens when caught. defaults to game_over
# tunnelVision: Whether the guard has field of view or tunnel vision
# trueSight: Whether the guard can see through objects
#-----------------------------------------------------------------------------
def detector(eventID, detectRange, detectAction = 1,
tunnelVision = false, trueSight = false)
event = $game_map.events[eventID]
event.isAware = true
event.detectAction = detectAction
event.detectRange = detectRange
event.tunnelVision = tunnelVision
event.trueSight = trueSight
event.setPosition
end
#-----------------------------------------------------------------------------
# Called in an event to set the location tile of the "jail"
# eventID: The ID of the event that is at the jail location.
# Again, use @event_id
#-----------------------------------------------------------------------------
def jail(eventID)
event = $game_map.events[eventID]
@jailX = event.x
@jailY = event.y
end
#-----------------------------------------------------------------------------
# Executes the desired action upon detecting the player
#-----------------------------------------------------------------------------
def doDetectAction
case @detectingEvent.detectAction
when 0 # goto jail
sendToJail
when 1 # game over
$scene = Scene_Gameover.new
when 2 # execute common event
doCommonEvent
when 3 # MGS - enemy moves towards player position
if @detectingEvent.detectState == 2
if not @captured
case @captureAction
when 0
sendToJail
when 1, 3
gameOver
when 2
doCommonEvent
end
@captured = true
end
else
Sound.play_found
@detectingEvent.balloon_id = 1
unless @alertedGuards.include?(@detectingEvent)
@alertedGuards.push(@detectingEvent)
end
end
end
$game_player.detected = false
@detectingEvent = nil
end
#-----------------------------------------------------------------------------
# MODE 0: Send player to the "jail" tile
#-----------------------------------------------------------------------------
def sendToJail
$game_player.reserve_transfer($game_map.map_id, @jailX, @jailY,
@detectingEvent.direction)
end
#-----------------------------------------------------------------------------
# MODE 1: Game Over
#-----------------------------------------------------------------------------
def gameOver
$scene = Scene_Gameover.new
end
#-----------------------------------------------------------------------------
# MODE 2: Execute Common Event
#-----------------------------------------------------------------------------
def doCommonEvent
$game_temp.common_event_id = @common_event_id
end
end
there is also this redeffine thing here
#-------------------------------------------------------------------------------# This is a surprise ^^
#-------------------------------------------------------------------------------
module Sound
def self.play_found
Audio.se_play("Audio/SE/found.wav", 100, 100)
end
end
#-------------------------------------------------------------------------------
# This contains command for object movement and can be reused and included in
# any game_character or it's descendants.
#-------------------------------------------------------------------------------
module Movement
#-----------------------------------------------------------------------------
# Checks to see whether this object has moved since the last check.
# RETURNS: Boolean
#-----------------------------------------------------------------------------
def moved?
if self.x != @oldX or self.y != @oldY
setPosition
return true
else
return false
end
end
#-----------------------------------------------------------------------------
# Checks to see whether this object has turned.
# RETURNS: Boolean
#-----------------------------------------------------------------------------
def turned?
if self.direction != @oldDirection
setDirection
return true
else
return false
end
end
#-----------------------------------------------------------------------------
# Saves the current direction so that it can be checked against after a turn
#-----------------------------------------------------------------------------
def setDirection
@oldDirection = self.direction
end
PS: to any admin i know some don't like people posing scrip without permission i would like o to apologize