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

Project1

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

[已经过期] 區域遇敵的缺陷

 关闭 [复制链接]

Lv4.逐梦者

梦石
0
星屑
9058
在线时间
1860 小时
注册时间
2010-7-18
帖子
974
跳转到指定楼层
1
发表于 2011-1-21 22:33:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x

以下的區域遇敵有一個缺陷

Type==0的時候,獨立區域遇敵,一個區域只能遇一種敵人

如何修改成一個區域很多種敵人呢??
  1. =begin


  2. ■ 区域遇敌-脚本版 By 茄子
  3. 联系QQ 9244579


  4. 轻松设置某个区域遇敌的敌人ID
  5. 在每个地图上放一个并行事件
  6. 事件内容为脚本(也就是设置该地图的敌人)
  7. 如:

  8. Control_Enemys::RANGS = [  
  9. [1,[0,3],[0,3]],   
  10. 数据分别为
  11. [数据库里敌人队伍1,[起始X坐标0,目的X坐标3],[起始Y坐标0,目的Y坐标3]]
  12. ==>该敌人ID=1)<==     ================>该敌人遇到的范围<=============
  13. 该ID是数据库中队伍的ID,不是敌人的ID。
  14. 遇敌概率还是在地图上设置
  15. 如果不需要区域遇敌,类型 0 = 单独区域遇敌, 1 = 区域遇敌+普通遇敌 , 2 = 普通遇敌
  16. Control_Enemys::TYPE = 2
  17. ]
  18. 设置完后在最后需要设置现在地图原来的敌人编号

  19. 如:

  20. 原来地图设置敌人两个编号为 1 2 都是幽灵
  21. Control_Enemys::OLD_ENEMYS = [1,2] 这样以便返回以前的敌人。


  22. =end
  23. module Control_Enemys
  24. OLD_ENEMYS = [1,2]
  25. RANGS =  [  
  26. [1,[0,3],[0,3]],
  27. [4,[16,19],[0,3]]
  28. ]
  29. TYPE = 0
  30. end
  31. class Game_Player
  32.   attr_writer :encounter_count
  33. end
  34. class Game_Map
  35.   attr_writer :encounter_list
  36. end
  37. class Scene_Map
  38.   def update
  39.     loop do
  40.       $game_map.update
  41.       $game_system.map_interpreter.update
  42.       $game_player.update
  43.       $game_system.update
  44.       $game_screen.update
  45.       unless $game_temp.player_transferring
  46.         break
  47.       end
  48.       transfer_player
  49.       if $game_temp.transition_processing
  50.         break
  51.       end
  52.     end
  53.     @spriteset.update
  54.     @message_window.update
  55.     if $game_temp.gameover
  56.       $scene = Scene_Gameover.new
  57.       return
  58.     end
  59.     if $game_temp.to_title
  60.       $scene = Scene_Title.new
  61.       return
  62.     end
  63.     if $game_temp.transition_processing
  64.       $game_temp.transition_processing = false
  65.       if $game_temp.transition_name == ""
  66.         Graphics.transition(20)
  67.       else
  68.         Graphics.transition(40, "Graphics/Transitions/" +
  69.           $game_temp.transition_name)
  70.       end
  71.     end
  72.     if $game_temp.message_window_showing
  73.       return
  74.     end
  75.     if Control_Enemys::TYPE == 1
  76.       if $game_player.encounter_count == 0 and Control_Enemys::OLD_ENEMYS != []
  77.       unless $game_system.map_interpreter.running? or
  78.              $game_system.encounter_disabled   
  79.         n = rand(Control_Enemys::OLD_ENEMYS.size)
  80.         troop_id = Control_Enemys::OLD_ENEMYS[n]
  81.         if $data_troops[troop_id] != nil
  82.           $game_temp.battle_calling = true
  83.           $game_temp.battle_troop_id = troop_id
  84.           $game_temp.battle_can_escape = true
  85.           $game_temp.battle_can_lose = false
  86.           $game_temp.battle_proc = nil
  87.          end
  88.         end
  89.       end  
  90.     end  
  91.     else
  92.      for i in Control_Enemys::RANGS
  93.       if $game_player.x >= i[1][0] and $game_player.x <= i[1][1] and
  94.        $game_player.y >= i[2][0] and $game_player.y <= i[2][1]
  95.       if $game_player.encounter_count == 0 and i[0] != []
  96.       unless $game_system.map_interpreter.running? or
  97.              $game_system.encounter_disabled
  98.         enemys = []
  99.         enemys.push(i[0])
  100.         n = rand(enemys.size)
  101.         troop_id = enemys[n]
  102.         if $data_troops[troop_id] != nil
  103.           $game_temp.battle_calling = true
  104.           $game_temp.battle_troop_id = troop_id
  105.           $game_temp.battle_can_escape = true
  106.           $game_temp.battle_can_lose = false
  107.           $game_temp.battle_proc = nil
  108.          end
  109.         end
  110.        end  
  111.      end
  112.    end
  113.     if Control_Enemys::TYPE == 2
  114.      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  115.       unless $game_system.map_interpreter.running? or
  116.              $game_system.encounter_disabled
  117.         n = rand($game_map.encounter_list.size)
  118.         troop_id = $game_map.encounter_list[n]
  119.         if $data_troops[troop_id] != nil
  120.           $game_temp.battle_calling = true
  121.           $game_temp.battle_troop_id = troop_id
  122.           $game_temp.battle_can_escape = true
  123.           $game_temp.battle_can_lose = false
  124.           $game_temp.battle_proc = nil
  125.         end
  126.       end
  127.     end
  128.    end
  129.     if Input.trigger?(Input::B)
  130.       unless $game_system.map_interpreter.running? or
  131.         $game_system.menu_disabled
  132.         $game_temp.menu_calling = true
  133.         $game_temp.menu_beep = true
  134.       end
  135.     end
  136.     if $DEBUG and Input.press?(Input::F9)
  137.       $game_temp.debug_calling = true
  138.     end
  139.     unless $game_player.moving?
  140.       if $game_temp.battle_calling
  141.         call_battle
  142.       elsif $game_temp.shop_calling
  143.         call_shop
  144.       elsif $game_temp.name_calling
  145.         call_name
  146.       elsif $game_temp.menu_calling
  147.         call_menu
  148.       elsif $game_temp.save_calling
  149.         call_save
  150.       elsif $game_temp.debug_calling
  151.         call_debug
  152.       end
  153.     end
  154.   end
  155. end
