Project1

标题: 图标战斗的“逃跑”选项无效。 [打印本页]

作者: 耶和华    时间: 2011-4-17 15:15
标题: 图标战斗的“逃跑”选项无效。
用了“菜鸟横板”和“图标战斗”,发现“图标战斗”的逃跑选项无效。
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. module Momo_IconCommand
  5.   # 图标名称设定
  6.   ATTACK_ICON_NAME = "B攻击" # 攻撃
  7.   SKILL_ICON_NAME = "B技能"   # 特技
  8.   GUARD_ICON_NAME = "B防御"  # 防御
  9.   ITEM_ICON_NAME = "B道具"     # 物品
  10.   ESCAPE_ICON_NAME = "B逃跑"  # 逃跑
  11.   # X坐标修正
  12.   X_PLUS = -47
  13.   # Y坐标修正
  14.   Y_PLUS = +35
  15.   # 选择时图标的动作
  16.   # 0:静止 1:放大
  17.   SELECT_TYPE = 0
  18.   # 闪烁时光芒的颜色
  19.   FLASH_COLOR = Color.new(255, 255, 255, 128)
  20.   # 闪烁时间
  21.   FLASH_DURATION = 10
  22.   # 闪烁间隔
  23.   FLASH_INTERVAL = 20
  24.   # 是否写出文字的名称
  25.   COM_NAME_DROW = true
  26.   # 文字名称是否移动
  27.   COM_NAME_MOVE = true
  28.   # 文字内容
  29.   ATTACK_NAME = "攻"    # 攻击
  30.   SKILL_NAME = "技"   # 特技
  31.   GUARD_NAME = "防"     # 防御
  32.   ITEM_NAME = "物"  # 物品
  33.   ESCAPE_NAME = "逃"  # 逃跑
  34.   # 文字颜色
  35.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  36.   # 文字坐标修正
  37.   COM_NAME_X_PLUS = 20
  38.   COM_NAME_Y_PLUS = 0
  39. end

  40. class Window_CommandIcon < Window_Selectable
  41.   attr_accessor :last_index
  42.   #--------------------------------------------------------------------------
  43.   # ● オブジェクト初期化
  44.   #--------------------------------------------------------------------------
  45.   def initialize(x, y, commands)
  46.     super(x, y, 32, 32)
  47.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
  48.     self.windowskin = RPG::Cache.windowskin("")
  49.     @item_max = commands.size
  50.     @commands = commands
  51.     @column_max = commands.size
  52.     @index = 0
  53.     @last_index = nil
  54.     @name_sprite = nil
  55.     @sprite = []
  56.     refresh
  57.   end
  58.   def dispose
  59.     super
  60.     for sprite in @sprite
  61.       sprite.dispose unless sprite.nil?
  62.     end
  63.     @name_sprite.dispose unless @name_sprite.nil?
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● リフレッシュ
  67.   #--------------------------------------------------------------------------
  68.   def refresh
  69.     @name_sprite.dispose unless @name_sprite.nil?
  70.     for sprite in @sprite
  71.       sprite.dispose unless sprite.nil?
  72.     end
  73.     @name_sprite = nil
  74.     draw_com_name if Momo_IconCommand::COM_NAME_DROW
  75.     @sprite = []
  76.     for i in 0...@item_max
  77.       draw_item(i)
  78.     end
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 項目の描画
  82.   #--------------------------------------------------------------------------
  83.   def draw_item(index)
  84.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])
  85.     @sprite[index].z = self.z + 100##########################
  86.   end
  87.   def draw_com_name
  88.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
  89.    
  90.   end
  91.   
  92.   # 更新
  93.   def update
  94.     super
  95.     icon_update
  96.     com_name_update if Momo_IconCommand::COM_NAME_DROW
  97.     if move_index?
  98.       @last_index = self.index
  99.     end
  100.   end
  101.   # アイコンの更新
  102.   def icon_update
  103.     for i in [email protected]
  104.       @sprite[i].active = (self.index == i)
  105.       @sprite[i].x = self.x + i * 24
  106.       @sprite[i].y = self.y + 0
  107.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
  108.       @sprite[i].visible = self.visible
  109.       @sprite[i].update
  110.     end
  111.   end
  112.   # コマンドネームの更新
  113.   def com_name_update
  114.     if move_index?
  115.       @name_sprite.name = get_com_name
  116.     end
  117.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
  118.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
  119.     @name_sprite.z = self.z + 1
  120.     @name_sprite.active = self.active
  121.     @name_sprite.visible = self.visible
  122.     @name_sprite.update
  123.   end
  124.   def get_com_name
  125.     make_name_set if @name_set.nil?
  126.     name = @name_set[self.index]
  127.     name = "" if name.nil?
  128.     return name
  129.   end
  130.   def make_name_set
  131.     @name_set = []
  132.     @name_set[0] = Momo_IconCommand::ATTACK_NAME
  133.     @name_set[1] = Momo_IconCommand::SKILL_NAME
  134.     @name_set[2] = Momo_IconCommand::GUARD_NAME
  135.     @name_set[3] = Momo_IconCommand::ITEM_NAME
  136.     @name_set[4] = Momo_IconCommand::ESCAPE_NAME
  137.   end
  138.   def move_index?
  139.     return self.index != @last_index
  140.   end
  141.   def need_reset
  142.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  143.   end
  144. end

  145. # アイコン用スプライト
  146. class Sprite_Icon < Sprite
  147.   attr_accessor :active
  148.   attr_accessor :icon_name
  149.   #--------------------------------------------------------------------------
  150.   # ● オブジェクト初期化
  151.   #--------------------------------------------------------------------------
  152.   def initialize(viewport, icon_name)
  153.     super(viewport)
  154.     @icon_name = icon_name
  155.     @last_icon = @icon_name
  156.     @count = 0
  157.     self.bitmap = RPG::Cache.icon(@icon_name)
  158.     self.ox = self.bitmap.width / 2
  159.     self.oy = self.bitmap.height / 2
  160.     @active = false
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 解放
  164.   #--------------------------------------------------------------------------
  165.   def dispose
  166.     if self.bitmap != nil
  167.       self.bitmap.dispose
  168.     end
  169.     super
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● フレーム更新
  173.   #--------------------------------------------------------------------------
  174.   def update
  175.     super
  176.     if @icon_name != @last_icon
  177.       @last_icon = @icon_name
  178.       self.bitmap = RPG::Cache.icon(@icon_name)
  179.     end
  180.     if @active
  181.       @count += 1
  182.       case Momo_IconCommand::SELECT_TYPE
  183.       when 0
  184.         icon_flash
  185.       when 1
  186.         icon_zoom
  187.       end
  188.       @count = 0 if @count == 20
  189.     else
  190.       icon_reset
  191.     end
  192.   end
  193.   def icon_flash
  194.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
  195.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
  196.     end
  197.   end
  198.   def icon_zoom
  199.     case @count
  200.     when 1..10
  201.       zoom = 1.0 + @count / 10.0
  202.     when 11..20
  203.       zoom = 2.0 - (@count - 10) / 10.0
  204.     end
  205.     self.zoom_x = zoom
  206.     self.zoom_y = zoom
  207.   end
  208.   def icon_reset
  209.     @count = 0
  210.     self.zoom_x = 1.0
  211.     self.zoom_y = 1.0
  212.   end
  213. end

  214. # コマンドネーム用スプライト
  215. class Sprite_Comm_Name < Sprite
  216.   attr_accessor :active
  217.   attr_accessor :name
  218.   attr_accessor :need_reset
  219.   #--------------------------------------------------------------------------
  220.   # ● オブジェクト初期化
  221.   #--------------------------------------------------------------------------
  222.   def initialize(viewport, name)
  223.     super(viewport)
  224.     @name = name
  225.     @last_name = nil
  226.     @count = 0
  227.     @x_plus = 0
  228.     @opa_plus = 0
  229.     @need_reset = false
  230.     @active = false
  231.     self.bitmap = Bitmap.new(160, 32)
  232.   end
  233.   #--------------------------------------------------------------------------
  234.   # ● 解放
  235.   #--------------------------------------------------------------------------
  236.   def dispose
  237.     if self.bitmap != nil
  238.       self.bitmap.dispose
  239.     end
  240.     super
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● フレーム更新
  244.   #--------------------------------------------------------------------------
  245.   def update
  246.     super
  247.     if @active
  248.       if need_reset?
  249.         @need_reset = false
  250.         @last_name = @name
  251.         text_reset
  252.       end
  253.       move_text if Momo_IconCommand::COM_NAME_MOVE
  254.     end
  255.   end
  256.   def move_text
  257.     @count += 1
  258.     @x_plus = [@count * 8, 80].min
  259.     self.x = self.x - 80 + @x_plus
  260.     self.opacity = @count * 25
  261.   end
  262.   def text_reset
  263.     @count = 0
  264.     @x_plus = 0
  265.     self.bitmap.clear
  266.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
  267.     self.bitmap.draw_text(0, 0, 160, 32, @name)
  268.   end
  269.   def need_reset?
  270.     return (@name != @last_name or @need_reset)
  271.   end
  272. end

  273. class Scene_Battle
  274.   #--------------------------------------------------------------------------
  275.   # ● プレバトルフェーズ開始
  276.   #--------------------------------------------------------------------------
  277.   alias scene_battle_icon_command_start_phase1 start_phase1
  278.   def start_phase1
  279.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  280.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  281.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  282.     com4 = Momo_IconCommand::ITEM_ICON_NAME
  283.     com5 = Momo_IconCommand::ESCAPE_ICON_NAME
  284.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4, com5])
  285.     @actor_command_window.y = 160
  286.     @actor_command_window.back_opacity = 160
  287.     @actor_command_window.active = false
  288.     @actor_command_window.visible = false
  289.     @actor_command_window.update
  290.     scene_battle_icon_command_start_phase1
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ● アクターコマンドウィンドウのセットアップ
  294.   #--------------------------------------------------------------------------
  295.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  296.   def phase3_setup_command_window
  297.     scene_battle_icon_command_phase3_setup_command_window
  298.     # アクターコマンドウィンドウの位置を設定
  299.     @actor_command_window.x = command_window_actor_x(@actor_index)
  300.     @actor_command_window.y = command_window_actor_y(@actor_index)
  301.     @actor_command_window.need_reset
  302.   end
  303.   def command_window_actor_x(index)
  304.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  305.   end
  306.   def command_window_actor_y(index)
  307.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  308.   end
  309. end

  310. #==============================================================================
  311. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  312. #==============================================================================
复制代码
工程: 范例1.zip (494.92 KB, 下载次数: 39) dsu_plus_rewardpost_czw
作者: 忧雪の伤    时间: 2011-4-17 15:17
本帖最后由 忧雪の伤 于 2011-4-17 15:22 编辑

只显示了图标却没有更改光标的条件分歧跳转的内容,
当然没有效果。


  1. class Scene_Battle
  2.   def update_phase3_basic_command
  3.     if Input.trigger?(Input::B)
  4.       $game_system.se_play($data_system.cancel_se)
  5.       phase3_prior_actor
  6.       return
  7.     end
  8.     if Input.trigger?(Input::C)
  9.       case @actor_command_window.index
  10.       when 0
  11.         $game_system.se_play($data_system.decision_se)
  12.         @active_battler.current_action.kind = 0
  13.         @active_battler.current_action.basic = 0
  14.         start_enemy_select
  15.       when 1  
  16.         $game_system.se_play($data_system.decision_se)
  17.         @active_battler.current_action.kind = 1
  18.         start_skill_select
  19.       when 2  
  20.         $game_system.se_play($data_system.decision_se)
  21.         @active_battler.current_action.kind = 2
  22.         start_item_select
  23.       when 3  
  24.         $game_system.se_play($data_system.decision_se)
  25.         @active_battler.current_action.kind = 0
  26.         @active_battler.current_action.basic = 1
  27.         phase3_next_actor
  28.       when 4
  29.         if $game_temp.battle_can_escape == false
  30.           $game_system.se_play($data_system.buzzer_se)
  31.           return
  32.         end
  33.         $game_system.se_play($data_system.decision_se)
  34.         update_phase2_escape
  35.       end
  36.     end
  37.   end
  38. end
复制代码



随便你咯。




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