Save-Point
Combo Attacks Script Help - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Combo Attacks Script Help (/thread-4569.html)

Pages: 1 2


Combo Attacks Script Help - JackMonty - 03-09-2013

Hi All,

I need some help trying to fix a script which handles combo attacks. The script is to use in CCOA's battle system, see below:


Code:
#==============================================================================
# • Combo Skills (Chrono Trigger Style)
# by mikb89
# demo: 2 August 2009
# versione 1.2 - CCOA (3.04) compatible
#------------------------------------------------------------------------------
# To create a combo skill simply create a normal skill and then configure the
# combination parameters here. Note, the combo skills use the system from RM2K,
# therefore to use a technique with an attribute, you must have the equipment
# with that attribute. For example the skill "Sword Strike" with the attribute
# "Sword", requires you to have a weapon equipped with the attribute "Sword"
# (therefore an actual sword). If you do not want to use system attributes this
# can now be configured via the USA_ATTRIBUTI_SKILL below. Ensure it's set to 0
#==============================================================================
# • Configuration:
#------------------------------------------------------------------------------
module Impostazioni
class CTCombo

TASTO_CAMBIO_SKILL_E_COMBO = Input::A
# Combos are utilizzed by selecting "Skills" from the menu (or as otherwise
# named) and pressing a button. Press it again to return to normal skills.
# This constant specifies the key to press.
# Input::A equals SHIFT
# Input::CTRL equals CONTROL
# Input::L and Input::R equate to PageUp and PageDown
# There are other combinations, the important thing is the syntax which should
# always be "Input::" "key to use"

ARCHIVIAZIONE_VIA_SWITCH = 0
# In Chrono Trigger there are three party members who go into battle but the
# characters who are in the party (besides these three) can use combos from the
# menu. This method can be repeated here by setting this parameter to 1. By
# setting the parameter to 0 combos will only be valid if the characters needed
# to perform them actaully go into battle.

SWITCH_INIZIALE_MEMBRI = 1
# If the above constant is set to 1, this value specifies the switch that is
# activated when the first charcter is in your party. The other characters will
# have the following switch values depending on their order in the database.
# Note that if this method is active switches must be set for the three heroes
# who go into battle.

USA_ATTRIBUTI_SKILL = 0
# Active (1) or Deactivated (0). This controls the usage of skill attributes.
# As not everyone is familiar with attributes (which was used by standard in
# RM2K) I thought I would give the option to remove them. Whatever the setting,
# this refers only to the SKILL COMBO!
end
end

$combo_skill = [53, 54, 55, 56, 57, 58, 59, 60, 61, 81, 82, 83, 84, 85, 86, 87, 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, 147, 148, 149, 150, 151, 152, 153, 154]
# Contains the IDs of the skills that form the combo.
# In this case skils n° 53 and° 54 are combo skills.

$combo_hero = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 9], [1, 8], [1, 7], [1, 10], [2, 3], [2, 4], [2, 5], [2, 6], [2, 8], [2, 7], [3, 4], [3, 5], [3, 7], [4, 5], [4, 6], [4, 9], [5, 10], [9, 8], [9, 7], [7, 8], [7, 9, 8], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [11, 12, 13, 14], [6, 11, 12, 13, 14], [15, 16, 17, 18]]
# Contains the ID of the characters that can use the combo (Each combo is
# sepearted by [ ] brackets which contain the character ID that the combo
# belongs to). In this case the first skill in the list (Skill 53) can be
# performed by characters 1 & 2. The second skill (Skill 54) can be performed
# by characters 1 & 3 etc.

$combo_point = [[4, 5], [4, 4], [4, 4], [4, 4], [6, 6], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [8, 8, 8], [10, 10, 10, 10, 10], [12, 12, 12, 12, 12], [16, 16, 16, 16, 16], [20, 20, 20, 20, 20], [22, 22, 22, 22, 22], [16, 16, 16, 16], [16, 16, 16, 16, 16], [20, 20, 20, 20]]
# Contains the required magic points for each charatcer to perform the combo
# The characters a denoted in the $combo_hero section, replace the character
# ID with the magic points to be used. In this case skill the first skill in
# the list (Skill 53) can be performed by characters 1 & 2 and it will cost
# character 1 - 4 magic points and character 2 - 5 magic points.

# End of configuration

#-----------------VALENTINO------------
SKILL_COMBO = {
147=>SHOOT, #shoot
148=>ARROW,  #arrow
149=>VICTORY, #victory
150=>CLUSTER, #cluster
152=>ARROW  #arrow
}
#----------------VALENTINO-------------


