-
Notifications
You must be signed in to change notification settings - Fork 0
/
maru_EquipinBattle.rb
194 lines (189 loc) · 8.05 KB
/
maru_EquipinBattle.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#
#Change equipment during battle
#
#Add "equipment" to command,
#Equipment can be changed during battle.
#
#★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#------------------------------------------------------------------------------
#Setting
module MARU_battleequip
SWITCH = 1 #Switch to enable "equipment command"
#------------------------------------------------------------------------------
end
#==============================================================================
# ■ Window_ActorCommand
#------------------------------------------------------------------------------
# Window used to select actor actions on the battle screen.
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# ● Create command list
#--------------------------------------------------------------------------
alias ma0075make_command_list make_command_list
def make_command_list
ma0075make_command_list
add_equip_command if $game_switches[MARU_battleequip::SWITCH] == true
end
#--------------------------------------------------------------------------
# ● Add item command to list
#--------------------------------------------------------------------------
def add_equip_command
add_command("Equipment", :equip)
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# Class for battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Create all windows
#--------------------------------------------------------------------------
alias ma0075_create_all_windows create_all_windows
def create_all_windows
ma0075_create_all_windows
create_equip_window if $game_switches[MARU_battleequip::SWITCH] == true
end
#--------------------------------------------------------------------------
# ● Create actor command window
#--------------------------------------------------------------------------
alias ma0075_create_actor_command_window create_actor_command_window
def create_actor_command_window
ma0075_create_actor_command_window
@actor_command_window.set_handler(:equip, method(:command_equip))
end
#--------------------------------------------------------------------------
# ● Create equipment window
#--------------------------------------------------------------------------
def create_equip_window
@status_equip_window = Window_EquipStatus.new(0, @help_window.height)
@status_equip_window.visible = false
@status_equip_window.viewport = @viewport
wx = @status_equip_window.width
wy = @help_window.height
ww = Graphics.width - @status_equip_window.width
@command_equip_window = Window_EquipCommand.new(wx, wy, ww)
@command_equip_window.visible = false
@command_equip_window.deactivate
@command_equip_window.viewport = @viewport
@command_equip_window.help_window = @help_window
@command_equip_window.set_handler(:equip, method(:command_equip_e))
@command_equip_window.set_handler(:optimize, method(:command_optimize))
@command_equip_window.set_handler(:clear, method(:command_clear))
@command_equip_window.set_handler(:cancel, method(:on_command_cancel))
wx = @status_equip_window.width
wy = @command_equip_window.y + @command_equip_window.height
ww = Graphics.width - @status_equip_window.width
@slot_window = Window_EquipSlot.new(wx, wy, ww)
@slot_window.visible = false
@slot_window.viewport = @viewport
@slot_window.help_window = @help_window
@slot_window.status_window = @status_equip_window
@slot_window.set_handler(:ok, method(:on_slot_ok))
@slot_window.set_handler(:cancel, method(:on_slot_cancel))
wx = 0
wy = @slot_window.y + @slot_window.height
ww = Graphics.width
wh = Graphics.height - wy
@item_equip_window = Window_EquipItem.new(wx, wy, ww, wh)
@item_equip_window.visible = false
@item_equip_window.viewport = @viewport
@item_equip_window.help_window = @help_window
@item_equip_window.status_window = @status_equip_window
@item_equip_window.set_handler(:ok, method(:on_item_equip_ok))
@item_equip_window.set_handler(:cancel, method(:on_item_equip_cancel))
@slot_window.item_window = @item_equip_window
end
#--------------------------------------------------------------------------
# ● Command [equipment]
#--------------------------------------------------------------------------
def command_equip
@help_window.show
@actor = BattleManager.actor
@status_equip_window.actor = @actor
@slot_window.actor = @actor
@item_equip_window.actor = @actor
@status_equip_window.refresh
@status_equip_window.show
@command_equip_window.refresh
@command_equip_window.show.activate
@slot_window.refresh
@slot_window.show
@item_equip_window.refresh
@item_equip_window.show
end
#--------------------------------------------------------------------------
# ● Command [change equipment]
#--------------------------------------------------------------------------
def command_equip_e
@slot_window.activate
@slot_window.select(0)
end
#--------------------------------------------------------------------------
# ● Command [optimize]
#--------------------------------------------------------------------------
def command_optimize
Sound.play_equip
@actor.optimize_equipments
@status_equip_window.refresh
@slot_window.refresh
@command_equip_window.activate
end
#--------------------------------------------------------------------------
# ● Command [remove all]
#--------------------------------------------------------------------------
def command_clear
Sound.play_equip
@actor.clear_equipments
@status_equip_window.refresh
@slot_window.refresh
@command_equip_window.activate
end
#--------------------------------------------------------------------------
# ● Command [cancel]
#--------------------------------------------------------------------------
def on_command_cancel
@help_window.hide
@status_equip_window.hide
@command_equip_window.hide
@slot_window.hide
@item_equip_window.hide
@actor_command_window.activate
@actor_command_window.select(0)
end
#--------------------------------------------------------------------------
# ● Slot [decision]
#--------------------------------------------------------------------------
def on_slot_ok
@item_equip_window.activate
@item_equip_window.select(0)
end
#--------------------------------------------------------------------------
# ● Slot [cancel]
#--------------------------------------------------------------------------
def on_slot_cancel
@slot_window.unselect
@command_equip_window.activate
end
#--------------------------------------------------------------------------
# ● Item [decision]
#--------------------------------------------------------------------------
def on_item_equip_ok
Sound.play_equip
@actor.change_equip(@slot_window.index, @item_equip_window.item)
@slot_window.activate
@slot_window.refresh
@item_equip_window.unselect
@item_equip_window.refresh
end
#--------------------------------------------------------------------------
# ● Item [cancel]
#--------------------------------------------------------------------------
def on_item_equip_cancel
@slot_window.activate
@item_equip_window.unselect
end
end