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

Project1

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

[已经解决] 怎么在战斗结束后,战斗结算前调用公共事件?

[复制链接]

Lv4.逐梦者

梦石
0
星屑
7495
在线时间
1152 小时
注册时间
2016-9-10
帖子
165

开拓者

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

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

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

x
如题,想要在战斗结束后,战斗结算前,执行一个公共事件,完了再进行战斗结算,再切回地图界面
也就是顺序是:敌人全死=>执行公共事件=>战斗结算=>切回地图界面

然而,现在 process_victory 里第一行加入 $game_temp.reserve_common_event(common_event_id) 只是进行预约,并不会执行,
而是要等结算完,切回地图界面才执行

想请教下,如果需要在战斗结束后,战斗结束前 执行公共事件,需要怎么改?
谢谢

Lv4.逐梦者

梦石
1
星屑
14503
在线时间
2086 小时
注册时间
2017-9-28
帖子
662
2
发表于 2018-12-14 12:18:27 | 只看该作者
  1. =begin
  2. #===============================================================================
  3. Title: 战斗后事件
  4. Author: Hime
  5. Date: Nov 18, 2015
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. Nov 18, 2015
  9.    - fixed bug where post battle victory event only ran once
  10. Aug 10, 2013
  11.    - Re-structured script to make compatibility easier to handle
  12. May 12, 2013
  13.    - Initial release
  14. --------------------------------------------------------------------------------   
  15. ** Terms of Use
  16. * Free to use in non-commercial projects
  17. * Contact me for commercial use
  18. * No real support. The script is provided as-is
  19. * Will do bug fixes, but no compatibility patches
  20. * Features may be requested but no guarantees, especially if it is non-trivial
  21. * Credits to Hime Works in your project
  22. * Preserve this header
  23. --------------------------------------------------------------------------------
  24. ** 说明

  25. 可以让某个敌群事件页作为“战斗后事件”,该事件会在战斗结束后、回到游戏地图前
  26. 执行。可以让你在胜利/失败信息显示后执行一些额外事件 .

  27. --------------------------------------------------------------------------------
  28. ** Installation

  29. Place this script below Materials and above Main

  30. --------------------------------------------------------------------------------
  31. ** 使用方法

  32. 在事件页中使用注释:

  33.    <post battle victory> - 每次战斗胜利后执行
  34.    <post battle defeat> - 每次战斗失败后执行
  35.    
  36. 事件页会在符合情况条件时自动执行.

  37. --------------------------------------------------------------------------------
  38. ** Compatibility

  39. This script defines custom victory and defeat processing methods in
  40. BattleManager.   

  41. #===============================================================================
  42. =end
  43. $imported = {} if $imported.nil?
  44. $imported["TH_PostBattleEvents"] = true
  45. #===============================================================================
  46. # ** Configuration
  47. #===============================================================================
  48. module TH
  49.   module Post_Battle_Events
  50.    
  51.     Victory_Regex = /<post battle victory>/i
  52.     Defeat_Regex = /<post battle defeat>/i
  53.   end
  54. end
  55. #===============================================================================
  56. # ** Rest of script
  57. #===============================================================================
  58. module RPG
  59.   
  60.   class Troop
  61.     def post_battle_victory_event
  62.       return @post_battle_events[:victory] unless @post_battle_events.nil?
  63.       parse_post_battle_event
  64.       return @post_battle_events[:victory]
  65.     end
  66.   
  67.     def post_battle_defeat_event
  68.       return @post_battle_events[:defeat] unless @post_battle_events.nil?
  69.       parse_post_battle_event
  70.       return @post_battle_events[:defeat]
  71.     end
  72.    
  73.     def parse_post_battle_event
  74.       @post_battle_events = {}
  75.       
  76.       to_delete = []
  77.       @pages.each do |page|
  78.         if page.parse_post_battle_event(@post_battle_events)
  79.           to_delete << page
  80.         end
  81.       end
  82.       
  83.       to_delete.each do |page|
  84.         @pages -= to_delete
  85.       end
  86.     end
  87.   end
  88.   
  89.   class Troop::Page
  90.     def parse_post_battle_event(post_events)
  91.       @list.each do |cmd|
  92.         if cmd.code == 108
  93.           if cmd.parameters[0] =~ TH::Post_Battle_Events::Victory_Regex
  94.             post_events[:victory] = self
  95.             return true
  96.           elsif cmd.parameters[0] =~ TH::Post_Battle_Events::Defeat_Regex
  97.             post_events[:defeat] = self
  98.             return true
  99.           end
  100.         end
  101.       end
  102.       return false
  103.     end
  104.   end
  105. end

  106. module BattleManager

  107.   #-----------------------------------------------------------------------------
  108.   # Overwrite.
  109.   #-----------------------------------------------------------------------------
  110.   def self.process_victory
  111.     play_battle_end_me
  112.     replay_bgm_and_bgs
  113.     $game_message.add(sprintf(Vocab::Victory, $game_party.name))
  114.     display_exp
  115.     gain_gold
  116.     gain_drop_items
  117.     gain_exp
  118.     process_post_victory_event #-- you can customize this
  119.     SceneManager.return
  120.     battle_end(0)
  121.     return true
  122.   end

  123.   #-----------------------------------------------------------------------------
  124.   #
  125.   #-----------------------------------------------------------------------------
  126.   def self.process_defeat
  127.     $game_message.add(sprintf(Vocab::Defeat, $game_party.name))
  128.     wait_for_message
  129.     process_post_defeat_event #-- you can customize this
  130.     if @can_lose
  131.       revive_battle_members
  132.       replay_bgm_and_bgs
  133.       SceneManager.return
  134.     else
  135.       SceneManager.goto(Scene_Gameover)
  136.     end
  137.     battle_end(2)
  138.     return true
  139.   end
  140.   
  141.   def self.process_post_victory_event
  142.     SceneManager.scene.process_post_victory_event if $game_troop.post_battle_victory_event
  143.   end
  144.   
  145.   def self.process_post_defeat_event
  146.     SceneManager.scene.process_post_defeat_event if $game_troop.post_battle_defeat_event
  147.   end
  148. end

  149. #-------------------------------------------------------------------------------
  150. # Post battle process events defined in the troop objects
  151. #-------------------------------------------------------------------------------
  152. class Game_Troop < Game_Unit
  153.   
  154.   def post_battle_victory_event
  155.     troop.post_battle_victory_event
  156.   end
  157.   
  158.   def post_battle_defeat_event
  159.     troop.post_battle_defeat_event
  160.   end
  161.   
  162.   def setup_victory_event
  163.     return unless post_battle_victory_event
  164.     @interpreter.setup(post_battle_victory_event.list)
  165.   end
  166.   
  167.   def setup_defeat_event
  168.     return unless post_battle_defeat_event
  169.     @interpreter.setup(post_battle_defeat_event.list)
  170.   end
  171. end

  172. #-------------------------------------------------------------------------------
  173. # Perform post-process battle event processing
  174. #-------------------------------------------------------------------------------
  175. class Scene_Battle < Scene_Base
  176.   
  177.   def process_post_victory_event
  178.     $game_troop.setup_victory_event
  179.     while !scene_changing?
  180.       $game_troop.interpreter.update
  181.       wait_for_message
  182.       wait_for_effect if $game_troop.all_dead?
  183.       process_forced_action
  184.       break unless $game_troop.interpreter.running?
  185.       update_for_wait
  186.     end
  187.   end
  188.   
  189.   def process_post_defeat_event
  190.     $game_troop.setup_defeat_event
  191.     while !scene_changing?
  192.       $game_troop.interpreter.update
  193.       wait_for_message
  194.       wait_for_effect if $game_party.all_dead?
  195.       process_forced_action
  196.       break unless $game_troop.interpreter.running?
  197.       update_for_wait
  198.     end
  199.   end
  200. end
复制代码

评分

参与人数 1星屑 +20 收起 理由
VIPArcher + 20 认可答案

查看全部评分

VA外站脚本汉化群:226308173   |    部分远古文件备份:https://wwzv.lanzoue.com/b02rac5pc  密码:acgm
回复 支持 1 反对 0

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7495
在线时间
1152 小时
注册时间
2016-9-10
帖子
165

开拓者

3
 楼主| 发表于 2018-12-14 17:40:54 | 只看该作者
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 05:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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