扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 175|回复: 0

[转载发布] 第二货币商店

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

    连续签到: 1 天

    [LV.7]常住居民III

    2358

    主题

    428

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    11519
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    14333

    灌水之王

    发表于 2024-4-19 18:24:10 | 显示全部楼层 |阅读模式
    脚本内容
    1. SG_ID = 100#存储第二货币的变量SG_NA = "灵魂"#第二货币的单位module RPG  class Weapon    def sgprice      arr = @description.split(/SG/)      return arr[1].to_i if arr[1] != nil      return 0    end    def description      arr = @description.split(/SG/)      return arr[0] if arr[1] != nil      return @description    end  end  class Armor    def sgprice      arr = @description.split(/SG/)      return arr[1].to_i if arr[1] != nil      return 0    end    def description      arr = @description.split(/SG/)      return arr[0] if arr[1] != nil      return @description    end  end  class Item    def sgprice      arr = @description.split(/SG/)      return arr[1].to_i if arr[1] != nil      return 0    end    def description      arr = @description.split(/SG/)      return arr[0] if arr[1] != nil      return @description    end  endendclass Scene_SGShop < Scene_Shop  def main    # 生成帮助窗口    @help_window = Window_Help.new    # 生成指令窗口    @command_window = Window_ShopCommand.new    # 生成金钱窗口    @gold_window = Window_SGold.new    @gold_window.x = 480    @gold_window.y = 64    # 生成时间窗口    @dummy_window = Window_Base.new(0, 128, 640, 352)    # 生成购买窗口    @buy_window = Window_SGShopBuy.new($game_temp.shop_goods)    @buy_window.active = false    @buy_window.visible = false    @buy_window.help_window = @help_window    # 生成卖出窗口    @sell_window = Window_SGShopSell.new    @sell_window.active = false    @sell_window.visible = false    @sell_window.help_window = @help_window    # 生成数量输入窗口    @number_window = Window_ShopNumber.new    @number_window.active = false    @number_window.visible = false    # 生成状态窗口    @status_window = Window_ShopStatus.new    @status_window.visible = false    # 执行过渡    Graphics.transition    # 主循环    loop do      # 刷新游戏画面      Graphics.update      # 刷新输入信息      Input.update      # 刷新画面      update      # 如果画面切换的话就中断循环      if $scene != self        break      end    end    # 准备过渡    Graphics.freeze    # 释放窗口    @help_window.dispose    @command_window.dispose    @gold_window.dispose    @dummy_window.dispose    @buy_window.dispose    @sell_window.dispose    @number_window.dispose    @status_window.dispose  end  def update_buy    # 设置状态窗口的物品    @status_window.item = @buy_window.item    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 窗口状态转向初期模式      @command_window.active = true      @dummy_window.visible = true      @buy_window.active = false      @buy_window.visible = false      @status_window.visible = false      @status_window.item = nil      # 删除帮助文本      @help_window.set_text("")      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 获取物品      @item = @buy_window.item      # 物品无效的情况下、或者价格在所持金以上的情况下      if @item == nil or @item.sgprice > $game_variables[SG_ID]        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 获取物品所持数      case @item      when RPG::Item        number = $game_party.item_number(@item.id)      when RPG::Weapon        number = $game_party.weapon_number(@item.id)      when RPG::Armor        number = $game_party.armor_number(@item.id)      end      # 如果已经拥有了 99 个情况下      if number == 99        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 演奏确定 SE      $game_system.se_play($data_system.decision_se)      # 计算可以最多购买的数量      max = @item.sgprice == 0 ? 99 : $game_variables[SG_ID] / @item.sgprice      max = [max, 99 - number].min      # 窗口状态转向数值输入模式      @buy_window.active = false      @buy_window.visible = false      @number_window.set(@item, max, @item.sgprice)      @number_window.active = true      @number_window.visible = true    end  end  #--------------------------------------------------------------------------  # ● 画面更新 (卖出窗口激活的情况下)  #--------------------------------------------------------------------------  def update_sell    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 窗口状态转向初期模式      @command_window.active = true      @dummy_window.visible = true      @sell_window.active = false      @sell_window.visible = false      @status_window.item = nil      # 删除帮助文本      @help_window.set_text("")      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 获取物品      @item = @sell_window.item      # 设置状态窗口的物品      @status_window.item = @item      # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下      if @item == nil or @item.sgprice == 0        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 演奏确定 SE      $game_system.se_play($data_system.decision_se)      # 获取物品的所持数      case @item      when RPG::Item        number = $game_party.item_number(@item.id)      when RPG::Weapon        number = $game_party.weapon_number(@item.id)      when RPG::Armor        number = $game_party.armor_number(@item.id)      end      # 最大卖出个数 = 物品的所持数      max = number      # 窗口状态转向个数输入模式      @sell_window.active = false      @sell_window.visible = false      @number_window.set(@item, max, @item.sgprice / 2)      @number_window.active = true      @number_window.visible = true      @status_window.visible = true    end  end  def update_number    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 设置个数输入窗口为不活动·非可视状态      @number_window.active = false      @number_window.visible = false      # 命令窗口光标位置分支      case @command_window.index      when 0  # 购买        # 窗口状态转向购买模式        @buy_window.active = true        @buy_window.visible = true      when 1  # 卖出        # 窗口状态转向卖出模式        @sell_window.active = true        @sell_window.visible = true        @status_window.visible = false      end      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 演奏商店 SE      $game_system.se_play($data_system.shop_se)      # 设置个数输入窗口为不活动·非可视状态      @number_window.active = false      @number_window.visible = false      # 命令窗口光标位置分支      case @command_window.index      when 0  # 购买        # 购买处理        $game_variables[SG_ID] -= (@number_window.number * @item.sgprice)        case @item        when RPG::Item          $game_party.gain_item(@item.id, @number_window.number)        when RPG::Weapon          $game_party.gain_weapon(@item.id, @number_window.number)        when RPG::Armor          $game_party.gain_armor(@item.id, @number_window.number)        end        # 刷新各窗口        @gold_window.refresh        @buy_window.refresh        @status_window.refresh        # 窗口状态转向购买模式        @buy_window.active = true        @buy_window.visible = true      when 1  # 卖出        # 卖出处理        $game_variables[SG_ID] += (@number_window.number * (@item.sgprice/2))        case @item        when RPG::Item          $game_party.lose_item(@item.id, @number_window.number)        when RPG::Weapon          $game_party.lose_weapon(@item.id, @number_window.number)        when RPG::Armor          $game_party.lose_armor(@item.id, @number_window.number)        end        # 刷新各窗口        @gold_window.refresh        @sell_window.refresh        @status_window.refresh        # 窗口状态转向卖出模式        @sell_window.active = true        @sell_window.visible = true        @status_window.visible = false      end      return    end  endend#=============#窗口#=============class Window_SGold < Window_Base  def initialize    super(0, 0, 160, 64)    self.contents = Bitmap.new(width - 32, height - 32)    refresh  end  def refresh    self.contents.clear    cx = contents.text_size(SG_NA).width    self.contents.font.color = normal_color    self.contents.draw_text(4, 0, 120-cx-2, 32, $game_variables[SG_ID].to_s, 2)    self.contents.font.color = system_color    self.contents.draw_text(124-cx, 0, cx, 32, SG_NA, 2)  endendclass Window_SGShopBuy < Window_ShopBuy  def draw_item(index)    item = @data[index]    # 获取物品所持数    case item    when RPG::Item      number = $game_party.item_number(item.id)    when RPG::Weapon      number = $game_party.weapon_number(item.id)    when RPG::Armor      number = $game_party.armor_number(item.id)    end    # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色    # 除此之外的情况设置为无效文字色    if item.sgprice  0      self.contents.font.color = normal_color    else      self.contents.font.color = disabled_color    end    x = 4 + index % 2 * (288 + 32)    y = index / 2 * 32    rect = Rect.new(x, y, self.width / @column_max - 32, 32)    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))    bitmap = RPG::Cache.icon(item.icon_name)    opacity = self.contents.font.color == normal_color ? 255 : 128    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)  endendclass Window_SGShopNumber < Window_ShopNumber  def refresh    self.contents.clear    draw_item_name(@item, 4, 96)    self.contents.font.color = normal_color    self.contents.draw_text(272, 96, 32, 32, "×")    self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2)    self.cursor_rect.set(304, 96, 32, 32)    # 描绘合计价格和货币单位    domination = SG_NA    cx = contents.text_size(domination).width    total_price = @price * @number    self.contents.font.color = normal_color    self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2)    self.contents.font.color = system_color    self.contents.draw_text(332-cx, 160, cx, 32, domination, 2)  endendclass Scene_Map  def call_shop    # 清除商店调用标志    $game_temp.shop_calling = false    # 矫正主角姿势    $game_player.straighten    # 切换到商店画面    if $game_temp.sgshop_calling      $scene = Scene_SGShop.new    else      $scene = Scene_Shop.new    end    $game_temp.sgshop_calling = false  endendclass Interpreter  def command_sgshop    $game_temp.sgshop_calling = true  endendclass Game_Temp  attr_accessor:sgshop_calling  alias initialize_new initialize  def initialize    initialize_new    @sgshop_calling = false  endend复制代码
    复制代码
    用法如图:

    在商店处理前加入脚本command_sgshop便是第二货币商店
    不加便是普通商店
    定义价格方法,在说明里面添加SGxxx,xxx为价格。即SG199就是价值199第二货币(你如果无聊的话,貌似可以设置成负数- -)

    范例地址
    http://rpg.blue/UP_PIC/200801/第二货币商店_96845380.rar






    ==========分割线·希望版主发布以上内容=============









    顺便附上无聊版本,这个和普通版本最大的区别就是:没有占用游戏变量,貌似更正规一点
    但却不能和站上默认的第二货币脚本以及魔法商店脚本关联,不适合新手使用(众人:其实区别也就几行,使你自己偷懒不愿意整合相关脚本。某冰:都说是无聊版本了,一般人用普通脚本就可以满足了- -)
    1. SG_NA = "灵魂"#第二货币的单位module RPG  class Weapon    def sgprice      arr = @description.split(/SG/)      return arr[1].to_i if arr[1] != nil      return 0    end    def description      arr = @description.split(/SG/)      return arr[0] if arr[1] != nil      return @description    end  end  class Armor    def sgprice      arr = @description.split(/SG/)      return arr[1].to_i if arr[1] != nil      return 0    end    def description      arr = @description.split(/SG/)      return arr[0] if arr[1] != nil      return @description    end  end  class Item    def sgprice      arr = @description.split(/SG/)      return arr[1].to_i if arr[1] != nil      return 0    end    def description      arr = @description.split(/SG/)      return arr[0] if arr[1] != nil      return @description    end  endendclass Scene_SGShop < Scene_Shop  def main    # 生成帮助窗口    @help_window = Window_Help.new    # 生成指令窗口    @command_window = Window_ShopCommand.new    # 生成金钱窗口    @gold_window = Window_SGold.new    @gold_window.x = 480    @gold_window.y = 64    # 生成时间窗口    @dummy_window = Window_Base.new(0, 128, 640, 352)    # 生成购买窗口    @buy_window = Window_SGShopBuy.new($game_temp.shop_goods)    @buy_window.active = false    @buy_window.visible = false    @buy_window.help_window = @help_window    # 生成卖出窗口    @sell_window = Window_SGShopSell.new    @sell_window.active = false    @sell_window.visible = false    @sell_window.help_window = @help_window    # 生成数量输入窗口    @number_window = Window_ShopNumber.new    @number_window.active = false    @number_window.visible = false    # 生成状态窗口    @status_window = Window_ShopStatus.new    @status_window.visible = false    # 执行过渡    Graphics.transition    # 主循环    loop do      # 刷新游戏画面      Graphics.update      # 刷新输入信息      Input.update      # 刷新画面      update      # 如果画面切换的话就中断循环      if $scene != self        break      end    end    # 准备过渡    Graphics.freeze    # 释放窗口    @help_window.dispose    @command_window.dispose    @gold_window.dispose    @dummy_window.dispose    @buy_window.dispose    @sell_window.dispose    @number_window.dispose    @status_window.dispose  end  def update_buy    # 设置状态窗口的物品    @status_window.item = @buy_window.item    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 窗口状态转向初期模式      @command_window.active = true      @dummy_window.visible = true      @buy_window.active = false      @buy_window.visible = false      @status_window.visible = false      @status_window.item = nil      # 删除帮助文本      @help_window.set_text("")      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 获取物品      @item = @buy_window.item      # 物品无效的情况下、或者价格在所持金以上的情况下      if @item == nil or @item.sgprice > $game_party.sgold        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 获取物品所持数      case @item      when RPG::Item        number = $game_party.item_number(@item.id)      when RPG::Weapon        number = $game_party.weapon_number(@item.id)      when RPG::Armor        number = $game_party.armor_number(@item.id)      end      # 如果已经拥有了 99 个情况下      if number == 99        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 演奏确定 SE      $game_system.se_play($data_system.decision_se)      # 计算可以最多购买的数量      max = @item.sgprice == 0 ? 99 : $game_party.sgold / @item.sgprice      max = [max, 99 - number].min      # 窗口状态转向数值输入模式      @buy_window.active = false      @buy_window.visible = false      @number_window.set(@item, max, @item.sgprice)      @number_window.active = true      @number_window.visible = true    end  end  #--------------------------------------------------------------------------  # ● 画面更新 (卖出窗口激活的情况下)  #--------------------------------------------------------------------------  def update_sell    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 窗口状态转向初期模式      @command_window.active = true      @dummy_window.visible = true      @sell_window.active = false      @sell_window.visible = false      @status_window.item = nil      # 删除帮助文本      @help_window.set_text("")      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 获取物品      @item = @sell_window.item      # 设置状态窗口的物品      @status_window.item = @item      # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下      if @item == nil or @item.sgprice == 0        # 演奏冻结 SE        $game_system.se_play($data_system.buzzer_se)        return      end      # 演奏确定 SE      $game_system.se_play($data_system.decision_se)      # 获取物品的所持数      case @item      when RPG::Item        number = $game_party.item_number(@item.id)      when RPG::Weapon        number = $game_party.weapon_number(@item.id)      when RPG::Armor        number = $game_party.armor_number(@item.id)      end      # 最大卖出个数 = 物品的所持数      max = number      # 窗口状态转向个数输入模式      @sell_window.active = false      @sell_window.visible = false      @number_window.set(@item, max, @item.sgprice / 2)      @number_window.active = true      @number_window.visible = true      @status_window.visible = true    end  end  def update_number    # 按下 B 键的情况下    if Input.trigger?(Input::B)      # 演奏取消 SE      $game_system.se_play($data_system.cancel_se)      # 设置个数输入窗口为不活动·非可视状态      @number_window.active = false      @number_window.visible = false      # 命令窗口光标位置分支      case @command_window.index      when 0  # 购买        # 窗口状态转向购买模式        @buy_window.active = true        @buy_window.visible = true      when 1  # 卖出        # 窗口状态转向卖出模式        @sell_window.active = true        @sell_window.visible = true        @status_window.visible = false      end      return    end    # 按下 C 键的情况下    if Input.trigger?(Input::C)      # 演奏商店 SE      $game_system.se_play($data_system.shop_se)      # 设置个数输入窗口为不活动·非可视状态      @number_window.active = false      @number_window.visible = false      # 命令窗口光标位置分支      case @command_window.index      when 0  # 购买        # 购买处理        $game_party.sgold -= (@number_window.number * @item.sgprice)        case @item        when RPG::Item          $game_party.gain_item(@item.id, @number_window.number)        when RPG::Weapon          $game_party.gain_weapon(@item.id, @number_window.number)        when RPG::Armor          $game_party.gain_armor(@item.id, @number_window.number)        end        # 刷新各窗口        @gold_window.refresh        @buy_window.refresh        @status_window.refresh        # 窗口状态转向购买模式        @buy_window.active = true        @buy_window.visible = true      when 1  # 卖出        # 卖出处理        $game_party.sgold += (@number_window.number * (@item.sgprice/2))        case @item        when RPG::Item          $game_party.lose_item(@item.id, @number_window.number)        when RPG::Weapon          $game_party.lose_weapon(@item.id, @number_window.number)        when RPG::Armor          $game_party.lose_armor(@item.id, @number_window.number)        end        # 刷新各窗口        @gold_window.refresh        @sell_window.refresh        @status_window.refresh        # 窗口状态转向卖出模式        @sell_window.active = true        @sell_window.visible = true        @status_window.visible = false      end      return    end  endend#=============#窗口#=============class Window_SGold < Window_Base  def initialize    super(0, 0, 160, 64)    self.contents = Bitmap.new(width - 32, height - 32)    refresh  end  def refresh    self.contents.clear    cx = contents.text_size(SG_NA).width    self.contents.font.color = normal_color    self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.sgold.to_s, 2)    self.contents.font.color = system_color    self.contents.draw_text(124-cx, 0, cx, 32, SG_NA, 2)  endendclass Window_SGShopBuy < Window_ShopBuy  def draw_item(index)    item = @data[index]    # 获取物品所持数    case item    when RPG::Item      number = $game_party.item_number(item.id)    when RPG::Weapon      number = $game_party.weapon_number(item.id)    when RPG::Armor      number = $game_party.armor_number(item.id)    end    # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色    # 除此之外的情况设置为无效文字色    if item.sgprice  0      self.contents.font.color = normal_color    else      self.contents.font.color = disabled_color    end    x = 4 + index % 2 * (288 + 32)    y = index / 2 * 32    rect = Rect.new(x, y, self.width / @column_max - 32, 32)    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))    bitmap = RPG::Cache.icon(item.icon_name)    opacity = self.contents.font.color == normal_color ? 255 : 128    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)  endendclass Window_SGShopNumber < Window_ShopNumber  def refresh    self.contents.clear    draw_item_name(@item, 4, 96)    self.contents.font.color = normal_color    self.contents.draw_text(272, 96, 32, 32, "×")    self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2)    self.cursor_rect.set(304, 96, 32, 32)    # 描绘合计价格和货币单位    domination = SG_NA    cx = contents.text_size(domination).width    total_price = @price * @number    self.contents.font.color = normal_color    self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2)    self.contents.font.color = system_color    self.contents.draw_text(332-cx, 160, cx, 32, domination, 2)  endendclass Scene_Map  def call_shop    # 清除商店调用标志    $game_temp.shop_calling = false    # 矫正主角姿势    $game_player.straighten    # 切换到商店画面    if $game_temp.sgshop_calling      $scene = Scene_SGShop.new    else      $scene = Scene_Shop.new    end    $game_temp.sgshop_calling = false  endendclass Interpreter  def command_sgshop    $game_temp.sgshop_calling = true  end  def gain_sgold(n)    $game_party.gain_sgold(n)  end  def lose_sgold(n)    $game_party.lose_sgold(n)  endendclass Game_Party  attr_accessor:sgold   alias initialize_new initialize  def initialize    initialize_new    @sgold = 0  end  def gain_sgold(n)    @sgold = [[@sgold + n, 0].max, 9999999].min  end  def lose_sgold(n)    gain_sgold(-n)  endendclass Game_Temp  attr_accessor:sgshop_calling  alias initialize_new initialize  def initialize    initialize_new    @sgshop_calling = false  endend复制代码
    复制代码
    用法:
    召唤商店部分相同,区别在于如何获取第二货币。通过事件内嵌脚本gain_sgold(n)或者lose_gold(n)实现
    范例同
                 本帖来自P1论坛作者凌冰,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=94428  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

    关闭

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2025-5-4 17:38 , Processed in 0.114910 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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