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

Project1

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

[已经解决] 关于技能消耗

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2017-1-18
帖子
50
跳转到指定楼层
1
发表于 2017-1-21 14:53:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我备注了当释放某射击技能时
<itemneed item_25 1>
<itemcost item_25 1>
却发现背包空着时角色也能开技能= =
#--------------------------------------------------------------------
# ● require Taroxd基础设置
#    制作消耗物品的技能
#--------------------------------------------------------------------
#
#  使用方法:
#    技能备注 <itemcost item_id number>
#       item_id 为消耗的物品 id,number 为消耗的物品个数。
#       number 可不填,默认为 1(即 <itemcost item_id>)。
#    技能备注 <itemneed item_id number>
#       item_id 为需要的物品 id(不消耗),number 为消耗的物品个数。
#       number 可不填,默认为 1
#
#--------------------------------------------------------------------

Taroxd::ItemCost = Struct.new(:item, :number, :cost) do
  MP_ICON = 188
  TP_ICON = 189

  RE = /<item\s*(cost|need)\s+(\d+)(\s+\d+)?>/i

  def self.parse_note(note)
    note.scan(RE).map do |cost, item_id, number|
      new($data_items[item_id.to_i],
        (number ? number.to_i : 1),
        cost == 'cost')
    end
  end

  def meet?
    $game_party.item_number(item) >= number
  end

  def pay
    $game_party.lose_item(item, number) if cost
  end
end

class RPG::Skill < RPG::UsableItem
  def item_costs
    @item_costs ||= Taroxd::ItemCost.parse_note(@note)
  end
end

class Game_BattlerBase

  def_and :skill_cost_payable? do |skill|
    skill.item_costs.all?(&:meet?)
  end

  def_after :pay_skill_cost do |skill|
    skill.item_costs.each(&:pay)
  end
end


class Window_SkillList < Window_Selectable

  def draw_skill_cost(rect, skill)
    contents.font.size -= 6
    change_color(tp_cost_color, enable?(skill))
    draw_skill_cost_icon(rect, skill,
      @actor.skill_tp_cost(skill), Taroxd::ItemCost::TP_ICON)
    change_color(mp_cost_color, enable?(skill))
    draw_skill_cost_icon(rect, skill,
      @actor.skill_mp_cost(skill), Taroxd::ItemCost::MP_ICON)
    skill.item_costs.each do |item_cost|
      draw_skill_cost_icon(rect, skill,
        item_cost.number, item_cost.item.icon_index)
    end
    contents.font.size += 6
  end

  def draw_skill_cost_icon(rect, skill, cost, icon_index)
    return if cost == 0
    x = rect.x + rect.width - 24
    draw_icon(icon_index, x, rect.y, enable?(skill))
    draw_text(x, rect.y + 8, 24, 16, cost, 2) unless cost == 1
    rect.width -= 24
  end
end

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2017-1-18
帖子
50
2
 楼主| 发表于 2017-1-21 14:55:14 | 只看该作者
#-------------------------------------------
# ● require Taroxd基础设置
#    额外战斗行动
#-------------------------------------------
#
#    在战斗公式或事件指令-脚本中输入
#      battler.extra_skill(skill_id, target_index)
#    即可产生一次额外的行动(对应 skill_id 的技能)。
#    target_index 省略时,目标默认为 battler 上次的目标。
#
#    battler.extra_item(item_id, target_index)
#      与 extra_skill 相同。行动内容为对应 item_id 的物品。
#
#    battler.extra_action(skill_id, target_index)
#      与 extra_skill 相同。
#
#    注意,额外的行动也是有消耗的(包括 MP、物品等)
#    当消耗不满足,或者因为其他原因无法行动时,额外行动无效。
#
#-------------------------------------------

class Taroxd::ExtraAction < Game_Action

  # 默认目标。-2: 上次目标, -1: 随机
  DEFAULT_TARGET_INDEX = -2

  class << self

    def new(_, _)
      super.tap { |action| @actions.push action }
    end

    # 获取最后生成的 action 对象并移除这个对象。
    # 如果没有 action,返回 nil。
    def current!
      @actions.pop
    end

    def clear
      @actions = []
    end
  end

  def initialize(subject, target_index)
    super(subject)
    @target_index = target_index
  end

  def make_targets
    @target_index = @subject.last_target_index if @target_index == -2
    super
  end
end

class Game_Battler < Game_BattlerBase
  
  ExtraAction = Taroxd::ExtraAction

  def extra_skill(id, target_index = ExtraAction::DEFAULT_TARGET_INDEX)
    ExtraAction.new(self, target_index).set_skill(id)
  end

  alias_method :extra_action, :extra_skill

  def extra_item(id, target_index = ExtraAction::DEFAULT_TARGET_INDEX)
    ExtraAction.new(self, target_index).set_item(id)
  end
end

class Scene_Battle < Scene_Base

  def_before :battle_start, Taroxd::ExtraAction.method(:clear)

  def_before :process_forced_action do
    action = Taroxd::ExtraAction.current!
    return unless action
    last_subject = @subject
    @subject = action.subject
    @subject.actions.unshift(action)
    process_action
    @subject = last_subject
  end
end

顺便一问,这个战斗公式指的是哪?我在伤害公式里面输出后报错了(脸红)

点评

额。。  发表于 2017-1-21 15:23
最终警告:根据版规A-10-a,版主有权力把“频繁提问者”当成伸手党严肃处理。如果你的游戏需要非常多的非默认技术,请开始自学脚本。  发表于 2017-1-21 15:01
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6235
在线时间
1457 小时
注册时间
2015-7-25
帖子
617

极短25参与开拓者

3
发表于 2017-1-21 14:57:56 | 只看该作者
。。。。首先我没看脚本,只看了设置的说明...发现貌似这样写备注才对吧。。。。<itemneed 25 1><itemcost 25 1>

点评

大佬,谢谢(尴尬脸)  发表于 2017-1-21 17:16

评分

参与人数 1星屑 +250 收起 理由
RaidenInfinity + 250 认可答案

查看全部评分

笨肉包的游戏讨论群932812135 (实时更新) 喜欢的话欢迎加入~
目前的坑
??? #像素风OC游戏 准备中 短篇-约5小时
花城梦之心 #像素风OC游戏 系统开发+素材绘制中
【不可思议的迷宫】幽灵契约外传:歌莉娅 v0.3.8.1 (游戏文件已上传更新
同时更新中~ (沉迷摸鱼中~更新速度较慢请见谅w)
这是属于笨肉包一个人的旅行~(再见了...蚊子湯,七重酱,笨肉包永远想你们!TwT
旅途的最终目标~ ???(保密~
回复 支持 1 反对 0

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2920
在线时间
713 小时
注册时间
2010-7-25
帖子
813

开拓者

4
发表于 2017-1-26 00:19:02 | 只看该作者
事件中用    $game_actors[1].extra_skill(5, -1)
也可以伤害公式里   b.extra_skill(13)
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-14 13:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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