Derniers messages sur les forums

Une communauté de plus d'un millier de membres actifs

Acheter des mercenaires

Si vous cherchez un scrîpt pour acheter des mercenaires, comme dans Diablo 2, j'ai ce qu'il vous faut :

Il y a en tout septs nouveaux scripts (tous des modifications de scene_shop et des window_shop) à ajouter mettez les au-dessus de main où à côté de Scene_Shop et les Window_Shop peut importe. Ensuite, ajouter les divers méthodes à Game_Party.

1) Scene_Hireling
Code:
class Scene_Hireling
    #--------------------------------------------------------------------------
  def initialize
  @Number_Hireling = 0
end
  #--------------------------------------------------------------------------
  def main
         @help_window = Window_Help.new
        @command_window = Window_HirelingCommand.new
        @gold_window = Window_Gold.new
        @gold_window.x = 480
        @gold_window.y = 64
        @dummy_window = Window_Base.new(0, 128, 640, 352)
#-----------------  edit ----------------------------------------
        @buy_window = Window_HirelingBuy.new
#-----------------  edit/ ----------------------------------------
        @buy_window.active = false
       @buy_window.visible = false  
        @none_window =Window_HirelingNone.new
        @none_window.active = false
        @none_window.visible = false        
        @number_window = Window_HirelingNumber.new
        @number_window.active = false
        @number_window.visible = false
         @status_window = Window_HirelingStatus.new
         @status_window.visible = false        
    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      
    @number_window.dispose
    @status_window.dispose  
    @none_window.dispose
  end
  #--------------------------------------------------------------------------
  def update  
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @number_window.update
    @status_window.update  
    @none_window.update
    if @command_window.active
      update_command
      return
    end
    if @buy_window.active
      update_buy
      return
    end
    if @number_window.active
      update_number
      return
    end
     if @none_window.active
      update_none
      return
    end  
end  
  #--------------------------------------------------------------------------
  def update_command
    if Input.trigger?(Input::B)    
     exit
      return
    end
    if Input.trigger?(Input::C)  
      case @command_window.index
      when 0
         if $game_party.actors.size == 4
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @none_window.active = true
        @none_window.visible = true
        @none_window.refresh      
      else
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
        end
        when 1      
        exit      
      end
      return
    end
  end
    #-------------------------------------------------------------------------
   #-----------------  edit ----------------------------------------
  def exit            
       $game_system.se_play($data_system.cancel_se)
         for i in 1...$data_items.size
         if $game_party.hireling_number(i) > 0
           $game_variables[1] = i
           $game_party.hireling_shop(i,-1)
         end
       end
       $scene = Scene_Map.new
     end
#-----------------  edit/ ----------------------------------------
  #--------------------------------------------------------------------------
  def update_buy  
     #-----------------  edit ----------------------------------------
     @status_window.item = @buy_window.item  
      #-----------------  edit/ ----------------------------------------
    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.item = nil
      @status_window.visible = false  
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 4 - @Number_Hireling
         $game_system.se_play($data_system.decision_se)
       @command_window.active = false
        @dummy_window.visible = false
        @none_window.active = true
        @none_window.visible = true
        @none_window.refresh            
         @buy_window.active = false
        @buy_window.visible = false      
        @status_window.visible = false      
       else
           @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
end
  #--------------------------------------------------------------------------
def update_none
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
           @command_window.active = true
      @dummy_window.visible = true
      @none_window.active = false
      @none_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end      
  end
  #--------------------------------------------------------------------------
  def update_number
      if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
          @number_window.active = false
      @number_window.visible = false    
        @buy_window.active = true
        @buy_window.visible = true    
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)    
      @number_window.active = false
      @number_window.visible = false    
        $game_party.lose_gold(1 * @item.price)
        #-----------------  edit ----------------------------------------
          $game_party.gain_hireling(@item.id)
          $game_party.hireling_shop(@item.id,-1)
          $game_party.hireling_check(@item.id)
         #-----------------  edit/ ----------------------------------------          
          @Number_Hireling += 1
     @gold_window.refresh
        @buy_window.refresh
        @status_window.refresh
        @buy_window.active = true
        @buy_window.visible = true        
      return
    end
  end
