Project1

标题: 关于图标战斗逃跑无效 [打印本页]

作者: pertas    时间: 2012-8-25 00:03
标题: 关于图标战斗逃跑无效
Q:灵儿续传里的图标战斗脚本,我添加了逃跑后图标是出现了,但是点击无效果,搜索了很多都无解,求高手解答


  1. #==============================================================================
  2. #==============================================================================
  3. module Momo_IconCommand
  4.   # 图标名称设定
  5.   ATTACK_ICON_NAME = "B攻击" # 攻撃
  6.   SKILL_ICON_NAME = "B技能"   # 特技
  7.   GUARD_ICON_NAME = "B防御"  # 防御
  8.   ITEM_ICON_NAME = "B道具"     # 物品
  9.   ESCAPE_ICON_NAME = "B逃跑"  # 逃跑
  10.   # X坐标修正
  11.   X_PLUS = -320
  12.   # Y坐标修正
  13.   Y_PLUS = -100
  14.   # 选择时图标的动作
  15.   # 0:静止 1:放大
  16.   SELECT_TYPE = 0
  17.   # 闪烁时光芒的颜色
  18.   FLASH_COLOR = Color.new(255, 255, 255, 128)
  19.   # 闪烁时间
  20.   FLASH_DURATION = 10
  21.   # 闪烁间隔
  22.   FLASH_INTERVAL = 20
  23.   # 是否写出文字的名称
  24.   COM_NAME_DROW = false
  25.   # 文字名称是否移动
  26.   COM_NAME_MOVE = false
  27.   # 文字内容
  28.   ATTACK_NAME = "攻击"    # 攻击
  29.   SKILL_NAME = "特技"   # 特技
  30.   GUARD_NAME = "防御"     # 防御
  31.   ITEM_NAME = "物品"  # 物品
  32.   ESCAPE_NAME = "逃跑"  # 逃跑
  33.   # 文字颜色
  34.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  35.   # 文字坐标修正
  36.   COM_NAME_X_PLUS = 0
  37.   COM_NAME_Y_PLUS = 0
  38. end
  39. class Window_CommandIcon < Window_Selectable
  40.   attr_accessor :last_index
  41.   #--------------------------------------------------------------------------
  42.   # ● オブジェクト初期化
  43.   #--------------------------------------------------------------------------
  44.   def initialize(x, y, commands)
  45.     super(x, y, 37, 37)
  46.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
  47.     self.windowskin = RPG::Cache.windowskin("")
  48.     @item_max = commands.size
  49.     @commands = commands
  50.     @column_max = commands.size
  51.     @index = 0
  52.     @last_index = nil
  53.     @name_sprite = nil
  54.     @sprite = []
  55.     refresh
  56.   end
  57.   def dispose
  58.     super
  59.     for sprite in @sprite
  60.       sprite.dispose unless sprite.nil?
  61.     end
  62.     @name_sprite.dispose unless @name_sprite.nil?
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● リフレッシュ
  66.   #--------------------------------------------------------------------------
  67.   def refresh
  68.     @name_sprite.dispose unless @name_sprite.nil?
  69.     for sprite in @sprite
  70.       sprite.dispose unless sprite.nil?
  71.     end
  72.     @name_sprite = nil
  73.     draw_com_name if Momo_IconCommand::COM_NAME_DROW
  74.     @sprite = []
  75.     for i in 0...@item_max
  76.       draw_item(i)
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 項目の描画
  81.   #--------------------------------------------------------------------------
  82.   def draw_item(index)
  83.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])
  84.     @sprite[index].z = self.z + 1
  85.   end
  86.   def draw_com_name
  87.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
  88.    
  89.   end
  90.   
  91.   # 更新
  92.   def update
  93.       
  94.    

  95.    
  96.    
  97.    
  98.     super
  99.     icon_update
  100.     com_name_update if Momo_IconCommand::COM_NAME_DROW
  101.     if move_index?
  102.       @last_index = self.index
  103.     end
  104.   end
  105.   # アイコンの更新
  106.   def icon_update
  107.     qx = 25
  108.     qy = 385
  109.     for i in [email protected]
  110.       @sprite[i].active = (self.index == i)
  111.       @sprite[0].x = 40 +qx+480
  112.       @sprite[0].y = -15 +qy-150
  113.       @sprite[1].x = 0 + qx+480
  114.       @sprite[1].y = 23 + qy-150
  115.       @sprite[2].x = 40 + qx+480
  116.       @sprite[2].y = 59 + qy-150
  117.       @sprite[3].x = 81 + qx+480
  118.       @sprite[3].y = 23 + qy-150
  119.       @sprite[3].x = 75 + qx+480
  120.       @sprite[4].y = 46 + qy-150
  121.       #@sprite[i].x = self.x + i * 56
  122.       #@sprite[i].y = self.y + 0
  123.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
  124.       @sprite[i].visible = self.visible
  125.       @sprite[i].update
  126.     end
  127.   end
  128.   # コマンドネームの更新
  129.   def com_name_update
  130.     if move_index?
  131.       @name_sprite.name = get_com_name
  132.     end
  133.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
  134.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
  135.     @name_sprite.z = self.z + 1
  136.     @name_sprite.active = self.active
  137.     @name_sprite.visible = self.visible
  138.     @name_sprite.update
  139.   end
  140.   def get_com_name
  141.     make_name_set if @name_set.nil?
  142.     name = @name_set[self.index]
  143.     name = "" if name.nil?
  144.     return name
  145.   end
  146.   def make_name_set
  147.     @name_set = []
  148.     @name_set[0] = Momo_IconCommand::ATTACK_NAME
  149.     @name_set[1] = Momo_IconCommand::SKILL_NAME
  150.     @name_set[2] = Momo_IconCommand::GUARD_NAME
  151.     @name_set[3] = Momo_IconCommand::ITEM_NAME
  152.     @name_set[4] = Momo_IconCommand::ESCAPE_NAME
  153.   end
  154.   def move_index?
  155.     return self.index != @last_index
  156.   end
  157.   def need_reset
  158.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  159.   end
  160. end
  161. # アイコン用スプライト
  162. class Sprite_Icon < Sprite
  163.   attr_accessor :active
  164.   attr_accessor :icon_name
  165.   #--------------------------------------------------------------------------
  166.   # ● オブジェクト初期化
  167.   #--------------------------------------------------------------------------
  168.   def initialize(viewport, icon_name)
  169.     super(viewport)
  170.     @icon_name = icon_name
  171.     @last_icon = @icon_name
  172.     @count = 0
  173.     self.bitmap = RPG::Cache.icon(@icon_name)
  174.     self.ox = self.bitmap.width / 2
  175.     self.oy = self.bitmap.height / 2
  176.     @active = false
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 解放
  180.   #--------------------------------------------------------------------------
  181.   def dispose
  182.     if self.bitmap != nil
  183.       self.bitmap.dispose
  184.     end
  185.     super
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● フレーム更新
  189.   #--------------------------------------------------------------------------
  190.   def update
  191.    
  192.    
  193.     super
  194.     if @icon_name != @last_icon
  195.       @last_icon = @icon_name
  196.       self.bitmap = RPG::Cache.icon(@icon_name)
  197.     end
  198.     if @active
  199.       @count += 1
  200.       case Momo_IconCommand::SELECT_TYPE
  201.       when 0
  202.         icon_flash
  203.       when 1
  204.         icon_zoom
  205.       end
  206.       @count = 0 if @count == 20
  207.     else
  208.       icon_reset
  209.     end
  210.   end
  211.   def icon_flash
  212.    
  213.    
  214.    
  215.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
  216.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
  217.     end
  218.   end
  219.   def icon_zoom
  220.     case @count
  221.     when 1..10
  222.       zoom = 1.0 + @count / 10.0
  223.     when 11..20
  224.       zoom = 2.0 - (@count - 10) / 10.0
  225.     end
  226.     self.zoom_x = zoom
  227.     self.zoom_y = zoom
  228.   end
  229.   def icon_reset
  230.     @count = 0
  231.     self.zoom_x = 1.0
  232.     self.zoom_y = 1.0
  233.   end
  234. end
  235. # コマンドネーム用スプライト
  236. class Sprite_Comm_Name < Sprite
  237.   attr_accessor :active
  238.   attr_accessor :name
  239.   attr_accessor :need_reset
  240.   #--------------------------------------------------------------------------
  241.   # ● オブジェクト初期化
  242.   #--------------------------------------------------------------------------
  243.   def initialize(viewport, name)
  244.     super(viewport)
  245.     @name = name
  246.     @last_name = nil
  247.     @count = 0
  248.     @x_plus = 0
  249.     @opa_plus = 0
  250.     @need_reset = false
  251.     @active = false
  252.     self.bitmap = Bitmap.new(160, 32)
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 解放
  256.   #--------------------------------------------------------------------------
  257.   def dispose
  258.     if self.bitmap != nil
  259.       self.bitmap.dispose
  260.     end
  261.     super
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● フレーム更新
  265.   #--------------------------------------------------------------------------
  266.   def update
  267.    
  268.    
  269.    
  270.     super
  271.     if @active
  272.       if need_reset?
  273.         @need_reset = false
  274.         @last_name = @name
  275.         text_reset
  276.       end
  277.       move_text if Momo_IconCommand::COM_NAME_MOVE
  278.     end
  279.   end
  280.   def move_text
  281.     @count += 1
  282.     @x_plus = [@count * 8, 80].min
  283.     self.y = 0
  284.     self.x = self.x - 300 - @x_plus
  285.     self.opacity = @count * 25
  286.   end
  287.   def text_reset
  288.     @count = 0
  289.     @x_plus = 0
  290.     self.bitmap.clear
  291.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
  292.     self.bitmap.draw_text(0, 0, 160, 32, @name)
  293.   end
  294.   def need_reset?
  295.     return (@name != @last_name or @need_reset)
  296.   end
  297. end
  298. class Scene_Battle
  299.   #--------------------------------------------------------------------------
  300.   # ● プレバトルフェーズ開始
  301.   #--------------------------------------------------------------------------
  302.   alias scene_battle_icon_command_start_phase1 start_phase1
  303.   def start_phase1
  304.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  305.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  306.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  307.     com4 = Momo_IconCommand::ITEM_ICON_NAME
  308.     com5 = Momo_IconCommand::ESCAPE_ICON_NAME
  309.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4, com5])
  310.     @actor_command_window.y = 160
  311.     @actor_command_window.back_opacity = 160
  312.     $fff = 0
  313.     @actor_command_window.active = false
  314. #    @actor_command_window.visible = false
  315.     @actor_command_window.update
  316.     scene_battle_icon_command_start_phase1
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● アクターコマンドウィンドウのセットアップ
  320.   #--------------------------------------------------------------------------
  321.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  322.   def phase3_setup_command_window
  323.     scene_battle_icon_command_phase3_setup_command_window
  324.     # アクターコマンドウィンドウの位置を設定
  325.     @actor_command_window.x = 1000
  326.     @actor_command_window.y = 1000
  327.     @actor_command_window.need_reset
  328.   end
  329.   def command_window_actor_x(index)
  330.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  331.   end
  332.   def command_window_actor_y(index)
  333.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  334.   end
  335. end
  336. #==============================================================================
  337. #==============================================================================
复制代码

dsu_plus_rewardpost_czw
作者: 熊猫    时间: 2012-8-25 11:14
在脚本[Scene_Battle 3]搜索
  1. case @actor_command_window.index
复制代码
把下面代码的加到case控制语句里面
  1.       when 4
  2.         # 不能逃跑的情况下
  3.         if $game_temp.battle_can_escape == false
  4.           # 演奏冻结 SE
  5.           $game_system.se_play($data_system.buzzer_se)
  6.           return
  7.         end
  8.         # 演奏确定 SE
  9.         $game_system.se_play($data_system.decision_se)
  10.         # 逃走处理
  11.         update_phase2_escape
复制代码





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