查看: 2664|回复: 1

[已经解决] 隨機禮物組只能三組

[复制链接]
梦石
0
星屑
55
在线时间
26 小时
注册时间
2011-1-7
回帖
5
发表于 2013-12-30 23:23:36 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 radiational 于 2013-12-31 01:29 编辑

在這個腳本中

無法添加D以上禮物組

有辦法擴大嗎



[pre lang="ruby" line="1"]=begin

  說明:
  
  事件中執行腳本呼叫來獲取隨機物品
  
    random_gift(group, number)
    例:隨機獲得組:A中的三件物品:  random_gift(:A, 3)
   
=end

class Game_Interpreter
  Random_Gifts = { #隨機獎品列表
    :A => [:i1, :i2, :i3, :w1, :w2, :a1, :a3], #i物品,w武器,每個組用逗號隔開
    :B => [:i1_10, :w1_12, :a5_9], #這樣代表物品1~10,武器1~12,護甲5~9
    :C => [:w1_60]
  }
  # 設置開關號碼,當開關開啟時一定會獲取到不同的幾件物品
  # 設置為 nil 的話則總是有可能獲取到相同的物品
  Diff_Gift_Swth = 1
  def display_gift_text(name)
    $game_message.add("獲得:" + name)
  end
  #
  def random_gift(group, num)
    gifts = []
    Random_Gifts[group].each {|g|
      g = g.to_s
      type = g[0]=="i" ? 0 : g[0]=="w" ? 1 : 2
      if g.include?("_")
        a, b = g.scan(/\d+/)
        for i in a.to_i..b.to_i
          gift = which_random_gift(type)
          gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
        end
      else
        g =~ /(\d+)/
        gift = which_random_gift(type)[$1.to_i]
        gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
      end
    }
    wait_for_message
    if Diff_Gift_Swth && $game_switches[Diff_Gift_Swth]
      gifts.sample(num).each {|g|
        $game_party.gain_item(g, 1)
        display_gift_text(g.name)
      }
    else
      num.times {
        g = gifts[rand(gifts.size)]
        $game_party.gain_item(g, 1)
        display_gift_text(g.name)
      }
    end
    $game_message.face_name = ''
    $game_message.face_index = 0
    $game_message.background = 0
    $game_message.position = 2
    wait_for_message
  end
  #
  def which_random_gift(type)
    case type
    when 0; $data_items
    when 1; $data_weapons
    when 2; $data_armors
    end
  end
  #
  def report_random_gifts_crash(group, g)
    msgbox("隨機禮物發生錯誤:Group :#{group}  Element :#{g}") if $TEST
  end
end
[/pre]
梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2013-12-30 23:43:25 | 显示全部楼层
自己加啊{:2_253:}
那个 :C => [.....] 后面加个半角逗号,然后
:D => [.....]

点评

阿呀 原來後面要加逗號 可以了 謝謝ˊ  发表于 2013-12-30 23:54
他說不行..  发表于 2013-12-30 23:52
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部