brainstorm
Member
I need help with this script:
I get an Error everytime, It says that a method error I think. No method for Name...
class Game_Enemy
#--------------------------------------------------------------------------
#note type = 1 for item 2 for weapon and 3 for armor
def get_item_ids
hash = Hash.new([nil, nil, nil])
#hash[id] = [id, type, chance]
hash[24] = [4,1,20] #[item_id, item_type, chance]
hash[23] = [4,1,20]
return hash[self.id]
end
#--------------------------------------------------------------------------
def get_rare_ids
hash = Hash.new([nil, nil, nil])
#hash[id] = [id, type, chance]
hash[24] = [9,1,10] #[item_id, item_type, chance]
hash[23] = [9,1,10]
return hash[self.id]
end
end
#===================================================
# â–¼ CLASS Scan_Window Begins
#===================================================
class Scan_Window < Window_Base
def initialize(battler)
super(80,0,480,320)
self.contents = Bitmap.new(width - 32, height - 32)
@battler = battler
self.back_opacity = 160
refresh
end
def refresh
self.contents.clear
draw_scan(@battler)
end
def draw_scan(battler)
y = 0
self.contents.draw_text(0,y,120,32,battler.name)
self.contents.font.color = system_color
cx = contents.text_size("HP:").width
self.contents.draw_text(128,y,120,32,"HP:")
self.contents.draw_text(288,y,120,32,"SP:")
self.contents.font.color = normal_color
self.contents.draw_text(128+cx+8,y,120,32,"#{battler.hp}/#{battler.maxhp}")
self.contents.draw_text(288+cx+8,y,120,32,"#{battler.sp}/#{battler.maxsp}")
draw_battler(battler,0,y+32,128,128)
for i in 0..9
draw_parameter(battler,160*(i%2)+128,i/2 * 32 + 32, max_width, i)
end
draw_battler_items(battler,0,y+192)
draw_battler_elements(battler,0,y+224)
end
def draw_battler_items(battler,x,y)
cx = contents.text_size("Items:").width
self.contents.draw_text(x,y,cx,32,"Items:")
item = [battler.item_id, battler.weapon_id, battler.armor_id]
id = item.max
type = item.index(id)
type_array = ["items","weapons","armors"]
item_name = eval("$data_#{type_array[type]}[id].name") + " "
width = contents.text_size(item_name).width if item_name != nil
width = 0 if item_name == nil
self.contents.draw_text(x+cx+8,y,width,32,item_name)
total_width = cx+16+width
sec = battler.get_item_ids
if not sec.compact.empty?
sec_type = sec[1] - 1
sec_id = sec[0]
sec_name = eval("$data_#{type_array[sec_type]}[sec_id].name") + " "
width = contents.text_size(sec_name).width if sec_name != nil
self.contents.draw_text(x+total_width,y,width,32,sec_name)
total_width += 8+width
end
rare = battler.get_rare_ids
if not rare.compact.empty?
rare_type = rare[1] - 1
rare_id = rare[0]
rare_name = eval("$data_#{type_array[rare_type]}[rare_id].name")
width = contents.text_size(rare_name).width if rare_name != nil
self.contents.font.color = Color.new(255,224,32)
self.contents.draw_text(x+total_width,y,width,32,rare_name)
self.contents.font.color = normal_color
end
end
def draw_battler(battler,x,y,width,height)
bitmap = RPG::Cache.battler(battler.battler_name, battler.battler_hue)
w = bitmap.width
h = bitmap.height
zoom_x = w
zoom_y = h
if (w > width) or (h > height)
zoom_x = width if w > width
zoom_y = height if h > height
end
dest_rect = Rect.new(x, y, zoom_x, zoom_y)
src_rect = Rect.new(0, 0, w, h)
self.contents.stretch_blt(dest_rect, bitmap, src_rect, 255)
end
def draw_parameter(battler, x, y, width, type)
array = ["atk","pdef","mdef","str","dex","agi","int","eva","gold","exp"]
if not ["eva","exp"].include?(array[type])
name = eval("$data_system.words.#{array[type]}")
else
name = array[type].capitalize
end
value = eval("battler.#{array[type]}")
self.contents.font.color = system_color
self.contents.draw_text(x, y, width, 32, "#{name}")
self.contents.font.color = normal_color
self.contents.draw_text(x + width, y, 36, 32, "#{value}",2)
end
def max_width
array = ["atk","pdef","mdef","str","dex","agi","int","gold"]
max = 0
for i in 0..7
stat_name = eval("$data_system.words.#{array}")
if max < contents.text_size(stat_name).width
max = contents.text_size(stat_name).width
end
end
return max
end
def draw_battler_elements(battler, x, y)
elements = battler.weaknesses
string = "Weaknesses: "
if not elements.empty?
for element in elements
string += $data_system.elements[element] + " "
end
else
string += "None"
end
self.contents.draw_text(x, y, self.width, 32, string)
elements = battler.resistance
string = "Resists: "
if not elements.empty?
for element in elements
string += $data_system.elements[element] + " "
end
else
string += "None"
end
self.contents.draw_text(x, y+32, self.width, 32, string)
end
end
#===================================================
# â–² CLASS Scan_Window Ends
#===================================================
#--------------------------------------------------------------------------
#note type = 1 for item 2 for weapon and 3 for armor
def get_item_ids
hash = Hash.new([nil, nil, nil])
#hash[id] = [id, type, chance]
hash[24] = [4,1,20] #[item_id, item_type, chance]
hash[23] = [4,1,20]
return hash[self.id]
end
#--------------------------------------------------------------------------
def get_rare_ids
hash = Hash.new([nil, nil, nil])
#hash[id] = [id, type, chance]
hash[24] = [9,1,10] #[item_id, item_type, chance]
hash[23] = [9,1,10]
return hash[self.id]
end
end
#===================================================
# â–¼ CLASS Scan_Window Begins
#===================================================
class Scan_Window < Window_Base
def initialize(battler)
super(80,0,480,320)
self.contents = Bitmap.new(width - 32, height - 32)
@battler = battler
self.back_opacity = 160
refresh
end
def refresh
self.contents.clear
draw_scan(@battler)
end
def draw_scan(battler)
y = 0
self.contents.draw_text(0,y,120,32,battler.name)
self.contents.font.color = system_color
cx = contents.text_size("HP:").width
self.contents.draw_text(128,y,120,32,"HP:")
self.contents.draw_text(288,y,120,32,"SP:")
self.contents.font.color = normal_color
self.contents.draw_text(128+cx+8,y,120,32,"#{battler.hp}/#{battler.maxhp}")
self.contents.draw_text(288+cx+8,y,120,32,"#{battler.sp}/#{battler.maxsp}")
draw_battler(battler,0,y+32,128,128)
for i in 0..9
draw_parameter(battler,160*(i%2)+128,i/2 * 32 + 32, max_width, i)
end
draw_battler_items(battler,0,y+192)
draw_battler_elements(battler,0,y+224)
end
def draw_battler_items(battler,x,y)
cx = contents.text_size("Items:").width
self.contents.draw_text(x,y,cx,32,"Items:")
item = [battler.item_id, battler.weapon_id, battler.armor_id]
id = item.max
type = item.index(id)
type_array = ["items","weapons","armors"]
item_name = eval("$data_#{type_array[type]}[id].name") + " "
width = contents.text_size(item_name).width if item_name != nil
width = 0 if item_name == nil
self.contents.draw_text(x+cx+8,y,width,32,item_name)
total_width = cx+16+width
sec = battler.get_item_ids
if not sec.compact.empty?
sec_type = sec[1] - 1
sec_id = sec[0]
sec_name = eval("$data_#{type_array[sec_type]}[sec_id].name") + " "
width = contents.text_size(sec_name).width if sec_name != nil
self.contents.draw_text(x+total_width,y,width,32,sec_name)
total_width += 8+width
end
rare = battler.get_rare_ids
if not rare.compact.empty?
rare_type = rare[1] - 1
rare_id = rare[0]
rare_name = eval("$data_#{type_array[rare_type]}[rare_id].name")
width = contents.text_size(rare_name).width if rare_name != nil
self.contents.font.color = Color.new(255,224,32)
self.contents.draw_text(x+total_width,y,width,32,rare_name)
self.contents.font.color = normal_color
end
end
def draw_battler(battler,x,y,width,height)
bitmap = RPG::Cache.battler(battler.battler_name, battler.battler_hue)
w = bitmap.width
h = bitmap.height
zoom_x = w
zoom_y = h
if (w > width) or (h > height)
zoom_x = width if w > width
zoom_y = height if h > height
end
dest_rect = Rect.new(x, y, zoom_x, zoom_y)
src_rect = Rect.new(0, 0, w, h)
self.contents.stretch_blt(dest_rect, bitmap, src_rect, 255)
end
def draw_parameter(battler, x, y, width, type)
array = ["atk","pdef","mdef","str","dex","agi","int","eva","gold","exp"]
if not ["eva","exp"].include?(array[type])
name = eval("$data_system.words.#{array[type]}")
else
name = array[type].capitalize
end
value = eval("battler.#{array[type]}")
self.contents.font.color = system_color
self.contents.draw_text(x, y, width, 32, "#{name}")
self.contents.font.color = normal_color
self.contents.draw_text(x + width, y, 36, 32, "#{value}",2)
end
def max_width
array = ["atk","pdef","mdef","str","dex","agi","int","gold"]
max = 0
for i in 0..7
stat_name = eval("$data_system.words.#{array}")
if max < contents.text_size(stat_name).width
max = contents.text_size(stat_name).width
end
end
return max
end
def draw_battler_elements(battler, x, y)
elements = battler.weaknesses
string = "Weaknesses: "
if not elements.empty?
for element in elements
string += $data_system.elements[element] + " "
end
else
string += "None"
end
self.contents.draw_text(x, y, self.width, 32, string)
elements = battler.resistance
string = "Resists: "
if not elements.empty?
for element in elements
string += $data_system.elements[element] + " "
end
else
string += "None"
end
self.contents.draw_text(x, y+32, self.width, 32, string)
end
end
#===================================================
# â–² CLASS Scan_Window Ends
#===================================================
I get an Error everytime, It says that a method error I think. No method for Name...