Project1

标题: 帮我改进下这个脚本 [打印本页]

作者: machinemxy    时间: 2008-2-26 03:18
标题: 帮我改进下这个脚本
class Window_VariableWindow < Window_Base
  VISIBLE_ID = 1  # 可见性控制(开关ID)
  VALUE_ID = 1    # 数值控制(变量ID)
  def initialize
    super(0,0,200,60)
    self.opacity = 0
    self.visible = $game_switches[VISIBLE_ID]
    @data = $game_variables[VALUE_ID]
    refresh
  end
  def refresh
    self.contents.clear
    draw_icon(137,0,0)
    self.contents.draw_text(25, 0, 40, WLH, $game_variables[VALUE_ID])
  end
  def update
    self.visible = $game_switches[VISIBLE_ID]
    if @data != $game_variables[VALUE_ID]
      refresh
      @data = $game_variables[VALUE_ID]
    end
  end
end
class Scene_Map < Scene_Base
  alias variable_start start
  alias variable_update update
  alias variable_terminate terminate
  def start
    variable_start
    @variableWindow = Window_VariableWindow.new
  end
  def update
    @variableWindow.update
    variable_update
  end
  def terminate
    variable_terminate
    @variableWindow.dispose
  end
end

这个脚本功能为在地图左上角显示变量1作为HP。现在我想同时显示变量1 2 3 分别作为 攻 防 和 血,显示在左端。应该怎么修改呢? [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: Beside    时间: 2008-2-26 03:21
怎么改进说都没说
作者: machinemxy    时间: 2008-2-26 03:22
最底下说了啊
作者: Beside    时间: 2008-2-26 03:30
你意思是说变量一是你自己设定的一个数值作为血而不是游戏里角色的hp值? [LINE]1,#dddddd[/LINE]系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
作者: 雪流星    时间: 2008-2-26 03:45
  1. class Window_VariableWindow < Window_Base
  2. VISIBLE_ID = 1  # 可见性控制(开关ID)
  3. HP_ID = 1       # 显示HP的变量ID
  4. ATK_ID = 2      # 显示攻击的变量ID
  5. DEF_ID = 3      # 显示防御的变量ID

  6. def initialize
  7.    super(0,0,200,110)
  8.    self.opacity = 0
  9.    self.visible = $game_switches[VISIBLE_ID]
  10.    $game_variables[HP_ID]  = $game_actors[1].hp
  11.    $game_variables[ATK_ID] = $game_actors[1].atk
  12.    $game_variables[DEF_ID] = $game_actors[1].def
  13.    
  14.    refresh
  15. end
  16. def refresh
  17.    self.contents.clear
  18.    draw_icon(137,0,0)
  19.    self.contents.draw_text(25, 0, 40, WLH, $game_variables[HP_ID])
  20.    draw_icon(1,0,24)
  21.    self.contents.draw_text(25, 24, 40, WLH, $game_variables[ATK_ID])
  22.    draw_icon(52,0,48)
  23.    self.contents.draw_text(25, 48, 40, WLH, $game_variables[DEF_ID])
  24. end
  25. def update
  26.    self.visible = $game_switches[VISIBLE_ID]
  27.    
  28.    if $game_actors[1].hp != $game_variables[HP_ID]
  29.      refresh
  30.      $game_variables[HP_ID] = $game_actors[1].hp
  31.    end
  32.    
  33.    if $game_actors[1].atk != $game_variables[ATK_ID]
  34.      refresh
  35.      $game_variables[ATK_ID] = $game_actors[1].atk
  36.    end
  37.    
  38.    if $game_actors[1].def != $game_variables[DEF_ID]
  39.      refresh
  40.      $game_variables[DEF_ID] = $game_actors[1].def
  41.    end
  42. end
  43. end
  44. class Scene_Map < Scene_Base
  45. alias variable_start start
  46. alias variable_update update
  47. alias variable_terminate terminate
  48. def start
  49.    variable_start
  50.    @variableWindow = Window_VariableWindow.new
  51. end
  52. def update
  53.    @variableWindow.update
  54.    variable_update
  55. end
  56. def terminate
  57.    variable_terminate
  58.    @variableWindow.dispose
  59. end
  60. end
复制代码


修改完成,我不晓得原来的是谁写的,不过MS完全没用 [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: machinemxy    时间: 2008-2-26 03:55
楼上的可以实行,不过误解我的意思了。我不是用游戏里的攻击防御等,而是要用变量1 2 3 控制三者,我自己会设置。所以不要读取角色的数据。能否再改下 ?
作者: Beside    时间: 2008-2-26 04:00
参照lss的  变量先开始不要赋值为角色属性就可以了
  $game_variables[HP_ID]  = $game_actors[1].hp
   $game_variables[ATK_ID] = $game_actors[1].atk
   $game_variables[DEF_ID] = $game_actors[1].def 这个地方
作者: machinemxy    时间: 2008-2-26 04:04
不用了,我自己改好了,谢谢各位好意
作者: 雪流星    时间: 2008-2-26 04:05
LZ不知有无兴趣学脚本
如果有的话可以看看我的脚本是怎麽改的
和原脚本对比看看

其实这只是一个很简单的修改而已

  1. class Window_VariableWindow < Window_Base
  2. VISIBLE_ID = 1  # 可见性控制(开关ID)
  3. HP_ID = 1       # 显示HP的变量ID
  4. ATK_ID = 2      # 显示攻击的变量ID
  5. DEF_ID = 3      # 显示防御的变量ID

  6. def initialize
  7.    super(0,0,200,110)
  8.    self.opacity = 0
  9.    # 设置窗口是否可见
  10.    self.visible = $game_switches[VISIBLE_ID]
  11.    # 设置变量
  12.    @hp  = $game_variables[HP_ID]
  13.    @atk = $game_variables[ATK_ID]
  14.    @def = $game_variables[DEF_ID]
  15.    # 刷新窗口
  16.    refresh
  17. end
  18. def refresh
  19.    # 清除原内容
  20.    self.contents.clear
  21.    # 显示图标
  22.    draw_icon(137,0,0)
  23.    draw_icon(1,0,24)
  24.    draw_icon(52,0,48)
  25.    # 显示变量
  26.    self.contents.draw_text(25, 0, 40, WLH, $game_variables[HP_ID])
  27.    self.contents.draw_text(25, 24, 40, WLH, $game_variables[ATK_ID])
  28.    self.contents.draw_text(25, 48, 40, WLH, $game_variables[DEF_ID])
  29. end
  30. def update
  31.    # 更新
  32.    self.visible = $game_switches[VISIBLE_ID]
  33.    
  34.    # 更新变量
  35.    if @hp != $game_variables[HP_ID]
  36.      refresh
  37.      @hp = $game_variables[HP_ID]
  38.    end
  39.    
  40.    if @atk != $game_variables[ATK_ID]
  41.      refresh
  42.      @atk = $game_variables[ATK_ID]
  43.    end
  44.    
  45.    if @def != $game_variables[DEF_ID]
  46.      refresh
  47.      @def = $game_variables[DEF_ID]
  48.    end
  49. end
  50. end

  51. class Scene_Map < Scene_Base
  52.   # 使用alias防止冲突
  53.   alias variable_start start
  54.   alias variable_update update
  55.   alias variable_terminate terminate
  56.   def start
  57.     variable_start
  58.     # 呼叫窗口
  59.     @variableWindow = Window_VariableWindow.new
  60.   end
  61.   def update
  62.     # 更新窗口
  63.     @variableWindow.update
  64.     variable_update
  65.   end
  66.   def terminate
  67.     variable_terminate
  68.     # 解放窗口
  69.     @variableWindow.dispose
  70.   end
  71. end
复制代码

作者: Beside    时间: 2008-2-26 04:07
我有兴趣学啊= =!ls教我吧我还很多不会呢...有意短信我{/hx}




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