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

Project1

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

额外战斗行动

[复制链接]

…あたしは天使なんかじゃないわ

梦石
0
星屑
2207
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

跳转到指定楼层
1
发表于 2015-2-9 21:08:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 taroxd 于 2015-3-22 19:23 编辑

RUBY 代码复制
  1. #-------------------------------------------
  2. # ● require Taroxd基础设置
  3. #    额外战斗行动
  4. #-------------------------------------------
  5. #
  6. #    在战斗公式或事件指令-脚本中输入
  7. #      battler.extra_skill(skill_id, target_index)
  8. #    即可产生一次额外的行动(对应 skill_id 的技能)。
  9. #    target_index 省略时,目标默认为 battler 上次的目标。
  10. #
  11. #    battler.extra_item(item_id, target_index)
  12. #      与 extra_skill 相同。行动内容为对应 item_id 的物品。
  13. #
  14. #    battler.extra_action(skill_id, target_index)
  15. #      与 extra_skill 相同。
  16. #
  17. #    注意,额外的行动也是有消耗的(包括 MP、物品等)
  18. #    当消耗不满足,或者因为其他原因无法行动时,额外行动无效。
  19. #
  20. #-------------------------------------------
  21.  
  22. class Taroxd::ExtraAction < Game_Action
  23.  
  24.   # 默认目标。-2: 上次目标, -1: 随机
  25.   DEFAULT_TARGET_INDEX = -2
  26.  
  27.   class << self
  28.  
  29.     def new(_, _)
  30.       super.tap { |action| @actions.push action }
  31.     end
  32.  
  33.     # 获取最后生成的 action 对象并移除这个对象。
  34.     # 如果没有 action,返回 nil。
  35.     def current!
  36.       @actions.pop
  37.     end
  38.  
  39.     def clear
  40.       @actions = []
  41.     end
  42.   end
  43.  
  44.   def initialize(subject, target_index)
  45.     super(subject)
  46.     @target_index = target_index
  47.   end
  48.  
  49.   def make_targets
  50.     @target_index = @subject.last_target_index if @target_index == -2
  51.     super
  52.   end
  53. end
  54.  
  55. class Game_Battler < Game_BattlerBase
  56.  
  57.   ExtraAction = Taroxd::ExtraAction
  58.  
  59.   def extra_skill(id, target_index = ExtraAction::DEFAULT_TARGET_INDEX)
  60.     ExtraAction.new(self, target_index).set_skill(id)
  61.   end
  62.  
  63.   alias_method :extra_action, :extra_skill
  64.  
  65.   def extra_item(id, target_index = ExtraAction::DEFAULT_TARGET_INDEX)
  66.     ExtraAction.new(self, target_index).set_item(id)
  67.   end
  68. end
  69.  
  70. class Scene_Battle < Scene_Base
  71.  
  72.   def_before :battle_start, Taroxd::ExtraAction.method(:clear)
  73.  
  74.   def_before :process_forced_action do
  75.     action = Taroxd::ExtraAction.current!
  76.     return unless action
  77.     last_subject = @subject
  78.     @subject = action.subject
  79.     @subject.actions.unshift(action)
  80.     process_action
  81.     @subject = last_subject
  82.   end
  83. end
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-5-1 12:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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