class Window_Combo < Window_Selectable
  #--------------------------------------------------------------------------
  # ? Inizialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 320, 640, 160)
    @actor = actor
    @column_max = 1
    refresh
    self.index = 0
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # ? Return selected combo
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ? Combo draw count
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil and $combo_skill.include?(skill.id)
        @data.push(skill)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? Draw combo
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    for i in 0...$combo_skill.size
      if $combo_skill[i] != nil
      if $combo_skill[i] == skill.id
        n = i
      end
      end
    end
    v = 0
    for h in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][h]] != nil
      if $game_actors[$combo_hero[n][h]].combo_can_use?(skill.id)
        v += 1
      end
    end
    end
    
    #VALENTINO
    formation = SKILL_COMBO[skill.id]
    @colore = false
    if formation != nil
      if $battle_formation == formation
        self.contents.font.color = normal_color
      else
        @colore = true
        self.contents.font.color = disabled_color
      end
    end
    #VALENTINO
    
    if v == $combo_hero[n].size
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    
   self.contents.font.color = disabled_color if @colore
    
    
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 64)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    if not $game_temp.in_battle
      self.contents.draw_text(x + 232, y, 48, 32, $combo_point[n][0].to_s, 2)
      self.contents.draw_text(x + 288, y, 48, 32, $combo_point[n][1].to_s, 2) rescue nil
      self.contents.draw_text(x + 344, y, 48, 32, $combo_point[n][2].to_s, 2) rescue nil
      self.contents.draw_text(x + 400, y, 48, 32, $combo_point[n][3].to_s, 2) rescue nil
    else
      po = []
      for i in 0...$game_party.actors.size
        if $combo_hero[n].include?($game_party.actors[i].id)
          po.push $game_party.actors[i].id
        end
      end
      ex = po.size
      for r in 0...$combo_hero[n].size
        if $combo_hero[n][r] != nil
        if not po.include?($combo_hero[n][r])
          po.push $combo_hero[n][r]
        end
        end
      end
      for ach in 0...po.size
        if ach == ex
          self.contents.font.color = self.contents.font.color == normal_color ? knockout_color : Color.new(255, 64, 0, 128)
        end
        for h in 0...$combo_hero[n].size
          if $combo_point[n][h] != nil
          if $combo_hero[n][h] == po[ach]
            punti = $combo_point[n][h]
          end
          end
        end
        self.contents.draw_text(x + 232 + (ach * 56), y, 48, 32, punti.to_s, 2)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? Combo description window
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end

