Partagez
Aller en bas
UltimaSasuke
UltimaSasuke
Membre

Nombre de messages : 88
Age : 24
Localisation : France, 05
Distinction : aucune
Date d'inscription : 27/07/2011

Script Variable et Victoire[Résolue] Empty Script Variable et Victoire[Résolue]

le Mer 18 Jan 2012 - 21:58
Bon je m'explique, je connais que dalle en script, et adorant les scripts. J'aimerais un script qui à chaque fin de combat comptabilise les victoires et l’insère dans une variable. Je suppose que c'est simple mais bon X)
Si vous me demandez pourquoi c'est pour le script Save de Yanfly.
Je précise script pour RPG VX-A. Merci d'avance =P


Dernière édition par UltimaSasuke le Jeu 19 Jan 2012 - 18:48, édité 1 fois
Gummy
Gummy
Staffeux retraité

Nombre de messages : 2666
Age : 28
Localisation : Belgique
Distinction : Modérateur imprévisible

Papy Lolo' [Nabots Nimousse]


Date d'inscription : 27/01/2008

Script Variable et Victoire[Résolue] Empty Re: Script Variable et Victoire[Résolue]

le Mer 18 Jan 2012 - 22:05
Pour le système de combat de base?
UltimaSasuke
UltimaSasuke
Membre

Nombre de messages : 88
Age : 24
Localisation : France, 05
Distinction : aucune
Date d'inscription : 27/07/2011

Script Variable et Victoire[Résolue] Empty Re: Script Variable et Victoire[Résolue]

le Mer 18 Jan 2012 - 22:13
Ah oui, et bien non l'ATB de Yami. Le voici :
Code:
#==============================================================================
#
# ▼ YSA Battle System: Classical ATB
# -- Last Updated: 2012.01.16
# -- Level: Easy, Normal
# -- Requires: YEA - Ace Battle Engine v1.15+.
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YSA-CATB"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.16 - Fix ATB speed changes when a battler's agi changes.
#            - Add casting time.
# 2012.01.16 - Add a function for preemptive strike and surprised.
#            - Fix a small bug with make action.
# 2012.01.13 - Bugfix for ATB Type Wait.
#            - Upgrade a little ATB gauge.
#            - Upgrade turn count.
#            - Compatible with: Lunatic CATB Start.
# 2012.01.12 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script will add a battle type into YEA Battle Engine Ace.
# Battle Type: Classical ATB.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# First, set the default battle system for your game to be :catb by either going
# to the Ace Battle Engine script and setting DEFAULT_BATTLE_SYSTEM as :catb or
# by using the following script call:
#
# $game_system:set_battle_system(:catb)
#
# Second, you can set the default wait for your game by either setting DEFAULT_WAIT
# or using the following script call:
#
# $game_system:set_catb_wait_type(wait_type)
#
# Which there are 4 types:
#  - :full    : ATB always run, except when animation run
#  - :quarter  : ATB pause when select skill/item/target
#  - :semi    : ATB pause when select target
#  - :wait    : ATB pause when choose action for actor
#
# Third, you can set the default turn counting for your game by either setting
# DEFAULT_TURN or using the following script call:
#
# $game_system:set_catb_turn_type(turn_type)
#
# Which there are 2 types:
#  - :tick    : Count as a turn after X frame
#  - :action  : Count as a turn after X actions
#
# -----------------------------------------------------------------------------
# Skill/Item Notetags - These notetags go in the skill/item notebox in the database.
# -----------------------------------------------------------------------------
# <charge rate: x%>
# Enable casting time (skill charge) for Skill or Item. Skill/Item will be charged
# at normal ATB filled speed * x%, which means it will be charged at x% rate.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script requires Yanfly Engine Ace - Ace Battle Engine v1.15+ and the
# script must be placed under Ace Battle Engine in the script listing.
#
#==============================================================================

#==============================================================================
# ▼ Configuration
#==============================================================================

