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

Project1

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

[已经过期] 我在脚本添加了-随机属性装备-脚本怎么打都不出前缀武器?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
66 小时
注册时间
2013-5-8
帖子
71
跳转到指定楼层
1
发表于 2013-5-13 14:28:42 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我在脚本添加了-随机属性装备-脚本怎么打怪都不出前缀武器?求高手指点一下,如何调整脚本才能打怪打出前缀武器之类的东西。 脚本如下
#encoding:utf-8
#==============================================================================
# ■ 随机属性装备 By wyongcan
#==============================================================================
module Equipplus
#得到随机属性装备方法:gainequip(装备ID,属性数)
#~ 前缀结构:
#~ ①权重(1-100) 越大越重要
#~ ②名称(多个名称用","分开,会随机取其中一个添加到武器名前)
#~ ③属性数组  提供两种方式:
#~ 1.[属性ID,增加值]    属性ID参考说明增强脚本 增加了9号属性“极品出现率” ID为8,影响前缀的好坏 1 - 100
#~ 2.与装备特性相同[code,data_id,value]  code,data_id参考说明增强脚本
  @maxparamplus = 4 #最大前缀数
  @moneyrate = 10 #物品价格计算公式为:原价格 + 前缀权重 * @moneyrate
  @transpose = [*1..100].reverse #用于把1变成100,100变成1
  @paramsplus = [           #暂时只写了三个前缀,可以自己添加,参照前缀结构
  [10,"力量,凶残",[[2,10]]], #物理攻击加10
  [20,"灵气",[[0,200],[1,200]]], # HP和MP各加200
[20,"不屈",[[0,500]]],# HP加500
[30,"灵巧",[[22,1,0.1]]],# 闪避+10%
[45,"轻盈",[[22,1,0.15]]],# 闪避+15%
[30,"稳重",[[43,0,0.1]]],# 命中+10%
[25,"魔力",[[1,350]]],# MP+350
[30,"专注",[[22,2,0.1]]],# 必杀几率+10%
[30,"坚韧",[[22,7,1.1]]],# 体力恢复速度+10%
[50,"悟性",[[23,9,1.1]]],# 经验获得+10%
  [60,"战神",[[21,2,2]]] #物理攻击双倍
  ]
  $商店随机 = true #商店买装备时出随机属性
  $战斗随机 = true #战斗后获得随机属性装备
  def self.getname(paramsplus)
    name = ""
    paramsplus.is_a?(Array) ? paramsplus.each{|a| @temp = []; a[1].scan(/^[\u4e00-\u9fa5|\w]*|,[\u4e00-\u9fa5|\w]*/){|b| @temp.push b.gsub(","){}}; name += @temp[rand(@temp.size)]} : paramsplus[1].scan(/^[\u4e00-\u9fa5|\w]*|,[\u4e00-\u9fa5|\w]*/){|b| @temp = [] if @temp == nil ;@temp.push b.gsub(","){}}
    name += @temp[rand(@temp.size)] if paramsplus.is_a?(Array) != true
    name += "之"
  end
  def self.getluck #获得极品出现率
    luck = 0
    $game_party.all_members.each{|a| a.weapons.each{|a| luck += a.params[8] if a.params.size == 9};a.armors.each{|a| luck += a.params[8] if a.params.size == 9}}
    luck
  end
  def self.getnewequip(xequip,params = nil) #提供两个参数  装备(RPG::Equip类下的)和附加前缀数,不填则为随机
    return unless xequip.is_a?(RPG::EquipItem)
    #xparamplus为前缀数
    xequip.paramsplus = [] if xequip.paramsplus == nil
    return if xequip.paramsplus.size >= @maxparamplus
    params != nil ? xparamplus = params :  xparamplus = rand(@maxparamplus * 110) / 100
    xparamplus = xparamplus.to_int
    return xequip if xparamplus == 0
    equip = xequip.dup
    paramsplus = equip.paramsplus.dup  #无奈的方法,不这样改一个装备所有同父装备的装备都会变
    newparams = equip.params.dup
    newfeatures = equip.features.dup
    aparamsplus = @paramsplus.collect{|a| [a[0] = @transpose[a[0]-1],a[1],a[2]]}.sort_by{|a| a[0]}
    while paramsplus.size < xparamplus
      temp = rand(aparamsplus[-1][0])
      temp = [temp - getluck,0].max
      x = []
      for i in aparamsplus
        x.push i if i[0] >= temp && paramsplus.include?(i) != true
      end
      if x != []
        a = [(x.size-1)*100 - getluck,0].max
        a = (rand(a)/100).to_int
        paramsplus.push x[a]
      end
    end
    equip.name = getname(paramsplus) + equip.name #更新名称
    paramsplus.each{|a| equip.price += @transpose[a[0] - 1] * @moneyrate} #更新价格
    paramsplus.select{|a| a[2].select{|a| a.size == 2}.each{|a| newparams[a[0]] += a[1]}} #更新属性
    #以下为更新特性
    features = []
    paramsplus.each{|a| a[2].each{|a| features.push a if a.size == 3}}
    while features.size > 0
      i = features.pop
      newfeatures.select{|a| a.code == i[0] && a.data_id == i[1]}.size == 0 ? newfeatures.push(RPG::BaseItem::Feature.new(i[0],i[1],i[2])) : newfeatures.each_with_index{|a,b| newfeatures[b].value += i[2] if a.code == i[0] && a.data_id == i[1]}
    end
    if equip.is_a?(RPG::Weapon)
      equip.id = $data_weapons.size
      $data_weapons.insert $data_weapons.size,equip
      $data_weapons[equip.id].paramsplus = paramsplus
      $data_weapons[equip.id].params = newparams
      $data_weapons[equip.id].features = newfeatures
    else
      equip.id = $data_armors.size
      $data_armors.insert $data_armors.size,equip
      $data_armors[equip.id].paramsplus = paramsplus
      $data_armors[equip.id].params = newparams
      $data_armors[equip.id].features = newfeatures
    end
    equip
  end
  def self.gainequip(id,params = nil)
    $game_party.gain_item(Equipplus.getnewequip($data_weapons[id],params),1,true)
  end
