+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Tutorials (https://www.save-point.org/forum-19.html)
+--- Thread: A good way to make an interrupt scene (/thread-1649.html)
A good way to make an interrupt scene - Ramiro - 11-20-2009
Hello im here to make a tip of an interrupt scene
What's an interrupt scene
Its an special scene than can be shown "inside" another scene (good to separate some thigs..., sometimes)
How can i make one?
It's not as hard as you can think, let me show how to make it.
First you need to add some variables in the scene you want to "insert" de scene.
example
Code:
class Your_Scene
def initialize
@interrupt_scene = nil
[more code]
end
end
Now the update part..
Code:
class Your_Scene
def update
if @interrupt_scene != nil
if @interrupt_scene.disposed?
@interrupt_scene = nil
else
@interrupt_scene.update
return
end
end
[more code]
end
end
And the last part: how to make the scene
Code:
class Your_new_scene
def initialize
@disposed = false
[your code]
end
def update
[your code]
end
def dispose
[your code]
end
def disposed?
return @disposed
end
end
And now the good part.
To call the scene:
@interrupt_scene = Your_scene.new
and to quit it. put in the scene:
@disposed = true
EXAMPLES FOR RPG MAKERS
[VX VERSION]
Content Hidden
Code:
class Scene_SkillInterrupt < Scene_Skill
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@disposed = false
start
post_start
end
def disposed?
return @disposed
end
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
pre_terminate
terminate
@disposed = true
end
#--------------------------------------------------------------------------
# * Switch to Next Actor Screen
#--------------------------------------------------------------------------
def next_actor
@actor_index += 1
@actor_index %= $game_party.members.size
pre_terminate
terminate
start
post_start
end
#--------------------------------------------------------------------------
# * Switch to Previous Actor Screen
#--------------------------------------------------------------------------
def prev_actor
@actor_index += $game_party.members.size - 1
@actor_index %= $game_party.members.size
pre_terminate
terimante
start
post_start
end
#--------------------------------------------------------------------------
# * Use Skill (apply effects to non-ally targets)
#--------------------------------------------------------------------------
def use_skill_nontarget
Sound.play_use_skill
@actor.mp -= @actor.calc_mp_cost(@skill)
@status_window.refresh
@skill_window.refresh
@target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
elsif @skill.common_event_id > 0
$game_temp.common_event_id = @skill.common_event_id
return_scene
end
end
end
class Scene_Map < Scene_Base
alias interrupt_scene_test_map_update update
alias interrupt_scene_test_map_start start
def start
@interrupt_scene = nil
interrupt_scene_test_map_start
end
def update
if @interrupt_scene != nil
update_interrupt_map
return
end
interrupt_scene_test_map_update
end
def update_interrupt_map
if @interrupt_scene.disposed?
@interrupt_scene = nil
else
@interrupt_scene.update
end
end
def call_interrupt_scene(scene)
@interrupt_scene = scene
end
end
[XP VERSION]
Content Hidden
Code:
class Scene_Map
alias interurpt_test_scene_map_initialize initialize
alias interurpt_test_scene_map_update update
def initialize
@interrupt_scene = nil
interurpt_test_scene_map_initialize
end
def update
if @interrupt_scene != nil
update_interrupt_scene
return
end
interurpt_test_scene_map_update
end
def update_interrupt_scene
if @interrupt_scene.disposed?
@interrupt_scene = nil
else
@interrupt_scene.update
end
end
def call_interrupt_scene(scene)
@interrupt_scene = scene
end
end
class Scene_Interrupt_Skill < Scene_Skill
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
# Get actor
@actor = $game_party.actors[@actor_index]
# Make help window, status window, and skill window
@help_window = Window_Help.new
@status_window = Window_SkillStatus.new(@actor)
@skill_window = Window_Skill.new(@actor)
# Associate help window
@skill_window.help_window = @help_window
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@disposed = false
end
def dispose_scene
# Dispose of windows
@help_window.dispose
@status_window.dispose
@skill_window.dispose
@target_window.dispose
@disposed = true
end
#--------------------------------------------------------------------------
# * Frame Update (if skill window is active)
#--------------------------------------------------------------------------
def update_skill
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
dispose_scene
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the skill window
@skill = @skill_window.skill
# If unable to use
if @skill == nil or not @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If effect scope is ally
if @skill.scope >= 3
# Activate target window
@skill_window.active = false
@target_window.x = (@skill_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Set cursor position to effect scope (single / all)
if @skill.scope == 4 || @skill.scope == 6
@target_window.index = -1
elsif @skill.scope == 7
@target_window.index = @actor_index - 10
else
@target_window.index = 0
end
# If effect scope is other than ally
else
# If common event ID is valid
if @skill.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Play use skill SE
$game_system.se_play(@skill.menu_se)
# Use up SP
@actor.sp -= @skill.sp_cost
# Remake each window content
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# Switch to map screen
dispose_scene
return
end
end
return
end
# If R button was pressed
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.actors.size
# Switch to different skill screen
dispose_scene
initialize(@actor_index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# Switch to different skill screen
dispose_scene
initialize(@actor_index)
return
end
end
def disposed?
return @disposed
end
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
def update_target
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Erase target window
@skill_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If unable to use because SP ran out
unless @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply skill use effects to entire party
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
# If target is user
if @target_window.index <= -2
# Apply skill use effects to target actor
target = $game_party.actors[@target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# If single target
if @target_window.index >= 0
# Apply skill use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.skill_effect(@actor, @skill)
end
# If skill was used
if used
# Play skill use SE
$game_system.se_play(@skill.menu_se)
# Use up SP
@actor.sp -= @skill.sp_cost
# Remake each window content
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# If entire party is dead
if $game_party.all_dead?
# Switch to game over screen
dispose_scene
$scene = Scene_Gameover.new
return
end
# If command event ID is valid
if @skill.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Switch to map screen
dispose_scene
return
end
end
# If skill wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
to call the scene (on Scene_map in this example)
Put in an event as "insert script"
Code:
scene = Scene_Interrupt_Skill.new(0)
$scene.call_interrupt_scene(scene)
And that's all. see ya!
A good way to make an interrupt scene - s_miracle - 11-21-2009
Sounds like its exactly what I've been looking for, but I don't really understand how this works, can you please make a short demo project showing an example interrupt scene if its not too much trouble?
A good way to make an interrupt scene - Jaberwocky - 11-21-2009
It's just running another class' update method in place of the first class' update method.
In other words, it's using the current $scene's main method to update instead of having it's own main method.
Nothing special about it.
A good way to make an interrupt scene - Ramiro - 11-21-2009
Ok i made an XP example and a VX example to call the Scene Skill on map
Remember, it's just an example you can make anything you want with this.
A good way to make an interrupt scene - s_miracle - 11-22-2009
Thanks, I figured it all out :cheery: I'll be sure to credit you if I ever get this thing done