#===============================================================================
# * Falcao Pearl ABS 脚本集 # 8
#
# 有关掉落物品和金币 v 1.0
# Pearl ABS 系统的一个插件,在没有ABS系统的情况下也可以独立运行。
#
# 网站: [url]http://falcaorgss.wordpress.com/[/url]
# Foro: [url]www.makerpalace.com[/url]
#===============================================================================
#
# * 安装
# 放在main之上就可以自动运行。
#
# * 使用方式
# 没有特别的使用方法,当玩家获得物品或金币时,就会有图标掉落在地图上。
# 下面是一些可以自定义的内容
#-------------------------------------------------------------------------------
module PearlItemPop
# 物品得失提示的X坐标
Pos_X = 10
# 物品得失提示的Y坐标
Pos_Y = 320
# 代表金币的图标的index
GoldIcon = 245
# 获得物品时播放的音效 (设定为nil则无音效)
ItemSe = "Item3"
# 获得金币时播放的音效 (设定为nil则无音效)
GoldSe = "Shop"
end
class Game_Party < Game_Unit
alias falcaopearl_itempop_gain gain_item
def gain_item(item, amount, include_equip = false)
if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
if amount > 0
$game_system.item_object = [item, amount]
RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
end
end
falcaopearl_itempop_gain(item, amount, include_equip = false)
end
alias falcaopearl_itempop_gold gain_gold
def gain_gold(amount)
if SceneManager.scene_is?(Scene_Map)
$game_system.item_object = [nil, amount]
RPG::SE.new(PearlItemPop::GoldSe, 80).play rescue nil
end
falcaopearl_itempop_gold(amount)
end
end
class Game_System
attr_accessor :item_object
end
class Spriteset_Map
alias falcaopearl_itempop_create create_pictures
def create_pictures
create_itempop_sprites
falcaopearl_itempop_create
end
def create_itempop_sprites
@item_object = $game_system.item_object
@item_sprite = Sprite_PopItem.new(@viewport2, @item_object) if
not @item_object.nil?
end
alias falcaopearl_itempop_update update
def update
if !@item_sprite.nil?
unless @item_sprite.disposed?
@item_sprite.update
else
@item_sprite.dispose
@item_object = nil
$game_system.item_object = nil
@item_sprite = nil
end
end
if @item_object != $game_system.item_object
@item_sprite.dispose if !@item_sprite.nil?
@item_sprite = nil
@item_sprite = Sprite_PopItem.new(@viewport2, $game_system.item_object)
@item_object = $game_system.item_object
end
falcaopearl_itempop_update
end
alias falcaopearl_itempop_dispose dispose
def dispose
@item_sprite.dispose unless @item_sprite.nil?
falcaopearl_itempop_dispose
end
end
class Sprite_PopItem < Sprite
def initialize(viewport, item)
super(viewport)
@item = item[0]
@num = item[1]
set_bitmap
self.x = PearlItemPop::Pos_X
self.y = PearlItemPop::Pos_Y
@erasetimer = 120
update
end
def update
super
if @erasetimer > 0
@erasetimer -= 1
self.opacity -= 10 if @erasetimer <= 25
dispose if @erasetimer == 0
end
end
def dispose
self.bitmap.dispose
super
end
def set_bitmap
@item.nil? ? operand = Vocab::currency_unit : operand = @item.name
string = operand + ' X' + @num.to_s
self.bitmap = Bitmap.new(26 + string.length * 9, 28)
self.bitmap.fill_rect(0, 0, self.bitmap.width, 28, Color.new(0, 0, 0, 100))
self.bitmap.font.size = 20
bitmap = Cache.system("Iconset")
icon = @item.nil? ? PearlItemPop::GoldIcon : @item.icon_index
rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
self.bitmap.blt(4, 0, bitmap, rect)
self.bitmap.draw_text(28, 0, 250, 32, string)
end
end