module YSA
  module CATB
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - General Configuration -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_FILL_TIME = 120 # Frames
    DEFAULT_WAIT      = :full # :full, :semi, :quarter, :wait
    FILL_TIME_VARIABLE  = 15 # Change DEFAULT_FILL_TIME by variable.
   
    PAUSE_WHEN_ACTIVE_PARTY_COMMAND = true
   
    PREEMTIVE_ATB_ACTOR = 70
    PREEMTIVE_ATB_ENEMY = 0
    SURPRISE_ATB_ACTOR = 0
    SURPRISE_ATB_ENEMY = 70
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Turn Configuration -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_TURN          = :tick # :tick, :action
   
    TICK_COUNT            = 150    # Turn after TICK_COUNT
    TICK_COUNT_VARIABLE  = 16    # Change TICK_COUNT by variable.
   
    AFTER_ACTION          = 1      # Turn after AFTER_ACTION actions.
    AFTER_ACTION_VARIABLE  = 17    # Change AFTER_ACTION by variable.
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Actor ATB Gauges -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    GAUGE_COLOR1 = 32
    GAUGE_COLOR2 = 31
    CHARGE_COLOR1 = 18
    CHARGE_COLOR2 = 10
    ATB_GAUGE_Y_PLUS = 12
    ATB_PHRASE = "ATB"
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Enemy ATB Gauges -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    SHOW_ENEMY_ATB_GAUGE    = true  # Display Enemy HP Gauge?
    ENEMY_GAUGE_WIDTH      = 128    # How wide the enemy gauges are.
    ENEMY_GAUGE_HEIGHT    = 12    # How tall the enemy gauges are.
    ENEMY_ATB_GAUGE_COLOUR1 = 1    # Colour 1 for ATB.
    ENEMY_ATB_GAUGE_COLOUR2 = 4    # Colour 2 for ATB.
    ENEMY_BACKGAUGE_COLOUR = 19    # Gauge Back colour.
   
  end
end

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YSA
  module REGEXP
  module USABLEITEM
   
    CHARGE_RATE = /<(?:CHARGE_RATE|charge rate):[ ](\d+)?([%%])>/i
   
  end # USABLEITEM
  end # REGEXP
end # YSA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
 
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_catb load_database; end
  def self.load_database
    load_database_catb
    load_notetags_catb
  end
 
  #--------------------------------------------------------------------------
  # new method: load_notetags_catb
  #--------------------------------------------------------------------------
  def self.load_notetags_catb
    groups = [$data_skills, $data_items]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_catb
      end
    end
  end
 
end # DataManager

#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem

  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :charge_rate
  attr_accessor :charge_on
 
  #--------------------------------------------------------------------------
  # common cache: load_notetags_catb
  #--------------------------------------------------------------------------
  def load_notetags_catb
    @charge_rate = 100
    @charge_on = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YSA::REGEXP::USABLEITEM::CHARGE_RATE
        @charge_on = true
        @charge_rate = $1.to_i
      #---
      end
    } # self.note.split
    #---
    @charge_rate = 100 if @charge_rate <= 0
  end
 
end # RPG::UsableItem

#==============================================================================
# ■ BattleManager
#==============================================================================