end



2) Window_HirelingCommand
Code:
class Window_HirelingCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item_max = 2
    @column_max = 2
    @commands = ["Buy", "Cancel"]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 50 + index * 240
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end


3) Window_HirelingBuy
Code:
class Window_HirelingBuy < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(0, 128, 268, 352)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  def refresh
      if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
@data = []
#----------------edit--------------------------
    for i in 1...$data_items.size
      if $game_party.hireling_number(i) > 0
        @data.push($data_items[i])
      end
    end  
#----------------edit/--------------------------
    @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
  #--------------------------------------------------------------------------
  def draw_item(index)    
    item = @data[index]
    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 item.price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end  
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))  
    self.contents.draw_text(x, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 100, y, 88, 32, item.price.to_s, 2)
  end
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end


4) Window_HirelingNumber
Code:
class Window_HirelingNumber < Window_Base
  #--------------------------------------------------------------------------
  def initialize
    super(0, 128, 268, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.contents.font.color = normal_color
    @item = nil
    @max = 1
    @price = 0
    @number = 1
    @leadingcharacters = 5
    @itemdetail = []
     refresh2  
  end
  #--------------------------------------------------------------------------
   def set(item, max, price)
    @item = item  
    @max = max
    @price = price
    @number = 1
    refresh
  end
  #--------------------------------------------------------------------------
def refresh2
   self.contents.font.name = $fontface
   self.contents.font.size = $fontsize
   self.contents.font.color = normal_color
   self.contents.clear
end
  #--------------------------------------------------------------------------
def refresh
   item_id = $currenthighlighteditem.id  
     self.contents.clear
    draw_item_name(@item, 0, 0)    
    domination = $data_system.words.gold
    cx = contents.text_size(domination).width
    total_price = @price * 1
    self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(332-cx, 160, cx, 32, domination, 2)
      get_item_detail(item_id)
   write_item_detail(5, 223)
end
  #--------------------------------------------------------------------------
def get_item_detail(item_id)
   descarray =
   [
   item_id * 7,
   item_id * 7 + 1,
   item_id * 7 + 2,
   item_id * 7 + 3,
   item_id * 7 + 4,
   item_id * 7 + 5,
   item_id * 7 + 6
   ]
     f = File.open("Data/Hireling.rxdata")
   @itemdetail = f.readlines  
   for i in 0..6
     @itemdetail[i] = ""
   end
   for i in 0..6
     cropheadcharacters(descarray[i])
   end
   @description = []
   for i in 0..6
     @description[i] = @itemdetail[descarray[i]]
   end
   return
end
  #--------------------------------------------------------------------------
def cropheadcharacters(descarray)
   if @itemdetail[descarray] == nil
     @itemdetail[descarray] = "123456 "
   end
   @itemdetail[descarray].slice!(0..@leadingcharacters)
   return
end
  #--------------------------------------------------------------------------
def write_item_detail(x, y)
   self.contents.font.color = system_color
   self.contents.draw_text(x, y - 100, 640, 32, "Description:")
   self.contents.font.color = normal_color
   self.contents.font.size = $fontsize - 2
   for i in 0..5
     self.contents.draw_text(x, y - 80, 640, 32, @description[i])
     y += 18
   end
   self.contents.font.color = Color.new(255, 255, 0, 255)
   self.contents.draw_text(x, y-80, 640, 32, @description[6])
end
end



5) Window_HirelingStatus
Code:
class Window_HirelingStatus < Window_Base
    #--------------------------------------------------------------------------
  def initialize
    super(268, 128, 372, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
#---------------------------edit ---------------------------------
#---------------------------edit/ ---------------------------------
    @item = nil
   refresh
  end
  #--------------------------------------------------------------------------
    def refresh        
  self.contents.clear  
    #---------------------------edit ---------------------------------  
     if @item == nil
      return
    end
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize    
    @actor = $game_actors[$game_party.hireling(@item.id)]      
    #---------------------------edit/ ---------------------------------  
    draw_actor_class(@actor, 0, 0)
    draw_actor_level(@actor, 170, 0)  
    draw_actor_hp(@actor, 0, 22, 172)
    draw_actor_sp(@actor, 0, 44, 172)
    draw_actor_parameter(@actor, 0, 66, 0)
    draw_actor_parameter(@actor, 0, 88, 1)
    draw_actor_parameter(@actor, 0, 110, 2)
    draw_actor_parameter(@actor, 0, 132, 3)
    draw_actor_parameter(@actor, 0, 154, 4)
    draw_actor_parameter(@actor, 0, 176, 5)
    draw_actor_parameter(@actor, 0, 198, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(0, 220, 140, 32, "Expérience : ")
    self.contents.draw_text(0, 244, 160, 32, "Niveau suivant : ")
    self.contents.font.color = normal_color
    self.contents.draw_text(0 + 140, 220, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(0 + 160, 244, 84, 32, @actor.next_rest_exp_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(170, 22, 196, 32, "Equipement : ")
    draw_item_name($data_weapons[@actor.weapon_id], 170, 44)
    draw_item_name($data_armors[@actor.armor1_id], 170, 66)
    draw_item_name($data_armors[@actor.armor2_id], 170, 88)
    draw_item_name($data_armors[@actor.armor3_id], 170, 110)
    draw_item_name($data_armors[@actor.armor4_id], 170, 132)
  end  
   #--------------------------------------------------------------------------
  def item=(item)  
    if @item != item
      @item = item
      refresh
      end
    end  
  end



6) Window_HirelingNone
Code:
class Window_HirelingNone < Window_Base


def initialize
   super(0, 128, 640, 352)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = $fontface
   self.contents.font.size = $fontsize
   self.contents.font.color = normal_color
   @itemdetail = []
   refresh2  
end

def refresh2
   self.contents.font.name = $fontface
   self.contents.font.size = $fontsize
   self.contents.font.color = normal_color
   self.contents.clear
end

def refresh
   item_id = $currenthighlighteditem.id
     self.contents.font.color = Color.new(255, 255, 0, 255)
     self.contents.draw_text(10, 0, 300, 200, "Vous ne pouvez acheter plus de mercenaires", 2)
     self.contents.draw_text(0, 14, 400, 300, "Pour acheter plus de mercenaires vous devez éliminer des membres de votre équipe", 2)
   end
   # <-------------------------------------------------------------------->
    
end


7) Scene_PreHireling (v.2)
Code:
class Scene_PreHireling
    #--------------------------------------------------------------------------
    def initialize(call)
      @call = call
    end
    #--------------------------------------------------------------------------
   def main  
    @quantity = 0
    @spriteset = Spriteset_Map.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze  
    @spriteset.dispose
  end
    #--------------------------------------------------------------------------
  def update
    @spriteset.update
    case @call
    when 1 ######modifier vos magasin de mercenaires ici
    if !$game_party.hireling_checking(33)
    $game_party.hireling_shop(33,1)
  end
    if !$game_party.hireling_checking(34)
    $game_party.hireling_shop(34,1)
   end
   if !$game_party.hireling_checking(35)
    $game_party.hireling_shop(35,1)
    end
    when 2              
    if !$game_party.hireling_checking(33)
    $game_party.hireling_shop(33,1)
    end  
     when 3      
    if !$game_party.hireling_checking(34)
    $game_party.hireling_shop(34,1)
  end
    if !$game_party.hireling_checking(35)
    $game_party.hireling_shop(35,1)  
    end  
    when 4      
    end
    for i in 1...$data_items.size
      if $game_party.hireling_number(i) > 0
        @quantity += 1
      end
      end
      if @quantity >= 1
        $scene = Scene_Hireling.new
      else
        no_more
     end  
end
    #--------------------------------------------------------------------------
def no_more
   $game_temp.message_text = "Sorry, but I have no others mercenary fo you!"    
   $scene = Scene_Map.new  
end
end



-8) Game_Party ## à modifier
Code:
def initialize ## ajouter les deux lignes  
    @actors = []  
    @gold = 0
    @steps = 0  
    @items = {}
    @weapons = {}
    @armors = {}  

  #-------------------edit------------------  
    @hirelings = {}
    @hirelings_bought = {}

  #-------------------edit/------------------  

#-------------------------edit------------------------------------ (à ajouter après def lose_armor ou ailleurs)
def gain_hireling(hireling_id)  
   add_actor(hireling(hireling_id))
end

   #--------------------------------------------------------------------------
   def hireling(hireling_id)##définissez ici quel objet correpond à quel mercenaire
    case hireling_id
   when 33
   actor_id = 9
   when 34
     actor_id = 10
   when 35
    actor_id = 11
  end
  return actor_id
end

#--------------------------------------------------------------------------
   def hireling_shop(id,n)
    if id > 0
      @hirelings[id] = [[hireling_number(id) + n, 0].max, 1].min
      end  
  end
   #--------------------------------------------------------------------------
    def hireling_number(id)
    return @hirelings.include?(id) ? @hirelings[id] : 0
  end
     #--------------------------------------------------------------------------
    def hireling_check(id)
    @hirelings_bought[id] = 1
  end
    #--------------------------------------------------------------------------
    def hireling_checking(id)
    if hireling_checking_number(id) > 0
      return true
    else
      return false
      end
    end
    #--------------------------------------------------------------------------
    def hireling_checking_number(id)
    return @hirelings_bought.include?(id) ? @hirelings_bought[id] : 0
  end  
   #-------------------------edit/------------------------------------

  end



Pour l'utiliser, vous n'avez qu'à placer dans le menu item du database du jeu, les noms des mercenaires à acheter (ex: Wartug'h)
Ensuite, créez un évènement et insérez-y le scrîpt :
$scene = Scene_PreHireling.new(X)
X = numéro correspond au magasin à appeler (voir Scene_PreHireling)

Vous pouvez rajouter une description qui apparaîtra lorsque vous sélectionnez le mercenaire à acheter. Pour ce faire vous devez créé un fichier du nom de Hireling.rxdata que vous placer dans le répertoire de votre jeu dans le dossier data.

Exemple du contenu :
Code:
#0 Description 1
     Description 2
     Description 3
     Description 4
     Description 5
     Description 6
     Description 7
#1   Race : Orc
       Force : Combat de corps à corps                
       Faiblesse : Magie élémentale
       Arme préférée : Hache à deux mains
       Wartug'h fait partie de la tribu des Blo'dKyler
      
    
#2   Race : Humain
       Force : Magie blanche            
       Faiblesse : Résistance physique
       Arme préférée : Bâton
       Adolf vient de la région de Stronghold, il a étudié avec le
       le mage ...


Chaque description doit contenir 7 lignes, si vous avez moins de 7 lignes de texte, alors laissez des espaces. Le numéro qui suit le symbole "#" correspond à l'objet du menu item - 1 (Donc, si vous avez placé l'objet du nom Wartug'h à la position 9, placez votre description à côté de #8)

(Pour créer le fichier, aller dans le dossier data de votre répertoire de jeu, créez un nouveau document texte, insérez-y vos descriptions. Puis, faites enregistrez sous (dans le menu fichier). Ensuite, changez le type de fichier à tous les fichiers et écrivez le nom du fichier "Hireling.rxdata". Enregistrez et voilà.)

Auteur: Danny Coulombe
Créé le: 2007-12-15 23:00:46
Cette page a été vues: 4752 fois

Prenez le temps de visiter nos partenaires

Vidéos, OST, émulation Espace Emulation, le nonos de l'emulation ! Forum réservé pour makers, traitant de thème divers. iKara Rpg Maker Tout sur Kingdom Hearts, des actus, des soluces, des vidéos, des musiques et plus encore... Actualités RPG, astuces, soluce, download sur Final Fantasy, Dragon Quest et Kingdom Hearts de Square-Enix. Animes Naruto, FMA, Love Hina... Final Fantasy VII Origin est un RPG amateur dont le scénario précède FFVII. Téléchargeable gratuitement sur ce site. Rpg Maker Love dit RML c'est un ensemble de sites entretenus par Monos.

Ajouter aux favoris Ajouter à mes favoris
Abonnement à au bulletin d'informations Newsletters
Abonnement aux flux d'actualités RSS M'abonner aux flux RSS