Group: Member
Posts: 25
Type: Mapper
RM Skill: Masterful
Hi all, I'm currently using ???nOBodY??? (aka sUBzeR_0)'s script called ''Spell System v1.1''
Script
CODE
#=============================================================================== # Spell System v1.1 # by ???nOBodY??? (aka sUBzeR_0) # Last Updated: 12/1/2010 # # Version 1.1 # #=============================================================================== # # Update History: # - Version 1.1 - Added the option to randomize reflect's behavior # - Version 1.0 - Initial release # #=============================================================================== # # This script will provide various functions for a new type of skill called # spells. Spells, by default, are any skills that have a Spirit_F value. In # addition, there are some new states such as reflect, atheist, and vanish, # which affect and are affected by spells. # # Reflect: If a spell targets a target with the reflect state, that spell is # reflected back at the same index as the original target. If target's index is # an index that doesn't exist in the party, it is reduced by the party size. For # example, enemy 5 will reflect back at actor 1. With the random reflection # module options, you can change this behavior from linear to random. # # Atheist: A monster/character with this state has their spi raised to the max, # but they cannot cast any spells. # # Perma Silence: Currently only used for atheist state. Make sure this state has # it's "restriction" effect set to "cannot cast spells". # # Vanish: A character with this state has the interesting effect of losing this # evasion-granting state when hit by a spell. Module option available for if you # want this effect even if the spell is reflected. As for what vanish actually # does, at the moment, nothing. Unless you use a different script, or edit the # state itself that is. # # Truespell: A spell tagged as <truespell> bypasses the atheist state. # # If using any Tankentai version, uncomment the method arguments on lines 289 & # 324. Also, add this bit of code to the top of the config script: # # $imported = {} if $imported == nil # $imported["Tankentai"] = true # #=============================================================================== # Credits: # # -???nOBodY??? (aka sUBzeR_0) #=============================================================================== # # Aliases: # - Scene_Battle: update # - Scene_Battle: make_escape_ratio # - Scene_Battle: turn_end # - Scene_Battle: execute_action_skill # #===============================================================================
$imported = {} if $imported == nil $imported["SpellSystemCore"] = true
module SUBZERO_MODULE # If true, all skills with a Spirit F value greater than 0 are automatically # defined as "spells". AUTO_SPELL_DEFINING = true
# If true, the vanish state will be removed when hit by a spell, even if the # spell itself is reflected. LOSE_VANISH_IF_REFLECTED = true
# If true, reflect will randomly reflect back a spell to a random target. # Only works for single target attacks. RANDOM_REFLECT_EFFECT_PRIMARY = true
# If true, reflect will randomly reflect back a spell to a random target. # Only works for single target attacks, and if the target index doesn't # exist in the party. RANDOM_REFLECT_EFFECT_SECONDARY = true
REFLECT_ANIMATION = 113 # Animation ID for reflecting spells TRUESPELL_ANIMATION = nil # Animation ID for truespell spells; nil to disable REFLECT_STATE = 27 # State ID for reflect state ATHEIST_STATE = 43 # State ID for atheist state PERMA_SILENCE_STATE = 44 # State ID for perma silence state; for atheist state VANISH_STATE = 45 # State ID for vanish state end
#=============================================================================== # CUSTOMIZATION END. FURTHER EDITTING IS DONE AT YOUR OWN RISK. YOU HAVE BEEN WARNED. #===============================================================================
module SUBZERO_MODULE module REGEXP SPELL = /<(?:SPELL|spell)>/i NONSPELL = /<(?:NONSPELL|nonspell)>/i NONREFLECTABLE = /<(?:NONREFLECTABLE|nonreflectable)>/i TRUESPELL = /<(?:TRUESPELL|truespell)>/i end end
module SUBZERO_MODULE module SPELL_SYSTEM def self.check_note_tags(obj, tag) obj.note.each_line { |notetag| case notetag when tag return true end } return false end end end
module RPG class Enemy def has_atheist_state? if @has_atheist_state.nil? txt = SUBZERO_MODULE::SPELL_SYSTEM.check_note_tags(self, /<(?:atheist)>/i) @has_atheist_state = txt end return @has_atheist_state end end end
if SUBZERO_MODULE::AUTO_SPELL_DEFINING == true if @spi_f > 0 @is_spell = true @is_reflectable = true end end
self.note.split(/[\r\n]+/).each { |line| case line when SUBZERO_MODULE::REGEXP::SPELL @is_spell = true @is_reflectable = true when SUBZERO_MODULE::REGEXP::NONSPELL @is_spell = false @is_reflectable = false when SUBZERO_MODULE::REGEXP::NONREFLECTABLE @is_reflectable = false when SUBZERO_MODULE::REGEXP::TRUESPELL @is_truespell = true end } end
def is_spell? sz_cache_skill_spellsystem if @is_spell == nil return @is_spell end
def is_reflectable? sz_cache_skill_spellsystem if @is_reflectable == nil return @is_reflectable end
def is_truespell? sz_cache_skill_spellsystem if @is_truespell == nil return @is_truespell end end
class Game_BattleAction
#-------------------------------------------------------------------------- # * Create Target Array #-------------------------------------------------------------------------- def sz_make_targets_reflected if attack? return make_attack_targets elsif skill? return sz_make_obj_targets_reflected(skill) elsif item? return make_obj_targets(item) end end
#-------------------------------------------------------------------------- # * Create Skill or Item Targets # obj : Skill or item #-------------------------------------------------------------------------- def sz_make_obj_targets_reflected(obj) targets = [] random_reflection_index = 0 if $imported["LargeParty"] random_reflection_index = 1 + rand(KGC::LargeParty::MAX_BATTLE_MEMBERS - 1) else random_reflection_index = 1 + rand(4 - 1) end # if $imported["Tankentai"] # random_reflection_index = 1 + rand(N01::MAX_MEMBER - 1) # else # random_reflection_index = 1 + rand(4 - 1) # end if obj.for_opponent? if obj.for_random? if obj.for_one? # One random enemy number_of_targets = 1 elsif obj.for_two? # Two random enemies number_of_targets = 2 else # Three random enemies number_of_targets = 3 end number_of_targets.times do targets.push(friends_unit.random_target) end elsif obj.dual? # One enemy, dual if SUBZERO_MODULE::RANDOM_REFLECT_EFFECT_PRIMARY == true targets.push(friends_unit.smooth_target(random_reflection_index)) else targets.push(friends_unit.smooth_target(@target_index)) end targets += targets elsif obj.for_one? # One enemy if SUBZERO_MODULE::RANDOM_REFLECT_EFFECT_PRIMARY == true targets.push(friends_unit.smooth_target(random_reflection_index)) else targets.push(friends_unit.smooth_target(@target_index)) end else # All enemies targets += friends_unit.existing_members end elsif obj.for_user? # User targets.push(battler) elsif obj.for_dead_friend? if obj.for_one? # One ally (incapacitated) targets.push(friends_unit.smooth_dead_target(@target_index)) else # All allies (incapacitated) targets += friends_unit.dead_members end elsif obj.for_friend? if obj.for_one? # One ally if SUBZERO_MODULE::RANDOM_REFLECT_EFFECT_PRIMARY == true targets.push(opponents_unit.smooth_target(random_reflection_index)) else if SUBZERO_MODULE::RANDOM_REFLECT_EFFECT_SECONDARY == true targets.push(opponents_unit.smooth_target(random_reflection_index)) else targets.push(opponents_unit.smooth_target(@target_index)) end end else # All allies targets += opponents_unit.existing_members end end return targets.compact end
end
class Scene_Battle < Scene_Base
#-------------------------------------------------------------------------- # * Execute Battle Action: Skill (Reflected) #-------------------------------------------------------------------------- def sz_execute_action_skill_reflected skill = @active_battler.action.skill text = @active_battler.name + skill.message1 @message_window.add_instant_text(text) unless skill.message2.empty? wait(10) @message_window.add_instant_text(skill.message2) end targets = @active_battler.action.sz_make_targets_reflected display_animation(targets, skill.animation_id) @active_battler.mp -= @active_battler.calc_mp_cost(skill) $game_temp.common_event_id = skill.common_event_id for target in targets target.skill_effect(@active_battler, skill) display_action_effects(target, skill) end end
alias sz_spell_system_main_update update def update for i in 0...$game_troop.members.size if $game_troop.members[i].state?(SUBZERO_MODULE::ATHEIST_STATE) == false if $game_troop.members[i].state?(SUBZERO_MODULE::PERMA_SILENCE_STATE) $game_troop.members[i].remove_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) end end end for i in 0...$game_party.members.size if $game_party.members[i].state?(SUBZERO_MODULE::ATHEIST_STATE) == false if $game_party.members[i].state?(SUBZERO_MODULE::PERMA_SILENCE_STATE) $game_party.members[i].remove_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) end end end sz_spell_system_main_update end
alias sz_spell_system_main_make_escape_ratio make_escape_ratio def make_escape_ratio for i in 0...$game_troop.members.size if $data_enemies[$game_troop.members[i].enemy_id].has_atheist_state? if $imported["LimitBreak"] $game_troop.members[i].spi = KGC::LimitBreak::ENEMY_PARAMETER_LIMIT else $game_troop.members[i].spi = 999 end $game_troop.members[i].add_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) end end for i in 0...$game_party.members.size if $game_party.members[i].state?(SUBZERO_MODULE::ATHEIST_STATE) if $imported["LimitBreak"] $game_party.members[i].spi = KGC::LimitBreak::ACTOR_PARAMETER_LIMIT else $game_party.members[i].spi = 999 end $game_party.members[i].add_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) end end sz_spell_system_main_make_escape_ratio end
alias sz_spell_system_main_turn_end turn_end def turn_end#(member) for i in 0...$game_troop.members.size if $game_troop.members[i].state?(SUBZERO_MODULE::ATHEIST_STATE) if $imported["LimitBreak"] $game_troop.members[i].spi = KGC::LimitBreak::ENEMY_PARAMETER_LIMIT else $game_troop.members[i].spi = 999 end $game_troop.members[i].add_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) #~ else #~ remove_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) end end for i in 0...$game_party.members.size if $game_party.members[i].state?(SUBZERO_MODULE::ATHEIST_STATE) if $imported["LimitBreak"] $game_party.members[i].spi = KGC::LimitBreak::ACTOR_PARAMETER_LIMIT else $game_party.members[i].spi = 999 end $game_party.members[i].add_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) #~ else #~ remove_state(SUBZERO_MODULE::PERMA_SILENCE_STATE) end end sz_spell_system_main_turn_end#(@active_battler) end
alias sz_spell_system_main_execute_action_skill execute_action_skill unless $@ def execute_action_skill skill = @active_battler.action.skill targets = @active_battler.action.make_targets temp_spi = 0 counter = 0 for target in targets if skill.is_spell? if skill.is_reflectable? && target.state?(SUBZERO_MODULE::REFLECT_STATE) display_animation(targets, SUBZERO_MODULE::REFLECT_ANIMATION.to_i) sz_execute_action_skill_reflected if SUBZERO_MODULE::LOSE_VANISH_IF_REFLECTED if target.state?(SUBZERO_MODULE::VANISH_STATE) target.remove_state(SUBZERO_MODULE::VANISH_STATE) end end counter = 1 break else if skill.is_truespell? && target.state?(SUBZERO_MODULE::ATHEIST_STATE) display_animation(targets, SUBZERO_MODULE::TRUESPELL_ANIMATION.to_i) unless SUBZERO_MODULE::TRUESPELL_ANIMATION == nil temp_spi = target.spi target.spi = 0 sz_spell_system_main_execute_action_skill unless counter == 1 target.spi = temp_spi counter = 1 break end end end end skill = @active_battler.action.skill unless counter == 1 targets = @active_battler.action.make_targets unless counter == 1 if skill.is_spell? && counter != 1 if target.state?(SUBZERO_MODULE::VANISH_STATE) target.remove_state(SUBZERO_MODULE::VANISH_STATE) end end sz_spell_system_main_execute_action_skill unless counter == 1 counter = 0 end
end
This script allows the creation of a "Reflect" state. When a party member casts a spell on an enemy that was given the Reflect buff, the spell is bounced back at the caster.
However, if I use a spell that targets all enemies while only one of them has reflect, none of them will get hurt and the spell will be bounced back at all of my party members. Is there anyway to make it so that only enemies with reflect are immune to a spell when it targets all enemies? And so that it only gets bounced once for every enemy with reflect?
The main issue here is because if one of my party members has Reflect, when an enemy will cast a spell that targets all of my party, I don't want those without reflect to be immune to the spell. I also don't want the enemy to be punished more than once for every character with the Reflect buff.
Thanks for your help!
This post has been edited by TheDrifter: Nov 10 2011, 07:07 PM