class Window_ComboStatus < Window_Base
  #--------------------------------------------------------------------------
  # ? Inizialization
  #--------------------------------------------------------------------------
  def initialize(actor, n)
    super(0, 64*n, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ? Draw values
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @actor != nil
      draw_actor_name(@actor, 4, 0)
      draw_actor_state(@actor, 140, 0)
      draw_actor_hp(@actor, 284, 0)
      draw_actor_sp(@actor, 460, 0)
    end
  end
  #--------------------------------------------------------------------------
  # ? Set character
  #--------------------------------------------------------------------------
  def actor=(actor)
    @actor = actor
    refresh
  end
end

class Scene_Combo
  #--------------------------------------------------------------------------
  # ? Inizialization
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # ? Main cycle
  #--------------------------------------------------------------------------
  def main
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @status_window = Window_ComboStatus.new(@actor, 1)
    @status_window2 = Window_ComboStatus.new(nil, 2)
    @status_window3 = Window_ComboStatus.new(nil, 3)
    @status_window4 = Window_ComboStatus.new(nil, 4)
    @skill_window = Window_Combo.new(@actor)
    @skill_window.help_window = @help_window
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @status_window.dispose
    @status_window2.dispose
    @status_window3.dispose
    @status_window4.dispose
    @skill_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  # ? Update
  #--------------------------------------------------------------------------
  def update
    @help_window.update
    @status_window.update
    @status_window2.update
    @status_window3.update
    @status_window4.update
    @skill_window.update
    @target_window.update
    if @skill_window.active
      update_skill
      return
    end
    if @target_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? Combo Management
  #--------------------------------------------------------------------------
  def update_skill
    for i in 0...$combo_skill.size
      if $combo_skill[i] == @skill_window.skill.id
        n = i
      end
    end
    if n != nil
      v = 0
      for h in 0...$combo_hero[n].size
        if $game_actors[$combo_hero[n][h]] != nil
        if $game_actors[$combo_hero[n][h]].combo_can_use?(@skill_window.skill.id)
          v += 1
        end
        end
      end
    end
    @status_window.actor = $game_actors[$combo_hero[n][0]] rescue @status_window.actor = @actor
    @status_window2.actor = $game_actors[$combo_hero[n][1]] rescue @status_window2.actor = nil
    @status_window3.actor = $game_actors[$combo_hero[n][2]] rescue @status_window3.actor = nil
    @status_window4.actor = $game_actors[$combo_hero[n][3]] rescue @status_window4.actor = nil
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(1)
      return
    end
    if Input.trigger?(Input::C)
      @skill = @skill_window.skill
      if @skill == nil or not v == $combo_hero[n].size
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      if @skill.scope >= 3
        @skill_window.active = false
        @target_window.x = (@skill_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        if @skill.scope == 4 || @skill.scope == 6
          @target_window.index = -1
        elsif @skill.scope == 7
          @target_window.index = @actor_index - 10
        else
          @target_window.index = 0
        end
      else
        if @skill.common_event_id > 0
          $game_temp.common_event_id = @skill.common_event_id
          $game_system.se_play(@skill.menu_se)
          for s in 0...$combo_hero[n].size
            if $game_actors[$combo_hero[n][s]] != nil
            $game_actors[$combo_hero[n][s]].sp -= $combo_point[n][s]
          end
          
          end
          @status_window.refresh
          @status_window2.refresh
          @status_window3.refresh
          @status_window4.refresh
          @skill_window.refresh
          @target_window.refresh
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
    if Input.trigger?(Input::R)
      $game_system.se_play($data_system.cursor_se)
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Combo.new(@actor_index)
      return
    end
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.cursor_se)
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Combo.new(@actor_index)
      return
    end
    if Input.trigger?(Impostazioni::CTCombo::TASTO_CAMBIO_SKILL_E_COMBO)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_Skill.new(@actor_index)
      return
    end
  end
  #--------------------------------------------------------------------------
  # ? Character select for combo use
  #--------------------------------------------------------------------------
  def update_target
    for i in 0...$combo_skill.size
      if $combo_skill[i] == @skill_window.skill.id
        n = i
      end
    end
    @status_window.actor = $game_actors[$combo_hero[n][0]] rescue @status_window.actor = @actor
    @status_window2.actor = $game_actors[$combo_hero[n][1]] rescue @status_window2.actor = nil
    @status_window3.actor = $game_actors[$combo_hero[n][2]] rescue @status_window3.actor = nil
    @status_window4.actor = $game_actors[$combo_hero[n][3]] rescue @status_window4.actor = nil
    v = 0
    for h in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][h]] != nil
      if $game_actors[$combo_hero[n][h]].combo_can_use?(@skill_window.skill.id)
        v += 1
      end
      end
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @skill_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    if Input.trigger?(Input::C)
      unless v == $combo_hero[n].size
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @target_window.index == -1
        used = false
        for i in $game_party.actors
          used |= i.skill_effect(@actor, @skill)
        end
      end
      if @target_window.index <= -2
        target = $game_party.actors[@target_window.index + 10]
        used = target.skill_effect(@actor, @skill)
      end
      if @target_window.index >= 0
        target = $game_party.actors[@target_window.index]
        used = target.skill_effect(@actor, @skill)
      end
      if used
        $game_system.se_play(@skill.menu_se)
        for s in 0...$combo_hero[n].size
          if $game_actors[$combo_hero[n][s]] != nil
          $game_actors[$combo_hero[n][s]].sp -= $combo_point[n][s]
          end
        end
        @status_window.refresh
        @status_window2.refresh
        @status_window3.refresh
        @status_window4.refresh
        @skill_window.refresh
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        if @skill.common_event_id > 0
          $game_temp.common_event_id = @skill.common_event_id
          $scene = Scene_Map.new
          return
        end
      end
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end
end

class Game_Actor < Game_Battler
    def combo_can_use?(skill_id)
    for i in 0...$combo_skill.size
      if $combo_skill[i] == skill_id
        n = i
      end
    end
    for i in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][i]] != nil
      if not $game_actors[$combo_hero[n][i]].skills.include?(skill_id)
        return false
      end
    end
    end
  
    if Impostazioni::CTCombo::USA_ATTRIBUTI_SKILL == 0
      return super
    else
      @acc = 0
      @times = 0
      for a in $data_skills[skill_id].element_set
        @times +=1
        if ($combo_hero[n][0] != nil and $data_weapons[$game_actors[$combo_hero[n][0]].weapon_id] != nil and $data_weapons[$game_actors[$combo_hero[n][0]].weapon_id].element_set.include?(a)) or
          ($combo_hero[n][1] != nil and $data_weapons[$game_actors[$combo_hero[n][1]].weapon_id] != nil and $data_weapons[$game_actors[$combo_hero[n][1]].weapon_id].element_set.include?(a)) or
          ($combo_hero[n][2] != nil and $data_weapons[$game_actors[$combo_hero[n][2]].weapon_id] != nil and $data_weapons[$game_actors[$combo_hero[n][2]].weapon_id].element_set.include?(a))
          @acc += 1
        else
          if ($combo_hero[n][0] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor1_id] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor1_id].guard_element_set.include?(a)) or
            ($combo_hero[n][1] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor1_id] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor1_id].guard_element_set.include?(a)) or
            ($combo_hero[n][2] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor1_id] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor1_id].guard_element_set.include?(a))
            @acc += 1
          else
            if ($combo_hero[n][0] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor2_id] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor2_id].guard_element_set.include?(a)) or
              ($combo_hero[n][1] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor2_id] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor2_id].guard_element_set.include?(a)) or
              ($combo_hero[n][2] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor2_id] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor2_id].guard_element_set.include?(a))
              @acc += 1
            else
              if ($combo_hero[n][0] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor3_id] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor3_id].guard_element_set.include?(a)) or
                ($combo_hero[n][1] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor3_id] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor3_id].guard_element_set.include?(a)) or
                ($combo_hero[n][2] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor3_id] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor3_id].guard_element_set.include?(a))
                @acc += 1
              else
                if ($combo_hero[n][0] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor4_id] != nil and $data_armors[$game_actors[$combo_hero[n][0]].armor4_id].guard_element_set.include?(a)) or
                  ($combo_hero[n][1] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor4_id] != nil and $data_armors[$game_actors[$combo_hero[n][1]].armor4_id].guard_element_set.include?(a)) or
                  ($combo_hero[n][2] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor4_id] != nil and $data_armors[$game_actors[$combo_hero[n][2]].armor4_id].guard_element_set.include?(a))
                  @acc += 1
                else
                  return false
                end
              end
            end
          end
        end
      end
      if @times == @acc
        return super
      else
        return false
      end
    end
  end
