Project1
标题: 区域速度和区域开关 [打印本页]
作者: MIMOSHAL 时间: 7 小时前
标题: 区域速度和区域开关
用deepsick写的两个脚本,感觉用处不大,也不知道有没有和其他人写的重复,总之顺手分享出来了。
区域速度
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
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
区域开关
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
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
作者: MIMOSHAL 时间: 7 小时前
woc打错字了,应该是DeepSeek
| 欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |