Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Treasure Hunt
#1
Treasure Hunt
by Jimmie
Apr 11 2006

This is a locked, single-post thread from Creation Asylum.  Archived here to prevent its loss.
No support is given.  If you are the owner of the thread, please contact administration.


Ok. First of all, this is not like the pokémon item finder.


What it does is show a transparent window in the lower left (160*96 px) and draws two graphs in it. The closer you are, the closer to each other the two graphs are. When you're on the spot, the graphs are swapped for a note. Don't ask why. You can easily replace the image.

It also plays a sound whenever you're close enough. This can be removed around line 80. Remove these lines:

Code:
   if @playing != @distance
       Audio.se_play("Audio/SE/" + '014-Move02', 60-(@distance*5)**0.5, 100)
       @playing = @distance
     end
   else
     @playing = @distance


When installed and activated, it should look like this when a 'source' is nearby:
[Image: treasurehunt.png]

The window is empty if there is no source. Text and windowskin are both easily changed.

Insert the script in a new slot above main and below the SDK
You need a picture called 'note' in your pictures folder. It's automatically centered in the window, so don't worry.


That said, howdo you use it?
Easy. Make an event, and insert two comments. One should be
resonance

and the next should be the range. This isn't always exact tiles, so experiment.

Example:
Comment: resonance
Comment: 8



Now, 8 is a very large range, 3 or 4 are good numbers for this, but like I said, experiment.

Good luck, have fun [Image: tongue.gif]


CODE
Code:
#Treasure hunt/resonance by Jimme Reashu
#SDK is required.
#Last updated 13 of April 2006
#Fixed a few bugs
#Made the window dissapear if there are no resonating events
#Requested by Anaxim

SDK.log('Treasure Hunt', 'Jimme Reashu', 1, '11-04-06')

if SDK.state('Treasure Hunt')
 
#--------------------------------------------------------------------------
class Window_Graph < Window_Base
 attr_reader :act
#--------------------------------------------------------------------------
 def initialize
   super(480,384,160,96)
   @act = false
   self.contents = Bitmap.new(width-32, height-32)
   self.opacity = 124
   self.windowskin = RPG::Cache.windowskin('001-Blue01')
   @amplitude = 0.1
   @repeat = 30
   @color = Color.new(255,70,0,255)
   @color2 = Color.new(70,255,0,255)
   @pixels = []
   @pixels2 = []
   @count = 0
   self.contents.font.name = $defaultfonttype
   self.contents.font.size = 12
   @sprite = Sprite.new
   @sprite.bitmap = RPG::Cache.picture('note')
   @sprite.x = 560 - @sprite.bitmap.width/2
   @sprite.y = 432 - @sprite.bitmap.height/2
   @sprite.visible = false
   draw_text
   @playing = 99
 end
 #--------------------------------------------------------------------------
 def draw_text
   self.contents.font.color = Color.new(0,0,0)
   self.contents.fill_rect(0,0,1,64, Color.new(255,255,255))
   self.contents.fill_rect(0,62,128,2, Color.new(255,255,255))
   self.contents.draw_text(1,1,128,10, "Resonance")
   self.contents.draw_text(2,0,128,10, "Resonance")
   self.contents.draw_text(2,2,128,10, "Resonance")
   self.contents.draw_text(3,1,128,10, "Resonance")
   self.contents.font.color = Color.new(255,255,255)
   self.contents.draw_text(2,1,128,10, "Resonance")
 end
 #--------------------------------------------------------------------------
def  update_act
  @act = false
   @distance = 999
    for event in $game_map.events
     next if event[1].page == nil
     commands = SDK.event_comment_input(event[1].page, 1, 'resonance')
     next if commands == nil
     @act = true
     i = commands[0].to_i
     @distance = [($game_player.x - event[1].x)**2 + ($game_player.y - event[1].y)**2, @distance].min
     @distance = 999 if @distance > i**2
   end
 end

 def update
   @count %= 128
   @count += 2
   for i in 0...@count
     x = i
     @pixels[i] = [x, @amplitude * Math.sin((x-@distance*0.7)/128.0*@repeat)*100+32]
     @pixels2[i] = [x, [@amplitude*(@distance/5.0),@amplitude*2].min * Math.sin((x+@distance*0.7)/128.0*@repeat)*100+32]
   end
   self.contents.clear
    if @distance < 999
   unless @distance == 0
     @pixels.each{|a|self.contents.fill_rect(a[0], a[1], 1, 1, @color)}
     @pixels2.each{|a|self.contents.fill_rect(a[0], a[1], 1, 1, @color2)}
     @sprite.visible = false
   else
     @sprite.visible = true
   end
   if @playing != @distance
       Audio.se_play("Audio/SE/" + '014-Move02', 60-(@distance*5)**0.5, 100)
       @playing = @distance
     end
   else
     @sprite.visible = false
     @playing = @distance
   end
   draw_text
 end
end
end

if SDK.state('Treasure Hunt')
 
#--------------------------------------------------------------------------
class Scene_Map
#--------------------------------------------------------------------------
 def main_draw
   @spriteset = Spriteset_Map.new
   @message_window = Window_Message.new
   @graph_window = Window_Graph.new
   Graphics.transition
 end
 #--------------------------------------------------------------------------
 def main_dispose
   Graphics.freeze
   @spriteset.dispose
   @graph_window.dispose
   automatic_dispose
 end
 #--------------------------------------------------------------------------
 def update_graphics
   @spriteset.update
   @message_window.update
   @graph_window.update_act
   if @graph_window.visible != @graph_window.act
   @graph_window.visible = @graph_window.act
 end
 @graph_window.update if @graph_window.act
 end
end
end

if SDK.state('Treasure Hunt')
 
class Game_Event < Game_Character
 attr_reader   :page
end
end
}




Users browsing this thread: