设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 95|回复: 0

[转载发布] Gem Roulette XP

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    前天 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4469

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    22945
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    28308

    灌水之王

    发表于 前天 11:49 | 显示全部楼层 |阅读模式
    Gem Roulette XP
    Version 1.0.8


    by Kyonides



    Introduction

    This is my own version of a roulette mini game. The gems you can see on the screenshot below will rotate as expected after you hit the OK button. Later on it will show you your prize. After you collect it, it will show up on the window on the right hand side of the screen as an icon. You may collect more prizes the more attempts you get.

    Just remember I didn't provide the gems you see below. Use your own icons if possible, you just need 10 of them.

    You may also find ports to VX and VX Ace.

    Screenshots





    Instructions

    There is a TXT file you need to edit so you can configure the prizes the player might earn after spinning the wheel. Later on you may check the instructions included in my script. You also need to place all required (gem) graphics in Graphics/Icons directory, you may need to create it first.

    All 3 Scripts

    DOWNLOAD DEMOS HERE


    XP Version 1.0.8

                    Code:        
    1. # * Gem Roulette XP - Stand Alone Version
    2. #   Scripter : Kyonides-Arkanthos
    3. #   v 1.0.8 - 2021-10-09
    4. #   Script Calls
    5. #   To open Gem Roulette :           $scene = Gem_Roulette.new
    6. #   To increase Spinning Attempts :  $game_party.roulette_attempts += Number
    7. #   This script will let you spin some gems as if they were part of a Wheel of
    8. #   Fortune. Later on you will collect your prize. Previous prizes will be
    9. #   displayed on the window on the right hand side.
    10. #   Prizes are picked up randomly but you can configure what prizes they might
    11. #   get if you edit the file named as shown on the PRIZE_FILENAME Constant below
    12. #   There is the possibility of not letting the player get a prize depending on
    13. #   then gem or slot selected by the script.
    14. #   Don't forget to include the sprites needed for the 10 Gem-Slots.
    15. module GemRouletteSetup
    16.   # Gem Icon Sprite Name Prefix - will be used as Slots
    17.   ICON_NAME_PREFIX = 'gem'
    18.   # SE for Startup and Prize is ready to be collected
    19.   SE_STARTUP = "056-Right02"
    20.   # Prizes TXT Filename
    21.   PRIZE_FILENAME = 'prizes.txt'
    22.   # Label for Position or Slot
    23.   POSITION_LABEL = 'Slot'
    24.   # Label for No Prize for you
    25.   NO_PRIZE = 'Nothing'
    26.   # Label for Item as Prize
    27.   ITEM_PRIZE   = 'Item'
    28.   # Label for Weapon as Prize
    29.   WEAPON_PRIZE = 'Weapon'
    30.   # Label for Armor as Prize
    31.   ARMOR_PRIZE  = 'Armor'
    32.   # Label for Skill as Prize
    33.   SKILL_PRIZE  = 'Skill'
    34.   # Label for HP as Prize or Punishment
    35.   HP_LOSS = 'HP'
    36.   # Label for SP as Prize or Punishment
    37.   SP_LOSS = 'SP'
    38.   # Icon filename for Losing HP or SP
    39.   STATS_LOSS_ICON = ''
    40.   # Points Earned Label
    41.   STATS_LOSS_LABEL = ' Earned: '
    42.   # Attempts Left Label
    43.   ATTEMPTS_LEFT = 'Attempts Left: '
    44.   # Spin the Wheel String
    45.   SPIN_WHEEL = 'Spin Wheel'
    46.   # Collect Prize String
    47.   COLLECT = 'Collect'
    48.   # No More Spins Left String
    49.   RUNOUT = 'No More Spins'
    50.   # Better Luck Next Time String
    51.   NEXT_TIME = 'Better Luck Next Time!'
    52.   # Points Label
    53.   POINTS = 'Points'
    54.   # DO NOT EDIT ANYTHING BELOW THIS LINE
    55.   PRIZE_RXDATA = 'Data/GemRoulette.rxdata'
    56.   PRIZES = {}
    57.   @prizes = []
    58.   @prize_points = []
    59.   extend self
    60.   attr_reader :prizes, :prize_points
    61.   def get_prize_data
    62.     if $DEBUG and File.exist?(PRIZE_FILENAME)
    63.       lines = File.readlines(PRIZE_FILENAME)
    64.       10.times do |n|
    65.         pts = lines[0].scan(/\d+ #{POINTS}/)[0].sub!(/ #{POINTS}/,'')
    66.         @prize_points << pts.to_i
    67.         lines.shift
    68.         PRIZES[n] = []
    69.         regex = /[a-zA-Z]+/
    70.         kinds = lines[0].scan(regex).map {|ln| self.prize_kind(ln) }
    71.         indexes = lines[0].scan(/[0-9\-]+/).map {|ln| self.prize_kind(ln) }
    72.         kinds.size.times {|m| PRIZES[n] << [kinds[m], indexes[m]] }
    73.         lines.shift
    74.       end
    75.       File.open(PRIZE_RXDATA, 'wb') do |file|
    76.         Marshal.dump(@prize_points, file)
    77.         Marshal.dump(PRIZES, file)
    78.       end
    79.       return
    80.     end
    81.     File.open(PRIZE_RXDATA, 'rb') do |file|
    82.       @prize_points = Marshal.load(file)
    83.       PRIZES.merge!(Marshal.load(file))
    84.     end
    85.   end
    86.   def prize_kind(kind)
    87.     regexp = /\d+/
    88.     case kind
    89.     when ITEM_PRIZE then :item
    90.     when WEAPON_PRIZE then :weapon
    91.     when ARMOR_PRIZE then :armor
    92.     when SKILL_PRIZE then :skill
    93.     when HP_LOSS then :hp
    94.     when SP_LOSS then :sp
    95.     when regexp then kind.to_i
    96.     end
    97.   end
    98.   get_prize_data
    99. end
    100. class StatsItem
    101.   attr_reader :name, :points, :icon_name
    102.   def initialize(new_name, new_points)
    103.     @name = new_name.to_s.upcase + ' ' + GemRouletteSetup::STATS_LOSS_LABEL
    104.     @name += new_points.to_s
    105.     @points = new_points
    106.     @icon_name = GemRouletteSetup::STATS_LOSS_ICON
    107.   end
    108. end
    109. class Game_Party
    110.   attr_accessor :roulette_attempts, :roulette_points
    111.   alias kyon_gem_roulette_gm_party_init initialize
    112.   def initialize
    113.     @roulette_attempts = 0
    114.     @roulette_points = 0
    115.     @skills = {}
    116.     kyon_gem_roulette_gm_party_init
    117.   end
    118.   def gain_skill(sid, n)
    119.     return unless sid > 0
    120.     @skills[sid] = [[skill_number(sid) + n, 0].max, 99].min
    121.   end
    122.   def lose_skill(sid, n) gain_skill(sid, -n) end
    123.   def skill_number(sid) @skills.include?(sid)? @skills[sid] : 0 end
    124. end
    125. class Sprite_Blink < Sprite
    126.   def update
    127.     super
    128.     if @_blink
    129.       @_blink_count = (@_blink_count + 1) % 32
    130.       alpha = 6 * (@_blink_count < 16 ? 16 - @_blink_count : @_blink_count - 16)
    131.       self.color.set(255, 255, 255, alpha)
    132.     end
    133.     @@_animations.clear rescue nil
    134.   end
    135.   def blink_on
    136.     return if @_blink
    137.     @_blink = true
    138.     @_blink_count = 0
    139.   end
    140.   def blink_off
    141.     return unless @_blink
    142.     @_blink = false
    143.     self.color.set(0, 0, 0, 0)
    144.   end
    145. end
    146. class Window_Roulette_Prizes < Window_Base
    147.   def initialize
    148.     super(552, 80, 88, 340)
    149.     @column_max = 2
    150.     refresh
    151.   end
    152.   def refresh
    153.     if self.contents != nil
    154.       self.contents.dispose
    155.       self.contents = nil
    156.     end
    157.     @data = GemRouletteSetup.prizes
    158.     @item_max = @data.size
    159.     return if @item_max == 0
    160.     self.contents = Bitmap.new(width - 32, @item_max * 32)
    161.     @item_max.times {|n| draw_item(n) }
    162.   end
    163.   def draw_item(index)
    164.     x = index % 2 * 32
    165.     y = index / 2 * 32
    166.     bitmap = RPG::Cache.icon(@data[index])
    167.     contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    168.   end
    169. end
    170. class Window_Command
    171.   def replace_command(index, command)
    172.     @commands[index] = command
    173.     refresh
    174.   end
    175. end
    176. class Window_GRPLabel < Window_Base
    177.   def initialize(w)
    178.     super(0, 0, w, 64)
    179.     self.contents = Bitmap.new(width - 32, height - 32)
    180.     refresh
    181.   end
    182.   def refresh
    183.     c = self.contents
    184.     c.clear
    185.     c.font.color = system_color
    186.     points = GemRouletteSetup::POINTS
    187.     c.draw_text(0, 0, self.width - 32, 32, points)
    188.     c.font.color = normal_color
    189.     points = $game_party.roulette_points.to_s
    190.     c.draw_text(0, 0, self.width - 32, 32, points, 2)
    191.   end
    192. end
    193. class Gem_Roulette
    194.   include GemRouletteSetup
    195.   def initialize
    196.     path = 'Graphics/Icons/'
    197.     items = Dir[path + ICON_NAME_PREFIX+'*'].sort
    198.     @items = items.map{|item| item.sub!(path, '') }
    199.     @moving_frames = 15
    200.     @steps = 60
    201.     Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)
    202.     @item_sprites = []
    203.     @cx = 320
    204.     @cy = 240
    205.     if @items.size < 10
    206.       @items += items[0,(10 - @items.size)].dup
    207.     elsif @items.size > 10
    208.       @items = @items[0,10]
    209.     end
    210.     @item_max = @items.size
    211.     @radius = 120
    212.     @d = 2.0 * Math::PI / @item_max
    213.     @item_max.times do |n|
    214.       @item_sprites << Sprite_Blink.new
    215.       @item_sprites[n].x = @cx - 20 - (@radius * Math.sin(@d * n)).round
    216.       @item_sprites[n].y = @cy - 60 + (@radius * Math.cos(@d * n)).round
    217.       @item_sprites[n].bitmap = RPG::Cache.icon(items[n % items.size])
    218.     end
    219.     @blink_index = 0
    220.     @item_sprites[@blink_index].blink_on
    221.     @xy = [@item_sprites[0].x, @item_sprites[0].y]
    222.     @prize_sprites = []
    223.     3.times do
    224.       @prize_sprites << Sprite.new
    225.       @prize_sprites[-1].z = 5000
    226.     end
    227.     @prize_sprites[0].x = @cx - 12
    228.     @prize_sprites[0].y = @cy - 36
    229.     @prize_sprites[1].x = @prize_sprites[0].x - 78
    230.     @prize_sprites[1].y = @prize_sprites[0].y + 36
    231.     @prize_sprites[2].x = 210
    232.     @prize_sprites[2].y = 344
    233.     make_attempts_left_label
    234.     @option_window = Window_Command.new(160, [SPIN_WHEEL])
    235.     @option_window.x = 240
    236.     @option_window.y = @prize_sprites[2].y + 36
    237.   end
    238.   def make_attempts_left_label
    239.     @prize_sprites[2].bitmap.clear rescue nil
    240.     @prize_sprites[2].bitmap = bitmap = Bitmap.new(220, 32)
    241.     color = Color.new(25, 25, 25, 180)
    242.     @prize_sprites[2].bitmap.fill_rect(0, 0, 220, 32, color)
    243.     attempts = ATTEMPTS_LEFT + $game_party.roulette_attempts.to_s
    244.     bitmap.draw_text(0, 0, 220, 32, attempts, 1)
    245.   end
    246.   def main
    247.     @spriteset = Spriteset_Map.new
    248.     @points_window = Window_GRPLabel.new(172)
    249.     @points_window.x = 640 - @points_window.width
    250.     3.times {|n| @prize_sprites[n].z = 5000 }
    251.     @item_max.times {|n| @item_sprites[n].z = 5000 }
    252.     @prizes_window = Window_Roulette_Prizes.new
    253.     Graphics.transition
    254.     loop do
    255.       Graphics.update
    256.       Input.update
    257.       update
    258.       break if $scene != self
    259.     end
    260.     Graphics.freeze
    261.     @prizes_window.dispose
    262.     @option_window.dispose
    263.     @xy.clear
    264.     @prize_sprites.each {|sprite| sprite.dispose }
    265.     @prize_sprites.clear
    266.     @item_sprites.each {|sprite| sprite.dispose }
    267.     @item_sprites.clear
    268.     @prize_sprites = @item_sprites = @xy = nil
    269.     @points_window.dispose
    270.     @spriteset.dispose
    271.   end
    272.   def update
    273.     @option_window.update
    274.     @prizes_window.update
    275.     @item_sprites.each{|sprite| sprite.update }
    276.     if @move
    277.       refresh_sprites
    278.       return
    279.     end
    280.     if Input.trigger?(Input::B)
    281.       exit_scene
    282.       return
    283.     elsif Input.trigger?(Input::C)
    284.       if $game_party.roulette_attempts == 0
    285.         if @result
    286.           retrieve_new_prize
    287.           exit_scene
    288.         else
    289.           $game_system.se_play($data_system.buzzer_se)
    290.         end
    291.         return
    292.       end
    293.       $game_system.se_play($data_system.decision_se)
    294.       retrieve_new_prize
    295.     end
    296.   end
    297.   def exit_scene
    298.     $game_system.se_play($data_system.buzzer_se)
    299.     GemRouletteSetup.prizes.clear
    300.     $scene = Scene_Map.new
    301.   end
    302.   def retrieve_new_prize
    303.     if !@move and !@result
    304.       @item_sprites[@blink_index].blink_off
    305.       @option_window.index = -1
    306.       $game_party.roulette_attempts -= 1
    307.       make_attempts_left_label
    308.       @index = rand(@item_max)
    309.       @move = true
    310.       return
    311.     end
    312.     return unless @result
    313.     GemRouletteSetup.prizes << @new_prize.icon_name if @new_prize
    314.     @prizes_window.refresh
    315.     @option_window.index = 0
    316.     case @kind
    317.     when :item then $game_party.gain_item(@new_prize.id, 1)
    318.     when :weapon then $game_party.gain_weapon(@new_prize.id, 1)
    319.     when :armor then $game_party.gain_armor(@new_prize.id, 1)
    320.     when :skill then $game_party.gain_skill(@new_prize.id, 1)
    321.     when :hp then $game_party.actors[0].hp += @new_prize.points
    322.     when :sp then $game_party.actors[0].sp += @new_prize.points
    323.     end
    324.     @prize_sprites[0].bitmap.clear rescue nil
    325.     @prize_sprites[1].bitmap.clear rescue nil
    326.     @result = nil
    327.     comm = $game_party.roulette_attempts > 0 ? SPIN_WHEEL : RUNOUT
    328.     @option_window.replace_command(0, comm)
    329.   end
    330.   def refresh_sprites
    331.     d1 = -@d / @moving_frames * 2
    332.     @item_max.times do |n|
    333.       m = n - @index
    334.       d = @d * m + d1 * @steps
    335.       @item_sprites[n].x = @cx - 20 - (@radius * Math.sin(d)).round
    336.       @item_sprites[n].y = @cy - 60 + (@radius * Math.cos(d)).round
    337.     end
    338.     @steps -= 1
    339.     if @steps == -1
    340.       if rand(5) == 0
    341.         @steps += 5
    342.         return
    343.       end
    344.       Audio.se_play("Audio/SE/" + GemRouletteSetup::SE_STARTUP, 80, 100)
    345.       @move = nil
    346.       @steps = 1 + @moving_frames * (3 + rand(5))
    347.       results = @item_sprites.map{|sprite| @xy == [sprite.x,sprite.y] }
    348.       @blink_index = @result = results.index(true)
    349.       @item_sprites[@blink_index].blink_on
    350.       check_prize
    351.     end
    352.   end
    353.   def get_prize_kind(kind, index)
    354.     @kind = kind
    355.     case kind
    356.     when :item then $data_items[index]
    357.     when :weapon then $data_weapons[index]
    358.     when :armor then $data_armors[index]
    359.     when :skill then $data_skills[index]
    360.     when :hp, :sp then StatsItem.new(kind, index)
    361.     end
    362.   end
    363.   def find_prize
    364.     case @prizes.size
    365.     when 1
    366.       @prizes[0][0] ? get_prize_kind(@prizes[0][0], @prizes[0][1]) : nil
    367.     else
    368.       index = @prizes.size > 2 ? rand(@prizes.size) : rand(4) % 2
    369.       get_prize_kind(@prizes[index][0], @prizes[index][1])
    370.     end
    371.   end
    372.   def no_prize
    373.     @kind = nil
    374.     @prize_sprites[1].bitmap = bitmap = Bitmap.new(200, 24)
    375.     bitmap.font.bold = true
    376.     bitmap.font.size = 19
    377.     bitmap.draw_text(0, 0, 200, 24, NEXT_TIME, 1)
    378.   end
    379.   def check_prize
    380.     $game_party.roulette_points += GemRouletteSetup.prize_points[@blink_index]
    381.     @points_window.refresh
    382.     @prizes = PRIZES[@result]
    383.     return no_prize if @prizes.nil? or @prizes[0].nil?
    384.     @new_prize = find_prize
    385.     return no_prize unless @new_prize
    386.     @prizes.clear
    387.     @prize_sprites[0].bitmap = RPG::Cache.icon(@new_prize.icon_name).dup
    388.     @prize_sprites[1].bitmap = bitmap = Bitmap.new(180, 24)
    389.     bitmap.font.bold = true
    390.     bitmap.font.size = 19
    391.     bitmap.draw_text(0, 0, 180, 24, @new_prize.name, 1)
    392.     @option_window.replace_command(0, COLLECT)
    393.   end
    394. end
    复制代码



    TXT Config File
    Valid for All Versions
                    Code:        
    1. Slot 1
    2. Weapon 1, Item 1, Armor 1, Skill 1
    3. Slot 2
    4. Weapon 2, Item 2, Skill 2
    5. Slot 3
    6. Weapon 5, Item 3, Armor 4, Skill 3
    7. Slot 4
    8. Weapon 1, Item 1, Armor 1, Skill 1
    9. Slot 5
    10. Weapon 1, Item 5, Item 8, Skill 1
    11. Slot 6
    12. Weapon 1, Item 1, Armor 8, Skill 1
    13. Slot 7
    14. Weapon 1, Item 1, Armor 1, Skill 1
    15. Slot 8
    16. Nothing
    17. Slot 9
    18. Weapon 1, Item 1, Armor 1, Skill 5
    19. Slot 10
    20. Weapon 4, Item 1, Armor 4, Skill 20
    复制代码


    FAQ

    Nothing to say, yet.


    Compatibility

    Designed for RPG Maker XP & VX & VX ACE. You may need to check out the other subfora to find them.


    Terms and Conditions

    Free for use in non commercial projects, but you may contact me in case you want to go commercial. Due credit is a must.

    By the way, I will only support the latest version available because it usually includes bug fixes and improvements.

    You are not allowed to repost my scripts on any other boards.

    Give me a free copy of your completed game if you include at least 2 of my scripts!



    本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/gem-roulette-xp.115333/

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-14 17:53 , Processed in 0.066311 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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