AccueilAccueil  PortailPortail  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  ConnexionConnexion  



-15%
Le deal à ne pas rater :
(Adhérents Fnac) LEGO® Star Wars™ 75367 Le croiseur d’assaut de ...
552.49 € 649.99 €
Voir le deal

Partagez
 

 [VX] Objet utilisable seulement par un/des persos en combat (compatible SBS)

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Invité
Invité
avatar



[VX] Objet utilisable seulement par un/des persos en combat (compatible SBS) Empty
MessageSujet: [VX] Objet utilisable seulement par un/des persos en combat (compatible SBS)   [VX] Objet utilisable seulement par un/des persos en combat (compatible SBS) Icon_minitimeVen 30 Mar 2012 - 20:03

Bonjour/bonsoir,

Il y a quelque temps j'avais demandé un script pour une utilisation d'objet seulement par un ou des persos en combat.
S4suk3 en avait fais un qui fonctionne bien mais qui n'est malheureusement pas compatible avec le SBS (chez moi en tout cas). Ne voulant pas trop le déranger encore et encore j'ai fais mes propres recherches en Anglais. Alors voiçi un script qui le permettra en combat.
Un script de : Mythran

Code:
# Exclude an actor or class from an item effect
# By Mithran
# Please do not resdistribute without asking!
# This restricts item usage of actors.
# In battle, this prevents any excluded actors or classes from using or being
# targeted by the item.
# In the menu screen, this will prevent the item from being used at all if none
# of the targets can be affected by it.

# Type <NO ACTOR n> in the notes field of an item where n is the actor id of
# the actor you want to exclude from the item effect
# Type <REQ ACTOR n> in the notes field of an item where n is the actor id of
# the actor you want to REQUIRE for the item effect
# Seperate multiple actor ids with commas

# Example:
# <NO ACTOR 1, 2, 4>
# The item would have no effect on Ralph, Ulrika, and Ylva.
# <REQ ACTOR 3>
# The item would only effect Bennett.

# Type <NO CLASS n> in the notes field of an item where n is the class id of
# the class you want to exclude from the item effect
# Type <REQ CLASS n> in the notes field of an item where n is the class id of
# the class you want to REQUIRE for the item effect
# Seperate class actor ids with commas

# <NO CLASS 1, 3>
# The item would have no effect on Paladins or Priests.
# <REQ CLASS 6>
# The item would only affect Dark Knights.

# If you restrict by both actor and class, BOTH will be required to get the item
# to work.

# ALL CAPS is required for these note tags

class Game_Battler
  alias item_effect_exclude_actor item_effect
  def item_effect(user, item)
    if actor?
      if item.exclude_actor(self)
        clear_action_results
        if $game_temp.in_battle
          @missed = true
          # so the failure message will display
        else
          @skipped = true
          # so the item will buzz and not be consumed
        end
        return
      end
    end
    item_effect_exclude_actor(user, item)
  end
 
end   
     
     
class RPG::Item
  def actor_exclude_list
    if note =~ /<NO\s?ACTOR\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end

  def class_exclude_list
    if note =~ /<NO\s?CLASS\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end
 
  def actor_require_list
    if note =~ /<REQ\s?ACTOR\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end

  def class_require_list
    if note =~ /<REQ\s?CLASS\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end
 
  def exclude_actor(actor)
    return true if !actor.is_a?(Game_Actor)
    return actor_exclude_list.include?(actor.id) || class_exclude_list.include?(actor.class_id) ||
      (!actor_require_list.empty? && !actor_require_list.include?(actor.id)) ||
      (!class_require_list.empty? && !class_require_list.include?(actor.class_id))
  end
 
end

class Scene_Battle < Scene_Base
  alias update_item_selection_exclude_actor update_item_selection
  def update_item_selection
    actor = @active_battler
    actor = @commander if @commander
    $game_temp.acs_item_selector = actor
    if @item_window != nil && @item_window.item != nil && @item_window.item.exclude_actor(actor) && Input.trigger?(Input::C)
      Sound.play_buzzer
      $game_temp.acs_item_selector = nil
      return
    end
    update_item_selection_exclude_actor
    $game_temp.acs_item_selector = nil
  end
 
  alias start_item_selection_exclude_actor start_item_selection
  def start_item_selection
    actor = @active_battler
    actor = @commander if @commander
    $game_temp.acs_item_selector = actor
    start_item_selection_exclude_actor
    $game_temp.acs_item_selector = nil
  end
 
  alias update_target_actor_selection_exclude_actor update_target_actor_selection
  def update_target_actor_selection
    if @item_window != nil && @item_window.item != nil && Input.trigger?(Input::C)
      actor = $game_party.members[@target_actor_window.index]
      if @item_window.item.exclude_actor(actor)
        Sound.play_buzzer
        return
      end
    end
    update_target_actor_selection_exclude_actor
  end

end

class Window_Item < Window_Selectable
  alias enable_exclude_actor enable?
  def enable?(item)
    return false if item != nil && $game_temp.in_battle && item.exclude_actor($game_temp.acs_item_selector)
    return enable_exclude_actor(item)
  end
end

class Game_Temp
  attr_accessor :acs_item_selector
end
Revenir en haut Aller en bas
 

[VX] Objet utilisable seulement par un/des persos en combat (compatible SBS)

Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

 Sujets similaires

-
» Affichage du nombre d'un objet sur la map (seulement si equip)
» Script pourcentage de chance d'obtention d'objet en combat
» Combat : Plus d'attaque et plus de se protéger,mais que Compétences et objet .
» Objet rendant surpuissant durant 1 combat. [Débutant/Moyen]
» Objets utilisable par une seule personne

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
RPG Maker VX :: Entraide :: Scripts :: Scripts VX - RGSS2 :: Combat-
Créer un forum | ©phpBB | Forum gratuit d'entraide | Signaler un abus | Forum gratuit