查看: 1757|回复: 0

[已经过期] 求整合魔法商店脚本

[复制链接]
梦石
0
星屑
80
在线时间
216 小时
注册时间
2011-9-17
回帖
125
发表于 2015-12-1 18:40:20 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 工藤~新一じ 于 2015-12-1 19:32 编辑

楼主昨天晚上发帖求修改限制型魔法商店的脚本,希望修改成扣除物品学技能的,等不到人回复,所以楼主自己研究了这段脚本,努力了几个小时,终于把这个效果实现了。
楼主是脚本盲,目前只是个懂一两句事件脚本的作者,但楼主有很多想法。
我还想在昨晚我改成功的物品学技能脚本里新增遗忘效果,也想让学习魔法的列表里简洁一些,只显示该主角可学的技能,但这两个效果对楼主来说实在太难实现了。所以楼主仍然保佑希望说论坛的大大能帮助我。
下面脚本第一个是我昨晚改成功的物品学技能脚本。
第二个是带有学习和遗忘效果的脚本。
第三个是把列表简洁,只显示对应角色可学技能的脚本。
楼主真心希望在第一个脚本里融入第二个脚本和第三个脚本的效果!在此先谢过,这个效果相信楼主现在的能力真的是做不出来了  


物品学技能,职业限制型魔法商店:(已测试)
  1. #==============================================================================
  2. # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
  3. #==============================================================================

  4. #——以下是一些自定义的内容
  5. #呼出魔法商店$scene = Scene_MShop.new([1,2,3,4,5,6,7,8])
  6. #在技能说明末尾增加@100,则学习此技能需要扣掉9号变量100

  7. $mShop_use_1 = "魔法水晶"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”

  8. $mShop_use_2 = "个"  #——这项是购买魔法特技的货币单位,如“点”、“¥”

  9. $mShop_use_variable = 9  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱

  10. $mShop_Window_Opacity = 200  #——这项是窗口透明度

  11. # 每个职业可以学的技能列表
  12. $class_canlearn_list = {  1 => [1,80],
  13.                           2 => [60,61],
  14.                           3 => []}

  15. #==============================================================================
  16. # ■ Window_MGold
  17. #------------------------------------------------------------------------------
  18. #  显示金钱的窗口。
  19. #==============================================================================
  20. class Window_MGold < Window_Base
  21.   #--------------------------------------------------------------------------
  22.   # ● 初始化窗口
  23.   #--------------------------------------------------------------------------
  24.   def initialize
  25.     super(0, 0, 272, 64)
  26.     self.contents = Bitmap.new(width - 32, height - 32)
  27.     refresh
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● 刷新
  31.   #--------------------------------------------------------------------------
  32.   def refresh
  33.     self.contents.clear
  34.     self.contents.font.color = system_color
  35.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  36.     self.contents.font.color = normal_color
  37.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  38.     self.contents.font.color = system_color
  39.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  40.   end
  41. end
  42. #==============================================================================
  43. # ■ Scene_MShop
  44. #------------------------------------------------------------------------------
  45. #  处理特技商店画面的类。
  46. #==============================================================================
  47. class Scene_MShop
  48.   #--------------------------------------------------------------------------
  49.   # ● 初始化
  50.   #--------------------------------------------------------------------------
  51.   def initialize(id)
  52.     @id = id
  53.   end  
  54.   #--------------------------------------------------------------------------
  55.   # ● 主处理
  56.   #--------------------------------------------------------------------------
  57.   def main
  58.     screen = Spriteset_Map.new
  59.     $game_variables[9] = $game_party.armor_number(951)
  60.     $game_party.remove_actor(997)#主角离开队伍
  61.     if $mShop_use_variable == 0
  62.       $mShop_gold = $game_party.gold
  63.     else
  64.       $mShop_gold = $game_variables[$mShop_use_variable]
  65.     end
  66.     # 生成帮助窗口
  67.     @help_window = Window_Help.new
  68.     @help_window.opacity = $mShop_Window_Opacity
  69.     # 生成金钱窗口
  70.     @gold_window = Window_MGold.new
  71.     @gold_window.x = 368
  72.     @gold_window.y = 416
  73.     @gold_window.opacity = $mShop_Window_Opacity
  74.     # 生成购买窗口
  75.     @buy_window = Window_MShopBuy.new(@id)
  76.     @buy_window.active = true
  77.     @buy_window.visible = true
  78.     @buy_window.help_window = @help_window
  79.     @buy_window.opacity = $mShop_Window_Opacity
  80.     # 生成状态窗口
  81.     @status_window = Window_MShopStatus.new
  82.     @status_window.visible = true
  83.     @status_window.active = false
  84.     @status_window.opacity = $mShop_Window_Opacity
  85.     # 执行过渡
  86.     Graphics.transition
  87.     # 主循环
  88.     loop do
  89.       # 刷新游戏画面
  90.       Graphics.update
  91.       # 刷新输入信息
  92.       Input.update
  93.       # 刷新画面
  94.       update
  95.       # 如果画面切换的话就中断循环
  96.       if $scene != self
  97.         break
  98.       end
  99.     end
  100.     # 准备过渡
  101.     Graphics.freeze
  102.     # 释放窗口
  103.     @help_window.dispose
  104.     #@mhelp_window.dispose
  105.     @gold_window.dispose
  106.     @buy_window.dispose
  107.     @status_window.dispose
  108.     screen.dispose
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 刷新画面
  112.   #--------------------------------------------------------------------------
  113.   def update
  114.     # 刷新窗口
  115.     @help_window.update
  116.     #@mhelp_window.update
  117.     @gold_window.update
  118.     @buy_window.update
  119.     @status_window.update
  120.     # 购买窗口激活的情况下: 调用 update_buy
  121.     if @buy_window.active
  122.       update_buy
  123.       return
  124.     end
  125.     if @status_window.active
  126.       update_status
  127.       return
  128.     end
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 刷新画面 (购买窗口激活的情况下)
  132.   #--------------------------------------------------------------------------
  133.   def update_buy
  134.     @status_window.skill = @buy_window.skill
  135.     if Input.trigger?(Input::B)
  136.       $game_system.se_play($data_system.cancel_se)
  137.       $game_variables[25] = $game_party.armor_number(951)
  138.       $game_variables[24] = $game_variables[25] - $game_variables[9]
  139.       $game_party.gain_armor(951,-$game_variables[24])
  140.       $game_party.add_actor(997)#主角加入队伍
  141.       $scene = Scene_Map.new
  142.       return
  143.     end
  144.     if Input.trigger?(Input::C)
  145.       @skill = @buy_window.skill
  146.       if @skill == nil or @skill.price > $mShop_gold
  147.         $game_system.se_play($data_system.buzzer_se)
  148.         return
  149.       end
  150.       $game_system.se_play($data_system.decision_se)
  151.       @buy_window.active = false
  152.       @status_window.index = 0
  153.       @status_window.active = true
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 刷新画面 (状态窗口激活的情况下)
  158.   #--------------------------------------------------------------------------
  159.   def update_status
  160.     if Input.trigger?(Input::B)
  161.       $game_system.se_play($data_system.cancel_se)
  162.       @status_window.active = false
  163.       @status_window.index = -1
  164.       @buy_window.active = true
  165.     end
  166.     actor = $game_party.actors[@status_window.index]
  167.     if Input.trigger?(Input::C)
  168.       can_learn=false
  169.       for j in $data_classes[actor.class_id].learnings
  170.         if j.skill_id == @skill.id
  171.           can_learn=true
  172.         end
  173.       end
  174.       
  175.       unless $class_canlearn_list[actor.class_id].nil?
  176.         can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
  177.       end

  178.       if can_learn==false
  179.         $game_system.se_play($data_system.cancel_se)
  180.         return
  181.       end
  182.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
  183.         $game_system.se_play($data_system.cancel_se)
  184.         return
  185.       else
  186.         $game_system.se_play($data_system.decision_se)
  187.         if $mShop_use_variable == 0
  188.           $game_party.gain_gold([email]-@skill.price[/email])
  189.           $mShop_gold -= @skill.price
  190.         else
  191.           $game_variables[$mShop_use_variable] -= @skill.price
  192.           $mShop_gold -= @skill.price
  193.         end
  194.         $game_party.actors[@status_window.index].learn_skill(@skill.id)
  195.         @gold_window.refresh
  196.         @buy_window.refresh
  197.         @status_window.refresh
  198.         @status_window.active = false
  199.         @status_window.index = -1
  200.         @buy_window.active = true
  201.       end      
  202.     end   
  203.   end
  204. end
  205. #==============================================================================
  206. # ■ Window_MShopStatus
  207. #------------------------------------------------------------------------------
  208. #  特技商店画面、显示物品所持数与角色装备的窗口。
  209. #==============================================================================
  210. class Window_MShopStatus < Window_Selectable
  211.   #--------------------------------------------------------------------------
  212.   # ● 初始化对像
  213.   #--------------------------------------------------------------------------
  214.   def initialize
  215.     super(368, 64, 272, 352)
  216.     self.contents = Bitmap.new(width - 32, height - 32)
  217.     self.contents.font.size = 18
  218.     @skill = nil
  219.     refresh
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 刷新
  223.   #--------------------------------------------------------------------------
  224.   def refresh
  225.     self.contents.clear
  226.     for i in 0...$game_party.actors.size
  227.       actor = $game_party.actors[i]
  228. #      draw_actor_graphic(actor,12,80*i+64)
  229.       self.contents.font.color = system_color
  230.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  231.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  232.       self.contents.font.color = normal_color
  233.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  234.       self.contents.font.color = system_color
  235.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  236.       self.contents.font.color = normal_color
  237.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  238.       self.contents.font.color = system_color
  239.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  240.       self.contents.font.color = normal_color
  241.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)   
  242.       can_learn=false
  243.       for j in $data_classes[actor.class_id].learnings
  244.         if j.skill_id == @skill.id
  245.           can_learn=true
  246.         end
  247.       end
  248.       unless $class_canlearn_list[actor.class_id].nil?
  249.         can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
  250.       end
  251.       
  252.       if can_learn == true
  253.         if actor.skill_learn?(@skill.id)
  254.           self.contents.font.color = Color.new(255,255,255,128)
  255.           self.contents.draw_text(44, 80*i+44, 196, 32, "已经学会改技能 ",2)        
  256.         else
  257.           self.contents.font.color = Color.new(255,255,0,255)
  258.           self.contents.draw_text(44, 80*i+44, 196, 32, "可以学会该技能 ",2)
  259.         end
  260.       else
  261.         self.contents.font.color = Color.new(255,255,255,128)
  262.         self.contents.draw_text(44, 80*i+44, 196, 32, "不适合学该技能 ",2)        
  263.       end
  264.     end
  265.     @item_max = $game_party.actors.size
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ● 设置物品
  269.   #     item : 新的物品
  270.   #--------------------------------------------------------------------------
  271.   def skill=(skill)
  272.     if @skill != skill
  273.       @skill = skill
  274.       refresh
  275.     end
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● 刷新光标矩形
  279.   #--------------------------------------------------------------------------
  280.   def update_cursor_rect
  281.     if @index < 0
  282.       self.cursor_rect.empty
  283.     else
  284.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  285.     end
  286.   end
  287. end
  288. #==============================================================================
  289. # ■ Window_MShopBuy
  290. #------------------------------------------------------------------------------
  291. #  特技商店画面、浏览显示可以购买的商品的窗口。
  292. #==============================================================================
  293. class Window_MShopBuy < Window_Selectable
  294.   #--------------------------------------------------------------------------
  295.   # ● 初始化对像
  296.   #     shop_goods : 商品
  297.   #--------------------------------------------------------------------------
  298.   def initialize(id)
  299.     super(0, 64, 368, 416)
  300.     @id = id
  301.     refresh
  302.     self.index = 0
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 获取物品
  306.   #--------------------------------------------------------------------------
  307.   def skill
  308.     return @data[self.index]
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 刷新
  312.   #--------------------------------------------------------------------------
  313.   def refresh
  314.     if self.contents != nil
  315.       self.contents.dispose
  316.       self.contents = nil
  317.     end
  318.     @data = []
  319.     for skill_id in @id
  320.       skill = $data_skills[skill_id]
  321.       if skill != nil
  322.         @data.push(skill)
  323.       end
  324.     end
  325.     @item_max = @data.size
  326.     if @item_max > 0
  327.       self.contents = Bitmap.new(width - 32, row_max * 32)
  328.       for i in 0...@item_max
  329.         draw_item(i)
  330.       end
  331.     end
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 描绘羡慕
  335.   #     index : 项目编号
  336.   #--------------------------------------------------------------------------
  337.   def draw_item(index)
  338.     skill = @data[index]
  339.     # 除此之外的情况设置为无效文字色
  340.     if skill.price <= $mShop_gold
  341.       self.contents.font.color = normal_color
  342.     else
  343.       self.contents.font.color = disabled_color
  344.     end
  345.     x = 4
  346.     y = index * 32
  347.     rect = Rect.new(x, y, self.width - 32, 32)
  348.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  349.     bitmap = RPG::Cache.icon(skill.icon_name)
  350.     opacity = self.contents.font.color == normal_color ? 255 : 128
  351.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  352.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  353.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 刷新帮助文本
  357.   #--------------------------------------------------------------------------
  358.   def update_help
  359.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  360.   end
  361. end
  362. #==============================================================================
  363. # ■ RPG原装定义
  364. #==============================================================================
  365. module RPG
  366.   class Skill
  367.     def description
  368.       description = @description.split(/@/)[0]
  369.       return description != nil ? description : ''
  370.     end
  371.     def price
  372.       price = @description.split(/@/)[1]
  373.       return price != nil ? price.to_i : 0
  374.     end
  375.   end
  376. end
