Class: Scene_Map

Inherits:
GamePlay::Base show all
Includes:
Graphics::FPSBalancer::Marker, Hooks
Defined in:
scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb,
scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00202 Scene_Map warp.rb,
scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00201 Scene_Map calling.rb

Overview

The map gameplay scene

Constant Summary collapse

PSN_COLOR =

Poison flash color

Color.new(123, 55, 123, 128)
RMXP_WILD_BATTLE_GROUPS =

List of RMXP Group that should be treated as “wild battle”

[1, 30]

Constants inherited from GamePlay::Base

GamePlay::Base::DEFAULT_TRANSITION, GamePlay::Base::DEFAULT_TRANSITION_PARAMETER

Constants included from Input

Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE

Constants included from GamePlay::DisplayMessage

GamePlay::DisplayMessage::MESSAGE_ERROR, GamePlay::DisplayMessage::MESSAGE_PROCESS_ERROR

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from GamePlay::Base

#__last_scene, #__result_process, #running, #viewport

Attributes included from GamePlay::DisplayMessage

#message_window

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Graphics::FPSBalancer::Marker

#frame_balanced?

Methods included from Hooks

#exec_hooks, #force_return, included, register, remove, remove_without_name

Methods inherited from GamePlay::Base

#add_disposable, #call_scene, #dispose, #find_parent, #main, #return_to_scene, #visible

Methods included from Input

dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?

Methods included from GamePlay::DisplayMessage

#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=

Constructor Details

#initializeScene_Map

Create a new Scene_Map



13
14
15
16
17
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 13

def initialize
  super
  @update_to_call = []
  Scheduler.start(:on_init, self.class)
end

Class Attribute Details

.battle_modesArray<Proc> (readonly)

List all the battle modes

Returns:

  • (Array<Proc>)


22
23
24
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00201 Scene_Map calling.rb', line 22

def battle_modes
  @battle_modes
end

.triggersHash{ Symbol => Proc } (readonly)

List of call_xxx trigger

Returns:

  • (Hash{ Symbol => Proc })


11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00201 Scene_Map calling.rb', line 11

def triggers
  @triggers
end

Instance Attribute Details

#spritesetSpriteset_Map (readonly)

Access to the spriteset of the map

Returns:



7
8
9
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 7

def spriteset
  @spriteset
end

Class Method Details

.add_call_scene(method_name, &block)

Add a call scene in Scene_Map

Parameters:

  • method_name (Symbol)

    name of the method to call (no argument)

  • block (Proc)

    block to execute in order to be sure the scene callable



16
17
18
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00201 Scene_Map calling.rb', line 16

def add_call_scene(method_name, &block)
  triggers[method_name] = block
end

.register_battle_mode(id, &block) {|scene| ... }

Add a battle mode

Parameters:

  • id (Integer)

    ID of the battle mode

  • block (Proc)

Yield Parameters:



28
29
30
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00201 Scene_Map calling.rb', line 28

def register_battle_mode(id, &block)
  battle_modes[id] = block
end

Instance Method Details

#delay_display_call(*args)

Prepare the call of a display_ method

Parameters:

  • args (Array)

    the send method parameter



95
96
97
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 95

def delay_display_call(*args)
  @update_to_call << args
end

#display_egg_hatch(pokemon)

Display the Egg hatch sequence

Parameters:



88
89
90
91
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 88

def display_egg_hatch(pokemon)
  GamePlay.make_egg_hatch(pokemon)
  $quests.hatch_egg
end

#display_poison_animation

Display the poisoning animation sequence



80
81
82
83
84
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 80

def display_poison_animation
  Audio.se_play('Audio/SE/psn')
  $game_screen.start_flash(PSN_COLOR, 20)
  $game_screen.start_shake(1, 20, 2)
end

#display_poison_end(pokemon)

Display the end of poisoning sequence

Parameters:



68
69
70
71
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 68

def display_poison_end(pokemon)
  PFM::Text.set_pknick(pokemon, 0)
  display_message(parse_text(22, 110))
end

#display_poison_faint(pokemon)

Display text showing pokemon fainted from poison



74
75
76
77
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 74

def display_poison_faint(pokemon)
  PFM::Text.set_pknick(pokemon, 0)
  display_message(parse_text(22, 185))
end

