Project1

标题: 为什么我把任务脚本写好了,商店就不能用了? [打印本页]

作者: 876加几    时间: 2013-10-6 11:20
标题: 为什么我把任务脚本写好了,商店就不能用了?
一个游戏没有商店是不能运行的。好吧,直接上图。

↑这个是任务系统↑

↑这个是商店报错图像↑
我没有改商店任何东西!
好吧,任务系统脚本:
  1. #==============================================================================
  2. # ■ Game_Temp
  3. #------------------------------------------------------------------------------
  4. #  在没有存档的情况下,处理临时数据的类。这个类的实例请参考
  5. # $game_temp 。
  6. #==============================================================================

  7. class Game_Temp
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_accessor :map_bgm                  # 地图画面 BGM (战斗时记忆用)
  12.   attr_accessor :message_text             # 信息文章
  13.   attr_accessor :message_proc             # 信息 返回调用 (Proc)
  14.   attr_accessor :choice_start             # 选择项 开始行
  15.   attr_accessor :choice_max               # 选择项 项目数
  16.   attr_accessor :choice_cancel_type       # 选择项 取消的情况
  17.   attr_accessor :choice_proc              # 选择项 返回调用 (Proc)
  18.   attr_accessor :num_input_start          # 输入数值 开始行
  19.   attr_accessor :num_input_variable_id    # 输入数值 变量 ID
  20.   attr_accessor :num_input_digits_max     # 输入数值 位数
  21.   attr_accessor :message_window_showing   # 显示信息窗口
  22.   attr_accessor :common_event_id          # 公共事件 ID
  23.   attr_accessor :in_battle                # 战斗中的标志
  24.   attr_accessor :battle_calling           # 调用战斗的标志
  25.   attr_accessor :battle_troop_id          # 战斗 队伍 ID
  26.   attr_accessor :battle_can_escape        # 战斗中 允许逃跑 ID
  27.   attr_accessor :battle_can_lose          # 战斗中 允许失败 ID
  28.   attr_accessor :battle_proc              # 战斗 返回调用 (Proc)
  29.   attr_accessor :battle_turn              # 战斗 回合数
  30.   attr_accessor :battle_event_flags       # 战斗 事件执行执行完毕的标志
  31.   attr_accessor :battle_abort             # 战斗 中断标志
  32.   attr_accessor :battle_main_phase        # 战斗 状态标志
  33.   attr_accessor :battleback_name          # 战斗背景 文件名
  34.   attr_accessor :forcing_battler          # 强制行动的战斗者
  35.   attr_accessor :shop_calling             # 调用商店的标志
  36.   attr_accessor :shop_goods               # 商店 商品列表
  37.   attr_accessor :name_calling             # 输入名称 调用标志
  38.   attr_accessor :name_actor_id            # 输入名称 角色 ID
  39.   attr_accessor :name_max_char            # 输入名称 最大字数
  40.   attr_accessor :menu_calling             # 菜单 调用标志
  41.   attr_accessor :menu_beep                # 菜单 SE 演奏标志
  42.   attr_accessor :save_calling             # 存档 调用标志
  43.   attr_accessor :debug_calling            # 调试 调用标志
  44.   attr_accessor :player_transferring      # 主角 场所移动标志
  45.   attr_accessor :player_new_map_id        # 主角 移动目标地图 ID
  46.   attr_accessor :player_new_x             # 主角 移动目标 X 坐标
  47.   attr_accessor :player_new_y             # 主角 移动目标 Y 坐标
  48.   attr_accessor :player_new_direction     # 主角 移动目标 朝向
  49.   attr_accessor :transition_processing    # 过渡处理中标志
  50.   attr_accessor :transition_name          # 过渡 文件名
  51.   attr_accessor :gameover                 # 游戏结束标志
  52.   attr_accessor :to_title                 # 返回标题画面标志
  53.   attr_accessor :last_file_index          # 最后存档的文件编号
  54.   attr_accessor :debug_top_row            # 调试画面 保存状态用
  55.   attr_accessor :debug_index              # 调试画面 保存状态用
  56.   attr_accessor :new_task_name            # 新任务 名称
  57.   attr_accessor :new_task_help            # 新任务 帮助文字
  58.   attr_accessor :new_task_gold            # 新任务 奖励金钱
  59.   attr_accessor :new_task_items           # 新任务 奖励物品
  60.   attr_accessor :new_task_weapons         # 新任务 奖励武器
  61.   attr_accessor :new_task_armors          # 新任务 奖励防具
  62.   attr_accessor :new_task_item_num        # 新任务 物品奖励数量
  63.   attr_accessor :new_task_weapon_num      # 新任务 武器奖励数量
  64.   attr_accessor :new_task_armor_num       # 新任务 防具奖励数量
  65.   attr_accessor :new_task_difficulty
  66.   #--------------------------------------------------------------------------
  67.   # ● 初始化对像
  68.   #--------------------------------------------------------------------------
  69.   def initialize
  70.     @map_bgm = nil
  71.     @message_text = nil
  72.     @message_proc = nil
  73.     @choice_start = 99
  74.     @choice_max = 0
  75.     @choice_cancel_type = 0
  76.     @choice_proc = nil
  77.     @num_input_start = 99
  78.     @num_input_variable_id = 0
  79.     @num_input_digits_max = 0
  80.     @message_window_showing = false
  81.     @common_event_id = 0
  82.     @in_battle = false
  83.     @battle_calling = false
  84.     @battle_troop_id = 0
  85.     @battle_can_escape = false
  86.     @battle_can_lose = false
  87.     @battle_proc = nil
  88.     @battle_turn = 0
  89.     @battle_event_flags = {}
  90.     @battle_abort = false
  91.     @battle_main_phase = false
  92.     @battleback_name = ''
  93.     @forcing_battler = nil
  94.     @shop_calling = false
  95.     @shop_id = 0
  96.     @name_calling = false
  97.     @name_actor_id = 0
  98.     @name_max_char = 0
  99.     @menu_calling = false
  100.     @menu_beep = false
  101.     @save_calling = false
  102.     @debug_calling = false
  103.     @player_transferring = false
  104.     @player_new_map_id = 0
  105.     @player_new_x = 0
  106.     @player_new_y = 0
  107.     @player_new_direction = 0
  108.     @transition_processing = false
  109.     @transition_name = ""
  110.     @gameover = false
  111.     @to_title = false
  112.     @last_file_index = 0
  113.     @debug_top_row = 0
  114.     @debug_index = 0
  115.     @new_task_name = ""
  116.     @new_task_help = ""
  117.     @new_task_gold = ""
  118.     @new_task_items = nil
  119.     @new_task_weapons = nil
  120.     @new_task_armors = nil
  121.     @new_task_item_num = 0
  122.     @new_task_weapon_num = 0
  123.     @new_task_armor_num = 0
  124.     @new_task_difficulty = 1
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 生成新任务(在Scene_Task的内部使用)
  128.   #--------------------------------------------------------------------------
  129.   def new_task(name, help, difficulty = 1, gold = 0, items = nil, weapons = nil, armors = nil, item_num = 1, weapon_num = 1, armor_num = 1)
  130.     # 实例变量的改变
  131.     @new_task_name = name
  132.     @new_task_help = help
  133.     @new_task_gold = gold
  134.     @new_task_items = items
  135.     @new_task_weapons = weapons
  136.     @new_task_armors = armors
  137.     @new_task_item_num = item_num
  138.     @new_task_weapon_num = weapon_num
  139.     @new_task_armor_num = armor_num
  140.     @new_task_difficulty = difficulty
  141.     $game_taskdata.tasks += 1
  142.     # 保存数据(载入数组)
  143.     if $game_taskdata.task_name[0] == ""
  144.       $game_taskdata.task_name = [@new_task_name]
  145.       $game_taskdata.task_command_name = [@new_task_name]
  146.       $game_taskdata.task_help = [@new_task_help]
  147.       $game_taskdata.task_gold = [@new_task_gold]
  148.       $game_taskdata.task_items = [@new_task_items]
  149.       $game_taskdata.task_weapons = [@new_task_weapons]
  150.       $game_taskdata.task_armors = [@new_task_armors]
  151.       $game_taskdata.task_item_num = [@new_task_item_num]
  152.       $game_taskdata.task_weapon_num = [@new_task_weapon_num]
  153.       $game_taskdata.task_armor_num = [@new_task_armor_num]
  154.       $game_taskdata.task_difficulty = [@new_task_difficulty]
  155.     else
  156.       $game_taskdata.task_name.push(@new_task_name)
  157.       $game_taskdata.task_command_name.push(@new_task_name)
  158.       $game_taskdata.task_help.push(@new_task_help)
  159.       $game_taskdata.task_gold.push(@new_task_gold)
  160.       $game_taskdata.task_items.push(@new_task_items)
  161.       $game_taskdata.task_weapons.push(@new_task_weapons)
  162.       $game_taskdata.task_armors.push(@new_task_armors)
  163.       $game_taskdata.task_item_num.push(@new_task_item_num)
  164.       $game_taskdata.task_weapon_num.push(@new_task_weapon_num)
  165.       $game_taskdata.task_armor_num.push(@new_task_armor_num)
  166.       $game_taskdata.task_difficulty.push(@new_task_difficulty)
  167.     end                     
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● 完成任务(在Scene_Task的内部使用)
  171.   #--------------------------------------------------------------------------
  172.   def final_task(id)
  173.     # 算出数组中的id
  174.     id = id - 1
  175.     # 修改数组数据
  176.     $game_taskdata.task_command_name[id] = $game_taskdata.task_command_name[id] + "(已完成)"
  177.     $game_taskdata.task_help[id] = $game_taskdata.task_help[id] + "\n(已完成)"
  178.     # 获得任务奖励
  179.     unless $game_taskdata.task_gold[id] == 0
  180.       $game_party.gain_gold($game_taskdata.task_gold[id])
  181.     end
  182.     unless $game_taskdata.task_items[id] == nil
  183.       $game_party.gain_item($game_taskdata.task_items[id], $game_taskdata.task_item_num[id])
  184.     end
  185.     unless $game_taskdata.task_weapons[id] == nil
  186.       $game_party.gain_weapon($game_taskdata.task_weapons[id], $game_taskdata.task_weapon_num[id])
  187.     end
  188.     unless $game_taskdata.task_armors[id] == nil
  189.       $game_party.gain_armor($game_taskdata.task_armors[id], $game_taskdata.task_weapon_num[id])
  190.     end
  191.   end
  192.   #------------------------------------------------------------------------
  193.   # 失败任务(啊啊啊!)
  194.   #------------------------------------------------------------------------
  195.   def lose_task(id)
  196.     $game_taskdata.task_command_name[id] = $game_taskdata.task_command_name[id] + "(已失败)"
  197.     $game_taskdata.task_help[id] = $game_taskdata.task_help[id] + "\n(已失败)"
  198.   end
  199. end
复制代码
  1. #==============================================================================
  2. # ■ Window_Task
  3. #------------------------------------------------------------------------------
  4. #  显示任务的选择行窗口。
  5. #==============================================================================

  6. class Window_Task < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 640, 480 - 64)
  12.     if $game_taskdata.tasks == 0
  13.       @item_max = 1
  14.     else
  15.       @item_max = $game_taskdata.tasks
  16.     end
  17.     difficulty = nil
  18.     self.contents = Bitmap.new(width - 32, height - 32)
  19.     refresh
  20.     self.index = 0
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 刷新
  24.   #--------------------------------------------------------------------------
  25.   def refresh
  26.     self.contents.clear
  27.     if $game_taskdata.tasks == 0
  28.       @item_max = 1
  29.     else
  30.       @item_max = $game_taskdata.tasks
  31.     end
  32.     if $game_taskdata.task_command_name[0] == ""
  33.       $f = true
  34.     else
  35.       $f = false
  36.     end
  37.     for i in 0...@item_max
  38.       draw_item(i,normal_color)
  39.     end
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 描绘项目
  43.   #     index : 项目编号
  44.   #     color : 文字色
  45.   #--------------------------------------------------------------------------
  46.   def draw_item(index,color)
  47.     self.contents.font.color = color
  48.     rect = Rect.new(4, 32 * index, 640 / 2 - 8, 32)
  49.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  50.     for i in 0...@item_max
  51.       self.contents.draw_text(rect, $game_taskdata.task_command_name[index])#ndex
  52.     end
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 项目无效化
  56.   #     index : 项目编号
  57.   #--------------------------------------------------------------------------
  58.   def disable_item(index)
  59.     draw_item(index, disabled_color)
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 刷新光标矩形
  63.   #--------------------------------------------------------------------------
  64.   def update_cursor_rect
  65.     if [url=home.php?mod=space&uid=370741]@Index[/url] < 0
  66.       self.cursor_rect.empty
  67.     else
  68.       self.cursor_rect.set(0, @index * 32, 320 - 8, 32)
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 拆分数组并显示内容
  73.   #--------------------------------------------------------------------------
  74.   def update
  75.     super
  76.     refresh
  77.     for i in 0...@item_max
  78.       x = 320 + 16
  79.       if self.index == i and $t == true and $game_taskdata.task_command_name[index] != ""
  80.         self.contents.font.color = system_color
  81.         self.contents.draw_text(x, 0, 100, 32, "任务名:")
  82.         self.contents.draw_text(x, 64, 100, 32, "难度:")
  83.         self.contents.draw_text(x, 112, 100, 32, "说明:")
  84.         if $game_taskdata.task_gold[index] != 0
  85.           self.contents.draw_text(x, 208, 100, 32, "奖励金钱:")
  86.           y = 272
  87.         else
  88.           y = 240
  89.         end
  90.         if $game_taskdata.task_items[index] != nil
  91.           self.contents.draw_text(x, y, 100, 32, "奖励物品:")
  92.         end
  93.         self.contents.font.color = normal_color
  94.         self.contents.draw_text(x, 32, 320 - 32, 32, $game_taskdata.task_name[index])
  95.         self.contents.draw_text(x, 144, 288, 32, $game_taskdata.task_help[index])
  96.         if $game_taskdata.task_gold[index] != 0
  97.           self.contents.draw_text(x, 208, 100, 32, $game_taskdata.task_gold[index])
  98.         end
  99.         if $game_taskdata.task_items[index] != nil
  100.           draw_item_name($data_items[$game_taskdata.task_items[index]], x, y + 32)
  101.           self.contents.draw_text(x + 100, y + 32, 280, 32, " × " + $game_taskdata.task_item_num[index].to_s)
  102.         end
  103.         if $game_taskdata.task_weapons[index] != nil
  104.           draw_item_name($data_weapons[$game_taskdata.task_weapons[index]], x, y + 64)
  105.           self.contents.draw_text(x + 100, y + 32, 280, 32, " × " + $game_taskdata.task_weapon_num[index].to_s)
  106.         end
  107.         if $game_taskdata.task_armors[index] != nil
  108.           draw_item_name($data_armors[$game_taskdata.task_armors[index]], x, y + 96)
  109.           self.contents.draw_text(x + 100, y + 32, 280, 32, " × " + $game_taskdata.task_armor_num[index].to_s)
  110.         end
  111.         text1 = "★" * $game_taskdata.task_difficulty[index]
  112.         text2 = "☆" * (5 - $game_taskdata.task_difficulty[index])
  113.         text = text1 + text2
  114.         self.contents.draw_text(x + 60, 64, 280, 32, text)
  115.       end
  116.     end
  117.     # 解除任务信息
  118.     if $t == true
  119.       # 按下 B 键的情况下
  120.       if Input.trigger?(Input::B)
  121.         $t = false
  122.         # 演奏取消 SE
  123.         $game_system.se_play($data_system.cancel_se)
  124.       end
  125.       if Input.trigger?(Input::UP)
  126.         $t = false
  127.         $game_system.se_play($data_system.cursor_se)
  128.       end
  129.       if Input.trigger?(Input::DOWN)
  130.         $t = false
  131.         $game_system.se_play($data_system.cursor_se)
  132.       end
  133.     end
  134.     if $t == false
  135.       refresh
  136.     end
  137.   end
  138. end
