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

Project1

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

[通用发布] 超级命令窗口

[复制链接]

Lv1.梦旅人

梦石
0
星屑
90
在线时间
85 小时
注册时间
2012-5-27
帖子
148
跳转到指定楼层
1
发表于 2012-7-1 18:03:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 退屈£无聊 于 2012-7-2 08:55 编辑
  1. ################################################################################
  2. #                               《超级命令窗口》
  3. #        说句实话,我一直在考虑做不做这个脚本,因为这个脚本跟菜单真的很像,最后
  4. #还是做了!既然做了,那就来稍微讲一讲特点吧!这是一款完全教学脚本,可以用了自己
  5. #做参考学习,我在下面的每一个脚本都进行了详细的讲解,如果你要改,你可以很清楚的
  6. #知道改哪里!所以在这我就不说使用方法了,因为我实在是太累了!~~
  7. #
  8. #
  9. #           制作人;STUPID  ANT              制作组;STUPID  PIG
  10. #
  11. ###############################################################################
  12. ##########################《使用声明》#########################################
  13. #本脚本由STUPID  PIG工作室自行研制,其制作权归本工作室所有,当然大家可以尽情的
  14. #使用,但是所有的备注都不能删除,呵呵~~就算你加密,我们也不怕,很轻松就能看到!
  15. #在使用过程中如果有什么漏洞或新的想法,可以联系我们,QQ;1660618519
  16. #当然,我不经常在线,所以你们还可以打我手机;13977375101
  17. #祝你们做游戏愉快!~~~~
  18. ################################################################################
  19. #-------------------------------------------------------------------------------
  20. #                               《电子书脚本》
  21. #其主要用途就是用来介绍怪物、我方、建设和地图,当然也可以做养成RPG的每月杂志!
  22. #制作者;STUPID  ANT
  23. #QQ;1660618519
  24. ###############################################################################
  25. ##########################《使用说明》#########################################
  26. #本脚本由STUPID  PIG工作室自行研制,其制作权归本工作室所有,当然大家可以尽情的
  27. #使用,但是所有的备注都不能删除,呵呵~~就算你加密,我们也不怕,很轻松就能看到!
  28. #在使用过程中如果有什么漏洞或新的想法,可以联系我们,QQ;1660618519
  29. #当然,我不经常在线,所以你们还可以打我手机;13977375101
  30. #祝你们做游戏愉快!~~~~
  31. #########################《使用方法》##########################################
  32. #在地图中建立一个事件,在事件编辑中,添加脚本,写上$scene = Scene_Book.new,就可以打开
  33. #如果想添加更多的页码,请在30行、31行、98行进行编辑!
  34. #-------------------------------------------------------------------------------
  35. class Scene_Book
  36.   ############################################################################
  37.   ####################《第一部分的总处理》####################################
  38.   ############################################################################
  39.   def main #主要的处理
  40.     #---------《封面处理》-------------------------------------
  41.     @sprite = Sprite.new #生成新的图片
  42.     @sprite.bitmap = RPG::Cache.title("封面" )  #这里你可以更改。
  43.     #-----------《页码选择处理;中级》--------------------------
  44.     s1 = "第一页"#这里你可以改名称
  45.     s2 = "第二页"#这里你可以改名称
  46.     s3 = "第三页"#这里你可以改名称
  47.     s4 = "第四页"#这里你可以改名称
  48.     #你可以再加S5、S6、S7等,不过下面的也有两处要跟着改
  49.     @command_window = Window_Command.new(192, [s1, s2, s3, s4])
  50.     #上面的 @command_window当你加了S5、S6等时,要改的第一处,加[s1, s2, s3, s4,s5,s6],写多少加多少!!
  51.     @command_window.back_opacity = 255#透明度
  52.     @command_window.x = 320 - @command_window.width / 2#x坐标
  53.     @command_window.y = 288#y坐标
  54.     @command_window.visible = false #一开始页码状态为关闭状态
  55.     @command_window.active = false #一开始页码状态为关闭状态

  56.     #----------《音乐处理》-------------------------------------
  57.     Audio.se_play("Audio/BGM/001_色は匂へど散りぬるを.mp3")  #这里是处理音乐的,可以更改!
  58.     #----------《显示的图片位置处理》---------------------------
  59.      @sprite.x = (640 - @sprite.bitmap.width) / 2  #这是X坐标
  60.      @sprite.y = (480 - @sprite.bitmap.height) / 2 #这是Y坐标
  61.     #----------《图片的主处理》---------------------------------
  62.     @sprite.opacity = 255  #透明度,255为不透明,0是完全透明。
  63.     #----------《必要的场景处理》-------------------------------
  64.     Graphics.transition   # 执行过渡
  65.     loop do   # 主循环
  66.     Graphics.update      # 刷新游戏画面
  67.     Input.update      # 刷新输入信息
  68.     update      # 刷新画面
  69.     if $scene != self     # 如果画面被切换就中断循环
  70.         break
  71.       end
  72.     end
  73.     #-------------《过渡及图片释放的必要处理》------------------
  74.      Graphics.freeze   # 准备过渡
  75.     @sprite.bitmap.dispose    #释放图形
  76.     @sprite.dispose   #释放图形处理
  77.     @command_window.dispose #释放窗口
  78.     end
  79.   ############################################################################
  80.   ####################《第二部分;刷新》######################################
  81.   ############################################################################
  82.   def update #刷新
  83.   #------------------《页码窗口的终极处理》--------------------
  84.       if Input.trigger?(Input::A) #当按下Shift键时发生以下事件
  85.         @update_phase = 2
  86.         Audio.se_play("Audio/SE/028-Door05") #播放SE
  87.         @command_window.visible = true #页码窗口打开
  88.         @command_window.active = true  #正式打开
  89.       end
  90.       @command_window.update #窗口刷新
  91.       @command_window.update #窗口刷新
  92.     if Input.trigger?(Input::B) #当按下ESC键时发生以下事件
  93.       $game_system.se_play($data_system.cancel_se) #播放系统SE
  94.       @command_window.visible = false #窗口关闭
  95.       @command_window.active = false #窗口关闭
  96.       @update_phase = 1
  97.       @command_window.index = 0 #窗口的计数回到0
  98.     end
  99.     if Input.trigger?(Input::C) #当按下ESC键时发生以下事件
  100.       case @command_window.index #这个我也说不清~~
  101.       when 0 #选择S1
  102.       $game_system.se_play($data_system.cancel_se)#播放选择系统SE
  103.       @sprite.bitmap.clear #清除所有图片
  104.       @sprite = Sprite.new #显示新的图片
  105.       @sprite.bitmap = RPG::Cache.title("1" ) #图片名称
  106.         @command_window.visible = false #窗口关闭
  107.         @command_window.active = false #窗口关闭
  108.         @update_phase = 3
  109.       when 1
  110.         #这里你就自己写
  111.       when 2
  112.         #这里你就自己写
  113.       when 3
  114.         #这里你就自己写
  115.       #when  
  116.       #当你改了S1、S2那些东西时,这里就是要改的第二处,看到when了吗?
  117.       #你加了的话就再加一个when,减就减一个when!~~
  118.       end
  119.    
  120.     end   
  121. #-----------------------《退出电子书的处理》------------------------
  122.     if Input.trigger?(Input::L) #当按下Q键时就发生以下事件
  123.       Graphics.freeze  #图片过渡
  124.       Graphics.transition(20)  #过渡时间
  125.       Audio.se_stop  #所有音乐停止
  126.       $scene = Scene_Map.new  #返回地图
  127.     end
  128.   end
  129. end
  130. ##############################################################################
  131. #STUPID PIG工作室,里面的人不是笨猪,而是一群充满梦想的年轻人!~~~~
  132. ##############################################################################

  133. #==============================================================================
  134. # ■ Scene_Map*新
  135. #------------------------------------------------------------------------------
  136. #        稍微改了一下,就是在地图中按下F5打开《超级命令窗口》!~~~
  137. #==============================================================================

  138. class Scene_Map #这是一个场景的建立!
  139. #--------------------------------------------------------------------------
  140. # ● 主处理
  141. #--------------------------------------------------------------------------
  142.   def main
  143. #-------------------《生成的主处理》---------------------------------------   
  144.     @spriteset = Spriteset_Map.new # 生成活动块,这个你不需要知道!因为它在Spriteset_Map里
  145.     @message_window = Window_Message.new# 生成谈话窗口,当触发谈话事件时才会打开!
  146. #-------------------《过渡的处理》-----------------------------------------   
  147.     Graphics.transition# 执行过渡
  148.     loop do    # 主循环
  149.       Graphics.update# 刷新游戏画面
  150.       Input.update# 刷新输入信息     
  151.       update # 刷新画面
  152.       if $scene != self # 如果画面切换的话就中断循环
  153.         break
  154.       end
  155.     end
  156.     Graphics.freeze# 准备过渡
  157. #----------------------《释放的处理》-------------------------------------   
  158.     @spriteset.dispose# 释放活动块   
  159.     @message_window.dispose# 释放信息窗口   
  160.     if $scene.is_a?(Scene_Title)# 标题画面切换中的情况下
  161.       Graphics.transition# 淡入淡出画面
  162.       Graphics.freeze
  163.     end
  164.   end
  165. #--------------------------------------------------------------------------
  166. # ● 刷新画面
  167. #--------------------------------------------------------------------------
  168.   def update #变量(刷新)
  169. #-----------------《在地图中按键的处理》-----------------------------------
  170.     if Input.press?(Input::F5) #当按下F5时,就打开《超级命令窗口》
  171.        $scene = Scene_High.new #场景转换的意思,因为《超级命令窗口》是Scene_High!
  172.     end

  173.     if Input.trigger?(Input::B) #当按下Esc时打开菜单!
  174.      unless $game_system.map_interpreter.running? or #不是在事件执行中或菜单禁止中
  175.              $game_system.menu_disabled
  176.         # 设置菜单调用标志以及 SE 演奏
  177.         $game_temp.menu_calling = true
  178.         $game_temp.menu_beep = true
  179.       end
  180.     end
  181.    
  182.     if $DEBUG and Input.press?(Input::F9) # 调试模式为 ON 并且按下 F9 键的情况就打开调试画面!~~
  183.        $game_temp.debug_calling = true      # 设置调用调试标志
  184.     end
  185. #----------《循环处理;简洁类》----------------------------------------------   
  186.     loop do  # 循环
  187.       # 按照地图、实例、主角的顺序刷新
  188.       # (本更新顺序不会在满足事件的执行条件下成为给予角色瞬间移动
  189.       #  的机会的重要因素)
  190. #-----------《刷新处理》-----------------------------------------------------
  191.       $game_map.update
  192.       $game_system.map_interpreter.update
  193.       $game_player.update
  194.       $game_system.update
  195.       $game_screen.update
  196.      unless $game_temp.player_transferring # 如果主角在场所移动中就中断循环
  197.         break
  198.       end
  199.       transfer_player# 执行场所移动
  200.       if $game_temp.transition_processing# 处理过渡中的情况下、中断循环
  201.         break
  202.       end
  203.     end
  204.     # 刷新活动块
  205.     @spriteset.update
  206.     # 刷新信息窗口
  207.     @message_window.update
  208.     # 游戏结束的情况下
  209.     if $game_temp.gameover
  210.       # 切换的游戏结束画面
  211.       $scene = Scene_Gameover.new
  212.       return
  213.     end
  214.     # 返回标题画面的情况下
  215.     if $game_temp.to_title
  216.       # 切换到标题画面
  217.       $scene = Scene_Title.new
  218.       return
  219.     end
  220.     # 处理过渡中的情况下
  221.     if $game_temp.transition_processing
  222.       # 清除过渡处理中标志
  223.       $game_temp.transition_processing = false
  224.       # 执行过渡
  225.       if $game_temp.transition_name == ""
  226.         Graphics.transition(20)
  227.       else
  228.         Graphics.transition(40, "Graphics/Transitions/" +
  229.           $game_temp.transition_name)
  230.       end
  231.     end
  232.     # 显示信息窗口中的情况下
  233.     if $game_temp.message_window_showing
  234.       return
  235.     end
  236.     # 遇敌计数为 0 且、且遇敌列表不为空的情况下
  237.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  238.       # 不是在事件执行中或者禁止遇敌中
  239.       unless $game_system.map_interpreter.running? or
  240.              $game_system.encounter_disabled
  241.         # 确定队伍
  242.         n = rand($game_map.encounter_list.size)
  243.         troop_id = $game_map.encounter_list[n]
  244.         # 队伍有效的话
  245.         if $data_troops[troop_id] != nil
  246.           # 设置调用战斗标志
  247.           $game_temp.battle_calling = true
  248.           $game_temp.battle_troop_id = troop_id
  249.           $game_temp.battle_can_escape = true
  250.           $game_temp.battle_can_lose = false
  251.           $game_temp.battle_proc = nil
  252.         end
  253.       end
  254.     end
  255.    
  256.    
  257.     # 不在主角移动中的情况下
  258.     unless $game_player.moving?
  259.       # 执行各种画面的调用
  260.       if $game_temp.battle_calling
  261.         call_battle
  262.       elsif $game_temp.shop_calling
  263.         call_shop
  264.       elsif $game_temp.name_calling
  265.         call_name
  266.       elsif $game_temp.menu_calling
  267.         call_menu
  268.       elsif $game_temp.save_calling
  269.         call_save
  270.       elsif $game_temp.debug_calling
  271.         call_debug
  272.       end
  273.     end
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 调用战斗
  277.   #--------------------------------------------------------------------------
  278.   def call_battle
  279.     # 清除战斗调用标志
  280.     $game_temp.battle_calling = false
  281.     # 清除菜单调用标志
  282.     $game_temp.menu_calling = false
  283.     $game_temp.menu_beep = false
  284.     # 生成遇敌计数
  285.     $game_player.make_encounter_count
  286.     # 记忆地图 BGM 、停止 BGM
  287.     $game_temp.map_bgm = $game_system.playing_bgm
  288.     $game_system.bgm_stop
  289.     # 演奏战斗开始 SE
  290.     $game_system.se_play($data_system.battle_start_se)
  291.     # 演奏战斗 BGM
  292.     $game_system.bgm_play($game_system.battle_bgm)
  293.     # 矫正主角姿势
  294.     $game_player.straighten
  295.     # 切换到战斗画面
  296.     $scene = Scene_Battle.new
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 调用商店
  300.   #--------------------------------------------------------------------------
  301.   def call_shop
  302.     # 清除商店调用标志
  303.     $game_temp.shop_calling = false
  304.     # 矫正主角姿势
  305.     $game_player.straighten
  306.     # 切换到商店画面
  307.     $scene = Scene_Shop.new
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 调用名称输入
  311.   #--------------------------------------------------------------------------
  312.   def call_name
  313.     # 清除调用名称输入标志
  314.     $game_temp.name_calling = false
  315.     # 矫正主角姿势
  316.     $game_player.straighten
  317.     # 切换到名称输入画面
  318.     $scene = Scene_Name.new
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● 调用菜单
  322.   #--------------------------------------------------------------------------
  323.   def call_menu
  324.     # 清除菜单调用标志
  325.     $game_temp.menu_calling = false
  326.     # 已经设置了菜单 SE 演奏标志的情况下
  327.     if $game_temp.menu_beep
  328.       # 演奏确定 SE
  329.       $game_system.se_play($data_system.decision_se)
  330.       # 清除菜单演奏 SE 标志
  331.       $game_temp.menu_beep = false
  332.     end
  333.     # 矫正主角姿势
  334.     $game_player.straighten
  335.     # 切换到菜单画面
  336.     $scene = Scene_Menu.new
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 调用存档
  340.   #--------------------------------------------------------------------------
  341.   def call_save
  342.     # 矫正主角姿势
  343.     $game_player.straighten
  344.     # 切换到存档画面
  345.     $scene = Scene_Save.new
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 调用调试
  349.   #--------------------------------------------------------------------------
  350.   def call_debug
  351.     # 清除调用调试标志
  352.     $game_temp.debug_calling = false
  353.     # 演奏确定 SE
  354.     $game_system.se_play($data_system.decision_se)
  355.     # 矫正主角姿势
  356.     $game_player.straighten
  357.     # 切换到调试画面
  358.     $scene = Scene_Debug.new
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 主角的场所移动
  362.   #--------------------------------------------------------------------------
  363.   def transfer_player
  364.     # 清除主角场所移动调试标志
  365.     $game_temp.player_transferring = false
  366.     # 移动目标与现在的地图有差异的情况下
  367.     if $game_map.map_id != $game_temp.player_new_map_id
  368.       # 设置新地图
  369.       $game_map.setup($game_temp.player_new_map_id)
  370.     end
  371.     # 设置主角位置
  372.     $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  373.     # 设置主角朝向
  374.     case $game_temp.player_new_direction
  375.     when 2  # 下
  376.       $game_player.turn_down
  377.     when 4  # 左
  378.       $game_player.turn_left
  379.     when 6  # 右
  380.       $game_player.turn_right
  381.     when 8  # 上
  382.       $game_player.turn_up
  383.     end
  384.     # 矫正主角姿势
  385.     $game_player.straighten
  386.     # 刷新地图 (执行并行事件)
  387.     $game_map.update
  388.     # 在生成活动块
  389.     @spriteset.dispose
  390.     @spriteset = Spriteset_Map.new
  391.     # 处理过渡中的情况下
  392.     if $game_temp.transition_processing
  393.       # 清除过渡处理中标志
  394.       $game_temp.transition_processing = false
  395.       # 执行过渡
  396.       Graphics.transition(20)
  397.     end
  398.     # 执行地图设置的 BGM、BGS 的自动切换
  399.     $game_map.autoplay
  400.     # 设置画面
  401.     Graphics.frame_reset
  402.     # 刷新输入信息
  403.     Input.update
  404.   end
  405. end





  406. #==============================================================================
  407. # ■ Window_PlayTime*新
  408. #------------------------------------------------------------------------------
  409. #     新的游戏时间窗口,其实就是改了下宽,因为下面要用到!~~~~~
  410. #==============================================================================

  411. class Window_PlayTime < Window_Base
  412.   #--------------------------------------------------------------------------
  413.   # ● 初始化对像
  414.   #--------------------------------------------------------------------------
  415.   def initialize
  416.     super(0, 0, 240, 96)
  417.     self.contents = Bitmap.new(width - 32, height - 32)
  418.     refresh
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ● 刷新
  422.   #--------------------------------------------------------------------------
  423.   def refresh
  424.     self.contents.clear
  425.     self.contents.font.color = system_color
  426.     self.contents.draw_text(4, 0, 120, 32, "所玩游戏时间")
  427.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  428.     hour = @total_sec / 60 / 60
  429.     min = @total_sec / 60 % 60
  430.     sec = @total_sec % 60
  431.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  432.     self.contents.font.color = normal_color
  433.     self.contents.draw_text(4, 32, 120, 32, text, 2)
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 刷新画面
  437.   #--------------------------------------------------------------------------
  438.   def update
  439.     super
  440.     if Graphics.frame_count / Graphics.frame_rate != @total_sec
  441.       refresh
  442.     end
  443.   end
  444. end



  445. #==============================================================================
  446. # ■ Window_Steps
  447. #------------------------------------------------------------------------------
  448. #  菜单画面显示步数的窗口。
  449. #==============================================================================

  450. class Window_Steps < Window_Base
  451.   #--------------------------------------------------------------------------
  452.   # ● 初始化对像
  453.   #--------------------------------------------------------------------------
  454.   def initialize
  455.     super(0, 0, 240, 96)
  456.     self.contents = Bitmap.new(width - 32, height - 32)
  457.     refresh
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # ● 刷新
  461.   #--------------------------------------------------------------------------
  462.   def refresh
  463.     self.contents.clear
  464.     self.contents.font.color = system_color
  465.     self.contents.draw_text(4, 0, 120, 32, "总的行走步数")
  466.     self.contents.font.color = normal_color
  467.     self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
  468.   end
  469. end






  470. #==============================================================================
  471. # ■ Window_Gold
  472. #------------------------------------------------------------------------------
  473. #  显示金钱的窗口。
  474. #==============================================================================

  475. class Window_Gold < Window_Base
  476.   #--------------------------------------------------------------------------
  477.   # ● 初始化窗口
  478.   #--------------------------------------------------------------------------
  479.   def initialize
  480.     super(0, 0, 240, 64)
  481.     self.contents = Bitmap.new(width - 32, height - 32)
  482.     refresh
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● 刷新
  486.   #--------------------------------------------------------------------------
  487.   def refresh
  488.     self.contents.clear
  489.     cx = contents.text_size($data_system.words.gold).width
  490.     self.contents.font.color = normal_color
  491.     self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
  492.     self.contents.font.color = system_color
  493.     self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
  494.   end
  495. end

  496. class Scene_High
  497. #--------------------------------------------------------------------------
  498. # ● 初始化对像
  499. #     第一项 : 命令光标的初期位置
  500. #--------------------------------------------------------------------------
  501.   def initialize(menu_index = 0)
  502.     @menu_index = menu_index
  503.   end
  504.   def main
  505.     s1 = "打开加点处理面板"
  506.     s2 = "打开专用猎人导书"
  507.     s3 = "打开二号存档画面"
  508.     s4 = "打开二号读档画面"
  509.     s5 = "去往猎人之家地图"
  510.     s6 = "打开结束游戏窗口"
  511.     @command_window = Window_Command.new(240, [s1, s2, s3, s4, s5, s6])
  512.     @command_window.index = @menu_index

  513.    
  514.     @sprite = Sprite.new
  515.     @sprite.bitmap = RPG::Cache.title("介绍.png" )
  516.     @sprite.x = 200
  517.     @sprite.y = 0
  518.     # 生成游戏时间窗口
  519.     @playtime_window = Window_PlayTime.new
  520.     @playtime_window.x = 0
  521.     @playtime_window.y = 224
  522.     # 生成步数窗口
  523.     @steps_window = Window_Steps.new
  524.     @steps_window.x = 0
  525.     @steps_window.y = 320
  526.     # 生成金钱窗口
  527.     @gold_window = Window_Gold.new
  528.     @gold_window.x = 0
  529.     @gold_window.y = 416
  530.     # 透明度(0为完全透明)
  531.     @sprite.opacity = 255
  532.     # 执行过渡
  533.     Graphics.transition
  534.     # 主循环
  535.     loop do
  536.       # 刷新游戏画面
  537.       Graphics.update
  538.       # 刷新输入信息
  539.       Input.update
  540.       # 刷新画面
  541.       update
  542.       # 如果画面被切换就中断循环
  543.       if $scene != self
  544.         break
  545.       end
  546.     end
  547.     # 装备过渡
  548.     Graphics.freeze
  549.     # 释放标题图形
  550.     @sprite.bitmap.dispose
  551.     @sprite.dispose

  552.     @command_window.dispose
  553.     @playtime_window.dispose
  554.     @steps_window.dispose
  555.     @gold_window.dispose
  556.   end

  557.   #--------------------------------------------------------------------------
  558.   # ● 刷新画面
  559.   #--------------------------------------------------------------------------
  560.   def update
  561.     # 刷新窗口
  562.     @command_window.update
  563.       @playtime_window.update
  564.     @steps_window.update
  565.     @gold_window.update
  566.     # 命令窗口被激活的情况下: 调用 update_command
  567.     if @command_window.active
  568.       update_command
  569.       return
  570.     end
  571.     # 状态窗口被激活的情况下: 调用 update_status
  572.     if @status_window.active
  573.       update_status
  574.       return
  575.     end
  576.   end
  577.    #--------------------------------------------------------------------------
  578.   # ● 刷新画面 (命令窗口被激活的情况下)
  579.   #--------------------------------------------------------------------------
  580.   def update_command
  581.     # 按下 B 键的情况下
  582.     if Input.trigger?(Input::B)
  583.       # 演奏取消 SE
  584.       $game_system.se_play($data_system.cancel_se)
  585.       # 切换的地图画面
  586.       $scene = Scene_Map.new
  587.       return
  588.     end
  589.     # 按下 C 键的情况下
  590.     if Input.trigger?(Input::C)
  591.       # 同伴人数为 0、存档、游戏结束以外的场合
  592.       if $game_party.actors.size == 0 and @command_window.index < 4
  593.         # 演奏冻结 SE
  594.         $game_system.se_play($data_system.buzzer_se)
  595.         return
  596.       end
  597.       # 命令窗口的光标位置分支
  598. case @command_window.index
  599.       when 0  
  600.         # 演奏确定 SE
  601.         $game_system.se_play($data_system.decision_se)

  602.            $scene = Scene_Lvup.new
  603.       when 1  
  604.         # 演奏确定 SE
  605.         $game_system.se_play($data_system.decision_se)
  606.         $scene = Scene_Book.new
  607.       when 2  
  608.         # 演奏确定 SE
  609.         $game_system.se_play($data_system.decision_se)

  610.         $scene = Scene_Save2.new
  611.       when 3  
  612.         # 演奏确定 SE
  613.         $game_system.se_play($data_system.decision_se)

  614.          $scene = Scene_Load2.new
  615.       when 4  

  616.           $game_system.se_play($data_system.buzzer_se)
  617.      $game_map.setup(6)
  618.     # 主角向初期位置移动
  619.     a = rand(20)
  620.     b = rand(15)
  621.     $game_player.moveto(a, b)
  622.     # 刷新主角
  623.     $game_player.refresh
  624.     # 执行地图设置的 BGM 与 BGS 的自动切换
  625.     $game_map.autoplay
  626.     # 刷新地图 (执行并行事件)
  627.     $game_map.update
  628.     # 切换地图画面
  629.     $scene = Scene_Map.new
  630.     when 5  # 游戏结束
  631.         # 演奏确定 SE
  632.         $game_system.se_play($data_system.decision_se)
  633.         # 切换到游戏结束画面
  634.         $scene = Scene_End.new
  635.     end
  636.       return
  637.     end
  638.   end
  639. end
  640.   
  641. #==============================================================================
  642. # ■ Scene_Save
  643. #------------------------------------------------------------------------------
  644. #  处理存档画面的类。
  645. #==============================================================================

  646. class Scene_Save2 < Scene_File
  647.   #--------------------------------------------------------------------------
  648.   # ● 初始化对像
  649.   #--------------------------------------------------------------------------
  650.   def initialize
  651.     super("要保存到这个文件吗?")
  652.   end
  653.   #--------------------------------------------------------------------------
  654.   # ● 确定时的处理
  655.   #--------------------------------------------------------------------------
  656.   def on_decision(filename)
  657.     # 演奏存档 SE
  658.     $game_system.se_play($data_system.save_se)
  659.     # 写入存档数据
  660.     file = File.open(filename, "wb")
  661.     write_save_data(file)
  662.     file.close
  663.     # 如果被事件调用
  664.     if $game_temp.save_calling
  665.       # 清除存档调用标志
  666.       $game_temp.save_calling = false
  667.       # 切换到地图画面
  668.       $scene = Scene_Map.new
  669.       return
  670.     end
  671.     # 切换到菜单画面
  672.     $scene = Scene_High.new(3)
  673.   end
  674.   #--------------------------------------------------------------------------
  675.   # ● 取消时的处理
  676.   #--------------------------------------------------------------------------
  677.   def on_cancel
  678.     # 演奏取消 SE
  679.     $game_system.se_play($data_system.cancel_se)
  680.     # 如果被事件调用
  681.     if $game_temp.save_calling
  682.       # 清除存档调用标志
  683.       $game_temp.save_calling = false
  684.       # 切换到地图画面
  685.       $scene = Scene_Map.new
  686.       return
  687.     end
  688.     # 切换到菜单画面
  689.     $scene = Scene_High.new(3)
  690.   end
  691.   #--------------------------------------------------------------------------
  692.   # ● 写入存档数据
  693.   #     file : 写入用文件对像 (已经打开)
  694.   #--------------------------------------------------------------------------
  695.   def write_save_data(file)
  696.     # 生成描绘存档文件用的角色图形
  697.     characters = []
  698.     for i in 0...$game_party.actors.size
  699.       actor = $game_party.actors[i]
  700.       characters.push([actor.character_name, actor.character_hue])
  701.     end
  702.     # 写入描绘存档文件用的角色数据
  703.     Marshal.dump(characters, file)
  704.     # 写入测量游戏时间用画面计数
  705.     Marshal.dump(Graphics.frame_count, file)
  706.     # 增加 1 次存档次数
  707.     $game_system.save_count += 1
  708.     # 保存魔法编号
  709.     # (将编辑器保存的值以随机值替换)
  710.     $game_system.magic_number = $data_system.magic_number
  711.     # 写入各种游戏对像
  712.     Marshal.dump($game_system, file)
  713.     Marshal.dump($game_switches, file)
  714.     Marshal.dump($game_variables, file)
  715.     Marshal.dump($game_self_switches, file)
  716.     Marshal.dump($game_screen, file)
  717.     Marshal.dump($game_actors, file)
  718.     Marshal.dump($game_party, file)
  719.     Marshal.dump($game_troop, file)
  720.     Marshal.dump($game_map, file)
  721.     Marshal.dump($game_player, file)
  722.   end
  723. end

  724. #==============================================================================
  725. # ■ Scene_Load
  726. #------------------------------------------------------------------------------
  727. #  处理读档画面的类。
  728. #==============================================================================

  729. class Scene_Load2 < Scene_File
  730.   #--------------------------------------------------------------------------
  731.   # ● 初始化对像
  732.   #--------------------------------------------------------------------------
  733.   def initialize
  734.     # 再生成临时对像
  735.     $game_temp = Game_Temp.new
  736.     # 选择存档时间最新的文件
  737.     $game_temp.last_file_index = 0
  738.     latest_time = Time.at(0)
  739.     for i in 0..3
  740.       filename = make_filename(i)
  741.       if FileTest.exist?(filename)
  742.         file = File.open(filename, "r")
  743.         if file.mtime > latest_time
  744.           latest_time = file.mtime
  745.           $game_temp.last_file_index = i
  746.         end
  747.         file.close
  748.       end
  749.     end
  750.     super("要载入哪个文件?")
  751.   end
  752.   #--------------------------------------------------------------------------
  753.   # ● 确定时的处理
  754.   #--------------------------------------------------------------------------
  755.   def on_decision(filename)
  756.     # 文件不存在的情况下
  757.     unless FileTest.exist?(filename)
  758.       # 演奏冻结 SE
  759.       $game_system.se_play($data_system.buzzer_se)
  760.       return
  761.     end
  762.     # 演奏读档 SE
  763.     $game_system.se_play($data_system.load_se)
  764.     # 写入存档数据
  765.     file = File.open(filename, "rb")
  766.     read_save_data(file)
  767.     file.close
  768.     # 还原 BGM、BGS
  769.     $game_system.bgm_play($game_system.playing_bgm)
  770.     $game_system.bgs_play($game_system.playing_bgs)
  771.     # 刷新地图 (执行并行事件)
  772.     $game_map.update
  773.     # 切换到地图画面
  774.     $scene = Scene_Map.new
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● 取消时的处理
  778.   #--------------------------------------------------------------------------
  779.   def on_cancel
  780.     # 演奏取消 SE
  781.     $game_system.se_play($data_system.cancel_se)
  782.     # 切换到标题画面
  783.     $scene = Scene_High.new
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # ● 读取存档数据
  787.   #     file : 读取用文件对像 (已经打开)
  788.   #--------------------------------------------------------------------------
  789.   def read_save_data(file)
  790.     # 读取描绘存档文件用的角色数据
  791.     characters = Marshal.load(file)
  792.     # 读取测量游戏时间用画面计数
  793.     Graphics.frame_count = Marshal.load(file)
  794.     # 读取各种游戏对像
  795.     $game_system        = Marshal.load(file)
  796.     $game_switches      = Marshal.load(file)
  797.     $game_variables     = Marshal.load(file)
  798.     $game_self_switches = Marshal.load(file)
  799.     $game_screen        = Marshal.load(file)
  800.     $game_actors        = Marshal.load(file)
  801.     $game_party         = Marshal.load(file)
  802.     $game_troop         = Marshal.load(file)
  803.     $game_map           = Marshal.load(file)
  804.     $game_player        = Marshal.load(file)
  805.     # 魔法编号与保存时有差异的情况下
  806.     # (加入编辑器的编辑过的数据)
  807.     if $game_system.magic_number != $data_system.magic_number
  808.       # 重新装载地图
  809.       $game_map.setup($game_map.map_id)
  810.       $game_player.center($game_player.x, $game_player.y)
  811.     end
  812.     # 刷新同伴成员
  813.     $game_party.refresh
  814.   end
  815. end



  816. #==============================================================================
  817. #菜单人物行走的处理
  818. #          初级篇
  819. #==============================================================================

  820. WALK_REFRESH_FRAME_SPEED = 10 # 刷新的速度,越大越慢~~~··

  821. #==============================================================================
  822. # Window_Base
  823. #==============================================================================
  824. class Window_Base < Window
  825. #《初始化的定义》---------------------------------------------------------------
  826.   alias initialize_walk initialize
  827.   def initialize(x, y, width, height)
  828.     initialize_walk(x, y, width, height)
  829.     @start_walk = false
  830.     @turn_index = 0
  831.     @turn_phase = 0
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # 角色行走图
  835.   #     actor : 角色
  836.   #     x     : 描绘的 X 坐标
  837.   #     y     : 描绘的 Y 坐标
  838.   #--------------------------------------------------------------------------
  839.   def draw_walk_actor_graphic(actor, x, y)
  840.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  841.     cw = bitmap.width / 4
  842.     ch = bitmap.height / 4
  843.     @start_turn = true
  844.     case @turn_phase
  845.     when 0
  846.       x_x = 0
  847.     when 1
  848.       x_x = cw
  849.     when 2
  850.       x_x = cw * 2
  851.     when 3
  852.       x_x = cw * 3
  853.     end
  854.     src_rect = Rect.new(x_x, 0, cw, ch)
  855.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  856.   end
  857.   #--------------------------------------------------------------------------
  858.   #  角色转向图
  859.   #     actor : 角色
  860.   #     x     : 描绘的 X 坐标
  861.   #     y     : 描绘的 Y 坐标
  862.   #--------------------------------------------------------------------------
  863.   def draw_turn_actor_graphic(actor, x, y)
  864.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  865.     cw = bitmap.width / 4
  866.     ch = bitmap.height / 4
  867.     @start_turn = true
  868.     case @turn_phase
  869.     when 0
  870.       x_x = 0
  871.     when 1
  872.       x_x = ch
  873.     when 2
  874.       x_x = ch * 3
  875.     when 3
  876.       x_x = ch * 2
  877.     end
  878.     src_rect = Rect.new(0, x_x, cw, ch)
  879.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  880.   end
  881.   #--------------------------------------------------------------------------
  882.   #  更新(可别使用刷新,玩命耗费内存= =)
  883.   #--------------------------------------------------------------------------
  884.   alias walk_update update
  885.   def update
  886.     walk_update
  887.     if @start_turn == true
  888.       @turn_index += 1
  889.       if @turn_index == WALK_REFRESH_FRAME_SPEED
  890.         refresh
  891.         @turn_index = 0
  892.         @turn_phase = (@turn_phase+1)%4
  893.       end
  894.     end
  895.   end  
  896. end

  897. #==============================================================================
  898. # Window_Base
  899. #==============================================================================
  900. class Window_Base < Window
  901.   #--------------------------------------------------------------------------
  902.   # 把原有静态图改为动态走步图
  903.   #--------------------------------------------------------------------------
  904.   def draw_actor_graphic(actor, x, y)
  905.     draw_walk_actor_graphic(actor, x, y)
  906.   end
  907. end
  908. # 脚本使用设定:

  909. LEVEL_UP_POINT = rand(5) + 1  # 每升一级所增加的点数
  910. LEVEL_UP_VARIABLE = 5  # 储存角色点数的变量编号与角色id编号的差值
  911.                         

  912. #==============================================================================
  913. # ■ Window_Command
  914. #------------------------------------------------------------------------------
  915. #  一般的命令选择行窗口。(追加定义)
  916. #==============================================================================
  917. class Window_Command < Window_Selectable
  918.   #--------------------------------------------------------------------------
  919.   # ● 项目有效化
  920.   #     index : 项目编号
  921.   #--------------------------------------------------------------------------
  922.   def able_item(index)
  923.     draw_item(index, normal_color)
  924.   end
  925. end
  926. #==============================================================================
  927. # ■ Game_Actor
  928. #------------------------------------------------------------------------------
  929. #  处理角色的类。(再定义)
  930. #==============================================================================
  931. class Game_Actor < Game_Battler
  932.   #--------------------------------------------------------------------------
  933.   # ● 更改 EXP
  934.   #     exp : 新的 EXP
  935.   #--------------------------------------------------------------------------
  936.   def exp=(exp)
  937.     @exp = [[exp, 9999999].min, 0].max
  938.     # 升级
  939.     while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  940.       @level += 1
  941.       # 增加4点可自由分配的点数
  942.       $game_variables[self.id + LEVEL_UP_VARIABLE] += LEVEL_UP_POINT
  943.       # 学会特技
  944.       for j in $data_classes[@class_id].learnings
  945.         if j.level == @level
  946.           learn_skill(j.skill_id)
  947.         end
  948.       end
  949.     end
  950.     # 降级
  951.     while @exp < @exp_list[@level]
  952.       @level -= 1
  953.     end
  954.     # 修正当前的 HP 与 SP 超过最大值
  955.     @hp = [@hp, self.maxhp].min
  956.     @sp = [@sp, self.maxsp].min
  957.   end
  958. end
  959. #==============================================================================
  960. # ■ Window_Base
  961. #------------------------------------------------------------------------------
  962. #  游戏中全部窗口的超级类(追加定义)
  963. #==============================================================================
  964. class Window_Base < Window
  965.   #--------------------------------------------------------------------------
  966.   # ● 描绘 HP
  967.   #     actor : 角色
  968.   #     x     : 描画目标 X 坐标
  969.   #     y     : 描画目标 Y 坐标
  970.   #     width : 描画目标的宽
  971.   #--------------------------------------------------------------------------
  972.   def draw_actor_hp_lvup(actor, x, y)
  973.     self.contents.font.color = system_color
  974.     self.contents.draw_text(x , y, 96, 32, "最大" + $data_system.words.hp)
  975.     if $temp_hp == 0
  976.       self.contents.font.color = normal_color
  977.       self.contents.draw_text(x + 120 , y, 48, 32, actor.maxhp.to_s, 2)
  978.     else
  979.       maxhp = actor.maxhp + $temp_hp
  980.       self.contents.font.color = Color.new(255, 128, 128, 255)
  981.       self.contents.draw_text(x + 120 , y, 48, 32, maxhp.to_s ,2)
  982.       self.contents.font.color = normal_color      
  983.       self.contents.draw_text(x + 155, y, 36, 32, "( ", 2)
  984.       if $temp_hp >=0
  985.         self.contents.font.color = Color.new(255, 128, 128, 255)
  986.         self.contents.draw_text(x + 155, y, 36, 32, " +",2)
  987.       else
  988.         self.contents.font.color = Color.new(255,255,0,255)
  989.         self.contents.draw_text(x + 155, y, 36, 32, " -",2)
  990.       end
  991.       self.contents.draw_text(x + 200, y, 36, 32, $temp_hp.to_s, 2)
  992.       self.contents.font.color = normal_color
  993.       self.contents.draw_text(x + 215, y, 36, 32, ")", 2)
  994.     end
  995.   end
  996.   #--------------------------------------------------------------------------
  997.   # ● 描绘 SP
  998.   #     actor : 角色
  999.   #     x     : 描画目标 X 坐标
  1000.   #     y     : 描画目标 Y 坐标
  1001.   #     width : 描画目标的宽
  1002.   #--------------------------------------------------------------------------
  1003.   def draw_actor_sp_lvup(actor, x, y)
  1004.     self.contents.font.color = system_color
  1005.     self.contents.draw_text(x , y, 96, 32, "最大" + $data_system.words.sp)
  1006.     if $temp_sp == 0
  1007.       self.contents.font.color = normal_color
  1008.       self.contents.draw_text(x + 120 , y, 48, 32, actor.maxsp.to_s, 2)
  1009.     else
  1010.       maxsp = actor.maxsp + $temp_sp
  1011.       self.contents.font.color = Color.new(255, 128, 128, 255)
  1012.       self.contents.draw_text(x + 120 , y, 48, 32, maxsp.to_s ,2)
  1013.       self.contents.font.color = normal_color      
  1014.       self.contents.draw_text(x + 155, y, 36, 32, "( ", 2)
  1015.       if $temp_sp >=0
  1016.         self.contents.font.color = Color.new(255, 128, 128, 255)
  1017.         self.contents.draw_text(x + 155, y, 36, 32, " +",2)
  1018.       else
  1019.         self.contents.font.color = Color.new(255,255,0,255)
  1020.         self.contents.draw_text(x + 155, y, 36, 32, " -",2)
  1021.       end
  1022.       self.contents.draw_text(x + 200, y, 36, 32, $temp_sp.to_s, 2)
  1023.       self.contents.font.color = normal_color
  1024.       self.contents.draw_text(x + 215, y, 36, 32, ")", 2)
  1025.     end
  1026.   end
  1027.   #--------------------------------------------------------------------------
  1028.   # ● 描绘能力值
  1029.   #     actor : 角色
  1030.   #     x     : 描画目标 X 坐标
  1031.   #     y     : 描画目标 Y 坐标
  1032.   #     type  : 能力值种类 (0~4)
  1033.   #--------------------------------------------------------------------------
  1034.   def draw_actor_lvup(actor, x, y, type)   
  1035.     # 定义数字颜色
  1036.     lvup = normal_color
  1037.     upcolor = Color.new(255, 128, 128, 255)
  1038.     self.contents.font.color = normal_color   
  1039.     case type
  1040.     when 0
  1041.       parameter_name = $data_system.words.str
  1042.       parameter_value = actor.str
  1043.       parameter_value_temp = parameter_value + $temp_str
  1044.       if $temp_str != 0
  1045.         lvup = upcolor
  1046.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  1047.         if $temp_str >= 0
  1048.           self.contents.font.color = lvup
  1049.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  1050.         else
  1051.           self.contents.font.color = Color.new(255,255,0,255)
  1052.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  1053.         end        
  1054.         self.contents.draw_text(x + 272, y, 80, 32, $temp_str.abs.to_s,1)
  1055.         self.contents.font.color = normal_color
  1056.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  1057.       end
  1058.     when 1
  1059.       parameter_name = $data_system.words.dex
  1060.       parameter_value = actor.dex
  1061.       parameter_value_temp = parameter_value + $temp_dex
  1062.       if $temp_dex != 0
  1063.         lvup = upcolor
  1064.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  1065.         if $temp_dex >= 0
  1066.           self.contents.font.color = lvup
  1067.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  1068.         else
  1069.           self.contents.font.color = Color.new(255,255,0,255)
  1070.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  1071.         end        
  1072.         self.contents.draw_text(x + 272, y, 80, 32, $temp_dex.abs.to_s,1)
  1073.         self.contents.font.color = normal_color
  1074.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  1075.       end
  1076.     when 2
  1077.       parameter_name = $data_system.words.agi
  1078.       parameter_value = actor.agi
  1079.       parameter_value_temp = parameter_value + $temp_agi
  1080.       if $temp_agi != 0
  1081.         lvup = upcolor
  1082.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  1083.         if $temp_agi >= 0
  1084.           self.contents.font.color = lvup
  1085.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  1086.         else
  1087.           self.contents.font.color = Color.new(255,255,0,255)
  1088.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  1089.         end        
  1090.         self.contents.draw_text(x + 272, y, 80, 32, $temp_agi.abs.to_s,1)
  1091.         self.contents.font.color = normal_color
  1092.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  1093.       end
  1094.     when 3
  1095.       parameter_name = $data_system.words.int
  1096.       parameter_value = actor.int
  1097.       parameter_value_temp = parameter_value + $temp_int
  1098.       if $temp_int != 0
  1099.         lvup = upcolor
  1100.         self.contents.draw_text(x + 256, y, 16, 32, "(")
  1101.         if $temp_int >= 0
  1102.           self.contents.font.color = lvup
  1103.           self.contents.draw_text(x + 272, y, 80, 32, "+",0)
  1104.         else
  1105.           self.contents.font.color = Color.new(255,255,0,255)
  1106.           self.contents.draw_text(x + 272, y, 80, 32, "-",0)
  1107.         end        
  1108.         self.contents.draw_text(x + 272, y, 80, 32, $temp_int.abs.to_s,1)
  1109.         self.contents.font.color = normal_color
  1110.         self.contents.draw_text(x + 272, y, 80, 32, ")", 2)
  1111.       end
  1112.     when 4
  1113.       parameter_name = "剩余点数"
  1114.       parameter_value = $point
  1115.       if $point != 0
  1116.         lvup = upcolor
  1117.       end
  1118.     end   
  1119.     self.contents.font.color = system_color
  1120.     self.contents.draw_text(x, y, 120, 32, parameter_name)
  1121.     self.contents.font.color = normal_color
  1122.     self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s)   
  1123.     if type != 4
  1124.       self.contents.draw_text(x + 150, y, 36, 32, "→")
  1125.     end  
  1126.     self.contents.font.color = lvup
  1127.     self.contents.draw_text(x + 180, y, 60, 32, parameter_value_temp.to_s)
  1128.     self.contents.font.color = normal_color        
  1129.   end
  1130. end
  1131. #==============================================================================
  1132. # ■ Window_lvup
  1133. #------------------------------------------------------------------------------
  1134. #  显示升级状态窗口。
  1135. #==============================================================================
  1136. class Window_Lvup < Window_Base
  1137.   #--------------------------------------------------------------------------
  1138.   # ● 初始化对像
  1139.   #     actor : 角色
  1140.   #--------------------------------------------------------------------------
  1141.   def initialize(actor)
  1142.     super(0, 0, 512, 320)
  1143.     self.contents = Bitmap.new(width - 32, height - 32)
  1144.     @actor = actor
  1145.     refresh
  1146.   end  
  1147.   #--------------------------------------------------------------------------
  1148.   # ● 刷新
  1149.   #--------------------------------------------------------------------------
  1150.   def refresh
  1151.     self.contents.clear
  1152.     draw_actor_graphic(@actor, 40, 112)
  1153.     draw_actor_name(@actor, 4, 0)
  1154.     draw_actor_class(@actor, 4 + 144, 0)
  1155.     draw_actor_level(@actor, 96, 32)
  1156.     draw_actor_state(@actor, 96, 64)   
  1157.     draw_actor_hp_lvup(@actor, 96+128, 32)
  1158.     draw_actor_sp_lvup(@actor, 96+128, 64)
  1159.     draw_actor_lvup(@actor, 96, 128, 0)
  1160.     draw_actor_lvup(@actor, 96, 160, 1)
  1161.     draw_actor_lvup(@actor, 96, 192, 2)
  1162.     draw_actor_lvup(@actor, 96, 224, 3)
  1163.     draw_actor_lvup(@actor, 96, 256, 4)
  1164.   end
  1165. end
  1166. #==============================================================================
  1167. # ■ Window_Help
  1168. #------------------------------------------------------------------------------
  1169. #  特技及物品的说明、角色的状态显示的窗口。
  1170. #==============================================================================
  1171. class Window_Lvup_Help < Window_Base
  1172.   #--------------------------------------------------------------------------
  1173.   # ● 初始化对像
  1174.   #--------------------------------------------------------------------------
  1175.   def initialize
  1176.     super(0, 320, 640, 160)
  1177.     self.contents = Bitmap.new(width - 32, height - 32)
  1178.     @test = "" #——这个东西用来检测,节约内存专用
  1179.   end  
  1180.   #--------------------------------------------------------------------------
  1181.   # ● 设置文本
  1182.   #--------------------------------------------------------------------------
  1183.   def lvup_text(text1, text2 = nil, text3 = nil, text4 = nil)
  1184.     if @test != text1
  1185.       @test = text1
  1186.     else
  1187.       return
  1188.     end   
  1189.     self.contents.clear
  1190.     self.contents.font.color = normal_color
  1191.     self.contents.draw_text(4, 0, self.width - 40, 32, text1)
  1192.     if text2 != nil
  1193.       self.contents.draw_text(4 , 32, self.width - 40, 32, text2)
  1194.     end
  1195.     self.contents.font.size -= 4
  1196.     if text3 != nil
  1197.       self.contents.draw_text(4 , 64, self.width - 40, 32, text3)
  1198.     end
  1199.     if text4 != nil
  1200.       self.contents.draw_text(4 , 96, self.width - 40, 32, text4)
  1201.     end
  1202.     self.contents.font.size += 4
  1203.   end
  1204. end
  1205. #==============================================================================
  1206. # ■ Scene_lvup
  1207. #------------------------------------------------------------------------------
  1208. #  处理升级画面的类。
  1209. #==============================================================================
  1210. class Scene_Lvup
  1211.   #--------------------------------------------------------------------------
  1212.   # ● 初始化对像
  1213.   #     actor_index : 角色索引
  1214.   #     menu_index : 选项起始位置
  1215.   #--------------------------------------------------------------------------
  1216.   def initialize(actor_index = 0 , menu_index = 0)
  1217.     @actor_index = actor_index
  1218.     @menu_index = menu_index
  1219.   end
  1220.   #--------------------------------------------------------------------------
  1221.   # ● 主处理
  1222.   #--------------------------------------------------------------------------
  1223.   def main
  1224.     s1 = "增加体力"
  1225.     s2 = "增加"+$data_system.words.str
  1226.     s3 = "增加"+$data_system.words.dex
  1227.     s4 = "增加"+$data_system.words.agi
  1228.     s5 = "增加"+$data_system.words.int
  1229.     s6 = "确认加点"
  1230.     s7 = "点数重置"
  1231.     @command_window = Window_Command.new(128, [s1, s2, s3, s4, s5, s6, s7])
  1232.     @command_window.index = @menu_index
  1233.     # 获取角色
  1234.     @actor = $game_party.actors[@actor_index]
  1235.     # 将角色的剩余点数带入
  1236.     $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE]   
  1237.     # 初始化临时量
  1238.     $temp_str = 0
  1239.     $temp_dex = 0
  1240.     $temp_agi = 0
  1241.     $temp_int = 0
  1242.     $temp_hp = 0
  1243.     $temp_sp = 0
  1244.     #=========================================================================
  1245.     # 特别提示:这些设置也可以使用小数,但是可能出现0值意外错误
  1246.     #  (各种编程语言都有这种意外),建议还是使用整数,正负不限
  1247.     #=========================================================================
  1248.     # 每提升一次力量,提升多少附加能力
  1249.     #=========================================================================
  1250.     @str_hp = 2     # 每提升一次力量附加提升多少HP
  1251.     @str_sp = 2     # 每提升一次力量附加提升多少SP
  1252.     @str_dex = 1    # 每提升一次力量附加提升多少灵巧
  1253.     @str_agi = 1    # 每提升一次力量附加提升多少速度
  1254.     @str_int = 0    # 每提升一次力量附加提升多少魔力
  1255.     @str_str = 5    # 每提升一次力量附加提升多少力量
  1256.     #=========================================================================
  1257.     # 每提升一次灵巧,提升多少附加能力
  1258.     #=========================================================================
  1259.     @dex_hp = 3     # 每提升一次灵巧附加提升多少HP
  1260.     @dex_sp = 2     # 每提升一次灵巧附加提升多少SP
  1261.     @dex_str = 1    # 每提升一次灵巧附加提升多少力量
  1262.     @dex_agi = 1    # 每提升一次灵巧附加提升多少速度
  1263.     @dex_int = 0    # 每提升一次灵巧附加提升多少魔力
  1264.     @dex_dex = 5    # 每提升一次灵巧附加提升多少灵巧
  1265.     #=========================================================================
  1266.     # 每提升一次速度,提升多少附加能力
  1267.     #=========================================================================
  1268.     @agi_hp = 3     # 每提升一次速度附加提升多少HP
  1269.     @agi_sp = 2     # 每提升一次速度附加提升多少SP
  1270.     @agi_str = 1    # 每提升一次速度附加提升多少力量
  1271.     @agi_dex = 1    # 每提升一次速度附加提升多少灵巧
  1272.     @agi_int = 0    # 每提升一次速度附加提升多少魔力
  1273.     @agi_agi = 2    # 每提升一次速度附加提升多少速度
  1274.     #=========================================================================
  1275.     # 每提升一次魔力,提升多少附加能力
  1276.     #=========================================================================
  1277.     @int_hp = 1     # 每提升一次魔力附加提升多少HP
  1278.     @int_sp = 10    # 每提升一次魔力附加提升多少SP
  1279.     @int_str = -1   # 每提升一次魔力附加提升多少力量
  1280.     @int_dex = -1   # 每提升一次魔力附加提升多少灵巧
  1281.     @int_agi = -1   # 每提升一次魔力附加提升多少速度
  1282.     @int_int = 4   # 每提升一次魔力附加提升多少魔力
  1283.     #=========================================================================
  1284.     # 每提升一次体力,提升多少附加能力
  1285.     #=========================================================================
  1286.     @hp = 15       # 每提升一次体力提升多少HP
  1287.     @sp = 10       # 每提升一次体力提升多少SP
  1288.     @hp_str = -1   # 每提升一次体力提升多少力量
  1289.     @hp_dex = -1   # 每提升一次体力提升多少速度
  1290.     @hp_agi = -1   # 每提升一次体力提升多少灵巧
  1291.     @hp_int = -1   # 每提升一次体力提升多少魔力   
  1292.     # 定义说明文字
  1293.     @text_hp_sc = "体力可以增加生存的能力,可以延长生存的时间!"
  1294.     @text_str_sc = $data_system.words.str + "可以增加物理攻击和物理技能的威力!"
  1295.     @text_dex_sc = $data_system.words.dex + "可以提高攻击的命中率和必杀!"
  1296.     @text_agi_sc = $data_system.words.agi + "可以提高回避、命中、逃跑成功率!"
  1297.     @text_int_sc = $data_system.words.int + "可以提高魔法的效果,可以增加1点魔法!"
  1298.     @text_save = "保存分配情况并返回游戏"
  1299.     @text_reset= "重新分配能力点数"
  1300.     @text_2 = "每增加一次此项能力值,可以提升能力值"
  1301.     @text_hp = "最大" + $data_system.words.hp + "值"
  1302.     @text_sp = "最大" + $data_system.words.sp + "值"
  1303.     @text_str = "最大" + $data_system.words.str + "值"
  1304.     @text_dex = "最大" + $data_system.words.dex + "值"
  1305.     @text_agi = "最大" + $data_system.words.agi + "值"
  1306.     @text_int = "最大" + $data_system.words.int + "值"
  1307.     s_disable
  1308.     # 生成状态窗口
  1309.     @lvup_window = Window_Lvup.new(@actor)
  1310.     @lvup_window.x = 128
  1311.     @lvup_window.y = 0   
  1312.     # 生成帮助窗口并初始化帮助文本
  1313.     @help_window = Window_Lvup_Help.new   
  1314.     # 执行过渡
  1315.     Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
  1316.     # 主循环
  1317.     loop do
  1318.       # 刷新游戏画面
  1319.       Graphics.update
  1320.       # 刷新输入信息
  1321.       Input.update
  1322.       # 刷新画面
  1323.       update
  1324.       # 如果切换画面就中断循环
  1325.       if $scene != self
  1326.         break
  1327.       end
  1328.     end
  1329.     # 准备过渡
  1330.     Graphics.freeze
  1331.     # 释放窗口
  1332.     @command_window.dispose
  1333.     @lvup_window.dispose
  1334.     @help_window.dispose
  1335.   end
  1336.   #--------------------------------------------------------------------------
  1337.   # ● 刷新画面
  1338.   #--------------------------------------------------------------------------
  1339.   def update
  1340.     # 刷新窗口
  1341.     @command_window.update
  1342.     s_disable
  1343.     @lvup_window.update
  1344.     #=============================================================
  1345.     # 按下 B 键的情况下
  1346.     #=============================================================
  1347.     if Input.trigger?(Input::B)
  1348.       # 演奏取消 SE
  1349.       $game_system.se_play($data_system.cancel_se)
  1350.       # 切换到地图画面
  1351.       $scene = Scene_High.new
  1352.       return
  1353.     end
  1354.     #=============================================================
  1355.     # 按下 C 键的情况下
  1356.     #=============================================================
  1357.     if Input.trigger?(Input::C)
  1358.       if @command_window.index == 5
  1359.           # 演奏确定 SE
  1360.         $game_system.se_play($data_system.decision_se)
  1361.         # 将角色的剩余点数带回
  1362.         $game_variables[@actor.id + LEVEL_UP_VARIABLE] = $point
  1363.         # 将角色点数实际加上
  1364.         @actor.str += $temp_str
  1365.         @actor.dex += $temp_dex
  1366.         @actor.agi += $temp_agi
  1367.         @actor.int += $temp_int
  1368.         @actor.maxhp += $temp_hp
  1369.         @actor.maxsp += $temp_sp
  1370.         # 切换到地图画面
  1371.         $scene = Scene_High.new
  1372.         return
  1373.       end
  1374.       if @command_window.index == 6
  1375.           # 演奏确定 SE
  1376.         $game_system.se_play($data_system.cancel_se)
  1377.           # 将角色的剩余点数带入
  1378.         $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE]   
  1379.           # 初始化临时量
  1380.         $temp_str = 0
  1381.         $temp_dex = 0
  1382.         $temp_agi = 0
  1383.         $temp_int = 0
  1384.         $temp_hp = 0
  1385.         $temp_sp = 0
  1386.         @lvup_window.refresh
  1387.         return
  1388.       end
  1389.       if $point == 0
  1390.         # 演奏冻结 SE
  1391.         $game_system.se_play($data_system.buzzer_se)
  1392.         return
  1393.       end
  1394.       case @command_window.index
  1395.       when 0
  1396.         # 演奏确定 SE
  1397.         $game_system.se_play($data_system.decision_se)
  1398.         $temp_hp += @hp
  1399.         $temp_sp += @sp
  1400.         $temp_str += @hp_str
  1401.         $temp_dex += @hp_dex
  1402.         $temp_agi += @hp_agi
  1403.         $temp_int += @hp_int
  1404.         $point -= 1
  1405.         @lvup_window.refresh
  1406.         s_disable
  1407.         return
  1408.       when 1
  1409.         # 演奏确定 SE
  1410.         $game_system.se_play($data_system.decision_se)
  1411.         $temp_str += @str_str
  1412.         $temp_hp += @str_hp
  1413.         $temp_sp += @str_sp
  1414.         $temp_dex += @str_dex
  1415.         $temp_agi += @str_agi
  1416.         $temp_int += @str_int
  1417.         $point -= 1
  1418.         @lvup_window.refresh
  1419.         s_disable
  1420.         return
  1421.       when 2
  1422.         # 演奏确定 SE
  1423.         $game_system.se_play($data_system.decision_se)
  1424.         $temp_dex += @dex_dex
  1425.         $temp_hp += @dex_hp
  1426.         $temp_sp += @dex_sp
  1427.         $temp_str += @dex_str
  1428.         $temp_agi += @dex_agi
  1429.         $temp_int += @dex_int
  1430.         $point -= 1
  1431.         @lvup_window.refresh
  1432.         s_disable
  1433.         return
  1434.       when 3
  1435.         # 演奏确定 SE
  1436.         $game_system.se_play($data_system.decision_se)
  1437.         $temp_agi += @agi_agi
  1438.         $temp_hp += @agi_hp
  1439.         $temp_sp += @agi_sp
  1440.         $temp_str += @agi_str
  1441.         $temp_dex += @agi_dex
  1442.         $temp_int += @agi_int
  1443.         $point -= 1
  1444.         @lvup_window.refresh
  1445.         s_disable
  1446.         return
  1447.       when 4
  1448.         # 演奏确定 SE
  1449.         $game_system.se_play($data_system.decision_se)
  1450.         $temp_int += @int_int
  1451.         $temp_hp += @int_hp
  1452.         $temp_sp += @int_sp
  1453.         $temp_str += @int_str
  1454.         $temp_dex += @int_dex
  1455.         $temp_agi += @int_agi
  1456.         $point -= 1
  1457.         @lvup_window.refresh
  1458.         s_disable
  1459.         return
  1460.       end
  1461.     end
  1462.     #=============================================================
  1463.     # 什么都没有按下的情况
  1464.     #=============================================================
  1465.     case @command_window.index   
  1466.     when 0  # 增加体力
  1467.       temptext1 = @text_hp + @hp.to_s + "点   " + @text_str + @hp_str.to_s + "点   " + @text_dex + @hp_dex.to_s + "点"
  1468.       temptext2 = @text_sp + @sp.to_s + "点   " + @text_agi + @hp_agi.to_s + "点   " + @text_int + @hp_int.to_s + "点"
  1469.       @help_window.lvup_text(@text_hp_sc , @text_2 , temptext1 , temptext2)
  1470.     when 1  # 增加力量
  1471.       temptext1 = @text_hp + @str_hp.to_s + "点   " + @text_str + @str_str.to_s + "点   " + @text_dex + @str_dex.to_s + "点"
  1472.       temptext2 = @text_sp + @str_sp.to_s + "点   " + @text_agi + @str_agi.to_s + "点   " + @text_int + @str_int.to_s + "点"
  1473.       @help_window.lvup_text(@text_str_sc , @text_2 , temptext1 , temptext2)
  1474.     when 2  # 增加灵巧
  1475.       temptext1 = @text_hp + @dex_hp.to_s + "点   " + @text_str + @dex_agi.to_s + "点   " + @text_dex + @dex_dex.to_s + "点"
  1476.       temptext2 = @text_sp + @dex_sp.to_s + "点   " + @text_agi + @dex_agi.to_s + "点   " + @text_int + @dex_int.to_s + "点"
  1477.       @help_window.lvup_text(@text_dex_sc , @text_2 , temptext1 , temptext2)
  1478.     when 3  # 增加速度
  1479.       temptext1 = @text_hp + @agi_hp.to_s + "点   " + @text_str + @agi_str.to_s + "点   " + @text_dex + @agi_dex.to_s + "点"
  1480.       temptext2 = @text_sp + @agi_sp.to_s + "点   " + @text_agi + @agi_agi.to_s + "点   " + @text_int + @agi_int.to_s + "点"
  1481.       @help_window.lvup_text(@text_agi_sc , @text_2 , temptext1 , temptext2)
  1482.     when 4  # 增加魔力
  1483.       temptext1 = @text_hp + @int_hp.to_s + "点   " + @text_str + @int_str.to_s + "点   " + @text_dex + @int_dex.to_s + "点"
  1484.       temptext2 = @text_sp + @int_sp.to_s + "点   " + @text_agi + @int_agi.to_s + "点   " + @text_int + @int_int.to_s + "点"
  1485.       @help_window.lvup_text(@text_int_sc , @text_2 , temptext1 , temptext2)
  1486.     when 5 # 保存设定
  1487.       @help_window.lvup_text(@text_save)
  1488.     when 6 # 点数重置
  1489.       @help_window.lvup_text(@text_reset)     
  1490.     end
  1491.     #=============================================================
  1492.     # 按下R与L换人的情况
  1493.     #=============================================================      
  1494.     if Input.trigger?(Input::R)
  1495.       # 演奏光标 SE
  1496.       $game_system.se_play($data_system.cursor_se)
  1497.       # 移至下一位角色
  1498.       @actor_index += 1
  1499.       @actor_index %= $game_party.actors.size
  1500.       # 切换到别的状态画面
  1501.       $scene = Scene_Lvup.new(@actor_index , @command_window.index)
  1502.       return
  1503.     end
  1504.     # 按下 L 键的情况下
  1505.     if Input.trigger?(Input::L)
  1506.       # 演奏光标 SE
  1507.       $game_system.se_play($data_system.cursor_se)
  1508.       # 移至上一位角色
  1509.       @actor_index += $game_party.actors.size - 1
  1510.       @actor_index %= $game_party.actors.size
  1511.       # 切换到别的状态画面
  1512.       $scene = Scene_Lvup.new(@actor_index , @command_window.index)
  1513.       return
  1514.     end
  1515.   end  
  1516.   #--------------------------------------------------------------------------
  1517.   # ● 选项明暗判断
  1518.   #--------------------------------------------------------------------------
  1519.   def s_disable
  1520.     # 判断剩余点数是否为0,如果为0,那么增加选项表示为暗色
  1521.     if $point == 0
  1522.       @command_window.disable_item(0)
  1523.       @command_window.disable_item(1)
  1524.       @command_window.disable_item(2)
  1525.       @command_window.disable_item(3)
  1526.       @command_window.disable_item(4)
  1527.     else
  1528.       @command_window.able_item(0)
  1529.       @command_window.able_item(1)      
  1530.       @command_window.able_item(2)
  1531.       @command_window.able_item(3)
  1532.       @command_window.able_item(4)
  1533.     end
  1534.   end
  1535. end

  1536. #==============================================================================
  1537. # *以上是升级加点的处理~~~
  1538. #==============================================================================
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
132 小时
注册时间
2012-1-21
帖子
512
2
发表于 2012-7-1 18:32:28 | 只看该作者
全部加上注释对于刚学习脚本的同学很有帮助呢,不过阁下不会用代码插入功能吗

