Class: Scene_ItemBase

Inherits:
Scene_MenuBase show all
Defined in:
Scene_ItemBase.rb

Overview

** Scene_ItemBase


This class performs common processing for the item screen and skill screen.

Direct Known Subclasses

Scene_Item, Scene_Skill

Instance Method Summary (collapse)

Methods inherited from Scene_MenuBase

#create_background, #create_help_window, #dispose_background, #next_actor, #on_actor_change, #prev_actor, #terminate

Methods inherited from Scene_Base

#check_gameover, #create_main_viewport, #dispose_all_windows, #dispose_main_viewport, #fadeout_all, #main, #perform_transition, #post_start, #pre_terminate, #return_scene, #scene_changing?, #terminate, #transition_speed, #update, #update_all_windows, #update_basic

Instance Method Details

- (Object) activate_item_window


  • Activate Item Window




91
92
93
94
# File 'Scene_ItemBase.rb', line 91

def activate_item_window
  @item_window.refresh
  @item_window.activate
end

- (Object) check_common_event


  • Determine if Common Event Is Reserved

    Transition to the map screen if the event call is reserved.



144
145
146
# File 'Scene_ItemBase.rb', line 144

def check_common_event
  SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
end

- (Object) create_actor_window


  • Create Actor Window




18
19
20
21
22
# File 'Scene_ItemBase.rb', line 18

def create_actor_window
  @actor_window = Window_MenuActor.new
  @actor_window.set_handler(:ok,     method(:on_actor_ok))
  @actor_window.set_handler(:cancel, method(:on_actor_cancel))
end

- (Boolean) cursor_left?


  • Determine if Cursor Is in Left Column


Returns:

  • (Boolean)


38
39
40
# File 'Scene_ItemBase.rb', line 38

def cursor_left?
  @item_window.index % 2 == 0
end

- (Object) determine_item


  • Confirm Item




79
80
81
82
83
84
85
86
87
# File 'Scene_ItemBase.rb', line 79

def determine_item
  if item.for_friend?
    show_sub_window(@actor_window)
    @actor_window.select_for_item(item)
  else
    use_item
    activate_item_window
  end
end

- (Object) hide_sub_window(window)


  • Hide Subwindow




54
55
56
57
58
59
# File 'Scene_ItemBase.rb', line 54

def hide_sub_window(window)
  @viewport.rect.x = @viewport.ox = 0
  @viewport.rect.width = Graphics.width
  window.hide.deactivate
  activate_item_window
end

- (Object) item


  • Get Currently Selected Item




26
27
28
# File 'Scene_ItemBase.rb', line 26

def item
  @item_window.item
end

- (Boolean) item_effects_valid?


  • Determine if Item Is Effective


Returns:

  • (Boolean)


116
117
118
119
120
# File 'Scene_ItemBase.rb', line 116

def item_effects_valid?
  item_target_actors.any? do |target|
    target.item_test(user, item)
  end
end

- (Object) item_target_actors


  • Get Array of Actors Targeted by Item Use




98
99
100
101
102
103
104
105
106
# File 'Scene_ItemBase.rb', line 98

def item_target_actors
  if !item.for_friend?
    []
  elsif item.for_all?
    $game_party.members
  else
    [$game_party.members[@actor_window.index]]
  end
end

- (Boolean) item_usable?


  • Determine if Item is Usable


Returns:

  • (Boolean)


110
111
112
# File 'Scene_ItemBase.rb', line 110

def item_usable?
  user.usable?(item) && item_effects_valid?
end

- (Object) on_actor_cancel


  • Actor [Cancel]




73
74
75
# File 'Scene_ItemBase.rb', line 73

def on_actor_cancel
  hide_sub_window(@actor_window)
end

- (Object) on_actor_ok


  • Actor [OK]




63
64
65
66
67
68
69
# File 'Scene_ItemBase.rb', line 63

def on_actor_ok
  if item_usable?
    use_item
  else
    Sound.play_buzzer
  end
end

- (Object) show_sub_window(window)


  • Show Subwindow




44
45
46
47
48
49
50
# File 'Scene_ItemBase.rb', line 44

def show_sub_window(window)
  width_remain = Graphics.width - window.width
  window.x = cursor_left? ? width_remain : 0
  @viewport.rect.x = @viewport.ox = cursor_left? ? 0 : window.width
  @viewport.rect.width = width_remain
  window.show.activate
end

- (Object) start


  • Start Processing




11
12
13
14
# File 'Scene_ItemBase.rb', line 11

def start
  super
  create_actor_window
end

- (Object) use_item


  • Use Item




132
133
134
135
136
137
138
139
# File 'Scene_ItemBase.rb', line 132

def use_item
  play_se_for_item
  user.use_item(item)
  use_item_to_actors
  check_common_event
  check_gameover
  @actor_window.refresh
end

- (Object) use_item_to_actors


  • Use Item on Actor




124
125
126
127
128
# File 'Scene_ItemBase.rb', line 124

def use_item_to_actors
  item_target_actors.each do |target|
    item.repeats.times { target.item_apply(user, item) }
  end
end

- (Object) user


  • Get Item's User




32
33
34
# File 'Scene_ItemBase.rb', line 32

def user
  $game_party.movable_members.max_by {|member| member.pha }
end