Advertisement
Jragyn

[VXa] J Fix-tha-dropz

Mar 23rd, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.55 KB | None | 0 0
  1. =begin
  2. J Fix-tha-dropz
  3. v1.1
  4. ::::Cleaned up script a bit
  5.  
  6. v1.0
  7. ::::Initial script-modification.
  8.  
  9. Stand alone fix for the drops-issue that XAS for VX Ace has(only dropping 1).
  10. Also adds in multiple drops, courtesy Yanfly.
  11.  
  12. This does rewrite the damage to always use the draw_text function instead of
  13. picture formatting.
  14.  
  15. $j_items and $j_names are temporary global variables.
  16. These will eventually be replaced when I find a way to get this info cross-class.
  17. (read: I get better at scripting/programming)
  18. =end
  19.  
  20. # This is the very tiny customization module!
  21. #=======================================================#
  22. module J                        #
  23. module XAS                      #
  24.                             #
  25. # Text color used for healing damage pops       #
  26.   HEAL_FONT_COLOR = Color.new(150, 255, 150)        #
  27.                             #
  28. # BETA; This enables an enemy that drops multiple items #
  29. # to scatter them in random places around where the #
  30. # enemy died. Currently, it can drop them on unpassable #
  31. # terrain, use at your own risk! (until I fix)      #
  32.   DROP_ARRANGEMENT = false              #
  33.                             #
  34. end                         #
  35. end                         #
  36. #=======================================================#
  37. $imported = {} if $imported.nil?
  38.  
  39. class Sprite_Base < Sprite
  40.   include XAS_DAMAGE_POP
  41.   include XAS_BA_ItemDrop
  42.  
  43.   alias j_xas_alt_damage damage
  44.   def damage(value, type = "")
  45.     dispose_damage
  46.     @damage_ox = 0
  47.     @damage_type = type
  48.     damage_string = value.to_s
  49.   #Dynamically draws the invisible bitmap for writing onto with the item's effects.
  50.     h = 40
  51.     count = $j_names + $j_items
  52.     for i in count
  53.       h += 24
  54.     end
  55.     bitmap = Bitmap.new(160, h)
  56.   #Draws all the details regarding what the text looks like based on the content.
  57.     bitmap.font.name = DAMAGE_FONT_NAME
  58.     bitmap.font.size = DAMAGE_FONT_SIZE
  59.     bitmap.font.bold = DAMAGE_FONT_BOLD
  60.     bitmap.font.italic = DAMAGE_FONT_ITALIC
  61.     bitmap.font.color = Color.new(0,0,0)
  62.     case @damage_type
  63.       when "Exp";   string_color = DAMAGE_EXP_FONT_COLOR
  64.       when "Gold";  string_color = DAMAGE_GOLD_FONT_COLOR
  65.       when "Item";  string_color = DAMAGE_ITEM_FONT_COLOR
  66. #===============================================================================    ========#
  67. # Parry is an NEW additional function created that is effectively a glorified miss. #
  68.       when "Parry"; string_color = J::XAS::PARRY_FONT_COLOR             #
  69. #=======================================================================================#
  70.     else
  71.       string_color = DAMAGE_DEFAULT_FONT_COLOR
  72.     end
  73.     if @damage_type != "Item" && value.to_i < 0
  74.       bitmap.font.size = DAMAGE_FONT_SIZE + 8
  75.       string_color = J::XAS::HEAL_FONT_COLOR
  76.       value = value.abs
  77.     end
  78.     bitmap.font.color = string_color
  79.     damage_string = value.to_s
  80.     damage_string = "MP " + damage_string if @damage_type == "Mp"
  81.     a = 0
  82.     if @damage_type == "Item"
  83.       for n in $j_names
  84.         bitmap.draw_text(0, 12 + a, 160, 36, n.to_s, 1)
  85.         bitmap.draw_text(1, 13 + a, 160, 36, n.to_s, 1)
  86.         a += 24
  87.       end
  88.       unless $j_items.empty?
  89.         bitmap.font.size = DAMAGE_FONT_SIZE + 8
  90.         string_color = J::XAS::HEAL_FONT_COLOR
  91.         bitmap.font.color = string_color
  92.         for i in $j_items
  93.           bitmap.draw_text(0, 12 + a, 160, 36, i.to_s, 1)
  94.           bitmap.draw_text(1, 13 + a, 160, 36, i.to_s, 1)
  95.           a += 24
  96.         end
  97.       end
  98.     else
  99.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  100.       bitmap.draw_text(1, 13, 160, 36, damage_string, 1)
  101.     end      
  102.     @_damage_sprite = ::Sprite.new(self.viewport)
  103.     @_damage_sprite.bitmap = bitmap
  104.     @_damage_sprite.ox = 80
  105.     @_damage_sprite.oy = 20
  106.     @_damage_sprite.x = self.x + @damage_ox
  107.     @_damage_sprite.y = self.y - self.oy / 2
  108.     @_damage_sprite.z = 3000
  109.     @_damage_duration = 60
  110.   end
  111.    
  112. end#Sprite_Base
  113.  
  114. module XAS_BA_ItemDrop
  115.   alias j_xas_fixdrops make_treasure
  116.   def make_treasure(target)
  117.     drops = []
  118. # if yanfly drops are included, will push those drops into the droplist too.
  119.     if $imported["YEA-ExtraDrops"] == true
  120.       for drop in target.extra_drops
  121.         next if rand > drop.drop_rate
  122.         drops << drop
  123.       end
  124.     end
  125. # Runs through the standard drop process, too.
  126.     for drop in target.drop_items
  127.       next if rand(drop.denominator) != 0
  128.       next if drop.kind == 0
  129.       drops << drop
  130.     end
  131. # Actually drops all the items and turns them into collectable events.
  132.     return unless $game_player.map_passable?(self.x, self.y, 0)
  133.     for di in drops
  134.       command = RPG::MoveCommand.new
  135.       command.code = 14
  136.       command.parameters = [0,0]
  137.       route = RPG::MoveRoute.new
  138.       route.repeat = false
  139.       route.list = [command, RPG::MoveCommand.new]        
  140.       page = RPG::Event::Page.new
  141.       page.move_type = 3
  142.       page.move_route = route
  143.       page.move_frequency = 6
  144.       page.priority_type = 1
  145.       page.trigger = 2
  146.       page.through = true
  147. #===============================================================================================#
  148. # This will move the drops around, but as of now, they could land on an un-passable tile.   #
  149. # Use at your own risk! (not that items on un-passable tiles break anything)            #
  150.       if J::XAS::DROP_ARRANGEMENT                               #
  151.          ix = self.x                                        #
  152.          iy = self.y                                        #
  153.          ix += rand(2) - 1                                  #
  154.          iy += rand(2) - 1                                  #
  155.       end                                           #
  156. #===============================================================================================#
  157.       event = RPG::Event.new(self.x, self.y)
  158.       event.pages = [page]
  159.       token = Token_Event.new($game_map.map_id, event)
  160.       if di.kind == 1
  161.         token.icon_name = $data_items[di.data_id].icon_index
  162.       elsif di.kind == 2
  163.         token.icon_name = $data_weapons[di.data_id].icon_index
  164.       elsif di.kind == 3
  165.         token.icon_name = $data_armors[di.data_id].icon_index
  166.       end
  167.       token.treasure = [di.kind, di.data_id]
  168.       token.treasure_time = 120 + XAS_BA::TREASURE_ERASE_TIME * 60
  169.       token.jump_high(0,0,20)
  170.       token.force_update = true
  171.       token.move_speed = 6
  172.       $game_map.add_token(token)
  173.     end#for
  174.   end#def
  175. end#moduleXASBAItemDrop
  176.  
  177. class Game_Player < Game_Character
  178.   alias j_xas_collectdrops check_treasure_here
  179.   def check_treasure_here
  180.     name = ""
  181.     $j_items = []
  182.     $j_names = []
  183.     for event in $game_map.events_xy(@x, @y)
  184.       if event.treasure != nil
  185.         name_pop = true
  186.         case event.treasure[0]
  187.           when 1
  188.             item = $data_items[event.treasure[1]]
  189.             if can_execute_field_item_effect?(item)
  190.               $j_items << self.battler.damage.abs.to_s
  191.             else
  192.               $game_party.gain_item(item, 1)
  193.               $j_names << item.name
  194.             end
  195.             $game_map.need_refresh = true
  196.           when 2
  197.             item = $data_weapons[event.treasure[1]]
  198.             $game_party.gain_item(item, 1, false)
  199.             $j_names << item.name
  200.           when 3
  201.             item = $data_armors[event.treasure[1]]
  202.             $game_party.gain_item(item, 1, false)
  203.             $j_names << item.name
  204.         end
  205.         Audio.se_play("Audio/SE/" + XAS_SOUND::ITEM_DROP , 100, 100)  
  206.         event.erase
  207.         if item != nil
  208.           if item.note =~ /<Drop Animation = (\d+)>/
  209.             self.animation_id = $1.to_i
  210.           end
  211.         end
  212.       end#if event.treasure
  213.       end#for event
  214.       if XAS_DAMAGE_POP::DAMAGE_ITEM_POP and name_pop
  215.         self.battler.damage = item.name
  216.         self.battler.damage_pop = true
  217.         self.battler.damage_type = "Item"
  218.       end
  219.   end#def
  220.  
  221. end#Game_Player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement