Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Ninja Penguin

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.
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 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:
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]]
Progress so far:
2lsuwoz.png

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. :|
15wb98n.png
 
Sooooooo hows the game going? Hope you haven't given up on this game and it looks funny. I have an idea that might be a pain in the arse but hey here goes: Perhaps certain items could react differently when they are in the correct position to one another. ie If a potion were to be turned upside down above a potion that was right side up underneath so that the openings were next to each-other then the two potions could mix to form a better potion as the potion on top would lose the cork and spill. So in the end you would end up with a better potion and an empty bottle. To help it should look like this:
p- potion 1 upside down
b- potion 2 right side up. Confusing probably but hey if it woks it works.
 
Darth J":26tns3ym said:
Sooooooo hows the game going? Hope you haven't given up on this game and it looks funny. I have an idea that might be a pain in the arse but hey here goes: Perhaps certain items could react differently when they are in the correct position to one another. ie If a potion were to be turned upside down above a potion that was right side up underneath so that the openings were next to each-other then the two potions could mix to form a better potion as the potion on top would lose the cork and spill. So in the end you would end up with a better potion and an empty bottle. To help it should look like this:
p- potion 1 upside down
b- potion 2 right side up. Confusing probably but hey if it woks it works.

I think making it more complicated is the last thing Jaberwocky wants.
 
Or I could maybe just use the crafting menu.
Also isn't the point of putting a cork in the bottle to keep it from spilling out? >.>


ANYWAYS

BAM
fk8gtl.png

Things you can see in this screenshot:
- Visual equipment
- Multiple attacks

Things you can't see:
- Weather over actors/under windows
- Fixed Z values
- Fixed viewports
- Fixed damage pops
- Fixed attack speeds
- Global $spriteset for smoother transitions between scenes

I need to go sprite some shields so I can dual-wield them.


Redesigned the equipment menu:
w00xdv.png

It's now part of the main menu, like the inventory/quest log are.
I think I made the silhouette too small.
I also have no idea where I'm going to put the item info or any of that junk.


Finished stackable item movement and handling and all that junk:
10h2l1k.png

Also added toggles for the info windows, grid, and colored squares.
Also finally gave each character their own inventory. Still need to make the seperate graphics, though.

Other stuff finished:
- Pengoku walks faster, flipping out of caterpillar sprites reduced
- Running from battles works again
- Quest log, obviously
- Fixed text spacing in message windows:
1e6rmp.png



Things to do:
- Take a nap
 
I wasn't too impressed by this game when I first saw it - personal bias against the lolsorandom^_^ness of ninja-penguins, but now this is looking really good and my past prejudices are washed away like last night's cider ~

This looks great man, hope you finish it some time.
 
2agm7uo.png

Equipment menu completed. Now works properly with equipment that uses multiple slots (i.e. 2handed weapons), and properly marks the equipment in the item bag as being equipped. It was complete dick to get it working correctly >_>;
(Don't ask me how that works because I don't have a damn clue)

NOW YOU CAN FINALLY FULFILL THAT RETARDED DREAM OF BEING ABLE TO DUAL-WIELD SHIELDS

Other stuff:
Moved magic orbs to their own menu, changed named to 'Aether', changed number from two to three. This should prevent a majority of the stupid remarks. Also recoded the way the cursors move so they move to the closest object in the direction you press, rather than the object with the smallest x/y difference. Basically what this means is it checks both the x and y values, instead of just one or the other, so the cursor moves in a much more predictable manner and is easier to use. Or something like that.

