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

Project1

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

[已经解决] 限制性魔法商店修改求教

[复制链接]

Lv3.寻梦者

梦石
0
星屑
4002
在线时间
604 小时
注册时间
2017-4-21
帖子
229
跳转到指定楼层
1
发表于 2018-10-10 07:02:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这是我目前在论坛搜到的魔法商店脚本

设置是:每个职业可以学的技能列表。
1=> [433,48,32,24,391,126,361,209],
1是职业id,后面括号是技能id

可是这个设置对我不太友善,因为职业很多,反而技能教学者比较少,我想修改成:每个技能可以让哪些职业学习
1=> [433,48,32,24,391,126,361,209],
1是技能id,后面括号是职业id

脚本方面我还不太在行,希望有大大伸出援手

  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 = {  
  13. 1=> [433,48,32,24,391,126,361,209],
  14. 2=> [433,48,32,24,391,126,361,209],

  15. 2105=> [628,455,504,126]
  16. }#注意,收尾的最后一个设置是没有逗号的,例如"1=> [391]",

  17. #==============================================================================
  18. # ■ Window_MGold
  19. #------------------------------------------------------------------------------
  20. #  显示金钱的窗口。
  21. #==============================================================================
  22. class Window_MGold < Window_Base
  23.   #--------------------------------------------------------------------------
  24.   # ● 初始化窗口
  25.   #--------------------------------------------------------------------------
  26.   def initialize
  27.     super(0, 0, 272, 64)
  28.     self.contents = Bitmap.new(width - 32, height - 32)
  29.     refresh
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 刷新
  33.   #--------------------------------------------------------------------------
  34.   def refresh
  35.     self.contents.clear
  36.     self.contents.font.color = system_color
  37.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  38.     self.contents.font.color = normal_color
  39.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  40.     self.contents.font.color = system_color
  41.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  42.   end
  43. end
  44. #==============================================================================
  45. # ■ Scene_MShop
  46. #------------------------------------------------------------------------------
  47. #  处理特技商店画面的类。
  48. #==============================================================================
  49. class Scene_MShop
  50.   #--------------------------------------------------------------------------
  51.   # ● 初始化
  52.   #--------------------------------------------------------------------------
  53.   def initialize(id)
  54.     @id = id
  55.   end  
  56.   #--------------------------------------------------------------------------
  57.   # ● 主处理
  58.   #--------------------------------------------------------------------------
  59.   def main
  60.     screen = Spriteset_Map.new
  61.     $game_variables[9] = $game_party.armor_number(951)
  62.     if $game_party.actors.size == 1
  63.     else
  64.       $game_party.remove_actor(997)#主角离开队伍
  65.     end
  66.     if $mShop_use_variable == 0
  67.       $mShop_gold = $game_party.gold
  68.     else
  69.       $mShop_gold = $game_variables[$mShop_use_variable]
  70.     end
  71.     # 生成帮助窗口
  72.     @help_window = Window_Help.new
  73.     @help_window.z=1896
  74.     @help_window.opacity = $mShop_Window_Opacity
  75.     # 生成金钱窗口
  76.     @gold_window = Window_MGold.new
  77.     @gold_window.x = 368
  78.     @gold_window.y = 416
  79.     @gold_window.z=1896
  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.z=1896
  87.     @buy_window.opacity = $mShop_Window_Opacity
  88.     # 生成状态窗口
  89.     @status_window = Window_MShopStatus.new
  90.     @status_window.visible = true
  91.     @status_window.active = false
  92.     @status_window.z=1896
  93.     @status_window.opacity = $mShop_Window_Opacity
  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.     screen.dispose
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 刷新画面
  121.   #--------------------------------------------------------------------------
  122.   def update
  123.     # 刷新窗口
  124.     @help_window.update
  125.     #@mhelp_window.update
  126.     @gold_window.update
  127.     @buy_window.update
  128.     @status_window.update
  129.     # 购买窗口激活的情况下: 调用 update_buy
  130.     if @buy_window.active
  131.       update_buy
  132.       return
  133.     end
  134.     if @status_window.active
  135.       update_status
  136.       return
  137.     end
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 刷新画面 (购买窗口激活的情况下)
  141.   #--------------------------------------------------------------------------
  142.   def update_buy
  143.     @status_window.skill = @buy_window.skill
  144.     if Input.trigger?(Input::B)
  145.       $game_system.se_play($data_system.cancel_se)
  146.       $game_variables[25] = $game_party.armor_number(951)
  147.       $game_variables[24] = $game_variables[25] - $game_variables[9]
  148.       $game_party.gain_armor(951,-$game_variables[24])
  149.       $game_party.add_actor(997)#主角加入队伍
  150.       $scene = Scene_Map.new
  151.       return
  152.     end
  153.     if Input.trigger?(Input::C)
  154.       @skill = @buy_window.skill
  155.       if @skill == nil or @skill.price > $mShop_gold
  156.         $game_system.se_play($data_system.buzzer_se)
  157.         return
  158.       end
  159.       $game_system.se_play($data_system.decision_se)
  160.       @buy_window.active = false
  161.       @status_window.index = 0
  162.       @status_window.active = true
  163.     end
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 刷新画面 (状态窗口激活的情况下)
  167.   #--------------------------------------------------------------------------
  168.   def update_status
  169.     if Input.trigger?(Input::B)
  170.       $game_system.se_play($data_system.cancel_se)
  171.       @status_window.active = false
  172.       @status_window.index = -1
  173.       @buy_window.active = true
  174.     end
  175.     actor = $game_party.actors[@status_window.index]
  176.     if Input.trigger?(Input::C)
  177.       can_learn=false
  178.       for j in $data_classes[actor.class_id].learnings
  179.         if j.skill_id == @skill.id
  180.           can_learn=true
  181.         end
  182.       end

  183.       unless $class_canlearn_list[actor.class_id].nil?
  184.         can_learn = true if $class_canlearn_list[actor.class_id].include?(@skill.id)
  185.       end

  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 protected])
  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(22, 80*i, 240, 32, actor.name)
  239.       self.contents.draw_text(0, 80*i , 240-42,32,"等级",2)
  240.       self.contents.font.color = normal_color
  241.       self.contents.draw_text(0, 80*i, 240-22, 32, actor.level.to_s , 2)
  242.       self.contents.font.color = system_color
  243.       self.contents.draw_text(22, 80*i+22, 45, 32, $data_system.words.hp)
  244.       self.contents.font.color = normal_color
  245.       self.contents.draw_text(22, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  246.       self.contents.font.color = system_color
  247.       self.contents.draw_text(128, 80*i+22, 45, 32, $data_system.words.sp)
  248.       self.contents.font.color = normal_color
  249.       self.contents.draw_text(128, 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.       if can_learn == true
  260.         if actor.skill_learn?(@skill.id)
  261.           self.contents.font.color = Color.new(255,255,255,128)
  262.           self.contents.draw_text(31, 80*i+44, 196, 32, "已经学会该技能 ",2)        
  263.         else
  264.           self.contents.font.color = Color.new(255,255,0,255)
  265.           self.contents.draw_text(31, 80*i+44, 196, 32, "可以学会该技能 ",2)
  266.         end
  267.       else
  268.         self.contents.font.color = Color.new(255,255,255,128)
  269.         self.contents.draw_text(31, 80*i+44, 196, 32, "不适合学该技能 ",2)        
  270.       end
  271.     end
  272.     @item_max = $game_party.actors.size
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● 设置物品
  276.   #     item : 新的物品
  277.   #--------------------------------------------------------------------------
  278.   def skill=(skill)
  279.     if @skill != skill
  280.       @skill = skill
  281.       refresh
  282.     end
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 刷新光标矩形
  286.   #--------------------------------------------------------------------------
  287.   def update_cursor_rect
  288.     if @index < 0
  289.       self.cursor_rect.empty
  290.     else
  291.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  292.     end
  293.   end
  294. end
  295. #==============================================================================
  296. # ■ Window_MShopBuy
  297. #------------------------------------------------------------------------------
  298. #  特技商店画面、浏览显示可以购买的商品的窗口。
  299. #==============================================================================
  300. class Window_MShopBuy < Window_Selectable
  301.   #--------------------------------------------------------------------------
  302.   # ● 初始化对像
  303.   #     shop_goods : 商品
  304.   #--------------------------------------------------------------------------
  305.   def initialize(id)
  306.     super(0, 64, 368, 416)
  307.     @id = id
  308.     refresh
  309.     self.index = 0
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ● 获取物品
  313.   #--------------------------------------------------------------------------
  314.   def skill
  315.     return @data[self.index]
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 刷新
  319.   #--------------------------------------------------------------------------
  320.   def refresh
  321.     if self.contents != nil
  322.       self.contents.dispose
  323.       self.contents = nil
  324.     end
  325.     @data = []
  326.     for skill_id in @id
  327.       skill = $data_skills[skill_id]
  328.       if skill != nil
  329.         @data.push(skill)
  330.       end
  331.     end
  332.     @item_max = @data.size
  333.     if @item_max > 0
  334.       self.contents = Bitmap.new(width - 32, row_max * 32)
  335.       for i in 0...@item_max
  336.         draw_item(i)
  337.       end
  338.     end
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ● 描绘羡慕
  342.   #     index : 项目编号
  343.   #--------------------------------------------------------------------------
  344.   def draw_item(index)
  345.     skill = @data[index]
  346.     # 除此之外的情况设置为无效文字色
  347.     if skill.price <= $mShop_gold
  348.       self.contents.font.color = normal_color
  349.     else
  350.       self.contents.font.color = disabled_color
  351.     end
  352.     x = 4
  353.     y = index * 32
  354.     rect = Rect.new(x, y, self.width - 32, 32)
  355.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  356.     bitmap = RPG::Cache.icon(skill.icon_name)
  357.     opacity = self.contents.font.color == normal_color ? 255 : 128
  358.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  359.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  360.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 刷新帮助文本
  364.   #--------------------------------------------------------------------------
  365.   def update_help
  366.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  367.   end
  368. end
  369. #==============================================================================
  370. # ■ RPG原装定义
  371. #==============================================================================
  372. module RPG
  373.   class Skill
  374.     def description
  375.       description = @description.split(/@/)[0]
  376.       return description != nil ? description : ''
  377.     end
  378.     def price
  379.       price = @description.split(/@/)[1]
  380.       return price != nil ? price.to_i : 0
  381.     end
  382.   end
  383. end
复制代码

Lv4.逐梦者

梦石
0
星屑
19284
在线时间
3074 小时
注册时间
2013-1-11
帖子
1288
2
发表于 2018-10-11 08:50:44 | 只看该作者
191-193、265-267分别替换为

  1.       unless $class_canlearn_list[@skill.id].nil?
  2.         can_learn = true if $class_canlearn_list[@skill.id].include?(actor.class_id)
  3.       end
复制代码

点评

卧槽,666666.谢谢大神  发表于 2018-10-11 09:21

评分

参与人数 2星屑 +30 +1 收起 理由
guoxiaomi + 30 认可答案
阮声悠悠 + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 23:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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