module BattleManager
 
  #--------------------------------------------------------------------------
  # alias method:
  #    - make_action_orders
  #    - prior_command
  #    - next_command
  #    - in_turn?
  #    - battle_start
  #--------------------------------------------------------------------------
  class <<self
    alias catb_make_action_orders make_action_orders
    alias catb_prior_command prior_command
    alias catb_next_command next_command
    alias catb_in_turn? in_turn?
    alias catb_battle_start battle_start
  end
 
  #--------------------------------------------------------------------------
  # battle_start
  #--------------------------------------------------------------------------
  def self.battle_start
    catb_battle_start
    if btype?(:catb)
      @average_agi = 0
      make_catb_action_orders
      battler_hash = $game_party.members + $game_troop.members
      battler_hash.each { |a|
        if @preemptive
          a.make_first_catb_value(1)
        elsif @surprise
          a.make_first_catb_value(2)
        else
          a.make_first_catb_value(0)
        end
        @average_agi += a.agi
      }
      @average_agi /= battler_hash.size
    end
  end
 
  #--------------------------------------------------------------------------
  # make_action_orders
  #--------------------------------------------------------------------------
  def self.make_action_orders
    catb_make_action_orders
    make_catb_action_orders if btype?(:catb)
  end
 
  #--------------------------------------------------------------------------
  # next_command
  #--------------------------------------------------------------------------
  def self.next_command
    return false if btype?(:catb)
    catb_next_command
  end
 
  #--------------------------------------------------------------------------
  # alias method: in_turn?
  #--------------------------------------------------------------------------
  def self.in_turn?
    return true if btype?(:catb)
    return catb_in_turn?
  end
 
  #--------------------------------------------------------------------------
  # new method: make_catb_action_orders
  #--------------------------------------------------------------------------
  class <<self
  def make_catb_action_orders
    @action_actors = [] if !@action_actors
    @action_enemies = [] if !@action_enemies
    @action_battlers = [] if !@action_battlers
  end
  end
 
  #--------------------------------------------------------------------------
  # new method: average_agi
  #--------------------------------------------------------------------------
  class <<self
  def average_agi
    return @average_agi
  end
  end
 
  #--------------------------------------------------------------------------
  # new method: set_actor
  #--------------------------------------------------------------------------
  class <<self
  def set_actor(actor_index)
    @actor_index = actor_index
  end
  end
 
  #--------------------------------------------------------------------------
  # prior_command
  #--------------------------------------------------------------------------
  def self.prior_command
    return false if btype?(:catb)
    catb_prior_command
  end
 
  #--------------------------------------------------------------------------
  # new method: make_catb_action
  #--------------------------------------------------------------------------
  class <<self
  def make_catb_action(battler)
    make_catb_action_orders
    return false if @action_battlers.include?(battler)
    @action_battlers.push(battler)
    @action_actors.push(battler) if battler.actor?
    @action_enemies.push(battler) if battler.enemy?
    return true
  end
  end
 
  #--------------------------------------------------------------------------
  # new method: delete_catb_action
  #--------------------------------------------------------------------------
  class <<self
  def delete_catb_action(battler)
    return false if !battler
    @action_battlers.delete(battler)
    @action_battlers = @action_battlers.compact
    @action_actors.delete(battler) if battler.actor?
    @action_actors = @action_actors.compact
    @action_enemies.delete(battler) if battler.enemy?
    @action_enemies = @action_enemies.compact
    return true
  end
  end
 
  #--------------------------------------------------------------------------
  # new method: action_list
  #--------------------------------------------------------------------------
  class <<self
  def action_list(type = :all)
    return @action_battlers if type == :all
    return @action_actors if type == :actor
    return @action_enemies if type = :enemy
  end
  end
 
end # BattleManager

#==============================================================================
# ■ Game_System
#==============================================================================

class Game_System
 
  #--------------------------------------------------------------------------
  # alias method: set_battle_system
  #--------------------------------------------------------------------------
  alias qatb_set_battle_system set_battle_system
  def set_battle_system(type)
    case type
    when :catb; @battle_system = :catb
    else;      qatb_set_battle_system(type)
    end
  end
 
  #--------------------------------------------------------------------------
  # alias method: battle_system_corrected
  #--------------------------------------------------------------------------
  alias qatb_battle_system_corrected battle_system_corrected
  def battle_system_corrected(type)
    case type
    when :catb; return :catb
    else;      return qatb_battle_system_corrected(type)
    end
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_fill_time
  #--------------------------------------------------------------------------
  def catb_fill_time
    return $game_variables[YSA::CATB::FILL_TIME_VARIABLE] > 0 ? $game_variables[YSA::CATB::FILL_TIME_VARIABLE] : YSA::CATB::DEFAULT_FILL_TIME
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_tick_count
  #--------------------------------------------------------------------------
  def catb_tick_count
    return $game_variables[YSA::CATB::TICK_COUNT_VARIABLE] > 0 ? $game_variables[YSA::CATB::TICK_COUNT_VARIABLE] : YSA::CATB::TICK_COUNT
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_after_action
  #--------------------------------------------------------------------------
  def catb_after_action
    return $game_variables[YSA::CATB::AFTER_ACTION_VARIABLE] > 0 ? $game_variables[YSA::CATB::AFTER_ACTION_VARIABLE] : YSA::CATB::AFTER_ACTION
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_turn_type
  #--------------------------------------------------------------------------
  def catb_turn_type
    return @catb_turn_type ? @catb_turn_type : YSA::CATB::DEFAULT_TURN
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_wait_type
  #--------------------------------------------------------------------------
  def catb_wait_type
    return @catb_wait_type ? @catb_wait_type : YSA::CATB::DEFAULT_WAIT
  end
 
  #--------------------------------------------------------------------------
  # new method: set_catb_wait_type
  #--------------------------------------------------------------------------
  def set_catb_wait_type(type = :full)
    @catb_wait_type = type
  end
 
  #--------------------------------------------------------------------------
  # new method: set_catb_turn_type
  #--------------------------------------------------------------------------
  def set_catb_turn_type(type = :tick)
    @catb_turn_type = type
  end
 