All that's left is...
Status menu, item bag sub-menu, skill menu, and the aether menu.
After that, the new main menu is completed. Mostly.
Except the graphics. And the movement of the characters (which will have to wait til I'm done respriting them).
Actually I don't even know what I'd put in the status menu since you can kinda already see all the stats and everything that isn't hidden right there...
 
Battle system is finally coming together.
http://www.youtube.com/watch?v=VodABU3-0Dk
Three working skills!
...Zero working items, though.
Actually I don't think you can even open the item menu in battle without it crashing >_>;

Finally got the state resistances working now, though. The duration, effect, and tick speed can all change depending on how much it gets resisted.
Or so I assume. I suppose I should go make a skill that adds a state and test the thing.
 
hey this is
shaping up to become pretty nice
looks like you're really determined to make this into a full fledged game
keep up the good work!

also
Jaberwoky":o4hulteh said:
NOW YOU CAN FINALLY FULFILL THAT RETARDED DREAM OF BEING ABLE TO DUAL-WIELD SHIELDS
ahahaha fuck yeah
 
Since I don't know what PS 2 is referring to, I'm going to go with 'no' o_o

Anyways...
State resistances/handling/etc. is working, and I finished converting the staff animations for Mitzy.
Also fixed a small bug with the soft caps on skills where it would increase the power over the soft cap by 2500% instead of cutting it to 25%... so you'd throw out cures for 3900 instead of 150 >_>; oops.
 
OK, so, I made demo... thing... Mostly so I could bother a few friends into debugging what's done so far.
Anyways, most everything that's done is working, so I figured I'd post it here as a sort of tech demo or something:
http://www.mediafire.com/?jwfgnegd4nn
The various Mitzy clones strewn about give you items you can use for messing around with the item grid system.
The big crate starts a battle. Note that the battle system is unfinished, so you cannot end the battle at all. You can't select the escape option, and winning will cause a crash.
A good chunk of the base systems are finished and working. Passive skills and equipment skills are working, but the menu options for them are not. The in-battle menus for skills and items work, but need to be redesigned.

Anyways, controls:
Item Menu: Q(L) = Page up, W(R) = Page down, A(X) = Toggle grid/Rotate item counterclockwise, S(Y) = Toggle grid coloring/Rotate item clockwise, D(Z) = Toggle info window/Flip item, Z(A) = Open option menu for grabbed item
Equip Menu: Z(A) = Hold to view info for selected item
Aether Menu: Z(A) = Hold to view info for selected rune

I think that's everything. If you decide to try it out, let me know of any bugs you find.
The ones I already know about are:
- Mitzy has no evade graphic, so it blanks the sprite out, which can cause enemies to run to the wrong spot to attack her. Similarly, the enemies have no evade graphics, so the same can happen with them.
- Pengoku has no casting or skill use animation
- The beatrice has no graphics, glostick only has graphics for the right hand since it's a test weapon
- Glostick has no info data
- Equipment is completely unrestricted, but the graphics are unfinished. Only Mitzy has graphics for the staff and mantle, and only Pengoku has graphics for the tantos and glostick. Also note that Pengoku has no graphics for single-wielding yet.

Mostly I just need the item grid tested a bit. Are the items being flipped/rotated/displayed/placed properly? Is the quantity and stacking working? Is the option menu displaying and working correctly?
etc.
 
Did some more work on the battle system. Still working on getting it to cancel actions properly if all the targets die and such.
There is a bug somewhere in the battle system. I have no idea what causes it and have been unable to reproduce it. One of the battlers just... sorta froze up when they would have been running back after attacking. The target cursor would be at 0,0 in the upper left corner when they're targeted, and when trying to attack them it crashes saying that 'is_target' is not a method for arrays... Some somewhere somehow, the battler is being replaced with an array for some reason...

Anyways, here's a demo:
http://www.mediafire.com/?dzscz7fx7ac6o04

In this demo there is a 'log.txt' file that records everything that happens during battle.
If you try the demo and get it to crash during battle, send me the log file so I can figure out what the hell is going on. o_o/
 
OK so if I had been awake enough to test the logging system I would have figured this out, BUT
size is a method of the File class, not a method of files opened with it. Whoops.

So, there's a sliiiight bug wherein it will crash as soon as a battle starts :D
Whoops.
Anyways, the 8 of you who decided to try it will have to redownload it:
http://www.mediafire.com/?d19kv5undocnn2q

I am just going to leave a battle running overnight and hope the error pops up while I'm asleep.
 
Well, I'm about halfway done with the base systems, so it shouldn't be too long until I can start on the actual gameplay and stuff. Depends on how many kinks there are to work out and how fast I can sprite most of the stuff, really.

There's really not a huge amount of stuff left to finish coding:
Skill/Ability menu, save/load, some pixel movement junk, finishing up the battle system, and a bit of tweaking to the message system and menu... that's pretty much it.

Also, did not get the error from running the battle all night, so it has something to do with selecting targets or something or other I don't know. Bleh.
 
Jaberwoky":2ndhq427 said:
Also, did not get the error from running the battle all night, so it has something to do with selecting targets or something or other I don't know. Bleh.

Or maybe just a theory but it might not just be selecting targets maybe selecting spells caused it?
 
Gah, RMXP's compressor is ignoring the empty folders ._.

Make a folder named 'Pixelmovement Data' in the game folder, then make two folders named 'Tables' and 'Waypoints' inside of it, and it should work.

I'm going to go remove whatever is trying to load that stuff...

Edit -
Alright, done. This one should work... Probably.
http://www.mediafire.com/?d19kv5undocnn2q

If you already downloaded it, you can just throw the new Scripts.rxdata into the Data folder (probably?):
http://www.mediafire.com/?kmleog8s4ugoio6
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top