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

Project1

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

关于敌人设置,请教下

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
55
在线时间
1 小时
注册时间
2007-4-20
帖子
135
跳转到指定楼层
1
发表于 2007-6-26 17:47:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
   我设置像仙剑那种自己触碰敌人的方式,我设置胜利后独立开关A打开,新建立事件页,勾上开关,打完后就没有了,但是我移动到另一福地图后再回来,也没有怪物...怎么搞的(我的意思是说:我想变成打完后消失,但我先进入别的地图后再回来还有怪物打,怎么弄?)
版务信息:本贴由楼主自主结贴~

Lv1.梦旅人

梦石
0
星屑
55
在线时间
1 小时
注册时间
2007-4-20
帖子
135
2
 楼主| 发表于 2007-6-26 17:47:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
   我设置像仙剑那种自己触碰敌人的方式,我设置胜利后独立开关A打开,新建立事件页,勾上开关,打完后就没有了,但是我移动到另一福地图后再回来,也没有怪物...怎么搞的(我的意思是说:我想变成打完后消失,但我先进入别的地图后再回来还有怪物打,怎么弄?)
版务信息:本贴由楼主自主结贴~

Lv2.观梦者

湛蓝的深海子<

梦石
0
星屑
600
在线时间
188 小时
注册时间
2006-12-5
帖子
1105

贵宾

3
发表于 2007-6-26 18:01:53 | 只看该作者
不要用独立开关,那样他就永久消失了……

一般这种遇敌方式用的是暂时消除事件,下次再进来他还会出现的
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2007-2-18
帖子
2464
4
发表于 2007-6-26 18:07:49 | 只看该作者
最近看到一个叫超!遇敌系统的东西,感觉不错
  1. #from 66RPG
  2. #-------------------------------------------------------------------------------------
  3. #超!遇敵系統
  4. #coding by Kevin Chang
  5. #追加定义15号开关为内部调用以解决剧情战死机的bug(by kaze)
  6. #==============================================================================
  7. # ■ Game_Event
  8. #------------------------------------------------------------------------------
  9. #  處理事件的程式。條件判斷、事件頁的切換、並行處理、執行事件功能
  10. #     在 Game_Map 的內部使用。
  11. #==============================================================================
  12. module RPG #新增name定義,作用於抓取事件名稱欄位值
  13. class Event
  14.    def initialize(x, y)
  15.      @id = 0
  16.      @name = ""
  17.      @x = x
  18.      @y = y
  19.      @pages = [RPG::Event::Page.new]
  20.    end
  21.    attr_accessor :id
  22.    attr_accessor :name
  23.    attr_accessor :x
  24.    attr_accessor :y
  25.    attr_accessor :pages
  26. end
  27. end
  28. class Game_Event < Game_Character
  29. #--------------------------------------------------------------------------
  30. # ● 定義實例變量
  31. #--------------------------------------------------------------------------
  32. attr_accessor   :trigger                  # 目標(改為可讀寫)
  33. attr_reader   :list                     # 執行內容
  34. attr_reader   :starting                 # 啟動中標誌
  35. attr_accessor :name                  #取得事件名稱
  36. attr_accessor :character_name #改變事件圖形為可讀寫
  37. attr_accessor :auto_fight   #敵人事件處碰啟動戰鬥設定
  38. attr_accessor :move_type          #移動方式讓 $game_map.events[event_id].move_type = ? 來設定
  39. #--------------------------------------------------------------------------
  40. # ● 初始化對像
  41. #     map_id : 地圖 ID
  42. #     event  : 事件 (RPG::Event)
  43. #--------------------------------------------------------------------------
  44. def initialize(map_id, event)
  45.    super()
  46.    @map_id = map_id
  47.    @event = event
  48.    @id = @event.id
  49.    @erased = false
  50.    @starting = false
  51.    @through = true
  52.    @name = @event.name #取得事件名稱
  53.    @character_name =""#改變事件圖形為可讀寫
  54.    @auto_fight = false #敵人事件接觸自動戰鬥
  55.    @move_type = 0 #移動方式 讓 $game_map.events[event_id].move_type = ? 來設定
  56.    #改變敵人事件的移動方法 0.不動 1.隨機 2.接近 4.自訂AI
  57.    # 初期位置的移動
  58.    moveto(@event.x, @event.y)
  59.    refresh
  60. end
  61.    #--------------------------------------------------------------------------
  62. # ● 接觸事件啟動判定
  63. #--------------------------------------------------------------------------
  64. def check_event_trigger_touch(x, y)
  65.    # 事件執行中的情況下
  66.    if $game_system.map_interpreter.running?
  67.      return
  68.    end
  69.    # 目標為 [與事件接觸] 以及和主角坐標一致的情況下
  70.    if @trigger == 2 and x == $game_player.x and y == $game_player.y
  71.      # 除跳躍中以外的情況、啟動判定就是正面的事件
  72.      if not jumping? and not over_trigger?
  73.        @auto_fight = true
  74.             start
  75.       else
  76.        @auto_fight = false
  77.      end
  78.    end
  79. end
  80. #--------------------------------------------------------------------------
  81. # ● 自動事件啟動判定
  82. #--------------------------------------------------------------------------
  83. def check_event_trigger_auto
  84.    # 目標為 [與事件接觸] 以及和主角坐標一致的情況下
  85.    if @trigger == 2 and @x == $game_player.x and @y == $game_player.y
  86.      # 除跳躍中以外的情況、啟動判定就是同位置的事件
  87.      if not jumping? and over_trigger?
  88.        @auto_fight = true
  89.        start
  90.      else
  91.        @auto_fight = false
  92.      end
  93.    end
  94.    # 目標是 [自動執行] 的情況下
  95.    if @trigger == 3
  96.      start
  97.    end
  98. end
  99. end

  100. #==============================================================================
  101. # ■ Game_Character (分割定義 2)
  102. #------------------------------------------------------------------------------
  103. #  處理角色的程式。本程式作為 Game_Player 與 Game_Event
  104. #     的超級程式使用。
  105. #==============================================================================

  106. class Game_Character
  107. #--------------------------------------------------------------------------
  108. # ● 移動類型 : 接近
  109. #--------------------------------------------------------------------------
  110. def move_type_toward_player
  111.    # 求得與主角坐標的差
  112.    sx = @x - $game_player.x
  113.    sy = @y - $game_player.y
  114.    # 求得差的絕對值
  115.    abs_sx = sx > 0 ? sx : -sx
  116.    abs_sy = sy > 0 ? sy : -sy
  117.    # 如果縱橫共計離開 20 個元件
  118.    if sx + sy >= 5#修正敵人警戒距離
  119.      # 隨機
  120.      move_random
  121.      return
  122.    end
  123.    # 隨機 0~5 的分支
  124.    case rand(6)
  125.    when 0..3  # 接近主角
  126.      move_toward_player
  127.    when 4  # 隨機
  128.      move_random
  129.    when 5  # 前進一步
  130.      move_forward
  131.    end
  132. end
  133. end

  134. #===========================================================
  135. #==============================================================================
  136. # ■ Scene_Map
  137. #------------------------------------------------------------------------------
  138. #  處理地圖畫面的程式。
  139. #==============================================================================

  140. class Scene_Map
  141. #--------------------------------------------------------------------------
  142. # ● 主處理
  143. #--------------------------------------------------------------------------
  144. $enemy_event_arry = [] #存放敵人事件的事件編號對應的敵人隊伍id(troop_id)
  145. $e_event_id = []#存放屬於敵人事件的事件id
  146. def main  
  147. @a = 0
  148.    # 生成活動塊
  149.    @spriteset = Spriteset_Map.new
  150.    # 生成訊息窗口
  151.    @message_window = Window_Message.new
  152.    # 執行過渡
  153.    Graphics.transition
  154.    # 主循環
  155.    loop do   
  156.      new_battle_module #呼叫新版遇敵系統
  157.      # 刷新遊戲畫面
  158.      Graphics.update
  159.      # 刷新輸入訊息
  160.      Input.update
  161.      # 刷新畫面
  162.      update
  163.      # 如果畫面切換的話就中斷循環
  164.      if $scene != self
  165.        break
  166.      end
  167.    end
  168.    # 準備過渡
  169.    Graphics.freeze
  170.    # 釋放活動塊
  171.    @spriteset.dispose
  172.    # 釋放訊息窗口
  173.    @message_window.dispose
  174.    # 標題畫面切換中的情況下
  175.    if $scene.is_a?(Scene_Title)
  176.      # 淡入淡出畫面
  177.      Graphics.transition
  178.      Graphics.freeze
  179.    end
  180. end
  181. #------------------------------------------------------------------
  182. #●怪物事件隨機圖示變化設計模組-主要控制
  183. #--------------------------------------------------------------------
  184. def new_battle_module
  185.    # 遇敵列表不為空的情況下
  186.    if $game_map.encounter_list != []
  187.      # 不是在事件執行中或者禁止遇敵中
  188.      unless $game_system.map_interpreter.running? or
  189.             $game_system.encounter_disabled
  190.        # 確定隊伍
  191.         for i in 1 .. $game_map.events.size
  192.           if $game_map.events[i].name == "敌人"
  193.             if $game_map.events[i].character_name == ""#避免怪物持續刷新,設置一個break的條件
  194.             $game_map.events[i].character_name = rand_enemies_character_name#改變敵人事件的圖片
  195.             $enemy_event_arry[i] = $enemy_event_id#將獲取的troop_id 存放到敵人事件陣列內
  196.             $e_event_id[@a] = i
  197.            @a += 1
  198.             $game_map.events[i].trigger = 2 #自動改為接觸啟動事件
  199.             $game_map.events[i].move_type = 2
  200.             #改變敵人事件的移動方法 0.不動 1.隨機 2.接近
  201.             # 隊伍有效的話
  202.             else
  203.               break
  204.             end#if 避免怪物持續刷新,設置一個break的條件
  205.           end
  206.       end#end for
  207.    end #unless
  208. end#if 遇敵列表不為空的情況下
  209. end#module   
  210. #--------------------------------------------------------------------
  211. #●怪物事件隨機圖示變化設計模組-戰鬥圖獲取
  212. #--------------------------------------------------------------------
  213. def rand_enemies_character_name
  214.         n = rand($game_map.encounter_list.size)#亂數取得地圖敵人列表數量
  215.         troop_id = $game_map.encounter_list[n]#亂數帶入敵人隊伍ID內,由敵人列表隨機取出一隊伍
  216.         troop = $data_troops[troop_id]#將隨機敵人隊伍資料存放到 troop 變數內
  217.         $enemy_event_id = troop_id
  218.         i =  rand(troop.members.size) #由troop隊伍資料內 隨機抽出一個敵人隊員
  219.         enemy_character_name = $data_enemies[troop.members[i].enemy_id].battler_name
  220.         #抽出的隨機敵人隊員,與data_enemies去比對出對應的怪物戰鬥圖,把戰鬥圖名稱取出
  221.          return enemy_character_name #回傳戰鬥圖名稱
  222. end
  223. #--------------------------------------------------------------------------
  224. # ● 刷新畫面
  225. #--------------------------------------------------------------------------
  226. def update
  227.    # 循環
  228.    loop do
  229.      # 按照地圖、實例、主角的順序刷新
  230.      # (本更新順序不會在的滿足事件的執行條件下成為給予角色瞬間移動
  231.      #  的機會的重要原素)
  232.      $game_map.update
  233.      $game_system.map_interpreter.update
  234.      $game_player.update
  235.      # 系統 (計時器)、畫面刷新
  236.      $game_system.update
  237.      $game_screen.update
  238.      # 如果主角在場所移動中就中斷循環
  239.      unless $game_temp.player_transferring
  240.        break
  241.      end
  242.      # 執行場所移動
  243.      transfer_player
  244.      # 處理過渡中的情況下、中斷循環
  245.      if $game_temp.transition_processing
  246.        break
  247.      end
  248.    end
  249.    # 刷新活動塊
  250.    @spriteset.update
  251.    # 刷新訊息窗口
  252.    @message_window.update
  253.    # 遊戲結束的情況下
  254.    if $game_temp.gameover
  255.      # 切換的遊戲結束畫面
  256.      $scene = Scene_Gameover.new
  257.      return
  258.    end
  259.    # 返回標題畫面的情況下
  260.    if $game_temp.to_title
  261.      # 切換到標題畫面
  262.      $scene = Scene_Title.new
  263.      return
  264.    end
  265.    # 處理過渡中的情況下
  266.    if $game_temp.transition_processing
  267.      # 清除過渡處理中標誌
  268.      $game_temp.transition_processing = false
  269.      # 執行過渡
  270.      if $game_temp.transition_name == ""
  271.        Graphics.transition(20)
  272.      else
  273.        Graphics.transition(40, "Graphics/Transitions/" +
  274.          $game_temp.transition_name)
  275.      end
  276.    end
  277.    # 顯示訊息窗口中的情況下
  278.    if $game_temp.message_window_showing
  279.      return
  280.    end
  281.    # 遇敵列表不為空的情況下且敵人事件 auto_fight 為true
  282.    for i in $e_event_id
  283.    if $game_map.encounter_list != [] and $game_map.events[i].auto_fight == true
  284.      $event_id_on_time = i #把正在進行戰鬥的 event_id 取出,以便後面呼叫使用
  285.      # 不是在事件執行中或者禁止遇敵中
  286.      unless $game_system.map_interpreter.running? or
  287.             $game_system.encounter_disabled
  288.        # 確定隊伍
  289.        troop_id = $enemy_event_arry[i]
  290.        # 隊伍有效的話
  291.        if $data_troops[troop_id] != nil
  292.          # 設置調用戰鬥標誌
  293.          $game_temp.battle_calling = true
  294.          $game_switches[15] = true
  295.          $game_temp.battle_troop_id = troop_id
  296.          $game_temp.battle_can_escape = true
  297.          $game_temp.battle_can_lose = false
  298.          $game_temp.battle_proc = nil
  299.        end
  300.      end
  301.    end
  302.    end #for
  303.    # 按下 B 鍵的情況下
  304.    if Input.trigger?(Input::B)
  305.      # 不是在事件執行中或菜單禁止中
  306.      unless $game_system.map_interpreter.running? or
  307.             $game_system.menu_disabled
  308.        # 設置菜單調用標誌以及 SE 演奏
  309.        $game_temp.menu_calling = true
  310.        $game_temp.menu_beep = true
  311.      end
  312.    end
  313.    # 調試模式為 ON 並且按下 F9 鍵的情況下
  314.    if $DEBUG and Input.press?(Input::F9)
  315.      # 設置調用調試標誌
  316.      $game_temp.debug_calling = true
  317.    end
  318.    # 不在主角移動中的情況下
  319.    unless $game_player.moving?
  320.      # 執行各種畫面的調用
  321.      if $game_temp.battle_calling
  322.        call_battle
  323.      elsif $game_temp.shop_calling
  324.        call_shop
  325.      elsif $game_temp.name_calling
  326.        call_name
  327.      elsif $game_temp.menu_calling
  328.        call_menu
  329.      elsif $game_temp.save_calling
  330.        call_save
  331.      elsif $game_temp.debug_calling
  332.        call_debug
  333.      end
  334.    end
  335. end
  336. end
  337. #==============================================================================
  338. # ■ Scene_Battle (分割定義 2)
  339. #------------------------------------------------------------------------------
  340. #  處理戰鬥畫面的程式。
  341. #==============================================================================
  342. class Scene_Battle
  343. #--------------------------------------------------------------------------
  344. # ● 畫面更新 (結束戰鬥回合)
  345. #--------------------------------------------------------------------------
  346. def update_phase5
  347.    # 等待計數大于 0 的情況下
  348.    if @phase5_wait_count > 0
  349.      # 減少等待計數
  350.      @phase5_wait_count -= 1
  351.      # 等待計數為 0 的情況下
  352.      if @phase5_wait_count == 0
  353.        # 顯示結果窗口
  354.        @result_window.visible = true
  355.        # 清除主回合標誌
  356.        $game_temp.battle_main_phase = false
  357.        # 刷新狀態窗口
  358.        @status_window.refresh
  359.      end
  360.      return
  361.    end
  362.    # 按下 C 鍵的情況下
  363.    if Input.trigger?(Input::C)
  364.      # 戰鬥結束
  365.      if $game_switches[15]
  366.       $game_map.events[$event_id_on_time].name = "死亡"
  367.       $game_map.events[$event_id_on_time].auto_fight = false
  368.       $game_map.events[$event_id_on_time].trigger = 0
  369.       $game_map.events[$event_id_on_time].erase
  370.       $game_switches[15] = false
  371.      end
  372.      battle_end(0)
  373.    end
  374. end
  375. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-9-21 08:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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