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

Project1

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

[已经过期] 使用魔法商店脚本时发生错误

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
183 小时
注册时间
2012-1-16
帖子
140
跳转到指定楼层
1
发表于 2012-4-4 11:20:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. =begin

  2. 复制全部脚本内容,在Main脚本之前按insert,插入此脚本全部内容。
  3. 首先,参考在脚本的顶部注释修改购买魔法消耗的货币称呼和变量编号(=0就是金钱)。
  4. 然后,给你所有可以购买的魔法的介绍说明部分,在后面添加 @价格。比如给某个冰魔法设置如下:

  5. 给予敌单体冰属性伤害。@500
  6. 最后,需要呼叫魔法商店的时候,在事件中使用脚本:$scene = Scene_MShop.new([1,2,3,4,5,6,8,10,21])

  7. 这样,其中的数字表示这个商店中出售的魔法编号。注意两点:1、中括号不可省略,2、如果一行输入不下,可以在数字的逗号后面换行,参考范例工程和截图。
  8. =end

  9. #==============================================================================

  10. # ■ 本脚本源自www.66rpg.com,转载与使用请保留此信息

  11. #==============================================================================


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


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


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


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


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


  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.     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.       $scene = Scene_Map.new

  138.       return

  139.     end

  140.     if Input.trigger?(Input::C)

  141.       @skill = @buy_window.skill

  142.       if @skill == nil or @skill.price > $mShop_gold

  143.         $game_system.se_play($data_system.buzzer_se)

  144.         return

  145.       end

  146.       $game_system.se_play($data_system.decision_se)

  147.       @buy_window.active = false

  148.       @status_window.index = 0

  149.       @status_window.active = true

  150.     end

  151.   end

  152.   #--------------------------------------------------------------------------

  153.   # ● 刷新画面 (状态窗口激活的情况下)

  154.   #--------------------------------------------------------------------------

  155.   def update_status

  156.     if Input.trigger?(Input::B)

  157.       $game_system.se_play($data_system.cancel_se)

  158.       @status_window.active = false

  159.       @status_window.index = -1

  160.       @buy_window.active = true

  161.     end

  162.     if Input.trigger?(Input::C)

  163.       can_learn=false

  164.       for j in $data_classes[$game_party.actors[@status_window.index].class_id].learnings

  165.         if j.skill_id == @skill.id

  166.           can_learn=true

  167.         end

  168.       end

  169.       if can_learn==false

  170.         $game_system.se_play($data_system.cancel_se)

  171.         return

  172.       end

  173.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)

  174.         $game_system.se_play($data_system.cancel_se)

  175.         return

  176.       else

  177.         $game_system.se_play($data_system.decision_se)

  178.         if $mShop_use_variable == 0

  179.           $game_party.gain_gold([email protected])

  180.           $mShop_gold -= @skill.price

  181.         else

  182.           $game_variables[$mShop_use_variable] -= @skill.price

  183.           $mShop_gold -= @skill.price

  184.         end

  185.         $game_party.actors[@status_window.index].learn_skill(@skill.id)

  186.         @gold_window.refresh

  187.         @buy_window.refresh

  188.         @status_window.refresh

  189.         @status_window.active = false

  190.         @status_window.index = -1

  191.         @buy_window.active = true

  192.       end      

  193.     end   
  194.   end

  195. end

  196. #==============================================================================

  197. # ■ Window_MShopStatus

  198. #------------------------------------------------------------------------------

  199. #  特技商店画面、显示物品所持数与角色装备的窗口。

  200. #==============================================================================

  201. class Window_MShopStatus < Window_Selectable

  202.   #--------------------------------------------------------------------------

  203.   # ● 初始化对像

  204.   #--------------------------------------------------------------------------

  205.   def initialize

  206.     super(368, 64, 272, 352)

  207.     self.contents = Bitmap.new(width - 32, height - 32)

  208.     self.contents.font.size = 18

  209.     @skill = nil

  210.     refresh

  211.   end

  212.   #--------------------------------------------------------------------------

  213.   # ● 刷新

  214.   #--------------------------------------------------------------------------

  215.   def refresh

  216.     self.contents.clear

  217.     for i in 0...$game_party.actors.size

  218.       actor = $game_party.actors[i]

  219.       draw_actor_graphic(actor,12,80*i+64)

  220.       self.contents.font.color = system_color

  221.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)

  222.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)

  223.       self.contents.font.color = normal_color

  224.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)

  225.       self.contents.font.color = system_color

  226.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)

  227.       self.contents.font.color = normal_color

  228.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)

  229.       self.contents.font.color = system_color

  230.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)

  231.       self.contents.font.color = normal_color

  232.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)   
  233.       can_learn=false

  234.       for j in $data_classes[actor.class_id].learnings

  235.         if j.skill_id == @skill.id

  236.           can_learn=true

  237.         end

  238.       end

  239.       if can_learn == true

  240.         if actor.skill_learn?(@skill.id)

  241.           self.contents.font.color = Color.new(255,255,255,128)

  242.           self.contents.draw_text(44, 80*i+44, 196, 32, "⊙已经学习⊙",2)        

  243.         else

  244.           self.contents.font.color = Color.new(255,255,0,255)

  245.           self.contents.draw_text(44, 80*i+44, 240, 32, "★尚未学习★")

  246.         end

  247.       else

  248.         self.contents.font.color = Color.new(255,255,255,128)

  249.         self.contents.draw_text(44, 80*i+44, 196, 32, "◇无法学习◇",2)        

  250.       end

  251.     end

  252.     @item_max = $game_party.actors.size

  253.   end

  254.   #--------------------------------------------------------------------------

  255.   # ● 设置物品

  256.   #     item : 新的物品

  257.   #--------------------------------------------------------------------------

  258.   def skill=(skill)

  259.     if @skill != skill

  260.       @skill = skill

  261.       refresh

  262.     end

  263.   end

  264.   #--------------------------------------------------------------------------

  265.   # ● 刷新光标矩形

  266.   #--------------------------------------------------------------------------

  267.   def update_cursor_rect

  268.     if @index < 0

  269.       self.cursor_rect.empty

  270.     else

  271.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)

  272.     end

  273.   end

  274. end

  275. #==============================================================================

  276. # ■ Window_MShopBuy

  277. #------------------------------------------------------------------------------

  278. #  特技商店画面、浏览显示可以购买的商品的窗口。

  279. #==============================================================================

  280. class Window_MShopBuy < Window_Selectable

  281.   #--------------------------------------------------------------------------

  282.   # ● 初始化对像

  283.   #     shop_goods : 商品

  284.   #--------------------------------------------------------------------------

  285.   def initialize(id)

  286.     super(0, 64, 368, 416)

  287.     @id = id

  288.     refresh

  289.     self.index = 0

  290.   end

  291.   #--------------------------------------------------------------------------

  292.   # ● 获取物品

  293.   #--------------------------------------------------------------------------

  294.   def skill

  295.     return @data[self.index]

  296.   end

  297.   #--------------------------------------------------------------------------

  298.   # ● 刷新

  299.   #--------------------------------------------------------------------------

  300.   def refresh

  301.     if self.contents != nil

  302.       self.contents.dispose

  303.       self.contents = nil

  304.     end

  305.     @data = []

  306.     for skill_id in @id

  307.       skill = $data_skills[skill_id]

  308.       if skill != nil

  309.         @data.push(skill)

  310.       end

  311.     end

  312.     @item_max = @data.size

  313.     if @item_max > 0

  314.       self.contents = Bitmap.new(width - 32, row_max * 32)

  315.       for i in 0...@item_max

  316.         draw_item(i)

  317.       end

  318.     end

  319.   end

  320.   #--------------------------------------------------------------------------

  321.   # ● 描绘羡慕

  322.   #     index : 项目编号

  323.   #--------------------------------------------------------------------------

  324.   def draw_item(index)

  325.     skill = @data[index]

  326.     # 除此之外的情况设置为无效文字色

  327.     if skill.price <= $mShop_gold

  328.       self.contents.font.color = normal_color

  329.     else

  330.       self.contents.font.color = disabled_color

  331.     end

  332.     x = 4

  333.     y = index * 32

  334.     rect = Rect.new(x, y, self.width - 32, 32)

  335.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

  336.     bitmap = RPG::Cache.icon(skill.icon_name)

  337.     opacity = self.contents.font.color == normal_color ? 255 : 128

  338.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

  339.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)

  340.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)

  341.   end

  342.   #--------------------------------------------------------------------------

  343.   # ● 刷新帮助文本

  344.   #--------------------------------------------------------------------------

  345.   def update_help

  346.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)

  347.   end

  348. end

  349. #==============================================================================

  350. # ■ RPG原装定义

  351. #==============================================================================

  352. module RPG

  353.   class Skill

  354.     def description

  355.       description = @description.split(/@/)[0]

  356.       return description != nil ? description : ''

  357.     end

  358.     def price

  359.       price = @description.split(/@/)[1]

  360.       return price != nil ? price.to_i : 0

  361.     end

  362.   end

  363. end



  364. #==============================================================================
复制代码
这个是脚本
错误的提示为
ArgumengtError
Wrong numeber of argumengts (0 for 1)
好像是变量的问题…

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
2
发表于 2012-4-4 13:09:30 | 只看该作者
请给出错误提示的行数……

点评

额…脚本也没告诉我哪行出错 当用“$scene = Scene_MShop.new([1,2,3,4,5,6,8,10,21])”呼出商店的时候,直接弹出上面的对话框报错 然后就退出来了… 进脚本编辑   发表于 2012-4-4 13:19

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
183 小时
注册时间
2012-1-16
帖子
140
3
 楼主| 发表于 2012-4-4 13:20:27 | 只看该作者
Wind2010 发表于 2012-4-4 13:09
请给出错误提示的行数……

没提示我哪里出错…
呼出魔法商店界面的时候就出错然后登出来了
我用新建的干净的工程测试时也是这样
想买一艘船         0/1
想住在一个凉爽的的国度         0/1
想获得永生         N/A
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-12 05:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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