end # Game_System

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
 
  MAX_CATB_VALUE = 100000.0
 
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias catb_initialize initialize
  def initialize
    catb_initialize
    @catb_value = 0
    @ct_catb_value = 0
  end
 
  #--------------------------------------------------------------------------
  # new method: base_gain_catb
  #--------------------------------------------------------------------------
  def base_gain_catb
    return MAX_CATB_VALUE / $game_system.catb_fill_time
  end
 
  #--------------------------------------------------------------------------
  # new method: real_gain_catb
  #--------------------------------------------------------------------------
  def real_gain_catb
    value = (self.agi.to_f / BattleManager.average_agi) * base_gain_catb
    return value
  end
 
  #--------------------------------------------------------------------------
  # new method: make_catb_update
  #--------------------------------------------------------------------------
  def make_catb_update
    return if @catb_value >= MAX_CATB_VALUE
    return if not inputable?
    @catb_value += [real_gain_catb, MAX_CATB_VALUE - @catb_value].min
  end
 
  #--------------------------------------------------------------------------
  # new method: make_catb_action
  #--------------------------------------------------------------------------
  def make_catb_action
    return unless @catb_value >= MAX_CATB_VALUE
    return clear_catb if not inputable?
    return BattleManager.make_catb_action(self)
  end
 
  #--------------------------------------------------------------------------
  # new method: make_ct_catb_update
  #--------------------------------------------------------------------------
  def make_ct_catb_update
    return if @catb_value < MAX_CATB_VALUE
    return if @ct_catb_value >= MAX_CATB_VALUE
    return if !self.current_action
    return if !self.current_action.item
    return if self.actor? && !self.current_action.confirm
    clear_catb if not inputable?
    @ct_catb_value = MAX_CATB_VALUE if !self.current_action.item.charge_on
    @ct_catb_value += [real_gain_catb * self.current_action.item.charge_rate / 100, MAX_CATB_VALUE - @ct_catb_value].min
  end
 
  #--------------------------------------------------------------------------
  # new method: charge_skill_done?
  #--------------------------------------------------------------------------
  def charge_skill_done?
    return @catb_value == MAX_CATB_VALUE && @ct_catb_value == MAX_CATB_VALUE
  end
 
  #--------------------------------------------------------------------------
  # new method: clear_catb
  #--------------------------------------------------------------------------
  def clear_catb
    make_actions
    @catb_value = 0
    @ct_catb_value = 0
    BattleManager.clear_actor if self.actor? && BattleManager.actor == self
    BattleManager.delete_catb_action(self)
  end
 
  #--------------------------------------------------------------------------
  # new method: make_first_catb_value
  #--------------------------------------------------------------------------
  def make_first_catb_value(pre = 0)
    make_actions
    @catb_value = 0
    @catb_value = YSA::CATB::PREEMTIVE_ATB_ACTOR if self.actor? && pre == 1
    @catb_value = YSA::CATB::PREEMTIVE_ATB_ENEMY if self.enemy? && pre == 1
    @catb_value = YSA::CATB::SURPRISE_ATB_ACTOR if self.actor? && pre == 2
    @catb_value = YSA::CATB::SURPRISE_ATB_ENEMY if self.enemy? && pre == 2
    lunatic_catb_start_formula(pre) if $imported["YSA-LunaticCATBStart"]
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_filled_rate
  #--------------------------------------------------------------------------
  def catb_filled_rate
    return @catb_value / MAX_CATB_VALUE
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_ct_filled_rate
  #--------------------------------------------------------------------------
  def catb_ct_filled_rate
    return @catb_value < MAX_CATB_VALUE ? 0 : @ct_catb_value / MAX_CATB_VALUE
  end
 
end # Game_Battler

#==============================================================================
# ■ Game_Action
#==============================================================================

class Game_Action
 
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :confirm
 
  #--------------------------------------------------------------------------
  # alias method: clear
  #--------------------------------------------------------------------------
  alias catb_clear clear
  def clear
    catb_clear
    @confirm = false
  end

