RPG Creator : créez votre MMORPG ou RPG sans aucune connaissance en programmation


Disponible le 4 Juin !




- Jouez à votre jeu sur tablettes tactiles, Smartphones et navigateurs Web
- Personnalisez vos menus
- Dessinez facilement et rapidement vos cartes
- Créez des actions pour le combat A-RPG


www.rpgcreator.net


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  [ 5 messages ] 
Auteur Message
 Sujet du message: Séparation d'inventaire
MessagePublié: 06 Aoû 2007, 19:57 
Roi
Roi
Avatar de l’utilisateur

Inscrit le: 13 Aoû 2006, 00:00
Messages: 2417
Localisation: Montréal, QC
Logiciel(s) préféré(s): RMXP, VS2008
Point(s) Fort(s): Script
Points d'aide: Illimité

Créations :

- Séparation d'inventaire

- Sprite_Text


Voir ses créations

Bonjour,

Voici un ensemble de script de ma composition qui permettent de séparer les inventaires des différents personnages de l'équipe.

Les instructions se trouvent dans l'entête du premier script.

Code: Tout sélectionner
#==============================================================================
# ■ Système d'inventaire séparé
#------------------------------------------------------------------------------
# Auteur :       Mat
# Crée le :      06/08/2006
# Version :      1.0
# Distribution : RPG Creative (http://rpgcreative.net/)
#------------------------------------------------------------------------------
# Ce script permet à chaque personnage d'avoir son propre inventaire séparé
#
# Note : l'aquisition d'objet (event ou combat) donnera l'objet automatiquement
# au premier personnage de l'equipe
#------------------------------------------------------------------------------
# Créer un nouveau script au dessus de main et placer le script à l'intérieur
#==============================================================================