end
if $商店随机 == true
  class Scene_Shop < Scene_MenuBase
    def do_buy(number)
      $game_party.lose_gold(number * buying_price)
      if @item.is_a?(RPG::EquipItem)
        x = number
        loop do
          break if x <= 0
          x -= 1
          $game_party.gain_item(Equipplus.getnewequip(@item), 1)
        end
      else
        $game_party.gain_item(@item, number)
      end
    end
  end
end
if $战斗随机 == true
  module BattleManager
    def self.gain_drop_items
      $game_troop.make_drop_items.each do |item|
        item.is_a?(RPG::EquipItem) ? xitem = Equipplus.getnewequip(item) : xitem = item
        $game_party.gain_item(xitem, 1)
        $game_message.add(sprintf(Vocab::ObtainItem, xitem.name))
      end
      wait_for_message
    end
  end
end
class RPG::EquipItem < RPG::BaseItem
  alias old initialize
  def initialize
    old
    @paramsplus #前缀
  end
  attr_accessor :paramsplus
end

Lv1.梦旅人

梦石
0
星屑
55
在线时间
79 小时
注册时间
2013-1-15
帖子
100
2
发表于 2013-5-13 15:30:27 | 只看该作者
有 装备增强帮助 脚本吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
66 小时
注册时间
2013-5-8
帖子
71
3
 楼主| 发表于 2013-5-13 20:14:24 | 只看该作者
好像没有~~!如果哪位有的话能发一下吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
66 小时
注册时间
2013-5-8
帖子
71
4
 楼主| 发表于 2013-5-13 20:29:03 | 只看该作者