end # Game_Action

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # catb_gauge_color
  #--------------------------------------------------------------------------
  def catb_color1;      text_color(YSA::CATB::GAUGE_COLOR1);      end;
  def catb_color2;      text_color(YSA::CATB::GAUGE_COLOR2);      end;
  def charge_color1;      text_color(YSA::CATB::CHARGE_COLOR1);      end;
  def charge_color2;      text_color(YSA::CATB::CHARGE_COLOR2);      end;
end # Window_Base

#==============================================================================
# ■ Window_BattleStatus
#==============================================================================

class Window_BattleStatus < Window_Selectable
 
  #--------------------------------------------------------------------------
  # alias method: draw_item
  #--------------------------------------------------------------------------
  alias catb_draw_item draw_item
  def draw_item(index)
    catb_draw_item(index)
    actor = battle_members[index]
    rect = item_rect(index)
    gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS + YSA::CATB::ATB_GAUGE_Y_PLUS
    return unless BattleManager.btype?(:catb)
    draw_actor_catb(actor, rect.x+2, line_height*1+gx, rect.width-4)
  end
 
  #--------------------------------------------------------------------------
  # new method: draw_actor_catb
  #--------------------------------------------------------------------------
  def draw_actor_catb(actor, dx, dy, width = 124)
    draw_gauge(dx, dy, width, actor.catb_filled_rate, catb_color1, catb_color2)
    if actor.catb_ct_filled_rate > 0
      draw_gauge(dx, dy, width, actor.catb_ct_filled_rate, charge_color1, charge_color2)
    end
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 30, line_height, YSA::CATB::ATB_PHRASE)
  end
 
  #--------------------------------------------------------------------------
  # new method: draw_item_actor_catb
  #--------------------------------------------------------------------------
  def draw_item_actor_catb(index)
    return if index.nil?
    actor = battle_members[index]
    rect = item_rect(index)
    return if actor.nil?
    gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS + YSA::CATB::ATB_GAUGE_Y_PLUS
    draw_actor_catb(actor, rect.x+2, line_height*1+gx, rect.width-4)
  end
 
  #--------------------------------------------------------------------------
  # new method: refresh_catb
  #--------------------------------------------------------------------------
  def refresh_catb
    return unless BattleManager.btype?(:catb)
    item_max.times {|i| draw_item_actor_catb(i) }
  end
 
end # Window_BattleStatus

#==============================================================================
# ■ Sprite_Battler
#==============================================================================

class Sprite_Battler < Sprite_Base
 
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias sprite_battler_initialize_catb initialize
  def initialize(viewport, battler = nil)
    sprite_battler_initialize_catb(viewport, battler)
    create_enemy_gauges_catb
  end
 
  #--------------------------------------------------------------------------
  # alias method: dispose
  #--------------------------------------------------------------------------
  alias sprite_battler_dispose_catb dispose
  def dispose
    sprite_battler_dispose_catb
    dispose_enemy_gauges_catb
  end
 
  #--------------------------------------------------------------------------
  # alias method: update
  #--------------------------------------------------------------------------
  alias sprite_battler_update_catb update
  def update
    sprite_battler_update_catb
    update_enemy_gauges_catb
  end

  #--------------------------------------------------------------------------
  # new method: create_enemy_gauges_catb
  #--------------------------------------------------------------------------
  def create_enemy_gauges_catb
    return if @battler.nil?
    return if @battler.actor?
    return unless BattleManager.btype?(:catb)
    @catb_back_gauge_viewport = Enemy_CATB_Gauge_Viewport.new(@battler, self, :back)
    @catb_gauge_viewport = Enemy_CATB_Gauge_Viewport.new(@battler, self, :catb)
    @catb_ct_gauge_viewport = Enemy_CATB_Gauge_Viewport.new(@battler, self, :catbct)
  end
 
  #--------------------------------------------------------------------------
  # new method: dispose_enemy_gauges_catb
  #--------------------------------------------------------------------------
  def dispose_enemy_gauges_catb
    return unless BattleManager.btype?(:catb)
    @catb_back_gauge_viewport.dispose unless @catb_back_gauge_viewport.nil?
    @catb_gauge_viewport.dispose unless @catb_gauge_viewport.nil?
    @catb_ct_gauge_viewport.dispose unless @catb_ct_gauge_viewport.nil?
  end
 
  #--------------------------------------------------------------------------
  # new method: update_enemy_gauges_catb
  #--------------------------------------------------------------------------
  def update_enemy_gauges_catb
    return unless BattleManager.btype?(:catb)
    @catb_back_gauge_viewport.update unless @catb_back_gauge_viewport.nil?
    @catb_gauge_viewport.update unless @catb_gauge_viewport.nil?
    @catb_ct_gauge_viewport.update unless @catb_ct_gauge_viewport.nil?
  end
 