#display_repel_check

Display the repel check sequence



57
58
59
60
61
62
63
64
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 57

def display_repel_check
  if $bag.item_quantity($game_temp.last_repel_used_id || 0) == 0
    display_message(parse_text(39, 0))
  elsif display_message(parse_text(39, 1), 1, text_get(25, 20), text_get(25, 21)) == 0
    PFM.game_state.set_repel_count(data_item($game_temp.last_repel_used_id).repel_count)
    $bag.remove_item($game_temp.last_repel_used_id, 1)
  end
end

#setup_start_battle(klass, battle_info)

Ensure the battle will start without any weird behaviour

Parameters:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00201 Scene_Map calling.rb', line 36

def setup_start_battle(klass, battle_info)
  return unless battle_info

  Graphics.freeze
  $game_temp.menu_calling = false
  $game_temp.menu_beep = false
  $game_player.make_encounter_count
  $game_temp.map_bgm = $game_system.playing_bgm.clone if $game_system.playing_bgm
  $game_system.se_play($data_system.battle_start_se)
  $game_player.straighten
  $scene = klass.new(battle_info)
  @running = false
  Yuki::FollowMe.set_battle_entry
end

#snap_to_bitmapTexture

Note:

You have to dispose the bitmap you got from this function

Take a snapshot of the scene

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 117

def snap_to_bitmap
  temp_view = Viewport.create(:main)
  # Snapshot of spriteset
  bitmaps = @spriteset.snap_to_bitmaps
  backs = bitmaps.map { |bmp| Sprite.new(temp_view).set_bitmap(bmp) }
  # Snapshot of Dynamic Light
  if (vp = NuriYuri::DynamicLight.viewport) && !vp.disposed? && vp.visible
    shader = vp.shader
    vp.shader = nil
    top_bitmap = vp.snap_to_bitmap
    vp.shader = shader
    top = ShaderedSprite.new(temp_view).set_bitmap(top_bitmap)
    top.shader = shader
  end
  # Start creating the snapshot of everything
  exec_hooks(Scene_Map, :snap_to_bitmap, binding)
  result = temp_view.snap_to_bitmap
  exec_hooks(Scene_Map, :snaped_to_bitmap, binding)
  # Dispose temporary snapshots
  top_bitmap&.dispose
  bitmaps.each(&:dispose)
  temp_view.dispose
  # Return actual snapshot
  return result
end

#sprite_set_update

Update everything related to the graphics of the map (used in Interfaces that require that)



44
45
46
47
48
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 44

def sprite_set_update
  $game_screen.update
  $game_map.refresh if $game_map.need_refresh
  @spriteset.update
end

#sprite_set_visible=(v)

Change the spriteset visibility

Parameters:

  • v (Boolean)

    the new visibility of the spriteset



52
53
54
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 52

def sprite_set_visible=(v)
  @spriteset.visible = v
end

#update

Update the scene process



20
21
22
23
24
25
26
27
28
29
30
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 20

def update
  Graphics::FPSBalancer.global.run { auto_transfert_update }
  update_graphics
  return false if switched_to_main_rmxp_scene
  return false if Graphics::FPSBalancer.global.skipping? && message_processing?
  return false unless super # Update message window & break if messages are shown

  update_scene_calling
ensure
  @running = false if $scene != self
end

#update_graphics

Section where we update the graphics of the scene (for now only spriteset)



33
34
35
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 33

def update_graphics
  @spriteset.update
end

#visible=(value)

Change the viewport visibility of the scene (we overwrite it because we don't want viewport to be hidden when calling a scene)

Parameters:

  • value (Boolean)


39
40
41
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 39

def visible=(value)
  @message_window.viewport.visible = value if @message_window
end

#window_message_close(smooth)

Force the message window to close

Parameters:

  • smooth (Boolean)

    if the message window is closed smoothly or not



101
102
103
104
105
106
107
108
109
110
111
112
# File 'scripts/01450 Systems/00003 Map Engine/00003 GamePlay/00200 Scene_Map.rb', line 101

def window_message_close(smooth)
  if smooth
    while $game_temp.message_window_showing
      Graphics.update
      @message_window.update
    end
  else
    $game_temp.message_window_showing = false
    @message_window.visible = false
    @message_window.opacity = 255
  end
end