用deepsick写的两个脚本,感觉用处不大,也不知道有没有和其他人写的重复,总之顺手分享出来了。
区域速度
RUBY 代码 - class Game_Player < Game_Character
- RUN_SWITCH_ID = 1
- # 设置不同区域的速度限制
- # 格式:区域ID => 最大允许速度
- REGION_SPEED_LIMITS = {
- 1 => 3, # 区域1:慢速行走(如沼泽)
- 2 => 4, # 区域2:正常速度(禁止奔跑)
- 3 => 4, # 区域3:正常速度(禁止奔跑)
- 4 => 3, # 区域4:慢速行走
- 5 => 2 # 区域5:极慢速度(如深水)
- }
- alias region_speed_update update
- def update
- region_speed_update
- update_speed_with_region_limits
- end
- def update_speed_with_region_limits
- current_region_id = $game_map.region_id(@x, @y)
- # 如果当前区域有速度限制
- if REGION_SPEED_LIMITS.has_key?(current_region_id)
- max_speed = REGION_SPEED_LIMITS[current_region_id]
- @move_speed = [@move_speed, max_speed].min
- # 如果没有区域限制且奔跑开关为ON,则奔跑
- elsif$game_switches[RUN_SWITCH_ID]
- @move_speed = 5 # 奔跑速度
- else
- @move_speed = 4 # 正常速度
- end
- end
- end
复制代码
区域开关
RUBY 代码 - class Game_Player < Game_Character
- alias region_switch_update update
- def update
- region_switch_update
- check_region_switch
- end
- def check_region_switch
- region_id = $game_map.region_id($game_player.x, $game_player.y)
- # 当进入区域ID为5时,打开开关10
- if region_id == 5
- $game_switches[10] = true
- end
- # 当进入区域ID为7时,打开开关15
- if region_id == 7
- $game_switches[15] = true
- end
- end
- end
复制代码
本帖来自P1论坛作者MIMOSHAL,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址: https://rpg.blue/forum.php?mod=viewthread&tid=498320 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。 |