Heures au format UTC + 1 heure [ Heure d’été ]


Règles du forum


Consultez la liste des Scripts : cliquez ici



Publier un nouveau sujet Répondre au sujet  [ 2 messages ] 
Auteur Message
 Sujet du message: Affichages des altérations d'état via des icônes
MessagePublié: 24 Juil 2009, 21:15 
Ancien membre du staff
Ancien membre du staff
Avatar de l’utilisateur

Inscrit le: 20 Juil 2008, 00:00
Messages: 1726
Niveau RPG Maker: correct
Point(s) Fort(s): polyvalent
Sexe: Masculin
Points d'aide: 0/60

Créations :

- Création d'un sous menu

- Personnalisation des tailles d'icônes et de curseurs

- Affichages des altérations d'état via des icônes


Voir ses créations

Description :
Ce script remplace l'affichage classique des altérations d'état par un affichage d' icônes. Ces icônes sont personnalisables à souhait. Plusieurs extensions du script sont mises à disposition.

Caractéristiques :
Auteur : Albavor
Droits : libre d'utilisation, libre de modification, libre de diffusion
Dépendance : Database Management par Åvygeil

Le script :

Code: Tout sélectionner
#==============================================================================
# ■ State_Icon
#------------------------------------------------------------------------------
# Par Albavor
# Ce script remplace l'affichage des altérations d'état par l'utilisation
# d'icônes.
#------------------------------------------------------------------------------
# Version 1.1
# Seules les 5 premières altérations d'état sont affichées dans la fenêtre de
# statut en combat et en menu.
#------------------------------------------------------------------------------
# Dépendance : Database_Management par Åvygeil
#==============================================================================

Database.create_table("Etat") { |t|
  t.column :id, :integer
  t.column :icone, :string
}

#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
 
  def make_battler_state_text(battler, width, need_normal)
    affichage = []
    for i in battler.states
      if $data_states[i].rating >= 1
          ligne = Database::Etat.find { |ligne|
          ligne.id == i
          }
          text = ligne.icone
          affichage.push(text)
        end
    end
    return affichage
  end
 
  def draw_actor_state(actor, x, y, width = 120)
    affichage = make_battler_state_text(actor, width, true)
    for i in 0...affichage.size
      text = affichage[i]
      text_x = x + i * 24
      text_y = y
      image = RPG::Cache.icon(text)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(text_x, text_y, image, Rect.new(0, 0, 24, 24), opacity)
    end
  end
end


Explications :
La version de base ne permet l'affichage que de 5 altérations dans le menu et les combats. La priorité d'affichage est la même que celle des animations d'altération. Cette version est limitée dans le cas où plus de 5 altérations sont infligées, mais elle est toujours plus avancée que le système de base. Une extension viendra compléter ce défaut.

Avant toute chose, lisez l'utilisation du Database Management. Chaque champ devra être rempli ainsi :
id : numéro de l'altération
icone : nom de l'icône à afficher pour cette altération

Je rappelle que le template ne doit pas être modifié.

Voilà, c'est aussi simple que ça. Les icônes en question doivent se trouver dans le dossier icon. Leur taille doit être de 24*24px.

Quelques screens.
Image
Image
Image

L'extension :
Cette extension se place à la suite du script précédent. Elle génère une fenêtre spéciale qui affiche la totalité des altérations d'état en combat.

Code: Tout sélectionner
#==============================================================================
# ■ State_Icon
#------------------------------------------------------------------------------
# Par Albavor
# Ce script remplace l'affichage des altérations d'état par l'utilisation
# d'icônes.
#------------------------------------------------------------------------------
# Version 1.1 extension
# Seules les 5 premières altérations d'état sont affichées dans la fenêtre de
# statut en combat et en menu. En combat, une commande supplémentaire permet
# d'accéder à la liste complète des altérations.
#------------------------------------------------------------------------------
# Dépendance : State_Icon Version 1.1
#==============================================================================

#==============================================================================
# ■ Window_BattleState
#==============================================================================
# Fenêtre affichant la totalité des icônes des altérations d'état.
#==============================================================================
class Window_BattleState < Window_Base
 
  def initialize(x, y, width, height, actor)
    super(x, y, width, height)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
 
  def dispose
    super
  end
 
  def refresh
    self.contents.clear
    affichage = make_battler_state_text(@actor, width, true)
    for i in 0...affichage.size
      text = affichage[i]
      text_x = 4 + i % 5 * 24
      text_y = i / 5 *24
      image = RPG::Cache.icon(text)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(text_x, text_y, image, Rect.new(0, 0, 24, 24), opacity)
    end
  end
end

#==============================================================================
# ■ Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Selectable
 
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = 24
    self.back_opacity = 160
    @commands = ["Engager", "Fuir", "Etat"]
    @item_max = 3
    @column_max = 3
    draw_item(0, normal_color)
    draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
    draw_item(2, normal_color)
    self.active = false
    self.visible = false
    self.index = 0
  end

  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(128 + index * 128 + 4, 0, 128 - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end

  def update_cursor_rect
    self.cursor_rect.set(128 + index * 128, 0, 128, 32)
  end
end

#==============================================================================
# ■ Scene_Battle
#==============================================================================
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)
    # アクターコマンドウィンドウを作成
    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
    # その他のウィンドウを作成
    @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
    # スプライトセットを作成
    @spriteset = Spriteset_Battle.new
    # ウェイトカウントを初期化
    @wait_count = 0
    # トランジション実行
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # プレバトルフェーズ開始
    start_phase1
    # メインループ
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # マップをリフレッシュ
    $game_map.refresh
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @etat_window != nil
      @etat_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # スプライトセットを解放
    @spriteset.dispose
    # タイトル画面に切り替え中の場合
    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
    # バトルイベント実行中の場合
    if $game_system.battle_interpreter.running?
      # インタプリタを更新
      $game_system.battle_interpreter.update
      # アクションを強制されているバトラーが存在しない場合
      if $game_temp.forcing_battler == nil
        # バトルイベントの実行が終わった場合
        unless $game_system.battle_interpreter.running?
          # 戦闘継続の場合、バトルイベントのセットアップを再実行
          unless judge
            setup_battle_event
          end
        end
        # アフターバトルフェーズでなければ
        if @phase != 5
          # ステータスウィンドウをリフレッシュ
          @status_window.refresh
        end
      end
    end
    # システム (タイマー)、画面を更新
    $game_system.update
    $game_screen.update
    # タイマーが 0 になった場合
    if $game_system.timer_working and $game_system.timer == 0
      # バトル中断
      $game_temp.battle_abort = true
    end
    # ウィンドウを更新
    @help_window.update
    @party_command_window.update
    @actor_command_window.update
    @status_window.update
    @message_window.update
    # スプライトセットを更新
    @spriteset.update
    # トランジション処理中の場合
    if $game_temp.transition_processing
      # トランジション処理中フラグをクリア
      $game_temp.transition_processing = false
      # トランジション実行
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # メッセージウィンドウ表示中の場合
    if $game_temp.message_window_showing
      return
    end
    # エフェクト表示中の場合
    if @spriteset.effect?
      return
    end
    # ゲームオーバーの場合
    if $game_temp.gameover
      # ゲームオーバー画面に切り替え
      $scene = Scene_Gameover.new
      return
    end
    # タイトル画面に戻す場合
    if $game_temp.to_title
      # タイトル画面に切り替え
      $scene = Scene_Title.new
      return
    end
    # バトル中断の場合
    if $game_temp.battle_abort
      # バトル開始前の BGM に戻す
      $game_system.bgm_play($game_temp.map_bgm)
      # バトル終了
      battle_end(1)
      return
    end
    # ウェイト中の場合
    if @wait_count > 0
      # ウェイトカウントを減らす
      @wait_count -= 1
      return
    end
    # アクションを強制されているバトラーが存在せず、
    # かつバトルイベントが実行中の場合
    if $game_temp.forcing_battler == nil and
       $game_system.battle_interpreter.running?
      return
    end
    # フェーズによって分岐
    case @phase
    when 1  # プレバトルフェーズ
      update_phase1
    when 2  # パーティコマンドフェーズ
      update_phase2
    when 3  # アクターコマンドフェーズ
      update_phase3
    when 4  # メインフェーズ
      update_phase4
    when 5  # アフターバトルフェーズ
      update_phase5
    when 21 # consultation des altérations d'état
      update_phase21
    end
  end
 
  def update_phase2
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # パーティコマンドウィンドウのカーソル位置で分岐
      case @party_command_window.index
      when 0  # 戦う
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アクターコマンドフェーズ開始
        start_phase3
      when 1  # 逃げる
        # 逃走可能ではない場合
        if $game_temp.battle_can_escape == false
          # ブザー SE を演奏
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # 逃走処理
        update_phase2_escape
      when 2
        $game_system.se_play($data_system.decision_se)
        start_phase21
      end
      return
    end
  end
 
  def start_phase21
    # フェーズ 3 に移行
    @phase = 21
    @party_command_window.active = false
    @party_command_window.visible = false
    # アクターを非選択状態に設定
    @actor_index = 0
    @active_battler = $game_party.actors[@actor_index]
  end
 
  def update_phase21   
    if @active_battler != nil
        @active_battler.blink = false
      end
    make_etat_window(@actor_index)

      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
     
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        if @etat_window != nil
          @etat_window.dispose
          @etat_window = nil
        end
        start_phase2
      end
   
      if Input.trigger?(Input::R)
        $game_system.se_play($data_system.cursor_se)
        @actor_index += 1
        @actor_index %= $game_party.actors.size
        make_etat_window(@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
        make_etat_window(@actor_index)
        return
      end
    end
 
  def make_etat_window(index)
    if @etat_window != nil
        @etat_window.dispose
        @etat_window = nil
      end
      actor = $game_party.actors[index]
    if actor.states.size != 0
      item_max = actor.states.size
      row_max = (item_max + 4) / 5
      height = 24 * row_max +32
      etat_x = @actor_index * 160
      etat_y = 320 - height
      @etat_window = Window_BattleState.new(etat_x, etat_y, 160, height, actor)
    end
    return
  end
end


Quelques images :
Image
Image

_________________
Image


Haut
 Profil  
 
 Sujet du message: Re: Affichages des altérations d'état via des icônes
MessagePublié: 24 Juil 2009, 21:17 
Ancien membre du staff
Ancien membre du staff
Avatar de l’utilisateur

Inscrit le: 20 Juil 2008, 00:00
Messages: 1726
Niveau RPG Maker: correct
Point(s) Fort(s): polyvalent
Sexe: Masculin
Points d'aide: 0/60

Créations :

- Création d'un sous menu

- Personnalisation des tailles d'icônes et de curseurs

- Affichages des altérations d'état via des icônes


Voir ses créations

Voici la version de Database Management utilisée.

Code: Tout sélectionner
#===============================================================================
# *** Database Management
#-------------------------------------------------------------------------------
# Auteur  : Åvygeil
#-------------------------------------------------------------------------------
# Ce script permet d'automatiser la création et la gestion de base de données
# à partir de fichiers texte sous un format de sérialisation spécial,
# DBSL (DataBase Serialization Language).
#===============================================================================

#===============================================================================
# ** Database
#-------------------------------------------------------------------------------
# Le module qui permet d'automatiquement créer les tables
# de la base de données, et les remplir.
#===============================================================================
module Database
   
  #-----------------------------------------------------------------------------
  # Chargement de la base de données de base.
  #-----------------------------------------------------------------------------
  Actor      = load_data("Data/Actors.rxdata")
  Class      = load_data("Data/Classes.rxdata")
  Skill      = load_data("Data/Skills.rxdata")
  Item        = load_data("Data/Items.rxdata")
  Weapon      = load_data("Data/Weapons.rxdata")
  Armor      = load_data("Data/Armors.rxdata")
  Enemy      = load_data("Data/Enemies.rxdata")
  Troop      = load_data("Data/Troops.rxdata")
  State      = load_data("Data/States.rxdata")
  Animation  = load_data("Data/Animations.rxdata")
  Tileset    = load_data("Data/Tilesets.rxdata")
  CommonEvent = load_data("Data/CommonEvents.rxdata")
  System      = load_data("Data/System.rxdata")

  #=============================================================================
  # ** Database::Table
  #-----------------------------------------------------------------------------
  # La classe Table donne une interface pour créer une classe correspondante.
  #=============================================================================
  class Table
   
    #===========================================================================
    # * Database::Table#initialize
    #    table_name  : nom de la table
    #    &block      : bloc de création des colonnes
    #---------------------------------------------------------------------------
    # La méthode initialize crée une nouvelle classe dans le module Database.
    #===========================================================================
    def initialize(table_name, &block)
      @columns = []
      @column_default_vals = []
      block.call(self)
      #-------------------------------------------------------------------------
      # Création de la classe Database::table_name
      #-------------------------------------------------------------------------
      class_table = ::Class.new
      # Constantes table_name::COLUMNS et table_name::COLUMN_DEFAULT_VALS
      class_table.const_set("COLUMNS", @columns)
      class_table.const_set("COLUMN_DEFAULT_VALS", @column_default_vals)
      class_table.class_eval{
        # Pour chaque colonne, on ajoute un accesseur
        for name in class_table.const_get("COLUMNS")
          attr_accessor name
        end
        # Constructeur des objets Database::table_name
        # Chaque champs de l'objet est mis sa valeur par défaut
        define_method("initialize") {
          columns = class_table.const_get("COLUMNS")
          column_default_vals = class_table.const_get("COLUMN_DEFAULT_VALS")
          for i in 0...columns.size
            instance_variable_set("@#{columns[i]}", column_default_vals[i])
          end
        }
        # Méthode qui renvoie la constante COLUMNS
        define_method("columns") {
          return class_table.const_get("COLUMNS")
        }
        # Database::table_name se comporte comme une table de base de données,
        # un objet Enumerable contenant une liste d'objets Database::table_name,
        # sur lequel on peut faire des requetes.
        class << self
          # Accesseur en écriture aux lignes de la table
          def rows=(rs)
            @rows = rs
          end
          # Objet Enumerable
          include Enumerable
          # Méthode each, qu itère sur les lignes de la table
          def each(&block)
            @rows.each(&block)
          end
        end
      }
      # On ajoute la classe créée au module Database.
      Database.const_set(table_name, class_table)
    end
   
    #===========================================================================
    # * Database::Table#column
    #    col_name  : nom de la colonne
    #    col_type  : type de la colonne (integer, string, boolean, array, hash)
    #---------------------------------------------------------------------------
    # Méthode d'ajout d'une colonne à la table.
    #===========================================================================
    def column(col_name, col_type, default_val = nil)
      @columns << col_name
      if default_val.nil?
        @column_default_vals << default_val(col_type)
      else
        @column_default_vals << default_val
      end
    end
   
    #===========================================================================
    # * Database::Table#default_val
    #    col_type  : type
    #---------------------------------------------------------------------------
    # Renvoie une valeur par défaut en fonction du type.
    #===========================================================================
    def default_val(col_type)
      case col_type
      when :integer
        return 0
      when :string
        return ""
      when :boolean
        return false
      when :array
        return []
      when :hash
        return {}
      else
        return nil
      end
    end
    private :default_val
   
  end

  #=============================================================================
  # * Database.create_table
  #    table_name  :
  #    &block      : bloc de création des colonnes
  #-----------------------------------------------------------------------------
  # Méthode de création et de remplissage d'une table de la base de données.
  #=============================================================================
  def self.create_table(table_name, &block)
    Table.new(table_name, &block)
    table = self.const_get(table_name)
    if $DEBUG
      Dir.mkdir("#{table_name} Data") rescue nil
      File.open("#{table_name} Data/template.dbsl", "w") do |file|
        file.puts(Serialization.dump(table.new))
      end
      data = []
      for dbsl_file in Dir["#{table_name} Data/*.dbsl"]
        File.open(dbsl_file, "r") do |file|
          obj = Serialization.load(file.read)
          data << obj
        end
      end
      File.open("Data/#{table_name}.rxdata", "wb") do |file|
        Marshal.dump(data, file)
      end
    end
    table.rows = load_data("Data/#{table_name}.rxdata")
  end

  #=============================================================================
  # ** Database::Serialization
  #-----------------------------------------------------------------------------
  # Ce module contient les méthodes qui permettent de sauver ou charger
  # des objets au format DBSL.
  #=============================================================================
  module Serialization
   
    #===========================================================================
    # * Database::Serialization.dump
    #    ruby_obj  : un objet Ruby
    #---------------------------------------------------------------------------
    # Renvoie une String représentant l'objet Ruby au format dbsl.
    #===========================================================================
    def self.dump(ruby_obj)
      s = "#{ruby_obj.class}\n"
      for var in ruby_obj.columns
        s << "#{var}: #{ruby_obj.method(var).call.to_dbsl}\n"
      end
      return s
    end

    #===========================================================================
    # * Database::Serialization.load
    #    dbsl_obj  : String représentant un "objet dbsl"
    #---------------------------------------------------------------------------
    # Récupère un objet Ruby à partir de sa description dbsl.
    #===========================================================================
    def self.load(dbsl_obj)
      lines = dbsl_obj.split("\n")
      ruby_obj = eval(lines[0] + ".new")
      for line in lines[1..lines.size-1]
        expr = line.split(":")
        ruby_obj.method(expr[0]+"=").call(eval(expr[1]))
      end
      return ruby_obj
    end
   
  end
   
end

#===============================================================================
# ** Représentation DBSL des types de base
#===============================================================================

#===============================================================================
# * Nilclass
#===============================================================================
class NilClass

  def to_dbsl
    "nil"
  end

end

#===============================================================================
# * TrueClass
#===============================================================================
class TrueClass

  def to_dbsl
    "true"
  end

end

#===============================================================================
# * FalseClass
#===============================================================================
class FalseClass

  def to_dbsl
    "false"
  end

end

#===============================================================================
# * Numeric
#===============================================================================
class Numeric

  def to_dbsl
    to_s
  end

end

#===============================================================================
# * String
#===============================================================================
class String

  def to_dbsl
    "\"#{to_s}\""
  end

end

#===============================================================================
# * Symbol
#===============================================================================
class Symbol

  def to_dbsl
    ":#{to_s}"
  end

end

#===============================================================================
# * Array
#===============================================================================
class Array

  def to_dbsl
    s = "["
    if self.size != 0
      for v in self[0...self.size-1]
        s << (v.to_dbsl + ", ")
      end
      s << (self.last.to_dbsl)
    end
    s << "]"
    return s
  end

end

#===============================================================================
# * Hash
#===============================================================================
class Hash

  def to_dbsl
    s = "{"
    if self.size != 0
      for k in self.keys[0...self.size-1]
        s << ("#{k.to_dbsl} => #{self[k].to_dbsl}, ")
      end
      s << "#{self.keys.last.to_dbsl} => #{self[self.keys.last].to_dbsl}"
    end
    s << "}"
    return s
  end

end

_________________
Image


Haut
 Profil  
 
Afficher les messages depuis:  Trier par  
Publier un nouveau sujet Répondre au sujet  [ 2 messages ] 

Heures au format UTC + 1 heure [ Heure d’été ]


Qui est en ligne ?

Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 3 invités


Vous ne pouvez pas publier de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas insérer de pièces jointes dans ce forum

Rechercher pour:
Sauter vers:  
cron
RPG Creative Forum version 5 ; Tous droits réservés
phpBB Group (Traduit par Xaphos)
Optimisé pour une résolution 1024*728