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

[转载发布] KLotto VX

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 207 天

    连续签到: 1 天

    [LV.7]常住居民III

    3646

    主题

    862

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 12:29 | 显示全部楼层 |阅读模式
    KLotto VX

    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 Script
                    Code:       
    # * KLotto VX#   Scripter : Kyonides Arkanthes#   v1.0.6 - 2019-11-19# This scriptlet will let you partake in raffles. Once the raffles are over, the# scene will change back to the current map.# * Script Calls *# $scene = KLottoShop.new#   Opens the shop with default values.# $scene = KLottoShop.new(SOME_HASH)# The following options you can use to replace SOME_HASH are optional.#   :id => 1                   - Changes the shop ID.#   :name => 'Claudia's Lotto' - Changes the shop's name.#   :cost => 25                - Changes the ticket cost.#   :prizes => [25000, 5000]   - Changes the amount of the prize.#   :max => 5                  - Changes the number of columns aka digits.# $game_system.winner_tickets#   Array of Strings - List of previous winner tickets.# $game_party.winner_tickets#   Array of Strings - List of winner tickets the party has ever purchased.# $game_party.purchase_lotto_tickets# $game_party.purchase_lotto_tickets(Total)#   Yes, via a script call you can let the player buy some tickets.#   The Total number can be omitted, its default value is 1.# $game_party.has_lotto_ticket?(String)#   String should be a Number converted to a String by calling Number.to_s# $game_party.discard_lotto_tickets#   Forces the player to dispose of every single lotto ticket.module KLotto  TICKET_ITEM_ID = 31  PREVIOUS_TICKETS_MAX = 10  TICKET_PRICE = 10  DEFAULT_GOLD = [10000, 5000, 2000]  SPHERES_MIN = 3  SPHERE_WIDTH = 32 # In Pixels  FIRST_SPHERE_X = 280  DISCARD_AFTER_ONE_RAFFLE = true # Discard Tickets after a raffle?  FILENAME = 'spheres32'  SE_STARTUP = '056-Right02'  GENERIC_NAME = 'Generic Lotto'  PRIZES = 'Current Prizes'  PARTY_GOLD = 'Your Money'  WINNING_TICKET_LABEL = 'Winning Ticket'  PAST_WINNING_TICKETS_LABEL = 'Past Winning Tickets'  NAME_FONT_SIZE = 32  WINNING_LABEL_FONT_SIZE = 24  WINNING_NUMBER_FONT_SIZE = 32  PREVIOUS_TICKETS_FONT_SIZE = 24  PRIZE_LABEL_FONT_SIZE = 24  PRIZE_FONT_SIZES = [32, 28, 24]endmodule LottoSpriteMod  attr_accessor :numberendclass KLottoTicket  def initialize(number=nil)    @number = number || rand(10).to_s + rand(10).to_s + rand(10).to_s  end  attr_reader :numberendclass Game_System  alias :kyon_lotto_gm_sys_init :initialize  def initialize    kyon_lotto_gm_sys_init    @winner_tickets = []  end  def tickets_maintenance    length = @winner_tickets.size - KLotto::PREVIOUS_TICKETS_MAX    length.times{ @winner_tickets.shift }  end  attr_reader :winner_ticketsendclass Game_Party  alias :kyon_lotto_gm_party_init :initialize  def initialize    kyon_lotto_gm_party_init    @lotto_tickets = []    @winner_tickets = []  end  def purchase_lotto_tickets(total=1)    return 0 if total < 1    gain_item($data_items[KLotto::TICKET_ITEM_ID], total)    total.times{ @lotto_tickets << KLottoTicket.new }  end  def discard_lotto_tickets    gain_item(KLotto::TICKET_ITEM_ID, -@lotto_tickets.size)    @lotto_tickets.clear  end  def has_lotto_ticket?(number) @lotto_tickets.include?(number) end  attr_reader :lotto_tickets, :winner_ticketsendclass KLottoShop  include KLotto  def initialize(hsh={})    @id = hsh.delete(:id) || 0    @name = hsh.delete(:name) || GENERIC_NAME    @cost = hsh.delete(:cost) || TICKET_PRICE    @prizes = hsh.delete(:prizes) || DEFAULT_GOLD    @spheres_max = hsh.delete(:total) || SPHERES_MIN    @raffles_max = @prizes.size    @raffles = 0    @spheres = {}    @indexes = Array.new(@spheres_max, 0)    @radius_x = 24    @radius_y = 64    @d = 2.0 * Math::PI / @spheres_max    @moving_frames = 15    @cy = 208    @x_offset = []    @sprites = []    @gold_label = $data_system.terms.gold    @stage = :main  end  def main    @width = $HIDDENCHEST ? Graphics.width : 640    h = 36    @bg = Spriteset_Map.new    @sprites << @shop_label = Sprite.new    @shop_label.x = 120    @shop_label.y = 4    b = Bitmap.new(@width - 240, NAME_FONT_SIZE + 4)    b.font.size = NAME_FONT_SIZE    b.draw_text(b.rect, @name, 1)    @shop_label.bitmap = b    h = PRIZE_LABEL_FONT_SIZE + 4    @sprites << @prize_label = Sprite.new    @prize_label.x = @plx = @width - 208    @prize_label.y = @ply = 32    @prize_label.bitmap = b = Bitmap.new(200, h)    b.font.size = PRIZE_LABEL_FONT_SIZE    b.draw_text(b.rect, PRIZES, 1)    make_prize_labels    sprite = @sprites[-1]    @sprites << @party_gold_label = Sprite.new    @party_gold_label.x = sprite.x    @party_gold_label.y = sprite.y + h + 8    @party_gold_label.bitmap = b = Bitmap.new(200, h)    b.font.size = PRIZE_LABEL_FONT_SIZE    b.draw_text(b.rect, PARTY_GOLD, 1)    @sprites << @gold_sprite = Sprite.new    @gold_sprite.x = @party_gold_label.x    @gold_sprite.y = @party_gold_label.y + h    @gold_bitmap = Bitmap.new(200, h)    refresh_party_gold    @gold_sprite.bitmap = @gold_bitmap    @sprites << @winner_label = Sprite.new    @winner_label.x = 4    @winner_label.y = 32    @winner_label.bitmap = b = Bitmap.new(208, WINNING_LABEL_FONT_SIZE + 4)    b.font.size = WINNING_LABEL_FONT_SIZE    b.draw_text(b.rect, WINNING_TICKET_LABEL, 1)    @sprites << @winner_ticket = Sprite.new    @winner_ticket.x = 8    @winner_ticket.y = 58    @winner_bitmap = Bitmap.new(200, WINNING_NUMBER_FONT_SIZE + 4)    @winner_bitmap.font.size = WINNING_NUMBER_FONT_SIZE    @winner_ticket.bitmap = @winner_bitmap    make_past_tickets    refresh_past_tickets_list    make_spheres    Graphics.transition    loop do      Graphics.update      Input.update      update      break if $scene != self    end    Graphics.freeze    terminate  end  def terminate    @spheres_max.times do |n|      @spheres[n].each{|s| s.dispose }    end    @spheres.clear    @sprites.each{|s| s.dispose }    @sprites.clear    @bg.dispose    $game_party.discard_lotto_tickets  end  def make_prize_labels    @raffles_max.times do |n|      h = PRIZE_FONT_SIZES[n]      @sprites << sprite = Sprite.new      sprite.x = @plx      sprite.y = @ply - 4 + h + n * 4 + 24 * n      sprite.bitmap = bit = Bitmap.new(200, h)      bit.font.size = h      bit.draw_text(bit.rect, DEFAULT_GOLD[n].to_s, 1)    end  end  def make_spheres    spheres = Cache.picture(FILENAME)    sh = spheres.height    @spheres_max.times do |m|      @spheres[m] = slot = []      w = SPHERE_WIDTH * m      @x_offset << offset = m * 36      10.times do |n|        sprite = Sprite.new        sprite.extend(LottoSpriteMod)        sprite.number = n.to_s        rand(4) % 2 == 0 ? slot.push(sprite) : slot.unshift(sprite)        sprite.x = FIRST_SPHERE_X + offset - 8        sprite.y = @cy        sprite.z = 1000        sprite.bitmap = spheres.dup        sprite.bitmap.draw_text(w, 0, SPHERE_WIDTH, 24, sprite.number, 1)        sprite.src_rect.set(w, 0, SPHERE_WIDTH, sh)      end      @indexes[m] = slot[-1].number.to_i    end    spheres.dispose  end  def make_past_tickets    @sprites << @past_tickets_label = Sprite.new    @past_tickets_label.x = 8    @past_tickets_label.y = @winner_ticket.y + PREVIOUS_TICKETS_FONT_SIZE + 16    h = PREVIOUS_TICKETS_FONT_SIZE + 4    @past_tickets_label.bitmap = b = Bitmap.new(200, h)    b.draw_text(b.rect, PAST_WINNING_TICKETS_LABEL, 1)    @sprites << @past_tickets = Sprite.new    @past_tickets.x = 8    @past_tickets.y = @past_tickets_label.y + 28    @past_bitmap = Bitmap.new(200, PREVIOUS_TICKETS_MAX * 24 + 4)    @past_tickets.bitmap = @past_bitmap  end  def refresh_past_tickets_list    @past_bitmap.clear    tickets = $game_system.winner_tickets    max = tickets.size    w = @past_bitmap.width    max.times{|n| @past_bitmap.draw_text(0, n * 24, w, 24, tickets[n], 1) }  end  def refresh_party_gold    @gold_bitmap.clear    @gold_bitmap.font.size = PRIZE_LABEL_FONT_SIZE    @gold_bitmap.draw_text(@gold_bitmap.rect, $game_party.gold.to_s, 1)  end  def update    if @stage == :main      update_start    elsif @stage == :spin      update_spheres    elsif @stage == :fall      update_fall    elsif @stage == :standby      update_stand_by    else      update_exit    end  end  def update_start    if Input.trigger?(Input::B)      update_exit      return    elsif Input.trigger?(Input::C)      Sound.play_decision      @raffles += 1      @digits = ''      @steps = 60 + rand(40)      @stage = :spin    end  end  def update_spheres    d1 = -@d / @moving_frames * 2    @spheres_max.times do |m|      col = @spheres[m]      10.times do |n|        o = n - @indexes[m]        d = @d * o + d1 * @steps        sx = FIRST_SPHERE_X + @x_offset[m] - 20        sphere = col[n]        sphere.x = sx - (@radius_x * Math.sin(d)).round        sphere.y = @cy - 60 + (@radius_y * Math.cos(d)).round      end    end    @steps -= 1    @stage = :fall if @steps == 0  end  def update_fall    Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)    @spheres_max.times do |m|      offset = @x_offset[m]      col = @spheres[m]      z_pos = []      10.times do |n|        z_order = rand(100)        random = rand(50) % 3        sprite = col[n]        sprite.x = FIRST_SPHERE_X + offset - 8        sprite.y = @cy        sprite.z = 1000 + (rand(160) % 3 == 0 ? z_order : -z_order)        z_pos = sprite.z      end      sprite = col.sort{|a,b| b.z <=> a.z }[0]      @digits += sprite.number    end    @winner_bitmap.font.size = WINNING_NUMBER_FONT_SIZE    @winner_bitmap.draw_text(@winner_bitmap.rect, @digits, 1)    @stage = :standby  end  def update_stand_by    return unless Input.trigger?(Input::B) or Input.trigger?(Input::C)    Sound.play_decision    $game_system.winner_tickets << @digits    $game_system.tickets_maintenance    refresh_past_tickets_list    @winner_bitmap.clear    if $game_party.has_lotto_ticket?(@digits)      $game_party.winning_tickets << KLottoTicket.new(@digits)      $game_party.gain_gold(@prizes[@raffles - 1])      refresh_party_gold      if DISCARD_AFTER_ONE_RAFFLE        $game_party.discard_lotto_tickets        return @stage = nil      end    end    @stage = @raffles_max > @raffles ? :main : nil  end  def update_exit    Sound.play_cancel    $scene = Scene_Map.new  endend


    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-vx.115419/

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-10 01:13 , Processed in 0.109592 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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