end # Sprite_Battler

#==============================================================================
# ■ Enemy_CATB_Gauge_Viewport
#==============================================================================

class Enemy_CATB_Gauge_Viewport < Viewport
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(battler, sprite, type)
    @battler = battler
    @base_sprite = sprite
    @type = type
    dw = YSA::CATB::ENEMY_GAUGE_WIDTH
    dw += 2 if @type == :back
    @start_width = dw
    dh = YSA::CATB::ENEMY_GAUGE_HEIGHT
    dh += 2 if @type == :back
    rect = Rect.new(0, 0, dw, dh)
    super(rect)
    self.z = 125
    create_gauge_sprites
    self.visible = false
    update_position
  end
 
  #--------------------------------------------------------------------------
  # dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprite.bitmap.dispose unless @sprite.bitmap.nil?
    @sprite.dispose
    super
  end
 
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    self.visible = @battler.dead? ? false : YSA::CATB::SHOW_ENEMY_ATB_GAUGE
    update_position
    update_gauge
  end
 
  #--------------------------------------------------------------------------
  # create_gauge_sprites
  #--------------------------------------------------------------------------
  def create_gauge_sprites
    @sprite = Plane.new(self)
    dw = self.rect.width * 2
    @sprite.bitmap = Bitmap.new(dw, self.rect.height)
    case @type
    when :back
      colour1 = Colour.text_colour(YSA::CATB::ENEMY_BACKGAUGE_COLOUR)
      colour2 = Colour.text_colour(YSA::CATB::ENEMY_BACKGAUGE_COLOUR)
    when :catb
      colour1 = Colour.text_colour(YSA::CATB::ENEMY_ATB_GAUGE_COLOUR1)
      colour2 = Colour.text_colour(YSA::CATB::ENEMY_ATB_GAUGE_COLOUR2)
    when :catbct
      colour1 = Colour.text_colour(YSA::CATB::CHARGE_COLOR1)
      colour2 = Colour.text_colour(YSA::CATB::CHARGE_COLOR2)
    end
    dx = 0
    dy = 0
    dw = self.rect.width
    dh = self.rect.height
    self.rect.width = target_gauge_width unless @type == :back
    @gauge_width = target_gauge_width
    @sprite.bitmap.gradient_fill_rect(dx, dy, dw, dh, colour1, colour2)
    @sprite.bitmap.gradient_fill_rect(dw, dy, dw, dh, colour2, colour1)
  end

  #--------------------------------------------------------------------------
  # update_position
  #--------------------------------------------------------------------------
  def update_position
    dx = @battler.screen_x - @start_width / 2
    self.rect.x = dx
    dh = self.rect.height + 1
    dh += 2 unless @type == :back
    dy = [@battler.screen_y, Graphics.height - dh - 120].min
    dy += 1 unless @type == :back
    dy -= YEA::BATTLE::ENEMY_GAUGE_HEIGHT if $imported["YEA-EnemyHPBars"]
    self.rect.y = dy
  end
 
  #--------------------------------------------------------------------------
  # update_gauge
  #--------------------------------------------------------------------------
  def update_gauge
    return if @gauge_width == target_gauge_width
    @gauge_width = target_gauge_width if @type == :catb
    @gauge_width = target_gauge_width_ct if @type == :catbct
    return if @type == :back
    self.rect.width = @gauge_width
  end
 
  #--------------------------------------------------------------------------
  # target_gauge_width
  #--------------------------------------------------------------------------
  def target_gauge_width
    return @battler.catb_filled_rate * @start_width
  end
 
  #--------------------------------------------------------------------------
  # target_gauge_width_ct
  #--------------------------------------------------------------------------
  def target_gauge_width_ct
    return @battler.catb_ct_filled_rate * @start_width
  end
 
end # Enemy_CATB_Gauge_Viewport
 
#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # alias method: process_action
  #--------------------------------------------------------------------------
  alias catb_process_action process_action
  def process_action
    process_catb
    perform_catb_action(@subject, true) if BattleManager.action_forced?
    catb_process_action unless BattleManager.btype?(:catb)
  end
 
  #--------------------------------------------------------------------------
  # new method: catb_pause?
  #--------------------------------------------------------------------------
  def catb_pause?
    return YSA::CATB::PAUSE_WHEN_ACTIVE_PARTY_COMMAND if @party_command_window.active
    return false if $game_system.catb_wait_type == :full
    return true if $game_system.catb_wait_type == :wait && (@actor_command_window.active || @skill_window.active || @item_window.active || @actor_window.active || @enemy_window.active)
    return true if $game_system.catb_wait_type == :quarter && (@skill_window.active || @item_window.active || @actor_window.active || @enemy_window.active)
    return true if $game_system.catb_wait_type == :semi && (@actor_window.active || @enemy_window.active)
  end
 
  #--------------------------------------------------------------------------
  # new method: process_catb
  #--------------------------------------------------------------------------
  def process_catb
    return unless SceneManager.scene_is?(Scene_Battle)
    return if scene_changing?
    return unless BattleManager.btype?(:catb)
    return if catb_pause?
    battler_hash = $game_party.members + $game_troop.members
    battler_hash.each { |a|
      a.make_catb_update
      a.make_catb_action
      a.make_ct_catb_update
    }
    #--- Update Tick Turn
    if $game_system.catb_turn_type == :tick
      @tick_clock = 0 if !@tick_clock
      @tick_clock += 1
      if @tick_clock >= $game_system.catb_tick_count
        @tick_clock = 0
        all_battle_members.each { |battler|
          battler.on_turn_end
        }
        @status_window.refresh
        $game_troop.increase_turn
      end
    end
    #--- Fix make action
    BattleManager.action_list(:actor).each { |battler|
      battler.make_actions if (battler.actor? && !battler.input)
    }
    #---
    @status_window.refresh_catb
    #--- Setup Actor
    @f_actor_index = 0 if !@f_actor_index || @f_actor_index < 0 || @f_actor_index + 1 > BattleManager.action_list(:actor).size
    f_actor = BattleManager.action_list(:actor)[@f_actor_index]
    @f_actor_index += 1 if (@f_actor_index + 1) < BattleManager.action_list(:actor).size && f_actor && f_actor.input && f_actor.input.item && f_actor.input.confirm
    f_actor = BattleManager.action_list(:actor)[@f_actor_index]
    if f_actor && f_actor.input && !f_actor.input.item && (!BattleManager.actor || @status_window.index != BattleManager.actor.index)
      BattleManager.set_actor(f_actor.index)
      @status_window.select(BattleManager.actor.index)
      @actor_command_window.setup(BattleManager.actor)
    end
    BattleManager.action_list.each { |battler|
      battler.make_actions if battler.enemy?
      perform_catb_action(battler) if !@subject
    }
  end
 
  #--------------------------------------------------------------------------
  # new method: perform_catb_action
  #--------------------------------------------------------------------------
  def perform_catb_action(subject, forced = false)
    return if subject && !subject.charge_skill_done?
    return if subject && subject.actor? && !forced && !subject.input
    return if subject && subject.actor? && !forced && !subject.input.item
    return if subject && subject.actor? && !forced && !subject.input.confirm
    @subject = subject if subject
    return if !@subject
    if @subject.current_action
      @subject.current_action.prepare
      execute_action
      process_event
      if $game_system.catb_turn_type == :action
        @tick_action = 0 if !@tick_action
        @tick_action += 1
        if @tick_action >= $game_system.catb_after_action
          @tick_action = 0
          all_battle_members.each { |battler|
            battler.on_turn_end
          }
          @status_window.refresh
          $game_troop.increase_turn
        end
      end
    end
    return if BattleManager.judge_win_loss
    @subject.clear_catb
    @status_window.draw_item(@subject.index) if @subject.actor?
    @subject = nil
  end
 
  #--------------------------------------------------------------------------
  # alias method: create_actor_command_window
  #--------------------------------------------------------------------------
  alias catb_create_actor_command_window create_actor_command_window
  def create_actor_command_window
    catb_create_actor_command_window
    if BattleManager.btype?(:catb)
      @actor_command_window.set_handler(:dir4, method(:prior_f_actor))
      @actor_command_window.set_handler(:dir6, method(:next_f_actor))
    end
  end
 
  #--------------------------------------------------------------------------
  # new method: prior_f_actor
  #--------------------------------------------------------------------------
  def prior_f_actor
    if @f_actor_index && BattleManager.action_list(:actor).size > 0
      @f_actor_index -= 1
      @f_actor_index = 0 if @f_actor_index < 0
      f_actor = BattleManager.action_list(:actor)[@f_actor_index]
      if f_actor
        BattleManager.set_actor(f_actor.index)
        @status_window.select(BattleManager.actor.index)
        @actor_command_window.setup(BattleManager.actor)
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # new method: next_f_actor
  #--------------------------------------------------------------------------
  def next_f_actor
    if @f_actor_index && BattleManager.action_list(:actor).size > 0
      @f_actor_index += 1
      @f_actor_index = 0 if (@f_actor_index + 1) > BattleManager.action_list(:actor).size
      f_actor = BattleManager.action_list(:actor)[@f_actor_index]
      if f_actor
        BattleManager.set_actor(f_actor.index)
        @status_window.select(BattleManager.actor.index)
        @actor_command_window.setup(BattleManager.actor)
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # alias method: turn_start
  #--------------------------------------------------------------------------
  alias catb_turn_start turn_start
  def turn_start
    if BattleManager.btype?(:catb)
      @party_command_window.close
      @actor_command_window.close
      @status_window.unselect
      @log_window.wait
      @log_window.clear
    else
      catb_turn_start
    end
  end
 
  #--------------------------------------------------------------------------
  # alias method: command_guard
  #--------------------------------------------------------------------------
  alias catb_command_guard command_guard
  def command_guard
    BattleManager.actor.input.confirm = true
    catb_command_guard
  end
 
  #--------------------------------------------------------------------------
  # alias method: on_enemy_ok
  #--------------------------------------------------------------------------
  alias catb_on_enemy_ok on_enemy_ok
  def on_enemy_ok
    BattleManager.actor.input.confirm = true
    catb_on_enemy_ok
  end
 
  #--------------------------------------------------------------------------
  # alias method: on_actor_ok
  #--------------------------------------------------------------------------
  alias catb_on_actor_ok on_actor_ok
  def on_actor_ok
    BattleManager.actor.input.confirm = true
    catb_on_actor_ok
  end
 
  #--------------------------------------------------------------------------
  # alias method: update_info_viewport
  #--------------------------------------------------------------------------
  alias catb_update_info_viewport update_info_viewport
  def update_info_viewport
    catb_update_info_viewport
    if BattleManager.btype?(:catb)
      move_info_viewport(128) if @actor_command_window.active || @actor_window.active || @enemy_window.active
      move_info_viewport(0)  if @party_command_window.active
    end
  end
 
