| 赞 | 406 |
| VIP | 0 |
| 好人卡 | 11 |
| 积分 | 402 |
| 经验 | 242285 |
| 最后登录 | 2025-11-4 |
| 在线时间 | 5850 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 40214
- 在线时间
- 5850 小时
- 注册时间
- 2006-11-10
- 帖子
- 6713
|
本帖最后由 灯笼菜刀王 于 2025-10-27 10:36 编辑
栗子, 比如你想要 A区域出现 幽灵 , B区域出现 丧尸, 那, 在数据库建两个敌群, 起名为 ”【0】幽灵“ 和 “【1】丧尸”,然后在地图遇敌列表里把这两个敌群放进去
然后, 想办法给AB两区域做区分, 可以用变量法 也可以用其他, 地形标志,区域ID(新增脚本)等, 只要让pleyer在进入指定区域时, 能获得"0","1" 这样的判断即可
这里用变量法举例子, 可以在地上铺事件, 但是要并排铺两个, 一个踩上的时候改变量为0, 一个踩上时改变量为1, 这样玩家在走出来的时候, 就会自动改变量数值, 并且走到一半回头也不会出问题
但是, 铺事件的方式在有"入口出口"的区域比较好用, 像你图上这样四通八达的区域, 铺一圈事件太麻烦了, 此时可以用并行处理, 通过player的坐标判断, 实时切换变量值
例如, 并行处理, 执行脚本
x = $game_player.x
y = $game_player.y
if x > 10 and x < 16 and y > 10 and y < 11
$game_variables[10086] = 1
else
$game_variables[10086] = 0
end
这样, 就把一个区域给圈上了, 只要玩家走到对应坐标就会改变量为1, 走出去就会改为0了, 此时遇敌就是指定的敌群啦
--------------
class Game_Player def tag_set(ary) (@tag_list = nil ;return) if ary.nil? @tag_list = ary end alias old_increase_steps increase_steps def increase_steps #[id,x1,y1,x2,y2] old_increase_steps return if @tag_list.nil? or @tag_list.empty? f = @tag_list.find{|j| @x >= j[1] && @x <= j[3] && @y >= j[2] && @y <= j[4]} $game_variables[10086] = f.nil? ? 0 : f[0] end end class Interpreter def 区域设置(*ary) ($game_player.tag_set(nil)) if ary[0] == nil $game_player.tag_set(ary) end end
class Game_Player
def tag_set(ary)
(@tag_list = nil ;return) if ary.nil?
@tag_list = ary
end
alias old_increase_steps increase_steps
def increase_steps #[id,x1,y1,x2,y2]
old_increase_steps
return if @tag_list.nil? or @tag_list.empty?
f = @tag_list.find{|j| @x >= j[1] && @x <= j[3] && @y >= j[2] && @y <= j[4]}
$game_variables[10086] = f.nil? ? 0 : f[0]
end
end
class Interpreter
def 区域设置(*ary)
($game_player.tag_set(nil)) if ary[0] == nil
$game_player.tag_set(ary)
end
end
每个区域都要写一串代码太麻烦了, 就附赠你一个直接设置的方法吧, 把它复制到上面那个脚本之下(记得把10086 改成你的区域变量ID数字)
然后, 每张地图, 都设置个"自动执行"的事件, 事件内容为
脚本: 区域设置([1,8,9,10,11],
[2,12,13,14,15],[3,16,17,18,19])
暂时消除事件
-
中括号内的数字是 [区域ID, x1,y1,x2,y2] , 这样在 第一个点和第二个点之间拉出来的矩形就是指定区域, 可以无限添加区域(不过受脚本框限制,笑, 写不下再去改造吧), 在添加的区域以外就是区域0
PS: 要换行的话从逗号处换, 有重叠的区域, 取最靠前的ID
如果想解除区域设置, 就执行事件脚本: 区域设置(nil) ;
========================
也可以用区域设置脚本, 传送门
此时, 把上面的脚本, tag = 1.to_s 改成 tag = $game_map.xy_ids($game_player.x,$game_player.y)[0].to_s; 就可以了, 比用变量方便, 缺点是需要你会用这个脚本
|
|