查看: 5210|回复: 10

[已经解决] 请问怎么设置只可以买入不可以卖出的商店啊

[复制链接]
梦石
0
星屑
35
在线时间
0 小时
注册时间
2018-7-10
回帖
3
发表于 2018-7-11 06:43:16 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
如题,不会脚本真是我心中的痛
梦石
0
星屑
2504
在线时间
191 小时
注册时间
2018-5-11
回帖
96
发表于 2018-7-11 09:36:21 | 显示全部楼层
本帖最后由 RyanBern 于 2018-7-12 15:58 编辑
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================

  4. #只能购买的商店:
  5. #在商店前面一行事件添加脚本:$game_temp.shop_type = 1

  6. #只能卖出的商店:
  7. #在商店前面一行事件添加脚本:$game_temp.shop_type = 2

  8. #普通商店:不用改动。

  9. class Scene_Shop
  10.   # --------------------------
  11.   def main
  12.     @help_window = Window_Help.new
  13.     @command_window = Window_ShopCommand.new
  14.     @gold_window = Window_Gold.new
  15.     @gold_window.x = 480
  16.     @gold_window.y = 64
  17.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  18.     @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
  19.     @buy_window.active = false
  20.     @buy_window.visible = false
  21.     @buy_window.help_window = @help_window
  22.     @sell_window = Window_ShopSell.new
  23.     @sell_window.active = false
  24.     @sell_window.visible = false
  25.     @sell_window.help_window = @help_window
  26.     @number_window = Window_ShopNumber.new
  27.     @number_window.active = false
  28.     @number_window.visible = false
  29.     @status_window = Window_ShopStatus.new
  30.     @status_window.visible = false
  31.     if $game_temp.shop_type == 1
  32.       @command_window.index = 0
  33.       @command_window.active = false
  34.       @dummy_window.visible = false
  35.       @buy_window.active = true
  36.       @buy_window.visible = true
  37.       @buy_window.refresh
  38.       @status_window.visible = true
  39.     end
  40.     if $game_temp.shop_type == 2
  41.       @command_window.index = 1
  42.       @command_window.active = false
  43.       @dummy_window.visible = false
  44.       @sell_window.active = true
  45.       @sell_window.visible = true
  46.       @sell_window.refresh
  47.     end
  48.     Graphics.transition
  49.     loop do
  50.       Graphics.update
  51.       Input.update
  52.       update
  53.       if $scene != self
  54.         break
  55.       end
  56.     end
  57.     Graphics.freeze
  58.     @status_window.item = nil
  59.     @status_window.refresh
  60.     @help_window.dispose
  61.     @command_window.dispose
  62.     @gold_window.dispose
  63.     @dummy_window.dispose
  64.     @buy_window.dispose
  65.     @sell_window.dispose
  66.     @number_window.dispose
  67.     @status_window.dispose
  68.     $game_temp.shop_type = 0
  69.   end
  70.   # --------------------------
  71.   def update
  72.     @help_window.update
  73.     @command_window.update
  74.     @gold_window.update
  75.     @dummy_window.update
  76.     @buy_window.update
  77.     @sell_window.update
  78.     @number_window.update
  79.     @status_window.update
  80.     if @command_window.active
  81.       update_command
  82.       return
  83.     end
  84.     if @buy_window.active
  85.       update_buy
  86.       return
  87.     end
  88.     if @sell_window.active
  89.       update_sell
  90.       return
  91.     end
  92.     if @number_window.active
  93.       update_number
  94.       return
  95.     end
  96.   end
  97.   # --------------------------
  98.   def update_command
  99.     if Input.trigger?(Input::B)
  100.       $game_system.se_play($data_system.cancel_se)
  101.       $scene = Scene_Map.new
  102.       return
  103.     end
  104.     if Input.trigger?(Input::C)
  105.       case @command_window.index
  106.       when 0
  107.         $game_system.se_play($data_system.decision_se)
  108.         @command_window.active = false
  109.         @dummy_window.visible = false
  110.         @buy_window.active = true
  111.         @buy_window.visible = true
  112.         @buy_window.refresh
  113.         @status_window.visible = true
  114.       when 1
  115.         $game_system.se_play($data_system.decision_se)
  116.         @command_window.active = false
  117.         @dummy_window.visible = false
  118.         @sell_window.active = true
  119.         @sell_window.visible = true
  120.         @sell_window.refresh
  121.       when 2
  122.         $game_system.se_play($data_system.decision_se)
  123.         $scene = Scene_Map.new
  124.       end
  125.       return
  126.     end
  127.   end
  128.   # --------------------------
  129.   def update_buy
  130.     @status_window.item = @buy_window.item
  131.     if Input.trigger?(Input::B)
  132.       if $game_temp.shop_type == 1
  133.          $game_system.se_play($data_system.cancel_se)
  134.          $scene = Scene_Map.new
  135.       else
  136.       $game_system.se_play($data_system.cancel_se)
  137.       @command_window.active = true
  138.       @dummy_window.visible = true
  139.       @buy_window.active = false
  140.       @buy_window.visible = false
  141.       @status_window.visible = false
  142.       @status_window.item = nil
  143.       @help_window.set_text("")
  144.       end
  145.       return
  146.     end
  147.     if Input.trigger?(Input::C)
  148.       @item = @buy_window.item
  149.       if @item == nil or @item.price > $game_party.gold
  150.         $game_system.se_play($data_system.buzzer_se)
  151.         return
  152.       end
  153.       case @item
  154.       when RPG::Item
  155.         number = $game_party.item_number(@item.id)
  156.       when RPG::Weapon
  157.         number = $game_party.weapon_number(@item.id)
  158.       when RPG::Armor
  159.         number = $game_party.armor_number(@item.id)
  160.       end
  161.       if number == 99
  162.         $game_system.se_play($data_system.buzzer_se)
  163.         return
  164.       end
  165.       $game_system.se_play($data_system.decision_se)
  166.       max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  167.       max = [max, 99 - number].min
  168.       @buy_window.active = false
  169.       @buy_window.visible = false
  170.       @number_window.set(@item, max, @item.price)
  171.       @number_window.active = true
  172.       @number_window.visible = true
  173.     end
  174.   end
  175.   # --------------------------
  176.   def update_sell
  177.     if Input.trigger?(Input::B)
  178.       if $game_temp.shop_type == 2
  179.          $game_system.se_play($data_system.cancel_se)
  180.          $scene = Scene_Map.new
  181.       else
  182.       $game_system.se_play($data_system.cancel_se)
  183.       @command_window.active = true
  184.       @dummy_window.visible = true
  185.       @sell_window.active = false
  186.       @sell_window.visible = false
  187.       @status_window.item = nil
  188.       @help_window.set_text("")
  189.       return
  190.       end
  191.     end
  192.     if Input.trigger?(Input::C)
  193.       @item = @sell_window.item
  194.       @status_window.item = @item
  195.       if @item == nil or @item.price == 0
  196.         $game_system.se_play($data_system.buzzer_se)
  197.         return
  198.       end
  199.       $game_system.se_play($data_system.decision_se)
  200.       case @item
  201.       when RPG::Item
  202.         number = $game_party.item_number(@item.id)
  203.       when RPG::Weapon
  204.         number = $game_party.weapon_number(@item.id)
  205.       when RPG::Armor
  206.         number = $game_party.armor_number(@item.id)
  207.       end
  208.       max = number
  209.       @sell_window.active = false
  210.       @sell_window.visible = false
  211.       @number_window.set(@item, max, @item.price / 2)
  212.       @number_window.active = true
  213.       @number_window.visible = true
  214.       @status_window.visible = true
  215.     end
  216.   end
  217.   # --------------------------
  218.   def update_number
  219.     if Input.trigger?(Input::B)
  220.       $game_system.se_play($data_system.cancel_se)
  221.       @number_window.active = false
  222.       @number_window.visible = false
  223.       case @command_window.index
  224.       when 0
  225.         @buy_window.active = true
  226.         @buy_window.visible = true
  227.       when 1
  228.         @sell_window.active = true
  229.         @sell_window.visible = true
  230.         @status_window.visible = false
  231.       end
  232.       return
  233.     end
  234.     if Input.trigger?(Input::C)
  235.       $game_system.se_play($data_system.shop_se)
  236.       @number_window.active = false
  237.       @number_window.visible = false
  238.       case @command_window.index
  239.       when 0
  240.         $game_party.lose_gold(@number_window.number * @item.price)
  241.         case @item
  242.         when RPG::Item
  243.           $game_party.gain_item(@item.id, @number_window.number)
  244.         when RPG::Weapon
  245.           $game_party.gain_weapon(@item.id, @number_window.number)
  246.         when RPG::Armor
  247.           $game_party.gain_armor(@item.id, @number_window.number)
  248.         end
  249.         @gold_window.refresh
  250.         @buy_window.refresh
  251.         @status_window.refresh
  252.         @buy_window.active = true
  253.         @buy_window.visible = true
  254.       when 1
  255.         $game_party.gain_gold(@number_window.number * (@item.price / 2))
  256.         case @item
  257.         when RPG::Item
  258.           $game_party.lose_item(@item.id, @number_window.number)
  259.         when RPG::Weapon
  260.           $game_party.lose_weapon(@item.id, @number_window.number)
  261.         when RPG::Armor
  262.           $game_party.lose_armor(@item.id, @number_window.number)
  263.         end
  264.         @gold_window.refresh
  265.         @sell_window.refresh
  266.         @status_window.refresh
  267.         @sell_window.active = true
  268.         @sell_window.visible = true
  269.         @status_window.visible = false
  270.       end
  271.       return
  272.     end
  273.   end
  274. end




  275. class Window_ShopCommand < Window_Selectable
  276.   # ----------------------------------------
  277.   def initialize
  278.     super(0, 64, 480, 64)
  279.     self.contents = Bitmap.new(width - 32, height - 32)
  280.     @item_max = 3
  281.     @column_max = 3
  282.     @commands = ["购买", "卖出", "离开"]
  283.     self.contents.font.name = "黑体"
  284.     self.contents.font.size = 24
  285.     refresh
  286.     self.index = 0
  287.   end
  288.   # ----------------------------------------
  289.   def refresh
  290.     self.contents.clear
  291.     if $game_temp.shop_type == 0
  292.       for i in 0...@item_max
  293.       draw_item(i)
  294.       end
  295.     end
  296.     if $game_temp.shop_type == 1
  297.       self.contents.draw_text(4, 0, 324, 32, "只能购买,不能卖出")
  298.       self.index = -1
  299.       update_cursor_rect
  300.     end
  301.     if $game_temp.shop_type == 2
  302.       self.contents.draw_text(4, 0, 324, 32, "只能卖出,不能购买")
  303.       self.index = -1
  304.       update_cursor_rect
  305.     end
  306.   end
  307.   # ----------------------------------------
  308.   def draw_item(index)
  309.     x = 4 + index * 160
  310.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  311.   end
  312.   # ----------------------------------------
  313.   def update_cursor_rect
  314.     if $game_temp.shop_type == 0
  315.       super
  316.     end
  317.     if $game_temp.shop_type == 1 || $game_temp.shop_type == 2
  318.       self.cursor_rect.empty
  319.     end
  320.   end
  321. end
  322. class Game_Temp
  323.   # ----------------------------------------
  324.   attr_accessor :shop_type
  325.   alias ini initialize
  326.   def initialize
  327.     ini
  328.     @shop_type = 0
  329.   end
  330. end


  331. #==============================================================================
  332. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  333. #=========================================================================
