Aller en bas
crackerwood
crackerwood
Membre

Nombre de messages : 364
Age : 39
Localisation : Derrière son pc y parait
Distinction : aucune
Date d'inscription : 03/08/2008

Ciblage héros/ennemis Empty Ciblage héros/ennemis

Sam 19 Mai 2012 - 17:42
Script pouvant faire en sorte de cibler les alliés ou ennemis.
Auteur : Inconnu
Code:
#
# Window_Selectable is the closest ancestor of Window_BattleActor
# and Window_BattleEnemy.
#
class Window_Selectable

  #
  # Alias the update method to check and see if
  # the user has pressed the key to change the targeting.
  #
  alias_method :ft_orig_update, :update
  def update
        ft_orig_update
        check_targeting_change_ft
  end

  #
  # Call the target_change closure (a method in Scene_Battle) if the user
  # pressed the Q key, and self is an instance of Window_BattleActor
  # or Window_BattleEnemy.
  #
  def check_targeting_change_ft
        if Input.trigger?(Input::L) && (self.is_a?(Window_BattleActor) ||
                              self.is_a?(Window_BattleEnemy))
          call_handler(:target_change)
        end
  end
end
#
# The changes to Scene_Battle are mostly for creating the hook that will
# see if the user pressed the target change key, and window management.
#
class Scene_Battle

  #
  # Alias this method and set the @actor_window target_change callback.
  #
  alias_method :ft_orig_create_actor_window, :create_actor_window
  def create_actor_window
        ft_orig_create_actor_window
        @actor_window.set_handler(:target_change,  method(:on_target_change_ft))
  end

  #
  # Add a check to see if the command that initiated the actor cancel
  # is attack, which is now a possiblity. If it is attack, activate the
  # actor command window.
  #
  alias_method :ft_orig_on_actor_cancel, :on_actor_cancel
  def on_actor_cancel
        ft_orig_on_actor_cancel
        if @actor_command_window.current_symbol == :attack
          @actor_command_window.activate
        end
  end

  #
  # Resets the target_change_ft flag to nil when the player goes back to
  # a previous character.
  #
  alias_method :ft_orig_prior_command, :prior_command
  def prior_command
        ft_orig_prior_command
        unless BattleManager.actor.nil?
          action = BattleManager.actor.actions.first
          action.target_change_ft = nil
        end
  end

  #
  # The callback method that gets called when the user toggles friendly or
  # enemy targeting. Depending on whether @actor_window or @enemy_window is
  # active, deactivate and hide the other window and change the item scope
  # to it's opposite.
  #
  def on_target_change_ft
        if @actor_window.active
          @actor_window.deactivate
          @actor_window.hide
          select_enemy_selection
          set_change_flag_ft
        elsif @enemy_window.active
          @enemy_window.deactivate
          @enemy_window.hide
          select_actor_selection
          set_change_flag_ft
        end
  end

  #
  # Sets the target_change_ft flag to the opposite value of what
  # it is currently set to.
  #
  def set_change_flag_ft
        action = BattleManager.actor.actions.first
        unless @actor_command_window.current_symbol == :guard
          action.target_change_ft = !action.target_change_ft
        end
  end
end
#
# Target calculation happens in Game_Action. The basic idea is to
# see if an action object has been flagged for a targeting change (which
# means it will target the opposite of what it normally targets) and
# then temporarily change the scope for the item/skill/attack associated
# with the action.
#
class Game_Action
  attr_accessor :target_change_ft  # @target_change_ft is the change flag.

  #
  # If the @target_change_ft flag is true, then do the opposite target
  # calculation to what the item is normally used for.
  #
  alias_method :ft_orig_make_targets, :make_targets
  def make_targets
        if @target_change_ft && item.for_opponent?
          return targets_for_friends
        elsif @target_change_ft && item.for_friend?
          return targets_for_opponents
        end
        ft_orig_make_targets
  end

  #
  # targets_for_friends and targets_for_opponents create a new
  # fake Game_BaseItem like object that will hold a new UsableItem object
  # that in turn holds the scope change. The original item object is
  # not affected.
  #

  alias_method :ft_orig_targets_for_friends, :targets_for_friends
  def targets_for_friends
        @item = new_item_object_ft unless @target_change_ft.nil?
        ft_orig_targets_for_friends
  end

  alias_method :ft_orig_targets_for_opponents, :targets_for_opponents
  def targets_for_opponents
        @item = new_item_object_ft unless @target_change_ft.nil?
        ft_orig_targets_for_opponents
  end
 
  #
  # Creates a placeholder to use instead of the standard Game_BaseItem
  # object that an action has. By doing this we can change the scope
  # without affecting the normal item object (which is baaad!).
  #
  def new_item_object_ft
        new_item = FakeBaseItem_FT.new(RPG::UsableItem.new)
        new_item.object.scope = get_opposite_scope_ft(@item.object.scope)
        new_item
  end
 
  #
  # Returnes the opposite scope. The scope codes can be found
  # in the help file.
  #
  def get_opposite_scope_ft(scope)
        case scope
        when 1
          7
        when 2
          8
        when 3
          7        # look in to this (dual skill might not work)
        when 4, 5, 6
          7
        when 7
          1
        when 8
          2
        when 9
          1
        when 10
          2
        when 11
          1
        end
  end
