#==============================================================================
# * Game_Player
#------------------------------------------------------------------------------
# ?It is the class which handles the prayer. It has the function of starting decision of the
# event and the scroll etc. of the map. Instance of this class is referred to being $game_player.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# - Constant
#--------------------------------------------------------------------------
CENTER_X = (320 - 16) * 4 # Picture central X coordinate * 4
CENTER_Y = (240 - 16) * 4 # Picture central Y coordinate * 4
#--------------------------------------------------------------------------
# - Transit possible decision
# x : X Coordinate
# y : Y Coordinate
# d : Direction (0,2,4,6,8) * In case of 0 = omnidirectional transit failures decision (for jump)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# New coordinate is calculated
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# When coordinate is outside the map
unless $game_map.valid?(new_x, new_y)
# Transit failure
return false
end
# When debugging mode ON and the CTRL key are pushed
if $DEBUG and Input.press?(Input::CTRL)
# Transit yes
return true
end
super
end
#--------------------------------------------------------------------------
# - In order to come to the picture center, setting the display position of the map
#--------------------------------------------------------------------------
def center(x, y)
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
$game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
$game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
end
#--------------------------------------------------------------------------
# - It moves to designated position
# x : X Coordinate
# y : Y Coordinate
#--------------------------------------------------------------------------
def moveto(x, y)
super
# Centering
center(x, y)
# Drawing up encounter count
make_encounter_count
end
#--------------------------------------------------------------------------
# - Step several increases
#--------------------------------------------------------------------------
def increase_steps
super
# When it is not in the midst of movement route forcing
unless @move_route_forcing
# Step several increases
$game_party.increase_steps
# When the number of steps is even number
if $game_party.steps % 2 == 0
# Slip damage check
$game_party.check_map_slip_damage
end
end
end
#--------------------------------------------------------------------------
# - Encounter count acquisition
#--------------------------------------------------------------------------
def encounter_count
return @encounter_count
end
#--------------------------------------------------------------------------
# - Encounter count compilation
#--------------------------------------------------------------------------
def make_encounter_count
# The image which shakes 2 dice
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
#--------------------------------------------------------------------------
# - Refreshment
#--------------------------------------------------------------------------
def refresh
# When party number of people 0 is
if $game_party.actors.size == 0
# Clearing the file name and hue of the character
@character_name = ""
@character_hue = 0
# Method end
return
end
# Acquiring the first actor
actor = $game_party.actors[0]
# Setting the file name and hue of the character
@character_name = actor.character_name
@character_hue = actor.character_hue
# Initializing opacity and synthetic method
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# - Event starting decision of the same position
#--------------------------------------------------------------------------
def check_event_trigger_here(triggers)
result = false
# When it is in the midst of event executing
if $game_system.map_interpreter.running?
return result
end
# Loop of all event
for event in $game_map.events.values
# When coordinate of the event and the trigger agrees
if event.x == @x and event.y == @y and triggers.include?(event.trigger)
# While jumping if at other than, starting decision event of the same position
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# - Event starting decision of front
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
# When it is in the midst of event executing
if $game_system.map_interpreter.running?
return result
end
# Calculating the coordinate of the front
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# Loop of all event
for event in $game_map.events.values
# When coordinate of the event and the trigger agrees
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# While jumping if at other than, starting decision event of front
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# When the event which corresponds is not found
if result == false
# If tile of front counter
if $game_map.counter?(new_x, new_y)
# Calculating the coordinate of 1 tile inner part
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# Loop of all event
for event in $game_map.events.values
# When coordinate of the event and the trigger agrees
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# While jumping if at other than, starting decision event of front
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# - Starting decision of contact event
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
# When it is in the midst of event executing
if $game_system.map_interpreter.running?
return result
end
# Loop of all event
for event in $game_map.events.values
# When coordinate of the event and the trigger agrees
if event.x == x and event.y == y and [1,2].include?(event.trigger)
# While jumping if at other than, starting decision event of front
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# - Frame renewal
#--------------------------------------------------------------------------
def update
# Whether or not in local variable on the move you remember
last_moving = moving?
# On the move, during event executing and during movement route forcing
# When it is not in each case is in the midst of message window indicating
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# If the direction button is pushed, moving the prayer to that direction
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# Remembering coordinate in local variable
last_real_x = @real_x
last_real_y = @real_y
super
# The character moves under, at the same time when position on the picture it is under from the center
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# Map under scroll
$game_map.scroll_down(@real_y - last_real_y)
end
# The character moves to the left, at the same time when position on the picture it is the left from the center
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# Map on the left scroll
$game_map.scroll_left(last_real_x - @real_x)
end
# The character moves to the right, at the same time when position on the picture it is the right from the center
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# Map on the right scroll
$game_map.scroll_right(@real_x - last_real_x)
end
# The character moves on, at the same time when position on the picture it is on from the center
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# Map on scroll
$game_map.scroll_up(last_real_y - @real_y)
end
# When it is not on the move
unless moving?
# When the previous prayer is on the move
if last_moving
# The event starting decision with the contact with the event of the same position
result = check_event_trigger_here([1,2])
# When there is no event which it starts
if result == false
# Debugging mode excluding the case where ON and the CTRL key are pushed
unless $DEBUG and Input.press?(Input::CTRL)
# Encounter countdown
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# When C button is pushed
if Input.trigger?(Input::C)
# The same position and event starting decision of front
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end