Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: Zexion on August 08, 2013, 08:17:47 pm

Title: Best way to do this? Treasure Chests
Post by: Zexion on August 08, 2013, 08:17:47 pm
I'm making the rest of the menu for my game, and I need every treasure chest the opens to be marked on the journal. Though there are easy ways to do this, I want to get it as close to the original as possible, but that would require tons of switches. Here's what I mean.
As the player journeys along the game, there will be chests spread across the worlds that they can open. These chests are then marked in the journal on a "per world" basis with the item received. Which is easy. The complex part, is that these chests must be marked in order, so I can't just use one variable per world and display the amount of chests unlocked. If they open a chest that is on the first map of the world, that will be marked "higher" than if they opened a chest on the last map of the world.
Title: Re: Best way to do this? Treasure Chests
Post by: KK20 on August 08, 2013, 08:34:18 pm
In treasure chest event:

found_treasure(world_id, chest_id)


In script

class Interpreter
  def found_treasure(world_id, chest_id)
    $game_party.found_treasures[world_id].push(chest_id)
    $game_party.found_treasures[world_id].sort!
  end
end
class Game_Party
  attr_accessor :found_treasures
 
  alias init_treasures initialize
  def initialize
    init_treasures
    @found_treasures = [[],[],[]] # represents 3 worlds
  end
end

### Drawing method in your menu
def draw_chests
  # Clear your bitmap first
  $game_party.found_treasures[world_id].each{|chest_id|
    bitmap.blt((chest_id%5) * 32, (chest_id/5) * 32, 32, 32, 'open_chest_gif'-bitmap) # basically something like that
  }
  # whatever else you want
end

Of course I have no idea what it's supposed to look like. (._ . )