Project1

标题: 转盘式抽奖游戏的问题 [打印本页]

作者: 300英雄    时间: 2017-7-31 11:51
标题: 转盘式抽奖游戏的问题
本帖最后由 300英雄 于 2017-7-31 11:57 编辑

■ 转转乐(转盘式抽奖游戏)<VA> ■     -> by 芯☆淡茹水
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 转转乐(转盘式抽奖游戏)<VA> ■     -> by 芯☆淡茹水
  3. #==============================================================================
  4. #
  5. # ■ 使用方法:复制该脚本,插入到 main 前,并复制范例工程 Graphics\Pictures
  6. #              文件夹下所有图片到目标游戏工程。
  7. #
  8. #    呼出抽奖场景方法:事件 -> 脚本:SceneManager.call(Scene_Prize)
  9. #
  10. #==============================================================================
  11. #
  12. # ■ 说明: 1,该转盘抽奖为随机,制作者不能控制(作弊)。制作者需要把可以抽奖
  13. #              的物品ID对应的填入下面的设置项即可。
  14. #
  15. #           2,每一盘抽奖的物品不会重复,得到的物品数量为 1 。
  16. #
  17. #           3,该范例仅支持 24 X 24 的物品图标 。
  18. #
  19. #           4,该范例的图片来源于网络。
  20. #==============================================================================
  21. module X☆R
  22. #==============================================================================
  23. # ■ 设置:↓
  24.   #-------------------------------------------------------------------------
  25.   # 消耗方式(0 固定金钱; 1 变量指定金钱; 2 消耗物品<数量为1>)。
  26.   Consumption_mode = 2
  27.   #-------------------------------------------------------------------------
  28.   # 消耗方式为 0 时,抽奖一次需要的金钱。
  29.   Need_gold = 1000
  30.   #-------------------------------------------------------------------------
  31.   # 消耗方式为 1 时,抽奖一次需要的指定金钱的变量ID。
  32.   Need_gold_var = 67
  33.   #-------------------------------------------------------------------------
  34.   # 消耗方式为 2 时,抽奖一次需要的物品ID。
  35.   Need_item_id = 119
  36.   #-------------------------------------------------------------------------
  37.   # 场景BGM(不需要就写空白引号 "" )。
  38.   Bgm_name = "英灵召唤"
  39.   #-------------------------------------------------------------------------
  40.   # 转针转动时播放的SE。
  41.   Change_se = "Coin"  
  42.   #-------------------------------------------------------------------------
  43.   # 转针停止时播放的SE。
  44.   Stop_se = "Item2"  
  45.   #-------------------------------------------------------------------------
  46.   # 可以出现在转盘里的普通物品ID。
  47.   Prize_items1 = [1,2,3,4,5,6,7,8,182]  
  48.   #-------------------------------------------------------------------------
  49.   # 可以出现在转盘里的珍贵物品ID。
  50.   Prize_items2 = [70,71,72,78,84,85,114,56,80,81,82,83,84,103,97,120,121,22,23,24,25,26,27,28,29,43,45,123,124,125,126,127,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,172,173,174,175,176,177,178,179,180]
  51.   #-------------------------------------------------------------------------
  52.   # 可以出现在转盘里的普通武器ID。
  53.   Prize_weapons1 = [19,7,13,25,31,37,49]
  54.   #-------------------------------------------------------------------------
  55.   # 可以出现在转盘里的珍贵武器ID。
  56.   Prize_weapons2 =  [72,73,74,75,78,80,76,77,79,81,85,86,81,82,83,84]
  57.   #-------------------------------------------------------------------------
  58.   # 可以出现在转盘里的普通防具ID。
  59.   Prize_armors1 =  [1]
  60.   #-------------------------------------------------------------------------
  61.   # 可以出现在转盘里的珍贵防具ID。
  62.   Prize_armors2 = [82,83,84,85,86,87,88,89,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131]
  63.   #-------------------------------------------------------------------------
  64.   # 物品在转盘里出现的几率(百分比)。
  65.   Item_rate = 95
  66.   #-------------------------------------------------------------------------
  67.   # 珍贵物品出现的概率为总物品数的(百分比)。
  68.   Precious_item_rate = 10  
  69.   #-------------------------------------------------------------------------
  70.   # 武器在转盘里出现的几率(百分比)。
  71.   Weapon_rate = 10
  72.   #-------------------------------------------------------------------------
  73.   # 珍贵武器出现的概率为总武器数的(百分比)。
  74.   Precious_weapon_rate = 25
  75.   #-------------------------------------------------------------------------
  76.   # 防具在转盘里出现的几率(百分比)。
  77.   Armor_rate = 10
  78.   #-------------------------------------------------------------------------
  79.   # 珍贵防具出现的概率为总防具数的(百分比)。
  80.   Precious_armor_rate = 25
  81.   #==========================================================================
  82.   #==========================================================================
  83.   # ■ 脚本正文 ↓
  84.   #==========================================================================
  85.   def self.can_start?
  86.     case Consumption_mode
  87.     when 0
  88.       return ($game_party.gold >= Need_gold)
  89.     when 1
  90.       return ($game_party.gold >= $game_variables[Need_gold_var])
  91.     when 2
  92.       return ($game_party.item_number($data_items[Need_item_id]) >= 1)
  93.     end
  94.   end
  95.   #-------------------------------------------------------------------------
  96.   def self.consumption
  97.     case Consumption_mode
  98.     when 0
  99.       $game_party.lose_gold(Need_gold)
  100.     when 1
  101.       $game_party.lose_gold($game_variables[Need_gold_var])
  102.     when 2
  103.       $game_party.lose_item($data_items[Need_item_id], 1)
  104.     end
  105.   end
  106. end  
  107. #==============================================================================
  108. class Game_System
  109.   attr_accessor :prize_items
  110. end
  111. #==============================================================================
  112. class Change < Sprite
  113.   #-------------------------------------------------------------------------
  114.   def initialize
  115.     super()
  116.     self.bitmap = Bitmap.new("Graphics/Pictures/转盘背景")
  117.     self.x = 0; self.y = 10; self.z = 500
  118.     @tit = Sprite.new
  119.     @tit.bitmap = Bitmap.new("Graphics/Pictures/转盘标题")
  120.     @tit.x = self.x + 50; @tit.y = self.y + 24; @tit.z = 600
  121.     @item_sprite = []
  122.     for i in 0..7
  123.       @item_sprite[i] = Sprite.new
  124.       @item_sprite[i].bitmap = Bitmap.new(24,24)
  125.       @item_sprite[i].x, @item_sprite[i].y = get_item_place(i)
  126.       @item_sprite[i].x += self.x; @item_sprite[i].y += self.y
  127.       @item_sprite[i].z = 600
  128.     end
  129.     @zhen = Sprite.new
  130.     @zhen.bitmap = Bitmap.new("Graphics/Pictures/转盘指针")
  131.     @zhen.ox = @zhen.bitmap.width / 2; @zhen.oy = @zhen.bitmap.height / 2
  132.     @zhen.x = self.x + 176; @zhen.y = self.y + 230; @zhen.z = 700
  133.     @zhen.angle = 337.5
  134.     @item_index = 0
  135.   end
  136.   #-------------------------------------------------------------------------
  137.   def dispose
  138.     @item_sprite.each{|w| w.bitmap.dispose; w.dispose}
  139.     @tit.bitmap.dispose
  140.     @zhen.bitmap.dispose
  141.     self.bitmap.dispose
  142.     @tit.dispose
  143.     @zhen.dispose
  144.     super
  145.   end
  146.   #-------------------------------------------------------------------------
  147.   def get_item_place(index)
  148.     case index
  149.     when 0
  150.       return 195, 146
  151.     when 1
  152.       return 238, 186
  153.     when 2
  154.       return 242, 248
  155.     when 3
  156.       return 192, 290
  157.     when 4
  158.       return 138, 290
  159.     when 5
  160.       return  90, 247
  161.     when 6
  162.       return  94, 190
  163.     when 7
  164.       return 134, 150
  165.     end
  166.   end
  167.   #-------------------------------------------------------------------------
  168.   def item_index
  169.     return  @item_index
  170.   end
  171.   #-------------------------------------------------------------------------
  172.   def set_items(items)
  173.     @item_sprite.each{|w| w.bitmap.clear}
  174.     return if items == []
  175.     for i in 0..7
  176.       item = items[i]
  177.       bitmap = Cache.system("Iconset")
  178.       rect = Rect.new(item.icon_index % 16 * 24, item.icon_index / 16 * 24, 24, 24)
  179.       @item_sprite[i].bitmap.blt(0, 0, bitmap, rect)
  180.     end
  181.   end
  182.   #-------------------------------------------------------------------------
  183.   def zhuan
  184.     Audio.se_play("Audio/SE/#{X☆R::Change_se}", 100, 100)
  185.     @zhen.angle -= 45
  186.     @item_index = (@item_index+1) % 8
  187.   end
  188. end
  189. #==============================================================================
  190. class Prize < Sprite
  191.   #-------------------------------------------------------------------------
  192.   def initialize
  193.     super()
  194.     self.x = 350; self.y = 10; self.z = 500
  195.     @messages = []
  196.   end
  197.   #-------------------------------------------------------------------------
  198.   def dispose
  199.     self.bitmap.dispose if self.bitmap
  200.     super
  201.   end
  202.   #-------------------------------------------------------------------------
  203.   def add_mess(txt)
  204.     @messages.unshift(txt)
  205.   end
  206.   #-------------------------------------------------------------------------
  207.   def set_messages
  208.     self.bitmap.dispose if self.bitmap
  209.     self.bitmap = Bitmap.new("Graphics/Pictures/奖品背景")
  210.     return if @messages == []
  211.     x = 14; y = 52
  212.     self.bitmap.font.bold = true
  213.     for i in [email]0...@messages.size[/email]
  214.       self.bitmap.font.size = (i == 0 ? 20 : 16)
  215.       txt = @messages[i]
  216.       if i == 0
  217.         self.bitmap.font.color = Color.new(0,0,0)
  218.         self.bitmap.draw_text(x-1, y-1, 120, 22, txt)
  219.         self.bitmap.draw_text(x-1, y+1, 120, 22, txt)
  220.         self.bitmap.draw_text(x-1, y-1, 120, 22, txt)
  221.         self.bitmap.draw_text(x+1, y-1, 120, 22, txt)
  222.       end
  223.       self.bitmap.font.color = (i == 0 ? Color.new(255,120,0) : Color.new(255,255,255))
  224.       self.bitmap.draw_text(x, y, 120, 22, txt)
  225.       y += (i == 0 ? 32 : 24)
  226.     end
  227.   end
  228.   #-------------------------------------------------------------------------
  229.   def update
  230.     super
  231.     @messages.pop until @messages.size <= 9
  232.     if @data_mes != @messages
  233.       @data_mes = @messages.clone
  234.       set_messages
  235.     end
  236.   end
  237. end
  238. #==============================================================================
  239. class Prize_Cam < Sprite
  240.   #--------------------------------------------------------------------------
  241.   def initialize
  242.     super()
  243.     self.x = 350; self.y = 299; self.z = 500
  244.     @cm_index = 0
  245.   end
  246.   #-------------------------------------------------------------------------
  247.   def dispose
  248.     self.bitmap.dispose if self.bitmap
  249.     super
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   def set_cam
  253.     self.bitmap.dispose if self.bitmap
  254.     self.bitmap = Bitmap.new("Graphics/Pictures/抽奖选择#{@cm_index}")
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   def index
  258.     return @cm_index
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   def update
  262.     super
  263.     if Input.trigger?(:DOWN)
  264.       @cm_index = (@cm_index + 1) % 2
  265.     elsif Input.trigger?(:UP)
  266.       @cm_index -= 1
  267.       @cm_index = 1 if @cm_index < 0
  268.     end
  269.     if @data_index != @cm_index
  270.       Sound.play_cursor unless @data_index.nil?
  271.       @data_index = @cm_index
  272.       set_cam
  273.     end
  274.   end
  275. end
  276. #==============================================================================
  277. class Prize_Gold < Sprite
  278.   #-------------------------------------------------------------------------
  279.   def initialize
  280.     super()
  281.     self.x = 349; self.y = 378; self.z = 500
  282.   end
  283.   #-------------------------------------------------------------------------
  284.   def dispose
  285.     self.bitmap.dispose if self.bitmap
  286.     super
  287.   end
  288.   #-------------------------------------------------------------------------
  289.   def set_show
  290.     self.bitmap.dispose if self.bitmap
  291.     self.bitmap = Bitmap.new("Graphics/Pictures/金钱窗口背景")
  292.     self.bitmap.font.bold = true
  293.     self.bitmap.font.color = Color.new(255,255,255)
  294.     if X☆R::Consumption_mode == 2
  295.       self.bitmap.font.size = 18
  296.       item = $data_items[X☆R::Need_item_id]
  297.       bitmap = Cache.system("Iconset")
  298.       rect = Rect.new(item.icon_index % 16 * 24, item.icon_index / 16 * 24, 24, 24)
  299.       self.bitmap.blt(8, 5, bitmap, rect)
  300.       txt = "#{item.name} X #{$game_party.item_number(item)}"
  301.       self.bitmap.draw_text(36, 2, 110, 32, txt)
  302.     else
  303.       self.bitmap.font.size = 20
  304.       self.bitmap.draw_text(0, 2, 100, 32, $game_party.gold.to_s, 2)
  305.       self.bitmap.font.color = Color.new(192, 224, 255)
  306.       self.bitmap.draw_text(102, 2, 48, 32, $data_system.currency_unit, 1)
  307.     end
  308.   end
  309.   #-------------------------------------------------------------------------
  310.   def update
  311.     super
  312.     if X☆R::Consumption_mode == 2
  313.       if @data_num != $game_party.item_number($data_items[X☆R::Need_item_id])
  314.         @data_num = $game_party.item_number($data_items[X☆R::Need_item_id])
  315.         set_show
  316.       end
  317.     else
  318.       if @data_gold != $game_party.gold
  319.         @data_gold = $game_party.gold
  320.         set_show
  321.       end
  322.     end
  323.   end
  324. end
  325. #==============================================================================
  326. class Scene_Prize < Scene_Base
  327.   #--------------------------------------------------------------------------
  328.   def start
  329.     @spriteset = Spriteset_Map.new
  330.     @zhuan = Change.new
  331.     @prize = Prize.new
  332.     @command = Prize_Cam.new
  333.     @gold = Prize_Gold.new
  334.     @wait_count = 0
  335.     @zhuan_count = 0
  336.     @count = 0
  337.     @speed = 1
  338.     set_prize_items
  339.     if X☆R::Bgm_name != ""
  340.       Audio.bgm_play("Audio/BGM/#{X☆R::Bgm_name}", 100, 100)
  341.     end
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   def pre_terminate
  345.     @zhuan.dispose
  346.     @prize.dispose
  347.     @command.dispose
  348.     @gold.dispose
  349.     @spriteset.dispose
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   def dispose_main_viewport
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   def update
  356.     super
  357.     @zhuan.update
  358.     @prize.update
  359.     @command.update
  360.     @gold.update
  361.     if @wait_count > 0
  362.       @wait_count -= 1
  363.       return
  364.     end
  365.     if @zhuan_count > 0
  366.       @mess = ""
  367.       update_zhuan
  368.       return
  369.     end
  370.     if Input.trigger?(Input::C)
  371.       case @command.index
  372.       when 0
  373.         unless X☆R::can_start?
  374.           Sound.play_buzzer
  375.           return
  376.         end
  377.         Sound.play_ok
  378.         X☆R::consumption
  379.         set_prize_items if @count > 0
  380.         @zhuan_count = rand(150) + 150
  381.       when 1
  382.         Sound.play_cancel
  383.         SceneManager.call(Scene_Map)
  384.       end
  385.     end
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   def update_zhuan
  389.     if @zhuan_count % @speed  == 0
  390.       @speed = [@speed + [(100 - @zhuan_count) / 20, 0].max, 6].min
  391.       @zhuan.zhuan
  392.     end
  393.     @zhuan_count -= 1
  394.     if @zhuan_count == 0
  395.       Audio.se_play("Audio/SE/#{X☆R::Stop_se}", 100, 100)
  396.       @speed = 1
  397.       @count += 1
  398.       get_prize
  399.       @wait_count = 60
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   def get_prize
  404.     item = @prize_items[@zhuan.item_index]
  405.     return if item.nil?
  406.     $game_party.gain_item(item, 1)
  407.     $game_system.prize_items = []
  408.     @prize.add_mess(item.name)
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   def set_prize_items
  412.     @prize_items = []
  413.     if $game_system.prize_items != nil and $game_system.prize_items != []
  414.       @prize_items = $game_system.prize_items.clone
  415.     else
  416.       set_item_mod until @prize_items.size >= 8
  417.       $game_system.prize_items = @prize_items.clone
  418.     end
  419.     @zhuan.set_items(@prize_items)
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   def set_item_mod
  423.     case rand (100)
  424.     when 0...XR::Item_rate
  425.       if rand(100) < X☆R::Precious_item_rate
  426.         mod = X☆R::Prize_items1 + X☆R::Prize_items2
  427.       else
  428.         mod = X☆R::Prize_items1.clone
  429.       end
  430.       item = $data_items[mod[rand(mod.size)]]
  431.       @prize_items << item unless @prize_items.include?(item)
  432.     when X☆R::Item_rate...(XR::Item_rate + X☆R::Weapon_rate)
  433.       if rand(100) < X☆R::Precious_weapon_rate
  434.         mod = X☆R::Prize_weapons1 + X☆R::Prize_weapons2
  435.       else
  436.         mod = X☆R::Prize_weapons1.clone
  437.       end
  438.       item = $data_weapons[mod[rand(mod.size)]]
  439.       @prize_items << item unless @prize_items.include?(item)
  440.     else
  441.       if rand(100) < X☆R::Precious_armor_rate
  442.         mod = X☆R::Prize_armors1 + X☆R::Prize_armors2
  443.       else
  444.         mod = X☆R::Prize_armors1.clone
  445.       end
  446.       item = $data_armors[mod[rand(mod.size)]]
  447.       @prize_items << item unless @prize_items.include?(item)
  448.     end
  449.   end
  450. end
  451. #==============================================================================