复制代码
  1. #===============================================================================
  2. # ● Scene_Task
  3. #-------------------------------------------------------------------------------
  4. #   处理任务画面的类。
  5. #===============================================================================
  6. class Scene_Task
  7.   #--------------------------------------------------------------------------
  8.   # ● 主处理
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     # 生成任务活动窗口
  12.     @task_window = Window_Task.new
  13.     @task_window.y = 64
  14.     if @task_window.active == false
  15.       @task_window.active = true
  16.     end
  17.     # 生成任务辅助窗口
  18.     @taskassist_window = Window_TaskAssist.new
  19.     # 执行过渡
  20.     Graphics.transition
  21.     # 主循环
  22.     loop do
  23.       # 刷新游戏画面
  24.       Graphics.update
  25.       # 刷新输入信息
  26.       Input.update
  27.       # 刷新画面
  28.       update
  29.       # 如果切换画面就中断循环
  30.       if $scene != self
  31.         break
  32.       end
  33.     end
  34.     # 准备过渡
  35.     Graphics.freeze
  36.     # 释放各个窗口
  37.     @task_window.dispose
  38.     @taskassist_window.dispose
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 刷新画面
  42.   #--------------------------------------------------------------------------
  43.   def update
  44.     # 刷新各个窗口
  45.     @task_window.update
  46.     @taskassist_window.update
  47.     # 解除任务信息
  48.     if $t == true
  49.       # 按下 B 键的情况下
  50.       if Input.trigger?(Input::B)
  51.         $t = false
  52.         # 演奏取消 SE
  53.         $game_system.se_play($data_system.cancel_se)
  54.       end
  55.       if Input.trigger?(Input::UP)
  56.         $t = false
  57.         $game_system.se_play($data_system.cursor_se)
  58.       end
  59.       if Input.trigger?(Input::DOWN)
  60.         $t = false
  61.         $game_system.se_play($data_system.cursor_se)
  62.       end
  63.     end
  64.     if $game_taskdata.tasks != 0
  65.       $f = false
  66.     end
  67.     # 当按下 C 键后可查看任务信息
  68.     if Input.trigger?(Input::C) and $game_taskdata.tasks != 0
  69.       $t = true #让T变为true
  70.       # 演奏确定 SE
  71.       $game_system.se_play($data_system.decision_se)
  72.     end
  73.     # 没显示任务时按下 B 键的情况下
  74.     if $t == false and Input.trigger?(Input::B)
  75.       # 切换到菜单界面
  76.       $scene = Scene_Menu.new(5)
  77.       # 演奏取消 SE
  78.       $game_system.se_play($data_system.cancel_se)
  79.     end
  80.     if $f == true
  81.       if Input.trigger?(Input::C)
  82.         # 演奏冻结 SE
  83.         $game_system.se_play($data_system.buzzer_se)
  84.       end
  85.       if Input.trigger?(Input::B)
  86.         # 切换到菜单界面
  87.         $scene = Scene_Menu.new(5)
  88.         # 演奏取消 SE
  89.         $game_system.se_play($data_system.cancel_se)
  90.       end
  91.     end
  92.   end
  93. end
复制代码
是不是某一项与商店冲突了?
作者: myownroc    时间: 2013-10-6 11:30
先占位置。
话说你把你的脚本放到新建的一个工程中试试。
作者: 弗雷德    时间: 2013-10-6 11:48
类型错误,无法将空值转换成字符串,请检查shopbuy 类 第84行是什么对象没有赋值。
作者: 紫英晓狼1130    时间: 2013-10-6 11:50
shopbuy没赋值,这也是LZ的脚本吧
作者: myownroc    时间: 2013-10-6 13:30
你的脚本在新工程里毫无问题,请检查是否更改了默认脚本Scene_ShopBuy。
作者: chd114    时间: 2013-10-6 17:13
把你的任务脚本去掉后还有错吗?




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