counter atack

Ver o tópico anterior Ver o tópico seguinte Ir em baixo

counter atack

Mensagem  roberto em Sab Mar 13, 2010 9:58 pm

Script criado pelo site XMS.
Created by XMS site.
Tradução e tutorial por Moghunter.

CARACTERíSTICAS
O personagens que estiver sobre o status counter e receber ataque ofensivo
revidará o ataque ao seu inimigo
Spoiler:
################################################################################
################################### XMS ########################################
################################################################################
=begin
COUNTER ATTACK
(Habilidade Contra Ataque)

--------------------------------------------------------------------------------
Script criado pelo site XMS.
Created by XMS site.
Tradução e tutorial por Moghunter.
--------------------------------------------------------------------------------

CARACTERíSTICAS
O personagens que estiver sobre o status counter e receber ataque ofensivo
revidará o ataque ao seu inimigo

UTILIZAÇÃO
Crie o status com o nome de "Counter" e ao lado do nome defina o tipo de
contra ataque, Exemplo de nomeação:
-----------------
Counter -cr
-----------------

TIPOS DE CONTRA ATAQUE(Deve-se colocar ao lado do status "Counter")

-cr => Contra ataca todos os tipos de ação.
-crp => Contra ataca ataques fí­sicos.
-crm => Contra ataca ataques mágicos.
-cre => Contra ataca apenas ataque de determinados elementos
Coloque o numero ID do atributo ao lado do código, por exemplo:
-----------------
Counter -cre7
-----------------
-ca => Contra ataca quando recebe algun tipo de ação.
-cas => Contra ataca habilidades especifica.
Coloque o numero ID da habilidade ao lado do código, por exemplo:
-----------------
Counter -cas10
-----------------
-cai => Contra ataca itens especificos, a mesma explicação acima.
-caa => Contra ataca o comando ataque.
-cae => Contra ataca quando fugir.
-cac => Contra ataca com a mesma ação inimiga.

=end
#--------------------------------------------------------------------------------
class Game_Battler
STATE_COUNTER_NAME = "Counter"#Nome do status.
end
class Game_Battler
def states=(states)
@states = states
end
alias original_initialize_before_counter_action initialize
def initialize
original_initialize_before_counter_action()
@counter_action = Game_BattleAction.new
end
alias original_current_action_before_counter_action current_action
def current_action
if @counter_action.cleared?
return original_current_action_before_counter_action()
else
return @counter_action
end
end
def counter_action
return @counter_action
end
def counter_acting?
if !@counter_action.cleared?
return true
else
return false
end
end
#alias original_dead_before_counter_action dead?
#def dead?
# if self.counter_acting?
# return false
# else
# return original_dead_before_counter_action()
# end
#end
def counter_action_for(attacker, skill = nil)
if attacker.counter_acting?
return
end
#if !self.movable? || !self.exist?
# return
#end
if attacker.is_a?(Game_Actor)
if self.is_a?(Game_Actor)
return
end
ind = $game_party.get_index_by(attacker)
s_ind = $game_troop.get_index_by(self)
elsif attacker.is_a?(Game_Enemy)
if self.is_a?(Game_Enemy)
return
end
ind = $game_troop.get_index_by(attacker)
s_ind = $game_party.get_index_by(self)
end
if ind.nil? || s_ind.nil?
return
end

act_kind = 'a'
act_id = 0

for id in @states
if $data_states[id].name =~ /^#{STATE_COUNTER_NAME}/
react_cond = false
react_succ = false
for opt in $data_states[id].options
if opt =~ /^cr([pmedns])([0-9]*)/
kind = $1
id = $2.to_i
react_cond = true
case kind
when 'p'
if skill.nil? || skill.atk_f >= 100
react_succ = true
end
when 'm'
if !skill.nil? && skill.int_f >= 100
react_succ = true
end
when 'e'
if id.nil? || id.zero?
next
elsif skill.nil?
if attacker.is_a?(Game_Actor) && !$data_weapons[@weapon_id].nil?
if $data_weapons[@weapon_id].element_set.include?(id)
react_succ = true
end
end
elsif skill.element_set.include?(id)
react_succ = true
end

when 'n'
no_attack = true
when 's'
miss_attack = true
when 'd'
if self.dead? && self.movable?
react_succ = true
end
end

elsif opt =~ /^ca([asime])([0-9]*)/
act_kind = $1
act_id = $2.to_i
act_cond = true
end
end

if (!react_cond || react_succ)
counter = true
break
else
next
end

end
end

if !counter
return
end
if no_attack == true
if self.damage != "Miss"
self.hp += self.damage
self.damage = "Avoid!!"
self.critical = false
@state_changed = false
self.states = @old_states
end
end
if miss_attack == true and self.damage != "Miss"
return
end


