#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?('Trickster\'s Bestiary')
class Window_BestiaryCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Call Window_Selectable#initialize
super(0, 0, 160, 480)
# Setup Item Max
@item_max = $game_system.enemies.size
# Create Contents
self.contents = Bitmap.new(width - 32, @item_max * 32)
# Set Font to Shadow
self.contents.font.shadow = true
# Refresh Window
refresh
# Set Index to 0
self.index = 0
end
#--------------------------------------------------------------------------
# * Get Battler
#--------------------------------------------------------------------------
def battler
return $game_system.enemies[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Clear Contents
self.contents.clear
# Draw Each Item
$game_system.enemies.each_index {|index| draw_item(index)}
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
# Get Enemy ID
enemy_id = $game_system.enemies[index]
# Get Position
x, y = 4, index * 32
# Get Enemy
enemy = $data_enemies[enemy_id]
# If Seen At Least Once
name = $game_system.seen[enemy_id] > 0 ? enemy.name : Bestiary::Not_Seen
# Draw Index
self.contents.draw_text(x, y, 32, 32, sprintf("%03d:", index+1))
# Draw Name
self.contents.draw_text(x + 36, y, contents.width, 32, name)
end
end
class Window_Bestiary < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Call Window Base#initialize
super(160, 0, 480, 480)
# Setup Contents
self.contents = Bitmap.new(width - 32, height - 32)
# Set Shadow
self.contents.font.shadow = true
# Setup Instance Variables
@battler = nil
# Refresh Window
refresh
end
#--------------------------------------------------------------------------
# * Set Battler
#--------------------------------------------------------------------------
def battler=(battler)
# Return if a battler and ids are the same
return if @battler != nil and @battler.id == battler
# Set Battler
@battler = $data_enemies[battler]
# Refresh
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# if battler is nil or not seen
if @battler == nil or $game_system.seen[@battler.id] == 0
# Clear
self.contents.clear
# Return
return
end
# Clear Contents
self.contents.clear
# Setup Local Variable battler
battler = @battler
# Draw Name
draw_actor_name(battler, 0, 0)
# Draw Hp
draw_actor_hp(battler, 176, 0, 112)
# Draw Sp
draw_actor_sp(battler, 328, 0, 112)
# Draw Enemy
draw_enemy(battler, 0, 32, 176, 176)
# Do 10 times
10.times do |i|
# Get X and Y
x, y = (i % 2) == 0 ? 176 : 328, (i / 2) * 32 + 32
# Draw Parameter
draw_parameter(battler, x, y, 80, i)
end
# Draw Seens
draw_seens(battler, 328, 192, 80)
# Draw Kills
draw_kills(battler, 328, 224, 80)
# Draw Items
draw_battler_items(battler, 0, 192)
# Draw Elements
draw_battler_elements(battler, 0, 224, 328)
# Draw Maps Where can be found
draw_maps(battler, 0, 288, 328)
# Draw Description
draw_battler_description(battler, 0, 352)
end
#--------------------------------------------------------------------------
# * Draw Name
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 176, 32, actor.name, 1)
end
#--------------------------------------------------------------------------
# * Draw HP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# Draw "HP" text string
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# Draw HP
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width, 32, actor.maxhp.to_s, 2)
end
#--------------------------------------------------------------------------
# * Draw SP
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : draw spot width
#--------------------------------------------------------------------------
def draw_actor_sp(actor, x, y, width = 144)
# Draw "SP" text string
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
# Draw SP
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width, 32, actor.maxsp.to_s, 2)
end
#--------------------------------------------------------------------------
# * Draw Seens
#--------------------------------------------------------------------------
def draw_seens(battler, x, y, width)
# System Color Font
self.contents.font.color = system_color
# Draw Parameter Name
self.contents.draw_text(x, y, width, 32, 'Seen')
# Normal Color Font
self.contents.font.color = normal_color
# Get Value
value = $game_system.seen[battler.id].to_s
# Draw Value
self.contents.draw_text(x + 32, y, width, 32, value, 2)
end
#--------------------------------------------------------------------------
# * Draw Kills
#--------------------------------------------------------------------------
def draw_kills(battler, x, y, width)
# System Color Font
self.contents.font.color = system_color
# Draw Parameter Name
self.contents.draw_text(x, y, width, 32, 'Killed')
# Normal Color Font
self.contents.font.color = normal_color
# Get Value
value = $game_system.killed[battler.id].to_s
# Draw Value
self.contents.draw_text(x + 32, y, width, 32, value, 2)
end
#--------------------------------------------------------------------------
# * Draw Parameter
#--------------------------------------------------------------------------
def draw_parameter(battler, x, y, width, type)
# Setup Array (Array of Strings)
array = %w( atk pdef mdef str dex agi int eva gold exp )
# If type is not eva or exp
if not ['eva','exp'].include?(array[type])
# Call $data_system.words.(variable)
name = $data_system.words.method(array[type]).call
else
# Just Capitalize it
name = array[type].capitalize
end
# Call battler.(variable) to get value
value = battler.method(array[type]).call.to_s
# System Color Font
self.contents.font.color = system_color
# Draw Parameter Name
self.contents.draw_text(x, y, width, 32, name)
# Normal Color Font
self.contents.font.color = normal_color
# Draw Value
self.contents.draw_text(x + 32, y, width, 32, value, 2)
end
#--------------------------------------------------------------------------
# * Draw Battler Items
#--------------------------------------------------------------------------
def draw_battler_items(battler, x, y)
# Get Width
cx = contents.text_size('Items:').width
# Draw Items:
self.contents.draw_text(x, y, width, 32, 'Items:')
# Set Total Width
total_width = cx + 8
# Setup Battler Array
item_array = [battler.item_id, battler.weapon_id, battler.armor_id]
# Get Secondary Item Ids
secondary = battler.respond_to?
get_item_ids) ? battler.get_item_ids : []
# Get Rare Item Ids
rare = battler.respond_to?
get_rare_ids) ? battler.get_rare_ids : []
# If An Item
if item_array.max != 0
# Item Id
item_id = item_array.max
# Item Type
item_type = item_array.index(item_id)
# Branch By Item Type
case item_type
when 0
item = $data_items[item_id]
when 1
item = $data_weapons[item_id]
when 2
item = $data_armors[item_id]
end
# Get Item Name
item_name = item.name + ((secondary + rare).empty? ? '' : ',')
# Get Width
width = contents.text_size(item_name).width
# Draw Item Name
self.contents.draw_text(x + cx + 8, y, width, 32, item_name)
# Set Total Width
total_width = cx + 16 + width
end
# If not empty?
if not secondary.empty?
# Get Item ID and Item Type
item_id, item_type = secondary[0..1]
# Branch By Item Type
case item_type
when 1
item = $data_items[item_id]
when 2
item = $data_weapons[item_id]
when 3
item = $data_armors[item_id]
end
# Get Item Name
item_name = item.name + (rare.empty? ? '' : ',')
# Get Width
width = contents.text_size(item_name).width
# Draw Item Name
self.contents.draw_text(x + total_width, y, width, 32, item_name)
# Add to Total Width
total_width += 8 + width
end
# If not Empty
if not rare.empty?
# Get Item ID and Item Type
item_id, item_type = rare[0..1]
# Branch By Item Type
case item_type
when 1
item = $data_items[item_id]
when 2
item = $data_weapons[item_id]
when 3
item = $data_armors[item_id]
end
# Get Width
width = contents.text_size(item.name).width
# Set Text to Gold
self.contents.font.color = Color.new(255, 224, 32)
# Draw Item Name
self.contents.draw_text(x + total_width, y, width, 32, item.name)
# Set Text to Normal Color
self.contents.font.color = normal_color
# Add to Total Width
total_width += 8 + width
end
# If Nothing Drawn (that is total width is cx + 8)
if total_width == cx + 8
# Draw Nothing
self.contents.draw_text(x + cx + 8, y, self.width, 32, 'None')
end
end
#--------------------------------------------------------------------------
# * Draw Enemy
#--------------------------------------------------------------------------
def draw_enemy(enemy, x, y, width, height, opacity = 255)
# Get Bitmap
bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
# If Stretching
if Bestiary::Draw_Type == 0
# Fit Blt (See MACL)
self.contents.fit_blt(x, y, width, height, bitmap, opacity)
# If Cropping
else
# Get Direction of Crop
dir = Bestiary::Crop[enemy.id]
# Crop Blt (See MACL)
self.contents.crop_blt(x, y, width, height, bitmap, dir, 1, opacity)
end
end
#--------------------------------------------------------------------------
# * Draw Battler Elements
#--------------------------------------------------------------------------
def draw_battler_elements(battler, x, y, width)
# Get Weakesses
elements = battler.weaknesses
# Set String
string = 'Weak: '
# If Elements not empty
if not elements.empty?
# Set Name OF Element
elements.each {|element| string += $data_system.elements[element] + ', '}
# Remove Last Two Characters
string[-2, 2] = ''
else
# Add None
string += 'None'
end
# Draw Weakness String
self.contents.draw_text(x, y, width, 32, string)
# Get Resistance Elements
elements = battler.resistance
# Set String
string = 'Strong: '
# If Elements not empty
if not elements.empty?
# Set Name of Element
elements.each {|element| string += $data_system.elements[element] + ', '}
# Remove Last Two Characters
string[-2, 2] = ''
else
# Add None
string += 'None'
end
# Draw Resistance String
self.contents.draw_text(x, y + 32, width, 32, string)
end
#--------------------------------------------------------------------------
# * Draw Battler Maps
#--------------------------------------------------------------------------
def draw_maps(battler, x, y, width)
# Setup String
string = 'Location: '
# Get Troops
troops = (1...$data_troops.size).to_a - Bestiary::Excluded_Troops
# Delete Id if Enemy is not in it
troops.delete_if {|troop_id| !$data_troops[troop_id].has_enemy?(battler.id)}
# Setup Maps Array
maps = []
# Get Maps
$data_mapinfos.each do |index, map|
# Skip if index is 0
next if index == 0
# If Includes any of the troops in list Push index
maps << index if map.encounter_list.includes_any?(*troops)
end
# Remove Excluded
maps -= Bestiary::Excluded_Maps
# Add Locations
maps += Bestiary::Locations[battler.id].to_a
# Remove Duplicates
maps.uniq!
# If Maps are not empty
if not maps.empty?
# Run Through and Push Strings
maps.each {|map_id| string += "#{$data_mapinfos[map_id].name}, "}
# Remove Last Two Characters
string[-2, 2] = ''
else
# Add None (Unknown)
string += 'Unknown'
end
# Draw Text
self.contents.draw_text(x, y, width, 32, string)
end
#--------------------------------------------------------------------------
# * Draw Battler Description
#--------------------------------------------------------------------------
def draw_battler_description(battler, x, y)
# Get String
string = 'Description: ' + Bestiary::Description[battler.id]
# Draw Wrapped Text
self.contents.draw_wrap_text(x, y, contents.width, 32, string)
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end