复制代码




可学习和遗忘技能魔法商店:(已测试)


  1. #==============================================================================
  2. # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
  3. #==============================================================================

  4. #——以下是一些自定义的内容

  5. $mShop_use_1 = "灵魄"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”

  6. $mShop_use_2 = "特斯拉"  #——这项是购买魔法特技的货币单位,如“点”、“¥”

  7. $mShop_use_variable = 1  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱

  8. $mShop_Window_Opacity = 200  #——这项是窗口透明度

  9. #==============================================================================
  10. # ■ Window_MGold
  11. #------------------------------------------------------------------------------
  12. #  显示金钱的窗口。
  13. #==============================================================================
  14. class Window_MGold < Window_Base
  15.   #--------------------------------------------------------------------------
  16.   # ● 初始化窗口
  17.   #--------------------------------------------------------------------------
  18.   def initialize
  19.     super(0, 0, 272, 64)
  20.     self.contents = Bitmap.new(width - 32, height - 32)
  21.     refresh
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 刷新
  25.   #--------------------------------------------------------------------------
  26.   def refresh
  27.     self.contents.clear
  28.     self.contents.font.color = system_color
  29.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  30.     self.contents.font.color = normal_color
  31.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  32.     self.contents.font.color = system_color
  33.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  34.   end
  35. end
  36. #==============================================================================
  37. # ■ Scene_MShop
  38. #------------------------------------------------------------------------------
  39. #  处理特技商店画面的类。
  40. #==============================================================================
  41. class Scene_MShop
  42.   #--------------------------------------------------------------------------
  43.   # ● 初始化
  44.   #--------------------------------------------------------------------------
  45.   def initialize(id)
  46.     @id = id
  47.   end  
  48.   #--------------------------------------------------------------------------
  49.   # ● 主处理
  50.   #--------------------------------------------------------------------------
  51.   def main
  52.     screen = Spriteset_Map.new
  53.     if $mShop_use_variable == 0
  54.       $mShop_gold = $game_party.gold
  55.     else
  56.       $mShop_gold = $game_variables[$mShop_use_variable]
  57.     end
  58.     # 生成帮助窗口
  59.     @help_window = Window_Help.new
  60.     @help_window.opacity = $mShop_Window_Opacity

  61.     # 生成金钱窗口
  62.     @gold_window = Window_MGold.new
  63.     @gold_window.x = 368
  64.     @gold_window.y = 416
  65.     @gold_window.opacity = $mShop_Window_Opacity
  66.     # 生成购买窗口
  67.     @buy_window = Window_MShopBuy.new(@id)
  68.     @buy_window.active = true
  69.     @buy_window.visible = true
  70.     @buy_window.help_window = @help_window
  71.     @buy_window.opacity = $mShop_Window_Opacity
  72.     # 生成状态窗口
  73.     @status_window = Window_MShopStatus.new
  74.     @status_window.visible = true
  75.     @status_window.active = false
  76.     @status_window.opacity = $mShop_Window_Opacity
  77.         
  78.     #生成指令窗口
  79.     @command_window = Window_Command.new(160,["学会","遗忘"])
  80.     @command_window.x = 320
  81.     @command_window.y = 240
  82.     @command_window.z = 500
  83.     @command_window.visible = false
  84.     @command_window.active = false
  85.     @command_window.opacity = $mShop_Window_Opacity
  86.    
  87.     # 执行过渡
  88.     Graphics.transition
  89.     # 主循环
  90.     loop do
  91.       # 刷新游戏画面
  92.       Graphics.update
  93.       # 刷新输入信息
  94.       Input.update
  95.       # 刷新画面
  96.       update
  97.       # 如果画面切换的话就中断循环
  98.       if $scene != self
  99.         break
  100.       end
  101.     end
  102.     # 准备过渡
  103.     Graphics.freeze
  104.     # 释放窗口
  105.     @help_window.dispose
  106.     #@mhelp_window.dispose
  107.     @gold_window.dispose
  108.     @buy_window.dispose
  109.     @status_window.dispose
  110.     @command_window.dispose
  111.     screen.dispose
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 刷新画面
  115.   #--------------------------------------------------------------------------
  116.   def update
  117.     # 刷新窗口
  118.     @help_window.update
  119.     #@mhelp_window.update
  120.     @gold_window.update
  121.     @buy_window.update
  122.     @status_window.update
  123.     @command_window.update
  124.     # 购买窗口激活的情况下: 调用 update_buy
  125.     if @buy_window.active
  126.       update_buy
  127.       return
  128.     end
  129.     if @status_window.active
  130.       update_status
  131.       return
  132.     end
  133.     if @command_window.active
  134.       update_command
  135.       return
  136.     end
  137.    
  138.   end
  139.   
  140.   #--------------------------------------------------------------------------
  141.   # ● 刷新画面 (指令窗口激活的情况下)
  142.   #--------------------------------------------------------------------------
  143.   def update_command
  144.     if Input.trigger?(Input::B)
  145.       $game_system.se_play($data_system.cancel_se)
  146.       @status_window.index = -1
  147.       @command_window.active = false
  148.       @command_window.visible = false
  149.       @buy_window.active = true
  150.       return
  151.     end
  152.     if Input.trigger?(Input::C)
  153.       if @command_window.index == 0      
  154.         if $game_party.actors[@status_window.index].skill_learn?(@skill.id) or @skill.price > $mShop_gold
  155.           $game_system.se_play($data_system.cancel_se)
  156.           return
  157.         else
  158.           $game_system.se_play($data_system.decision_se)
  159.           if $mShop_use_variable == 0
  160.             $game_party.gain_gold([email]-@skill.price[/email])
  161.             $mShop_gold -= @skill.price
  162.           else
  163.             $game_variables[$mShop_use_variable] -= @skill.price
  164.             $mShop_gold -= @skill.price
  165.           end
  166.           $game_party.actors[@status_window.index].learn_skill(@skill.id)
  167.           @gold_window.refresh
  168.           @buy_window.refresh
  169.           @status_window.refresh
  170.           @status_window.index = -1
  171.           @buy_window.active = true
  172.           @command_window.active = false
  173.           @command_window.visible = false   
  174.         end
  175.       elsif  @command_window.index == 1
  176.         if $game_party.actors[@status_window.index].skill_learn?(@skill.id) == false
  177.           $game_system.se_play($data_system.cancel_se)
  178.           return
  179.         else
  180.           $game_system.se_play($data_system.decision_se)
  181.           if $mShop_use_variable == 0
  182.             $game_party.gain_gold(@skill.price/2)  #<-遗忘价格为学习的一半,/2的地方相同
  183.             $mShop_gold += @skill.price/2
  184.           else
  185.             $game_variables[$mShop_use_variable] += @skill.price/2
  186.             $mShop_gold += @skill.price/2
  187.           end
  188.           $game_party.actors[@status_window.index].forget_skill(@skill.id)
  189.           @gold_window.refresh
  190.           @buy_window.refresh
  191.           @status_window.refresh
  192.           @status_window.index = -1
  193.           @buy_window.active = true
  194.           @command_window.active = false
  195.           @command_window.visible = false
  196.         end
  197.       end
  198.       return
  199.     end
  200.   end
  201.   
  202.   #--------------------------------------------------------------------------
  203.   # ● 刷新画面 (购买窗口激活的情况下)
  204.   #--------------------------------------------------------------------------
  205.   def update_buy
  206.     @status_window.skill = @buy_window.skill
  207.     if Input.trigger?(Input::B)
  208.       $game_system.se_play($data_system.cancel_se)
  209.       $scene = Scene_Map.new
  210.       return
  211.     end
  212.     if Input.trigger?(Input::C)
  213.       @skill = @buy_window.skill
  214.       if @skill == nil #or @skill.price > $mShop_gold  
  215.         $game_system.se_play($data_system.buzzer_se)
  216.         return
  217.       end
  218.       $game_system.se_play($data_system.decision_se)
  219.       @buy_window.active = false
  220.       @status_window.index = 0
  221.       @status_window.active = true
  222.     end
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 刷新画面 (状态窗口激活的情况下)
  226.   #--------------------------------------------------------------------------
  227.   def update_status
  228.     if Input.trigger?(Input::B)
  229.       $game_system.se_play($data_system.cancel_se)
  230.       @status_window.active = false
  231.       @status_window.index = -1
  232.       @buy_window.active = true
  233.     end
  234.     if Input.trigger?(Input::C)
  235.        @status_window.active = false
  236.        @command_window.visible = true
  237.        @command_window.active = true
  238.     end   
  239.   end
  240. end
  241. #==============================================================================
  242. # ■ Window_MShopStatus
  243. #------------------------------------------------------------------------------
  244. #  特技商店画面、显示物品所持数与角色装备的窗口。
  245. #==============================================================================
  246. class Window_MShopStatus < Window_Selectable
  247.   #--------------------------------------------------------------------------
  248.   # ● 初始化对像
  249.   #--------------------------------------------------------------------------
  250.   def initialize
  251.     super(368, 64, 272, 352)
  252.     self.contents = Bitmap.new(width - 32, height - 32)
  253.     self.contents.font.size = 18
  254.     @skill = nil
  255.     refresh
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 刷新
  259.   #--------------------------------------------------------------------------
  260.   def refresh
  261.     self.contents.clear
  262.     for i in 0...$game_party.actors.size
  263.       actor = $game_party.actors[i]
  264.       draw_actor_graphic(actor,12,80*i+64)
  265.       self.contents.font.color = system_color
  266.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  267.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  268.       self.contents.font.color = normal_color
  269.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  270.       self.contents.font.color = system_color
  271.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  272.       self.contents.font.color = normal_color
  273.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  274.       self.contents.font.color = system_color
  275.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  276.       self.contents.font.color = normal_color
  277.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)      
  278.       if actor.skill_learn?(@skill.id)
  279.         self.contents.font.color = Color.new(255,255,255,128)
  280.         self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)        
  281.       else
  282.         self.contents.font.color = Color.new(255,255,0,255)
  283.         self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
  284.       end
  285.     end
  286.     @item_max = $game_party.actors.size
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● 设置物品
  290.   #     item : 新的物品
  291.   #--------------------------------------------------------------------------
  292.   def skill=(skill)
  293.     if @skill != skill
  294.       @skill = skill
  295.       refresh
  296.     end
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 刷新光标矩形
  300.   #--------------------------------------------------------------------------
  301.   def update_cursor_rect
  302.     if @index < 0
  303.       self.cursor_rect.empty
  304.     else
  305.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  306.     end
  307.   end
  308. end
  309. #==============================================================================
  310. # ■ Window_MShopBuy
  311. #------------------------------------------------------------------------------
  312. #  特技商店画面、浏览显示可以购买的商品的窗口。
  313. #==============================================================================
  314. class Window_MShopBuy < Window_Selectable
  315.   #--------------------------------------------------------------------------
  316.   # ● 初始化对像
  317.   #     shop_goods : 商品
  318.   #--------------------------------------------------------------------------
  319.   def initialize(id)
  320.     super(0, 64, 368, 416)
  321.     @id = id
  322.     refresh
  323.     self.index = 0
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 获取物品
  327.   #--------------------------------------------------------------------------
  328.   def skill
  329.     return @data[self.index]
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 刷新
  333.   #--------------------------------------------------------------------------
  334.   def refresh
  335.     if self.contents != nil
  336.       self.contents.dispose
  337.       self.contents = nil
  338.     end
  339.     @data = []
  340.     for skill_id in @id
  341.       skill = $data_skills[skill_id]
  342.       if skill != nil
  343.         @data.push(skill)
  344.       end
  345.     end
  346.     @item_max = @data.size
  347.     if @item_max > 0
  348.       self.contents = Bitmap.new(width - 32, row_max * 32)
  349.       for i in 0...@item_max
  350.         draw_item(i)
  351.       end
  352.     end
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 描绘羡慕
  356.   #     index : 项目编号
  357.   #--------------------------------------------------------------------------
  358.   def draw_item(index)
  359.     skill = @data[index]
  360.     # 除此之外的情况设置为无效文字色
  361.     if skill.price <= $mShop_gold
  362.       self.contents.font.color = normal_color
  363.     else
  364.       self.contents.font.color = disabled_color
  365.     end
  366.     x = 4
  367.     y = index * 32
  368.     rect = Rect.new(x, y, self.width - 32, 32)
  369.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  370.     bitmap = RPG::Cache.icon(skill.icon_name)
  371.     opacity = self.contents.font.color == normal_color ? 255 : 128
  372.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  373.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  374.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 刷新帮助文本
  378.   #--------------------------------------------------------------------------
  379.   def update_help
  380.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  381.   end
  382. end
  383. #==============================================================================
  384. # ■ RPG原装定义
  385. #==============================================================================
  386. module RPG
  387.   class Skill
  388.     def description
  389.       description = @description.split(/@/)[0]
  390.       return description != nil ? description : ''
  391.     end
  392.     def price
  393.       price = @description.split(/@/)[1]
  394.       return price != nil ? price.to_i : 0
  395.     end
  396.   end
  397. end
复制代码






只列出该角色技能,魔法商店:(未测试)
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================

  4. #==============================================================================
  5. # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
  6. #==============================================================================

  7. #——以下是一些自定义的内容

  8. $mShop_use_1 = "学习点数"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”

  9. $mShop_use_2 = " "  #——这项是购买魔法特技的货币单位,如“点”、“¥”

  10. $mShop_use_variable = [1,2,3]  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱

  11. $mShop_Window_Opacity = 160  #——这项是窗口透明度
  12. #==============================================================================
  13. # ■ RPG原装定义
  14. #==============================================================================
  15. module RPG
  16.   class Skill
  17.     def description
  18.       description = @description.split(/@/)[0]
  19.       return description != nil ? description : ''
  20.     end
  21.     def price
  22.       price = @description.split(/@/)[1]
  23.       return price != nil ? price.to_i : 0
  24.     end
  25.   end
  26. end

  27. #==============================================================================
  28. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  29. #==============================================================================

  30. #==============================================================================
  31. # ■ Window_MShopStatus
  32. #------------------------------------------------------------------------------
  33. #  特技商店画面、显示物品所持数与角色装备的窗口。
  34. #==============================================================================
  35. class Window_MShopStatus < Window_Selectable
  36.   #--------------------------------------------------------------------------
  37.   # ● 初始化对像
  38.   #--------------------------------------------------------------------------
  39.   def initialize
  40.     super(0, 64, 272, 352)
  41.     self.contents = Bitmap.new(width - 32, height - 32)
  42.     self.contents.font.size = 18
  43.     @skill = nil
  44.     self.index = 0
  45.     refresh
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 刷新
  49.   #--------------------------------------------------------------------------
  50.   def refresh
  51.     self.contents.clear
  52.     for i in 0...$game_party.actors.size
  53.       actor = $game_party.actors[i]
  54.       draw_actor_graphic(actor,12,80*i+64)
  55.       self.contents.font.color = system_color
  56.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  57.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  58.       self.contents.font.color = normal_color
  59.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  60.       self.contents.font.color = system_color
  61.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  62.       self.contents.font.color = normal_color
  63.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  64.       self.contents.font.color = system_color
  65.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  66.       self.contents.font.color = normal_color
  67.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)   
  68.       can_learn=false
  69.       for j in $data_classes[actor.class_id].learnings
  70.         if j.skill_id == @skill.id
  71.           can_learn=true
  72.         end
  73.       end
  74.       if can_learn == true
  75.         if actor.skill_learn?(@skill.id)
  76.           self.contents.font.color = Color.new(255,255,255,128)
  77.           self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)      
  78.         else
  79.           self.contents.font.color = Color.new(255,255,0,255)
  80.           self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
  81.         end
  82.       else
  83.         self.contents.font.color = Color.new(255,255,255,128)
  84.         self.contents.draw_text(44, 80*i+44, 196, 32, "◇此项特技无法学习◇",2)      
  85.       end
  86.     end
  87.     @item_max = $game_party.actors.size
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 设置物品
  91.   #     item : 新的物品
  92.   #--------------------------------------------------------------------------
  93.   def skill=(skill)
  94.     if @skill != skill
  95.       @skill = skill
  96.       refresh
  97.     end
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 刷新光标矩形
  101.   #--------------------------------------------------------------------------
  102.   def update_cursor_rect
  103.     if @index < 0
  104.       self.cursor_rect.empty
  105.     else
  106.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  107.     end
  108.   end
  109. end

  110. #==============================================================================
  111. # ■ Window_MShopBuy
  112. #------------------------------------------------------------------------------
  113. #  特技商店画面、浏览显示可以购买的商品的窗口。
  114. #==============================================================================
  115. class Window_MShopBuy < Window_Selectable
  116.   #--------------------------------------------------------------------------
  117.   # ● 初始化对像
  118.   #     shop_goods : 商品
  119.   #--------------------------------------------------------------------------
  120.   def initialize(id)
  121.     super(272, 64, 368, 416)
  122.     @id = id
  123.     refresh
  124. #    self.index = 0
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 获取物品
  128.   #--------------------------------------------------------------------------
  129.   def skill
  130.     return @data[self.index]
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 刷新
  134.   #--------------------------------------------------------------------------
  135.   def refresh
  136.     if self.contents != nil
  137.       self.contents.dispose
  138.       self.contents = nil
  139.     end
  140.     @data = []
  141.     for skill_id in @id
  142.       skill = $data_skills[skill_id]
  143.       if skill != nil
  144.         @data.push(skill)
  145.       end
  146.     end
  147.     @item_max = @data.size
  148.     if @item_max > 0
  149.       self.contents = Bitmap.new(width - 32, row_max * 32)
  150.       for i in 0...@item_max
  151.         draw_item(i)
  152.       end
  153.     end
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 描绘羡慕
  157.   #     index : 项目编号
  158.   #--------------------------------------------------------------------------
  159.   def draw_item(index)
  160.     skill = @data[index]
  161.     # 除此之外的情况设置为无效文字色
  162.     if skill.price <= $mShop_gold
  163.       self.contents.font.color = normal_color
  164.     else
  165.       self.contents.font.color = disabled_color
  166.     end
  167.     x = 4
  168.     y = index * 32
  169.     rect = Rect.new(x, y, self.width - 32, 32)
  170.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  171.     bitmap = RPG::Cache.icon(skill.icon_name)
  172.     opacity = self.contents.font.color == normal_color ? 255 : 128
  173.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  174.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  175.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 刷新帮助文本
  179.   #--------------------------------------------------------------------------
  180.   def update_help
  181.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  182.   end
  183. end

  184. #==============================================================================
  185. # ■ Window_MGold
  186. #------------------------------------------------------------------------------
  187. #  显示金钱的窗口。
  188. #==============================================================================
  189. class Window_MGold < Window_Base
  190.   #--------------------------------------------------------------------------
  191.   # ● 初始化窗口
  192.   #--------------------------------------------------------------------------
  193.   def initialize
  194.     super(0, 0, 272, 64)
  195.     self.contents = Bitmap.new(width - 32, height - 32)
  196.     refresh
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 刷新
  200.   #--------------------------------------------------------------------------
  201.   def refresh
  202.     self.contents.clear
  203.     self.contents.font.color = system_color
  204.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  205.     self.contents.font.color = normal_color
  206.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  207.     self.contents.font.color = system_color
  208.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  209.   end
  210. end
  211. #==============================================================================
  212. # ■ Scene_MShop
  213. #------------------------------------------------------------------------------
  214. #  处理特技商店画面的类。
  215. #==============================================================================
  216. class Scene_MShop
  217.   #--------------------------------------------------------------------------
  218.   # ● 初始化
  219.   #--------------------------------------------------------------------------
  220.   def initialize(actor_id = 1)
  221.     @actor = $game_party.actors[actor_id - 1]
  222.     @id = []
  223.     if $mShop_use_variable[actor_id - 1] == 0
  224.       $mShop_gold = $game_party.gold
  225.     else
  226.       $mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]]
  227.     end
  228.     for i in 0... $data_classes[@actor.class_id].learnings.size
  229.       @id[i] = $data_classes[@actor.class_id].learnings[i].skill_id
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 主处理
  234.   #--------------------------------------------------------------------------
  235.   def main
  236.     screen = Spriteset_Map.new
  237.     # 生成帮助窗口
  238.     @help_window = Window_Help.new
  239.     @help_window.opacity = $mShop_Window_Opacity
  240.     # 生成金钱窗口
  241.     @gold_window = Window_MGold.new
  242.     @gold_window.x = 0
  243.     @gold_window.y = 416
  244.     @gold_window.opacity = $mShop_Window_Opacity
  245.     # 生成购买窗口
  246.     @buy_window = Window_MShopBuy.new(@id)
  247.     @buy_window.active = false
  248.     @buy_window.visible = true
  249.     @buy_window.help_window = @help_window
  250.     @buy_window.opacity = $mShop_Window_Opacity
  251.     # 生成状态窗口
  252.     @status_window = Window_MShopStatus.new
  253.     @status_window.visible = true
  254.     @status_window.active = true
  255.     @status_window.opacity = $mShop_Window_Opacity
  256.     # 执行过渡
  257.     Graphics.transition
  258.     # 主循环
  259.     loop do
  260.       # 刷新游戏画面
  261.       Graphics.update
  262.       # 刷新输入信息
  263.       Input.update
  264.       # 刷新画面
  265.       update
  266.       # 如果画面切换的话就中断循环
  267.       if $scene != self
  268.         break
  269.       end
  270.     end
  271.     # 准备过渡
  272.     Graphics.freeze
  273.     # 释放窗口
  274.     @help_window.dispose
  275.     @gold_window.dispose
  276.     @buy_window.dispose
  277.     @status_window.dispose
  278.     screen.dispose
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 刷新画面
  282.   #--------------------------------------------------------------------------
  283.   def update
  284.     # 刷新窗口
  285.     @help_window.update
  286.     @gold_window.update
  287.     @buy_window.update
  288.     @status_window.update
  289.     # 购买窗口激活的情况下: 调用 update_buy
  290.     if @buy_window.active
  291.       update_buy
  292.       return
  293.     end
  294.     if @status_window.active
  295.       update_status
  296.       return
  297.     end
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 刷新画面 (右侧窗口激活的情况下)
  301.   #--------------------------------------------------------------------------
  302.   def update_buy
  303.     @status_window.skill = @buy_window.skill
  304.     if Input.trigger?(Input::B)
  305.       $game_system.se_play($data_system.cancel_se)
  306.         @buy_window.active = false
  307.         @buy_window.index = -1
  308.         @status_window.active = true
  309.        return
  310.     end
  311.     if Input.trigger?(Input::C)
  312.       @skill = @buy_window.skill
  313.       if @skill == nil or @skill.price > $mShop_gold
  314.         $game_system.se_play($data_system.buzzer_se)
  315.         return
  316.       end
  317.       can_learn=false
  318.       for j in $data_classes[$game_party.actors[@status_window.index].class_id].learnings
  319.         if j.skill_id == @skill.id
  320.           can_learn=true
  321.         end
  322.       end
  323.       if can_learn==false
  324.         $game_system.se_play($data_system.cancel_se)
  325.         return
  326.       end
  327.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
  328.         $game_system.se_play($data_system.cancel_se)
  329.         return
  330.       else
  331.         $game_system.se_play($data_system.decision_se)
  332.         if $mShop_use_variable[@actor.id - 1] == 0
  333.           $game_party.gain_gold([email]-@skill.price[/email])
  334.           $mShop_gold -= @skill.price
  335.         else
  336.           $game_variables[$mShop_use_variable[@actor.id - 1]] -= @skill.price
  337.           $mShop_gold -= @skill.price
  338.         end
  339.         $game_party.actors[@status_window.index].learn_skill(@skill.id)
  340.         @gold_window.refresh
  341.         @buy_window.refresh
  342.         @status_window.refresh
  343.         $game_system.se_play($data_system.decision_se)
  344.         @buy_window.active = false
  345.         @buy_window.index = -1
  346.         @status_window.active = true
  347.       end
  348.     end
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 刷新画面 (状态窗口激活的情况下)
  352.   #--------------------------------------------------------------------------
  353.   def update_status
  354.     if Input.trigger?(Input::B)
  355.       $game_system.se_play($data_system.cancel_se)
  356.       $scene = Scene_Map.new #---改成menu
  357.     end
  358.     if Input.trigger?(Input::C)
  359.       @actor = $game_party.actors[@status_window.index]
  360.       @id = []
  361.       for i in 0... $data_classes[@actor.class_id].learnings.size
  362.         @id[i] = $data_classes[@actor.class_id].learnings[i].skill_id
  363.       end
  364.       @buy_window.dispose
  365.       @buy_window = Window_MShopBuy.new(@id)
  366.       @buy_window.help_window = @help_window
  367.       if $mShop_use_variable[@actor.id - 1] == 0
  368.         $mShop_gold = $game_party.gold
  369.       else
  370.         $mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]]
  371.       end
  372.       @buy_window.opacity = $mShop_Window_Opacity
  373.       @status_window.refresh
  374.       @status_window.active = false
  375.       @buy_window.active = true
  376.       @buy_window.index = 0
  377.       @gold_window.refresh
  378.     end
  379.   end
  380. end
复制代码
  
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部