end # Scene_Battle

#==============================================================================
#
# ▼ End of File
#
#==============================================================================

Qui dois aller avec Ace Battle Engine. (Je ne peut pas l'afficher ici ou même dans un nouveaux post car trop long) Mais un lien
Ici (vous pouvez le télécharger avec Dowload)
dricc
dricc
Membre

Nombre de messages : 2757
Localisation : Lille
Distinction : Altruiste - Incarnation de la Patience [Mist']
Date d'inscription : 10/08/2009

Script Variable et Victoire[Résolue] Empty Re: Script Variable et Victoire[Résolue]

le Jeu 19 Jan 2012 - 10:39
Bon , ton systeme de combat ne modifie pas Battle manager ... donc :

Code:

module BattleManager
  def self.judge_win_loss
    if @phase
      $game_variables[56]+=1 if $game_troop.all_dead?
      return process_abort  if $game_party.members.empty?
      return process_defeat  if $game_party.all_dead?
      return process_victory if $game_troop.all_dead?
      return process_abort  if aborting?
    end
    return false
  end
end

remplace le 56 par ce que tu veux et ça te comptera tes victoires .
UltimaSasuke
UltimaSasuke
Membre

Nombre de messages : 88
Age : 24
Localisation : France, 05
Distinction : aucune
Date d'inscription : 27/07/2011

Script Variable et Victoire[Résolue] Empty Re: Script Variable et Victoire[Résolue]

le Jeu 19 Jan 2012 - 18:14
Très bien merci Dricc =) Je test et je met résolue!
Revenir en haut
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum