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

[转载发布] KLotto ACE

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

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 2026-8-2 12:42:29 | 显示全部楼层 |阅读模式
    KLotto ACE

    by Kyonides Arkanthes



    Introduction

    Do you recall my script Gem Roulette?

    Yes, the one with the spinning wheel made out of gems!

    Well, here's an interesting variant of it, this time is about the lotto!



    This script can be customize up to a certain point, still, it can be used as a plug & play script as well, if you don't edit anything.

    Yes, the spheres do fly!



    Screenshot




    NOTES

    You'll need a picture that includes all the different colored spheres distributed in a single horizontal strip.
    The width and the height of each individual frame cell should be identical, making it an actual square.

    VX Ace Script
                    Code:       
    1. # * KLotto ACE
    2. #   Scripter : Kyonides Arkanthes
    3. #   v1.0.6 - 2019-11-19
    4. # This scriptlet will let you partake in raffles. Once the raffles are over, the
    5. # scene will change back to the current map.
    6. # * Script Calls *
    7. # KLotto.set(OptionsHash)
    8. #   Optional - It lets you customize the KLottoShop
    9. #   The following options you can use to replace OptionsHash are optional.
    10. #   id: 1                   - Changes the shop ID.
    11. #   name: 'Claudia's Lotto' - Changes the shop's name.
    12. #   cost: 25                - Changes the ticket cost.
    13. #   prizes: [25000, 5000]   - Changes the amount of the prize.
    14. #   max: 5                  - Changes the number of columns aka digits.
    15. # SceneManager.goto(KLottoShop)
    16. #   Opens the shop no matter if you have called KLotto.set before or not.
    17. # $game_system.winner_tickets
    18. #   Array of Strings - List of previous winner tickets.
    19. # $game_party.winner_tickets
    20. #   Array of Strings - List of winner tickets the party has ever purchased.
    21. # $game_party.purchase_lotto_tickets
    22. # $game_party.purchase_lotto_tickets(Total)
    23. #   Yes, via a script call you can let the player buy some tickets.
    24. #   The Total number can be omitted, its default value is 1.
    25. # $game_party.has_lotto_ticket?(String)
    26. #   String should be a Number converted to a String by calling Number.to_s
    27. # $game_party.discard_lotto_tickets
    28. #   Forces the player to dispose of every single lotto ticket.
    29. module KLotto
    30.   TICKET_ITEM_ID = 31
    31.   PREVIOUS_TICKETS_MAX = 10
    32.   TICKET_PRICE = 10
    33.   DEFAULT_GOLD = [10000, 5000, 2000]
    34.   SPHERES_MIN = 3
    35.   SPHERE_WIDTH = 32 # In Pixels
    36.   FIRST_SPHERE_X = 280
    37.   FILENAME = 'spheres32'
    38.   SE_STARTUP = '056-Right02'
    39.   GENERIC_NAME = 'Generic Lotto'
    40.   PRIZES = 'Current Prizes'
    41.   PARTY_GOLD = 'Your Money'
    42.   WINNING_TICKET_LABEL = 'Winning Ticket'
    43.   PAST_WINNING_TICKETS_LABEL = 'Past Winning Tickets'
    44.   NAME_FONT_SIZE = 32
    45.   WINNING_LABEL_FONT_SIZE = 24
    46.   WINNING_NUMBER_FONT_SIZE = 32
    47.   PREVIOUS_TICKETS_FONT_SIZE = 24
    48.   PRIZE_LABEL_FONT_SIZE = 24
    49.   PRIZE_FONT_SIZES = [32, 28, 24]
    50.   @options = {} # Do Not Touch This!
    51.   def self.options() @options end
    52.   def self.set(hash={}) @options = hash end
    53. end
    54. module LottoSpriteMod
    55.   attr_accessor :number
    56. end
    57. class KLottoTicket
    58.   def initialize(number=nil)
    59.     @number = number || rand(10).to_s + rand(10).to_s + rand(10).to_s
    60.   end
    61.   attr_reader :number
    62. end
    63. class Game_System
    64.   alias :kyon_lotto_gm_sys_init :initialize
    65.   def initialize
    66.     kyon_lotto_gm_sys_init
    67.     @winner_tickets = []
    68.   end
    69.   def tickets_maintenance
    70.     length = @winner_tickets.size - KLotto::PREVIOUS_TICKETS_MAX
    71.     length.times{ @winner_tickets.shift }
    72.   end
    73.   attr_reader :winner_tickets
    74. end
    75. class Game_Party
    76.   alias :kyon_lotto_gm_party_init :initialize
    77.   def initialize
    78.     kyon_lotto_gm_party_init
    79.     @lotto_tickets = []
    80.     @winner_tickets = []
    81.   end
    82.   def purchase_lotto_tickets(total=1)
    83.     return 0 if total < 1
    84.     gain_item($data_items[KLotto::TICKET_ITEM_ID], total)
    85.     total.times{ @lotto_tickets << KLottoTicket.new }
    86.   end
    87.   def discard_lotto_tickets
    88.     gain_item(KLotto::TICKET_ITEM_ID, -@lotto_tickets.size)
    89.     @lotto_tickets.clear
    90.   end
    91.   def has_lotto_ticket?(number) @lotto_tickets.include?(number) end
    92.   attr_reader :lotto_tickets, :winner_tickets
    93. end
    94. class KLottoShop
    95.   include KLotto
    96.   def initialize
    97.     options = KLotto.options
    98.     @id = options.delete(:id) || 0
    99.     @name = options.delete(:name) || GENERIC_NAME
    100.     @cost = options.delete(:cost) || TICKET_PRICE
    101.     @prizes = options.delete(:prizes) || DEFAULT_GOLD
    102.     @spheres_max = options.delete(:total) || SPHERES_MIN
    103.     @raffles_max = @prizes.size
    104.     @raffles = 0
    105.     @spheres = {}
    106.     @indexes = Array.new(@spheres_max, 0)
    107.     @radius_x = 24
    108.     @radius_y = 64
    109.     @d = 2.0 * Math::PI / @spheres_max
    110.     @moving_frames = 15
    111.     @cy = 208
    112.     @x_offset = []
    113.     @sprites = []
    114.     @gold_label = $data_system.currency_unit
    115.     @stage = :main
    116.   end
    117.   def main
    118.     @width = $HIDDENCHEST ? Graphics.width : 640
    119.     h = 36
    120.     @bg = Sprite.new
    121.     @bg.bitmap = SceneManager.background_bitmap
    122.     @bg.color.set(16, 16, 16, 128)
    123.     @sprites << @shop_label = Sprite.new
    124.     @shop_label.x = 120
    125.     @shop_label.y = 4
    126.     b = Bitmap.new(@width - 240, NAME_FONT_SIZE + 4)
    127.     b.font.size = NAME_FONT_SIZE
    128.     b.draw_text(b.rect, @name, 1)
    129.     @shop_label.bitmap = b
    130.     h = PRIZE_LABEL_FONT_SIZE + 4
    131.     @sprites << @prize_label = Sprite.new
    132.     @prize_label.x = @plx = @width - 208
    133.     @prize_label.y = @ply = 32
    134.     @prize_label.bitmap = b = Bitmap.new(200, h)
    135.     b.font.size = PRIZE_LABEL_FONT_SIZE
    136.     b.draw_text(b.rect, PRIZES, 1)
    137.     make_prize_labels
    138.     sprite = @sprites[-1]
    139.     @sprites << @party_gold_label = Sprite.new
    140.     @party_gold_label.x = sprite.x
    141.     @party_gold_label.y = sprite.y + h + 8
    142.     @party_gold_label.bitmap = b = Bitmap.new(200, h)
    143.     b.font.size = PRIZE_LABEL_FONT_SIZE
    144.     b.draw_text(b.rect, PARTY_GOLD, 1)
    145.     @sprites << @gold_sprite = Sprite.new
    146.     @gold_sprite.x = @party_gold_label.x
    147.     @gold_sprite.y = @party_gold_label.y + h
    148.     @gold_bitmap = Bitmap.new(200, h)
    149.     refresh_party_gold
    150.     @gold_sprite.bitmap = @gold_bitmap
    151.     @sprites << @winner_label = Sprite.new
    152.     @winner_label.x = 4
    153.     @winner_label.y = 32
    154.     @winner_label.bitmap = b = Bitmap.new(208, WINNING_LABEL_FONT_SIZE + 4)
    155.     b.font.size = WINNING_LABEL_FONT_SIZE
    156.     b.draw_text(b.rect, WINNING_TICKET_LABEL, 1)
    157.     @sprites << @winner_ticket = Sprite.new
    158.     @winner_ticket.x = 8
    159.     @winner_ticket.y = 58
    160.     @winner_bitmap = Bitmap.new(200, WINNING_NUMBER_FONT_SIZE + 4)
    161.     @winner_bitmap.font.size = WINNING_NUMBER_FONT_SIZE
    162.     @winner_ticket.bitmap = @winner_bitmap
    163.     make_past_tickets
    164.     refresh_past_tickets_list
    165.     make_spheres
    166.     Graphics.transition
    167.     main_loop while @stage
    168.     terminate
    169.   end
    170.   def terminate
    171.     Graphics.freeze
    172.     @spheres_max.times do |n|
    173.       @spheres[n].each{|s| s.dispose }
    174.     end
    175.     @spheres.clear
    176.     @sprites.each{|s| s.dispose }
    177.     @sprites.clear
    178.     @bg.dispose
    179.     $game_party.discard_lotto_tickets
    180.   end
    181.   def make_prize_labels
    182.     @raffles_max.times do |n|
    183.       h = PRIZE_FONT_SIZES[n]
    184.       @sprites << sprite = Sprite.new
    185.       sprite.x = @plx
    186.       sprite.y = @ply - 4 + h + n * 4 + 24 * n
    187.       sprite.bitmap = bit = Bitmap.new(200, h)
    188.       bit.font.size = h
    189.       bit.draw_text(bit.rect, DEFAULT_GOLD[n].to_s, 1)
    190.     end
    191.   end
    192.   def make_spheres
    193.     spheres = Cache.picture(FILENAME)
    194.     sh = spheres.height
    195.     @spheres_max.times do |m|
    196.       @spheres[m] = slot = []
    197.       w = SPHERE_WIDTH * m
    198.       @x_offset << offset = m * 36
    199.       10.times do |n|
    200.         sprite = Sprite.new
    201.         sprite.extend(LottoSpriteMod)
    202.         sprite.number = n.to_s
    203.         rand(4) % 2 == 0 ? slot.push(sprite) : slot.unshift(sprite)
    204.         sprite.x = FIRST_SPHERE_X + offset - 8
    205.         sprite.y = @cy
    206.         sprite.z = 1000
    207.         sprite.bitmap = spheres.dup
    208.         sprite.bitmap.draw_text(w, 0, SPHERE_WIDTH, 24, sprite.number, 1)
    209.         sprite.src_rect.set(w, 0, SPHERE_WIDTH, sh)
    210.       end
    211.       @indexes[m] = slot[-1].number.to_i
    212.     end
    213.     spheres.dispose
    214.   end
    215.   def make_past_tickets
    216.     @sprites << @past_tickets_label = Sprite.new
    217.     @past_tickets_label.x = 8
    218.     @past_tickets_label.y = @winner_ticket.y + PREVIOUS_TICKETS_FONT_SIZE + 16
    219.     h = PREVIOUS_TICKETS_FONT_SIZE + 4
    220.     @past_tickets_label.bitmap = b = Bitmap.new(200, h)
    221.     b.draw_text(b.rect, PAST_WINNING_TICKETS_LABEL, 1)
    222.     @sprites << @past_tickets = Sprite.new
    223.     @past_tickets.x = 8
    224.     @past_tickets.y = @past_tickets_label.y + 28
    225.     @past_bitmap = Bitmap.new(200, PREVIOUS_TICKETS_MAX * 24 + 4)
    226.     @past_tickets.bitmap = @past_bitmap
    227.   end
    228.   def refresh_past_tickets_list
    229.     @past_bitmap.clear
    230.     tickets = $game_system.winner_tickets
    231.     max = tickets.size
    232.     w = @past_bitmap.width
    233.     max.times{|n| @past_bitmap.draw_text(0, n * 24, w, 24, tickets[n], 1) }
    234.   end
    235.   def refresh_party_gold
    236.     @gold_bitmap.clear
    237.     @gold_bitmap.font.size = PRIZE_LABEL_FONT_SIZE
    238.     @gold_bitmap.draw_text(@gold_bitmap.rect, $game_party.gold.to_s, 1)
    239.   end
    240.   def main_loop
    241.     Graphics.update
    242.     Input.update
    243.     update
    244.   end
    245.   def update
    246.     if @stage == :main
    247.       update_start
    248.     elsif @stage == :spin
    249.       update_spheres
    250.     elsif @stage == :fall
    251.       update_fall
    252.     elsif @stage == :standby
    253.       update_stand_by
    254.     elsif @stage == :exit
    255.       update_exit
    256.     end
    257.   end
    258.   def update_start
    259.     if Input.trigger?(Input::B)
    260.       update_exit
    261.       return
    262.     elsif Input.trigger?(Input::C)
    263.       Sound.play_ok
    264.       @raffles += 1
    265.       @digits = ''
    266.       @steps = 60 + rand(40)
    267.       @stage = :spin
    268.     end
    269.   end
    270.   def update_spheres
    271.     d1 = -@d / @moving_frames * 2
    272.     @spheres_max.times do |m|
    273.       col = @spheres[m]
    274.       10.times do |n|
    275.         o = n - @indexes[m]
    276.         d = @d * o + d1 * @steps
    277.         sx = FIRST_SPHERE_X + @x_offset[m] - 20
    278.         sphere = col[n]
    279.         sphere.x = sx - (@radius_x * Math.sin(d)).round
    280.         sphere.y = @cy - 60 + (@radius_y * Math.cos(d)).round
    281.       end
    282.     end
    283.     @steps -= 1
    284.     @stage = :fall if @steps == 0
    285.   end
    286.   def update_fall
    287.     Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)
    288.     @spheres_max.times do |m|
    289.       offset = @x_offset[m]
    290.       col = @spheres[m]
    291.       z_pos = []
    292.       10.times do |n|
    293.         z_order = rand(100)
    294.         random = rand(50) % 3
    295.         sprite = col[n]
    296.         sprite.x = FIRST_SPHERE_X + offset - 8
    297.         sprite.y = @cy
    298.         sprite.z = 1000 + (rand(160) % 3 == 0 ? z_order : -z_order)
    299.         z_pos = sprite.z
    300.       end
    301.       sprite = col.sort{|a,b| b.z <=> a.z }[0]
    302.       @digits += sprite.number
    303.     end
    304.     @winner_bitmap.font.size = WINNING_NUMBER_FONT_SIZE
    305.     @winner_bitmap.draw_text(@winner_bitmap.rect, @digits, 1)
    306.     @stage = :standby
    307.   end
    308.   def update_stand_by
    309.     return unless Input.trigger?(Input::B) or Input.trigger?(Input::C)
    310.     Sound.play_ok
    311.     $game_system.winner_tickets << @digits
    312.     $game_system.tickets_maintenance
    313.     refresh_past_tickets_list
    314.     @winner_bitmap.clear
    315.     if $game_party.has_lotto_ticket?(@digits)
    316.       $game_party.winning_tickets << KLottoTicket.new(@digits)
    317.       $game_party.gain_gold(@prizes[@raffles - 1])
    318.       refresh_party_gold
    319.     end
    320.     @stage = @raffles_max > @raffles ? :main : :exit
    321.   end
    322.   def update_exit
    323.     Sound.play_cancel
    324.     $game_party.discard_lotto_tickets
    325.     SceneManager.goto(Scene_Map)
    326.     @stage = nil
    327.   end
    328. end
    复制代码


    Terms & Conditions

    You must include my nickname and the current website's URL in your game credits. Do not repost it anywhere else!
    Free for non commercial games.


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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 11:38 , Processed in 0.122279 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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