#==============================================================================
# ▼ Game_Actor
#------------------------------------------------------------------------------
# Cette classe modélise les acteurs avec leurs propres inventaires
#==============================================================================
class Game_Actor < Game_Battler
 
  attr_reader   :items #liste des items possédés par l'acteur
  attr_reader   :weapons #liste des armes possédés par l'acteur
  attr_reader   :armors #liste des armures possédés par l'acteur
 
 
 
  alias inventory_actor_initialize initialize
 
  #============================================================================
  # ● initialize
  #    id : id du personnage dans la base de données
  #----------------------------------------------------------------------------
  # Permet d'initialiser un personnage
  #============================================================================
  def initialize(id)
    inventory_actor_initialize(id)
    @items = Hash.new
    @weapons = Hash.new
    @armors = Hash.new
  end
 
  #============================================================================
  # ● gain_item
  #    item_id : id de l'item à ajouter à ce personnage
  #    n : nombre d'objet à rajouter
  #----------------------------------------------------------------------------
  # Permet d'ajouter un ou plusieurs objets à ce personnage
  #============================================================================
  def gain_item(item_id, n)
    if item_id > 0
      @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
    end
  end
 
  #============================================================================
  # ● gain_weapon
  #    weapon_id : id de l'arme à ajouter à ce personnage
  #    n : nombre d'arme à rajouter
  #----------------------------------------------------------------------------
  # Permet d'ajouter un ou plusieurs armes à ce personnage
  #============================================================================
  def gain_weapon(weapon_id, n)
    if weapon_id > 0
      @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
    end
  end
 
  #============================================================================
  # ● gain_armor
  #    armor_id : id de l'armure à ajouter à ce personnage
  #    n : nombre d'armire à rajouter
  #----------------------------------------------------------------------------
  # Permet d'ajouter un ou plusieurs armures à ce personnage
  #============================================================================
  def gain_armor(armor_id, n)
    if armor_id > 0
      @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
    end
  end
 
  #============================================================================
  # ● lose_item
  #    item_id : id de l'objet à retirer à ce personnage
  #    n : nombre d'objet à rajouter
  #----------------------------------------------------------------------------
  # Permet de retirer un ou plusieurs objets à ce personnage
  #============================================================================
  def lose_item(item_id, n)
    gain_item(item_id, -n)
  end
 
  #============================================================================
  # ● lose_weapon
  #    weapon_id : id de l'arme à retirer à ce personnage
  #    n : nombre d'arme à rajouter
  #----------------------------------------------------------------------------
  # Permet de retirer un ou plusieurs armes à ce personnage
  #============================================================================
  def lose_weapon(weapon_id, n)
    gain_weapon(weapon_id, -n)
  end
 
  #============================================================================
  # ● lose_armor
  #    item_id : id de l'armure à retirer à ce personnage
  #    n : nombre d'armure à rajouter
  #----------------------------------------------------------------------------
  # Permet de retirer un ou plusieurs armures à ce personnage
  #============================================================================
  def lose_armor(armor_id, n)
    gain_armor(armor_id, -n)
  end
   
  #============================================================================
  # ● item_number
  #    item_id : id de l'objet à comptabiliser
  #----------------------------------------------------------------------------
  # Comptabilise le nombre de fois que le personnage possède un objet
  #============================================================================
  def item_number(item_id)
    return @items.include?(item_id) ? @items[item_id] : 0
  end

  #============================================================================
  # ● weapon_number
  #    weapon_id : id de l'arme à comptabiliser
  #----------------------------------------------------------------------------
  # Comptabilise le nombre de fois que le personnage possède une arme
  #============================================================================
  def weapon_number(weapon_id)
    return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
  end

  #============================================================================
  # ● armor_number
  #    armor_id : id de l'armure à comptabiliser
  #----------------------------------------------------------------------------
  # Comptabilise le nombre de fois que le personnage possède une armure
  #============================================================================
  def armor_number(armor_id)
    return @armors.include?(armor_id) ? @armors[armor_id] : 0
  end
 
  #============================================================================
  # ● item_can_use?
  #    item_id : id de l'objet à vérifier
  #----------------------------------------------------------------------------
  # Vérifier qu'un objet peut être utiliser par le personnage
  #============================================================================ 
  def item_can_use?(item_id)
    if item_number(item_id) == 0
      return false
    end
    occasion = $data_items[item_id].occasion
    if $game_temp.in_battle
      return (occasion == 0 or occasion == 1)
    end
    return (occasion == 0 or occasion == 2)
  end
 
  #============================================================================
  # ● equip
  #    equip_type : le type d'équipement
  #    id : id de l'equipement
  #----------------------------------------------------------------------------
  # Permet d'équiper un objet à ce personnage
  #============================================================================
  def equip(equip_type, id)
    case equip_type
    when 0
      if id == 0 or weapon_number(id) > 0
        gain_weapon(@weapon_id, 1)
        @weapon_id = id
        lose_weapon(id, 1)
      end
    when 1
      if id == 0 or armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        gain_armor(@armor1_id, 1)
        @armor1_id = id
        lose_armor(id, 1)
      end
    when 2
      if id == 0 or armor_number(id) > 0
        update_auto_state($data_armors[@armor2_id], $data_armors[id])
       gain_armor(@armor2_id, 1)
        @armor2_id = id
        lose_armor(id, 1)
      end
    when 3
      if id == 0 or armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        gain_armor(@armor3_id, 1)
        @armor3_id = id
        lose_armor(id, 1)
      end
    when 4
      if id == 0 or armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        gain_armor(@armor4_id, 1)
        @armor4_id = id
        lose_armor(id, 1)
      end
    end
  end
 
end