1.请问怎么做到多个转盘呢:一个地方我可以设置很多个不同的转盘
A——转盘是一个独立的
B——转盘又是一一个独立的

2.兼容一下下面脚本<图标支援>(转盘里面无法显示图标支援指定的图标,只能显示默认数据库的)<icon: 300 8051> (300这个ICON文件名中8051号ID图标) <icon: name index>这个是格式
系统本身是使用IconSet的,我又添加了另一个叫做300的IconSet。脚本Icon_Sheets这个地方设定"300" = > [24,24],然后物品/技能/装备/状态设置<icon: 300 8051>然后去转盘里运行发现一个空白的,抽到以后就是我数据库设定ICON的物品。所以想问问怎么让转盘也能显示
RUBY 代码复制
  1. =begin
  2. #===============================================================================
  3.  Title: Custom Icon Sheets
  4.  Author: Hime
  5.  Date: Jun 1, 2016
  6. --------------------------------------------------------------------------------
  7.  ** Change log
  8.  Jun 1, 2015
  9.    - added patch for yanfly's ace item menu
  10.  May 27, 2015
  11.    - fixed bug with yanfly's shop options
  12.  Jun 13, 2013
  13.    - icon width and height is now specified for each sheet individually
  14.  Mar 31, 2013
  15.    - now correctly draws icons of non-default sizes
  16.  Mar 25, 2013
  17.    - Initial release
  18. --------------------------------------------------------------------------------   
  19.  ** Terms of Use
  20.  * Free to use in non-commercial projects
  21.  * Contact me for commercial use
  22.  * No real support. The script is provided as-is
  23.  * Will do bug fixes, but no compatibility patches
  24.  * Features may be requested but no guarantees, especially if it is non-trivial
  25.  * Credits to Hime Works in your project
  26.  * Preserve this header
  27. --------------------------------------------------------------------------------
  28.  ** Description
  29.  
  30.  This script allows you to designate which icon sheet you want to draw your
  31.  icon from. This allows you to organize your icons so that you don't need
  32.  to load one large iconset just to draw one icon.
  33. --------------------------------------------------------------------------------
  34.  ** Installation
  35.  
  36.  Place this script below Materials and above Main
  37.  
  38. --------------------------------------------------------------------------------
  39.  ** Usage
  40.  
  41.  -- Installation --
  42.  
  43.  Place this script below Materials and above Main.
  44.  
  45.  -- Setting up custom icon sheets --
  46.  
  47.  Place any custom icon sheets in your Graphics/System folder.
  48.  In the configuration below, add the filenames (without extensions) to the
  49.  `Icon_Sheets` array. You must also include the default icon sheet to use,
  50.  which is "Iconset"
  51.  
  52.  -- Using custom icon indices --
  53.  
  54.  Now that you have set up your icon sheets, you can begin using them.
  55.  In your database, note-tag objects with
  56.  
  57.    <icon: name index>
  58.    
  59.  Where
  60.    `name` is the exact filename of the icon index, without extensions
  61.    `index` is the index of the icon in the specified file.
  62.  
  63. --------------------------------------------------------------------------------
  64.  ** Compatibility
  65.  
  66.  This script overwrites the following methods:
  67.  
  68.    Window_Base
  69.      draw_icon
  70.  
  71. #===============================================================================
  72. =end
  73. $imported = {} if $imported.nil?
  74. $imported["TH_CustomIconSheets"] = true
  75. #===============================================================================
  76. # ** Configuration
  77. #===============================================================================
  78. module TH
  79.   module Custom_Icon_Sheets
  80.  
  81.     # List of icon sheets to load. Case-insensitive.
  82.     # All icon sheets must be placed in the System folder
  83.     # You must provide the dimensions of the icons as well
  84.     Icon_Sheets = {
  85.       "Iconset"     => [24, 24],
  86.       "300"     => [24, 24],
  87.       "最终"     => [24, 24],
  88.       "TLX"     => [24, 24],
  89.       #"CustomIcons" => [24, 24],
  90.       #"LargeIcons"  => [65, 65]
  91.     }
  92.  
  93.     # The default sheet to use if none is specified
  94.     Default_Sheet = "Iconset"
  95.  
  96.     # Note-tag format.
  97.     Regex = /<icon:\s*(\w+)\s*(\d+)>/i
  98.  
  99. #===============================================================================
  100. # ** Rest of script
  101. #===============================================================================
  102.  
  103.     #---------------------------------------------------------------------------
  104.     # Each sheet starts at a specific icon index.
  105.     #---------------------------------------------------------------------------
  106.     def self.icon_offsets
  107.       @icon_offsets
  108.     end
  109.     #---------------------------------------------------------------------------
  110.     # Load all icon sheets. This script uses a look-up table to map icon
  111.     # indices to specific icon sheets.
  112.     #---------------------------------------------------------------------------
  113.     def self.load_sheets
  114.       @icon_offsets = {}
  115.       @icon_table = []
  116.       icon_count = 0
  117.       Icon_Sheets.each {|sheet, (width, height)|
  118.         sheet = sheet.downcase
  119.         bmp = Cache.system(sheet)
  120.  
  121.         # update the "icon index offset" for the current icon sheet.
  122.         # This is used by the look-up table to determine how the icon index
  123.         # is offset
  124.         @icon_offsets[sheet] = icon_count
  125.         @icon_table.push([sheet, icon_count, width, height])
  126.  
  127.         # number of icons per sheet is given by the number of icons per row
  128.         # times the number of icons per height, including empty spaces.
  129.         icon_count += (bmp.width / width) * (bmp.height / height)
  130.       }
  131.  
  132.       # store the icon table in reverse order
  133.       @icon_table.reverse!
  134.     end
  135.  
  136.     def self.load_icon_sheet(index)
  137.       @icon_table.each {|sheet, offset, width, height|
  138.         if index >= offset
  139.           index -= offset
  140.           return Cache.system(sheet), index, width, height
  141.         end
  142.       }
  143.     end
  144.   end
  145. end
  146.  
  147. module RPG
  148.   class BaseItem
  149.     def icon_sheet
  150.       return @icon_sheet unless @icon_sheet.nil?
  151.       load_notetag_custom_icon_sheet
  152.       return @icon_sheet
  153.     end
  154.  
  155.     def load_notetag_custom_icon_sheet
  156.       res = self.note.match(TH::Custom_Icon_Sheets::Regex)
  157.       if res
  158.         @icon_sheet = res[1].downcase
  159.         @custom_icon_index = res[2].to_i
  160.       else
  161.         @icon_sheet = TH::Custom_Icon_Sheets::Default_Sheet.downcase
  162.         @custom_icon_index = @icon_index
  163.       end
  164.     end
  165.  
  166.     alias :th_custom_icon_sheets_icon_index :icon_index
  167.     def icon_index
  168.       parse_custom_icon_index unless @custom_icon_index_checked
  169.       th_custom_icon_sheets_icon_index
  170.     end
  171.  
  172.     #---------------------------------------------------------------------------
  173.     # Automatically updates the icon index based on the appropriate icon sheet
  174.     # to use.
  175.     #---------------------------------------------------------------------------
  176.     def parse_custom_icon_index
  177.       # offset the index as necessary, using the icon sheet to look up the offset
  178.       self.icon_index = TH::Custom_Icon_Sheets.icon_offsets[self.icon_sheet] + @custom_icon_index
  179.       @custom_icon_index_checked = true
  180.     end
  181.   end
  182. end
  183.  
  184. module DataManager
  185.  
  186.   class << self
  187.     alias :th_custom_icon_sheets_load_database :load_database
  188.   end
  189.  
  190.   #-----------------------------------------------------------------------------
  191.   # Prepare the custom icon database
  192.   #-----------------------------------------------------------------------------
  193.   def self.load_database
  194.     th_custom_icon_sheets_load_database
  195.     TH::Custom_Icon_Sheets.load_sheets
  196.   end
  197. end
  198.  
  199. class Window_Base < Window
  200.  
  201.   #-----------------------------------------------------------------------------
  202.   # Overwrite. Get the appropriate bitmap to draw from.
  203.   #-----------------------------------------------------------------------------
  204.   def draw_icon(icon_index, x, y, enabled = true)
  205.     bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(icon_index)
  206.     rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
  207.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  208.   end
  209. end
  210.  
  211. #===============================================================================
  212. # Compatibility patches. This script must be placed under the other scripts
  213. #===============================================================================
  214. class CSCA_Window_EncyclopediaInfo < Window_Base
  215.   def csca_draw_icon(item)
  216.     if item.csca_custom_picture == ""
  217.       bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(icon_index)
  218.       rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
  219.       target = Rect.new(0,0,72,72)
  220.       contents.stretch_blt(target, bitmap, rect)
  221.     else
  222.       bitmap = Bitmap.new("Graphics/Pictures/"+item.csca_custom_picture+".png")
  223.       target = Rect.new(0,0,72,72)
  224.       contents.stretch_blt(target, bitmap, bitmap.rect, 255)
  225.     end
  226.   end
  227. end if $imported["CSCA-Encyclopedia"]
  228.  
  229. #===============================================================================
  230. # Compatibility with Yanfly Ace Shop Options: drawing custom icon in shop
  231. #===============================================================================
  232. class Window_ShopData < Window_Base
  233.   def draw_item_image
  234.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  235.     rect = Rect.new(1, 1, 94, 94)
  236.     contents.fill_rect(rect, colour)
  237.     if @item.image.nil?
  238.  
  239.       bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(@item.icon_index)
  240.       rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
  241.       target = Rect.new(0, 0, 96, 96)
  242.       contents.stretch_blt(target, bitmap, rect)
  243.     else
  244.       bitmap = Cache.picture(@item.image)
  245.       contents.blt(0, 0, bitmap, bitmap.rect, 255)
  246.     end
  247.   end
  248. end if $imported["YEA-ShopOptions"]
  249.  
  250. #===============================================================================
  251. # Compatibility with Yanfly Ace Item Menu: drawing custom icon in item menu
  252. #===============================================================================
  253. class Window_ItemStatus < Window_Base
  254.   def draw_item_image
  255.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  256.     rect = Rect.new(1, 1, 94, 94)
  257.     contents.fill_rect(rect, colour)
  258.     if @item.image.nil?
  259.  
  260.       bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(@item.icon_index)
  261.       rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
  262.       target = Rect.new(0, 0, 96, 96)
  263.       contents.stretch_blt(target, bitmap, rect)
  264.     else
  265.       bitmap = Cache.picture(@item.image)
  266.       contents.blt(0, 0, bitmap, bitmap.rect, 255)
  267.     end
  268.   end
  269. end if $imported["YEA-ItemMenu"]


作者: 300英雄    时间: 2017-7-31 12:00
图片补充说明

QQ截图20170731120027.png (115.98 KB, 下载次数: 20)

物品的设置(最后一行)

物品的设置(最后一行)

QQ图片20170731120012.png (436.36 KB, 下载次数: 21)

转盘的情况

转盘的情况

作者: shengfeng    时间: 2017-7-31 17:50
可以在特定地方买一次东西摇一次奖(摇奖界面只有一个物品其它为空)也就是说摇到空的就没奖品
作者: shengfeng    时间: 2017-7-31 22:29
shengfeng 发表于 2017-7-31 17:50
可以在特定地方买一次东西摇一次奖(摇奖界面只有一个物品其它为空)也就是说摇到空的就没奖品 ...

摇奖为空意思是摇奖界面只设一个物品不是100%中奖摇中空图标(不设置物品)时为不中奖




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1