end

#
# @object holds an instance of RPG::UsableItem that we can use to
# set the new scope on.
#
class FakeBaseItem_FT
  attr_reader :object

  def initialize(object)
        @object = object
  end
end

Le script ne permet pas de cibler un seul ou plusieurs alliés/ennemis. Il permet seulement de choisir entre les alliés/ennemis.

DarkHeroe
DarkHeroe
Membre

Nombre de messages : 190
Age : 24
Localisation : Reunion Island
Distinction : aucune
Date d'inscription : 17/12/2011

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Sam 19 Mai 2012 - 20:49
Merci du partage Wink
Shadow-clad
Shadow-clad
Membre

Nombre de messages : 510
Age : 33
Localisation : A durbuy normal j'en suis le maire ! ^^
Distinction : Survivant ultime de Koh Lanta : Erem Vehyx 2010
[Denis Coco' Smile]
Date d'inscription : 18/06/2010
http://redmoonlight.forumgratuit.org/forum.htm

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Dim 20 Mai 2012 - 0:46
merci du partage je vais voir de ce pas si il est compatible avec mon sbs.
Gummy
Gummy
Staffeux retraité

Nombre de messages : 2666
Age : 32
Localisation : Belgique
Distinction : Modérateur imprévisible

Papy Lolo' [Nabots Nimousse]


Date d'inscription : 27/01/2008

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Dim 20 Mai 2012 - 12:24
Merci, +1 pt de participation Smile
Dany
Dany
Membre

Nombre de messages : 784
Age : 27
Distinction : aucune
Date d'inscription : 16/11/2010
http://gamers-studio.forumofficiel.fr/

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Jeu 12 Juil 2012 - 16:40
Il marche pas c'est normal? Car j'ai mis au dessus main puis au dessus matérials mais rien a faire je peux pas sélectionner des alliés!
Sois sa permet pas de sélectionner Allié/Monstre mais a autre chose mais j'ai rien capter!
Nozvez
Nozvez
Membre

Nombre de messages : 354
Distinction : aucune
Date d'inscription : 16/03/2012

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Jeu 12 Juil 2012 - 16:44
Le script ne permet pas de cibler un seul ou plusieurs alliés/ennemis. Il permet seulement de choisir entre les alliés/ennemis.
Dany
Dany
Membre

Nombre de messages : 784
Age : 27
Distinction : aucune
Date d'inscription : 16/11/2010
http://gamers-studio.forumofficiel.fr/

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Ven 13 Juil 2012 - 17:00
Comment ça je comprend pas! Je croit que si je prend une potion je peux le donner c'est ça?
crackerwood
crackerwood
Membre

Nombre de messages : 364
Age : 39
Localisation : Derrière son pc y parait
Distinction : aucune
Date d'inscription : 03/08/2008

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Mer 18 Juil 2012 - 21:38
Je t'explique. Si tu as une magie qui touche un ennemi tu peux faire en sorte que ca touche un personnage. Ce script ne permet pas de choisir entre un ou tous. Ca fonctionne qu'à partir de ce que tu as mis dans base de données seulment.
Dany
Dany
Membre

Nombre de messages : 784
Age : 27
Distinction : aucune
Date d'inscription : 16/11/2010
http://gamers-studio.forumofficiel.fr/

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Ven 20 Juil 2012 - 10:13
A ok! Merci!
Wingstock
Wingstock
Membre

Nombre de messages : 3
Distinction : aucune
Date d'inscription : 12/10/2014

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Lun 13 Oct 2014 - 1:13
J'ai trouvé un léger bug dans ce script.

J'explique : je sélectionne "Attaque", je cible l'ennemi, j'appuie sur Page Up pour passer à la sélection des alliés, puis j'appuie à nouveau sur Page Up pour retourner à la sélection des ennemis. Et là quand je valide ma cible, l'attaque est lancée contre mon héros et non contre l'ennemi ciblé.

C'est un bug ou une mauvais manip de ma part ?
Contenu sponsorisé

Ciblage héros/ennemis Empty Re: Ciblage héros/ennemis

Revenir en haut
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum