Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
theoryoferin

Pokemon-like Badge System Crashing Game

Question

Alright, I've been testing and poking at this all day. I'm giving up and asking for help now.

 

I've implemented this code into my game from the Scripts' Database onsite. I also created an item as a case for the 8 pendants that are a side quest in my game. After adding the images for the items and a common event to pull up the case on screen, everything works when you don't have any of the pendants.  

 

Once you obtain a pendant, it will still open, but then upon exiting the case, the game stops responding. I'm sure it's something simple that I'm missing, but help?

 

 

 

#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
# --------credits--------
# * Diagostimo for composing this script
# * Darkness for requesting it
#
# ------Author Notes------
# * this script shows badge images and details depending if they have been
# obtained or not
#
# * to call the script use this script call : "$scene = Scene_Badges.new"
#
# * to add badges to your possesion use this script call : "$game_system.badge_array.push(BADGE_ID)"
# or you can push multiple like so : "$game_system.badge_array.push(BADGE_ID, BADGE_ID, BADGE_ID)"
#
# * add the graphics of the badge to the pictures directory and call it "badge'BADGE_ID'"
# so for example I add badge 1 : "badge1.png"
#
# * if for any reason you need to remove a badge from your possesion you use
# this script call : "$game_system.badge_array.delete(BADGE_ID)"
#
# * if you want to have a conditional branch inside an event to condition to a
# badge been in possesion use this script call : "$game_system.badge_array.include?(BADGE_ID)"
#
# * see below for all other related configuration, note this script only supports
# 8 badges like pokemon games, adding more details/images for other values than
# specified will simply be ingnored, also note that badge images should be 32x32 sized images.
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
#                                                C O N F I G U R A T I O N                                                     
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
module Badges
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-#
# * set the image opacity for badges not in possession
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-#
NOT_POSSESSION_OPACITY = 100 #255 max, 0 min
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * configure the following descriptions for badges IN possession
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
def self.badge_in_possession(index)
case index
         when 1 then 'The Water Pendant'
         when 2 then 'The Pendant'
         when 3 then 'The Pendant'
         when 4 then 'The Pendant'
         when 5 then 'The Pendant'
         when 6 then 'The Pendant'
         when 7 then 'The Pendant'
         when 8 then 'The Pendant'
end
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# * configure the following descriptions for badges NOT in possession
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
def self.badge_not_in_possession(index)
case index
         when 1 then '???'
         when 2 then '???'
         when 3 then '???'
         when 4 then '???'
         when 5 then '???'
         when 6 then '???'
         when 7 then '???'
         when 8 then '???'
end
end
end
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
#
#                                        E N D C O N F I G U R A T I O N
#
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
class Bitmap
def format_text(text, width)
words = text.split(' ')
return words if words.size == 1
result, current_text = [], words.shift
words.each_index {|i|
         if self.text_size("#{current_text} #{words[i]}").width > width
                 result.push(current_text)
                 current_text = words[i]
         else
                 current_text = "#{current_text} #{words[i]}"
         end
         result.push(current_text) if i >= words.size - 1}
return result
end
end
class Game_System
attr_accessor :badge_array
alias init_init initialize
def initialize
init_init
@badge_array = []
end
end
class Window_Badges < Window_Base
attr_reader :index
def initialize
centre = (640 - 288) / 2
super(centre, 0, 288, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.index = 0
refresh
end
def index=(index)
@index = index
update_cursor_rect
end
def update_cursor_rect
x = 0 + @index * 32
y = 0
self.cursor_rect.set(x, y, 32, 32)
end
def refresh
self.contents.clear
for i in 1..8
         @bitmap = RPG::Cache.picture("badge#{i}")
         x = 0 + (i - 1) % 8 * 32
         rect = Rect.new(0, 0, @bitmap.width, @bitmap.height)
         if $game_system.badge_array.include?(i)
         self.contents.blt(x, 0, @bitmap, rect, 255)
         else
         self.contents.blt(x, 0, @bitmap, rect, Badges::NOT_POSSESSION_OPACITY)
         end
end
end
def update
super
if Input.repeat?(Input::RIGHT) && @index < 7
         @index += 1
         $game_system.se_play($data_system.cursor_se)
end
if Input.repeat?(Input::LEFT) && @index > 0
         @index -= 1
         $game_system.se_play($data_system.cursor_se)
end
update_cursor_rect
refresh
end
end
class Window_Badge_Description < Window_Base
attr_accessor :text
def initialize
@text = ''
super(0, 0, 288, 128)
self.contents = Bitmap.new( width - 32, height - 32)
end
def refresh
self.contents.clear
text = self.contents.format_text(@text, 256)
text.each_index {|i|
         self.contents.draw_text(0, 0 + i*32, 256, 32, text[i])}
end
def update
super
refresh
end
end
class Scene_Badges
def main
@badges_window = Window_Badges.new
@description_window = Window_Badge_Description.new
@badges_window.y = (480 - @description_window.height) - @badges_window.height
@description_window.y = @badges_window.y + @badges_window.height
@description_window.x = @badges_window.x
@sprite = Spriteset_Map.new
Graphics.transition
loop { Graphics.update; Input.update; update; break if $scene != self }
@badges_window.dispose
@description_window.dispose
end
def update
$scene = Scene_Map.new if Input.trigger?(Input::B)
if $game_system.badge_array.include?(@badges_window.index + 1)
         @description_window.text = Badges.badge_in_possession(@badges_window.index + 1)
else
         @description_window.text = Badges.badge_not_in_possession(@badges_window.index + 1)
end
@badges_window.update
@description_window.update
end
end

 

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

hey theoryoferin, thanks for reporting the bug, I looked into it and turns out I forgot something minor, I have changed the script in the database with the fix :)

Share this post


Link to post
Share on other sites
  • 0

Oh how 1 line of code can mess everything up lol

 

Thank Erin for letting us know it had issues, and Thanks Diagostimo for fixing it :D

 

I've looked at the script before and have been tempted to use it, but i'm unsure how at this point in my games development.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...