查看: 2083|回复: 5

[已经解决] 为什么敌群里面无法用开关呼叫并行公共事件

[复制链接]
梦石
0
星屑
50
在线时间
203 小时
注册时间
2014-9-5
回帖
391
发表于 2014-12-5 21:27:48 | 显示全部楼层 |阅读模式

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

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

×
在数据库敌群 下面的事件表里 写 事件第一页 回合0 时,打开开关 1号

然后 某公共事件的并行执行条件就是 开关1 打开 时, 但是怎么也不生效,公共事件不出现

而只能在战斗事件里直接叫出该公共事件才有效
http://weibo.com/234216217
大家好,这是我的微博,一起关注独立游戏与RM游戏
我的微博名:落华蜂

闇吼者の災悪眷族

梦石
0
星屑
1366
在线时间
2881 小时
注册时间
2014-7-29
回帖
6408
发表于 2014-12-5 21:29:32 | 显示全部楼层
本帖最后由 三途亚梦 于 2014-12-5 21:37 编辑

没有为啥,就是不行……

并行事件的触发和运行机理大概是不符合战斗的回合制原理的,所以其触发在战斗中设置为不可。

评分

参与人数 1星屑 +2 收起 理由
taroxd + 2 你自己去看看代码不就知道了

查看全部评分

回复

使用道具 举报

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-12-5 21:38:47 | 显示全部楼层
本帖最后由 taroxd 于 2014-12-5 21:43 编辑
三途亚梦 发表于 2014-12-5 21:29
没有为啥,就是不行……

并行事件的触发机理大概是不符合战斗的回合制原理的,所以其触发在战斗 ...


我没记错的话F1应该有写,并行事件只在地图处理中有效。

原因是并行事件的更新是在 Game_Map 中的(没记错的话),而战斗时并不会对地图进行更新。
战斗时的事件处理应该是只有在某些特定的时间点(如:回合开始/行动结束/回合结束)等进行判断的。

这是一个合理的设定。比如说,万一你在选择技能目标的时候,一个并行事件把敌人弄死,甚至把所有敌人都灭了怎么办……考虑并行事件的话,会使场景的逻辑复杂很多。

不妨考虑一下,把并行事件的内容直接写进战斗场景的 update 里面吧。事件的所有功能都可以由脚本来完成的。

评分

参与人数 3星屑 +188 梦石 +1 收起 理由
落华蜂 + 100 认可答案
VIPArcher + 1 我很赞同
三途亚梦 + 88 感谢TD触科普~

查看全部评分

回复

使用道具 举报

无限の剣制

梦石
0
星屑
10450
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2014-12-5 21:42:23 | 显示全部楼层
如果事件的内容可以不用通过并行来实现,不妨尝试在战斗者每次行动前/后执行一次该公共事件。我记得之前有人问过类似的问题就是用这个方法解决的

评分

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

查看全部评分

回复

使用道具 举报

梦石
0
星屑
55
在线时间
473 小时
注册时间
2014-5-28
回帖
363
发表于 2014-12-6 04:58:45 | 显示全部楼层
本帖最后由 DivineCrow 于 2014-12-6 05:01 编辑

 
试试看这个吧

可以在战斗或是商店等场景执行公共事件

在公共事件的最上面备注[pre lang="ruby" line="1"]<run scene: current>[/pre]

Scene Interpreter By 姫HimeWorks[pre lang="ruby" line="1"]=begin
#===============================================================================
Title: Scene Interpreter
Author: Hime
Date: Nov 19, 2014
--------------------------------------------------------------------------------
** Change log
Nov 19, 2014
   - Interpreter is re-created on reset so commands don't continue to run from
     the previous session
Oct 13, 2014
   - added support for disabling other windows when interpreter takes control
   - moved interpreter into SceneManager as a global scene interpreter
Sep 5, 2013
   - fixed bug where common events returning to map did not execute properly
Apr 24, 2013
   - fixed bug where game crashed when no common events were reserved
Apr 3, 2013
   - Added comment to determine scene to run common event
Mar 30, 2013
   - Initial release
--------------------------------------------------------------------------------   
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** Description

This script adds an interpreter and message window to every scene so that
you can run common events in any scene.

--------------------------------------------------------------------------------
** Installation

Place this below Materials and above Main. You should place this above other
custom scripts.

--------------------------------------------------------------------------------
** Usage

If you would like a common event to run in the current scene, create a
comment in the common event command list with this string

   <run scene: current>
  
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_SceneInterpreter"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
  module Scene_Interpreter
   
    # Run common events directly in scene without going to map
    No_Return_Scene = true
   
    Run_Regex = /<run[-_ ]scene:\s*(\w+)/i
  end
