Project1
标题:
如何在游戏中改变区域ID?
[打印本页]
作者:
火锅深处
时间:
2019-5-13 11:36
标题:
如何在游戏中改变区域ID?
用了Theo的这个脚本,不过希望的其实不是两个区域交换,是说比如区域1变成区域0但是区域0还是区域0
当然不用这个脚本也完全OK。
=============================================================================
# TheoAllen - 交换区域
# Version : 1.0
# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
# (This script documentation is written in informal indonesian language)
# =============================================================================
($imported ||= {})[:Theo_RegionSwitch] = true
# =============================================================================
# Change Logs :
# -----------------------------------------------------------------------------
# 2014.03.21 - Finished script
# =============================================================================
=begin
介绍 :
本脚本可以互相切换不同区域的位置。
使用方法 :
将本脚本放在插件脚本之下,Main之上
使用脚本:
region_switch(初始区域id, 交换后区域id)
例子 :
region_switch(1, 0)
则1号区域会被视为0号区域.
使用条款 :
署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.
=end
# =============================================================================
# 无设定
# =============================================================================
class Game_System
attr_reader :regswitch
alias theo_regswitch_init initialize
def initialize
theo_regswitch_init
@regswitch = {}
end
end
class Game_Map
alias theo_regswitch_reg_id region_id
def region_id(x,y)
result = theo_regswitch_reg_id(x,y)
switch = $game_system.regswitch[[map_id, result]]
if switch.nil?
$game_system.regswitch[[map_id, result]] = result
end
return switch
end
end
class Game_Interpreter
def region_switch(region_id, switch, map_id = $game_map.map_id)
$game_system.regswitch[[map_id, region_id]] = switch
end
end
#~ class Scene_Map
#~
#~ alias theo_regtest_update update
#~ def update
#~ theo_regtest_update
#~ puts $game_player.region_id
#~ end
#~
#~ end
复制代码
作者:
张咚咚
时间:
2019-6-11 09:21
class Game_Map
#--------------------------------------------------------------------------
# ● 获取区域 ID
#--------------------------------------------------------------------------
def region_id(x, y)
valid?(x, y) ? ((@custom_region ||= {})[[x, y]] ? @custom_region[[x, y]] : @map.data[x, y, 3] >> 8) : 0
end
#--------------------------------------------------------------------------
# ● 设置区域 ID
#--------------------------------------------------------------------------
def set_region_id(x, y, id=nil)
@custom_region ||= {}
id ? @custom_region[[x, y]] = id : @custom_region.delete([x, y])
end
end
复制代码
插入到main之前。
设置区域ID:
$game_map.set_region_id(x, y, id) # 不写ID为删除自定义ID
获取区域ID:
$game_map.region_id(x, y)
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1