Annuaire du RPG
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

Annuaire du RPG

Répertoire de ressources/scripts[...] pour le logiciel Rpg Maker !
 
AccueilAccueil  PortailPortail  Dernières imagesDernières images  RechercherRechercher  S'enregistrerS'enregistrer  ConnexionConnexion  
Le deal à ne pas rater :
Retour en stock du coffret Pokémon Zénith Suprême – ...
Voir le deal

 

 VX - Niveau pour équiper une arme

Aller en bas 
AuteurMessage
Neko
Fondateur
Fondateur
Neko


Messages : 184
Date d'inscription : 14/07/2013
Age : 25
Localisation : Ici, la plupart du temps.

VX - Niveau pour équiper une arme Empty
MessageSujet: VX - Niveau pour équiper une arme   VX - Niveau pour équiper une arme Icon_minitimeSam 27 Juil - 7:17

VX - Niveau pour équiper une arme


Auteur : Ayene

Screen ;
(Désolé, j'ai pas encore réussi à prendre un screen)


Code:

#===================================================================
# Equipment Requirements [VX]
# by Ayene
# 27.01.2010 ver 1.2
# www.ultimateam.pl
#===================================================================
# Opis:
# The script allows you to set requirements for weapon and armor.
# For instance, outfitting a hero with two-handed axe would be possible
# only after reaching a specific level or having adequate statistics.
# Also added an option that allows to require certain skills.
#
# Instruction:
# To use the script insert tag into the "Notes" box located in the
# Weapon or Armor tab of the database:
#  <stat_require LV, MAXHP, MAXMP, ATK, DEF, SPI, AGI>,
# where:
# LV - required actor's level
# MAXHP - maximum HP
# MAXMP - maximum MP
# ATK - Attack
# DEF - Defence
# SPI - Spirit
# AGI - Agility
#
# For example:
# If you want a character to equip a weapon at level 6, provided that
# it has 120 max HP, 40 Attack, 70 Defence,
# add in the specified weapon's "Note" box:
#  <stat_require 6, 120, 0, 40, 70, 0, 0>
#
# Next, to equip an armor, which "requires" adequate agility:
# <stat_require 0, 0, 0, 0, 0, 0, 50>
#
# To set that the specified armor can be equipped only after gaining
# certain skill(s), add in "Note" box:
# <skill_require ID, ID, ...>
# where:
# ID - required skill(s) ID(s)
 
# For example:
# To equip an weapon, that "requires" skills ID 10 and 40:
# <skill_require 10, 40>
#===================================================================
module AYENE
  module ItemSpec
    ITEM_SPEC = /<(?:STAT_REQUIRE|stat_require)\s*(\d+)\s*, \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+)>/i
    WEAPON_TEXT = "Pour équiper cette arme vous devez avoir:"
    ARMOR_TEXT = "Pour équiper cette armure vous devez avoir:"   
    ACC_TEXT = "Pour équiper cet accessoire vous devez avoir:"
    PARAM_NAMES = ["Niveau", "Max HP", "Max MP", "Attaqua", "Défense", "Intelligence", "Agilité", "Magie:"] 
    SKILL_SPEC = /<(?:SKILL_REQUIRE|skill_require)[ ]*(\d+(?:[ ]*,[ ]*\d+)*)>/i
    SHOW_SKILL_REC = true  # Show which skill is needed? (true/false)
  end
end
 
#===================================================================
# ** RPG::BaseItem
#===================================================================
class RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :spec_params
  #--------------------------------------------------------------------------
  # * Requirements Initialization
  #--------------------------------------------------------------------------
  def equip_req_ini
    @spec_params = {}
    (0..6).each{|i| @spec_params[i] = 0}
    @spec_params[7] = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when AYENE::ItemSpec::ITEM_SPEC
        @spec_params[0] = $1.to_i
        @spec_params[1] = $2.to_i
        @spec_params[2] = $3.to_i
        @spec_params[3] = $4.to_i
        @spec_params[4] = $5.to_i
        @spec_params[5] = $6.to_i
        @spec_params[6] = $7.to_i
      end
    }
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when AYENE::ItemSpec::SKILL_SPEC
        $1.scan(/\d+/).each { |num|
          skill_id = num.to_i
          @spec_params[7].push(skill_id) if $data_skills[skill_id] != nil
        }
      end
    }
  end