end

class Game_Battler
  def combo_can_use?(skill_id)
    for i in 0...$combo_skill.size
      if $combo_skill[i] == skill_id
        n = i
      end
    end
    for i in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][i]] != nil
      if $combo_point[n][i] > $game_actors[$combo_hero[n][i]].sp
        return false
      end
      end
    end
    for i in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][i]] != nil
      if $game_actors[$combo_hero[n][i]].hp == 0 and not $game_actors[$combo_hero[n][i]].immortal
        return false
      end
      end
    end
    for i in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][i]] != nil
      if $data_skills[skill_id].atk_f == 0 and $game_actors[$combo_hero[n][i]].restriction == 1
        return false
      end
      end
    end
    occasion = $data_skills[skill_id].occasion
    pl = 0
    if $game_temp.in_battle
      for i in 0...$combo_hero[n].size
        if $game_actors[$combo_hero[n][i]] != nil
        if $game_party.actors.include?($game_actors[$combo_hero[n][i]])
          pl += 1
        end
        end
      end
      if pl == $combo_hero[n].size
        return (occasion == 0 or occasion == 1)
      else
        return false
      end
    else
      for i in 0...$combo_hero[n].size
        if $combo_hero[n][i] != nil
        if Impostazioni::CTCombo::ARCHIVIAZIONE_VIA_SWITCH
          if $game_switches[$combo_hero[n][i] + Impostazioni::CTCombo::SWITCH_INIZIALE_MEMBRI - 1] == true
            pl += 1
          end
          end
        else
          if $game_party.actors.include?($combo_hero[n][i])
            pl += 1
          end
        end
      end
      if pl == $combo_hero[n].size
        return (occasion == 0 or occasion == 2)
      else
        return false
      end
    end
  end
end

class Scene_Skill
  alias ctbs_update_skill update_skill
  def update_skill
    ctbs_update_skill
    if Input.trigger?(Impostazioni::CTCombo::TASTO_CAMBIO_SKILL_E_COMBO)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_Combo.new(@actor_index)
      return
    end
  end
end

class Scene_Battle
  def main
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    $game_system.battle_interpreter.setup(nil, 0)
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    #ccoa
    #s1 = $data_system.words.attack
    #s2 = $data_system.words.skill
    #s3 = $data_system.words.guard
    #s4 = $data_system.words.item
    #@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    #@actor_command_window.y = 160
    #@actor_command_window.back_opacity = 160
    #@actor_command_window.active = false
    #@actor_command_window.visible = false
    @help_window2 = Win_Help.new
    @help_window2.visible = false
    @help_window2.contents_opacity = 0
    @help_time = 0
    @actor_command_windows = []
    setup_actor_command_windows
    @cursor_bitmap = Sprite.new
    @cursor_bitmap.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
    @cursor_bitmap.src_rect.set(128, 96, 32, 32)
    @cursor_bitmap.visible = false
    @blink_count = 0
    #fine ccoa
    @spriteset = Spriteset_Battle.new
    @wait_count = 0
    # compatibilità CCOA
    @extra_sprites = [] if @extra_sprites == nil
   # cp_preset_party
   # @cp_meters = CP_Meters.new
   # @extra_sprites.push(@cp_meters)
    # fine compatibilità
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(100, "Graphics/Transitions/" +
        $data_system.battle_transition) #era 40 ora è 100 x ccoa
    end
    start_phase1
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    $game_map.refresh
    Graphics.freeze
    #ccoa
    for window in @actor_command_windows
      window.dispose
    end
    #@actor_command_window.dispose
    #fine ccoa
    @party_command_window.dispose
    @help_window.dispose
    @help_window2.dispose #ccoa
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    #ccoa
    if @skill_window2 != nil
      @skill_window2.dispose
    end
    #fine ccoa
    if @combo_window != nil
      @combo_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    @spriteset.dispose
    # compatibilità CCOA
    @cursor_bitmap.dispose
    #@cp_meters.dispose
    # fine compatibilità
    if $scene.is_a?(Scene_Title)
      Graphics.transition
      Graphics.freeze
    end
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end

  def update_phase3
    if @enemy_arrow != nil
      update_phase3_enemy_select
      return #ccoa
    elsif @actor_arrow != nil
      update_phase3_actor_select
      return #ccoa
    elsif @skill_window != nil
      update_phase3_skill_select
      return #ccoa
    elsif @combo_window != nil
      update_phase3_combo_select
      return #ccoa
    elsif @item_window != nil
      update_phase3_item_select
      return #ccoa
    end #ccoa
    
    #ccoa
    #elsif @actor_command_window.active
    #  update_phase3_basic_command
    #end
    # If actor command window is enabled
    for i in 0..$game_party.actors.size - 1
      if @actor_command_windows[i].active
          update_phase3_basic_command
        return
      end
    end
    #fine ccoa
  end
  
  alias update_phase3_skill_select_combo update_phase3_skill_select
  def update_phase3_skill_select
    update_phase3_skill_select_combo
    if Input.trigger?(Impostazioni::CTCombo::TASTO_CAMBIO_SKILL_E_COMBO)
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        end_skill_select
        start_combo_select
      return
    end
  end

  def update_phase3_combo_select
    @combo_window.visible = true
    @combo_window.update
    for i in 0...$combo_skill.size
      if $combo_skill[i] == @combo_window.skill.id
        n = i
      end
    end
    for b in 0...$game_party.actors.size
      $game_party.actors[b].blink = false
    end
    if n != nil
      for h in 0...$combo_hero[n].size
        if $game_actors[$combo_hero[n][h]] != nil
        if $game_party.actors.include?($game_actors[$combo_hero[n][h]])
          $game_actors[$combo_hero[n][h]].blink = true
          end
        end
      end
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      end_combo_select
      return
    end
    if Input.trigger?(Input::C)
      @skill = @combo_window.skill
      #VALENTINO
    formation = SKILL_COMBO[@skill.id]
    if formation != nil
      unless $battle_formation == formation
        $game_system.se_play($data_system.buzzer_se)
        return
      end
    end
      #VALENTINO
      
      if n == nil
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      v = 0
      for h in 0...$combo_hero[n].size
        if $game_actors[$combo_hero[n][h]] != nil
        if $game_actors[$combo_hero[n][h]].combo_can_use?(@skill.id)
          v += 1
        end
        end
      end
      if @skill == nil or not v == $combo_hero[n].size
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @active_battler.current_action.skill_id = @skill.id
      @combo_window.visible = false
      if @skill.scope == 1
        start_enemy_select
      elsif @skill.scope == 3 or @skill.scope == 5
        start_actor_select
      else
        end_combo_select
        phase3_next_actor
      end
      return
    end
    if Input.trigger?(Impostazioni::CTCombo::TASTO_CAMBIO_SKILL_E_COMBO)
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        end_combo_select
        start_skill_select
      return
    end    
  end

  def update_phase3_enemy_select
    @enemy_arrow.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      end_enemy_select
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @active_battler.current_action.target_index = @enemy_arrow.index
      end_enemy_select
      if @skill_window != nil
        end_skill_select
      end
      if @combo_window != nil
        end_combo_select
      end
      if @item_window != nil
        end_item_select
      end
      phase3_next_actor
    end
  end

  def update_phase3_actor_select
    @actor_arrow.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      end_actor_select
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @active_battler.current_action.target_index = @actor_arrow.index
      end_actor_select
      if @skill_window != nil
        end_skill_select
      end
      if @combo_window != nil
        end_combo_select
      end
      if @item_window != nil
        end_item_select
      end
      phase3_next_actor
    end
  end

  def start_combo_select
    @combo_window = Window_Combo.new(@active_battler)
    @combo_window.help_window = @help_window
    #ccoa
    for i in 0..$game_party.actors.size - 1
      @actor_command_windows[i].active = false
      @actor_command_windows[i].visible = false
    end
    #@actor_command_window.active = false
    #@actor_command_window.visible = false
    #fine ccoa
  end
  
  def end_combo_select
    for b in 0...$game_party.actors.size
      $game_party.actors[b].blink = false
    end
    @active_battler.blink = true
    @combo_window.dispose
    @combo_window = nil
    @help_window.visible = false
    #ccoa
    @actor_command_windows[@actor_index].active = true
    @actor_command_windows[@actor_index].visible = true
    #@actor_command_window.active = true
    #@actor_command_window.visible = true
    #fine ccoa
  end

  def make_skill_action_result
    @animate = nil
    @skill = $data_skills[@active_battler.current_action.skill_id]
    for i in 0...$combo_skill.size
      if $combo_skill[i] == @skill.id
        n = i
      end
    end
    if not $combo_skill.include?(@skill.id)
      #ccoa
      if @active_battler.is_a?(Game_Actor)
        if $USING_INDIV_SKILL_ANIM
          @active_battler.set_pose(@active_battler.skill_hash[$data_skills[@active_battler.current_action.skill_id].name], false)
        else # get animation by skill type
          @active_battler.set_pose(@active_battler.skill_type_hash[@active_battler.skill_kind], false)
        end
      else
        @active_battler.set_pose($SKILL, false)
      end
      #fine ccoa
      unless @active_battler.current_action.forcing
        unless @active_battler.skill_can_use?(@skill.id)
          $game_temp.forcing_battler = nil
          @phase4_step = 1
          return
        end
      end
      @active_battler.sp -= @skill.sp_cost
      @status_window.refresh
      #ccoa
      @help_window2.contents_opacity = 0
      @help_window2.y = -200
      $name_help = CCOA_CBS::NAME_SKILL
      @help_window2.set_text(@skill.name, 1)
      #@help_window.set_text(@skill.name, 1)
      #fine ccoa
      @animation1_id = @skill.animation1_id
      @animation2_id = @skill.animation2_id
      @common_event_id = @skill.common_event_id
      set_target_battlers(@skill.scope)
      for target in @target_battlers
        target.skill_effect(@active_battler, @skill)
        #ccoa
        unless target == @active_battler
          reset_pose(target)
        end
        #fine ccoa
      end
    else
      #ccoa
      if n != nil
        for h in 0...$combo_hero[n].size
          if $game_actors[$combo_hero[n][h]] != nil
          if $game_actors[$combo_hero[n][h]].is_a?(Game_Actor)
            if $USING_INDIV_SKILL_ANIM
              $game_actors[$combo_hero[n][h]].set_pose($game_actors[$combo_hero[n][h]].skill_hash[$data_skills[@active_battler.current_action.skill_id].name], false)
            else # get animation by skill type
              $game_actors[$combo_hero[n][h]].set_pose($game_actors[$combo_hero[n][h]].skill_type_hash[$game_actors[$combo_hero[n][h]].skill_kind], false)
            end
            end
          else
            $game_actors[$combo_hero[n][h]].set_pose($SKILL, false) if $game_actors[$combo_hero[n][h]] != nil
          end
        end
      else
        if @active_battler.is_a?(Game_Actor)
          if $USING_INDIV_SKILL_ANIM
            @active_battler.set_pose(@active_battler.skill_hash[$data_skills[@active_battler.current_action.skill_id].name], false)
          else # get animation by skill type
            @active_battler.set_pose(@active_battler.skill_type_hash[@active_battler.skill_kind], false)
          end
        else
          @active_battler.set_pose($SKILL, false)
        end
      end
      #fine ccoa
      unless @active_battler.current_action.forcing
        if n != nil
          v = 0
          for h in 0...$combo_hero[n].size
            if $game_actors[$combo_hero[n][h]] != nil
            if $game_actors[$combo_hero[n][h]].combo_can_use?(@skill.id)
              v +=1
            end
            end
          end
        end
        unless v == $combo_hero[n].size
          $game_temp.forcing_battler = nil
          @phase4_step = 1
          return
        end
      end
      if n != nil
        for h in 0...$combo_hero[n].size
          if $game_actors[$combo_hero[n][h]] != nil
          $game_actors[$combo_hero[n][h]].sp -= $combo_point[n][h]
          @animate = $combo_hero[n]
        end
        end
      end
      @status_window.refresh
      #ccoa
      @help_window2.contents_opacity = 0
      @help_window2.y = -200
      $name_help = CCOA_CBS::NAME_SKILL
      @help_window2.set_text(@skill.name, 1)
      #@help_window.set_text(@skill.name, 1)
      #fine ccoa
      @animation1_id = @skill.animation1_id
      @animation2_id = @skill.animation2_id
      @common_event_id = @skill.common_event_id
      set_target_battlers(@skill.scope)
      for target in @target_battlers
        target.skill_effect(@active_battler, @skill)
        #ccoa
        if n != nil
          for h in 0...$combo_hero[n].size
            if $game_actors[$combo_hero[n][h]] != nil
            unless target == $game_actors[$combo_hero[n][h]]
              reset_pose(target)
            end
            end
          end
        else
          unless target == @active_battler
            reset_pose(target)
          end
        end
        #fine ccoa
      end
    end
  end

  def update_phase4_step3
    if @animate == nil
      if @animation1_id == 0
        @active_battler.white_flash = true
        #ccoa
        if @active_battler.animated
          @wait_count = [@active_battler.attack_frames * 10 - 10, 8].max
        else
          @wait_count = 8
        end
        #fine ccoa
      else
        @active_battler.animation_id = @animation1_id
        @active_battler.animation_hit = true
      end
      #ccoa
      if @active_battler.current_action.kind == 0 and @active_battler.current_action.basic == 0
        @active_battler.set_pose($ATTACK, false)
      end
      #fine ccoa
      @phase4_step = 4
    else
      if @animation1_id == 0
        for b in 0...@animate.size
          $game_actors[@animate[b]].white_flash = true
          #ccoa
          if $game_actors[@animate[b]].animated
            @wait_count = [$game_actors[@animate[b]].attack_frames * 10 - 10, 8].max
          else
            @wait_count = 8
          end
          #fine ccoa
        end
      else
        for b in 0...@animate.size
          $game_actors[@animate[b]].animation_id = @animation1_id
          $game_actors[@animate[b]].animation_hit = true
        end
      end
      #ccoa
      for b in 0...@animate.size
        if $game_actors[@animate[b]].current_action.kind == 0 and $game_actors[@animate[b]].current_action.basic == 0
          $game_actors[@animate[b]].set_pose($ATTACK, false)
        end
      end
      #fine ccoa
      @animate = nil
      @phase4_step = 4
    end
  end
