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

Project1

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

[已经解决] 如何在游戏中改变区域ID?

[复制链接]

Lv5.捕梦者

梦石
18
星屑
13525
在线时间
1708 小时
注册时间
2017-1-12
帖子
1771

开拓者

跳转到指定楼层
1
发表于 2019-5-13 11:36:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
用了Theo的这个脚本,不过希望的其实不是两个区域交换,是说比如区域1变成区域0但是区域0还是区域0
当然不用这个脚本也完全OK。
  1. =============================================================================
  2. # TheoAllen - 交换区域
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_RegionSwitch] = true
  8. # =============================================================================
  9. # Change Logs :
  10. # -----------------------------------------------------------------------------
  11. # 2014.03.21 - Finished script
  12. # =============================================================================
  13. =begin

  14.   介绍 :
  15.   本脚本可以互相切换不同区域的位置。
  16.   
  17.   使用方法 :
  18.   将本脚本放在插件脚本之下,Main之上
  19.   
  20.   使用脚本:
  21.   
  22.   region_switch(初始区域id, 交换后区域id)
  23.   
  24.   例子 :
  25.   
  26.   region_switch(1, 0)
  27.   
  28.   则1号区域会被视为0号区域.
  29.   
  30.   使用条款 :
  31.   署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  32.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.   

  33. =end
  34. # =============================================================================
  35. # 无设定
  36. # =============================================================================
  37. class Game_System
  38.   attr_reader :regswitch
  39.   
  40.   alias theo_regswitch_init initialize
  41.   def initialize
  42.     theo_regswitch_init
  43.     @regswitch = {}
  44.   end
  45.   
  46. end

  47. class Game_Map
  48.   
  49.   alias theo_regswitch_reg_id region_id
  50.   def region_id(x,y)
  51.     result = theo_regswitch_reg_id(x,y)
  52.     switch = $game_system.regswitch[[map_id, result]]
  53.     if switch.nil?
  54.       $game_system.regswitch[[map_id, result]] = result
  55.     end
  56.     return switch
  57.   end
  58.   
  59. end

  60. class Game_Interpreter
  61.   
  62.   def region_switch(region_id, switch, map_id = $game_map.map_id)
  63.     $game_system.regswitch[[map_id, region_id]] = switch
  64.   end
  65.   
  66. end

  67. #~ class Scene_Map
  68. #~   
  69. #~   alias theo_regtest_update update
  70. #~   def update
  71. #~     theo_regtest_update
  72. #~     puts $game_player.region_id
  73. #~   end
  74. #~   
  75. #~ end
复制代码

Lv4.逐梦者

梦石
0
星屑
19284
在线时间
3074 小时
注册时间
2013-1-11
帖子
1288
2
发表于 2019-6-11 09:21:31 | 只看该作者
  1. class Game_Map
  2.   #--------------------------------------------------------------------------
  3.   # ● 获取区域 ID
  4.   #--------------------------------------------------------------------------
  5.   def region_id(x, y)
  6.     valid?(x, y) ? ((@custom_region ||= {})[[x, y]] ? @custom_region[[x, y]] : @map.data[x, y, 3] >> 8) : 0
  7.   end
  8.   #--------------------------------------------------------------------------
  9.   # ● 设置区域 ID
  10.   #--------------------------------------------------------------------------
  11.   def set_region_id(x, y, id=nil)
  12.     @custom_region ||= {}
  13.     id ? @custom_region[[x, y]] = id : @custom_region.delete([x, y])
  14.   end
  15. end
复制代码


插入到main之前。
设置区域ID:$game_map.set_region_id(x, y, id) # 不写ID为删除自定义ID
获取区域ID:$game_map.region_id(x, y)

评分

参与人数 1星屑 +100 收起 理由
VIPArcher + 100 我很赞同

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 20:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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