复制代码

评分

参与人数 1星屑 +50 收起 理由
RyanBern + 50 认可答案

查看全部评分

人生总会有中二的时候,比如现在
回复

使用道具 举报

梦石
0
星屑
2504
在线时间
191 小时
注册时间
2018-5-11
回帖
96
发表于 2018-7-11 09:36:59 | 显示全部楼层
就是这个脚本,291行可以换字体
人生总会有中二的时候,比如现在
回复

使用道具 举报

梦石
0
星屑
2504
在线时间
191 小时
注册时间
2018-5-11
回帖
96
发表于 2018-7-11 09:42:47 | 显示全部楼层
这是以前的脚本,能用。以前66RPG上有的
人生总会有中二的时候,比如现在
回复

使用道具 举报

梦石
0
星屑
35
在线时间
0 小时
注册时间
2018-7-10
回帖
3
 楼主| 发表于 2018-7-11 12:54:21 | 显示全部楼层
18649119621 发表于 2018-7-11 09:42
这是以前的脚本,能用。以前66RPG上有的

超级感谢!
回复

使用道具 举报

梦石
0
星屑
35
在线时间
0 小时
注册时间
2018-7-10
回帖
3
 楼主| 发表于 2018-7-11 13:02:08 | 显示全部楼层
诶它说Window_Selectable没有被定义。
回复