#==============================================================================
# ▼ Interpreter
#------------------------------------------------------------------------------
# Fonctions appelées par les events
#==============================================================================
class Interpreter
 
  #============================================================================
  # ● commande_126
  #----------------------------------------------------------------------------
  # Ajoute un objet au premier personnage
  #============================================================================
  def command_126
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    $game_party.actors[0].gain_item(@parameters[0], value)
    return true
  end
 
  #============================================================================
  # ● commande_127
  #----------------------------------------------------------------------------
  # Ajoute une arme au premier personnage
  #============================================================================
  def command_127
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    $game_party.actors[0].gain_weapon(@parameters[0], value)
    return true
    end
 
  #============================================================================
  # ● commande_128
  #----------------------------------------------------------------------------
  # Ajoute une armure au premier personnage
  #============================================================================ 
  def command_128
    value = operate_value(@parameters[1], @parameters[2], @parameters[3])
    $game_party.actors[0].gain_armor(@parameters[0], value)
    return true
  end
 
  #============================================================================
  # ● commande_111
  #----------------------------------------------------------------------------
  # Condition
  #============================================================================ 
  def command_111
    result = false
    case @parameters[0]
    when 0
      result = ($game_switches[@parameters[1]] == (@parameters[2] == 0))
    when 1
      value1 = $game_variables[@parameters[1]]
      if @parameters[2] == 0
        value2 = @parameters[3]
      else
        value2 = $game_variables[@parameters[3]]
      end
      case @parameters[4]
      when 0
        result = (value1 == value2)
      when 1
        result = (value1 >= value2)
      when 2
        result = (value1 <= value2)
      when 3
        result = (value1 > value2)
      when 4
        result = (value1 < value2)
      when 5
        result = (value1 != value2)
      end
    when 2
      if @event_id > 0
        key = [$game_map.map_id, @event_id, @parameters[1]]
        if @parameters[2] == 0
          result = ($game_self_switches[key] == true)
        else
          result = ($game_self_switches[key] != true)
        end
      end
    when 3
      if $game_system.timer_working
        sec = $game_system.timer / Graphics.frame_rate
        if @parameters[2] == 0
          result = (sec >= @parameters[1])
        else
          result = (sec <= @parameters[1])
        end
      end
    when 4
      actor = $game_actors[@parameters[1]]
      if actor != nil
        case @parameters[2]
        when 0
          result = ($game_party.actors.include?(actor))
        when 1
          result = (actor.name == @parameters[3])
        when 2
          result = (actor.skill_learn?(@parameters[3]))
        when 3
          result = (actor.weapon_id == @parameters[3])
        when 4
          result = (actor.armor1_id == @parameters[3] or
                    actor.armor2_id == @parameters[3] or
                    actor.armor3_id == @parameters[3])
        when 5
          result = (actor.state?(@parameters[3]))
        end
      end
    when 5
      enemy = $game_troop.enemies[@parameters[1]]
      if enemy != nil
        case @parameters[2]
        when 0
          result = (enemy.exist?)
        when 1
          result = (enemy.state?(@parameters[3]))
        end
      end
    when 6
      character = get_character(@parameters[1])
      if character != nil
        result = (character.direction == @parameters[2])
      end
    when 7
      if @parameters[2] == 0
        result = ($game_party.gold >= @parameters[1])
      else
        result = ($game_party.gold <= @parameters[1])
      end
    when 8
      result = false
      for i in 0..$game_party.actors.size - 1
        result |= ($game_party.actors[i].item_number(@parameters[1]) > 0)
      end
    when 9
      result = false
      for i in 0..$game_party.actors.size - 1
        result |= ($game_party.weapon_number(@parameters[1]) > 0)
      end
    when 10
      for i in 0..$game_party.actors.size - 1
        result |= ($game_party.armor_number(@parameters[1]) > 0)
      end
    when 11
      result = (Input.press?(@parameters[1]))
    when 12
      result = eval(@parameters[1])
    end
    @branch[@list[@index].indent] = result
    if @branch[@list[@index].indent] == true
      @branch.delete(@list[@index].indent)
      return true
    end
    return command_skip
  end
end


Haut
 Profil  
 
 Sujet du message: Re: Séparation d'inventaire
MessagePublié: 06 Aoû 2007, 19:58 
Roi
Roi
Avatar de l’utilisateur

Inscrit le: 13 Aoû 2006, 00:00
Messages: 2417
Localisation: Montréal, QC
Logiciel(s) préféré(s): RMXP, VS2008
Point(s) Fort(s): Script
Points d'aide: Illimité

Créations :

- Séparation d'inventaire

- Sprite_Text


Voir ses créations

Ce script gère l'inventaire de chaque personnage dans le menu

Code: Tout sélectionner
#==============================================================================
# ▼ Window_Item
#------------------------------------------------------------------------------
# Fenêtre affichant tout les objets possèdés par un personnage
#==============================================================================
class Window_Item

  #============================================================================
  # ● initialize
  #    actor : le personnage duquel on affiche les objets
  #----------------------------------------------------------------------------
  # Initialise la fenetre
  #============================================================================
  alias inventory_window_item_initialize initialize
  def initialize(actor)
    @actor = actor
    inventory_window_item_initialize
  end

  #============================================================================
  # ● refresh
  #----------------------------------------------------------------------------
  # Fonction de raffréchissement de la fenetre
  #============================================================================
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
   
    for i in 1...$data_items.size
      if @actor.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
   
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if @actor.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if @actor.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
   
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  #============================================================================
  # ● draw_item
  #    index : l'index de l'objet dans le tableau de la fenetre
  #----------------------------------------------------------------------------
  # Fonction permet d'afficher un objet
  #============================================================================
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = @actor.item_number(item.id)
    when RPG::Weapon
      number = @actor.weapon_number(item.id)
    when RPG::Armor
      number = @actor.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
      @actor.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.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, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end

end

#==============================================================================
# ▼ Window_EquipItem
#------------------------------------------------------------------------------
# Fenêtre affichant l'equipement possédé par un personnage
#==============================================================================
class Window_EquipItem < Window_Selectable

  #============================================================================
  # ● refresh
  #----------------------------------------------------------------------------
  # Fonction de raffréchissement de la fenetre
  #============================================================================
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if @actor.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons[i])
        end
      end
    end
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if @actor.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            @data.push($data_armors[i])
          end
        end
      end
    end
    @data.push(nil)
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    for i in 0...@item_max-1
      draw_item(i)
    end
  end

  #============================================================================
  # ● draw_item
  #    index : l'index de l'objet dans le tableau de la fenetre
  #----------------------------------------------------------------------------
  # Fonction permet d'afficher un objet
  #============================================================================
  def draw_item(index)
    item = @data[index]
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    case item
    when RPG::Weapon
      number = @actor.weapon_number(item.id)
    when RPG::Armor
      number = @actor.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end

end


#==============================================================================
# ▼ Scene_Item
#------------------------------------------------------------------------------
# Scene de gestion des objets
#==============================================================================
class Scene_Item


  #============================================================================
  # ● initialize
  #    actor_index : index du personnage duquel on gere les objets
  #----------------------------------------------------------------------------
  # Initialise la scene
  #============================================================================
  def initialize(actor_index)
    @actor_index = actor_index
  end

  #============================================================================
  # ● main
  #============================================================================
  def main
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @item_window = Window_Item.new(@actor)
    @item_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
    @item_window.dispose
    @target_window.dispose
  end

  #============================================================================
  # ● update_item
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre d'objet
  #============================================================================
  def update_item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0)
      return
    end
   
    if Input.trigger?(Input::C)
      @item = @item_window.item
      unless @item.is_a?(RPG::Item)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      unless @actor.item_can_use?(@item.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      if @item.scope >= 3
        @item_window.active = false
        @target_window.x = (@item_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
      else
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $game_system.se_play(@item.menu_se)
          if @item.consumable
            @actor.lose_item(@item.id, 1)
            @item_window.draw_item(@item_window.index)
          end
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end

  #============================================================================
  # ● update_target
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre de cible
  #============================================================================
  def update_target
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      unless @actor.item_can_use?(@item.id)
        @item_window.refresh
      end
      @item_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    if Input.trigger?(Input::C)
      if @actor.item_number(@item.id) == 0
        $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.item_effect(@item)
        end
      end
      if @target_window.index >= 0
        target = $game_party.actors[@target_window.index]
        used = target.item_effect(@item)
      end
      if used
        $game_system.se_play(@item.menu_se)
        if @item.consumable
          @actor.lose_item(@item.id, 1)
          @item_window.draw_item(@item_window.index)
        end
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.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

#==============================================================================
# ▼ Scene_Menu
#------------------------------------------------------------------------------
# Scene du Menu principal
#==============================================================================
class Scene_Menu

  #============================================================================
  # ● update_command
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre de commande
  #============================================================================
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
   
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
     
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
      return
    end
  end

  #============================================================================
  # ● update_status
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre des status
  #============================================================================
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end

    if Input.trigger?(Input::C)

      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new(@status_window.index)
      when 1
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when 3
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end

end


Haut
 Profil  
 
 Sujet du message: Re: Séparation d'inventaire
MessagePublié: 06 Aoû 2007, 19:58 
Roi
Roi
Avatar de l’utilisateur

Inscrit le: 13 Aoû 2006, 00:00
Messages: 2417
Localisation: Montréal, QC
Logiciel(s) préféré(s): RMXP, VS2008
Point(s) Fort(s): Script
Points d'aide: Illimité

Créations :

- Séparation d'inventaire

- Sprite_Text


Voir ses créations

Ce script gère l'inventaire pendant les combats

Code: Tout sélectionner
#==============================================================================
# ▼ Scene_Battle
#------------------------------------------------------------------------------
# Scene des combats
#==============================================================================
class Scene_Battle
 
  #============================================================================
  # ● update_phase3_item_select
  #----------------------------------------------------------------------------
  # Mise a jour de la phase 3 pour la selection d'objet
  #============================================================================   
  def update_phase3_item_select
    @item_window.visible = true
    @item_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      end_item_select
      return
    end
    if Input.trigger?(Input::C)
      @item = @item_window.item
      unless $game_party.actors[@actor_index].item_can_use?(@item.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @active_battler.current_action.item_id = @item.id
      @item_window.visible = false
      if @item.scope == 1
        start_enemy_select
      elsif @item.scope == 3 or @item.scope == 5
        start_actor_select
      else
        end_item_select
        phase3_next_actor
      end
      return
    end
  end
 
  #============================================================================
  # ● start_phase5
  #----------------------------------------------------------------------------
  # Debut de la phase 5
  #============================================================================
  def start_phase5
    @phase = 5
    $game_system.me_play($game_system.battle_end_me)
    $game_system.bgm_play($game_temp.map_bgm)
    exp = 0
    gold = 0
    treasures = []
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
        gold += enemy.gold
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    treasures = treasures[0..5]
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    $game_party.gain_gold(gold)
    for item in treasures
      case item
      when RPG::Item
        $game_party.actors[0].gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.actors[0].gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.actors[0].gain_armor(item.id, 1)
      end
    end
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    @phase5_wait_count = 100
  end

  #============================================================================
  # ● start_item_select
  #----------------------------------------------------------------------------
  # Fonction de sélection des objets
  #============================================================================
  def start_item_select
    @item_window = Window_Item.new(@active_battler)
    @item_window.help_window = @help_window
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
 
  #============================================================================
  # ● make_item_action_result
  #----------------------------------------------------------------------------
  # Fonction de résultat d'utilisation d'un objet
  #============================================================================
  def make_item_action_result
    @item = $data_items[@active_battler.current_action.item_id]
    unless @active_battler.item_can_use?(@item.id)
      @phase4_step = 1
      return
    end
    if @item.consumable
      @active_battler.lose_item(@item.id, 1)
    end
    @help_window.set_text(@item.name, 1)
    @animation1_id = @item.animation1_id
    @animation2_id = @item.animation2_id
    @common_event_id = @item.common_event_id
    index = @active_battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    set_target_battlers(@item.scope)
    for target in @target_battlers
      target.item_effect(@item)
    end
  end
 
end


Haut
 Profil  
 
 Sujet du message: Re: Séparation d'inventaire
MessagePublié: 06 Aoû 2007, 19:59 
Roi
Roi
Avatar de l’utilisateur

Inscrit le: 13 Aoû 2006, 00:00
Messages: 2417
Localisation: Montréal, QC
Logiciel(s) préféré(s): RMXP, VS2008
Point(s) Fort(s): Script
Points d'aide: Illimité

Créations :

- Séparation d'inventaire

- Sprite_Text


Voir ses créations

Ce script gère l'inventaire dans les magasins

Code: Tout sélectionner
#==============================================================================
# ▼ Window_ShopSell
#------------------------------------------------------------------------------
# Fenetre de vente d'objet
#==============================================================================
class Window_ShopSell < Window_Selectable
 
  #============================================================================
  # ● initialize
  #    actor : acteur qui va vendre les objets
  #----------------------------------------------------------------------------
  # Initialisation de la fenetre
  #============================================================================
  def initialize(actor = nil)
    super(0, 128, 640, 352)
    @column_max = 2
    @actor = actor
    if @actor != nil
      refresh
    end
    self.index = 0
  end

  #============================================================================
  # ● item
  #----------------------------------------------------------------------------
  # retourne l'objet selectionne
  #============================================================================
  def item
    return @data[self.index]
  end

  #============================================================================
  # ● refresh
  #----------------------------------------------------------------------------
  # focntion de rafraichissement de la fenetre
  #============================================================================
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 1...$data_items.size
      if @actor.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    for i in 1...$data_weapons.size
      if @actor.weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    for i in 1...$data_armors.size
      if @actor.armor_number(i) > 0
        @data.push($data_armors[i])
      end
    end

    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  #============================================================================
  # ● draw_item
  #    index : index de l'objet à dessiener dans le tableau de la fenetre
  #----------------------------------------------------------------------------
  # Fonction pour dessiner un objet
  #============================================================================
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = @actor.item_number(item.id)
    when RPG::Weapon
      number = @actor.weapon_number(item.id)
    when RPG::Armor
      number = @actor.armor_number(item.id)
    end
   
    if item.price > 0
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.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, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
end

#==============================================================================
# ▼ Scene_Shop
#------------------------------------------------------------------------------
# Scene d'achat et de vente d'objet
#==============================================================================
class Scene_Shop
 
  #============================================================================
  # ● main
  #============================================================================
  def main
    @help_window = Window_Help.new
  
    @command_window = Window_ShopCommand.new
   
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64

    @dummy_window = Window_Base.new(0, 128, 640, 352)
  
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
  
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window

    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false

    @status_window = Window_ShopStatus.new
    @status_window.visible = false

    @target_window = Window_Target.new
    @target_window.active = false
    @target_window.visible = false
    @target_window.index = 0
   
    Graphics.transition
  
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze

    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
    @target_window.dispose
  end
 
  #============================================================================
  # ● update
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la scene
  #============================================================================
  def update
   
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @sell_window.update
    @number_window.update
    @status_window.update
    @target_window.update
   
    if @command_window.active
      update_command
      return
    end
   
    if @target_window.active
      update_target
      return
    end

    if @buy_window.active
      update_buy
      return
    end

    if @sell_window.active
      update_sell
      return
    end

    if @number_window.active
      update_number
      return
    end
  end
 
  #============================================================================
  # ● update_command
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre de commande
  #============================================================================
  def update_command
   
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
   
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0 
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
       
        @target_window.active = true
        @target_window.visible = true
        @target_window.refresh
       
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
       
        @target_window.active = true
        @target_window.visible = true
        @target_window.refresh
       
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
 
  #============================================================================
  # ● update_target
  #----------------------------------------------------------------------------
  # Fonction demise à jour de la fenetre de cible
  #============================================================================
  def update_target
    if Input.trigger?(Input::B)
      @target_window.active = false
      @target_window.visible = false
     
      @command_window.active = true
    end
   
    if Input.trigger?(Input::C)
      actor_index = @target_window.index
      @actor = $game_party.actors[actor_index]
   
      case @command_window.index
      when 0
       
        $game_system.se_play($data_system.decision_se)
        @target_window.active = false
        @target_window.visible = false
        @dummy_window.visible = false
       
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
   
      when 1
        $game_system.se_play($data_system.decision_se)
        @target_window.active = false
        @target_window.visible = false
        @dummy_window.visible = false
       
        @sell_window = Window_ShopSell.new(@actor)
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
      end
    end
  end
 
  #============================================================================
  # ● update_buy
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre d'achat
  #============================================================================
  def update_buy
    @status_window.item = @buy_window.item

    if Input.trigger?(Input::B)
     
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end
   
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
     
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end

      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end

      $game_system.se_play($data_system.decision_se)
      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
      max = [max, 99 - number].min

      @buy_window.active = false
      @buy_window.visible = false
      @number_window.set(@item, max, @item.price)
      @number_window.active = true
      @number_window.visible = true
    end
  end
 
  #============================================================================
  # ● update_sell
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre de vente
  #============================================================================
  def update_sell
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end

    if Input.trigger?(Input::C)
      @item = @sell_window.item
      @status_window.item = @item
      if @item == nil or @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end
      max = number
      @sell_window.active = false
      @sell_window.visible = false
      @number_window.set(@item, max, @item.price / 2)
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
    end
  end
 
  #============================================================================
  # ● update_number
  #----------------------------------------------------------------------------
  #  Fonction de mise à jour de la fenetre de dénombrement
  #============================================================================
  def update_number
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0
        @target_window.active = true
        @target_window.visible = true

      when 1
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      end
      return
    end
   
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0
        $game_party.lose_gold(@number_window.number * @item.price)
        case @item
        when RPG::Item
          @actor.gain_item(@item.id, @number_window.number)
        when RPG::Weapon
          @actor.gain_weapon(@item.id, @number_window.number)
        when RPG::Armor
          @actor.gain_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @buy_window.refresh
        @status_window.refresh
        @buy_window.active = true
        @buy_window.visible = true
      when 1
        $game_party.gain_gold(@number_window.number * (@item.price / 2))
        case @item
        when RPG::Item
          @actor.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          @actor.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          @actor.lose_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @sell_window.refresh
        @status_window.refresh
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      end
      return
    end
  end
end


Haut
 Profil  
 
 Sujet du message: Re: Séparation d'inventaire
MessagePublié: 06 Aoû 2007, 20:03 
Roi
Roi
Avatar de l’utilisateur

Inscrit le: 13 Aoû 2006, 00:00
Messages: 2417
Localisation: Montréal, QC
Logiciel(s) préféré(s): RMXP, VS2008
Point(s) Fort(s): Script
Points d'aide: Illimité

Créations :

- Séparation d'inventaire

- Sprite_Text


Voir ses créations

Cette scène permet de pouvoir échanger les objets entre les différents personnages.

Pour l'appeler via un event ou bien par script (par exemple le menu), insérer le code
Code: Tout sélectionner
$scene = Scene_Exchange.new(actor_id)

Ou actor_id est l'index du personnage qui donnera des objets aux autres.

Code: Tout sélectionner
#==============================================================================
# ▼ Scene_Exchange
#------------------------------------------------------------------------------
# Scene permettant déchanger les objets entre les différents personnages
#==============================================================================
class Scene_Exchange
 
 
  #============================================================================
  # ● initialize
  #    actor_index : index du personnage duquel on gere les objets
  #----------------------------------------------------------------------------
  # Initialise la scene
  #============================================================================
  def initialize(actor_index)
    @actor_index = actor_index
  end
 
  #============================================================================
  # ● main
  #============================================================================
  def main
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @item_window = Window_Item.new(@actor)
    @item_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
    @item_window.dispose
    @target_window.dispose
  end
 
 
  #============================================================================
  # ● update
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la scene
  #============================================================================
  def update
    @help_window.update
    @item_window.update
    @target_window.update
   
    if @item_window.active
      update_item
      return
    end
   
    if @target_window.active
      update_target
      return
    end
  end

  #============================================================================
  # ● update_item
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre d'objet
  #============================================================================
  def update_item
   
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0)
      return
    end
    if Input.trigger?(Input::C)
      @item = @item_window.item
      $game_system.se_play($data_system.decision_se)
      @item_window.active = false
      @target_window.x = (@item_window.index + 1) % 2 * 304
      @target_window.visible = true
      @target_window.active = true
      @target_window.index = 0
    end
  end

  #============================================================================
  # ● update
  #----------------------------------------------------------------------------
  # Fonction de mise à jour de la fenetre de cible
  #============================================================================
  def update_target
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @item_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
   
    if Input.trigger?(Input::C)
     
      if @item.is_a?(RPG::Item)
        if @actor.item_number(@item.id) == 0
          $game_system.se_play($data_system.buzzer_se)
          return
        end
       
        if @target_window.index != @actor_index
          $game_system.se_play($data_system.decision_se)
          target = $game_party.actors[@target_window.index]
          target.gain_item(@item.id, 1)
          @actor.lose_item(@item.id, 1)
          @item_window.active = true
          @target_window.visible = false
          @target_window.active = false
        else
          $game_system.se_play($data_system.buzzer_se)
        end
       
      end
       
      if @item.is_a?(RPG::Weapon)
        if @actor.weapon_number(@item.id) == 0
          $game_system.se_play($data_system.buzzer_se)
          return
        end
       
        if @target_window.index != @actor_index
          $game_system.se_play($data_system.decision_se)
          target = $game_party.actors[@target_window.index]
          target.gain_weapon(@item.id, 1)
          @actor.lose_weapon(@item.id, 1)
          @item_window.active = true
          @target_window.visible = false
          @target_window.active = false
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      end
       
      if @item.is_a?(RPG::Armor)
        if @actor.armor_number(@item.id) == 0
          $game_system.se_play($data_system.buzzer_se)
          return
        end
       
        if @target_window.index != @actor_index
          $game_system.se_play($data_system.decision_se)
          target = $game_party.actors[@target_window.index]
          target.gain_armor(@item.id, 1)
          @actor.lose_armor(@item.id, 1)
          @item_window.active = true
          @target_window.visible = false
          @target_window.active = false
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      end
      @item_window.refresh
    end
  end
end



Si vous avez des remarques constructives ou bien des difficultés (bug, erreur, mauvaise compréhension...), n'hésitez pas à m'en faire part.

Bon making à tous.


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

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


Qui est en ligne ?

Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 2 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