ho trovato questo addon per il tankentai che permette di creare un'abilita come altruismo,ma non mi funziona....
io ho fatto cosi:
ho creato una nuova abilita e un nuovo stato
l'abilita aggiunge il nuovo stato
lo stato ha il seguente note tag <COVER 1 0>
ecco lo script
Spoiler
#_/ > cover ally always : <COVER 1 0>
#_/ > 50% chance of physically cover ally: <COVER 2 50>
#_/ > cover phys and mag damage if ally hp is at 20%: <COVER 3 20>
#_/
#_/----------------------------------------------------------------------------
#_/ Where to install:
#_/ Above Main, after the battle system.
#_/----------------------------------------------------------------------------
#_/ Compatible:
#_/ Done and tested for SBS3.4e + ATB 1.2c
#_/-----------------------------------------------------------------------------
#_/
#_/ !ATTENTION! : don't forget to check remove state at end of battle, or
#_/ bad stuff will occur!
#_/-----------------------------------------------------------------------------
#_/
#_/ Version Log:
#_/ 1.0 - Started Script, defender takes damage for protected, pops damage
#_/ 1.1 - Added sprite movement
#_/ 1.2 - Corrected some bugs regarding damage and skill effects
#_/ 2.0 - Added more cover types
#_/ 2.1 - Added protected battler animation
#_/
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#------------------------------------------------------------------------------
# Cover SEQUENCE
# If you know how to use takentai action sequences you can edit this one.
# Please take into account that the script places the defender in the covered
# ally position, no matter what COVER_RESET does.
# COVER_RESET is only used to make the battler stand in place for a time, and
# then return to his original start position.
#
# BUG NOTE:
# Sometimes the defender turn starts before he can execute
# "Start Pos Return", and will stay in the ally being defended spot until
# he is called to defend again. You can add "Start Pos Return" to your
# "COMMAND_INPUT" and this will no longer occur.
# In the next version i will adress this issue, when i have the time z.z
#------------------------------------------------------------------------------
module N01
COVERSCRIPT_SEQUENCE = {
"COVER_RESET" => ["30","Start Pos Return","FLEE_RESET"],
"BE_COVERED" => ["EVADE_JUMP","20","Start Pos Return","FLEE_RESET"]
}
ACTION.merge!(COVERSCRIPT_SEQUENCE)
end
#==============================================================================
# ¦ State
#==============================================================================
class RPG::State
attr_accessor :skill_user
end
#used by Scene_battle
class Spriteset_Battle
attr_accessor :actor_sprites
#returns the position of the battler in actor_sprites array
def pos_in_sprite_array(battler_id)
for i in 0...actor_sprites.size
if actor_sprites[i].battler.id == battler_id
return i
end
end
return -1
end
end
#access to spriteset
class Scene_Battle < Scene_Base
attr_accessor :spriteset
end
#==============================================================================
# ¦ Game_Battler
#==============================================================================
class Game_Battler
alias lusitano_cover_old_initialize initialize
def initialize
lusitano_cover_old_initialize #calls old initialize
@covered = nil #flag, true if actor battler os being protected
@protector = 0 # id of battler who is protecting
@protector_spr_id = 0 # id of battler sprite in $scene.spriteset.actor_sprites
@cover_type = 0 # type of cover (physical, magical, both, bellow %hp
@cover_param = 0 # second param for cover ( chance, hp%, etc.)
@is_covering = nil # flag, true if actor is covering another battler
end
alias cover_skill_effect skill_effect
def skill_effect(user, skill)
@skill_user = user
cover_skill_effect(user, skill)
end
#--------------------------------------------------------------------------
# ? check_for_state_extensions
# sees if the added state has extensions defined
# state_id : position of state in the $data_states[] array
#--------------------------------------------------------------------------
def LUS_COVER_check_for_state_extensions(state_id)
return unless @states.include?(state_id)
$data_states[state_id].note.each_line { |line|
case line
when /<(?:cover|COVER)\s*(\d+)\s*(\d+)>/i
@cover_type = $1.to_i
@cover_param = $2.to_i
@covered = true
@protector = $data_states[state_id].skill_user.id
#$game_actors[@protector].set_covering
@protector_spr_id = $scene.spriteset.pos_in_sprite_array(@protector)
return true
end
}
end
#--------------------------------------------------------------------------
# ? alias add_state
# checks for element modifiers
# state_id : position of state in the $data_states[] array
#--------------------------------------------------------------------------
alias add_state_lus_cover add_state
def add_state(state_id)
state = $data_states[state_id]
state.skill_user = @skill_user
add_state_lus_cover(state_id)
LUS_COVER_check_for_state_extensions(state_id)
#checks if self was selected to cover self
remove_state_lus_cover(state_id) if @protector == self.id
end
#--------------------------------------------------------------------------
# ? alias remove_state
# resets affliction type to 1 if state was an afliction
# state_id : position of state in the $data_states[] array
#--------------------------------------------------------------------------
alias remove_state_lus_cover remove_state
def remove_state(state_id)
#checks and reverts to the old weapon_animation_id
if LUS_COVER_check_for_state_extensions(state_id) == true
@cover_type = 0
@covered = false
@protector = nil
@protector_spr_id = 0
@cover_param = 0
end
remove_state_lus_cover(state_id)
end
#--------------------------------------------------------------------------
# * Checks if type of cover allows the battler to be covered
# cover_type : type of cover
# Returns true if battler checks conditions for being covered
#--------------------------------------------------------------------------
def can_be_Covered
# if protector is dead...
if $game_actors[@protector].dead? && @states.size > 0
#check wich state will be removed
for state in @states
if LUS_COVER_check_for_state_extensions(state.id) == true
remove_state(state.id)
end
end
return false
end
#checks type of cover
case @cover_type
when 1,4 #protect physical damage
return true
when 2,5
chance = rand(100) #chance of being covered
return false unless chance >= @cover_param
return true
when 3,6 # if hp is bellow the setting
return false unless ((self.hp.to_f / self.maxhp.to_f) * 100) <= @cover_param
return true
else
return false
end
end
#--------------------------------------------------------------------------
# * Apply State Changes
# obj : Skill, item, or attacker
#--------------------------------------------------------------------------
alias lus_cover_apply_state_changes apply_state_changes
def apply_state_changes(obj)
if @covered == true
#checks if battler can be covered
return if can_be_Covered
end
lus_cover_apply_state_changes(obj)
end
#--------------------------------------------------------------------------
# * Calculation of Damage From Normal Attack
# attacker : Attacker
# The results are substracted added to @hp_damage
# @hp_damage Will be used by execute_damage
#--------------------------------------------------------------------------
alias lusitano_cover_mk_atk_dam make_attack_damage_value
def make_attack_damage_value(attacker)
#calculates de HP_DAMAGE the user would receive
# this is a call to the original make_attack_damage_value
lusitano_cover_mk_atk_dam(attacker)
#checks if user is being covered
return unless @covered == true
#checks if battler can be covered
return unless can_be_Covered
@hp_damage = 0 # takes no hp damage
#calculates the damage value
$game_actors[@protector].make_attack_damage_value(attacker)
#executes hp change
$game_actors[@protector].execute_damage(attacker)
#pops protector damage
#$scene.spriteset.actor_sprites[@protector_spr_id].damage_pop($game_actors[@protector].hp_damage)
cover_sprite_movement
end # end of method
#--------------------------------------------------------------------------
# * Calculation of Damage From OBJ
# user : user (game_battler)
# The results are substracted added to @hp_damage or @mp_damage
# @hp_damage Will be used by execute_damage
#--------------------------------------------------------------------------
alias lusitano_cover_make_obj_damage_value make_obj_damage_value
def make_obj_damage_value(user, obj)
lusitano_cover_make_obj_damage_value(user, obj)
return unless @hp_damage > 0 && obj.is_a?(RPG::Skill)
return unless obj.physical_attack || @cover_type > 3
#checks if user is being covered
return unless @covered == true
#checks if battler can be covered
return unless can_be_Covered
@hp_damage = 0 # takes no hp damage
#calculates the damage value
$game_actors[@protector].make_attack_damage_value(user)
#executes hp change
$game_actors[@protector].execute_damage(user)
#defender sprite animation
cover_sprite_movement
$game_actors[@protector].apply_state_changes(obj)
end
#--------------------------------------------------------------------------
# * Cover Sprite Movement
# Handles the sprite animation for cover event
#--------------------------------------------------------------------------
def cover_sprite_movement
#$scene is Scene_Battle
#actor_sprites is sprite_battler
#makes battler do be_covered_action
self_sprite_id = $scene.spriteset.pos_in_sprite_array(self.id)
action = $game_actors[self.id].be_covered_action
$scene.spriteset.set_action(true, self_sprite_id, action)
#makes defender jump to spot!
$game_actors[@protector].change_base_position(self.position_x, self.position_y)
# $game_actors[@protector].position_y = self.position_y
#sets return sequence
action = $game_actors[@protector].cover_action
$scene.spriteset.set_action(true, @protector_spr_id, action)
#pops defender damage
$scene.spriteset.actor_sprites[@protector_spr_id].damage_pop($game_actors[@protector].hp_damage)
#pop alternative ( i should check this later)
#@spriteset.set_damage_pop(actor, member.index, mp_damage)
# damage_num is from the actors interpreter, it forces and pops the damage
# but takes a while to take place so it is not a good alternative
# $game_actors[@protector].damage_num($game_actors[@protector].hp_damage)
end
#returns the cover_action
def cover_action
return "COVER_RESET"
end
#returns the be covered action
def be_covered_action
return "BE_COVERED"
end
end