设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1456|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
80
在线时间
216 小时
注册时间
2011-9-17
帖子
151
跳转到指定楼层
1
发表于 2015-12-1 18:40:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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


物品学技能,职业限制型魔法商店:(已测试)
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
  3. #==============================================================================
  4.  
  5. #——以下是一些自定义的内容
  6. #呼出魔法商店$scene = Scene_MShop.new([1,2,3,4,5,6,7,8])
  7. #在技能说明末尾增加@100,则学习此技能需要扣掉9号变量100
  8.  
  9. $mShop_use_1 = "魔法水晶"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
  10.  
  11. $mShop_use_2 = "个"  #——这项是购买魔法特技的货币单位,如“点”、“¥”
  12.  
  13. $mShop_use_variable = 9  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
  14.  
  15. $mShop_Window_Opacity = 200  #——这项是窗口透明度
  16.  
  17. # 每个职业可以学的技能列表
  18. $class_canlearn_list = {  1 => [1,80],
  19.                           2 => [60,61],
  20.                           3 => []}
  21.  
  22. #==============================================================================
  23. # ■ Window_MGold
  24. #------------------------------------------------------------------------------
  25. #  显示金钱的窗口。
  26. #==============================================================================
  27. class Window_MGold < Window_Base
  28.   #--------------------------------------------------------------------------
  29.   # ● 初始化窗口
  30.   #--------------------------------------------------------------------------
  31.   def initialize
  32.     super(0, 0, 272, 64)
  33.     self.contents = Bitmap.new(width - 32, height - 32)
  34.     refresh
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 刷新
  38.   #--------------------------------------------------------------------------
  39.   def refresh
  40.     self.contents.clear
  41.     self.contents.font.color = system_color
  42.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  43.     self.contents.font.color = normal_color
  44.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  45.     self.contents.font.color = system_color
  46.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  47.   end
  48. end
  49. #==============================================================================
  50. # ■ Scene_MShop
  51. #------------------------------------------------------------------------------
  52. #  处理特技商店画面的类。
  53. #==============================================================================
  54. class Scene_MShop
  55.   #--------------------------------------------------------------------------
  56.   # ● 初始化
  57.   #--------------------------------------------------------------------------
  58.   def initialize(id)
  59.     @id = id
  60.   end  
  61.   #--------------------------------------------------------------------------
  62.   # ● 主处理
  63.   #--------------------------------------------------------------------------
  64.   def main
  65.     screen = Spriteset_Map.new
  66.     $game_variables[9] = $game_party.armor_number(951)
  67.     $game_party.remove_actor(997)#主角离开队伍
  68.     if $mShop_use_variable == 0
  69.       $mShop_gold = $game_party.gold
  70.     else
  71.       $mShop_gold = $game_variables[$mShop_use_variable]
  72.     end
  73.     # 生成帮助窗口
  74.     @help_window = Window_Help.new
  75.     @help_window.opacity = $mShop_Window_Opacity
  76.     # 生成金钱窗口
  77.     @gold_window = Window_MGold.new
  78.     @gold_window.x = 368
  79.     @gold_window.y = 416
  80.     @gold_window.opacity = $mShop_Window_Opacity
  81.     # 生成购买窗口
  82.     @buy_window = Window_MShopBuy.new(@id)
  83.     @buy_window.active = true
  84.     @buy_window.visible = true
  85.     @buy_window.help_window = @help_window
  86.     @buy_window.opacity = $mShop_Window_Opacity
  87.     # 生成状态窗口
  88.     @status_window = Window_MShopStatus.new
  89.     @status_window.visible = true
  90.     @status_window.active = false
  91.     @status_window.opacity = $mShop_Window_Opacity
  92.     # 执行过渡
  93.     Graphics.transition
  94.     # 主循环
  95.     loop do
  96.       # 刷新游戏画面
  97.       Graphics.update
  98.       # 刷新输入信息
  99.       Input.update
  100.       # 刷新画面
  101.       update
  102.       # 如果画面切换的话就中断循环
  103.       if $scene != self
  104.         break
  105.       end
  106.     end
  107.     # 准备过渡
  108.     Graphics.freeze
  109.     # 释放窗口
  110.     @help_window.dispose
  111.     #@mhelp_window.dispose
  112.     @gold_window.dispose
  113.     @buy_window.dispose
  114.     @status_window.dispose
  115.     screen.dispose
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 刷新画面
  119.   #--------------------------------------------------------------------------
  120.   def update
  121.     # 刷新窗口
  122.     @help_window.update
  123.     #@mhelp_window.update
  124.     @gold_window.update
  125.     @buy_window.update
  126.     @status_window.update
  127.     # 购买窗口激活的情况下: 调用 update_buy
  128.     if @buy_window.active
  129.       update_buy
  130.       return
  131.     end
  132.     if @status_window.active
  133.       update_status
  134.       return
  135.     end
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 刷新画面 (购买窗口激活的情况下)
  139.   #--------------------------------------------------------------------------
  140.   def update_buy
  141.     @status_window.skill = @buy_window.skill
  142.     if Input.trigger?(Input::B)
  143.       $game_system.se_play($data_system.cancel_se)
  144.       $game_variables[25] = $game_party.armor_number(951)
  145.       $game_variables[24] = $game_variables[25] - $game_variables[9]
  146.       $game_party.gain_armor(951,-$game_variables[24])
  147.       $game_party.add_actor(997)#主角加入队伍
  148.       $scene = Scene_Map.new
  149.       return
  150.     end
  151.     if Input.trigger?(Input::C)
  152.       @skill = @buy_window.skill
  153.       if @skill == nil or @skill.price > $mShop_gold
  154.         $game_system.se_play($data_system.buzzer_se)
  155.         return
  156.       end
  157.       $game_system.se_play($data_system.decision_se)
  158.       @buy_window.active = false
  159.       @status_window.index = 0
  160.       @status_window.active = true
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● 刷新画面 (状态窗口激活的情况下)
  165.   #--------------------------------------------------------------------------
  166.   def update_status
  167.     if Input.trigger?(Input::B)
  168.       $game_system.se_play($data_system.cancel_se)
  169.       @status_window.active = false
  170.       @status_window.index = -1
  171.       @buy_window.active = true
  172.     end
  173.     actor = $game_party.actors[@status_window.index]
  174.     if Input.trigger?(Input::C)
  175.       can_learn=false
  176.       for j in $data_classes[actor.class_id].learnings
  177.         if j.skill_id == @skill.id
  178.           can_learn=true
  179.         end
  180.       end
  181.  
  182.       unless $class_canlearn_list[actor.class_id].nil?
  183.         can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
  184.       end
  185.  
  186.       if can_learn==false
  187.         $game_system.se_play($data_system.cancel_se)
  188.         return
  189.       end
  190.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
  191.         $game_system.se_play($data_system.cancel_se)
  192.         return
  193.       else
  194.         $game_system.se_play($data_system.decision_se)
  195.         if $mShop_use_variable == 0
  196.           $game_party.gain_gold([email]-@skill.price[/email])
  197.           $mShop_gold -= @skill.price
  198.         else
  199.           $game_variables[$mShop_use_variable] -= @skill.price
  200.           $mShop_gold -= @skill.price
  201.         end
  202.         $game_party.actors[@status_window.index].learn_skill(@skill.id)
  203.         @gold_window.refresh
  204.         @buy_window.refresh
  205.         @status_window.refresh
  206.         @status_window.active = false
  207.         @status_window.index = -1
  208.         @buy_window.active = true
  209.       end      
  210.     end   
  211.   end
  212. end
  213. #==============================================================================
  214. # ■ Window_MShopStatus
  215. #------------------------------------------------------------------------------
  216. #  特技商店画面、显示物品所持数与角色装备的窗口。
  217. #==============================================================================
  218. class Window_MShopStatus < Window_Selectable
  219.   #--------------------------------------------------------------------------
  220.   # ● 初始化对像
  221.   #--------------------------------------------------------------------------
  222.   def initialize
  223.     super(368, 64, 272, 352)
  224.     self.contents = Bitmap.new(width - 32, height - 32)
  225.     self.contents.font.size = 18
  226.     @skill = nil
  227.     refresh
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● 刷新
  231.   #--------------------------------------------------------------------------
  232.   def refresh
  233.     self.contents.clear
  234.     for i in 0...$game_party.actors.size
  235.       actor = $game_party.actors[i]
  236. #      draw_actor_graphic(actor,12,80*i+64)
  237.       self.contents.font.color = system_color
  238.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  239.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  240.       self.contents.font.color = normal_color
  241.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  242.       self.contents.font.color = system_color
  243.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  244.       self.contents.font.color = normal_color
  245.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  246.       self.contents.font.color = system_color
  247.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  248.       self.contents.font.color = normal_color
  249.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)   
  250.       can_learn=false
  251.       for j in $data_classes[actor.class_id].learnings
  252.         if j.skill_id == @skill.id
  253.           can_learn=true
  254.         end
  255.       end
  256.       unless $class_canlearn_list[actor.class_id].nil?
  257.         can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
  258.       end
  259.  
  260.       if can_learn == true
  261.         if actor.skill_learn?(@skill.id)
  262.           self.contents.font.color = Color.new(255,255,255,128)
  263.           self.contents.draw_text(44, 80*i+44, 196, 32, "已经学会改技能 ",2)        
  264.         else
  265.           self.contents.font.color = Color.new(255,255,0,255)
  266.           self.contents.draw_text(44, 80*i+44, 196, 32, "可以学会该技能 ",2)
  267.         end
  268.       else
  269.         self.contents.font.color = Color.new(255,255,255,128)
  270.         self.contents.draw_text(44, 80*i+44, 196, 32, "不适合学该技能 ",2)        
  271.       end
  272.     end
  273.     @item_max = $game_party.actors.size
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 设置物品
  277.   #     item : 新的物品
  278.   #--------------------------------------------------------------------------
  279.   def skill=(skill)
  280.     if @skill != skill
  281.       @skill = skill
  282.       refresh
  283.     end
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 刷新光标矩形
  287.   #--------------------------------------------------------------------------
  288.   def update_cursor_rect
  289.     if @index < 0
  290.       self.cursor_rect.empty
  291.     else
  292.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  293.     end
  294.   end
  295. end
  296. #==============================================================================
  297. # ■ Window_MShopBuy
  298. #------------------------------------------------------------------------------
  299. #  特技商店画面、浏览显示可以购买的商品的窗口。
  300. #==============================================================================
  301. class Window_MShopBuy < Window_Selectable
  302.   #--------------------------------------------------------------------------
  303.   # ● 初始化对像
  304.   #     shop_goods : 商品
  305.   #--------------------------------------------------------------------------
  306.   def initialize(id)
  307.     super(0, 64, 368, 416)
  308.     @id = id
  309.     refresh
  310.     self.index = 0
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 获取物品
  314.   #--------------------------------------------------------------------------
  315.   def skill
  316.     return @data[self.index]
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● 刷新
  320.   #--------------------------------------------------------------------------
  321.   def refresh
  322.     if self.contents != nil
  323.       self.contents.dispose
  324.       self.contents = nil
  325.     end
  326.     @data = []
  327.     for skill_id in @id
  328.       skill = $data_skills[skill_id]
  329.       if skill != nil
  330.         @data.push(skill)
  331.       end
  332.     end
  333.     @item_max = @data.size
  334.     if @item_max > 0
  335.       self.contents = Bitmap.new(width - 32, row_max * 32)
  336.       for i in 0...@item_max
  337.         draw_item(i)
  338.       end
  339.     end
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 描绘羡慕
  343.   #     index : 项目编号
  344.   #--------------------------------------------------------------------------
  345.   def draw_item(index)
  346.     skill = @data[index]
  347.     # 除此之外的情况设置为无效文字色
  348.     if skill.price <= $mShop_gold
  349.       self.contents.font.color = normal_color
  350.     else
  351.       self.contents.font.color = disabled_color
  352.     end
  353.     x = 4
  354.     y = index * 32
  355.     rect = Rect.new(x, y, self.width - 32, 32)
  356.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  357.     bitmap = RPG::Cache.icon(skill.icon_name)
  358.     opacity = self.contents.font.color == normal_color ? 255 : 128
  359.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  360.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  361.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 刷新帮助文本
  365.   #--------------------------------------------------------------------------
  366.   def update_help
  367.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  368.   end
  369. end
  370. #==============================================================================
  371. # ■ RPG原装定义
  372. #==============================================================================
  373. module RPG
  374.   class Skill
  375.     def description
  376.       description = @description.split(/@/)[0]
  377.       return description != nil ? description : ''
  378.     end
  379.     def price
  380.       price = @description.split(/@/)[1]
  381.       return price != nil ? price.to_i : 0
  382.     end
  383.   end
  384. end




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






只列出该角色技能,魔法商店:(未测试)
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4.  
  5. #==============================================================================
  6. # ■ 本脚本源自[url]www.66rpg.com[/url],转载与使用请保留此信息
  7. #==============================================================================
  8.  
  9. #——以下是一些自定义的内容
  10.  
  11. $mShop_use_1 = "学习点数"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
  12.  
  13. $mShop_use_2 = " "  #——这项是购买魔法特技的货币单位,如“点”、“¥”
  14.  
  15. $mShop_use_variable = [1,2,3]  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
  16.  
  17. $mShop_Window_Opacity = 160  #——这项是窗口透明度
  18. #==============================================================================
  19. # ■ RPG原装定义
  20. #==============================================================================
  21. module RPG
  22.   class Skill
  23.     def description
  24.       description = @description.split(/@/)[0]
  25.       return description != nil ? description : ''
  26.     end
  27.     def price
  28.       price = @description.split(/@/)[1]
  29.       return price != nil ? price.to_i : 0
  30.     end
  31.   end
  32. end
  33.  
  34. #==============================================================================
  35. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  36. #==============================================================================
  37.  
  38. #==============================================================================
  39. # ■ Window_MShopStatus
  40. #------------------------------------------------------------------------------
  41. #  特技商店画面、显示物品所持数与角色装备的窗口。
  42. #==============================================================================
  43. class Window_MShopStatus < Window_Selectable
  44.   #--------------------------------------------------------------------------
  45.   # ● 初始化对像
  46.   #--------------------------------------------------------------------------
  47.   def initialize
  48.     super(0, 64, 272, 352)
  49.     self.contents = Bitmap.new(width - 32, height - 32)
  50.     self.contents.font.size = 18
  51.     @skill = nil
  52.     self.index = 0
  53.     refresh
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 刷新
  57.   #--------------------------------------------------------------------------
  58.   def refresh
  59.     self.contents.clear
  60.     for i in 0...$game_party.actors.size
  61.       actor = $game_party.actors[i]
  62.       draw_actor_graphic(actor,12,80*i+64)
  63.       self.contents.font.color = system_color
  64.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  65.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  66.       self.contents.font.color = normal_color
  67.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  68.       self.contents.font.color = system_color
  69.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  70.       self.contents.font.color = normal_color
  71.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  72.       self.contents.font.color = system_color
  73.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  74.       self.contents.font.color = normal_color
  75.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)   
  76.       can_learn=false
  77.       for j in $data_classes[actor.class_id].learnings
  78.         if j.skill_id == @skill.id
  79.           can_learn=true
  80.         end
  81.       end
  82.       if can_learn == true
  83.         if actor.skill_learn?(@skill.id)
  84.           self.contents.font.color = Color.new(255,255,255,128)
  85.           self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)      
  86.         else
  87.           self.contents.font.color = Color.new(255,255,0,255)
  88.           self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
  89.         end
  90.       else
  91.         self.contents.font.color = Color.new(255,255,255,128)
  92.         self.contents.draw_text(44, 80*i+44, 196, 32, "◇此项特技无法学习◇",2)      
  93.       end
  94.     end
  95.     @item_max = $game_party.actors.size
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 设置物品
  99.   #     item : 新的物品
  100.   #--------------------------------------------------------------------------
  101.   def skill=(skill)
  102.     if @skill != skill
  103.       @skill = skill
  104.       refresh
  105.     end
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 刷新光标矩形
  109.   #--------------------------------------------------------------------------
  110.   def update_cursor_rect
  111.     if @index < 0
  112.       self.cursor_rect.empty
  113.     else
  114.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  115.     end
  116.   end
  117. end
  118.  
  119. #==============================================================================
  120. # ■ Window_MShopBuy
  121. #------------------------------------------------------------------------------
  122. #  特技商店画面、浏览显示可以购买的商品的窗口。
  123. #==============================================================================
  124. class Window_MShopBuy < Window_Selectable
  125.   #--------------------------------------------------------------------------
  126.   # ● 初始化对像
  127.   #     shop_goods : 商品
  128.   #--------------------------------------------------------------------------
  129.   def initialize(id)
  130.     super(272, 64, 368, 416)
  131.     @id = id
  132.     refresh
  133. #    self.index = 0
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 获取物品
  137.   #--------------------------------------------------------------------------
  138.   def skill
  139.     return @data[self.index]
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 刷新
  143.   #--------------------------------------------------------------------------
  144.   def refresh
  145.     if self.contents != nil
  146.       self.contents.dispose
  147.       self.contents = nil
  148.     end
  149.     @data = []
  150.     for skill_id in @id
  151.       skill = $data_skills[skill_id]
  152.       if skill != nil
  153.         @data.push(skill)
  154.       end
  155.     end
  156.     @item_max = @data.size
  157.     if @item_max > 0
  158.       self.contents = Bitmap.new(width - 32, row_max * 32)
  159.       for i in 0...@item_max
  160.         draw_item(i)
  161.       end
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 描绘羡慕
  166.   #     index : 项目编号
  167.   #--------------------------------------------------------------------------
  168.   def draw_item(index)
  169.     skill = @data[index]
  170.     # 除此之外的情况设置为无效文字色
  171.     if skill.price <= $mShop_gold
  172.       self.contents.font.color = normal_color
  173.     else
  174.       self.contents.font.color = disabled_color
  175.     end
  176.     x = 4
  177.     y = index * 32
  178.     rect = Rect.new(x, y, self.width - 32, 32)
  179.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  180.     bitmap = RPG::Cache.icon(skill.icon_name)
  181.     opacity = self.contents.font.color == normal_color ? 255 : 128
  182.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  183.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  184.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 刷新帮助文本
  188.   #--------------------------------------------------------------------------
  189.   def update_help
  190.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  191.   end
  192. end
  193.  
  194. #==============================================================================
  195. # ■ Window_MGold
  196. #------------------------------------------------------------------------------
  197. #  显示金钱的窗口。
  198. #==============================================================================
  199. class Window_MGold < Window_Base
  200.   #--------------------------------------------------------------------------
  201.   # ● 初始化窗口
  202.   #--------------------------------------------------------------------------
  203.   def initialize
  204.     super(0, 0, 272, 64)
  205.     self.contents = Bitmap.new(width - 32, height - 32)
  206.     refresh
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● 刷新
  210.   #--------------------------------------------------------------------------
  211.   def refresh
  212.     self.contents.clear
  213.     self.contents.font.color = system_color
  214.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  215.     self.contents.font.color = normal_color
  216.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  217.     self.contents.font.color = system_color
  218.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  219.   end
  220. end
  221. #==============================================================================
  222. # ■ Scene_MShop
  223. #------------------------------------------------------------------------------
  224. #  处理特技商店画面的类。
  225. #==============================================================================
  226. class Scene_MShop
  227.   #--------------------------------------------------------------------------
  228.   # ● 初始化
  229.   #--------------------------------------------------------------------------
  230.   def initialize(actor_id = 1)
  231.     @actor = $game_party.actors[actor_id - 1]
  232.     @id = []
  233.     if $mShop_use_variable[actor_id - 1] == 0
  234.       $mShop_gold = $game_party.gold
  235.     else
  236.       $mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]]
  237.     end
  238.     for i in 0... $data_classes[@actor.class_id].learnings.size
  239.       @id[i] = $data_classes[@actor.class_id].learnings[i].skill_id
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 主处理
  244.   #--------------------------------------------------------------------------
  245.   def main
  246.     screen = Spriteset_Map.new
  247.     # 生成帮助窗口
  248.     @help_window = Window_Help.new
  249.     @help_window.opacity = $mShop_Window_Opacity
  250.     # 生成金钱窗口
  251.     @gold_window = Window_MGold.new
  252.     @gold_window.x = 0
  253.     @gold_window.y = 416
  254.     @gold_window.opacity = $mShop_Window_Opacity
  255.     # 生成购买窗口
  256.     @buy_window = Window_MShopBuy.new(@id)
  257.     @buy_window.active = false
  258.     @buy_window.visible = true
  259.     @buy_window.help_window = @help_window
  260.     @buy_window.opacity = $mShop_Window_Opacity
  261.     # 生成状态窗口
  262.     @status_window = Window_MShopStatus.new
  263.     @status_window.visible = true
  264.     @status_window.active = true
  265.     @status_window.opacity = $mShop_Window_Opacity
  266.     # 执行过渡
  267.     Graphics.transition
  268.     # 主循环
  269.     loop do
  270.       # 刷新游戏画面
  271.       Graphics.update
  272.       # 刷新输入信息
  273.       Input.update
  274.       # 刷新画面
  275.       update
  276.       # 如果画面切换的话就中断循环
  277.       if $scene != self
  278.         break
  279.       end
  280.     end
  281.     # 准备过渡
  282.     Graphics.freeze
  283.     # 释放窗口
  284.     @help_window.dispose
  285.     @gold_window.dispose
  286.     @buy_window.dispose
  287.     @status_window.dispose
  288.     screen.dispose
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 刷新画面
  292.   #--------------------------------------------------------------------------
  293.   def update
  294.     # 刷新窗口
  295.     @help_window.update
  296.     @gold_window.update
  297.     @buy_window.update
  298.     @status_window.update
  299.     # 购买窗口激活的情况下: 调用 update_buy
  300.     if @buy_window.active
  301.       update_buy
  302.       return
  303.     end
  304.     if @status_window.active
  305.       update_status
  306.       return
  307.     end
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 刷新画面 (右侧窗口激活的情况下)
  311.   #--------------------------------------------------------------------------
  312.   def update_buy
  313.     @status_window.skill = @buy_window.skill
  314.     if Input.trigger?(Input::B)
  315.       $game_system.se_play($data_system.cancel_se)
  316.         @buy_window.active = false
  317.         @buy_window.index = -1
  318.         @status_window.active = true
  319.        return
  320.     end
  321.     if Input.trigger?(Input::C)
  322.       @skill = @buy_window.skill
  323.       if @skill == nil or @skill.price > $mShop_gold
  324.         $game_system.se_play($data_system.buzzer_se)
  325.         return
  326.       end
  327.       can_learn=false
  328.       for j in $data_classes[$game_party.actors[@status_window.index].class_id].learnings
  329.         if j.skill_id == @skill.id
  330.           can_learn=true
  331.         end
  332.       end
  333.       if can_learn==false
  334.         $game_system.se_play($data_system.cancel_se)
  335.         return
  336.       end
  337.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
  338.         $game_system.se_play($data_system.cancel_se)
  339.         return
  340.       else
  341.         $game_system.se_play($data_system.decision_se)
  342.         if $mShop_use_variable[@actor.id - 1] == 0
  343.           $game_party.gain_gold([email]-@skill.price[/email])
  344.           $mShop_gold -= @skill.price
  345.         else
  346.           $game_variables[$mShop_use_variable[@actor.id - 1]] -= @skill.price
  347.           $mShop_gold -= @skill.price
  348.         end
  349.         $game_party.actors[@status_window.index].learn_skill(@skill.id)
  350.         @gold_window.refresh
  351.         @buy_window.refresh
  352.         @status_window.refresh
  353.         $game_system.se_play($data_system.decision_se)
  354.         @buy_window.active = false
  355.         @buy_window.index = -1
  356.         @status_window.active = true
  357.       end
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 刷新画面 (状态窗口激活的情况下)
  362.   #--------------------------------------------------------------------------
  363.   def update_status
  364.     if Input.trigger?(Input::B)
  365.       $game_system.se_play($data_system.cancel_se)
  366.       $scene = Scene_Map.new #---改成menu
  367.     end
  368.     if Input.trigger?(Input::C)
  369.       @actor = $game_party.actors[@status_window.index]
  370.       @id = []
  371.       for i in 0... $data_classes[@actor.class_id].learnings.size
  372.         @id[i] = $data_classes[@actor.class_id].learnings[i].skill_id
  373.       end
  374.       @buy_window.dispose
  375.       @buy_window = Window_MShopBuy.new(@id)
  376.       @buy_window.help_window = @help_window
  377.       if $mShop_use_variable[@actor.id - 1] == 0
  378.         $mShop_gold = $game_party.gold
  379.       else
  380.         $mShop_gold = $game_variables[$mShop_use_variable[@actor.id - 1]]
  381.       end
  382.       @buy_window.opacity = $mShop_Window_Opacity
  383.       @status_window.refresh
  384.       @status_window.active = false
  385.       @buy_window.active = true
  386.       @buy_window.index = 0
  387.       @gold_window.refresh
  388.     end
  389.   end
  390. end
   
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-22 21:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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