设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1958|回复: 2
打印 上一主题 下一主题

[已经解决] 如何设置道具使用条件?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
143
在线时间
347 小时
注册时间
2010-7-7
帖子
128
跳转到指定楼层
1
发表于 2013-12-9 17:29:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
比如在战斗中,将要使用复活石来复活一名队友,但是使用复活石会消耗100点TP值,如果TP值不足则无法使用该道具,请问如何实现?

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

2
发表于 2013-12-9 20:39:55 | 只看该作者
本帖最后由 Sion 于 2013-12-9 20:41 编辑

RUBY 代码复制
  1. # 设置战斗物品消耗,物品备注中写:
  2. # cost tp:100 消耗使用者 100 TP
  3. # Cost_HP 200 消耗 200 HP
  4. # cost_mp_100 消耗 100 MP
  5. # 大小写和用来隔开的符号随意
  6. # 对应值不足则无法使用,可以设置一个物品消耗多种数值
  7. # 因为平时使用物品根本没有指定使用者,所以非战斗中使用物品时,不计算这些额外消耗。
  8. # [url=home.php?mod=space&uid=95897]@actor[/url]
  9.  
  10. class Game_Actor
  11.   alias_method :consume_item_s20131209, :consume_item
  12.   def consume_item(item)
  13.     pay_item_cost(item)
  14.     consume_item_s20131209(item)
  15.   end
  16.   def pay_item_cost(item)
  17.     return unless $game_party.in_battle
  18.     note = item.note.downcase
  19.     self.hp -= $1.to_i if note =~ /cost.hp.(\d+)/
  20.     self.mp -= $1.to_i if note =~ /cost.mp.(\d+)/
  21.     self.tp -= $1.to_i if note =~ /cost.tp.(\d+)/
  22.   end
  23.   def enough_item_cost?(item)
  24.     note = item.note.downcase
  25.     return false if note =~ /cost.hp.(\d+)/ && hp <= $1.to_i
  26.     return false if note =~ /cost.mp.(\d+)/ && mp < $1.to_i
  27.     return false if note =~ /cost.tp.(\d+)/ && tp < $1.to_i
  28.     return true
  29.   end
  30. end
  31.  
  32. class Window_BattleItem
  33.   def actor=(actor)
  34.     return if @actor == actor
  35.     @actor = actor
  36.     refresh
  37.     self.oy = 0
  38.   end
  39.   def enable?(item)
  40.     super && @actor.enough_item_cost?(item)
  41.   end
  42. end
  43.  
  44. class Scene_Battle
  45.   alias_method :s20131209_command_item, :command_item
  46.   def command_item
  47.     @item_window.actor = BattleManager.actor
  48.     s20131209_command_item
  49.   end
  50. end
   
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
143
在线时间
347 小时
注册时间
2010-7-7
帖子
128
3
 楼主| 发表于 2013-12-9 20:53:16 | 只看该作者
Sion 发表于 2013-12-9 20:39
# 设置战斗物品消耗,物品备注中写:
# cost tp:100 消耗使用者 100 TP
# Cost_HP 200 消耗 200 HP

十分感谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-16 21:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表