#===============================================================================
#
# Shanghai Simple Script - Death Common Events
# Last Date Updated: 2010.06.16
# Level: Normal
#
# This script causes certain actors and enemies to trigger common events when
# they die in battle. Although this could be evented, there's a lot of messy
# condition work involved with battle event pages, which is why I created this
# script.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# <death event: x>
# This is for enemies. Makes common event x run when the enemy dies.
#===============================================================================
$imported = {} if $imported == nil
$imported["DeathCommonEvents"] = true
module SSS
# This has sets the common events that run when specific actors die. If it
# isn't present, then no common event will run.
ACTOR_DEATH_EVENTS ={
# Actor => Common Event ID
=begin
1 => 15,
2 => 16,
3 => 17,
4 => 18,
=end
} # Remove this and perish.
# This has sets the common events that run when specific classes die. If it
# isn't present, then no common event will run.
CLASS_DEATH_EVENTS ={
=begin
# Class => Common Event ID
1 => 19,
2 => 20,
3 => 21,
4 => 22,
=end
} # Remove this and perish.
end
#==============================================================================
# RPG::Enemy
#==============================================================================
class RPG::Enemy
#--------------------------------------------------------------------------
# * Death Event
#--------------------------------------------------------------------------
def death_event
return @death_event if @death_event != nil
@death_event = 0
self.note.split(/[\r\n]+/).each { |line|
case line
when /<(?:DEATH_EVENT|death event):[ ](\d+)>/i
@death_event = $1.to_i
end
}
return @death_event
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Perform Collapse
#--------------------------------------------------------------------------
alias perform_collapse_actor_sss_death_events perform_collapse unless $@
def perform_collapse
perform_collapse_actor_sss_death_events
if $game_temp.in_battle and dead?
if SSS::ACTOR_DEATH_EVENTS.include?(@actor_id)
$death_events.push(SSS::ACTOR_DEATH_EVENTS[@actor_id])
elsif SSS::CLASS_DEATH_EVENTS.include?(@class_id)
$death_events.push(SSS::CLASS_DEATH_EVENTS[@class_id])
end
end
end
end
#==============================================================================
# ** Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Perform Collapse
#--------------------------------------------------------------------------
alias perform_collapse_enemy_sss_death_events perform_collapse unless $@
def perform_collapse
perform_collapse_enemy_sss_death_events
if $game_temp.in_battle and dead?
$death_events.push(enemy.death_event) if enemy.death_event > 0
end
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias main_sss_death_events main unless $@
def main
$death_events = []
main_sss_death_events
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Execute Battle Actions
#--------------------------------------------------------------------------
alias execute_action_sss_death_events execute_action unless $@
def execute_action
execute_action_sss_death_events
run_death_common_events
end
#--------------------------------------------------------------------------
# * Run Death Common Events
#--------------------------------------------------------------------------
def run_death_common_events
for common_event_id in $death_events
next if $data_common_events[common_event_id].nil?
$game_temp.common_event_id = common_event_id
process_battle_event
end
$death_events = []
end
#--------------------------------------------------------------------------
# * End Battle
#--------------------------------------------------------------------------
alias battle_end_sss_death_events battle_end unless $@
def battle_end(result)
$death_events = []
battle_end_sss_death_events(result)
end
end
#===============================================================================
#
# END OF FILE
#
#===============================================================================