复制代码
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
93 小时
注册时间
2009-10-16
帖子
235
2
发表于 2011-1-22 02:57:22 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9058
在线时间
1860 小时
注册时间
2010-7-18
帖子
974
3
 楼主| 发表于 2011-1-22 11:53:49 | 只看该作者
那個是敵人隊伍的ID

要變成一個區域多個敵人隊伍才對

上面打錯了不是多種是多個敵人隊伍
回复 支持 反对

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
4
发表于 2011-1-22 12:04:51 | 只看该作者
  1. =begin


  2. ■ 区域遇敌-脚本版 By 茄子
  3. 联系QQ 9244579


  4. 轻松设置某个区域遇敌的敌人ID
  5. 在每个地图上放一个并行事件
  6. 事件内容为脚本(也就是设置该地图的敌人)
  7. 如:

  8. Control_Enemys::RANGS = [  
  9. [[1],[0,3],[0,3]],   
  10. 数据分别为
  11. [数据库里敌人队伍1,[起始X坐标0,目的X坐标3],[起始Y坐标0,目的Y坐标3]]
  12. ==>该敌人ID=1)<==     ================>该敌人遇到的范围<=============
  13. 该ID是数据库中队伍的ID,不是敌人的ID。
  14. 遇敌概率还是在地图上设置
  15. 如果不需要区域遇敌,类型 0 = 单独区域遇敌, 1 = 区域遇敌+普通遇敌 , 2 = 普通遇敌
  16. Control_Enemys::TYPE = 2
  17. ]
  18. 设置完后在最后需要设置现在地图原来的敌人编号

  19. 如:

  20. 原来地图设置敌人两个编号为 1 2 都是幽灵
  21. Control_Enemys::OLD_ENEMYS = [1,2] 这样以便返回以前的敌人。


  22. =end
  23. module Control_Enemys
  24. OLD_ENEMYS = [1,2]
  25. RANGS =  [  
  26. [[1],[0,3],[0,3]],
  27. [[4,5],[16,19],[0,3]]
  28. ]
  29. TYPE = 0
  30. end
  31. class Game_Player
  32.   attr_writer :encounter_count
  33. end
  34. class Game_Map
  35.   attr_writer :encounter_list
  36. end
  37. class Scene_Map
  38.   def update
  39.     loop do
  40.       $game_map.update
  41.       $game_system.map_interpreter.update
  42.       $game_player.update
  43.       $game_system.update
  44.       $game_screen.update
  45.       unless $game_temp.player_transferring
  46.         break
  47.       end
  48.       transfer_player
  49.       if $game_temp.transition_processing
  50.         break
  51.       end
  52.     end
  53.     @spriteset.update
  54.     @message_window.update
  55.     if $game_temp.gameover
  56.       $scene = Scene_Gameover.new
  57.       return
  58.     end
  59.     if $game_temp.to_title
  60.       $scene = Scene_Title.new
  61.       return
  62.     end
  63.     if $game_temp.transition_processing
  64.       $game_temp.transition_processing = false
  65.       if $game_temp.transition_name == ""
  66.         Graphics.transition(20)
  67.       else
  68.         Graphics.transition(40, "Graphics/Transitions/" +
  69.           $game_temp.transition_name)
  70.       end
  71.     end
  72.     if $game_temp.message_window_showing
  73.       return
  74.     end
  75.     if Control_Enemys::TYPE == 1
  76.       if $game_player.encounter_count == 0 and Control_Enemys::OLD_ENEMYS != []
  77.       unless $game_system.map_interpreter.running? or
  78.              $game_system.encounter_disabled   
  79.         n = rand(Control_Enemys::OLD_ENEMYS.size)
  80.         troop_id = Control_Enemys::OLD_ENEMYS[n]
  81.         if $data_troops[troop_id] != nil
  82.           $game_temp.battle_calling = true
  83.           $game_temp.battle_troop_id = troop_id
  84.           $game_temp.battle_can_escape = true
  85.           $game_temp.battle_can_lose = false
  86.           $game_temp.battle_proc = nil
  87.          end
  88.         end
  89.       end  
  90.     end  
  91.     else
  92.      for i in Control_Enemys::RANGS
  93.       if $game_player.x >= i[1][0] and $game_player.x <= i[1][1] and
  94.        $game_player.y >= i[2][0] and $game_player.y <= i[2][1]
  95.       if $game_player.encounter_count == 0 and i[0] != []
  96.       unless $game_system.map_interpreter.running? or
  97.              $game_system.encounter_disabled
  98.         enemys = []
  99.         if i[0].size == 1
  100.           enemys.push(i[0][0])
  101.         else
  102.           enemys.push(i[0][rand(i[0].size-1)])
  103.         end
  104.         n = rand(enemys.size)
  105.         troop_id = enemys[n]
  106.         if $data_troops[troop_id] != nil
  107.           $game_temp.battle_calling = true
  108.           $game_temp.battle_troop_id = troop_id
  109.           $game_temp.battle_can_escape = true
  110.           $game_temp.battle_can_lose = false
  111.           $game_temp.battle_proc = nil
  112.          end
  113.         end
  114.        end  
  115.      end
  116.    end
  117.     if Control_Enemys::TYPE == 2
  118.      if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  119.       unless $game_system.map_interpreter.running? or
  120.              $game_system.encounter_disabled
  121.         n = rand($game_map.encounter_list.size)
  122.         troop_id = $game_map.encounter_list[n]
  123.         if $data_troops[troop_id] != nil
  124.           $game_temp.battle_calling = true
  125.           $game_temp.battle_troop_id = troop_id
  126.           $game_temp.battle_can_escape = true
  127.           $game_temp.battle_can_lose = false
  128.           $game_temp.battle_proc = nil
  129.         end
  130.       end
  131.     end
  132.    end
  133.     if Input.trigger?(Input::B)
  134.       unless $game_system.map_interpreter.running? or
  135.         $game_system.menu_disabled
  136.         $game_temp.menu_calling = true
  137.         $game_temp.menu_beep = true
  138.       end
  139.     end
  140.     if $DEBUG and Input.press?(Input::F9)
  141.       $game_temp.debug_calling = true
  142.     end
  143.     unless $game_player.moving?
  144.       if $game_temp.battle_calling
  145.         call_battle
  146.       elsif $game_temp.shop_calling
  147.         call_shop
  148.       elsif $game_temp.name_calling
  149.         call_name
  150.       elsif $game_temp.menu_calling
  151.         call_menu
  152.       elsif $game_temp.save_calling
  153.         call_save
  154.       elsif $game_temp.debug_calling
  155.         call_debug
  156.       end
  157.     end
  158.   end
  159. end