另外,请将脚本的功能总结写于最前面

点评

阿咧?这家伙发完脚本就跑了么  发表于 2012-7-2 06:47
我真心觉得这是个学习的好资料~  发表于 2012-7-1 22:45
心情大好呢
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
90
在线时间
85 小时
注册时间
2012-5-27
帖子
148
3
 楼主| 发表于 2012-7-8 13:21:20 | 只看该作者
呵呵,现在我会用代码功能了,谢谢你的指教!~~~~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
90
在线时间
85 小时
注册时间
2012-5-27
帖子
148
4
 楼主| 发表于 2012-7-8 13:23:42 | 只看该作者
零の使魔 发表于 2012-7-1 18:32
全部加上注释对于刚学习脚本的同学很有帮助呢,不过阁下不会用代码插入功能吗

另外,请将脚本的功能总结写 ...

顺便提一下,我一般周六,周日才上网,其余的就是制作游戏和学习了,所以我回贴的时间一般比较晚!{:2_287:}

点评

me不是上班族  发表于 2012-7-9 15:00
上班族么,= = 另外注意不要连帖  发表于 2012-7-8 16:32
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2012-7-16
帖子
6
5
发表于 2012-8-26 17:48:36 | 只看该作者
又没叫你回帖

评分

参与人数 1星屑 -40 收起 理由
忧雪の伤 -40

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2012-8-17
帖子
29
6
发表于 2012-8-27 23:05:00 | 只看该作者
好详细的说明,感谢了,脚本正苦手,正好有帮助啊
回复 支持 反对

使用道具 举报

Lv3.寻梦者

伴侣:北岛谜烟

梦石
0
星屑
2902
在线时间
3547 小时
注册时间
2012-8-7
帖子
12181

贵宾

7
发表于 2012-8-28 17:40:12 | 只看该作者
会和其他脚本冲突么?可以在VA用么……总觉得不符合VA的脚本格式……

如果能把功能列举出来就更好了!

点评

会有冲突,只能在XP中使用  发表于 2012-8-30 10:50
本人收不到提醒(点评|回复|@人),总之有事情到空间留言一起普通普通
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-13 14:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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