Project1

标题: 求教魔法商店技能学习前提 [打印本页]

作者: a118045648    时间: 2011-7-28 11:12
标题: 求教魔法商店技能学习前提
也就是技能LV1学习后才能学习LV2,在魔法商店的技能描述上
  1. if actor.skill_learn?(@skill.id)
  2.         self.contents.font.color = Color.new(255,255,255,128)
  3.         self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)        
  4.       else
  5.         self.contents.font.color = Color.new(255,255,0,255)
  6.         self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
  7.       end
  8.     end
复制代码
再加上一个“请先学习该系技能LV1或LV2”

魔法商店范例.rar (187.69 KB, 下载次数: 165) dsu_plus_rewardpost_czw
作者: 秋庭里香    时间: 2011-7-28 11:52
  1. #==============================================================================
  2. # ■ 本脚本源自www.66rpg.com,转载与使用请保留此信息
  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.     Graphics.transition
  79.     # 主循环
  80.     loop do
  81.       # 刷新游戏画面
  82.       Graphics.update
  83.       # 刷新输入信息
  84.       Input.update
  85.       # 刷新画面
  86.       update
  87.       # 如果画面切换的话就中断循环
  88.       if $scene != self
  89.         break
  90.       end
  91.     end
  92.     # 准备过渡
  93.     Graphics.freeze
  94.     # 释放窗口
  95.     @help_window.dispose
  96.     #@mhelp_window.dispose
  97.     @gold_window.dispose
  98.     @buy_window.dispose
  99.     @status_window.dispose
  100.     screen.dispose
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 刷新画面
  104.   #--------------------------------------------------------------------------
  105.   def update
  106.     # 刷新窗口
  107.     @help_window.update
  108.     #@mhelp_window.update
  109.     @gold_window.update
  110.     @buy_window.update
  111.     @status_window.update
  112.     # 购买窗口激活的情况下: 调用 update_buy
  113.     if @buy_window.active
  114.       update_buy
  115.       return
  116.     end
  117.     if @status_window.active
  118.       update_status
  119.       return
  120.     end
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 刷新画面 (购买窗口激活的情况下)
  124.   #--------------------------------------------------------------------------
  125.   def update_buy
  126.     @status_window.skill = @buy_window.skill
  127.     if Input.trigger?(Input::B)
  128.       $game_system.se_play($data_system.cancel_se)
  129.       $scene = Scene_Map.new
  130.       return
  131.     end
  132.     if Input.trigger?(Input::C)
  133.       @skill = @buy_window.skill
  134.       if @skill == nil or @skill.price > $mShop_gold
  135.         $game_system.se_play($data_system.buzzer_se)
  136.         return
  137.       end
  138.       $game_system.se_play($data_system.decision_se)
  139.       @buy_window.active = false
  140.       @status_window.index = 0
  141.       @status_window.active = true
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 刷新画面 (状态窗口激活的情况下)
  146.   #--------------------------------------------------------------------------
  147.   def update_status
  148.     if Input.trigger?(Input::B)
  149.       $game_system.se_play($data_system.cancel_se)
  150.       @status_window.active = false
  151.       @status_window.index = -1
  152.       @buy_window.active = true
  153.     end
  154.     if Input.trigger?(Input::C)
  155.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
  156.         $game_system.se_play($data_system.cancel_se)
  157.         return
  158.       elsif @skill != nil and @skill.uplevel_lv32 != nil and !$game_party.actors[@status_window.index].skill_learn?(@skill.uplevel_lv32)
  159.         $game_system.se_play($data_system.cancel_se)
  160.         return
  161.       else
  162.         $game_system.se_play($data_system.decision_se)
  163.         if $mShop_use_variable == 0
  164.           $game_party.gain_gold([email protected])
  165.           $mShop_gold -= @skill.price
  166.         else
  167.           $game_variables[$mShop_use_variable] -= @skill.price
  168.           $mShop_gold -= @skill.price
  169.         end
  170.         $game_party.actors[@status_window.index].learn_skill(@skill.id)
  171.         @gold_window.refresh
  172.         @buy_window.refresh
  173.         @status_window.refresh
  174.         @status_window.active = false
  175.         @status_window.index = -1
  176.         @buy_window.active = true
  177.       end      
  178.     end   
  179.   end
  180. end
  181. #==============================================================================
  182. # ■ Window_MShopStatus
  183. #------------------------------------------------------------------------------
  184. #  特技商店画面、显示物品所持数与角色装备的窗口。
  185. #==============================================================================
  186. class Window_MShopStatus < Window_Selectable
  187.   #--------------------------------------------------------------------------
  188.   # ● 初始化对像
  189.   #--------------------------------------------------------------------------
  190.   def initialize
  191.     super(368, 64, 272, 352)
  192.     self.contents = Bitmap.new(width - 32, height - 32)
  193.     self.contents.font.size = 18
  194.     @skill = nil
  195.     refresh
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 刷新
  199.   #--------------------------------------------------------------------------
  200.   def refresh
  201.     self.contents.clear
  202.     for i in 0...$game_party.actors.size
  203.       actor = $game_party.actors[i]
  204.       draw_actor_graphic(actor,12,80*i+64)
  205.       self.contents.font.color = system_color
  206.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  207.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  208.       self.contents.font.color = normal_color
  209.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  210.       self.contents.font.color = system_color
  211.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  212.       self.contents.font.color = normal_color
  213.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  214.       self.contents.font.color = system_color
  215.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  216.       self.contents.font.color = normal_color
  217.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)
  218.       
  219.       if actor.skill_learn?(@skill.id)
  220.         self.contents.font.color = Color.new(255,255,255,128)
  221.         self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)        
  222.       elsif @skill != nil and @skill.uplevel_lv32 != nil and !actor.skill_learn?(@skill.uplevel_lv32)
  223.         self.contents.font.color = Color.new(255,255,255,128)
  224.         self.contents.draw_text(44, 80*i+44, 196, 32, "⊙请先学习上级技能⊙",2)
  225.       else
  226.         self.contents.font.color = Color.new(255,255,0,255)
  227.         self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
  228.       end
  229.     end
  230.     @item_max = $game_party.actors.size
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 设置物品
  234.   #     item : 新的物品
  235.   #--------------------------------------------------------------------------
  236.   def skill=(skill)
  237.     if @skill != skill
  238.       @skill = skill
  239.       refresh
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 刷新光标矩形
  244.   #--------------------------------------------------------------------------
  245.   def update_cursor_rect
  246.     if @index < 0
  247.       self.cursor_rect.empty
  248.     else
  249.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  250.     end
  251.   end
  252. end
  253. #==============================================================================
  254. # ■ Window_MShopBuy
  255. #------------------------------------------------------------------------------
  256. #  特技商店画面、浏览显示可以购买的商品的窗口。
  257. #==============================================================================
  258. class Window_MShopBuy < Window_Selectable
  259.   #--------------------------------------------------------------------------
  260.   # ● 初始化对像
  261.   #     shop_goods : 商品
  262.   #--------------------------------------------------------------------------
  263.   def initialize(id)
  264.     super(0, 64, 368, 416)
  265.     @id = id
  266.     refresh
  267.     self.index = 0
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 获取物品
  271.   #--------------------------------------------------------------------------
  272.   def skill
  273.     return @data[self.index]
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 刷新
  277.   #--------------------------------------------------------------------------
  278.   def refresh
  279.     if self.contents != nil
  280.       self.contents.dispose
  281.       self.contents = nil
  282.     end
  283.     @data = []
  284.     for skill_id in @id
  285.       skill = $data_skills[skill_id]
  286.       if skill != nil
  287.         @data.push(skill)
  288.       end
  289.     end
  290.     @item_max = @data.size
  291.     if @item_max > 0
  292.       self.contents = Bitmap.new(width - 32, row_max * 32)
  293.       for i in 0...@item_max
  294.         draw_item(i)
  295.       end
  296.     end
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 描绘羡慕
  300.   #     index : 项目编号
  301.   #--------------------------------------------------------------------------
  302.   def draw_item(index)
  303.     skill = @data[index]
  304.     # 除此之外的情况设置为无效文字色
  305.     if skill.price <= $mShop_gold
  306.       self.contents.font.color = normal_color
  307.     else
  308.       self.contents.font.color = disabled_color
  309.     end
  310.     x = 4
  311.     y = index * 32
  312.     rect = Rect.new(x, y, self.width - 32, 32)
  313.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  314.     bitmap = RPG::Cache.icon(skill.icon_name)
  315.     opacity = self.contents.font.color == normal_color ? 255 : 128
  316.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  317.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  318.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● 刷新帮助文本
  322.   #--------------------------------------------------------------------------
  323.   def update_help
  324.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  325.   end
  326. end
  327. #==============================================================================
  328. # ■ RPG原装定义
  329. #==============================================================================
  330. module RPG
  331.   class Skill
  332.     def description
  333.       description = @description.split(/@/)[0]
  334.       return description != nil ? description : ''
  335.     end
  336.     def price
  337.       price = @description.split(/@/)[1]
  338.       return price != nil ? price.to_i : 0
  339.     end
  340.     def name
  341.       name = @name.split(/@/)[0]
  342.       return name != nil ? name : ''
  343.     end
  344.     def uplevel_lv32
  345.       name = @name.split(/@/)[1]
  346.       return name != nil ? name.to_i : nil
  347.     end
  348.   end
  349. end
复制代码
稍微改了一下,现在只需要在名称后面加上 @13 就可以达到“必须学习13号技能才可以学习”的效果~例如:LV2 @13
作者: a118045648    时间: 2011-7-28 12:06
秋庭里香 发表于 2011-7-28 11:52
稍微改了一下,现在只需要在名称后面加上 @13 就可以达到“必须学习13号技能才可以学习”的效果~例如:LV2  ...

谢谢了~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1