end
 
#===================================================================
# ** RPG::Weapon
#===================================================================
class RPG::Weapon < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Requirements Text
  #--------------------------------------------------------------------------
  def eqreq_text
    return AYENE::ItemSpec::WEAPON_TEXT
  end
end
 
#===================================================================
# ** RPG::Armor
#===================================================================
class RPG::Armor < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Requirements Text
  #--------------------------------------------------------------------------
  def eqreq_text
    case kind
    when 3
      return AYENE::ItemSpec::ACC_TEXT
    else
      return AYENE::ItemSpec::ARMOR_TEXT
    end 
  end
end
 
#===================================================================
# ** Game_Actor
#===================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Determine if Item can be Equipped (Actor's Parameters)
  #--------------------------------------------------------------------------
  def equip_allowed?(item)
    return true if (item.spec_params[0] <= level && item.spec_params[1] <= base_maxhp &&
    item.spec_params[2] <= base_maxmp && item.spec_params[3] <= base_atk &&
    item.spec_params[4] <= base_def && item.spec_params[5] <= base_spi &&
    item.spec_params[6] <= base_agi) && equip_skill_allowed?(item)
    return false
  end
  #--------------------------------------------------------------------------
  # * Determine if Item can be Equipped (Actor's Skills )
  #--------------------------------------------------------------------------
  def equip_skill_allowed?(item) 
    item.spec_params[7].each{|skill_id|
      return false if !skill_learn?($data_skills[skill_id]) 
    }
    return true
  end
end
 
#===================================================================
# ** Game_Interpreter
#===================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Aliased Definitions
  #--------------------------------------------------------------------------
  alias aye_eqreq_command_315 command_315
  alias aye_eqreq_command_316 command_316
  alias aye_eqreq_command_317 command_317
  alias aye_eqreq_command_318 command_318
  #--------------------------------------------------------------------------
  # * Check Equipment
  #      actor    : actor
  #--------------------------------------------------------------------------
  def check_change_equip(actor)
    for i in 0..4
      item = actor.equips[i]
      actor.change_equip(i, nil) if !item.nil? && !actor.equip_allowed?(item)
    end
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  def command_315
    aye_eqreq_command_315
    iterate_actor_id(@params[0]) do |actor|
      check_change_equip(actor) 
    end 
  end
  #--------------------------------------------------------------------------
  # * Change Level
  #--------------------------------------------------------------------------
  def command_316
    aye_eqreq_command_316
    iterate_actor_id(@params[0]) do |actor|
      check_change_equip(actor) 
    end
  end 
  #--------------------------------------------------------------------------
  # * Change Parameters
  #--------------------------------------------------------------------------
  def command_317
    aye_eqreq_command_317
    iterate_actor_id(@params[0]) do |actor|
      check_change_equip(actor) 
    end
  end 
  #--------------------------------------------------------------------------
  # * Change Skills
  #--------------------------------------------------------------------------
  def command_318
    aye_eqreq_command_318
    iterate_actor_id(@params[0]) do |actor|
      check_change_equip(actor) 
    end
  end
end
 
#===================================================================
# ** Window_EquipReq
#===================================================================
class Window_EquipReq < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #      item    : item
  #      data    : parameters (array)
  #      actor    : actor
  #      skill    : skill
  #--------------------------------------------------------------------------
  def initialize(item, data, actor, skill) 
    if skill.empty? or !AYENE::ItemSpec::SHOW_SKILL_REC
      height = (data.size+1) / 2 * WLH + WLH + 32
    else
      height = (data.size+1) / 2 * WLH + WLH + 32 + WLH * [skill.size, 7].min
    end   
    super(42, 180 - height/2, 460, height)
    self.back_opacity = 255
    self.contents.font.color = crisis_color
    self.contents.draw_text(4, 0, self.width - 40, WLH, item.eqreq_text, 1)
    x = 10
    y = WLH 
    data.each_with_index{|array, i| 
      self.contents.font.color = system_color
      self.contents.draw_text(x+i%2*240, y+i/2*WLH, 200, WLH, AYENE::ItemSpec::PARAM_NAMES[array[0]].to_s, 0)   
      self.contents.font.color = normal_color
      self.contents.draw_text(x+120+i%2*240, y+i/2*WLH, 40, WLH, array[1].to_s, 2)
    }
    if !skill.empty? and AYENE::ItemSpec::SHOW_SKILL_REC
      size = (data.size+1)/2*WLH
      self.contents.font.color = system_color
      self.contents.draw_text(x, y+size, 200, WLH, AYENE::ItemSpec::PARAM_NAMES[7].to_s, 0) 
      self.contents.font.color = normal_color
      skill.each_with_index{|id, i|   
        self.contents.draw_text(x+140, y+size+WLH*i, 200, WLH, "- #{$data_skills[id].name}", 0)     
      }
    end
  end
end
 
#===================================================================
# ** Window_EquipItem
#===================================================================
class Window_EquipItem < Window_Item
  #--------------------------------------------------------------------------
  # * Determine if item is enabled
  #--------------------------------------------------------------------------
  def enable?(item)
    return @actor.equip_allowed?(item)
  end
end
 
#===================================================================
# ** Scene_Title
#===================================================================
class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Aliased Definitions
  #--------------------------------------------------------------------------
  alias aye_eqreq_sctit_loaddata load_database
  #--------------------------------------------------------------------------
  # * Load Database (aliased)
  #--------------------------------------------------------------------------
  def load_database
    aye_eqreq_sctit_loaddata
    for group in [$data_weapons, $data_armors]
      for obj in group
        next if obj.nil?
        obj.equip_req_ini
      end
    end
  end
end
 
#===================================================================
# ** Scene_Equip
#===================================================================
class Scene_Equip < Scene_Base
  #--------------------------------------------------------------------------
  # * Aliased Definitions
  #--------------------------------------------------------------------------
  alias aye_eqreq_sceq_update update
  alias aye_eqreq_sceq_upditsel update_item_selection
  #--------------------------------------------------------------------------
  # * Update Frame (aliased)
  #--------------------------------------------------------------------------
  def update     
    if @eqreq_window != nil
      update_eqreq_window
    else
      aye_eqreq_sceq_update
    end   
  end 
  #--------------------------------------------------------------------------
  # * Update Item Selection (aliased)
  #--------------------------------------------------------------------------
  def update_item_selection
    @item = @item_window.item
    if @item != nil and !@actor.equip_allowed?(@item) and Input.trigger?(Input::C)
      Sound.play_buzzer
      @item_window.active = false   
      show_eqreq_window
    else
      aye_eqreq_sceq_upditsel
    end       
  end 
  #--------------------------------------------------------------------------
  # * Show Requirements Window
  #--------------------------------------------------------------------------
  def show_eqreq_window
    @frame = 0
    data = []
    @item.spec_params.each {|type, value|         
      data.push([type, value]) if value > 0 if type < 7 
    }
    data.sort!{|a,b| a[0] <=> b[0]} 
    skill = @item.spec_params[7] 
    @eqreq_window = Window_EquipReq.new(@item, data, @actor, skill)     
  end
  #--------------------------------------------------------------------------
  # * Update Requirements Window
  #--------------------------------------------------------------------------
  def update_eqreq_window
    @frame < 200 ? @frame += 1 : @frame = 0
    if @frame == 200 or Input.trigger?(Input::C) or Input.trigger?(Input::B)
      @eqreq_window.dispose
      @eqreq_window = nil   
      @item_window.active = true   
    end
  end
end
 

UTILISATION : Dans tes armes; tu mets par exemple ( BDD )

Code:
<stat_require 8, 1, 2, 3, 4, 5, 6>


  • 8 représente le niveau nécessaire
  • 1 représente MAX HP
  • 2 représente MAX MP
  • 3 représente attaque
  • 4 représente défense
  • 5 représente intelligence
  • 6 représente agilité


Pour faire que par niveau on met par exemple pour un niveau 5.
Code:
<stat_require 5, 0, 0, 0, 0, 0, 0>

Revenir en haut Aller en bas
https://annuairedurpg.1fr1.net
 
VX - Niveau pour équiper une arme
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» [ RPG Maker XP ] S'équiper de deux armes et/ou d'une arme à deux mains
» [RPG MAKER XP ] Afficher le niveau des héros
» GTBSv2 pour VX Ace Rel 1.1 v2.0
»  Combat à la souris pour VX
» 505 Battlers pour SBS ( Final Fantasy IV, V et VI )

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Annuaire du RPG :: RPG maker & co :: Scripts :: RGSS 2 :: Autres-
Sauter vers: