# 多种地图能力 v1.1
#----------#
#特点: 我也不懂该叫什么。此脚本可以让玩家拥有跳跃,投掷和抓东西的能力。
#
#使用方法: 即插即用,在下面根据自己的需要进行设定
#.
# 跳跃:
# 按跳跃键(A键)可以让玩家向前跳跃两格.
# 不会跳到不可通行的图块上,也不会跳到"不可跳跃区域"的图块上.
# 可以通过开关禁用此功能.
#
# 投掷:
# 使用脚本: pickup
# 可以被捡起的事件会被玩家捡起.再次按下确认键后,事件会被投掷
# 2图块远的位置,不会丢到不可通行的图块上。
# 事件被投掷且落地后,会自动开启其D独立开关。
# (事件可以捡起其他事件,使用脚本:
# pick_up(事件_id) - 但只能在移动路线中使用.
# 也可以被投掷,使用脚本:
# throw - 同样只能在移动路线中使用.)
#
# 抓取:
# 使用脚本: grab
# 事件可以被玩家抓取.抓取时,玩家只能向前或向后移动,再按下确定键后
# 可以松手。
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
# provided on facebook: [url]http://www.facebook.com/DaimoniousTailsGames[/url]
# All my other scripts and projects can be found here: [url]http://daimonioustails.weebly.com/[/url]
#
#- Free to use in any project with credit given, donations always welcome!
#跳跃键:
JUMP_KEY = :Z
#不可跳跃区域
NO_JUMP_REGIONS = [10,11]
#禁用跳跃的开关, 开关开启时,玩家无法跳跃
TOGGLE_JUMP_SWITCH = 323
#事件名中包含以下字符的,玩家可以跳跃过该事件
JUMP_EVENT_STRING = "BG"
class Game_Character < Game_CharacterBase
attr_accessor :carried
attr_accessor :through
attr_accessor :priority_type
attr_accessor :x
attr_accessor :y
attr_accessor :direction
attr_accessor :direction_fix
attr_accessor :move_succeed
alias env_screen_y screen_y
alias env_screen_x screen_x
def pick_up(event_id)
@carrying = event_id
@carrying = $game_map.events[event_id] if $game_map.events[event_id]
@carrying.through = true
@carrying.carried = self
@carrying.priority_type = 2
end
def throw
@carrying.moveto(@x,@y)
@carrying.direction = @direction
return unless @carrying.jump_forward_field
@carrying.thrown
@carrying.through = false
@carrying.priority_type = 1
@carrying.carried = nil
@carrying = nil
end
def screen_y
@carried ? @carried.screen_y - 24 : env_screen_y
end
def screen_x
@carried ? @carried.screen_x : env_screen_x
end
def can_jump?(x,y)
return false if NO_JUMP_REGIONS.include?($game_map.region_id(@x+x/2,@y+y/2))
return false if NO_JUMP_REGIONS.include?($game_map.region_id(@x+x,@y+y))
map_passable?(@x+x,@y+y,@direction) && !collide_with_characters?(@x+x,@y+y) &&
!sp_cwc(@x+x/2,@y+y/2)
end
def sp_cwc(x, y)
$game_map.events_xy_nt(x, y).any? do |event|
next if event.name.include?(JUMP_EVENT_STRING)
event.normal_priority? || self.is_a?(Game_Event)
end
end
def jump_forward_field
return jump_straight(0,2) if @direction == 2
return jump_straight(-2,0) if @direction == 4
return jump_straight(2,0) if @direction == 6
return jump_straight(0,-2) if @direction == 8
end
def jump_straight(x,y)
return false if jumping?
if can_jump?(x,y)
jump(x,y)
return true
else
jump(0,0)
return false
end
end
def thrown
end
end
class Game_Player < Game_Character
alias throw_cae check_action_event
alias throw_ms move_straight
alias throw_update update
def update
throw_update
if !Input.press?(:C) && @grabbed
@grabbed = nil
@direction_fix = false
@move_speed += 1
@move_frequency += 1
end
end
def move_by_input
allow = !$game_switches[TOGGLE_JUMP_SWITCH]
return jump_forward_field if Input.trigger?(JUMP_KEY) && !@grabbed && allow
return if !movable? || $game_map.interpreter.running?
return if jumping?
move_straight(Input.dir4) if Input.dir4 > 0
end
def check_action_event
if @carrying
throw
return true
end
throw_cae
end
def grab(event_id)
@grabbed = $game_map.events[event_id]
@move_speed -= 1
@move_frequency -= 1
@grabbed.move_speed = @move_speed
@grabbed.move_frequency = @move_frequency
@direction_fix = true
end
def move_straight(d, tok = true)
return throw_ms(d, tok) if @grabbed.nil?
return unless @direction == d || @direction == (d-10).abs
if @direction == d
@grabbed.move_straight(d,tok)
throw_ms(d, tok) if @grabbed.move_succeed
elsif @direction == (d-10).abs
throw_ms(d,tok)
@grabbed.move_straight(d,tok) if @move_succeed
end
end
end
class Game_Event < Game_Character
attr_accessor :move_speed
attr_accessor :move_frequency
def thrown
super
$game_self_switches[[@map_id, @id, "D"]] = true
end
def update
super
check_event_trigger_auto
return unless @interpreter
@interpreter.setup(@list, @event.id) unless @interpreter.running?
@interpreter.update unless jumping?
end
def name
@event.name
end
end
class Game_Interpreter
def pickup
$game_player.pick_up(@event_id)
end
def grab
$game_player.grab(@event_id)
end
end