Project1

标题: 区域速度和区域开关 [打印本页]

作者: MIMOSHAL    时间: 7 小时前
标题: 区域速度和区域开关
用deepsick写的两个脚本,感觉用处不大,也不知道有没有和其他人写的重复,总之顺手分享出来了。

区域速度
RUBY 代码复制
  1. class Game_Player < Game_Character
  2.   RUN_SWITCH_ID = 1
  3.  
  4.   # 设置不同区域的速度限制
  5.   # 格式:区域ID => 最大允许速度
  6.   REGION_SPEED_LIMITS = {
  7.     1 => 3,  # 区域1:慢速行走(如沼泽)
  8.     2 => 4,  # 区域2:正常速度(禁止奔跑)
  9.     3 => 4,  # 区域3:正常速度(禁止奔跑)
  10.     4 => 3,  # 区域4:慢速行走
  11.     5 => 2   # 区域5:极慢速度(如深水)
  12.   }
  13.  
  14.   alias region_speed_update update
  15.   def update
  16.     region_speed_update
  17.     update_speed_with_region_limits
  18.   end
  19.  
  20.   def update_speed_with_region_limits
  21.     current_region_id = $game_map.region_id(@x, @y)
  22.  
  23.     # 如果当前区域有速度限制
  24.     if REGION_SPEED_LIMITS.has_key?(current_region_id)
  25.       max_speed = REGION_SPEED_LIMITS[current_region_id]
  26.       @move_speed = [@move_speed, max_speed].min
  27.     # 如果没有区域限制且奔跑开关为ON,则奔跑
  28.     elsif $game_switches[RUN_SWITCH_ID]
  29.       @move_speed = 5  # 奔跑速度
  30.     else
  31.       @move_speed = 4  # 正常速度
  32.     end
  33.   end
  34. end


区域开关
RUBY 代码复制
  1. class Game_Player < Game_Character
  2.   alias region_switch_update update
  3.   def update
  4.     region_switch_update
  5.     check_region_switch
  6.   end
  7.  
  8.   def check_region_switch
  9.     region_id = $game_map.region_id($game_player.x, $game_player.y)
  10.  
  11.     # 当进入区域ID为5时,打开开关10
  12.     if region_id == 5
  13.       $game_switches[10] = true
  14.     end
  15.  
  16.     # 当进入区域ID为7时,打开开关15
  17.     if region_id == 7
  18.       $game_switches[15] = true
  19.     end
  20.   end
  21. end

作者: MIMOSHAL    时间: 7 小时前
woc打错字了,应该是DeepSeek




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1