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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
| ################################################################
# RETCON Library
# Bestiary Version 1.4
# Author: Matt (McDohl)
# Script is free for usage, but please give credit where credit
# is due. :)
################################################################
# PURPOSE
# This script adds a bestiary (yes, it's spelled bestiary) to your
# game. It hides enemies until they've been encountered, keeps
# track of how many have been defeated, displays their stats,
# as well as a blurb about the enemy.
#
# As of right now, there is a lot of hard-coded stuff in this script.
# That will change as I get more familiar with RGSS3 and VX ACE's
# method handling.
################################################################
# UPDATE HISTORY
# 1.4 - Added description text offset.
# Added function to module to change the variable appropriate for
# bestiary access. Bad programming practices shoo.
# 1.3 - Added method to check if the bestiary variable exists.
# If not, call function to create it. Mostly for users
# who plug in this script while loading a game save.
# Checks for draw_text word wrap script, as now is part of
# the RETCON library.
# Added lock function.
# Fixed bug wherein selecting a locked function would cause
# a user's game to crash.
# 1.2 - Fixed bug which was not ticing off multiple enemy deaths
# correctly.
# More code cleaning.
# 1.1 - Added tag+method to skip a monster in the database
# Used terms as defined in the database rather than hardcode.
# Added columns variable.
# Rudimentary code cleanup.
# 1.0 - First draft
################################################################
# METHODOLOGY
# Trois nouvelles classes de fenêtres sont créées:
#
# Window_Bestiary - Affiche la fenêtre bestiaire. Sous-ensemble de
# Window_Command, C'est là que les monstres sont affichés / cachés (shown/hidden).
#
# Window_Monster - Affiche les informations essentielles de monstres sur l'être
# Sélectionné dans Window Bestiary. Sous-ensemble de Window_Selectable.
#
# Window_MonsterDesc - Affiche le numéro d'index du monstre, le nom,
# Ainsi que combien de fois vaincu.
#
# Une nouvelle classe de scène est créée:
#
# Scene_Bestiary - Gère toutes les fenêtres du bestiaire.
#
# Five previously initialized classes are modified.
#
# Window_MenuCommand - Modified to include the bestiary method to the
# menu.
#
# Scene_Menu - Affiche la commande bestiaire dans le menu.
#
# Game_Party - Initalizes and saves the bestiary hash, as well as
# making it referable. This is where the bestiary hash is saved as well, so
# make sure to start a new game when testing this script, or to comment it out
# if you want to continue.
#
# Game_Troop - Le rend si ennemis vu sont mis à vrai dans le hash bestiaire.
#
# Game_Battler - Tics the bestiary hash when an enemy is defeated.
################################################################
# USAGE
# Dans la section Notes de l'onglet Monstres de la base de données, vous pouvez
# Description au monstre à analyser dans le bestiaire. Tags pour le
# Bestiaire suivre ce format:
#
# <bestiary: *.* />
#
# Où *. * Est remplacé par le texte descripteur que vous souhaitez afficher
# Dans le bestiaire. Il s'agit de deux lignes, et nécessite des retours manuels de carrage, donc utilisez
# \ N pour délimiter où la fonction draw_text_ex devrait passer à la ligne suivante.
#
# Example:
# <bestiary: The legendary white tiger. His fangs are said\nto be able to crush diamonds. />
#
# Remarque: Si le script wrapper de texte draw_text est chargé, \ n n'est pas nécessaire. Ce sera
# Afficher le texte normalement.
#
# Si vous souhaitez sauter un monstre dans la base de données d'être classé dans le hash,
# (Utilisé comme une sorte delinear, pas prêt à être implémenté, ou quelle que soit la raison),
# Il suffit d'ajouter cette balise dans les notes:
# <skipbestiary />
#
# Pour modifier l'accès Bestiaire, appelez la fonction script suivante dans votre jeu
# RETCON::Bestiary::bestiary_access(bool)
# Replace 'bool' with either 'true' (accessible) or 'false' (inaccessible)
################################################################
# CONCERNS
#-If enemies "revive", it will not detract from their kill count.
#-There is a potential collision issue should an actor name have
# the same name as a monster during the same fight and an actor dies.
# This is due to the Game_Battler class not distinguishing between
# actors and enemies.
#-Assumes all listings in the database are monsters. If you're organizing
# your monsters by adding blanks and such, make sure you use the skipbestiary
# tag.
################################################################
# CUSTOMIZATION
module RETCON
module Bestiary
#Nom du bestiaire dans le menu de commande.
Name = "Bestiaire"
#Largeur du menu monstre. Réglez sur 544, ou la largeur maximale.
Width = 544
#What to display in the bestiary when an enemy is locked.
Hidden = "???"
#Number of columns to display on the bestiary.
Columns = 2
# Faire le bestiaire accessible dans le menu. Définissez sur true pour la rendre disponible,
#set à false pour le rendre indisponible, au début de votre jeu.
Available = true
#Offset pour la description du bestiaire. Mesuré par pixels.
#Make négatif pour soulever le texte. Assurez-vous de baisser le texte.
#line_height est de 24 pixels.
DescOffset = 0
################################################################
#Customization ends here!
#You shouldn't really edit below here, but if you know what
#you're doing, it won't be a big deal. Edit at your own risk and
#all that jazz.
################################################################
def self.check_for_bestiary
$game_party.make_the_bestiary if $game_party.bestiary.nil?
end
def self.bestiary_access(bestiarybool)
$game_party.bestiary_accessible = bestiarybool
end
end
end
#################
#CLASS ORIGINALS#
#################
#The bestiary command window, activates when selected.
class Window_Bestiary < Window_Command
def initialize
super(0, fitting_height(1))
end
def window_height
Graphics.height - fitting_height(1)
end
def window_width
return RETCON::Bestiary::Width
end
#Interprets bestiary hash to display commands.
def make_command_list
RETCON::Bestiary::check_for_bestiary
i = 0
$game_party.bestiary.each {|k, v|
i += 1
if v[0] == false
add_command(RETCON::Bestiary::Hidden, :bestiary_blank)
else
add_command("%03d" %i.to_s + ". #{k}", :bestiary_lookup)
end
}
end
def col_max
return RETCON::Bestiary::Columns
end
#Masquer et afficher les fonctions qui masquent le menu de commande lorsque vous affichez un ennemi
def hide
self.opacity = 0
self.contents_opacity = 0
end
def show
self.opacity = 255
self.contents_opacity = 255
end
end
#Window to display the monster once selected.
class Window_Monster < Window_Selectable
def initialize
super(0, fitting_height(1), Graphics.width, Graphics.height - fitting_height(1))
draw_horz_line(line_height * 11)
self.openness = 0
open
end
#three methods to display the monster window
def display_monster(enemyindex)
monsterdb = $data_enemies[enemyindex]
get_the_entry(monsterdb)
draw_monster(monsterdb)
draw_stats(monsterdb)
end
def get_the_entry(db)
#draws the bestiary description text as set in notes.
monstentry = db.note
if monstentry =~ /<bestiary: (.*) \/>/i
monstentry = $1.to_str
if !$imported.nil? && $imported["RETCON-wordwrap"] == true
draw_text(4, line_height * 12 + RETCON::Bestiary::DescOffset, Graphics.width, line_height * 4, monstentry)
else
monstentry = monstentry.gsub(/\\n/, "\n")
draw_text_ex(4, line_height * 12 + RETCON::Bestiary::DescOffset, monstentry)
end
end
end
#calls and displays the monster image, including hues.
def draw_monster(db)
@monstviewport = Viewport.new(6, fitting_height(1) + 6, 412, Graphics.height - fitting_height(5))
@monstviewport.z = 1000
@monstpicture = Sprite.new(@monstviewport)
@monstpicture.bitmap = Cache.battler(db.battler_name, db.battler_hue)
#determines centers of the viewpoint and currently loaded image
ox = @monstviewport.rect.width / 2
oy = @monstviewport.rect.height / 2
obx = @monstpicture.bitmap.width / 2
oby = @monstpicture.bitmap.height / 2
#realigns the image so it's centered in the viewport
@monstpicture.x = ox - obx
@monstpicture.y = oy - oby
end
#displays the monsters stats. Does not show MP.
#Same lines for each stat, but one is aligned left and one aligned right.
def draw_stats(db)
stat_window_width = Graphics.width - 430
stat_window_x = 403
stats = Array.new
params = Array.new
stats = [Vocab::param(0), Vocab::param(2), Vocab::param(3), Vocab::param(4), Vocab::param(5), Vocab::param(6), Vocab::param(7)]
change_color(system_color)
7.times{|i| draw_text(stat_window_x, fitting_height(i-1), stat_window_width, line_height, stats[i])}
params = [db.params[0], db.params[2], db.params[3], db.params[4], db.params[5], db.params[6], db.params[7]]
change_color(normal_color)
7.times {|i| draw_text(stat_window_x, fitting_height(i-1), stat_window_width, line_height, params[i], 2)}
change_color(text_color(17))
draw_text(stat_window_x, fitting_height(6), stat_window_width, line_height, Vocab::currency_unit)
change_color(normal_color)
draw_text(stat_window_x, fitting_height(7), stat_window_width, line_height, db.gold, 2)
change_color(text_color(23))
draw_text(stat_window_x, fitting_height(8), stat_window_width, line_height, "EXP")
change_color(normal_color)
draw_text(stat_window_x, fitting_height(9), stat_window_width, line_height, db.exp, 2)
end
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
def line_color
color = normal_color
color.alpha = 128
color
end
#erases the picture when window closes.
def clear_pic
@monstpicture.dispose
end
def window_width
return Graphics.width
end
end
#description window when displaying monster. Shows name as well as times defeated.
class Window_MonsterDesc < Window_Selectable
def initialize
super(0, 0, Graphics.width, fitting_height(1))
self.openness = 0
open
end
def display_desc(enemyname, enemyindex)
enemynumindex = "%03d" %enemyindex.to_s
change_color(text_color(6))
draw_text(0, 0, width-30, line_height, "Entrée #" + enemynumindex + ": " + enemyname)
change_color(normal_color)
draw_text(0, 0, width-30, line_height, "Nombre de défaits: " + $game_party.bestiary[enemyname][1].to_s, 2)
end
end
#Displays the scene
class Scene_Bestiary < Scene_MenuBase
def initialize
super
create_bestiary
end
#shows the command window for the bestiary
def create_bestiary
@monsterlisting = Window_Bestiary.new
@monsterlisting.set_handler(:bestiary_blank, method(:play_error))
@monsterlisting.set_handler(:bestiary_lookup, method(:monst_display))
@monsterlisting.set_handler(:cancel, method(:backout))
@monsterlisting.active = true
end
def backout
SceneManager.return
end
#when a monster is selected, initializes the new windows and makes
#them the focus
def monst_display
@monster = Window_Monster.new
@monsterdesc = Window_MonsterDesc.new
monster_info
@monster.set_handler(:cancel, method(:clear_monster))
@monsterdesc.set_handler(:cancel, method(:clear_monster))
@monsterlisting.hide
@monster.active = true
@monsterdesc.active = true
end
#sends information to window classes to display correct information
def monster_info
subjectnumber = @monsterlisting.index+1
subject = $data_enemies[subjectnumber].name
@monsterdesc.display_desc(subject, subjectnumber)
@monster.display_monster(subjectnumber)
end
#dummy function to do nothing when locked enemy is selected
def play_error
@monsterlisting.active = true
Sound::play_buzzer
end
#refocuses the bestiary command list
def clear_monster
@monster.clear_pic
@monster.close
@monsterdesc.close
@monsterlisting.show
@monsterlisting.active = true
end
end
###############
#CLASS ADDENDA#
###############
#Ajoute l'option bestiaire à la fenêtre, en ajoutant add_original_commands
class Window_MenuCommand < Window_Command
alias bestiary_command add_original_commands
def add_original_commands
bestiary_command
add_command(RETCON::Bestiary::Name, :bestiary, $game_party.bestiary_accessible)
end
end
#adds the bestiary option to the command menu
class Scene_Menu < Scene_MenuBase
alias bestiary_command_window create_command_window
def create_command_window
bestiary_command_window
#the addition
@command_window.set_handler(:bestiary, method(:command_bestiary))
end
def command_bestiary
SceneManager.call(Scene_Bestiary)
end
end
#initializes the bestiary hash, as well as makes it accessible.
class Game_Party < Game_Unit
attr_accessor :bestiary
attr_accessor :bestiary_accessible
alias beastiary_retain_previous initialize
def initialize
beastiary_retain_previous
make_the_bestiary
end
#initalizes the bestiary hash.
def make_the_bestiary
enemies = $data_enemies
monsterlist = Array.new
@bestiary = Hash.new
@bestiary_accessible = RETCON::Bestiary::Available
i = 0
while i < enemies.length
if i == 0
i = 1
end
if enemies[i].note =~ /<skipbestiary \/>/i
p i-1 ##skip method
else
monsterlist[i-1] = enemies[i].name
@bestiary.merge! monsterlist[i-1] => [false, 0]
end
i += 1
end
end
end
#upon battle initialization, unlocks enemies in the bestiary
class Game_Troop < Game_Unit
alias bestiary_setup setup
def setup(troop_id)
bestiary_setup(troop_id)
seen_the_enemy
end
def seen_the_enemy
RETCON::Bestiary::check_for_bestiary
members.each do |enemy|
if $game_party.bestiary[enemy.original_name][0] == false
$game_party.bestiary[enemy.original_name][0] = true
end
end
end
end
#checks death in a battle to see if it was enemy or ally.
#if enemy, then add a tick to the bestiary hash.
class Game_Battler < Game_BattlerBase
alias bestiary_die die
def die
bestiary_die
enemy_check
end
def enemy_check
enemy_dead = false
$game_troop.members.each do |enemy|
if enemy.original_name == @original_name && enemy_dead == false
$game_party.bestiary[enemy.original_name][1] += 1
enemy_dead = true
end
end
end
end |