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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
| #=============================================================
# Battle Pop-Ups
# By Jet10985 (Jet)
#=================================================================
# This script will create and show pop-ups for multiple battle events such as
# hp/mp/tp loss and being inflicted with states.
# This script has: 25 customization options.
#=================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Actor: level_up, gain_exp
# Game_Battler: add_state
# Sprite_Battler: initialize, update, dispose, start_new_effect
#=================================================================
module Jet
module BattlePopUps
# This is the name of the font you want to use for pop-ups.
POPUP_FONT = "Verdana"
# The text and color shown when a character is knocked out (dies).
KNOCKOUT_TEXT = "Mort"
KNOCKOUT_COLOR = Color.new(255, 167, 0)
# The text and color shown when a character takes damage.
# The actual damage is appended to the end.
HURT_TEXT = "Dégâts "
HURT_COLOR = Color.new(255, 0, 0)
# The text and color shown when a character heals health.
# The actual health is appended to the end.
HEAL_TEXT = "Soigné "
HEAL_COLOR = Color.new(0, 255, 0)
# The text and color shown when a character gains exp.
# The actual exp is appended to the end.
EXP_PLUS_TEXT = "EXP "
EXP_PLUS_COLOR = Color.new(167, 167, 0)
# The text and color shown when an attack is critical.
CRITICAL_TEXT = "Critique"
CRITICAL_COLOR = Color.new(255, 106, 43)
# The text and color shown when an attack misses.
MISSED_TEXT = "Raté"
MISS_COLOR = Color.new(45, 78, 99)
# The text and color shown when an attack is evaded.
EVADED_TEXT = "Esquive"
EVADE_COLOR = Color.new(156, 187, 255)
# The text, color, and animation shown when a character levels up.
# For no animation, use 0.
LEVEL_TEXT = "Level Up"
LEVEL_COLOR = Color.new(167, 255, 52)
# These are the colors used for displaying when a state is added.
# It follows this format: state_id => Color.new(r, g, b)
STATE_ADDED_COLORS = {
2 => Color.new(128, 0, 255),
3 => Color.new(128, 0, 255),
4 => Color.new(128, 0, 255)
}
# This is the default state added color.
STATE_ADDED_COLORS.default = Color.new(128, 0, 255)
end
end
#=================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#=================================================================
($imported ||= {})[:jet] ||= {}
$imported[:jet][:BattlePopUps] = true
class Game_Actor
alias jet4921_level_up level_up
def level_up(*args, &block)
jet4921_level_up(*args, &block)
unless self.exp >= next_level_exp and next_level_exp > 0
make_popup(Jet::BattlePopUps::LEVEL_TEXT, Jet::BattlePopUps::LEVEL_COLOR)
end
end
alias jet1029_gain_exp gain_exp
def gain_exp(exp)
make_popup(Jet::BattlePopUps::EXP_PLUS_TEXT + exp.to_s, Jet::BattlePopUps::EXP_PLUS_COLOR)
jet1029_gain_exp(exp)
end
end
class Game_Battler
alias jet8573_add_state add_state
def add_state(sid)
before = state?(sid)
jet8573_add_state(sid)
return if before == state?(sid)
if sid == death_state_id
make_popup(Jet::BattlePopUps::KNOCKOUT_TEXT, Jet::BattlePopUps::KNOCKOUT_COLOR)
else
make_popup("+#{$data_states[sid].name}", Jet::BattlePopUps::STATE_ADDED_COLORS[sid])
end
end
def make_popup(text, color)
return unless SceneManager.scene_is?(Scene_Battle)
f = self.battle_sprite; return if f.nil?
f.popups.unshift(Sprite_JetPopup.new(text.to_s, color, f)) if !f.nil?
end
def battle_sprite
return nil unless SceneManager.scene_is?(Scene_Battle)
SceneManager.scene.spriteset.battler_sprites.each {|a|
return a if a.battler == self
}
return nil
end
end
class Scene_Battle
attr_reader :spriteset
end
class Sprite_JetPopup < Sprite_Base
def initialize(text, color, obj)
super(nil)
@text = text
@color = color
@character = obj
self.visible = false
@y_prog = 0
form_self
end
def form_self
samp = Bitmap.new(1, 1)
self.bitmap = Bitmap.new(samp.text_size(@text).width, 24)
self.bitmap.font.color = @color
self.bitmap.font.name = Jet::BattlePopUps::POPUP_FONT
self.bitmap.draw_text(0, 0, self.bitmap.width, 24, @text)
self.x = @character.x - (self.bitmap.width / 2)
self.x += (@character.src_rect.width / 2) if @character.battler.actor?
self.y = @character.battler.enemy? ? @character.y : (@character.y + @character.src_rect.height)
self.y += @character.src_rect.height if @character.battler.actor?
samp.dispose
end
def update
super
self.x = @character.x - (self.bitmap.width / 2)
if $imported[:jet][:AnimatedBattlers]
self.x += (@character.src_rect.width / 2) if @character.battler.actor?
end
self.y = @character.y - 16 - @y_prog
if $imported[:jet][:AnimatedBattlers]
self.y += @character.src_rect.height if @character.battler.actor?
end
@y_prog += 1
self.opacity -= 2.125
if self.opacity <= 0
self.dispose
end
end
end
class Sprite_Battler
attr_accessor :popups
alias jet4758_initialize initialize
def initialize(*args, &block)
@popups = []
@updating_sprites = []
@popup_wait = 0
jet4758_initialize(*args, &block)
end
alias jet7467_update update
def update(*args, &block)
jet7467_update(*args, &block)
if @popup_wait == 0
if !@popups.empty?
@updating_sprites.push(@popups.pop)
@popup_wait = 30
end
else
@popup_wait -= 1
end
@updating_sprites.each {|a|
a.visible = true if !a.visible
a.update
@updating_sprites.delete(a) if a.disposed?
}
end
alias jet5483_dispose dispose
def dispose(*args, &block)
(@updating_sprites + @popups).each {|a| a.dispose }
jet5483_dispose(*args, &block)
end
alias jet3745_setup_new_effect setup_new_effect
def setup_new_effect(*args, &block)
jet3745_setup_new_effect(*args, &block)
do_sprite_popups
end
def make_popup(text, color)
@popups.unshift(Sprite_JetPopup.new(text.to_s, color, self))
end
def do_sprite_popups
return if @battler.nil?
if @battler_struct.nil?
@battler_struct = Struct.new(:hp).new(0)
@battler_struct.hp = @battler.hp
end
check_success_popup
check_hp_popup
end
def check_success_popup
if @battler.result.success
if @battler.result.critical
make_popup(Jet::BattlePopUps::CRITICAL_TEXT, Jet::BattlePopUps::CRITICAL_COLOR)
elsif @battler.result.missed
make_popup(Jet::BattlePopUps::MISSED_TEXT, Jet::BattlePopUps::MISS_COLOR)
elsif @battler.result.evaded
make_popup(Jet::BattlePopUps::EVADED_TEXT, Jet::BattlePopUps::EVADE_COLOR)
end
@battler.result.clear_hit_flags
end
end
def check_hp_popup
if @battler_struct.hp != @battler.hp
f = @battler_struct.hp - @battler.hp
if f > 0
make_popup(Jet::BattlePopUps::HURT_TEXT + f.to_s, Jet::BattlePopUps::HURT_COLOR)
elsif f < 0
make_popup(Jet::BattlePopUps::HEAL_TEXT + f.abs.to_s, Jet::BattlePopUps::HEAL_COLOR)
end
@battler_struct.hp = @battler.hp
end
end
end |