复制代码
小改了一下,不知道行不行

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9058
在线时间
1860 小时
注册时间
2010-7-18
帖子
974
5
 楼主| 发表于 2011-1-22 12:12:40 | 只看该作者
本帖最后由 ms0688987 于 2011-1-22 14:07 编辑

應該怎麼用呢?



是這樣[[1]+[2],[1,11],[6,6]],
還是[[1][2],[1,11],[6,6]],

還是[[1],[1,11],[6,6]],
       [[2],[1,11],[6,6]],兩個同區域判定

可是都不行   同區域2個隊伍以上要怎麼設定???

点评

[[1][2],[1,11],[6,6]]  发表于 2011-1-22 14:52
看注释,和原来的差不多,只是原来的区域遇敌队伍ID要用[]括住,只有一个也要括  发表于 2011-1-22 12:33
回复 支持 反对

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
6
发表于 2011-1-22 14:54:08 | 只看该作者
回复 ms0688987 的帖子

把我那个脚本的113行去掉,114行改成 troop_id = enemys[0]

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9058
在线时间
1860 小时
注册时间
2010-7-18
帖子
974
7
 楼主| 发表于 2011-1-22 15:06:24 | 只看该作者
本帖最后由 ms0688987 于 2011-1-22 18:52 编辑

測試出來了

可是我用[[1,2,3,4],[1,11],[5,5]],

只會有1,2,3種怪遇的到

遇了10幾場沒半場4的隊伍

不知道是遇不到還是人品太差

点评

啊,应该是用[[1,2],[1,11],[6,6]]- -  发表于 2011-1-22 15:15
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-2-20 17:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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