| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-7-27 |
| 在线时间 | 158 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 158 小时
- 注册时间
- 2016-1-7
- 回帖
- 102
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 燕征 于 2016-3-31 03:36 编辑
我照著[RMXP发布] 五合一推箱子【更新15.8.20】範例
使用該範例提供的腳本、公共事件、事件設定(設置成只推,不可重疊,使用的開關號碼、公共事件號碼換了)
想做出推箱的關卡
註:事件只有設置主角左前的石頭及石頭正前方的洞
但洞完全只有路障功能,而石頭會神奇地被隔空踹走,請問是還有什麼地方沒有注意到嗎@@?
[fold=此方法使用之推箱腳本: 推箱子-只推+推拉-可重疊][pre lang="ruby"]#==============================================================================
#==============================================================================
# ■ [XP] 推箱子-只推+推拉-可重叠
#------------------------------------------------------------------------------
# ★ 说明
# * 推箱子游戏用脚本
# * 只支持”直接推箱子“及“按着确定键拉箱子”
# * 可重叠事件
# * 可设定“只推”或“可推拉”
# * 有两处可以自己设定,分别是”第30行“及“第136行”
#------------------------------------------------------------------------------
# 更新作者:蝉岭Cicada
# 许可协议:FSL
#------------------------------------------------------------------------------
# ★ 历史版本
#
# - 1.2.0000 by 20150820
# * 修改;简化脚本和公共事件
#
# - 1.1.0000 by 20150720
# * 修改;集成“只推”与“推拉”、“重叠”与”不重叠“
#
# - 1.0.0000 by 20150719
# * 初版;
#
#------------------------------------------------------------------------------
$ccdscript ||= {}
$ccdscript[:ccd20150820] = "1.1.0000.20150720"
module FSL
module CCD
#------------------------------------------------------------------------------
# ◆ 设定部分
#------------------------------------------------------------------------------
OVER = 0
# 重叠开关:
# 1 为 开
# 0 为 关
# 不需要时建议关,避免卡
PUSHONLY = 1
# 只推开关:
# 1 为 开
# 0 为 关
# 只能推,不能拉。推的过程中,按确定键可以停止。
SE_NAME = "041-Knock02" # "音效名称"
SE_VOICE = 80 # 音量
SE_TEMPLE = 100 # 节拍
# 推拉音效:
# 通用音效
# 依次是 "音效名称"、音量、 节拍
#------------------------------------------------------------------------------
# 设定结束
#------------------------------------------------------------------------------
# 请勿更改
SE = RPG::AudioFile.new(SE_NAME, SE_VOICE, SE_TEMPLE)
end #end module CCD
end #end modul FSL
#==============================================================================
#==============================================================================
class Game_Player < Game_Character
# include
include FSL
#------------------------------------------------------------------------
# 重叠的 判断、开关开启、事件触发 及 说明
#------------------------------------------------------------------------
@@lambda_over = lambda{|tx, ty, event_move|
$game_map.events.values.each do |target|
if target.x == $game_player.x + tx && target.y == $game_player.y + ty &&
target.list[0].code==108 &&
( # 有 4 种重叠的情况:
# 1.不指定:
# 在目标的第1行,注释上 0
# 可被所有箱子重叠
target.list[0].parameters[0] == 0.to_s ||
# 2.指定事件ID:
# 在目标的第1行,注释上 指定的事件ID
# 只可被唯一箱子重叠
target.list[0].parameters[0] == @@event.id.to_s ||
# 3.指定图形:
# 在目标的第1、2、3行,注释上 想重叠的箱子的 文件名、面向、图形
# 面向:上下左右 依次是 2、4、6、8
# 图形:由左至右 依次是 0、1、2、3
# 可被相同的图形的箱子重叠
if target.list.size >=3
[target.list[0].parameters[0],
target.list[1].parameters[0],
target.list[2].parameters[0]] ==
[@@event.character_name,
@@event.direction.to_s,
@@event.pattern.to_s];end ||
# 4.指定复数个事件ID:
# 在目标的第1行,注释上 指定的事件ID
# 只可被指定的复数个箱子重叠
# ID间,以 "|" 隔开
# 如:2|3|5
target.list[0].parameters[0].split("|").include?(@@event.id.to_s) if
target.list[0].parameters[0].class == String
) # 以上判断
# 事件移动实现
event_move.call
#--------------------------------------------------------------------
# ◆ 自定义部分(自行发挥)
#--------------------------------------------------------------------
$game_self_switches[[$game_map.map_id, @@event.id, "A"]] = true
$game_self_switches[[$game_map.map_id, target.id, "A"]] = true
$game_switches[28] = true
# 预设:
# 开启 "事件" 及 "目标" 的 "独立开关A"
# 开关[28] 为 ON (重叠判定开关)
$game_map.need_refresh = true
# 刷新地图
# 以下参考:
# $game_self_switches[] = true
# $game_switches[] = true
# $game_variables[] = -1
#--------------------------------------------------------------------
# 自定义结束
#--------------------------------------------------------------------
end # end if
end # end do
} # end lambda
#------------------------------------------------------------------------
# 重叠的设定结束
#------------------------------------------------------------------------
def update
last_moving = moving?
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# Event
event = @@event = $game_system.map_interpreter.event
# 箱子和主角速度相等
ps = $game_player.instance_variable_get(:@move_speed)
es = event.instance_variable_get(:@move_speed)
if ps != es
event.instance_variable_set(:@move_speed, ps)
end
# 音效
se = lambda{event.list[-2].code == 250 ? $game_system.se_play(event.list[-2].parameters[0]) : $game_system.se_play(FSL::CCD::SE)}
case Input.dir4
when 2
if $game_switches[27] == true
# 下拉
if FSL::CCD::PUSHONLY == 0 && Input.press?(Input::C)
if $game_player.y > event.y && passable?(@x, @y, 2)
se.call
event.y += 1
move_down
end #end if
# 下推
elsif !Input.press?(Input::C)
if $game_player.y < event.y && passable?(@x, @y + 1, 2)
se.call
event.y += 1
elsif FSL::CCD::OVER == 1
@@lambda_over.call(0, 2, lambda{event.y += 1})
end #end if
move_down
end #end if
else
move_down
end #end if
when 4
if $game_switches[27] == true
# 左拉
if FSL::CCD::PUSHONLY == 0 && Input.press?(Input::C)
if $game_player.x < event.x && passable?(@x, @y, 4)
se.call
event.x -= 1
move_left
end #end if
# 左推
elsif !Input.press?(Input::C)
if $game_player.x > event.x && passable?(@x - 1, @y, 4)
se.call
event.x -= 1
elsif FSL::CCD::OVER == 1
@@lambda_over.call(-2, 0, lambda{event.x -= 1})
end #end if
move_left
end #end if
else
move_left
end #end if
when 6
if $game_switches[27] == true
# 右拉
if FSL::CCD::PUSHONLY == 0 && Input.press?(Input::C)
if $game_player.x > event.x && passable?(@x, @y, 6)
se.call
event.x += 1
move_right
end #end if
# 右推
elsif !Input.press?(Input::C)
if $game_player.x < event.x && passable?(@x + 1, @y, 6)
se.call
event.x += 1
elsif FSL::CCD::OVER == 1
@@lambda_over.call(2, 0, lambda{event.x += 1})
end #end if
move_right
end #end if
else
move_right
end #end if
when 8
if $game_switches[27] == true
if FSL::CCD::PUSHONLY == 0 && Input.press?(Input::C)
# 上拉
if $game_player.y < event.y && passable?(@x, @y, 8)
se.call
event.y -= 1
move_up
end #end if
# 上推
elsif !Input.press?(Input::C)
if $game_player.y > event.y && passable?(@x, @y - 1, 8)
se.call
event.y -= 1
elsif FSL::CCD::OVER == 1
@@lambda_over.call(0, -2, lambda{event.y -= 1})
end #end if
move_up
end #end if
else
move_up
end #end if
end #end case
end#end unless
last_real_x = @real_x
last_real_y = @real_y
super
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y - last_real_y)
end
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
$game_map.scroll_left(last_real_x - @real_x)
end
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x - last_real_x)
end
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
$game_map.scroll_up(last_real_y - @real_y)
end
unless moving?
if last_moving
result = check_event_trigger_here([1,2])
if result == false
unless $DEBUG and Input.press?(Input::CTRL)
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
if Input.trigger?(Input::C)
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end #end def
end #end class
class Game_Character; attr_accessor :x; attr_accessor :y; end
class Interpreter; attr_accessor :event_id
def x; $game_map.events[event_id].x; end
def y; $game_map.events[event_id].y; end
def event; $game_map.events[event_id]; end
end
#==============================================================================
#==============================================================================
[/pre][/fold] |
|