使用道具 举报

梦石
0
星屑
2504
在线时间
191 小时
注册时间
2018-5-11
回帖
96
发表于 2018-7-11 13:23:31 | 显示全部楼层
可能有脚本冲突,把这个脚本换个位置试试
人生总会有中二的时候,比如现在
回复

使用道具 举报

梦石
0
星屑
2504
在线时间
191 小时
注册时间
2018-5-11
回帖
96
发表于 2018-7-11 13:25:36 | 显示全部楼层
我这里是没有问题的,你看一看输入脚本正确了没有
人生总会有中二的时候,比如现在
回复

使用道具 举报

梦石
0
星屑
35
在线时间
0 小时
注册时间
2018-7-10
回帖
3
 楼主| 发表于 2018-7-11 13:33:24 | 显示全部楼层
18649119621 发表于 2018-7-11 13:25
我这里是没有问题的,你看一看输入脚本正确了没有

可以用了!!谢谢!!!
回复

使用道具 举报

梦石
0
星屑
6245
在线时间
558 小时
注册时间
2018-6-5
回帖
125
发表于 2018-7-18 00:43:44 | 显示全部楼层
(xxx商人):是否购买一个x物品?
显示选择项:买,不买
买的场合:
条件分歧:金钱 y 以上时:
(xxx商人):购买成功。x物品+1。金钱-y。
除此以外的场合:
(xxx商人):卢布不足。
不买的场合:无
俄罗斯帝国末代沙皇尼古拉二世
#俄文转写 = Царь Николай II
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部