Project1
标题:
怎么在战斗结束后,战斗结算前调用公共事件?
[打印本页]
作者:
devil033
时间:
2018-12-13 23:41
标题:
怎么在战斗结束后,战斗结算前调用公共事件?
如题,想要在战斗结束后,战斗结算前,执行一个公共事件,完了再进行战斗结算,再切回地图界面
也就是顺序是:敌人全死=>执行公共事件=>战斗结算=>切回地图界面
然而,现在 process_victory 里第一行加入 $game_temp.reserve_common_event(common_event_id) 只是进行预约,并不会执行,
而是要等结算完,切回地图界面才执行
想请教下,如果需要在战斗结束后,战斗结束前 执行公共事件,需要怎么改?
谢谢
作者:
Nil2018
时间:
2018-12-14 12:18
=begin
#===============================================================================
Title: 战斗后事件
Author: Hime
Date: Nov 18, 2015
--------------------------------------------------------------------------------
** Change log
Nov 18, 2015
- fixed bug where post battle victory event only ran once
Aug 10, 2013
- Re-structured script to make compatibility easier to handle
May 12, 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
--------------------------------------------------------------------------------
** 说明
可以让某个敌群事件页作为“战斗后事件”,该事件会在战斗结束后、回到游戏地图前
执行。可以让你在胜利/失败信息显示后执行一些额外事件 .
--------------------------------------------------------------------------------
** Installation
Place this script below Materials and above Main
--------------------------------------------------------------------------------
** 使用方法
在事件页中使用注释:
<post battle victory> - 每次战斗胜利后执行
<post battle defeat> - 每次战斗失败后执行
事件页会在符合情况条件时自动执行.
--------------------------------------------------------------------------------
** Compatibility
This script defines custom victory and defeat processing methods in
BattleManager.
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_PostBattleEvents"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
module Post_Battle_Events
Victory_Regex = /<post battle victory>/i
Defeat_Regex = /<post battle defeat>/i
end
end
#===============================================================================
# ** Rest of script
#===============================================================================
module RPG
class Troop
def post_battle_victory_event
return @post_battle_events[:victory] unless @post_battle_events.nil?
parse_post_battle_event
return @post_battle_events[:victory]
end
def post_battle_defeat_event
return @post_battle_events[:defeat] unless @post_battle_events.nil?
parse_post_battle_event
return @post_battle_events[:defeat]
end
def parse_post_battle_event
@post_battle_events = {}
to_delete = []
@pages.each do |page|
if page.parse_post_battle_event(@post_battle_events)
to_delete << page
end
end
to_delete.each do |page|
@pages -= to_delete
end
end
end
class Troop::Page
def parse_post_battle_event(post_events)
@list.each do |cmd|
if cmd.code == 108
if cmd.parameters[0] =~ TH::Post_Battle_Events::Victory_Regex
post_events[:victory] = self
return true
elsif cmd.parameters[0] =~ TH::Post_Battle_Events::Defeat_Regex
post_events[:defeat] = self
return true
end
end
end
return false
end
end
end
module BattleManager
#-----------------------------------------------------------------------------
# Overwrite.
#-----------------------------------------------------------------------------
def self.process_victory
play_battle_end_me
replay_bgm_and_bgs
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
display_exp
gain_gold
gain_drop_items
gain_exp
process_post_victory_event #-- you can customize this
SceneManager.return
battle_end(0)
return true
end
#-----------------------------------------------------------------------------
#
#-----------------------------------------------------------------------------
def self.process_defeat
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
wait_for_message
process_post_defeat_event #-- you can customize this
if @can_lose
revive_battle_members
replay_bgm_and_bgs
SceneManager.return
else
SceneManager.goto(Scene_Gameover)
end
battle_end(2)
return true
end
def self.process_post_victory_event
SceneManager.scene.process_post_victory_event if $game_troop.post_battle_victory_event
end
def self.process_post_defeat_event
SceneManager.scene.process_post_defeat_event if $game_troop.post_battle_defeat_event
end
end
#-------------------------------------------------------------------------------
# Post battle process events defined in the troop objects
#-------------------------------------------------------------------------------
class Game_Troop < Game_Unit
def post_battle_victory_event
troop.post_battle_victory_event
end
def post_battle_defeat_event
troop.post_battle_defeat_event
end
def setup_victory_event
return unless post_battle_victory_event
@interpreter.setup(post_battle_victory_event.list)
end
def setup_defeat_event
return unless post_battle_defeat_event
@interpreter.setup(post_battle_defeat_event.list)
end
end
#-------------------------------------------------------------------------------
# Perform post-process battle event processing
#-------------------------------------------------------------------------------
class Scene_Battle < Scene_Base
def process_post_victory_event
$game_troop.setup_victory_event
while !scene_changing?
$game_troop.interpreter.update
wait_for_message
wait_for_effect if $game_troop.all_dead?
process_forced_action
break unless $game_troop.interpreter.running?
update_for_wait
end
end
def process_post_defeat_event
$game_troop.setup_defeat_event
while !scene_changing?
$game_troop.interpreter.update
wait_for_message
wait_for_effect if $game_party.all_dead?
process_forced_action
break unless $game_troop.interpreter.running?
update_for_wait
end
end
end
复制代码
作者:
devil033
时间:
2018-12-14 17:40
Nil2018 发表于 2018-12-14 12:18
完美,感谢
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1