end

class Window_Skill < Window_Selectable
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      #ccoa
      if (@skill_kind == -1)
        if skill != nil and not $combo_skill.include?(skill.id)
          @data.push(skill)
        end
      else
        if (skill != nil and skill.element_set.include?(@skill_kind)) and not $combo_skill.include?(skill.id)
          @data.push(skill)
        end
      end
      #if skill != nil and not $combo_skill.include?(skill.id)
      #  @data.push(skill)
      #end
      #fine ccoa
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
end

#ccoa
class Win_Skill < Window_Selectable
    def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end

    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if (@skill_kind == -1)
        if skill != nil and not $combo_skill.include?(skill.id)
          @data.push(skill)
        end
      else
        if (skill != nil and skill.element_set.include?(@skill_kind)) and not $combo_skill.include?(skill.id)
          @data.push(skill)
        end
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
end
#fine ccoa

The script works well for the most part but it seems to mess-up the standard magic menu - its difficult to explain but here goes - when in a battle and using "Magic" when you hover over the different magic spells and move the cursor the magic points used are wrong! Plus even on the last spell if you move the cursor the values keep changing. This is because the combo attacks were originally listed in the magic menu - the script removes them but it seems the magic point values of the combo attacks remains...


Here is a video that will hopefully describe the problem:


