设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 20|回复: 1
打印 上一主题 下一主题

[原创发布] 区域速度和区域开关

[复制链接]

Lv2.观梦者

梦石
0
星屑
458
在线时间
51 小时
注册时间
2025-7-10
帖子
16
跳转到指定楼层
1
发表于 昨天 15:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
用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

Lv2.观梦者

梦石
0
星屑
458
在线时间
51 小时
注册时间
2025-7-10
帖子
16
2
 楼主| 发表于 昨天 15:21 | 只看该作者
woc打错字了,应该是DeepSeek
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-11-24 00:14

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表