[résolu]Mon héro recule quand il fait "se défendre"
Ven 24 Jan 2014 - 18:28
Salut !
Alors je n'avais jamais remarqué jusque là mais, quand j'utilise la commande "se défendre", mon perso recule mais ne revient pas à sa position de départ...
voici le scripte que j'utilise pour les combats, si ça peut aider :
Alors je n'avais jamais remarqué jusque là mais, quand j'utilise la commande "se défendre", mon perso recule mais ne revient pas à sa position de départ...
voici le scripte que j'utilise pour les combats, si ça peut aider :
- Code:
#===============================================================================
# Jet's Viewed Battle System
# By Jet10985(Jet)
#===============================================================================
# This script will add actor sprites into the battle scene.
# This script has: 10 customization options.
#===============================================================================
# Overwritten Methods:
# Game_Actor: use_sprite?, screen_x, screen_y
# Sprite_Battler: revert_to_normal
# Scene_Battle: show_attack_animation
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Enemy: screen_x, screen_y
# Sprite_Battler: update_origin, update_bitmap
# Window_BattleEnemy: update
# Window_BattleActor: update
# Window_ActorCommand: update
#===============================================================================
=begin
Set an enemy's attack animation by using this in their notebox:
<anim: 50>
Replace 50 with the animation id.
--------------------------------------------------------------------------------
You may use a sprite for a monster instead of a regular battler by using this
notetag in the monster's notebox:
<sprite: ImageName, 0>
Replace ImageName with the name of the spritesheet, and 0 with the index on the
spritesheet you want the monster to use.
=end
module Jet
module VBS
# Which direction do actors face on the field? There are 4 options:
# :up, :down, :left, or :right. Actor's will direction chosen.
ACTOR_ORIENTATION = :left
# This will make it so actor's are centered on the screen instead of being
# placed in pre-determined lines using START_POINT and SPACE_DIFFERENCE.
CENTER_ACTORS = false
# This is the x and y starting point for actors. This option may take one of
# 2 functions. If CENTER_ACTORS is true, and ACTOR_ORIENTATION is either
# :left, or :right, then only the x value will be used as where to center
# the actors. If it is :down or :up, only the y value will be used.
# If CENTER_ACTORS is false, then this is where actor's will begin to be
# placed on screen.
START_POINT = [400, 221]
# This is how much space is between each actor on the field.
SPACE_DIFFERENCE = 22
# If you're using the :left or :right view, this will push each
# subsequent actor back by a certain number of pixels, to avoid having
# a straight line.
SIDEVIEW_PUSH_BACK = 16
# Do you want to reverse the direction and field during an ambush?
# (This is when enemies surprise the player and get the first turn)
REVERSE_FIELD_FOR_AMBUSH = false
# this is how far the actor will move forward when they are selection an
# action, as well as executing it.
SLIDE_AMOUNT = 50
# This is how far the actor will slide each frame until they reach their
# goal of SLIDE_FORWARD. Best used when this is a factor of SLIDE_FORWARD.
FRAME_SLIDE = 6
# During selecting an actor command, and during selecting an enemy target,
# would you like the selected character to flash?
DO_FLASH = false
# These are state-based sprite changes. If the actor has one of these states
# then the game will search for a sprite of the character's regular sprite
# name with the special state tag appended to it. So if Jimmy's sprite
# name was $Jimmy, and he had poison inflcted on him, and poison's id was
# listed here as ["_poison", 0], it would change Jimmy's in-battle sprite
# to $Jimmy_poison at the first sprite index.
STATE_SPRITES = {
1 => ["", 0],
2 => ["", 0]
}
# Do not touch this option.
DIR_ORIENT = {right: 6, left: 4, down: 2, up: 8}[ACTOR_ORIENTATION]
end
end
#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Integer
def even?
self % 2 == 0
end
def odd?
!even?
end
end
class RPG::Enemy
def animation
(f = note.match(/<anim:[ ]*(\d+)>/i)) ? f[1].to_i : 1
end
def battle_sprite
(f = note.match(/<sprite:[ ]*(.+),[ ]*(\d+)>/i)) ? f[1..2] : false
end
end
module BattleManager
class << self
alias jet3845_on_encounter on_encounter
def on_encounter(*args, &block)
jet3845_on_encounter(*args, &block)
@true_surprise = @surprise
end
end
def self.true_surprise
@true_surprise ||= false
end
def self.player_dir
if @true_surprise && Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
return 10 - Jet::VBS::DIR_ORIENT
else
return Jet::VBS::DIR_ORIENT
end
end
end
class Game_Actor
def use_sprite?
true
end
def screen_x
if [8, 2].include?(BattleManager.player_dir)
if Jet::VBS::CENTER_ACTORS
x = Graphics.width / 2
x -= 16
x += Jet::VBS::SPACE_DIFFERENCE / 2 if $game_party.members.size.even?
x -= ($game_party.members.size / 2 - index) * Jet::VBS::SPACE_DIFFERENCE
return x
else
return Jet::VBS::START_POINT[0] + Jet::VBS::SPACE_DIFFERENCE * index
end
end
return Jet::VBS::START_POINT[0]
end
alias jet3745_screen_x screen_x
def screen_x(*args, &block)
x = jet3745_screen_x(*args, &block)
case BattleManager.player_dir
when 4
x += Jet::VBS::SIDEVIEW_PUSH_BACK * index
when 6
x -= Jet::VBS::SIDEVIEW_PUSH_BACK * index
end
return x if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
x = Graphics.width - x if BattleManager.true_surprise && [6, 4].include?(BattleManager.player_dir)
x
end
def screen_y
if [6, 4].include?(BattleManager.player_dir)
if Jet::VBS::CENTER_ACTORS
y = Graphics.height / 2
y -= 16
y += Jet::VBS::SPACE_DIFFERENCE / 2 if $game_party.members.size.even?
y -= ($game_party.members.size / 2 - index) * Jet::VBS::SPACE_DIFFERENCE
return y
else
return Jet::VBS::START_POINT[1] + Jet::VBS::SPACE_DIFFERENCE * index
end
end
return Jet::VBS::START_POINT[1]
end
alias jet3745_screen_y screen_y
def screen_y(*args, &block)
y = jet3745_screen_y(*args, &block)
return y if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
y = Graphics.height - y if BattleManager.true_surprise && [8, 2].include?(BattleManager.player_dir)
y
end
def screen_z
101 + index
end
alias jet3745_character_name character_name
def character_name(*args, &block)
name = jet3745_character_name(*args, &block)
return name unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return name + add[0]
end
}
return name
end
alias jet3745_character_index character_index
def character_index(*args, &block)
index = jet3745_character_index(*args, &block)
return index unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return index + add[1]
end
}
return index
end
end
class Game_Enemy
alias jet3745_screen_x screen_x
def screen_x(*args, &block)
x = jet3745_screen_x(*args, &block)
return x if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
x = Graphics.width - x if BattleManager.true_surprise && [6, 4].include?(BattleManager.player_dir)
x
end
alias jet3745_screen_y screen_y
def screen_y(*args, &block)
y = jet3745_screen_y(*args, &block)
return y if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
y = Graphics.height - y if BattleManager.true_surprise && [8, 2].include?(BattleManager.player_dir)
y
end
def atk_animation_id1
enemy.animation
end
def atk_animation_id2
0
end
def bat_sprite?
!!enemy.battle_sprite
end
def character_name
enemy.battle_sprite[0]
end
def character_index
enemy.battle_sprite[1].to_i
end
alias jet3745_character_name character_name
def character_name(*args, &block)
name = jet3745_character_name(*args, &block)
return name unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return name + add[0]
end
}
return name
end
alias jet3745_character_index character_index
def character_index(*args, &block)
index = jet3745_character_index(*args, &block)
return index unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return index + add[1]
end
}
return index
end
end
class Sprite_Battler
alias jet3835_update_bitmap update_bitmap
def update_bitmap(*args, &block)
if @battler.actor? || @battler.bat_sprite?
actor_update_bitmap
elsif @battler.enemy?
jet3835_update_bitmap(*args, &block)
end
end
def actor_update_bitmap
@timer ||= 0
@index ||= 1
@char_index ||= @battler.character_index
@back_time ||= false
index = @index
char_index = @char_index
@timer += 1
(@index += (@back_time ? -1 : 1); @timer = 0) if @timer == 19
if @index == 3
@back_time = true
@index = 1
elsif @index == -1
@back_time = false
@index = 1
end
@char_index = @battler.character_index
bitmap = Cache.character(@battler.character_name)
return if bitmap == @bitmap && index == @index && @char_index == char_index
self.bitmap = bitmap
sign = @battler.character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
dir = BattleManager.player_dir
dir = 10 - dir if @battler.is_a?(Game_Enemy)
sx = (@battler.character_index % 4 * 3) * cw + (cw * @index)
sy = (@battler.character_index / 4 * 4 + (dir - 2) / 2) * ch
self.src_rect.set(sx, sy, cw, ch)
end
alias jet3745_update_origin update_origin
def update_origin(*args, &block)
if @battler.actor? || @battler.bat_sprite?
actor_update_origin
elsif @battler.enemy?
jet3745_update_origin(*args, &block)
end
end
def actor_update_origin
self.ox = (@actor_ox ||= 0)
self.oy = (@actor_oy ||= 0)
end
def revert_to_normal
self.blend_type = 0
self.color.set(0, 0, 0, 0)
self.opacity = 255
if bitmap && @battler && !@battler.actor? && !@battler.bat_sprite?
self.ox = bitmap.width / 2 if bitmap
self.src_rect.y = 0
end
end
def slide_forward(amount = Jet::VBS::SLIDE_AMOUNT, frame = Jet::VBS::FRAME_SLIDE)
dir = BattleManager.player_dir
dir = 10 - dir if @battler.is_a?(Game_Enemy)
case dir
when 2
affect = :@actor_oy
frame *= -1
when 4
affect = :@actor_ox
amount *= -1
when 6
affect = :@actor_ox
frame *= -1
when 8
affect = :@actor_oy
amount *= -1
end
orig_amount = amount
until (orig_amount < 0 ? amount >= 0 : amount <= 0)
instance_variable_set(affect, instance_variable_get(affect) + frame)
amount += frame
SceneManager.scene.spriteset.update
Graphics.update
end
end
def slide_backward(amount = Jet::VBS::SLIDE_AMOUNT, frame = Jet::VBS::FRAME_SLIDE)
dir = BattleManager.player_dir
dir = 10 - dir if @battler.is_a?(Game_Enemy)
case dir
when 2
affect = :@actor_oy
amount *= -1
when 4
affect = :@actor_ox
frame *= -1
when 6
affect = :@actor_ox
amount *= -1
when 8
affect = :@actor_oy
frame *= -1
end
orig_amount = amount
until (orig_amount < 0 ? amount >= 0 : amount <= 0)
instance_variable_set(affect, instance_variable_get(affect) + frame)
amount += frame
SceneManager.scene.spriteset.update
Graphics.update
end
end
end
class Scene_Battle
attr_reader :spriteset
def show_attack_animation(targets)
show_normal_animation(targets, @subject.atk_animation_id1, false)
show_normal_animation(targets, @subject.atk_animation_id2, true)
end
alias jet3746_use_item use_item
def use_item(*args, &block)
sprite = @spriteset.battler_to_sprite(@subject)
if (@subject.actor? || @subject.bat_sprite?) && !@subject.current_action.guard?
sprite.slide_forward
end
jet3746_use_item(*args, &block)
if (@subject.actor? || @subject.bat_sprite?)
sprite.slide_backward
end
end
end
class Spriteset_Battle
def battler_to_sprite(actor)
battler_sprites.each {|a|
return a if a.battler == actor
}
return false
end
end
class Window_BattleEnemy
alias jet3745_update update
def update(*args, &block)
jet3745_update(*args, &block)
if self.active && Jet::VBS::DO_FLASH
if Object.const_defined?(:Mouse)
$game_troop.alive_members.each {|a|
img = SceneManager.scene.spriteset.battler_to_sprite(a)
x = img.x - img.ox
y = img.y - img.oy
if Mouse.area?(x, y, img.src_rect.width, img.src_rect.height)
self.index = a.index
end
}
end
active_troop = $game_troop.alive_members[@index]
sprite = SceneManager.scene.spriteset.battler_to_sprite(active_troop)
sprite.start_effect(:whiten) if !sprite.effect?
end
end
end
class Window_BattleActor
alias jet3745_update update
def update(*args, &block)
jet3745_update(*args, &block)
if self.active && Jet::VBS::DO_FLASH
if Object.const_defined?(:Mouse)
$game_party.alive_members.each {|a|
img = SceneManager.scene.spriteset.battler_to_sprite(a)
x = img.x - img.ox
y = img.y - img.oy
if Mouse.area?(x, y, img.src_rect.width, img.src_rect.height)
self.index = a.index
end
}
end
active_troop = $game_party.members[@index]
sprite = SceneManager.scene.spriteset.battler_to_sprite(active_troop)
sprite.start_effect(:whiten) if !sprite.effect?
end
end
end
class Window_ActorCommand
alias jet3745_update update
def update(*args, &block)
jet3745_update(*args, &block)
if self.active && Jet::VBS::DO_FLASH
active_troop = @actor
sprite = SceneManager.scene.spriteset.battler_to_sprite(active_troop)
sprite.start_effect(:whiten) if !sprite.effect?
end
end
end
class Game_Action
def guard?
item == $data_skills[subject.guard_skill_id]
end
end
- SpytjeAdministrateur
- Nombre de messages : 5935
Localisation : La terre
Distinction : Spiraliste [Korn']
Forestia : Projet du mois juillet 2014
Papy Pulkigrat [Yama']
Date d'inscription : 16/03/2008
Re: [résolu]Mon héro recule quand il fait "se défendre"
Ven 24 Jan 2014 - 18:56
Est ce que tu as d'autres scripts ou addons pour ce script d'installé ?
Re: [résolu]Mon héro recule quand il fait "se défendre"
Ven 24 Jan 2014 - 19:11
ATB :
- Code:
#==============================================================================
# +++ MOG - AT System (v0.7 Beta) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Sistema de batalha de turnos em tempo real.
#==============================================================================
#==============================================================================
# ● Histórico (Version History)
#==============================================================================
# v 0.7 - Melhoria na performance.
# v 0.6 - Corrigido o bug de ações forçadas consecutivas.
# - Corrigido o bug de contagem de turnos das condições. (Stop / Sleep)
# - Corrigido o bug de resetar o AT quando o battler recebe qualquer
# tipo de status que não tenham o efeito Stop / Sleep.
# v 0.5 - Corrigido o bug da contagem de turnos nas condições. (States)
# v 0.4 - Corrigido o bug de crash randômico. (relativo a dispose de imagem.)
# - Corrigido o bug de crash randômico. (relativo ao turno.)
# - Corrigido o bug de travar a tela na execução da mensagem de batalha.
# v 0.3 - Corrigido o Bug da janela de comando ao apertar a tecla Cancel.
# - Corrigido o Bug de não apresentar a janela de status no começo.
# - Melhor codificação para aumentar a compatibilidade.
# - Opção de definir a posição do medidor de AT pelo X&Y do battler.
# v 0.2 - Corrigido o bug da seleção do alvo para ações de cast time.
# v 0.1 - Primeiro lançamento.
#==============================================================================
#==============================================================================
# ● Imagens Necessárias
#==============================================================================
# Serão necessários as imagens:
#
# Battle_AT_Layout.png
# Battle_AT_Meter.png
#
# Na pasta GRAPHICS/SYSTEM/
#
#==============================================================================
# ● AT SYSTEM
#==============================================================================
# A velocidade de AT é baseaddo na agilidade do Battler.
# Em caso de batalhas preventivas (Preemptive) os aliados começarão com AT em
# 80% e os inimigos começarão com AT em 0 (Zero)
# Em batalhas surpresas (Surprise) é o inverso das batalhas preventivas.
# Em batalhas normais todos os battlers começarão com AT em 40%.
#==============================================================================
# ● CAST TIME
#==============================================================================
# Para definir uma habilidade ou item com a função de Cast Time basta definir
# o valor da velocidade (Speed) diferente de 0 (Zero).
#
# NOTA - Não é possível ativar 2 ou mais habilidades com a função Cast Time no
# mesmo turno. (Caso você esteja usando características de Multi Action em
# seu projeto.)
#==============================================================================
module MOG_AT_SYSTEM
# Tipo de posicionamento da Hud.
# 0 - Posição fixa.
# 1 - Posição baseado no valor X e Y do battler.
HUD_POSITION_TYPE = 0
#Posição geral (Inicial) da Hud.
HUD_POSITION = [-26,319]
#Posição do medidor de AT
AT_METER_POSITION = [29,1]
#Definição da posição do espaço da HUD entre os membros do grupo.
#
#MEMBERS_SPACE = [Horizontal ,Vertical]
#
MEMBERS_SPACE = [0,25]
#Velocidade de animação do medidor de at, defina 0 se não quiser a animação.
AT_METER_FLOW_SPEED = 3
#Prioridade da Hud.
BATTLE_HUD_Z = 0
#Som quando o sistema AT estiver no maximo
SE_ACTIVE = "Decision2"
#Definição do valor de AT para ativar a ação.(Gauge Meter).
AT_GAUGE_METER = 5000
# Definição do tipo de duração (Contagem/formula) de um turno.
# Essa definição influência na ativação dos eventos de batalha.
# (BATTLE EVENTS)
#
# 0 - Duração de um turno é um valor fixo.
# 1 - Duração de um turno é multiplicado pela quantidade de batllers.
# 2 - Duração de um turno é baseado na média de agilidade dos battlers.
#
TURN_DURATION_TYPE = 1
# Definição de valor usado para calcular a duração de um turno.
TURN_DURATION = 60
# Definição da animação quando o battler usa habilidades de carregamento.
CAST_ANIMATION = 49
# Ativar a janela de LOG, deixe desativado se desejar uma batalha mais
# dinâmica.
WAIT_LOG_WINDOW = true
# Ativar a mensagem inicial com os nomes dos inimigos.
MESSAGE_ENEMY_APPEAR = true
# Definição da posição da janela de mensagem.
# 0 - Superior
# 1 - Centro
# 2 - Inferior
MESSAGE_POSITION = 0
end
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
attr_accessor :at_max
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_at_system_initialize initialize
def initialize
@at_max = [[MOG_AT_SYSTEM::AT_GAUGE_METER, 999999].min, 100].max
mog_at_system_initialize
end
end
#==============================================================================
# ■ BattleManager
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# ● Battle Start
#--------------------------------------------------------------------------
def self.battle_start
$game_system.battle_count += 1
$game_party.on_battle_start
$game_troop.on_battle_start
if MOG_AT_SYSTEM::MESSAGE_ENEMY_APPEAR
$game_troop.enemy_names.each do |name|
$game_message.add(sprintf(Vocab::Emerge, name))
end
end
if @preemptive
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
elsif @surprise
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
end
wait_for_message
end
#--------------------------------------------------------------------------
# ● Input Start
#--------------------------------------------------------------------------
def self.input_start_at(battler)
if @phase != :input
@phase = :input
battler.make_actions
clear_actor
end
return !@surprise && battler.inputable?
end
#--------------------------------------------------------------------------
# ● Turn Start
#--------------------------------------------------------------------------
def self.turn_start
@phase = :turn
clear_actor
make_action_orders
end
#--------------------------------------------------------------------------
# ● Preemtive Attack
#--------------------------------------------------------------------------
def self.preemptive_attack
@preemptive
end
#--------------------------------------------------------------------------
# ● Suprise Attack
#--------------------------------------------------------------------------
def self.surprise_attack
@surprise
end
end
#==============================================================================
# ■ Game Action
#==============================================================================
class Game_Action
#--------------------------------------------------------------------------
# ● Prepare
#--------------------------------------------------------------------------
alias mog_at_system_prepare prepare
def prepare
mog_at_system_prepare
set_cast_action
end
#--------------------------------------------------------------------------
# ● Set Cast Action
#--------------------------------------------------------------------------
def set_cast_action
return if forcing
if @item.object != nil and @item.object.speed != 0 and @subject.at_cast.empty?
@subject.at_cast = [@item.object,@item.object.speed.abs,@target_index]
@item.object = nil
@subject.animation_id = MOG_AT_SYSTEM::CAST_ANIMATION
@subject.at = 0
BattleManager.turn_end if @subject.auto_battle?
elsif !@subject.at_cast.empty?
if @subject.at_cast[1] == 0
@item.object = @subject.at_cast[0]
@target_index = @subject.at_cast[2]
@subject.at_cast.clear
else
@item.object = nil
end
end
end
end
#==============================================================================
# ■ Game Battler Base
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● Inputable?
#--------------------------------------------------------------------------
def inputable?
normal? && !auto_battle? && self.at == $game_system.at_max
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
attr_accessor :at
attr_accessor :at_cast
attr_accessor :at_turn_duration
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_at_system_initialize initialize
def initialize
mog_at_system_initialize
@at = 0
@at_cast = []
@at_cast_selectable = true
@at_turn_duration = 0
end
#--------------------------------------------------------------------------
# ● At
#--------------------------------------------------------------------------
def at
n = at_active? ? $game_system.at_max : 0
return [[@at, n].min, 0].max
end
#--------------------------------------------------------------------------
# ● At Active
#--------------------------------------------------------------------------
def at_active?
return false if restriction >= 4
return false if self.hp == 0
return true
end
#--------------------------------------------------------------------------
# ● Added New State
#--------------------------------------------------------------------------
alias mog_at_system_add_new_state add_new_state
def add_new_state(state_id)
mog_at_system_add_new_state(state_id)
if restriction >= 4
self.at_cast.clear
self.at = 0
end
end
end
#==============================================================================
# ■ Game Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● Tranform
#--------------------------------------------------------------------------
alias mog_at_system_transform transform
def transform(enemy_id)
mog_at_system_transform(enemy_id)
self.at = 0
self.at_cast.clear
end
end
if !MOG_AT_SYSTEM::WAIT_LOG_WINDOW
#==============================================================================
# ■ BattleManager
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
end
#--------------------------------------------------------------------------
# ● Message Speed
#--------------------------------------------------------------------------
def message_speed
return 5
end
end
end
#==============================================================================
# ■ Scene Battle
#==============================================================================
class Scene_Battle < Scene_Base
include MOG_AT_SYSTEM
#--------------------------------------------------------------------------
# ● AT Wait
#--------------------------------------------------------------------------
alias mog_at_system_start start
def start
reset_at_parameter
mog_at_system_start
end
#--------------------------------------------------------------------------
# ● Battle Start
#--------------------------------------------------------------------------
def battle_start
BattleManager.battle_start
process_event
set_turn_duration
end
#--------------------------------------------------------------------------
# ● Reset AT Parameter
#--------------------------------------------------------------------------
def reset_at_parameter
return if @at_phase != nil
@at_phase = 0
n_at = $game_system.at_max * 40 / 100
p_at = $game_system.at_max * 90 / 100
s_at = 0
all_battle_members.each do |battler|
if BattleManager.preemptive_attack
battler.at = p_at if battler.is_a?(Game_Actor)
battler.at = s_at if battler.is_a?(Game_Enemy)
elsif BattleManager.surprise_attack
battler.at = p_at if battler.is_a?(Game_Enemy)
battler.at = s_at if battler.is_a?(Game_Actor)
else
battler.at = n_at
end
if battler.at >= $game_system.at_max
battler.at = $game_system.at_max - 1
end
battler.at = 0 if battler.at < 0
battler.at_cast.clear
end
end
#--------------------------------------------------------------------------
# ● Set Turn Duration
#--------------------------------------------------------------------------
def set_turn_duration
max_battlers = all_battle_members.size > 0 ? all_battle_members.size : 1
case TURN_DURATION_TYPE
when 1
n = TURN_DURATION * max_battlers
when 2
turn_sp = 0
all_battle_members.each do |battler|
turn_sp += battler.agi
end
n = TURN_DURATION + (turn_sp / max_battlers)
else
n = TURN_DURATION
end
turn_time_max = [[n, 9999].min, 120].max
@turn_duration = [0, turn_time_max]
if @status_window != nil
@status_window.open
end
end
#--------------------------------------------------------------------------
# ● Turn End
#--------------------------------------------------------------------------
def turn_end
@at_phase = 0
all_battle_members.each do |battler|
if battler.at >= $game_system.at_max
battler.at = 0
refresh_status
@log_window.display_auto_affected_status(battler)
@log_window.wait_and_clear
end
end
BattleManager.turn_end
end
#--------------------------------------------------------------------------
# ● Update Turn Duration
#--------------------------------------------------------------------------
def update_turn_duration
return if @turn_duration == nil or @turn_duration[0] == nil
@turn_duration[0] += 1
if @turn_duration[0] >= @turn_duration[1]
@turn_duration[0] = 0
$game_troop.increase_turn
process_event
check_states_effect_turn
end
end
#--------------------------------------------------------------------------
# ● Check States Effect Turn
#--------------------------------------------------------------------------
def check_states_effect_turn
all_battle_members.each do |battler|
battler.on_turn_end if battler.restriction >= 4
end
end
#--------------------------------------------------------------------------
# ● Update AT System
#--------------------------------------------------------------------------
def update_at_system
reset_at_parameter if @at_phase == nil
set_turn_duration if @turn_duration == nil
return if !can_update_at?
update_turn_duration
all_battle_members.each do |battler|
update_battler_turn_duration(battler)
if !battler.at_cast.empty?
battler.at_cast[1] -= 1
if battler.at_cast[1] <= 0
execute_at_cast(battler)
break
end
else
battler.at += battler.agi
end
if battler.at >= $game_system.at_max
battler.on_turn_end
update_at_actor(battler)
update_at_enemy(battler)
battler.current_action.prepare if battler.current_action
if battler.at_cast.empty?
@at_phase = 1
turn_start if battler.is_a?(Game_Enemy)
end
break
end
end
end
#--------------------------------------------------------------------------
# ● Update Battler Turn Duration
#--------------------------------------------------------------------------
def update_battler_turn_duration(battler)
if battler.restriction >= 4
battler.at_turn_duration += 1
if battler.at_turn_duration >= $game_system.at_max
battler.on_turn_end
battler.at_turn_duration = 0
end
else
battler.at_turn_duration = 0
end
end
#--------------------------------------------------------------------------
# ● Execute AT CAST
#--------------------------------------------------------------------------
def execute_at_cast(battler)
@subject = battler
battler.make_actions
turn_start
end
#--------------------------------------------------------------------------
# ● Update AT Actor
#--------------------------------------------------------------------------
def update_at_actor(battler)
return if !battler.is_a?(Game_Actor)
start_party_command_selection_at(battler)
end
#--------------------------------------------------------------------------
# ● Update AT Enemy
#--------------------------------------------------------------------------
def update_at_enemy(battler)
return if !battler.is_a?(Game_Enemy)
battler.make_actions
end
#--------------------------------------------------------------------------
# ● Can Update AT
#--------------------------------------------------------------------------
def can_update_at?
return false if $game_troop.interpreter.running?
return false if BattleManager.action_forced?
return false if @at_phase != 0
return false if $game_message.visible
return false if BattleManager.in_turn?
return true
end
#--------------------------------------------------------------------------
# ● Star Party Command Selection at
#--------------------------------------------------------------------------
def start_party_command_selection_at(battler)
unless scene_changing?
refresh_status
@status_window.unselect
@status_window.open
if BattleManager.input_start_at(battler)
@actor_command_window.close
next_command
else
turn_start
end
end
end
#--------------------------------------------------------------------------
# ● Update Basic
#--------------------------------------------------------------------------
alias mog_at_system_update_basic update_basic
def update_basic
mog_at_system_update_basic
update_at_system
update_party_command
$game_message.position = MESSAGE_POSITION
end
#--------------------------------------------------------------------------
# ● Update Party Command
#--------------------------------------------------------------------------
def update_party_command
return if !@party_command_window.active
return if !@actor_command_window.visible
return if $game_message.visible
if Input.trigger?(:B)
next_command
Sound.play_cancel
@party_command_window.active = false
end
end
end
#==============================================================================
# ■ AT Meter
#==============================================================================
class AT_Meter
include MOG_AT_SYSTEM
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(actor)
dispose
@actor = actor
if HUD_POSITION_TYPE == 1 and @actor.use_sprite?
@x = HUD_POSITION[0] + @actor.screen_x rescue 0
@y = HUD_POSITION[1] + @actor.screnn_y rescue 0
else
@x = HUD_POSITION[0] + (MEMBERS_SPACE[0] * @actor.index)
@y = HUD_POSITION[1] + (MEMBERS_SPACE[1] * @actor.index)
end
pre_cache
create_layout
create_at_meter
end
#--------------------------------------------------------------------------
# ● Pre Cache
#--------------------------------------------------------------------------
def pre_cache
@meter = Cache.system("Battle_AT_Meter")
@meter_cw = @meter.width / 3
@meter_ch = @meter.height / 3
end
#--------------------------------------------------------------------------
# ● Create Layout
#--------------------------------------------------------------------------
def create_layout
@layout = Sprite.new
@layout.bitmap = Cache.system("Battle_AT_Layout")
@layout.z = BATTLE_HUD_Z
@layout.x = @x
@layout.y = @y
end
#--------------------------------------------------------------------------
# ● Create AT Meter
#--------------------------------------------------------------------------
def create_at_meter
@at_meter = Sprite.new
@at_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
@at_meter.z = BATTLE_HUD_Z + 50
@at_meter.x = @x + AT_METER_POSITION[0]
@at_meter.y = @y + AT_METER_POSITION[1]
@at_flow = rand(@meter_cw * 2)
at_flow_update
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
return if @layout == nil
@layout.bitmap.dispose
@layout.dispose
@layout = nil
@at_meter.bitmap.dispose
@at_meter.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
return if @layout == nil
at_position
at_flow_update
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def at_position
return unless HUD_POSITION_TYPE == 1 and @actor.use_sprite?
@x = HUD_POSITION[0] + @actor.screen_x rescue 0
@y = HUD_POSITION[1] + @actor.screnn_y rescue 0
@layout.x = @x
@layout.y = @y
@at_meter.x = @x + AT_METER_POSITION[0]
@at_meter.y = @y + AT_METER_POSITION[1]
end
#--------------------------------------------------------------------------
# ● AT Flow Update
#--------------------------------------------------------------------------
def at_flow_update
@at_meter.bitmap.clear
if !@actor.at_cast.empty?
max_cast = @actor.at_cast[0].speed.abs != 0 ? @actor.at_cast[0].speed.abs : 1
at_width = @meter_cw * @actor.at_cast[1] / max_cast
ch = @meter_ch * 2
else
at_width = @meter_cw * @actor.at / $game_system.at_max
ch = @actor.at < $game_system.at_max ? 0 : @meter_ch
end
src_rect = Rect.new(@at_flow, ch,at_width, @meter_ch)
@at_meter.bitmap.blt(0,0, @meter, src_rect)
@at_flow += AT_METER_FLOW_SPEED
@at_flow = 0 if @at_flow >= @meter_cw * 2
end
end
#==============================================================================
# ■ Spriteset Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_at_system_initialize initialize
def initialize
mog_at_system_initialize
create_at_meter
end
#--------------------------------------------------------------------------
# ● Create AT Meter
#--------------------------------------------------------------------------
def create_at_meter
dispose_at_meter
@at_meter = []
index = 0
for i in $game_party.members
@at_meter.push(AT_Meter.new(i))
index += 1
break if index >= $game_party.max_battle_members
end
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias mog_at_system_dispose dispose
def dispose
mog_at_system_dispose
dispose_at_meter
end
#--------------------------------------------------------------------------
# ● Dispose AT Meter
#--------------------------------------------------------------------------
def dispose_at_meter
return if @at_meter == nil
@at_meter.each {|sprite| sprite.dispose }
@at_meter.clear
@at_meter = nil
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_at_system_update update
def update
mog_at_system_update
update_at_meter
end
#--------------------------------------------------------------------------
# ● Update AT Meter
#--------------------------------------------------------------------------
def update_at_meter
return if @at_meter == nil
@at_meter.each {|sprite| sprite.update }
end
end
$mog_rgss3_at_system = true
Re: [résolu]Mon héro recule quand il fait "se défendre"
Ven 24 Jan 2014 - 19:11
Ainsi que Party member :
- Code:
#==============================================================================
#
# ▼ Yanfly Engine Ace - Party System v1.08
# -- Last Updated: 2012.01.23
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-PartySystem"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.23 - Bug fixed: Party members are now rearranged when newly added.
# 2012.01.14 - New Feature: Maximum Battle Members Variable added.
# 2012.01.07 - Bug fixed: Error with removing members.
# 2012.01.05 - Bug fixed: Escape skill/item effects no longer counts as death.
# 2011.12.26 - Compatibility Update: New Game+
# 2011.12.17 - Updated Spriteset_Battle to have updated sprite counts.
# 2011.12.13 - Updated to provide better visual display when more than 5 pieces
# of equipment are equipped on an actor at a time.
# 2011.12.05 - Added functionality to display faces in the Party Select Window.
# - Fixed bug that doesn't refresh the caterpillar when new members
# join the party.
# 2011.12.04 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# RPG Maker VX Ace comes with a very nice party system. However, changing the
# maximum number of members isn't possible without the aid of a script. This
# script enables you the ability to change the maximum number of party members,
# change EXP rates, and/or open up a separate party menu (if desired). In
# addition to that, you can lock the position of actors within a party and
# require other actors to be in the active party before continuing.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# *IMPORTANT* These script calls require the new party menu to be enabled to
# use them. Otherwise, nothing will happen.
#
# lock_actor(x)
# unlock_actor(x)
# This will lock actor x in its current position in the party if the actor is
# in the current party. The actor is unable to switch position and must remain
# in that position until the lock is removed. Use the unlock script call to
# remove the locked status. This script requires the actor to have joined and
# in the current party before the script call will work.
#
# require_actor(x)
# unrequire_actor(x)
# This will cause the party to require actor x in order to continue. If the
# actor isn't in the current party but is in the reserve party, the party menu
# will open up and prompt the player to add the required actor into the party
# before being able to continue. This script call will not function unless the
# specific actor has joined the party, whether it is in the current or reserve.
#
# call_party_menu
# This will open up the party menu. This script call requires for the party
# menu to be enabled to use.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
module YEA
module PARTY
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - General Party Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# In this section, you can adjust the general party settings for your game
# such as the maximum amount of members and whatnot, the EXP rate for
# party members in the reserve, etc.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
MAX_BATTLE_MEMBERS = 3 # Maximum party members. Default: 4
SPLIT_EXP = false # Splits EXP with more members in the party.
RESERVE_EXP_RATE = 0.50 # Reserve EXP Rate. Default: 1.00
# If you wish to be able to change the maximum number of battle members
# during the middle of your game, set this constant to a variable ID. If
# that variable ID is a number greater than 0, that variable will determine
# the current maximum number of battle members. Be cautious about using
# this during battle.
MAX_MEMBERS_VARIABLE = 0
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Party Menu Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# This section contains various menu settings for those who wish to use a
# menu separate for the party system. Here, adjust the menu command order,
# icons used, and other settings.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ENABLE_MENU = true # Enables party menu. Default: false
COMMANDS =[ # The order at which the menu items are shown.
# [:command, "Display"],
[ :change, "Modifier",],
[ :remove, "Enlever",],
[ :revert, "Retour",],
[ :finish, "Terminer",],
] # Do not remove this.
COMMAND_ALIGN = 1 # 0:Left Align, 1:Center Align, 2:Right Align
# These settings here are used for the upper right window: the Party Select
# window where the player selects a member to swap out or remove.
PARTY_FONT_SIZE = 20 # Font size used for party member names.
LOCK_FIRST_ACTOR = false # Lock the first actor by default?
LOCKED_ICON = 125 # Icon used for locked members.
REQUIRED_ICON = 126 # Icon used for required members.
EMPTY_TEXT = "-Vide-" # Text used when a member isn't present.
DISPLAY_FACE = false # Display faces instead of sprites?
# These settings here are used for the lower left window: the Party List
# window where the player selects a member to replace.
REMOVE_ICON = 185 # Icon used for removing members.
REMOVE_TEXT = "-Enlever-" # Text used for remove member command.
ACTOR_Y_BUFFER = 12 # Amount the actor graphic be adjusted by.
# These settings here are used for the lower right window: the Party Status
# window where info about a selected actor is shown.
NO_DATA = "-Pas de donnée-" # Text used for when no actor is shown.
IN_PARTY_COLOUR = 6 # Text colour used for in party members.
STAT_FONT_SIZE = 20 # Font size used for stats.
EQUIP_TEXT = "Equipement" # Text used to display equipment.
end # PARTY
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#==============================================================================
# ■ Icon
#==============================================================================
module Icon
#--------------------------------------------------------------------------
# self.locked_party
#--------------------------------------------------------------------------
def self.locked_party; return YEA::PARTY::LOCKED_ICON; end
#--------------------------------------------------------------------------
# self.required_party
#--------------------------------------------------------------------------
def self.required_party; return YEA::PARTY::REQUIRED_ICON; end
#--------------------------------------------------------------------------
# self.remove_party
#--------------------------------------------------------------------------
def self.remove_party; return YEA::PARTY::REMOVE_ICON; end
end # Icon
#==============================================================================
# ■ Variable
#==============================================================================
module Variable
#--------------------------------------------------------------------------
# self.max_battle_members
#--------------------------------------------------------------------------
def self.max_battle_members
default = YEA::PARTY::MAX_BATTLE_MEMBERS
return default if YEA::PARTY::MAX_MEMBERS_VARIABLE <= 0
return default if $game_variables[YEA::PARTY::MAX_MEMBERS_VARIABLE] <= 0
return $game_variables[YEA::PARTY::MAX_MEMBERS_VARIABLE]
end
end # Variable
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :locked
attr_accessor :required
#--------------------------------------------------------------------------
# alias method: setup
#--------------------------------------------------------------------------
alias game_actor_setup_ps setup
def setup(actor_id)
game_actor_setup_ps(actor_id)
@locked = false
@required = false
end
#--------------------------------------------------------------------------
# overwrite method: final_exp_rate
#--------------------------------------------------------------------------
def final_exp_rate
n = exr * (battle_member? ? 1 : reserve_members_exp_rate)
if $game_party.in_battle
n /= [$game_party.battle_members.size, 1].max if YEA::PARTY::SPLIT_EXP
end
return n
end
#--------------------------------------------------------------------------
# overwrite method: reserve_members_exp_rate
#--------------------------------------------------------------------------
def reserve_members_exp_rate
$data_system.opt_extra_exp ? YEA::PARTY::RESERVE_EXP_RATE : 0
end
end # Game_Actor
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :battle_members_array
#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias game_party_initialize_ps initialize
def initialize
game_party_initialize_ps
@battle_members_array = nil
end
#--------------------------------------------------------------------------
# overwrite method: max_battle_members
#--------------------------------------------------------------------------
def max_battle_members; return Variable.max_battle_members; end
#--------------------------------------------------------------------------
# alias method: setup_starting_members
#--------------------------------------------------------------------------
alias setup_starting_members_ps setup_starting_members
def setup_starting_members
setup_starting_members_ps
initialize_battle_members
return unless YEA::PARTY::LOCK_FIRST_ACTOR
return if members[0].nil?
members[0].locked = true
end
#--------------------------------------------------------------------------
# alias method: setup_battle_test_members
#--------------------------------------------------------------------------
alias setup_battle_test_members_ps setup_battle_test_members
def setup_battle_test_members
setup_battle_test_members_ps
return unless YEA::PARTY::LOCK_FIRST_ACTOR
return if members[0].nil?
members[0].locked = true
end
#--------------------------------------------------------------------------
# overwrite method: battle_members
#--------------------------------------------------------------------------
def battle_members
initialize_battle_members if initialize_battle_members?
array = []
for actor_id in @battle_members_array
break if array.size > max_battle_members
next if actor_id.nil?
next if $game_actors[actor_id].nil?
next unless $game_actors[actor_id].exist?
array.push($game_actors[actor_id])
end
return array
end
#--------------------------------------------------------------------------
# new method: initialize_battle_members?
#--------------------------------------------------------------------------
def initialize_battle_members?
return true if @battle_members_array.nil?
return @battle_members_array.size != max_battle_members
end
#--------------------------------------------------------------------------
# new method: initialize_battle_members
#--------------------------------------------------------------------------
def initialize_battle_members
@battle_members_array = []
for i in 0...max_battle_members
@battle_members_array.push(@actors[i]) unless @actors[i].nil?
@battle_members_array.push(0) if @actors[i].nil?
end
$game_player.refresh
end
#--------------------------------------------------------------------------
# alias method: add_actor
#--------------------------------------------------------------------------
alias game_party_add_actor_ps add_actor
def add_actor(actor_id)
game_party_add_actor_ps(actor_id)
return if @battle_members_array.include?(actor_id)
return unless @battle_members_array.include?(0)
index = @battle_members_array.index(0)
@battle_members_array[index] = actor_id
$game_player.refresh
$game_map.need_refresh = true
rearrange_actors
end
#--------------------------------------------------------------------------
# alias method: remove_actor
#--------------------------------------------------------------------------
alias game_party_remove_actor_ps remove_actor
def remove_actor(actor_id)
game_party_remove_actor_ps(actor_id)
return unless @battle_members_array.include?(actor_id)
index = @battle_members_array.index(actor_id)
@battle_members_array[index] = 0
$game_player.refresh
$game_map.need_refresh = true
rearrange_actors
end
#--------------------------------------------------------------------------
# new method: rearrange_actors
#--------------------------------------------------------------------------
def rearrange_actors
initialize_battle_members if @battle_members_array.nil?
array = []
for actor_id in @battle_members_array
next if [0, nil].include?(actor_id)
next if $game_actors[actor_id].nil?
array.push(actor_id)
end
for actor_id in @actors
next if array.include?(actor_id)
next if $game_actors[actor_id].nil?
array.push(actor_id)
end
@actors = array
end
end # Game_Party
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# new method: lock_actor
#--------------------------------------------------------------------------
def lock_actor(actor_id)
return unless YEA::PARTY::ENABLE_MENU
actor = $game_actors[actor_id]
return unless $game_party.battle_members.include?(actor.id)
actor.locked = true
end
#--------------------------------------------------------------------------
# new method: unlock_actor
#--------------------------------------------------------------------------
def unlock_actor(actor_id)
return unless YEA::PARTY::ENABLE_MENU
actor = $game_actors[actor_id]
return unless $game_party.battle_members.include?(actor.id)
actor.locked = false
end
#--------------------------------------------------------------------------
# new method: require_actor
#--------------------------------------------------------------------------
def require_actor(actor_id)
return unless YEA::PARTY::ENABLE_MENU
return if $game_system.formation_disabled
actor = $game_actors[actor_id]
return unless $game_party.all_members.include?(actor)
actor.required = true
call_party_menu unless $game_party.battle_members.include?(actor)
end
#--------------------------------------------------------------------------
# new method: unrequire_actor
#--------------------------------------------------------------------------
def unrequire_actor(actor_id)
return unless YEA::PARTY::ENABLE_MENU
return if $game_system.formation_disabled
actor = $game_actors[actor_id]
return unless $game_party.all_members.include?(actor)
actor.required = false
call_party_menu unless $game_party.battle_members.include?(actor)
end
#--------------------------------------------------------------------------
# new method: call_party_menu
#--------------------------------------------------------------------------
def call_party_menu
return unless YEA::PARTY::ENABLE_MENU
return if $game_system.formation_disabled
SceneManager.call(Scene_Party)
end
end # Game_Interpreter
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# overwrite method: create_actors
#--------------------------------------------------------------------------
def create_actors
total = $game_party.max_battle_members
@actor_sprites = Array.new(total) { Sprite_Battler.new(@viewport1) }
end
end # Spriteset_Battle
#==============================================================================
# ■ Window_PartyMenuCommand
#==============================================================================
class Window_PartyMenuCommand < Window_Command
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; return 160; end
#--------------------------------------------------------------------------
# visible_line_number
#--------------------------------------------------------------------------
def visible_line_number; 4; end
#--------------------------------------------------------------------------
# alignment
#--------------------------------------------------------------------------
def alignment
return Menu.command_window_align if $imported["YEA-AceMenuEngine"]
return YEA::PARTY::COMMAND_ALIGN
end
#--------------------------------------------------------------------------
# scene
#--------------------------------------------------------------------------
def scene; return SceneManager.scene; end
#--------------------------------------------------------------------------
# make_command_list
#--------------------------------------------------------------------------
def make_command_list
for command in YEA::PARTY::COMMANDS
case command[0]
when :change, :remove, :revert
add_command(command[1], command[0])
when :finish
add_command(command[1], command[0], enable_cancel?)
else; next
end
end
end
#--------------------------------------------------------------------------
# process_cancel
#--------------------------------------------------------------------------
def process_cancel
unless enable_cancel?
Sound.play_buzzer
return
end
super
end
#--------------------------------------------------------------------------
# in_party?
#--------------------------------------------------------------------------
def in_party?(actor)
return $game_party.battle_members.include?(actor)
end
#--------------------------------------------------------------------------
# enable_cancel?
#--------------------------------------------------------------------------
def enable_cancel?
return false if $game_party.battle_members.size <= 0
for actor in $game_party.all_members
next if in_party?(actor)
return false if actor.required
return false if actor.locked
end
return true
end
end # Window_PartyMenuCommand
#==============================================================================
# ■ Window_PartySelect
#==============================================================================
class Window_PartySelect < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#-------------------------------------------------------------------------
def initialize(command_window)
@command_window = command_window
super(160, 0, window_width, fitting_height(visible_line_number))
select(0)
deactivate
refresh
end
#--------------------------------------------------------------------------
# col_max
#--------------------------------------------------------------------------
def col_max; return $game_party.max_battle_members; end
#--------------------------------------------------------------------------
# item_max
#--------------------------------------------------------------------------
def item_max; return $game_party.max_battle_members; end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; return Graphics.width - 160; end
#--------------------------------------------------------------------------
# visible_line_number
#--------------------------------------------------------------------------
def visible_line_number; 4; end
#--------------------------------------------------------------------------
# item_rect
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = contents.width / item_max
rect.height = contents.height
rect.x = index * rect.width
rect.y = 0
return rect
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# make_item_list
#--------------------------------------------------------------------------
def make_item_list
@data = $game_party.battle_members_array.clone
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
actor = $game_actors[@data[index]]
rect = item_rect(index)
if actor.nil?
draw_empty(rect.clone)
return
end
dx = rect.width / 2
dy = rect.height - 16
draw_actor_face(actor, rect.x, rect.y) if display_face?
draw_actor_graphic(actor, rect.x + dx, rect.y + dy) unless display_face?
draw_actor_name(actor, rect)
draw_locked_icon(actor, rect)
draw_required_icon(actor, rect)
end
#--------------------------------------------------------------------------
# display_face?
#--------------------------------------------------------------------------
def display_face?
return YEA::PARTY::DISPLAY_FACE
end
#--------------------------------------------------------------------------
# draw_empty
#--------------------------------------------------------------------------
def draw_empty(rect)
colour = Color.new(0, 0, 0, translucent_alpha/2)
rect.x += 2
rect.y += 2
rect.width -= 4
rect.height -= 4
contents.fill_rect(rect, colour)
reset_font_settings
change_color(system_color)
text = YEA::PARTY::EMPTY_TEXT
draw_text(rect, text, 1)
reset_font_settings
end
#--------------------------------------------------------------------------
# draw_actor_name
#--------------------------------------------------------------------------
def draw_actor_name(actor, rect)
contents.font.size = YEA::PARTY::PARTY_FONT_SIZE
change_color(normal_color, actor.exist?)
draw_text(rect.x+4, rect.y, rect.width-8, line_height, actor.name, 1)
end
#--------------------------------------------------------------------------
# draw_face
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, dx, dy, enabled = true)
bitmap = Cache.face(face_name)
dw = [96, item_rect(0).width-4].min
rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, dw, 92)
contents.blt(dx+2, dy+2, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
end
#--------------------------------------------------------------------------
# draw_locked_icon
#--------------------------------------------------------------------------
def draw_locked_icon(actor, rect)
return unless actor_locked?(actor)
draw_icon(Icon.locked_party, rect.x+rect.width-26, rect.height - 26)
end
#--------------------------------------------------------------------------
# draw_required_icon
#--------------------------------------------------------------------------
def draw_required_icon(actor, rect)
return if actor_locked?(actor)
return unless actor_required?(actor)
draw_icon(Icon.required_party, rect.x+rect.width-26, rect.height - 26)
end
#--------------------------------------------------------------------------
# actor_locked?
#--------------------------------------------------------------------------
def actor_locked?(actor); return actor.locked; end
#--------------------------------------------------------------------------
# actor_required?
#--------------------------------------------------------------------------
def actor_required?(actor)
return false if actor.locked
return actor.required
end
#--------------------------------------------------------------------------
# current_item_enabled?
#--------------------------------------------------------------------------
def current_item_enabled?; enable?(@data[index]); end
#--------------------------------------------------------------------------
# enable?
#--------------------------------------------------------------------------
def enable?(item)
case @command_window.current_symbol
when :change
return true if item.nil?
return true if item == 0
when :remove
return false if item.nil?
return false if item == 0
end
actor = $game_actors[item]
return false if actor.locked
return false if actor.required
return true
end
#--------------------------------------------------------------------------
# process_handling
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_ok if ok_enabled? && Input.trigger?(:C)
return process_cancel if cancel_enabled? && Input.trigger?(:B)
return process_pagedown if handle?(:pagedown) && Input.repeat?(:R)
return process_pageup if handle?(:pageup) && Input.repeat?(:L)
end
#--------------------------------------------------------------------------
# cur_actor
#--------------------------------------------------------------------------
def cur_actor
actor_id = @data[index]
return $game_actors[actor_id]
end
#--------------------------------------------------------------------------
# prev_actor
#--------------------------------------------------------------------------
def prev_actor
id = index == 0 ? @data.size - 1 : index - 1
actor_id = @data[id]
return $game_actors[actor_id]
end
#--------------------------------------------------------------------------
# next_actor
#--------------------------------------------------------------------------
def next_actor
id = index == @data.size - 1 ? 0 : index + 1
actor_id = @data[id]
return $game_actors[actor_id]
end
#--------------------------------------------------------------------------
# process_pageup
#--------------------------------------------------------------------------
def process_pageup
allow = true
allow = false if !prev_actor.nil? && prev_actor.locked
allow = false if !cur_actor.nil? && cur_actor.locked
Sound.play_buzzer unless allow
if allow
super
activate
select(index == 0 ? @data.size - 1 : index - 1)
end
end
#--------------------------------------------------------------------------
# process_pagedown
#--------------------------------------------------------------------------
def process_pagedown
allow = true
allow = false if !next_actor.nil? && next_actor.locked
allow = false if !cur_actor.nil? && cur_actor.locked
Sound.play_buzzer unless allow
if allow
super
activate
select(index == @data.size - 1 ? 0 : index + 1)
end
end
#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data[index]; end
end # Window_PartySelect
#==============================================================================
# ■ Window_PartyList
#==============================================================================
class Window_PartyList < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#-------------------------------------------------------------------------
def initialize(party_window)
super(0, fitting_height(4), window_width, window_height)
@party_window = party_window
select(1)
deactivate
refresh
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; return 200; end
#--------------------------------------------------------------------------
# window_height
#--------------------------------------------------------------------------
def window_height; return Graphics.height - fitting_height(4); end
#--------------------------------------------------------------------------
# item_max
#--------------------------------------------------------------------------
def item_max; return @data ? @data.size : 1; end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# make_item_list
#--------------------------------------------------------------------------
def make_item_list
@data = [0]
for member in $game_party.all_members
next if member.nil?
@data.push(member.id)
end
@data.push(0)
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
clear_item(index)
rect = item_rect(index)
if @data[index] == 0
draw_remove(rect)
return
end
actor = $game_actors[@data[index]]
draw_actor(actor, rect)
draw_actor_locked(actor, rect)
draw_actor_required(actor, rect)
end
#--------------------------------------------------------------------------
# draw_remove
#--------------------------------------------------------------------------
def draw_remove(rect)
reset_font_settings
draw_icon(Icon.remove_party, rect.x+4, rect.y)
text = YEA::PARTY::REMOVE_TEXT
draw_text(rect.x+32, rect.y, rect.width-32, line_height, text)
end
#--------------------------------------------------------------------------
# draw_actor
#--------------------------------------------------------------------------
def draw_actor(actor, rect)
buffer = YEA::PARTY::ACTOR_Y_BUFFER
draw_actor_graphic(actor, rect.x + 16, rect.y + rect.height + buffer)
text = actor.name
change_color(list_colour(actor), enabled?(actor))
draw_text(rect.x+32, rect.y, rect.width-32, line_height, text)
end
#--------------------------------------------------------------------------
# list_colour
#--------------------------------------------------------------------------
def list_colour(actor)
return text_color(YEA::PARTY::IN_PARTY_COLOUR) if in_party?(actor)
return normal_color
end
#--------------------------------------------------------------------------
# draw_actor_locked
#--------------------------------------------------------------------------
def draw_actor_locked(actor, rect)
return unless actor.locked
draw_icon(Icon.locked_party, rect.width-24, rect.y)
end
#--------------------------------------------------------------------------
# draw_actor_required
#--------------------------------------------------------------------------
def draw_actor_required(actor, rect)
return if actor.locked
return unless actor.required
draw_icon(Icon.required_party, rect.width-24, rect.y)
end
#--------------------------------------------------------------------------
# enabled?
#--------------------------------------------------------------------------
def enabled?(actor)
return false if actor.locked
return false if actor.required && in_party?(actor)
return actor.exist?
end
#--------------------------------------------------------------------------
# in_party?
#--------------------------------------------------------------------------
def in_party?(actor); return $game_party.battle_members.include?(actor); end
#--------------------------------------------------------------------------
# current_item_enabled?
#--------------------------------------------------------------------------
def current_item_enabled?
actor = $game_actors[item]
replace = $game_actors[@party_window.item]
unless actor.nil?
return false if actor.locked && in_party?(actor)
return false if actor.required && in_party?(actor)
end
return true if replace.nil?
return false if replace.locked
return false if replace.required
return true if actor.nil?
return actor.exist?
end
#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data[index]; end
end # Window_PartyList
#==============================================================================
# ** Window_PartyStatus
#==============================================================================
class Window_PartyStatus < Window_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(party_window, list_window)
super(200, fitting_height(4), window_width, window_height)
@party_window = party_window
@list_window = list_window
@actor = active_actor
refresh
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width; Graphics.width - 200; end
#--------------------------------------------------------------------------
# window_height
#--------------------------------------------------------------------------
def window_height; Graphics.height - fitting_height(4); end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
refresh if @actor != active_actor
end
#--------------------------------------------------------------------------
# active_actor
#--------------------------------------------------------------------------
def active_actor
if @list_window.active
actor = @list_window.item
else
actor = @party_window.item
end
return nil if [0, nil].include?(actor)
return actor
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
@actor = active_actor
reset_font_settings
if @actor.nil?
draw_nil_actor
return
end
actor = $game_actors[@actor]
draw_actor_face(actor, 0, 0)
draw_actor_name(actor, 108, 0)
draw_actor_class(actor, 228, 0, contents.width-232)
draw_actor_level(actor, 108, line_height)
draw_actor_icons(actor, 228, line_height, contents.width-232)
draw_actor_hp(actor, 108, line_height*2, contents.width-112)
draw_actor_mp(actor, 108, line_height*3, contents.width-112)
draw_actor_parameters(actor, 0, line_height*4 + line_height/2)
draw_equipments(actor, contents.width/2, line_height*4 + line_height/2)
end
#--------------------------------------------------------------------------
# draw_nil_actor
#--------------------------------------------------------------------------
def draw_nil_actor
colour = Color.new(0, 0, 0, translucent_alpha/2)
rect = Rect.new(0, 0, contents.width, contents.height)
contents.fill_rect(rect, colour)
change_color(system_color)
text = YEA::PARTY::NO_DATA
draw_text(rect, text, 1)
end
#--------------------------------------------------------------------------
# draw_actor_parameters
#--------------------------------------------------------------------------
def draw_actor_parameters(actor, dx, dy)
dw = contents.width/2 - 4
rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
contents.font.size = YEA::PARTY::STAT_FONT_SIZE
colour = Color.new(0, 0, 0, translucent_alpha/2)
array = [:atk, :def, :mat, :mdf, :agi, :luk]
cx = 4
for stat in array
case stat
when :atk
param = Vocab::param(2)
value = actor.atk.group
when :def
param = Vocab::param(3)
value = actor.def.group
when :mat
param = Vocab::param(4)
value = actor.mat.group
when :mdf
param = Vocab::param(5)
value = actor.mdf.group
when :agi
param = Vocab::param(6)
value = actor.agi.group
when :luk
param = Vocab::param(7)
value = actor.luk.group
else; next
end
contents.fill_rect(rect, colour)
change_color(system_color)
draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, param, 0)
change_color(normal_color)
draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, value, 2)
rect.y += line_height
end
reset_font_settings
end
#--------------------------------------------------------------------------
# draw_equipments
#--------------------------------------------------------------------------
def draw_equipments(actor, dx, dy)
text = YEA::PARTY::EQUIP_TEXT
change_color(system_color)
draw_text(dx, dy, contents.width - dx, line_height, text, 1)
dy += line_height
if actor.equips.size <= 5
actor.equips.each_with_index do |item, i|
draw_item_name(item, dx, dy + line_height * i)
end
else
orig_x = dx
actor.equips.each_with_index do |item, i|
next if item.nil?
draw_icon(item.icon_index, dx, dy)
dy += line_height if dx + 48 > contents.width
dx = dx + 48 > contents.width ? orig_x : dx + 24
end
end
end
end # Window_PartyStatus
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# overwrite method: command_formation
#--------------------------------------------------------------------------
if YEA::PARTY::ENABLE_MENU
def command_formation
SceneManager.call(Scene_Party)
end
end # YEA::PARTY::ENABLE_MENU
end # Scene_Menu
#==============================================================================
# ■ Scene_Party
#==============================================================================
class Scene_Party < Scene_MenuBase
#--------------------------------------------------------------------------
# start
#--------------------------------------------------------------------------
def start
super
@former_party = $game_party.battle_members_array.clone
create_command_window
create_party_window
create_list_window
create_status_window
end
#--------------------------------------------------------------------------
# create_command_window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_PartyMenuCommand.new(0, 0)
@command_window.set_handler(:change, method(:adjust_members))
@command_window.set_handler(:remove, method(:adjust_members))
@command_window.set_handler(:revert, method(:revert_party))
@command_window.set_handler(:finish, method(:return_scene))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# create_party_window
#--------------------------------------------------------------------------
def create_party_window
@party_window = Window_PartySelect.new(@command_window)
@party_window.set_handler(:ok, method(:on_party_ok))
@party_window.set_handler(:cancel, method(:on_party_cancel))
@party_window.set_handler(:pageup, method(:on_party_pageup))
@party_window.set_handler(:pagedown, method(:on_party_pagedown))
end
#--------------------------------------------------------------------------
# create_list_window
#--------------------------------------------------------------------------
def create_list_window
@list_window = Window_PartyList.new(@party_window)
@list_window.set_handler(:ok, method(:on_list_ok))
@list_window.set_handler(:cancel, method(:on_list_cancel))
end
#--------------------------------------------------------------------------
# create_status_window
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_PartyStatus.new(@party_window, @list_window)
end
#--------------------------------------------------------------------------
# adjust_members
#--------------------------------------------------------------------------
def adjust_members
@party_window.activate
end
#--------------------------------------------------------------------------
# window_refresh
#--------------------------------------------------------------------------
def window_refresh
$game_party.rearrange_actors
@command_window.refresh
@party_window.refresh
@list_window.refresh
$game_player.refresh
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# revert_party
#--------------------------------------------------------------------------
def revert_party
@command_window.activate
$game_party.battle_members_array = @former_party.clone
window_refresh
end
#--------------------------------------------------------------------------
# on_party_ok
#--------------------------------------------------------------------------
def on_party_ok
case @command_window.current_symbol
when :change
@list_window.activate
when :remove
index = @party_window.index
actor = $game_actors[$game_party.battle_members_array[index]]
Sound.play_equip
$game_party.battle_members_array[index] = 0
window_refresh
@party_window.activate
end
end
#--------------------------------------------------------------------------
# on_party_cancel
#--------------------------------------------------------------------------
def on_party_cancel
@command_window.activate
end
#--------------------------------------------------------------------------
# on_party_pageup
#--------------------------------------------------------------------------
def on_party_pageup
Sound.play_equip
actor_id1 = @party_window.item
actor_id2 = @party_window.prev_actor.nil? ? 0 : @party_window.prev_actor.id
max = @party_window.item_max-1
index1 = @party_window.index
index2 = @party_window.index == 0 ? max : index1-1
$game_party.battle_members_array[index1] = actor_id2
$game_party.battle_members_array[index2] = actor_id1
window_refresh
end
#--------------------------------------------------------------------------
# on_party_pagedown
#--------------------------------------------------------------------------
def on_party_pagedown
Sound.play_equip
actor_id1 = @party_window.item
actor_id2 = @party_window.next_actor.nil? ? 0 : @party_window.next_actor.id
max = @party_window.item_max-1
index1 = @party_window.index
index2 = @party_window.index == max ? 0 : index1+1
$game_party.battle_members_array[index1] = actor_id2
$game_party.battle_members_array[index2] = actor_id1
window_refresh
end
#--------------------------------------------------------------------------
# on_list_cancel
#--------------------------------------------------------------------------
def on_list_cancel
@party_window.activate
end
#--------------------------------------------------------------------------
# on_list_ok
#--------------------------------------------------------------------------
def on_list_ok
Sound.play_equip
replace = $game_actors[@party_window.item]
actor = $game_actors[@list_window.item]
index1 = @party_window.index
actor_id1 = actor.nil? ? 0 : actor.id
if actor.nil?
$game_party.battle_members_array[index1] = 0
window_refresh
@party_window.activate
return
end
actor_id2 = replace.nil? ? 0 : replace.id
if $game_party.battle_members_array.include?(actor_id1)
index2 = $game_party.battle_members_array.index(actor_id1)
$game_party.battle_members_array[index2] = actor_id2
end
$game_party.battle_members_array[index1] = actor_id1
window_refresh
@party_window.activate
end
end # Scene_Party
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
- SpytjeAdministrateur
- Nombre de messages : 5935
Localisation : La terre
Distinction : Spiraliste [Korn']
Forestia : Projet du mois juillet 2014
Papy Pulkigrat [Yama']
Date d'inscription : 16/03/2008
Re: [résolu]Mon héro recule quand il fait "se défendre"
Ven 24 Jan 2014 - 19:43
Je ne trouve pas de soucis, essaie de demander à Skillo pour t'aider, il est souvent sur la chatbox, il est scripteur
- SpytjeAdministrateur
- Nombre de messages : 5935
Localisation : La terre
Distinction : Spiraliste [Korn']
Forestia : Projet du mois juillet 2014
Papy Pulkigrat [Yama']
Date d'inscription : 16/03/2008
Re: [résolu]Mon héro recule quand il fait "se défendre"
Dim 26 Jan 2014 - 13:55
Il est tous les soir sur la chat box pourtant sinon il y a aussi Ekron qui est la le soir il est plutôt doué lui aussi.
- vincent26Membre
- Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010
Re: [résolu]Mon héro recule quand il fait "se défendre"
Ven 7 Fév 2014 - 22:31
Ouaip envoie moi une copie de ton fichier Scripts.rvdata2 je vais voir si je trouve (peut-être pas ce soir mais surement demain)
Re: [résolu]Mon héro recule quand il fait "se défendre"
Sam 8 Fév 2014 - 10:06
C'est ceci : https://www.mediafire.com/?r75qfusp2mg1ums ?
- vincent26Membre
- Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010
Re: [résolu]Mon héro recule quand il fait "se défendre"
Sam 8 Fév 2014 - 13:10
Salut remplace ton script par celui-ci et dis moi si ça convient ^^
- Code:
#===============================================================================
# Jet's Viewed Battle System
# By Jet10985(Jet)
#===============================================================================
# This script will add actor sprites into the battle scene.
# This script has: 10 customization options.
#===============================================================================
# Overwritten Methods:
# Game_Actor: use_sprite?, screen_x, screen_y
# Sprite_Battler: revert_to_normal
# Scene_Battle: show_attack_animation
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Enemy: screen_x, screen_y
# Sprite_Battler: update_origin, update_bitmap
# Window_BattleEnemy: update
# Window_BattleActor: update
# Window_ActorCommand: update
#===============================================================================
=begin
Set an enemy's attack animation by using this in their notebox:
<anim: 50>
Replace 50 with the animation id.
--------------------------------------------------------------------------------
You may use a sprite for a monster instead of a regular battler by using this
notetag in the monster's notebox:
<sprite: ImageName, 0>
Replace ImageName with the name of the spritesheet, and 0 with the index on the
spritesheet you want the monster to use.
=end
module Jet
module VBS
# Which direction do actors face on the field? There are 4 options:
# :up, :down, :left, or :right. Actor's will direction chosen.
ACTOR_ORIENTATION = :left
# This will make it so actor's are centered on the screen instead of being
# placed in pre-determined lines using START_POINT and SPACE_DIFFERENCE.
CENTER_ACTORS = false
# This is the x and y starting point for actors. This option may take one of
# 2 functions. If CENTER_ACTORS is true, and ACTOR_ORIENTATION is either
# :left, or :right, then only the x value will be used as where to center
# the actors. If it is :down or :up, only the y value will be used.
# If CENTER_ACTORS is false, then this is where actor's will begin to be
# placed on screen.
START_POINT = [400, 221]
# This is how much space is between each actor on the field.
SPACE_DIFFERENCE = 22
# If you're using the :left or :right view, this will push each
# subsequent actor back by a certain number of pixels, to avoid having
# a straight line.
SIDEVIEW_PUSH_BACK = 16
# Do you want to reverse the direction and field during an ambush?
# (This is when enemies surprise the player and get the first turn)
REVERSE_FIELD_FOR_AMBUSH = false
# this is how far the actor will move forward when they are selection an
# action, as well as executing it.
SLIDE_AMOUNT = 50
# This is how far the actor will slide each frame until they reach their
# goal of SLIDE_FORWARD. Best used when this is a factor of SLIDE_FORWARD.
FRAME_SLIDE = 6
# During selecting an actor command, and during selecting an enemy target,
# would you like the selected character to flash?
DO_FLASH = false
# These are state-based sprite changes. If the actor has one of these states
# then the game will search for a sprite of the character's regular sprite
# name with the special state tag appended to it. So if Jimmy's sprite
# name was $Jimmy, and he had poison inflcted on him, and poison's id was
# listed here as ["_poison", 0], it would change Jimmy's in-battle sprite
# to $Jimmy_poison at the first sprite index.
STATE_SPRITES = {
1 => ["", 0],
2 => ["", 0]
}
# Do not touch this option.
DIR_ORIENT = {right: 6, left: 4, down: 2, up: 8}[ACTOR_ORIENTATION]
end
end
#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Integer
def even?
self % 2 == 0
end
def odd?
!even?
end
end
class RPG::Enemy
def animation
(f = note.match(/<anim:[ ]*(\d+)>/i)) ? f[1].to_i : 1
end
def battle_sprite
(f = note.match(/<sprite:[ ]*(.+),[ ]*(\d+)>/i)) ? f[1..2] : false
end
end
module BattleManager
class << self
alias jet3845_on_encounter on_encounter
def on_encounter(*args, &block)
jet3845_on_encounter(*args, &block)
@true_surprise = @surprise
end
end
def self.true_surprise
@true_surprise ||= false
end
def self.player_dir
if @true_surprise && Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
return 10 - Jet::VBS::DIR_ORIENT
else
return Jet::VBS::DIR_ORIENT
end
end
end
class Game_Actor
def use_sprite?
true
end
def screen_x
if [8, 2].include?(BattleManager.player_dir)
if Jet::VBS::CENTER_ACTORS
x = Graphics.width / 2
x -= 16
x += Jet::VBS::SPACE_DIFFERENCE / 2 if $game_party.members.size.even?
x -= ($game_party.members.size / 2 - index) * Jet::VBS::SPACE_DIFFERENCE
return x
else
return Jet::VBS::START_POINT[0] + Jet::VBS::SPACE_DIFFERENCE * index
end
end
return Jet::VBS::START_POINT[0]
end
alias jet3745_screen_x screen_x
def screen_x(*args, &block)
x = jet3745_screen_x(*args, &block)
case BattleManager.player_dir
when 4
x += Jet::VBS::SIDEVIEW_PUSH_BACK * index
when 6
x -= Jet::VBS::SIDEVIEW_PUSH_BACK * index
end
return x if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
x = Graphics.width - x if BattleManager.true_surprise && [6, 4].include?(BattleManager.player_dir)
x
end
def screen_y
if [6, 4].include?(BattleManager.player_dir)
if Jet::VBS::CENTER_ACTORS
y = Graphics.height / 2
y -= 16
y += Jet::VBS::SPACE_DIFFERENCE / 2 if $game_party.members.size.even?
y -= ($game_party.members.size / 2 - index) * Jet::VBS::SPACE_DIFFERENCE
return y
else
return Jet::VBS::START_POINT[1] + Jet::VBS::SPACE_DIFFERENCE * index
end
end
return Jet::VBS::START_POINT[1]
end
alias jet3745_screen_y screen_y
def screen_y(*args, &block)
y = jet3745_screen_y(*args, &block)
return y if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
y = Graphics.height - y if BattleManager.true_surprise && [8, 2].include?(BattleManager.player_dir)
y
end
def screen_z
101 + index
end
alias jet3745_character_name character_name
def character_name(*args, &block)
name = jet3745_character_name(*args, &block)
return name unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return name + add[0]
end
}
return name
end
alias jet3745_character_index character_index
def character_index(*args, &block)
index = jet3745_character_index(*args, &block)
return index unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return index + add[1]
end
}
return index
end
end
class Game_Enemy
alias jet3745_screen_x screen_x
def screen_x(*args, &block)
x = jet3745_screen_x(*args, &block)
return x if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
x = Graphics.width - x if BattleManager.true_surprise && [6, 4].include?(BattleManager.player_dir)
x
end
alias jet3745_screen_y screen_y
def screen_y(*args, &block)
y = jet3745_screen_y(*args, &block)
return y if !Jet::VBS::REVERSE_FIELD_FOR_AMBUSH
y = Graphics.height - y if BattleManager.true_surprise && [8, 2].include?(BattleManager.player_dir)
y
end
def atk_animation_id1
enemy.animation
end
def atk_animation_id2
0
end
def bat_sprite?
!!enemy.battle_sprite
end
def character_name
enemy.battle_sprite[0]
end
def character_index
enemy.battle_sprite[1].to_i
end
alias jet3745_character_name character_name
def character_name(*args, &block)
name = jet3745_character_name(*args, &block)
return name unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return name + add[0]
end
}
return name
end
alias jet3745_character_index character_index
def character_index(*args, &block)
index = jet3745_character_index(*args, &block)
return index unless SceneManager.scene_is?(Scene_Battle)
states.sort {|a, b| b.priority <=> a.priority }.each {|a|
if (add = Jet::VBS::STATE_SPRITES[a.id])
return index + add[1]
end
}
return index
end
end
class Sprite_Battler
alias jet3835_update_bitmap update_bitmap
def update_bitmap(*args, &block)
if @battler.actor? || @battler.bat_sprite?
actor_update_bitmap
elsif @battler.enemy?
jet3835_update_bitmap(*args, &block)
end
end
def actor_update_bitmap
@timer ||= 0
@index ||= 1
@char_index ||= @battler.character_index
@back_time ||= false
index = @index
char_index = @char_index
@timer += 1
(@index += (@back_time ? -1 : 1); @timer = 0) if @timer == 19
if @index == 3
@back_time = true
@index = 1
elsif @index == -1
@back_time = false
@index = 1
end
@char_index = @battler.character_index
bitmap = Cache.character(@battler.character_name)
return if bitmap == @bitmap && index == @index && @char_index == char_index
self.bitmap = bitmap
sign = @battler.character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
dir = BattleManager.player_dir
dir = 10 - dir if @battler.is_a?(Game_Enemy)
sx = (@battler.character_index % 4 * 3) * cw + (cw * @index)
sy = (@battler.character_index / 4 * 4 + (dir - 2) / 2) * ch
self.src_rect.set(sx, sy, cw, ch)
end
alias jet3745_update_origin update_origin
def update_origin(*args, &block)
if @battler.actor? || @battler.bat_sprite?
actor_update_origin
elsif @battler.enemy?
jet3745_update_origin(*args, &block)
end
end
def actor_update_origin
self.ox = (@actor_ox ||= 0)
self.oy = (@actor_oy ||= 0)
end
def revert_to_normal
self.blend_type = 0
self.color.set(0, 0, 0, 0)
self.opacity = 255
if bitmap && @battler && !@battler.actor? && !@battler.bat_sprite?
self.ox = bitmap.width / 2 if bitmap
self.src_rect.y = 0
end
end
def slide_forward(amount = Jet::VBS::SLIDE_AMOUNT, frame = Jet::VBS::FRAME_SLIDE)
dir = BattleManager.player_dir
dir = 10 - dir if @battler.is_a?(Game_Enemy)
case dir
when 2
affect = :@actor_oy
frame *= -1
when 4
affect = :@actor_ox
amount *= -1
when 6
affect = :@actor_ox
frame *= -1
when 8
affect = :@actor_oy
amount *= -1
end
orig_amount = amount
until (orig_amount < 0 ? amount >= 0 : amount <= 0)
instance_variable_set(affect, instance_variable_get(affect) + frame)
amount += frame
SceneManager.scene.spriteset.update
Graphics.update
end
end
def slide_backward(amount = Jet::VBS::SLIDE_AMOUNT, frame = Jet::VBS::FRAME_SLIDE)
dir = BattleManager.player_dir
dir = 10 - dir if @battler.is_a?(Game_Enemy)
case dir
when 2
affect = :@actor_oy
amount *= -1
when 4
affect = :@actor_ox
frame *= -1
when 6
affect = :@actor_ox
amount *= -1
when 8
affect = :@actor_oy
frame *= -1
end
orig_amount = amount
until (orig_amount < 0 ? amount >= 0 : amount <= 0)
instance_variable_set(affect, instance_variable_get(affect) + frame)
amount += frame
SceneManager.scene.spriteset.update
Graphics.update
end
end
end
class Scene_Battle
attr_reader :spriteset
def show_attack_animation(targets)
show_normal_animation(targets, @subject.atk_animation_id1, false)
show_normal_animation(targets, @subject.atk_animation_id2, true)
end
alias jet3746_use_item use_item
def use_item(*args, &block)
sprite = @spriteset.battler_to_sprite(@subject)
if (@subject.actor? || @subject.bat_sprite?)
sprite.slide_backward if @subject.current_action.guard?
sprite.slide_forward if !@subject.current_action.guard?
end
jet3746_use_item(*args, &block)
if (@subject.actor? || @subject.bat_sprite?)
sprite.slide_backward if !@subject.current_action.guard?
sprite.slide_forward if @subject.current_action.guard?
end
end
end
class Spriteset_Battle
def battler_to_sprite(actor)
battler_sprites.each {|a|
return a if a.battler == actor
}
return false
end
end
class Window_BattleEnemy
alias jet3745_update update
def update(*args, &block)
jet3745_update(*args, &block)
if self.active && Jet::VBS::DO_FLASH
if Object.const_defined?(:Mouse)
$game_troop.alive_members.each {|a|
img = SceneManager.scene.spriteset.battler_to_sprite(a)
x = img.x - img.ox
y = img.y - img.oy
if Mouse.area?(x, y, img.src_rect.width, img.src_rect.height)
self.index = a.index
end
}
end
active_troop = $game_troop.alive_members[@index]
sprite = SceneManager.scene.spriteset.battler_to_sprite(active_troop)
sprite.start_effect(:whiten) if !sprite.effect?
end
end
end
class Window_BattleActor
alias jet3745_update update
def update(*args, &block)
jet3745_update(*args, &block)
if self.active && Jet::VBS::DO_FLASH
if Object.const_defined?(:Mouse)
$game_party.alive_members.each {|a|
img = SceneManager.scene.spriteset.battler_to_sprite(a)
x = img.x - img.ox
y = img.y - img.oy
if Mouse.area?(x, y, img.src_rect.width, img.src_rect.height)
self.index = a.index
end
}
end
active_troop = $game_party.members[@index]
sprite = SceneManager.scene.spriteset.battler_to_sprite(active_troop)
sprite.start_effect(:whiten) if !sprite.effect?
end
end
end
class Window_ActorCommand
alias jet3745_update update
def update(*args, &block)
jet3745_update(*args, &block)
if self.active && Jet::VBS::DO_FLASH
active_troop = @actor
sprite = SceneManager.scene.spriteset.battler_to_sprite(active_troop)
sprite.start_effect(:whiten) if !sprite.effect?
end
end
end
class Game_Action
def guard?
item == $data_skills[subject.guard_skill_id]
end
end
Re: [résolu]Mon héro recule quand il fait "se défendre"
Sam 8 Fév 2014 - 13:18
- vincent26Membre
- Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010
Re: [résolu]Mon héro recule quand il fait "se défendre"
Sam 8 Fév 2014 - 13:22
oui il ne faut pas utiliser le bouton sélectionner de la boite de script du forum il vaut mieux le sélectionné soit même car sinon le script et tout décaler sinon supprime les espace avant le =begin et avant le =end quelqu ligne aprés
Re: [résolu]Mon héro recule quand il fait "se défendre"
Sam 8 Fév 2014 - 13:28
PARFAIT !
Un très grand merci à toi Vincent
Un très grand merci à toi Vincent
- vincent26Membre
- Nombre de messages : 766
Age : 28
Localisation : baume de transit le village paumé
Distinction : aucune
Date d'inscription : 17/08/2010
Re: [résolu]Mon héro recule quand il fait "se défendre"
Sam 8 Fév 2014 - 13:30
Ya pas de quoi ^^
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|