http://www.mediafire.com/?0kmj4t9l43gi549


I have no idea in the script where this behavoiur is or how to fix it... if someone could help or give some pointers that would be great. thanks



RE: Combo Attacks Script Help - JackMonty - 04-19-2013

I've translated the above script into English and believe the issue is related to the @data.push(skill) where the skill is suppressed from the regular magic menu but the skill points value remains... I can't seem to remove these no matter what I try...

Does anyone know if there is a variable relating to the actual value of the points attached to a skill so I could try to manipulate that.

Thanks



RE: Combo Attacks Script Help - MechanicalPen - 04-19-2013

It looks like there is a Win_Skill AND a Window_Skill. What is the deal with that?

Hmm... the behavior you described makes it sound like all of the 'sp_cost's are being drawn next to the last skill. Did you check your draw_item() method?

Edit; I'll bet it is an incompatibility between this script and whatever script you are using to draw that fancy skill window.


RE: Combo Attacks Script Help - JackMonty - 04-22-2013

Hello,

The Win_Skill class is meant to add compatibility with COCA's battle scripts.

Window_Skill contains the following edited out:

#if skill != nil and not $combo_skill.include?(skill.id)
# @data.push(skill)
#end
#fine ccoa

I assumed this would leave behind the skills that are not combos and allow them to be selected in the standard magic menu - I'm not sure why these are edited out - I am quite unfamiliar with certain elements of this script...

In terms of the draw_item method from what I could see it was purely based on drawing items on the combo window and not the standard skills window...

Code:
def draw_item(index)
    skill = @data[index]
    for i in 0...$combo_skill.size
      if $combo_skill[i] != nil
      if $combo_skill[i] == skill.id
        n = i
      end

- if this is wrong I could add a line to try and subtract the SP values... The script is correctly removing SP Skills which are combos but I have no idea which part is doing that... are you able to identify this and if so would it be simply a matter of adding a line to remove the SP values too?

Any more tips would be appreciated - as always thanks for your help.


RE: Combo Attacks Script Help - MechanicalPen - 04-22-2013

Please paste in the entirety of that "draw_item" method. It seems to be doing odd things, and that might be your problem.


RE: Combo Attacks Script Help - JackMonty - 04-23-2013

Hi,

Here is the full code for draw_item

