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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
| #---------------------------------------------
# script de mort permanente créé par skillsan at gmail point com
# version 0.2 daté du 12/03/2015
# Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 4.0 International.
# http://creativecommons.org/licenses/by-sa/4.0/
#
#Prérequis :
#-créez un état KO (modifiez son id dans les constantes)
#-créez un état cible (modifiez son id dans les constantes)
#fonctionnement :
#la mort est remplacée par le KO, un perso en KO ne peut plus combattre,
#mais les ennemies peuvent encore le toucher, si tous les perso sont KO le combat
#est perdu. A chaque attaque en KO ou chaque KO les points de vitalités diminue
#de 1. S'ils sont à 0 le perso meure. Il est définitivement supprimé de l'équipe
#à la fin du combat.
class Game_BattlerBase
MAX_POINTS_DE_VITALITE = 100
ID_STATU_KO = 26
ID_STATU_CIBLE = 27
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :vp # VP
attr_reader :type # type actor ou monstre
#--------------------------------------------------------------------------
# * Access Method by Parameter Abbreviations
#--------------------------------------------------------------------------
def mvp; MAX_POINTS_DE_VITALITE; end # MVP Maximum Vital points
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(type = "base")
@hp = @mp = @tp = 1
@vp = MAX_POINTS_DE_VITALITE
@type = type
@hidden = false
clear_param_plus
clear_states
clear_buffs
end
def self.is_type?(compar)
return @type == compar
end
#--------------------------------------------------------------------------
# * Check Death State
#--------------------------------------------------------------------------
def death_state?
state?(death_state_id)
end
#--------------------------------------------------------------------------
# * Check K.O. State
#--------------------------------------------------------------------------
def ko_state?
state?(ko_state_id)
end
#--------------------------------------------------------------------------
# * Check Cible State
#--------------------------------------------------------------------------
def cible_state?
state?(cible_state_id)
end
#--------------------------------------------------------------------------
# * Knock Out
#--------------------------------------------------------------------------
def die
@hp = 0
clear_states
clear_buffs
end
#--------------------------------------------------------------------------
# * Get State ID of K.O.
#--------------------------------------------------------------------------
def ko_state_id
return ID_STATU_KO
end
#--------------------------------------------------------------------------
# * Get State ID of Cible
#--------------------------------------------------------------------------
def cible_state_id
return ID_STATU_CIBLE
end
#--------------------------------------------------------------------------
# * Fait revivre
#--------------------------------------------------------------------------
def revivre
if death_state?
@vp = 10
remove_state(ko_state_id)
remove_state(death_state_id)
if @level >5
@level -=5
else
@level = 1
end
@hp = (mhp / 4).round
end
end
#--------------------------------------------------------------------------
# * Get Percentage of Vital points
#--------------------------------------------------------------------------
def vp_rate
@vp.to_f / mvp
end
#--------------------------------------------------------------------------
# * Determine Incapacitation
#--------------------------------------------------------------------------
def ok?
exist? && !(death_state? || ko_state?)
end
end
#------------------------------------------------------------------------------
class Game_Battler < Game_BattlerBase
def initialize(type = "base")
@battler_name = ""
@battler_hue = 0
@actions = []
@speed = 0
@result = Game_ActionResult.new(self)
@last_target_index = 0
@guarding = false
clear_sprite_effects
super(type)
end
#--------------------------------------------------------------------------
# * Determine if States Are Addable
#--------------------------------------------------------------------------
def state_addable?(state_id)
if state_id != cible_state_id
alive? && $data_states[state_id] && !state_resist?(state_id) &&
!state_removed?(state_id) && !state_restrict?(state_id)
else
true
end
end
end
#------------------------------------------------------------------------------
class Game_Unit
def all_dead?
ok_members.empty?
end
#--------------------------------------------------------------------------
# * Get Array of Living And not KO Members
#--------------------------------------------------------------------------
def ok_members
members.select {|member| member.ok? }
end
end
class Game_Actor < Game_Battler
def initialize(actor_id)
super("actor")
setup(actor_id)
@last_skill = Game_BaseItem.new
end
#--------------------------------------------------------------------------
# * Refresh
# si les hp sont à 0, perso ko et -1 vital. si vital à 0 mort
#--------------------------------------------------------------------------
def refresh
state_resist_set.each {|state_id| erase_state(state_id) }
@hp = [[@hp, mhp].min, 0].max
@mp = [[@mp, mmp].min, 0].max
if @hp == 0
if !ko_state?
add_state(ko_state_id)
end
@vp = @vp - 1
if(@vp <= 0)
add_state(death_state_id)
else
@hp = 1 #mhp
end
end
end
end
class Window_Base < Window
def draw_actor_vp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.vp_rate, tp_gauge_color1, tp_gauge_color2)
change_color(system_color)
draw_text(x, y, 32, line_height, "Vp")
change_color(tp_color(actor))
draw_text(x + width - 32, y, 32, line_height, actor.vp.to_i, 1)
end
def draw_gauge(x, y, width, rate, color1, color2)
fill_w = (width * rate).to_i
gauge_y = y + line_height - 16
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
end
#--------------------------------------------------------------------------
# * Draw Simple Status
#--------------------------------------------------------------------------
def draw_actor_simple_status(actor, x, y)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + line_height * 1)
draw_actor_icons(actor, x, y + line_height * 2)
x_maring = 80
draw_actor_class(actor, x + x_maring, y)
contents.font.size = 20
draw_actor_hp(actor, x + x_maring, y + line_height * 1 - 7)
draw_actor_mp(actor, x + x_maring, y + line_height * 2 - 14)
draw_actor_vp(actor, x + x_maring, y + line_height * 3 - 21)
reset_font_settings
end
end
#---------------------------------------------------------------------------
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Draw Gauge Area (with TV)
#--------------------------------------------------------------------------
def draw_gauge_area_with_tp(rect, actor)
contents.font.size = 16
draw_actor_hp(actor, rect.x + 0, rect.y + -5, 64)
draw_actor_mp(actor, rect.x + 76, rect.y + -5, 64)
draw_actor_tp(actor, rect.x + 152, rect.y, 64)
draw_actor_vp(actor, rect.x + 0, rect.y + 5, 140)
reset_font_settings
end
#--------------------------------------------------------------------------
# * Draw Gauge Area (without TP)
#--------------------------------------------------------------------------
def draw_gauge_area_without_tp(rect, actor)
draw_actor_hp(actor, rect.x + 0, rect.y, 64)
draw_actor_mp(actor, rect.x + 76, rect.y, 64)
draw_actor_vp(actor, rect.x + 152, rect.y, 64)
end
end
#------------------------------------------------------------------------------
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Status < Window_Selectable
#--------------------------------------------------------------------------
# * Draw Basic Information
#--------------------------------------------------------------------------
def draw_basic_info(x, y)
draw_actor_level(@actor, x, y + line_height * 0)
draw_actor_icons(@actor, x, y + line_height * 1)
contents.font.size = 20
draw_actor_hp(@actor, x, y + line_height * 2 - 5)
draw_actor_mp(@actor, x, y + line_height * 3 - 10)
draw_actor_vp(@actor, x, y + line_height * 4 - 15)
reset_font_settings
end
end
module BattleManager
#--------------------------------------------------------------------------
# * Defeat Processing
#--------------------------------------------------------------------------
def self.process_defeat
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
wait_for_message
if @can_lose
revive_battle_members
replay_bgm_and_bgs
SceneManager.return
else
SceneManager.goto(Scene_Gameover)
end
battle_end(2)
return true
end
#--------------------------------------------------------------------------
# * Revive Battle Members (When Defeated)
#--------------------------------------------------------------------------
def self.revive_battle_members
$game_party.battle_members.each do |actor|
actor.vp = 1 if actor.vp <= 0
actor.hp = 1 if actor.ko_state?
actor.remove_state(actor.ko_state_id) if actor.ko_state?
actor.remove_state(actor.death_state_id) if actor.dead?
end
end
#--------------------------------------------------------------------------
# * Determine Win/Loss Results
#--------------------------------------------------------------------------
def self.judge_win_loss
if @phase
return process_abort if $game_party.members.empty?
return process_defeat if $game_party.all_dead?
return process_victory if $game_troop.all_dead?
return process_abort if aborting?
end
return false
end
#--------------------------------------------------------------------------
# * End Battle
# result : Result (0: Win 1: Escape 2: Lose)
#--------------------------------------------------------------------------
def self.battle_end(result)
$game_party.battle_members.each do |actor|
if actor.dead?
$game_party.remove_actor(actor.id)
end
end
@phase = nil
@event_proc.call(result) if @event_proc
$game_party.on_battle_end
$game_troop.on_battle_end
SceneManager.exit if $BTEST
end
#--------------------------------------------------------------------------
# * Start Turn
#--------------------------------------------------------------------------
def self.turn_start
@phase = :turn
clear_actor
make_action_orders
end
end
|