end
#===============================================================================
# ** Rest of Script
#===============================================================================
module RPG
  class CommonEvent
   
    #---------------------------------------------------------------------------
    # Which scene to run this common event
    #---------------------------------------------------------------------------
    def run_scene
      return @run_scene unless @run_scene.nil?
      parse_comments_scene_interpreter
      return @run_scene
    end
   
    #---------------------------------------------------------------------------
    # Parse the commands for a Run Scene comment
    #---------------------------------------------------------------------------
    def parse_comments_scene_interpreter
      # just an arbitrary default value
      @run_scene = :map
      @list.each do |cmd|
        if cmd.code == 108 && cmd.parameters[0] =~ TH::Scene_Interpreter::Run_Regex
          @run_scene = $1.downcase.to_sym
        end
      end
    end
  end
end

module SceneManager
  
  def self.init_interpreter
    @interpreter = Game_SceneInterpreter.new
  end
  
  def self.interpreter
    @interpreter
  end
end

#-------------------------------------------------------------------------------
# A special interpreter for scenes
#-------------------------------------------------------------------------------
class Game_SceneInterpreter < Game_Interpreter
end

class Scene_Base

  attr_reader :interpreter
  
  alias :th_scene_interpreter_main :main  
  def main
    unless @scene_interpreter_initialized
      @scene_interpreter_initialized = true
      SceneManager.init_interpreter
    end
    th_scene_interpreter_main
  end
  
  alias :th_scene_interpreter_start :start
  def start
    th_scene_interpreter_start
    create_message_window
  end
  
  alias :th_scene_interpreter_post_start :post_start
  def post_start
    @active_windows = []
    @windows = []
    th_scene_interpreter_post_start
    instance_variables.each do |varname|
      ivar = instance_variable_get(varname)
      if !ivar.is_a?(Window_SceneMessage) && ivar.is_a?(Window)
        @windows << ivar
      end
    end
  end
  
  #-----------------------------------------------------------------------------
  # Create message window
  #-----------------------------------------------------------------------------
  def create_message_window
    @message_window = Window_SceneMessage.new
  end
  
  alias :th_scene_interpreter_update :update
  def update
    th_scene_interpreter_update
    update_interpreter
  end
  
  #-----------------------------------------------------------------------------
  # Run any common events
  #-----------------------------------------------------------------------------
  def update_interpreter
   
    loop do
      SceneManager.interpreter.update
      return if SceneManager.interpreter.running?
      # Don't setup the common event if it doesn't run in the current scene
      return if $game_temp.common_event_reserved? && $data_common_events[$game_temp.common_event_id].run_scene != :current
      
      if SceneManager.interpreter.setup_reserved_common_event
        store_active_windows
      else
        restore_active_windows
        return
      end
    end   
  end
  
  #-----------------------------------------------------------------------------
  # Go through all windows and store them if they're active
  #-----------------------------------------------------------------------------
  def store_active_windows
    @windows.each do |win|
      if win.active
        @active_windows.push(win)
        win.deactivate
      end
    end   
  end
  
  def restore_active_windows
    @active_windows.each do |win|
      win.activate
    end
    @active_windows = []
  end
end

class Scene_ItemBase < Scene_MenuBase
  alias :th_scene_interpreter_check_common_event :check_common_event
  def check_common_event
    return if !$game_temp.common_event_reserved? || ($game_temp.common_event_reserved? && $data_common_events[$game_temp.common_event_id].run_scene == :current)
    th_scene_interpreter_check_common_event
  end
end

class Window_SceneMessage < Window_Message
  
  #-----------------------------------------------------------------------------
  # These are all random z values
  #-----------------------------------------------------------------------------
  alias :th_scene_interpreter_initialize :initialize
  def initialize
    super
    self.z = 500
    @gold_window.z = 500
    @item_window.z = 500
    @number_window.z = 500
    @choice_window.z = 500
  end
end[/pre]

点评

喔...这样子阿 我忽略了这点:/  发表于 2014-12-6 07:43
战斗场景本来就可以执行公共事件,关键是【并行】  发表于 2014-12-6 07:20
回复

使用道具 举报

精灵族の天使<

梦石
0
星屑
1712
在线时间
3039 小时
注册时间
2007-3-16
回帖
33092

开拓者贵宾

发表于 2014-12-6 15:06:50 | 显示全部楼层
敌群里的公共事件是按照回合/始终/战斗来写的,仔细的研究下公共事件的触发条件。
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部