Code:
#--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    for i in 0...$combo_skill.size
      if $combo_skill[i] != nil
      if $combo_skill[i] == skill.id
        n = i
      end
      end
    end
    v = 0
    for h in 0...$combo_hero[n].size
      if $game_actors[$combo_hero[n][h]] != nil
      if $game_actors[$combo_hero[n][h]].combo_can_use?(skill.id)
        v += 1
      end
    end
    end
    
    #VALENTINO
    formation = SKILL_COMBO[skill.id]
    @colore = false
    if formation != nil
      if $battle_formation == formation
        self.contents.font.color = normal_color
      else
        @colore = true
        self.contents.font.color = disabled_color
      end
    end
    #VALENTINO
    
    if v == $combo_hero[n].size
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    
   self.contents.font.color = disabled_color if @colore
    
    
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 64)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    if not $game_temp.in_battle
      self.contents.draw_text(x + 232, y, 48, 32, $combo_point[n][0].to_s, 2)
      self.contents.draw_text(x + 288, y, 48, 32, $combo_point[n][1].to_s, 2) rescue nil
      self.contents.draw_text(x + 344, y, 48, 32, $combo_point[n][2].to_s, 2) rescue nil
      self.contents.draw_text(x + 400, y, 48, 32, $combo_point[n][3].to_s, 2) rescue nil
    else
      po = []
      for i in 0...$game_party.actors.size
        if $combo_hero[n].include?($game_party.actors[i].id)
          po.push $game_party.actors[i].id
        end
      end
      ex = po.size
      for r in 0...$combo_hero[n].size
        if $combo_hero[n][r] != nil
        if not po.include?($combo_hero[n][r])
          po.push $combo_hero[n][r]
        end
        end
      end
      for ach in 0...po.size
        if ach == ex
          self.contents.font.color = self.contents.font.color == normal_color ? knockout_color : Color.new(255, 64, 0, 128)
        end
        for h in 0...$combo_hero[n].size
          if $combo_point[n][h] != nil
          if $combo_hero[n][h] == po[ach]
            punti = $combo_point[n][h]
          end
          end
        end
        self.contents.draw_text(x + 232 + (ach * 56), y, 48, 32, punti.to_s, 2)
      end
    end
  end

I thought this just drew the combo selection box - although I'm not very familiar with a lot of the code here so it may do much more than that...

Thanks for your help.


RE: Combo Attacks Script Help - MechanicalPen - 04-24-2013

I have no idea what that draw_item is doing, and I read the code! Once finals are over, I'll want to take a look at the full demo so I can trace the code better.


RE: Combo Attacks Script Help - JackMonty - 05-01-2013

Thanks MechanicalPen
I've uploaded the game and have sent you a link via PM!


RE: Combo Attacks Script Help - MechanicalPen - 05-03-2013

\o/ Flipping fixed it! Wouldn't you know it, the problems with the Skill Points being incorrect were found in the "Window_Skill SP Cost" script. XD

Seriously though, I would like to walk you through the steps I used to fix this bug in hopes of teaching you to be a better bug fixer. First, I fiddled with the arrow keys while trying to select a magic skill. The SP Cost changed whenever I pushed the arrow keys, but only up to a certain point. Furthermore I could push the arrow keys the same number of times in the opposite direction to get it back to the normal behavior. Knowing a thing or two about how windows work, I guessed that even though all the skills were drawn correctly, the data list might have had extra entries.

From the scripts you posted, I can tell you thought the very same thing! Nothing I could do to that part of the script could fix it, however. The second thing I noticed was the the window that displayed the SP Cost was separate from the one the displayed the skill names. I did a ctrl+shift+F (find in all) for "EP Cost" to figure out where that window was.

The script that it found was 'Window_Skill Status' which doesn't contain... well, much of anything! However, the script listed right above that one was "Window_Skill SP Cost" and that sounds like something that displays SP costs. Since those were what we were having trouble with, I took a look inside.

And guess what I found? Something about 'draw_item's and 'data.push's that looked like the ones in Win_Skill. The very same thing you thought could be the problem in the second post! So kudos to you for figuring that bit out.

But the 'data.push's in the 'Window_Skill SP Cost' script were a little different than the ones in the 'Combo Attacks Script.' If you would like to try and fix it yourself, that is where you should look. Otherwise, look in this spoiler for the solution.
"The bugfix"

Edit: Unfortunately, there is similar bug when selecting a target...


RE: Combo Attacks Script Help - JackMonty - 05-04-2013

Thanks so much MechanicalPen!

I guess I got too focused on just looking at the Combo Skills script that I didn't think to look beyond it at other possible elements.

This has been a great help and I will most certainly give you thanks in the credits!

Out of curiosity you mention
Quote:

Edit: Unfortunately, there is similar bug when selecting a target...
Do you mean when selecting an enemy to attack? And do you mean attacking them with a physical, magic or combo attack? I don't recall seeing any problems with this so I was just curious by want you meant.