查看: 2686|回复: 1

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

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

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

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

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

在這個腳本中

無法添加D以上禮物組

有辦法擴大嗎



  1. =begin

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

  10. class Game_Interpreter
  11.   Random_Gifts = { #隨機獎品列表
  12.     :A => [:i1, :i2, :i3, :w1, :w2, :a1, :a3], #i物品,w武器,每個組用逗號隔開
  13.     :B => [:i1_10, :w1_12, :a5_9], #這樣代表物品1~10,武器1~12,護甲5~9
  14.     :C => [:w1_60]
  15.   }
  16.   # 設置開關號碼,當開關開啟時一定會獲取到不同的幾件物品
  17.   # 設置為 nil 的話則總是有可能獲取到相同的物品
  18.   Diff_Gift_Swth = 1
  19.   def display_gift_text(name)
  20.     $game_message.add("獲得:" + name)
  21.   end
  22.   #
  23.   def random_gift(group, num)
  24.     gifts = []
  25.     Random_Gifts[group].each {|g|
  26.       g = g.to_s
  27.       type = g[0]=="i" ? 0 : g[0]=="w" ? 1 : 2
  28.       if g.include?("_")
  29.         a, b = g.scan(/\d+/)
  30.         for i in a.to_i..b.to_i
  31.           gift = which_random_gift(type)[i]
  32.           gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
  33.         end
  34.       else
  35.         g =~ /(\d+)/
  36.         gift = which_random_gift(type)[$1.to_i]
  37.         gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
  38.       end
  39.     }
  40.     wait_for_message
  41.     if Diff_Gift_Swth && $game_switches[Diff_Gift_Swth]
  42.       gifts.sample(num).each {|g|
  43.         $game_party.gain_item(g, 1)
  44.         display_gift_text(g.name)
  45.       }
  46.     else
  47.       num.times {
  48.         g = gifts[rand(gifts.size)]
  49.         $game_party.gain_item(g, 1)
  50.         display_gift_text(g.name)
  51.       }
  52.     end
  53.     $game_message.face_name = ''
  54.     $game_message.face_index = 0
  55.     $game_message.background = 0
  56.     $game_message.position = 2
  57.     wait_for_message
  58.   end
  59.   #
  60.   def which_random_gift(type)
  61.     case type
  62.     when 0; $data_items
  63.     when 1; $data_weapons
  64.     when 2; $data_armors
  65.     end
  66.   end
  67.   #
  68.   def report_random_gifts_crash(group, g)
  69.     msgbox("隨機禮物發生錯誤:Group :#{group}  Element :#{g}") if $TEST
  70.   end
  71. end
复制代码
梦石
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.

在本版发帖返回顶部