刚刚试了 装备帮助增强,脚本如下
#encoding:utf-8
#==============================================================================
# ■ 装备说明增强 By wyongcan
#==============================================================================
module Equipplus
  CODE ={
    11 => "属性抗性",
    12 => "弱化抗性",
    13 => "状态抗性",
    14 => "状态免疫",
    21 => "普通能力",
    22 => "添加能力",
    23 => "特殊能力",
    31 => "攻击附带属性",
    32 => "攻击附带状态",
    33 => "修正攻击速度",
    34 => "添加攻击次数",
    41 => "添加技能类型",
    42 => "禁用技能类型",
    43 => "添加技能",
    44 => "禁用技能",
    51 => "可装备武器类型",
    52 => "可装备护甲类型",
    53 => "固定装备",
    54 => "禁用装备",
    55 => "装备风格",
    61 => "添加行动次数",
    62 => "特殊标志",
    63 => "消失效果",
    64 => "队伍能力"}
  #特殊标志
  FLAG ={
                0 => "自动战斗",
                1 => "擅长防御",
                2 => "保护弱者",
                3 => "特技专注"}
  #普通能力
        PARAM ={
                0 => "最大HP",
                1 => "最大MP",
                2 => "物理攻击",
                3 => "物理防御",
                4 => "魔法攻击",
                5 => "魔法防御",
                6 => "敏 捷 值",
                7 => "幸 运 值"}
  #添加能力
        XPARAM ={
                0 => "物理命中几率:",
                1 => "物理闪避几率:",
                2 => "必杀几率:",
                3 => "必杀闪避几率:",
                4 => "魔法闪避几率:",
                5 => "魔法反射几率:",
                6 => "物理反击几率:",
                7 => "体力值再生速度:",
                8 => "魔力值再生速度:",
                9 => "特技值再生速度:"}
  #特殊能力
        SPARAM ={
                0 => "受到攻击的几率",
                1 => "防御效果比率",
                2 => "恢复效果比率",
                3 => "药理知识",
                4 => "MP消费率",
                5 => "TP消耗率",
                6 => "物理伤害加成",
                7 => "魔法伤害加成",
                8 => "地形伤害加成",
                9 => "经验获得加成"}
        @队伍能力 ={
                0 => "遇敌几率减半",
                1 => "随机遇敌无效",
                2 => "敌人偷袭无效",
                3 => "先制攻击几率上升",
                4 => "获得金钱数量双倍",
                5 => "物品掉落几率双倍"}
  def self.equiphelpready
    @状态 = {}
    @武器类型 = {}
    @防具类型 = {}
    @属性 = {}
    $data_states.each{|x| @状态[x.id] = x.name if x != nil}
    elements = $data_system.elements
    weapon_types = $data_system.weapon_types
    armor_types = $data_system.armor_types
    elements.each_with_index{|x,y| @属性[y] = x if x != ""}
    weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}
    armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}
  end
  def self.getequiphelp(equip)
    help = ""
    param = []
    equip.params.each_with_index{|x,y| param.push([PARAM[y],x])}
    param = param.select{|x| x[1] != 0}
    param.each{|x| help += x[0] + ":" + x[1].to_int.to_s + "\n"}
    features = equip.features
    features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"}
    features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"}
    features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
    features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"}
    features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"}
    features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"}
    features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"}
    features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
    features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
    features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
    features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
    features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
    features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
    features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"}
    features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"}
    features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"}
    features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"}
    features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"}
    featuresparam = []
    featuresparam.push features.select{|x| x.code == 21}
    featuresparam.push features.select{|x| x.code == 22}
    featuresparam.push features.select{|x| x.code == 23}
    featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
    featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"}
    featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"}
    help
  end
  def self.getline(text,maxtext)
    xtext = []
    line = 0
    text.each_line{|x| xtext.push x.sub(/\n/){}}
    xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}
    line
  end
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
#  显示特技和物品等的说明、以及角色状态的窗口
#==============================================================================