if act_kind == 'c'
if skill.nil?
act_kind = 'a'
else
act_kind = 's'
act_id = skill.id
end
end

case act_kind
when 's'
s = $data_skills[act_id]
if s.nil? || ![0,1].include?(s.occasion) || !self.skill_can_use?(act_id)
return
end
self.counter_action.skill_id = act_id
self.counter_action.kind = 1
if [1,2].include?(s.scope)
self.counter_action.target_index = ind
else
self.counter_action.target_index = s_ind
end
when 'i'#item kind:2 basic:0
i = $data_items[act_id]
if !self.is_a?(Game_Actor) || i.nil? || ![0,1].include?(i.occasion) || !$game_party.item_can_use?(act_id)
return
end
self.counter_action.item_id = act_id
self.counter_action.kind = 2
if [1,2].include?(i.scope)
self.counter_action.target_index = ind
else
self.counter_action.target_index = s_ind
end
when 'a'
self.counter_action.kind = 0
self.counter_action.target_index = ind
self.counter_action.basic = 0
when 'e'
if !self.is_a?(Game_Enemy)
return
end
self.counter_action.kind = 0
self.counter_action.target_index = ind
self.counter_action.basic = 2
end
return

end
alias original_attack_effect_before_counter_action attack_effect
def attack_effect(attacker)
@old_states = self.states.clone
val = original_attack_effect_before_counter_action(attacker)
self.counter_action_for(attacker)
return val
end
alias original_skill_effect_before_counter_action skill_effect
def skill_effect(attacker, skill)
@old_states = self.states.clone
val = original_skill_effect_before_counter_action(attacker, skill)
self.counter_action_for(attacker, skill)
return val
end

end

class Game_Actor < Game_Battler
def skill_can_use?(skill_id)
#if not skill_learn?(skill_id)
# return false
#end
return super
end
end
class Game_BattleAction

alias :xp_original_initialize :initialize
def initialize
xp_original_initialize()
@turn_move_times = 0
end
def cleared?
if @speed == 0 && @kind == 0 && @basic == 3 && @skill_id == 0 && @item_id == 0 && @target_index == -1 && @forcing == false
return true
else
return false
end
end

end
class Game_Party
def get_index_by(actor)
for i in 0...@actors.sizeEste endereço de e-mail está sendo protegido de spam, vocíª precisa de Javascript habilitado para víª-lo ()
if @actors[i].equal?(actor)
return i
end
end
return nil
end
end
class Game_Troop
def get_index_by(enemy)
for i in 0...@enemies.sizeEste endereço de e-mail está sendo protegido de spam, vocíª precisa de Javascript habilitado para víª-lo ()
if @enemies[i].equal?(enemy)
return i
end
end
return nil
end
end
class Scene_Battle
alias original_update_phase4_step6_before_counter_action update_phase4_step6
def update_phase4_step6
original_update_phase4_step6_before_counter_action()
clear_counter_action(@active_battler)
activate_counter_action(@action_battlers)
end
def clear_counter_action(active_battler)
if active_battler.nil?
return
end
if !active_battler.counter_acting?
return
end
active_battler.counter_action.clear
return
end
def activate_counter_action(action_battlers)
if !action_battlers[0].nil?
if action_battlers[0].counter_acting?#????????????????????
return
end
end
counter_battlers = []
$game_party.actors.each{|a|
if a.counter_acting?
counter_battlers.push(a)
end
}
$game_troop.enemies.each{|e|
if e.counter_acting?
counter_battlers.push(e)
end
}
counter_battlers = counter_battlers.sort_by{|b| b.agi}
counter_battlers.each{ |b|
action_battlers.unshift(b)
}
return
end
end
class Game_Battler
if method_defined?(:cp)
alias original_cp_before_counter_action cp
def cp
if self.counter_acting?
return 65535
else
return original_cp_before_counter_action()
end
end
end
if method_defined?(:cp=)
alias original_cp_before_counter_action= cp=
def cp=(n)
if self.counter_acting?
return
else
self.original_cp_before_counter_action = n
end
end
end
end

module RPG
class State
def name
if @new_name.nil?
name_setting()
end
return @new_name
end

def options
if @options.nil?
name_setting()
end
return @options
end

def name_setting
names = @name.split(/ +\-/)
@new_name = names.shift
if @new_name.nil?
@new_name = ''
end
@options = names
if @options.nil?
@options = []
end
end

end
end
avatar
roberto
Admin

Mensagens : 75
Pontos : 204
Reputação : 3
Data de inscrição : 03/03/2010

Ver perfil do usuário http://morpgmaker.mo-rpg.com

Voltar ao Topo Ir em baixo

Ver o tópico anterior Ver o tópico seguinte Voltar ao Topo

- Tópicos similares

 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum