daily pastebin goal
4%
SHARE
TWEET

Falcao map drops

Falmc Oct 17th, 2012 364 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================#
  2. #  #*****************#                                                         #
  3. #  #*** By Falcao ***#          * Falcao Map Drop version 1.0                  #
  4. #  #*****************#          This script allow you set events to drop: items#
  5. #                               weapons, armor and gold. everything work with a#
  6. #       RMVXACE                 simple comment tag                             #
  7. #                               Date: Octuber 18 2012                          #
  8. #                                                                              #
  9. # Falcao RGSS site:  http://falcaorgss.wordpress.com                           #
  10. # Falcao Forum site: http://makerpalace.com                                    #
  11. #==============================================================================#
  12.  
  13. #-------------------------------------------------------------------------------
  14. # * Installation
  15. #
  16. # Copy and paste this script above main, no methods were overwritten so,
  17. # compatibility is very high.
  18. #-------------------------------------------------------------------------------
  19. #
  20. # Instructions:
  21. #
  22. # Tag events as follows
  23. #
  24. # <drop_item: id>    
  25. # <drop_weapon: id>    - Change id for the item id to drop. Ex: <drop_item: 2>
  26. # <drop_armor: id>
  27. # <quantity: x>        - Change x for the quantity of items/weapon/armor to gain
  28. #
  29. # <drop_gold: amount>  - Change amount for gold value Ex: <drop_gold: 25>
  30. #
  31. # Important!
  32. # Events drops only one item/weapon etc. at the time.
  33. # Event start when the player take the drop, so you have the chance to,
  34. # erase the event, activate a self switch or whatever you want.
  35. #-------------------------------------------------------------------------------
  36. # * License
  37. #
  38. # For non-comercial games only, for comercial use please contactme to
  39. # falmc99@gamail.com
  40. #-------------------------------------------------------------------------------
  41.  
  42. module FalMapDrop
  43.  
  44.   # Gold icon index
  45.   GoldIcon = 245
  46.  
  47. end
  48.  
  49. # Spriteset map
  50. class Spriteset_Map
  51.   alias falcao_mapdrop_create_characters create_characters
  52.   def create_characters
  53.     dispose_mapdrop_sprites if !@mapdrop_sprites.nil?
  54.     @mapdrop_sprites = []
  55.     @mapdrop_events = []
  56.     falcao_mapdrop_create_characters
  57.   end
  58.  
  59.   alias falcao_mapdrop_characters_update update_characters
  60.   def update_characters
  61.     update_mapdrop_sprites
  62.     falcao_mapdrop_characters_update
  63.   end
  64.  
  65.   alias falcao_mapdrop_dispose_h dispose
  66.   def dispose
  67.     dispose_mapdrop_sprites
  68.     falcao_mapdrop_dispose_h
  69.   end
  70.  
  71.   def update_mapdrop_sprites
  72.     for event in $game_map.events.values
  73.       kind = nil
  74.       item   = event.check_drop("<drop_item: ")
  75.       weapon = event.check_drop("<drop_weapon: ")
  76.       armor  = event.check_drop("<drop_armor: ")
  77.       gold   = event.check_drop("<drop_gold: ")
  78.       kind = $data_items[item] if item != 0
  79.       kind = $data_weapons[weapon] if weapon != 0
  80.       kind = $data_armors[armor] if armor != 0
  81.       kind = gold if gold != 0
  82.       if kind != nil
  83.         unless @mapdrop_events.include?(event)
  84.           sprite = Sprite_MapDrop.new(@viewport1, event, kind)
  85.           @mapdrop_sprites.push(sprite)
  86.           @mapdrop_events.push(event)
  87.         end
  88.       end
  89.     end
  90.     for drop in @mapdrop_sprites
  91.       drop.update
  92.       @mapdrop_sprites.delete(drop) if drop.disposed?
  93.     end
  94.   end
  95.  
  96.   def dispose_mapdrop_sprites
  97.     @mapdrop_sprites.each {|sprite| sprite.dispose }
  98.     @mapdrop_sprites = nil
  99.   end
  100. end
  101.  
  102. # Basic drop sprites
  103. class Sprite_MapDrop < Sprite
  104.   def initialize(viewport, event, item)
  105.     super(viewport)
  106.     @event = event
  107.     @item = item
  108.     n = @event.check_drop("<quantity: ")
  109.     n > 0 ? @num = n : @num = 1
  110.     self.z = @event.screen_z + 1
  111.     @object_zooming = 0
  112.     set_bitmap
  113.     update
  114.   end
  115.  
  116.   def update
  117.     super
  118.     @event.through = true if not @event.through
  119.     self.bush_depth = @event.bush_depth
  120.     @object_zooming += 1
  121.     case @object_zooming
  122.     when 1..8  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  123.     when 9..16 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  124.     when 17..24 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0; @object_zooming = 0
  125.     end
  126.     self.x = @event.screen_x - 12
  127.     self.y = @event.screen_y - 24
  128.     if @event.x == $game_player.x and @event.y == $game_player.y and
  129.       !$game_player.moving?
  130.       if @item.is_a?(Fixnum)
  131.         $game_party.gain_gold(@item)
  132.         RPG::SE.new("Shop", 80).play
  133.       else
  134.         $game_party.gain_item(@item, @num)
  135.         RPG::SE.new("Item1", 80).play
  136.       end
  137.       @event.start
  138.       dispose
  139.     end
  140.   end
  141.  
  142.   def dispose
  143.     self.bitmap.dispose
  144.     self.bitmap = nil
  145.     super
  146.   end
  147.  
  148.   def set_bitmap
  149.     self.bitmap = Bitmap.new(26, 38)
  150.     bitmap = Cache.system("Iconset")
  151.     icon = @item.is_a?(Fixnum) ? FalMapDrop::GoldIcon : @item.icon_index
  152.     rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  153.     self.bitmap.blt(0, 0, bitmap, rect)
  154.     @item.is_a?(Fixnum) ? n = @item : n = @num
  155.     self.bitmap.font.size = 14
  156.     self.bitmap.draw_text(0, 8, 26, 32, n.to_s, 1)
  157.   end
  158. end
  159.  
  160. # Event tag definition
  161. class Game_Event < Game_Character
  162.   attr_accessor :through
  163.   def check_drop(comment, sw=true)
  164.     return 0 if @list.nil? or @list.size <= 0
  165.     for item in @list
  166.       if item.code == 108 or item.code == 408
  167.         return sw ?$1.to_i : $1.to_s if item.parameters[0] =~ /#{comment}(.*)>/i
  168.       end
  169.     end
  170.     return 0
  171.   end
  172. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top