The flask idea would require a minimum of three different graphics for anything affected by gravity. This in turn would require recoding the entire system for rotating/flipping, which was complete dick to get working in the first place (would shift around, get placed int he wrong spot, stack on top of other items, etc.).
So, I'll go with "shut up it's magic D8<"
You're welcome to try, though.
I don't actually remember how this works.
I don't even know how I'm going to work out adding items into the thing. I don't feel like coding a method to find open spots for items, so I'll probably just make the player manually stick stuff in it themselves.
I'm currently working on the new quest log.
I have run into a slight problem.
Problem: Can't code the layout very well without having the background sprited. Can't sprite the background very well until I know how the layout will fit.
With a window, it can be most any shape.
But did I make it a window? Noooo. I had to go and make it a book, so now it has to have proportions that
A) look normal for a book
B) Aren't too small
C) have room for a list on the side
The end result is that the code for quests is not going to be autoformatted, it's going to have to be manually set up similar to how the info window for items works.
Which looks like this:
Progress so far:
All it can currently do is list the quest lists. Quests will (eventually) be sorted by location.
After I make the cursor. And page-turning. And graphics. And method for drawing the data for it. And make the list on the right for the quests themselves.
Also tested out fotz's pixelmovement's built-in waypoint generator for pathfinding.
IT IS BOLLOCKS.
I get to do them by hand, yay!
Luckily, this won't be needed for a good while, so I can put in on hold for a looong time.
Lastly:
Flooded my damn fort again. :|
So, I'll go with "shut up it's magic D8<"
You're welcome to try, though.
Code:
class Window_Item_Bag < Window_Base
attr_accessor :phase
def initialize(bag = -1, x = 0, y = 0, z = 200)
super(0,0,640,480)
self.contents = Bitmap.new(width-32,height-32)
self.opacity = 0
@bag_grid = Sprite.new
@bag_contents = []
@grab_offset = [16,16,16,8]
@index = [0, 0, 0, bag]
@tempstorage = Item_Bag.new(4,10)
@tempstorage.background = [0,0]
if bag == -1
@itembag = $game_party.item_bag
else
@itembag = $game_actors[bag].item_bag
end
@offsets = [x, y, @itembag.background[0], @itembag.background[1], z, 416, 0]
@bag_grid.bitmap = Bitmap.new(32 * @itembag.columns, 32 * @itembag.rows)
@bag_grid.x = @offsets[0] + @offsets[2]
@bag_grid.y = @offsets[1] + @offsets[3]
@bag_grid.z = @offsets[4] + 20
@temp_contents = []
@temp_grid = Sprite.new
@temp_grid.bitmap = Bitmap.new(32 * @tempstorage.columns, 32 * @tempstorage.rows)
@temp_grid.x = @offsets[0] + @offsets[2] + @offsets[5]
@temp_grid.y = @offsets[1] + @offsets[3] + @offsets[6]
@temp_grid.z = @offsets[4]
@page = Sprite.new
@page.bitmap = Bitmap.new(120,32)
@page.z = @offsets[4] + 31
@tempindex = [0,0]
@grabbed_item = Sprite.new
@grabbed_item.z = @offsets[4] + 45
@toggle = [true, true, false]
@phase = [0, 0]
@grabbed = [nil, 0]
@info_window = Jaber_Info.new
@info_window.y = 500
bag_open
@cursor = Sprite.new
@cursor.bitmap = RPG::Cache.picture("Cursor")
@cursor.ox = 85
@cursor.oy = 8
@cursor.z = @offsets[4] + 50
@cursor.angle = 135
@cursor.x = 200 + @offsets[0] + @offsets[2]
@cursor.y = 200 + @offsets[1] + @offsets[3]
end
def bag_open
@animation_pictures = []
case @index[3]
when -1
@animation_pictures[0] = Sprite.new
@animation_pictures[0].bitmap = RPG::Cache.picture("Pengoku_BagBack")
@animation_pictures[0].x = @offsets[0]
@animation_pictures[0].y = @offsets[1]
@animation_pictures[0].z = @offsets[4] + 5
@animation_pictures[1] = Sprite.new
@animation_pictures[1].z = @offsets[4] + 30
@animation_pictures[1].bitmap = RPG::Cache.picture("Pengoku_BagFrontTop")
@animation_pictures[1].ox = @animation_pictures[1].bitmap.width / 2
@animation_pictures[1].oy = @animation_pictures[1].bitmap.height
@animation_pictures[1].x = @offsets[0] + 16 + @animation_pictures[1].ox
@animation_pictures[1].y = @offsets[1] + 16 + @animation_pictures[1].oy
@animation_pictures[3] = Sprite.new
@animation_pictures[3].z = @offsets[4] + 30
@animation_pictures[3].bitmap = RPG::Cache.picture("Pengoku_BagFrontBottom")
@animation_pictures[3].ox = @animation_pictures[3].bitmap.width / 2
@animation_pictures[3].oy = @animation_pictures[3].bitmap.height
@animation_pictures[3].x = @offsets[0] + 16 + @animation_pictures[3].ox
@animation_pictures[3].y = @offsets[1] + 367 + @animation_pictures[3].oy
@animation_pictures[2] = Sprite.new
@animation_pictures[2].bitmap = RPG::Cache.picture("Pengoku_BagFlap")
@animation_pictures[2].ox = @animation_pictures[2].bitmap.width / 2
@animation_pictures[2].oy = 32
@animation_pictures[2].x = @offsets[0] + @animation_pictures[2].ox
@animation_pictures[2].y = @offsets[1] + @animation_pictures[2].oy
@animation_pictures[2].z = @offsets[4] + 31
@animation_pictures[4] = Sprite.new
@animation_pictures[4].bitmap = RPG::Cache.picture("Pengoku_BagBack2")
@animation_pictures[4].ox = @animation_pictures[4].bitmap.width / 2
@animation_pictures[4].x = @offsets[0] - 32 + @animation_pictures[4].ox
@animation_pictures[4].y = @offsets[1] - 16
@animation_pictures[4].z = @offsets[4] + 3
@animation_pictures[0].y += 480
@animation_pictures[1].y += 480
@animation_pictures[2].y += 480
@animation_pictures[3].y += 480
@animation_pictures[4].y += 480
frame = 0
loop do
Graphics.update
for sprite in @animation_pictures
sprite.y -= 24
end
frame += 1
break if frame == 20
end
refresh_contents(0)
refresh_bag(0)
refresh_squares(0)
frame = 0
loop do
Graphics.update
frame += 1
if @animation_pictures[1].zoom_y == 0.0
@animation_pictures[3].zoom_y = [@animation_pictures[3].zoom_y -= 0.15, 0.0].max
@animation_pictures[3].zoom_x = [@animation_pictures[3].zoom_x -= 0.15, 0.0].max
else
@animation_pictures[1].zoom_y = [@animation_pictures[1].zoom_y -= 0.03, 0.0].max
end
@animation_pictures[2].zoom_y = [@animation_pictures[2].zoom_y -= 0.1, 0.0].max
@animation_pictures[4].y -= 1 if frame <= 32
break if @animation_pictures[3].zoom_y <= 0.0
end
refresh_contents(1)
refresh_bag(1)
refresh_squares(1)
update_info_text
end
end
def bag_close
case @index[3]
when -1
@info_window.dispose
fly_cursor_off
@cursor.dispose
frame = 0
loop do
frame += 1
Graphics.update
if @animation_pictures[3].zoom_y < 1.0
@animation_pictures[3].zoom_x = [@animation_pictures[3].zoom_x + 0.15, 1.0].min
@animation_pictures[3].zoom_y = [@animation_pictures[3].zoom_y + 0.15, 1.0].min
else
@animation_pictures[1].zoom_y = [@animation_pictures[1].zoom_y + 0.03, 1.0].min
end
@animation_pictures[2].zoom_y = [@animation_pictures[2].zoom_y + 0.1, 1.0].min if frame >= 20
@animation_pictures[4].y += 1 if frame <= 32
break if frame == 41
end
for item in @bag_contents
item.dispose unless item.nil?
end
@grabbed_item.dispose
@bag_grid.dispose
frame = 0
loop do
Graphics.update
for picture in @animation_pictures
picture.y += 48
end
frame += 1
break if frame > 20
end
end
end
def refresh_contents(target_bag)
if target_bag == 0
contents = @bag_contents
bag = @itembag
page = @index[2]
elsif target_bag == 1
contents = @temp_contents
bag = @tempstorage
page = nil
end
for item in contents
item.dispose unless item.nil?
end
contents.clear
for item in bag.items
if (page != nil) and (item[2] != page)
contents.push(nil)
next
end
pic = Sprite.new
pic.bitmap = RPG::Cache.picture(bag.get_item_data(item[3]).gridpicture)
pic.ox = 16
pic.oy = 16
pic.z = @offsets[4] + 21
contents.push(pic)
end
end
def set_grabbed
if @grab_offset[8] != nil
if @phase[1] == 0
contents = @bag_contents
elsif @phase[1] == 1
contents = @temp_contents
end
@grabbed_item.bitmap = contents[@grabbed[0]].bitmap
@grabbed_item.ox = 16
@grabbed_item.oy = 16
@grabbed_item.angle = contents[@grabbed[0]].angle
@grabbed_item.mirror = contents[@grabbed[0]].mirror
@grabbed_item.x = contents[@grabbed[0]].x
@grabbed_item.y = contents[@grabbed[0]].y
@grabbed_item.opacity = 255
else
@grabbed_item.opacity = 0
end
end
def refresh_grabbed(rotate = 0)
if @grab_offset[8] != nil
if @grabbed_item.angle != (90 * @grab_offset[7][1][0])
@grabbed_item.angle = (90 * @grab_offset[7][1][0])
if rotate == 1
temp = @grab_offset[4]
@grab_offset[4] = @grab_offset[5]
@grab_offset[5] = -temp
else
temp = @grab_offset[4]
@grab_offset[4] = -@grab_offset[5]
@grab_offset[5] = temp
end
end
@grabbed_item.mirror = @grab_offset[7][1][1]
end
end
def update_info_text
@info_window.set_item(get_cursor_object(2), get_cursor_object(1))
end
def update
super
if Input.repeat?(Input::RIGHT)
if @phase[1] == 0
@index[0] += 1
if @index[0] == @itembag.columns
@phase[1] = 1
@index[0] -= 1
end
elsif @phase[1] == 1
@tempindex[0] = [@tempindex[0] + 1, @tempstorage.columns - 1].min
end
update_info_text
end
if Input.repeat?(Input::LEFT)
if @phase[1] == 0
@index[0] = [@index[0] - 1, 0].max
elsif @phase[1] == 1
@tempindex[0] -= 1
if @tempindex[0] < 0
@tempindex[0] = 0
@phase[1] = 0
end
end
update_info_text
end
if Input.repeat?(Input::UP)
@index[1] = [@index[1] - 1, 0].max
@tempindex[1] = @index[1]
update_info_text
end
if Input.repeat?(Input::DOWN)
@index[1] = [@index[1] + 1, @itembag.rows - 1].min
@tempindex[1] = @index[1]
update_info_text
end
if Input.trigger?(Input::X)
if @phase[0] == 1
$game_system.se_play($data_system.cursor_se)
@grab_offset[7][1][0] += 1
@grab_offset[7][1][0] %= 4
refresh_grabbed(1)
end
end
if Input.trigger?(Input::Y)
if @phase[0] == 1
$game_system.se_play($data_system.cursor_se)
@grab_offset[7][1][0] -= 1
@grab_offset[7][1][0] %= 4
refresh_grabbed
end
end
if Input.trigger?(Input::Z)
if @phase[0] == 1
$game_system.se_play($data_system.cursor_se)
@grab_offset[7][1][1] = !@grab_offset[7][1][1]
@grab_offset[7][0] = !@grab_offset[7][0]
refresh_grabbed
end
end
if Input.trigger?(Input::L)
@index[2] -= 1
@index[2] %= @itembag.pages
refresh_contents(0)
refresh_bag(0)
refresh_squares(0)
update_info_text
update_page
end
if Input.trigger?(Input::R)
@index[2] += 1
@index[2] %= @itembag.pages
refresh_contents(0)
refresh_bag(0)
refresh_squares(0)
update_info_text
update_page
end
if Input.trigger?(Input::A)
#@info_window.set_item(1)
end
update_cursor
if @grab_offset[8] != nil
@grabbed_item.x = @cursor.x - (@grab_offset[4])
@grabbed_item.y = @cursor.y - (@grab_offset[5])
end
end
def update_cursor
x_off = @grab_offset[0]
y_off = @grab_offset[1]
if @grabbed[0] != nil
x_off = @grab_offset[2]
y_off = @grab_offset[3]
end
x_off += @offsets[0] + @offsets[2]
y_off += @offsets[1] + @offsets[3]
index_x = @index[0]
index_y = @index[1]
index_ax = @index[0]
index_ay = @index[1]
if @phase[1] == 1
x_off += @offsets[5]
y_off += @offsets[6]
index_x = @tempindex[0]
index_y = @tempindex[1]
end
index_c = @itembag.columns
index_r = @itembag.rows
if @cursor.x < x_off + (32 * index_x)
@cursor.x += [((x_off + (32 * index_x)) - @cursor.x) / 3, 1].max
elsif @cursor.x > x_off + (32 * index_x)
@cursor.x += [((x_off + (32 * index_x)) - @cursor.x) / 3, -1].min
end
if @cursor.y < y_off + (32 * index_y)
@cursor.y += [((y_off + (32 * index_y)) - @cursor.y) / 3, 1].max
elsif @cursor.y > y_off + (32 * index_y)
@cursor.y += [((y_off + (32 * index_y)) - @cursor.y) / 3, -1].min
end
angle = 135 - (((90 / (index_c - 1)) * index_ax) * (index_ay >= index_r / 2 ? -1 : 1))
angle -= ((90 / (index_r - 1)) * index_ay * (index_ax >= index_c / 2 ? 1 : -1))
angle -= 180 if ((index_ax >= index_c / 2) and (index_ay >= index_r / 2))
angle %= 360
@cursor.angle %= 360
if @cursor.angle.to_i != angle.to_i
angle_inc = (angle - @cursor.angle)
if angle_inc > 180
angle_inc -= 360
elsif angle_inc < -180
angle_inc += 360
end
if angle_inc < 0
@cursor.angle += [angle_inc / 4, -1].min
elsif angle_inc > 0
@cursor.angle += [angle_inc / 4, 1].max
end
end
update_info_offset(angle)
update_page
end
def can_dispose?
return @tempstorage.items.empty?
end
def dispose_warning
$game_system.se_play($data_system.buzzer_se)
end
def refresh_bag(target_bag)
count = -1
x_off = @grab_offset[0] + @offsets[0] + @offsets[2]
y_off = @grab_offset[1] + @offsets[1] + @offsets[3]
if target_bag == 0
bag = @itembag
contents = @bag_contents
page = @index[2]
elsif target_bag == 1
bag = @tempstorage
contents = @temp_contents
x_off += @offsets[5]
y_off += @offsets[6]
page = nil
end
for item in bag.items
count += 1
next if (page != nil) and (item[2] != page)
contents[count].x = x_off + (32 * item[0][0])
contents[count].y = y_off + (32 * item[0][1])
if item[1][0] == 1
contents[count].y += 32 * item[0][2][0]
elsif item[1][0] == 2
contents[count].x += 32 * item[0][2][0]
contents[count].y += 32 * item[0][2][1]
elsif item[1][0] == 3
contents[count].x += 32 * item[0][2][1]
end
contents[count].angle = (90 * item[1][0])
contents[count].mirror = item[1][1]
end
end
def refresh_squares(target_grid)
if target_grid == 0
grid = @bag_grid
bitmap = RPG::Cache.picture("10x10ItemGrid")
bag = @itembag
page = @index[2]
elsif target_grid == 1
grid = @temp_grid
bitmap = RPG::Cache.picture("4x10gridtemp")
bag = @tempstorage
page = 0
end
grid.bitmap.clear
if @toggle[0]
grid.bitmap.blt(0, 0, bitmap, Rect.new(0,0,bitmap.width, bitmap.height))
end
return unless @toggle[1]
x_inc = -1
for x in bag.grid[page]
x_inc += 1
y_inc = -1
for y in x
y_inc += 1
next if y == nil
case bag.items[y[0]][3][0]
when 0
bitmap = RPG::Cache.picture("Grid_Item")
when 1
bitmap = RPG::Cache.picture("Grid_Weapon")
when 2
bitmap = RPG::Cache.picture("Grid_Armor")
end
grid.bitmap.blt(32 * x_inc, 32 * y_inc, bitmap, Rect.new(0,0,32,32))
end
end
end
def update_c
if @phase[0] == 0
grab_item
update_info_text
elsif @phase[0] == 1
place_item
update_info_text
end
end
def update_b
if @phase[0] == 1
cancel_placement
update_info_text
end
end
def update_page
@page.bitmap.clear
@page.bitmap.draw_outline_text(0,0,120,32,(@index[2]+1).to_s + "/" + @itembag.pages.to_s)
end
def grab_item
need_refresh = -1
return if get_cursor_object == nil
if @phase[1] == 0
$game_system.se_play($data_system.decision_se)
@grabbed = [get_cursor_object(0), 0]
@phase[0] = 1
@grab_offset[4] = ((@index[0] * 32) - (@bag_contents[@grabbed[0]].x - 16 - (@offsets[0] + @offsets[2])))
@grab_offset[5] = ((@index[1] * 32) - (@bag_contents[@grabbed[0]].y - 16 - (@offsets[1] + @offsets[3])))
@grab_offset[6] = @itembag.grid[@index[2]][@index[0]][@index[1]][1]
@grab_offset[7] = [false, @itembag.items[@grabbed[0]][1].dup]
@grab_offset[8] = @itembag.items[@grabbed[0]]
@itembag.items.delete_at(@grabbed[0])
@itembag.items.compact!
@itembag.refresh_grid
need_refresh = 0
elsif @phase[1] == 1
$game_system.se_play($data_system.decision_se)
@grabbed = [get_cursor_object(0), 1]
@phase[0] = 1
@grab_offset[4] = (((@tempindex[0] * 32) + @offsets[5]) - (@temp_contents[@grabbed[0]].x - 16 - (@offsets[0] + @offsets[2])))
@grab_offset[5] = (((@tempindex[1] * 32) + @offsets[6]) - (@temp_contents[@grabbed[0]].y - 16 - (@offsets[1] + @offsets[3])))
@grab_offset[6] = @tempstorage.grid[0][@tempindex[0]][@tempindex[1]][1]
@grab_offset[7] = [false, @tempstorage.items[@grabbed[0]][1].dup]
@grab_offset[8] = @tempstorage.items[@grabbed[0]]
@tempstorage.items.delete_at(@grabbed[0])
@tempstorage.items.compact!
@tempstorage.refresh_grid
need_refresh = 1
end
if need_refresh != -1
set_grabbed
refresh_grabbed
refresh_contents(need_refresh)
refresh_bag(need_refresh)
refresh_squares(need_refresh)
end
end
def get_cursor_object(mode = 0)
val = nil
if @phase[0] == 1
if @toggle[2]
if mode == 0
val = @grabbed[0]
elsif mode == 1
val = @itembag.get_item_data(@grab_offset[8][3])
elsif mode == 2
val = @grab_offset[8][3]
end
end
else
if @phase[1] == 0
ind = @itembag.grid[@index[2]][@index[0]][@index[1]]
if ind != nil
if mode == 0
val = ind[0]
elsif mode == 1
val = @itembag.get_item_data(@itembag.items[ind[0]][3])
elsif mode == 2
val = @itembag.items[ind[0]][3]
end
end
elsif @phase[1] == 1
ind = @tempstorage.grid[0][@tempindex[0]][@tempindex[1]]
if ind != nil
if mode == 0
val = ind[0]
elsif mode == 1
val = @tempstorage.get_item_data(@tempstorage.items[ind[0]][3])
elsif mode == 2
val = @tempstorage.items[ind[0]][3]
end
end
end
end
return val
end
def cancel_placement
$game_system.se_play($data_system.cancel_se)
if @grabbed[1] == 0
@itembag.items.push(@grab_offset[8])
@itembag.refresh_grid
need_refresh = 0
elsif @grabbed[1] == 1
@tempstorage.items.push(@grab_offset[8])
@tempstorage.refresh_grid
need_refresh = 1
end
@grabbed.clear
@grab_offset[8] = nil
set_grabbed
refresh_contents(need_refresh)
refresh_bag(need_refresh)
refresh_squares(need_refresh)
@phase[0] = 0
end
def place_item
off_x = @grab_offset[6][0]
off_x = -@grab_offset[6][0] + @grab_offset[8][0][2][0] if @grab_offset[7][1][1]
off_y = @grab_offset[6][1]
if @grab_offset[7][1][0] == 1
off_x = @grab_offset[6][1]
if @grab_offset[7][1][1]
off_y = @grab_offset[6][0]
else
off_y = -@grab_offset[6][0] + @grab_offset[8][0][2][0]
end
elsif @grab_offset[7][1][0] == 2
if @grab_offset[7][1][1]
off_x = @grab_offset[6][0]
else
off_x = -@grab_offset[6][0] + @grab_offset[8][0][2][0]
end
off_y = -@grab_offset[6][1] + @grab_offset[8][0][2][1]
elsif @grab_offset[7][1][0] == 3
off_x = -@grab_offset[6][1] + @grab_offset[8][0][2][1]
if @grab_offset[7][1][1]
off_y = -@grab_offset[6][0] + @grab_offset[8][2][0]
else
off_y = @grab_offset[6][0]
end
end
if @grab_offset[7][0]
if @grab_offset[7][1][0] == 0 or @grab_offset[7][1][0] == 2
if off_x != (@grab_offset[8][0][2][0] / 2)
off_x = (off_x - @grab_offset[8][0][2][0]).abs
end
elsif @grab_offset[7][1][0] == 1 or @grab_offset[7][1][0] == 3
if off_y != (@grab_offset[8][0][2][0] / 2)
off_y = (off_y - @grab_offset[8][0][2][0]).abs
end
end
end
if @phase[1] == 0
newpos = [@index[0] - off_x, @index[1] - off_y, @grab_offset[7][1].dup, @grab_offset[8][3].dup]
unless @itembag.grid_open?(newpos, @index[2])
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@grab_offset[8][2] = @index[2]
@grab_offset[8][0][0] = newpos[0]
@grab_offset[8][0][1] = newpos[1]
@grab_offset[8][1] = @grab_offset[7][1].dup
@itembag.items.push(@grab_offset[8])
@itembag.refresh_grid
need_refresh = 0
elsif @phase[1] == 1
newpos = [@tempindex[0] - off_x, @tempindex[1] - off_y, @grab_offset[7][1].dup, @grab_offset[8][3].dup]
unless @tempstorage.grid_open?(newpos, 0)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@grab_offset[8][2] = 0
@grab_offset[8][0][0] = newpos[0]
@grab_offset[8][0][1] = newpos[1]
@grab_offset[8][1] = @grab_offset[7][1].dup
@tempstorage.items.push(@grab_offset[8])
@tempstorage.refresh_grid
need_refresh = 1
end
@grab_offset[8] = nil
@grabbed.clear
set_grabbed
refresh_contents(need_refresh)
refresh_bag(need_refresh)
refresh_squares(need_refresh)
@phase[0] = 0
end
def dispose
bag_close
@bag_contents.clear
@temp_contents.clear
@temp_grid.dispose
@page.dispose
for sprite in @animation_pictures
sprite.dispose
end
super
end
def update_info_offset(angle = nil)
inc_x = Math.cos(@cursor.angle / (180 / Math::PI)) * 75
inc_y = Math.sin(@cursor.angle / (180 / Math::PI)) * 75
inc_x *= -1
angle = @cursor.angle if angle == nil
case (angle.to_i / 90)
when 0
inc_x -= @info_window.width
inc_x -= [(@cursor.x.to_i + inc_x.to_i), 0].min
inc_y -= [(@cursor.y.to_i + inc_y.to_i + @info_window.height) - 480, 0].max
@info_window.flipped = true
when 1
inc_x -= [(@cursor.x.to_i + inc_x.to_i + @info_window.width) - 640, 0].max
inc_y -= [(@cursor.y.to_i + inc_y.to_i + @info_window.height) - 480, 0].max
@info_window.flipped = false
when 2
inc_x -= [(@cursor.x.to_i + inc_x.to_i + @info_window.width) - 640, 0].max
inc_y -= @info_window.height
inc_y -= [(@cursor.y.to_i + inc_y.to_i), 0].min
@info_window.flipped = false
else
inc_x -= @info_window.width
inc_y -= @info_window.height
inc_x -= [(@cursor.x.to_i + inc_x.to_i), 0].min
inc_y -= [(@cursor.y.to_i + inc_y.to_i), 0].min
@info_window.flipped = true
end
@info_window.x = @cursor.x + inc_x
@info_window.y = @cursor.y + inc_y
@info_window.z = @cursor.z - 1
end
def fly_cursor_off(dist = nil)
move_dist = 60
move_dist = dist if dist != nil
inc_x = Math.cos(@cursor.angle / (180 / Math::PI)) * move_dist
inc_y = Math.sin(@cursor.angle / (180 / Math::PI)) * move_dist
inc_x *= -1
until (@cursor.x > 640) or (@cursor.x < 0) or (@cursor.y > 480) or (@cursor.y < 0)
Graphics.update
@cursor.x += inc_x
@cursor.y += inc_y
end
end
end
class Item_Bag
attr_accessor :items
attr_accessor :grid
attr_accessor :rows
attr_accessor :columns
attr_accessor :background
attr_accessor :pages
def initialize(columns = 10, rows = 10, pages = 2)
@items = []
@background = [32,32]
@pages = pages
@rows = rows
@columns = columns
reset_grid
end
def reset_grid
@grid = []
i = 0
pages.times do
@grid.push([])
columns.times do
@grid[i].push([])
end
i += 1
end
end
def refresh_grid
index = 0
reset_grid
for data in @items
item = get_item_data(data[3])
data[0][2] = item.dimensions
for area in item.gridcoords
x_plus = area[0]
x_plus = -area[0] + data[0][2][0] if data[1][1]
y_plus = area[1]
if data[1][0] == 1
x_plus = area[1]
if data[1][1]
y_plus = area[0]
else
y_plus = -area[0] + data[0][2][0]
end
elsif data[1][0] == 2
if data[1][1]
x_plus = area[0]
else
x_plus = -area[0] + data[0][2][0]
end
y_plus = -area[1] + data[0][2][1]
elsif data[1][0] == 3
x_plus = -area[1] + data[0][2][1]
if data[1][1]
y_plus = -area[0] + data[0][2][0]
else
y_plus = area[0]
end
end
@grid[data[2]][data[0][0] + x_plus][data[0][1] + y_plus] = [index, area]
end
index += 1
end
end
def grid_open?(data, page)
item = get_item_data(data[3])
for area in item.gridcoords
x_plus = area[0]
x_plus = -area[0] + item.dimensions[0] if data[2][1]
y_plus = area[1]
if data[2][0] == 1
x_plus = area[1]
if data[2][1]
y_plus = area[0]
else
y_plus = -area[0] + item.dimensions[0]
end
elsif data[2][0] == 2
if data[2][1]
x_plus = area[0]
else
x_plus = -area[0] + item.dimensions[0]
end
y_plus = -area[1] + item.dimensions[1]
elsif data[2][0] == 3
x_plus = -area[1] + item.dimensions[1]
if data[2][1]
y_plus = -area[0] + item.dimensions[0]
else
y_plus = area[0]
end
end
if data[0] + x_plus >= @columns or data[0] + x_plus < 0
return false
end
if data[1] + y_plus >= @rows or data[1] + y_plus < 0
return false
end
if @grid[page][data[0] + x_plus][data[1] + y_plus] != nil
return false
end
end
return true
end
def real_x(id)
x_plus = 0
x_plus = @items[id][0][2] if @items[id][1][1]
if @items[id][1][0] == 2
x_plus = @items[id][0][2]
elsif @items[id][1][0] == 3
x_plus = @items[id][0][3]
end
return x_plus
end
def real_y(id)
y_plus = 0
if @items[id][1][0] == 1
y_plus = @items[id][0][2]
elsif @items[id][1][0] == 2
y_plus = @items[id][0][3]
elsif @items[id][1][0] == 3
y_plus = @items[id][0][2]
end
return y_plus
end
def get_item_data(item)
case item[0]
when 0
return $data_items[item[1]]
when 1
return $data_weapons[item[1]]
when 2
return $data_armors[item[1]]
end
end
end
I don't even know how I'm going to work out adding items into the thing. I don't feel like coding a method to find open spots for items, so I'll probably just make the player manually stick stuff in it themselves.
I'm currently working on the new quest log.
I have run into a slight problem.
Problem: Can't code the layout very well without having the background sprited. Can't sprite the background very well until I know how the layout will fit.
With a window, it can be most any shape.
But did I make it a window? Noooo. I had to go and make it a book, so now it has to have proportions that
A) look normal for a book
B) Aren't too small
C) have room for a list on the side
The end result is that the code for quests is not going to be autoformatted, it's going to have to be manually set up similar to how the info window for items works.
Which looks like this:
Code:
$data_weapons[2].info = [[0,[220,120]],[1,[0,0,0], $data_weapons[2].name],[1,[0,0,2], "(1H Katana)"],[3,[0,26], "basedmg"],[1,[16,20,0], $data_weapons[2].basedmg.to_s],[3,[58,26], "magdmg"],[1,[74,20,0], $data_weapons[2].matk.to_s],[3,[116,26], "delay"],[1,[132,20,0], $data_weapons[2].delay.to_s],[1,[0,38,0], "STR+10 DEX+5 AGI+10"],[4,[63,1]],[1,[0,57,0], "A katana that has been passed",17],[1,[0,72,0], "down through Pengoku's family",17],[1,[0,87,0], "for generations.",17]]
All it can currently do is list the quest lists. Quests will (eventually) be sorted by location.
After I make the cursor. And page-turning. And graphics. And method for drawing the data for it. And make the list on the right for the quests themselves.
Also tested out fotz's pixelmovement's built-in waypoint generator for pathfinding.
IT IS BOLLOCKS.
I get to do them by hand, yay!
Luckily, this won't be needed for a good while, so I can put in on hold for a looong time.
Lastly:
Flooded my damn fort again. :|