| 本帖最后由 Sion 于 2013-12-9 20:41 编辑 
 
 # 设置战斗物品消耗,物品备注中写:# cost tp:100 消耗使用者 100 TP# Cost_HP 200 消耗 200 HP# cost_mp_100 消耗 100 MP# 大小写和用来隔开的符号随意# 对应值不足则无法使用,可以设置一个物品消耗多种数值# 因为平时使用物品根本没有指定使用者,所以非战斗中使用物品时,不计算这些额外消耗。# [url=home.php?mod=space&uid=95897]@actor[/url]  class Game_Actor  alias_method :consume_item_s20131209, :consume_item  def consume_item(item)    pay_item_cost(item)    consume_item_s20131209(item)  end  def pay_item_cost(item)    return unless $game_party.in_battle    note = item.note.downcase    self.hp -= $1.to_i if note =~ /cost.hp.(\d+)/    self.mp -= $1.to_i if note =~ /cost.mp.(\d+)/    self.tp -= $1.to_i if note =~ /cost.tp.(\d+)/  end  def enough_item_cost?(item)    note = item.note.downcase    return false if note =~ /cost.hp.(\d+)/ && hp <= $1.to_i    return false if note =~ /cost.mp.(\d+)/ && mp < $1.to_i     return false if note =~ /cost.tp.(\d+)/ && tp < $1.to_i    return true  endend class Window_BattleItem  def actor=(actor)    return if @actor == actor    @actor = actor    refresh    self.oy = 0  end  def enable?(item)    super && @actor.enough_item_cost?(item)  endend class Scene_Battle  alias_method :s20131209_command_item, :command_item  def command_item    @item_window.actor = BattleManager.actor    s20131209_command_item  endend
# 设置战斗物品消耗,物品备注中写: 
# cost tp:100 消耗使用者 100 TP 
# Cost_HP 200 消耗 200 HP 
# cost_mp_100 消耗 100 MP 
# 大小写和用来隔开的符号随意 
# 对应值不足则无法使用,可以设置一个物品消耗多种数值 
# 因为平时使用物品根本没有指定使用者,所以非战斗中使用物品时,不计算这些额外消耗。 
# [url=home.php?mod=space&uid=95897]@actor[/url]  
  
class Game_Actor 
  alias_method :consume_item_s20131209, :consume_item 
  def consume_item(item) 
    pay_item_cost(item) 
    consume_item_s20131209(item) 
  end 
  def pay_item_cost(item) 
    return unless $game_party.in_battle 
    note = item.note.downcase 
    self.hp -= $1.to_i if note =~ /cost.hp.(\d+)/ 
    self.mp -= $1.to_i if note =~ /cost.mp.(\d+)/ 
    self.tp -= $1.to_i if note =~ /cost.tp.(\d+)/ 
  end 
  def enough_item_cost?(item) 
    note = item.note.downcase 
    return false if note =~ /cost.hp.(\d+)/ && hp <= $1.to_i 
    return false if note =~ /cost.mp.(\d+)/ && mp < $1.to_i  
    return false if note =~ /cost.tp.(\d+)/ && tp < $1.to_i 
    return true 
  end 
end 
  
class Window_BattleItem 
  def actor=(actor) 
    return if @actor == actor 
    @actor = actor 
    refresh 
    self.oy = 0 
  end 
  def enable?(item) 
    super && @actor.enough_item_cost?(item) 
  end 
end 
  
class Scene_Battle 
  alias_method :s20131209_command_item, :command_item 
  def command_item 
    @item_window.actor = BattleManager.actor 
    s20131209_command_item 
  end 
end 
 |