class Window_Help2 < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(line_number = 0)
    super(0, 0, 210, 0)
    self.z = 150
    contents.font.size = 14
    hide
  end
  #--------------------------------------------------------------------------
  # ● 设置内容
  #--------------------------------------------------------------------------
  def set_text(text)
      @text = text
      refresh
  end
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 更新帮助位置
  #--------------------------------------------------------------------------
  def uppos(index,rect,window)
    self.height = fitting_height2(Equipplus.getline(@xtext,13))
    create_contents
    contents.font.size = 14
    rect.x -= window.ox
    rect.y -= window.oy
    ax = rect.x + rect.width + 10
    ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
    ax += window.x
    ax = 0 if ax < 0
    ay = rect.y + rect.height
    ay = rect.y - self.height if ay + self.height > window.height
    ay += window.y
    ay = 0 if ay < 0
    self.x = ax
    self.y = ay
    set_text(@xtext)
    show
  end
  #--------------------------------------------------------------------------
  # ● 设置物品
  #     item : 技能、物品等
  #--------------------------------------------------------------------------
  def set_item(item)
    if item == nil
      set_text("")
      return
    end
    @xtext = ""
    @xtext = "名称:" + item.name + "\n"
    @xtext += "介绍:" + item.description + "\n"
    @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
    @xtext += Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
    @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    hide if @text == ""
    draw_text_ex(4, 0, @text,width,40,false)
  end
end
class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 计算窗口显示指定行数时的应用高度2*************************
  #--------------------------------------------------------------------------
  def fitting_height2(line_number)
    line_number * contents.font.size + standard_padding * 2
  end
#~ draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  #--------------------------------------------------------------------------
  # ● 绘制带有控制符的文本内容
  #   如果传递了width参数的话,会自动换行
  #--------------------------------------------------------------------------
  def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
    reset_font_settings if normalfont == true
    text = convert_escape_characters(text)
    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
    if width != nil
      pos[:height] = contents.font.size
      pos[:width] = width
      pos[:textwidth] = textwidth
    end
    process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
  #--------------------------------------------------------------------------
  # ● 文字的处理
  #     c    : 文字
  #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  #--------------------------------------------------------------------------
  def process_character(c, text, pos)
    case c
    when "\r"   # 回车
      return
    when "\n"   # 换行
      process_new_line(text, pos)
    when "\f"   # 翻页
      process_new_page(text, pos)
    when "\e"   # 控制符
      process_escape_character(obtain_escape_code(text), text, pos)
    else        # 普通文字
      pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
      if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
        process_new_line(text, pos)
      end
      process_normal_character(c, pos)
    end
  end
end

class Window_ItemList < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item)
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  end
end

class Window_SkillList < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item)
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  end
end

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) if @help_window
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
    @status_window.item = item if @status_window
  end
end

class Window_EquipSlot < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    super
    @help_window.set_item(item) if @help_window
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
    @status_window.set_temp_actor(nil) if @status_window
  end
end

class Scene_Shop < Scene_MenuBase
        alias on_sell_ok_old on_sell_ok
        def on_sell_ok
                on_sell_ok_old
                @help_window.hide
        end
        alias on_buy_ok_old on_buy_ok
        def on_buy_ok
                on_buy_ok_old
                @help_window.hide
        end
        alias on_number_ok_old on_number_ok
        def on_number_ok
                on_number_ok_old
    @help_window.refresh
                @help_window.show
        end
        alias on_number_cancel_old on_number_cancel
        def on_number_cancel
                on_number_cancel_old
    @help_window.refresh
                @help_window.show
        end
end

class Scene_Title < Scene_Base
  alias start_old start
  def start
    start_old
    Equipplus.equiphelpready
  end
end

class Scene_ItemBase < Scene_MenuBase
        alias old_on_actor_cancel on_actor_cancel
  def on_actor_cancel
    old_on_actor_cancel
        @help_window.refresh
  end
        alias old_on_actor_ok on_actor_ok
  def on_actor_ok
    old_on_actor_ok
        @help_window.refresh
  end
end

class Window_Base < Window
        alias old_process_new_line process_new_line
        def process_new_line(text, pos)
    old_process_new_line(text, pos)
                pos[:height] = contents.font.size if pos[:width] != nil
        end
end

class Scene_MenuBase < Scene_Base
  def create_help_window
    @help_window = Window_Help2.new
    @help_window.viewport = @viewport
  end
end
class Scene_Battle < Scene_Base
  def create_help_window
    @help_window = Window_Help2.new
    @help_window.visible = false
  end
end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
66 小时
注册时间
2013-5-8
帖子
71
5
 楼主| 发表于 2013-5-13 20:30:47 | 只看该作者
出现了以下的错误

78.jpg (12.59 KB, 下载次数: 23)

78.jpg
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-24 21:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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