#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #_/ ◆ Attack Element Settings - KGC_SetAttackElement ◆ VX ◆ #_/ ◇ Last Update: 2008/08/28 #_/ ◆ Written by TOMY #_/ ◆ Translation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/----------------------------------------------------------------------------- #_/ This script adds a function to set up attack elements to individual actors. #_/----------------------------------------------------------------------------- #_/ Note Tags: #_/ To set an enemy's attack element, insert in its Notes. #_/ At the moment of writing, is untested. #_/ Further investigation is needed. #_/ #_/ ◆ Script Commands ◆ #_/ This command is used in "Script" function in the third page of event #_/ commands under "Advanced". #_/ #_/ * set_actor_attack_element(ActorID, [ ElementID ]) #_/ This has the same effect as ACTOR_ELEMENT. (See Customization Block) #_/ Where ActorID = The specified actor in the database. #_/ Where ElementID = The specified element(s) in the database. #_/ To remove all elements, set ElementID to "nil" (Without quotations) #_/ #_/ Example: set_actor_attack_element(1, [2, 14]) #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ $data_system = load_data("Data/System.rvdata") if $data_system == nil #==============================================================================# # ★ Customization ★ # #==============================================================================# module KGC module SetAttackElement # ◆ Actor Attack Element Setup ◆ # This allows you to assign an element type to an actor's basic attack. ACTOR_ELEMENT = [] # ← Do not remove or alter this! # Format: # ACTOR_ELEMENT[ActorID] = [ElementID] # You may also set up multiple elements: # ACTOR_ELEMENT[ActorID] = [ElementID, ElementID, ElementID] # Example: This following sets Ralph's attack element to Fire and Wind # ACTOR_ELEMENT[1] = [9, 14] # Example: The follows sets Ulrika's attack element to Thunder. # ACTOR_ELEMENT[2] = [11] # ★ Insert Custom Actor Attack Element Setup(s) Below Here ★ ACTOR_ELEMENT[1] = [9] # ★ Insert Custom Actor Attack Element Setup(s) Above Here ★ # ◆ Non-Inherited Elements ◆ # This allows you to prevent actors from inheriting specified elements. # Format: # IGNORE_ELEMENT = [ElementID, ElementID, ElementID] # You may also set up a succession array: # Example: IGNORE_ELEMENT = [1..6, 10] IGNORE_ELEMENTS = [] end end #=============================================================================# # ★ End Customization ★ # #=============================================================================# #=================================================# # IMPORT # #=================================================# $imported = {} if $imported == nil $imported["SetAttackElement"] = true #=================================================# #============================================================================== # □ KGC::SkillCPSystem::Regexp #============================================================================== # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # # Note Field Tag Strings # # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # # Whatever word(s) are after the separator ( | ) in the following lines are # what are used to determine what is searched for in the "Note" section of a # skill or enemy. module KGC::SetAttackElement # Regular Expressions Module module Regexp # Skill Module module Skill # Inherit Attack Element tag string INHERIT_ATTACK_ELEMENT = /<(?:INHERIT_ATTACK_ELEMENT|inhatkelem)>/i end # Enemy Module module Enemy # Attack element tag string ATTACK_ELEMENT = /<(?:ATTACK_ELEMENT|atkelem)\s*(\d+(?:\s*,\s*\d+)*)>/i end end #-------------------------------------------------------------------------- # ○ Create Ignored Elements List #-------------------------------------------------------------------------- def self.create_ignore_element_list result = [] IGNORE_ELEMENTS.each { |e| if e.is_a?(Range) result |= e.to_a elsif e.is_a?(Integer) result |= [e] end } return result.sort end # Set ignored element ID list to array. IGNORE_ELEMENT_ID_LIST = create_ignore_element_list end #=================================================# #============================================================================== # □ KGC::Commands #============================================================================== module KGC module Commands module_function #-------------------------------------------------------------------------- # ○ Set Actor Attack Element # actor_id : Actor ID # element_set : Element (nil = None) #-------------------------------------------------------------------------- def set_actor_attack_element(actor_id, element_set = nil) actor = $game_actors[actor_id] return if actor == nil actor.attack_element_set = element_set end end end #=================================================# #=================================================# # INCLUDE COMMANDS # #=================================================# # Include KGC::Commands in Game_Interpreter # #=================================================# class Game_Interpreter include KGC::Commands end #=================================================# #============================================================================== # ■ RPG::UsableItem #============================================================================== class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # ○ Determine Attack Element Inheritance #-------------------------------------------------------------------------- def attack_element_inherit? return false end end #=================================================# #============================================================================== # ■ RPG::Skill #============================================================================== class RPG::Skill < RPG::UsableItem #-------------------------------------------------------------------------- # ○ Create Set Attack Element Cache #-------------------------------------------------------------------------- def create_set_attack_element_cache @__inherit_attack_element = false self.note.split(/[\r\n]+/).each { |line| case line when KGC::SetAttackElement::Regexp::Skill::INHERIT_ATTACK_ELEMENT # When included, set flag to true @__inherit_attack_element = true end } end #-------------------------------------------------------------------------- # ○ Determine Attack Element Inheritance #-------------------------------------------------------------------------- def attack_element_inherit? create_set_attack_element_cache if @__inherit_attack_element == nil return @__inherit_attack_element end end #=================================================# #============================================================================== # ■ RPG::Enemy #============================================================================== class RPG::Enemy #-------------------------------------------------------------------------- # ○ Create Set Attack Element Cache #-------------------------------------------------------------------------- def create_set_attack_element_cache @__attack_element_set = [] self.note.split(/[\r\n]+/).each { |line| case line when KGC::SetAttackElement::Regexp::Enemy::ATTACK_ELEMENT # When included, set elements to array elements = [] $1.scan(/\d+/).each { |num| elements << num.to_i } @__attack_element_set |= elements end } end #-------------------------------------------------------------------------- # ○ Determine Attack Element #-------------------------------------------------------------------------- def attack_element_set create_set_attack_element_cache if @__attack_element_set == nil return @__attack_element_set end end #=================================================# #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ Public Instance Variable #-------------------------------------------------------------------------- attr_accessor :attack_element_set # Attack Element Set #-------------------------------------------------------------------------- # ● Setup Elements #-------------------------------------------------------------------------- alias element_set_KGC_SetAttackElement element_set def element_set return (element_set_KGC_SetAttackElement | attack_element_set) end #-------------------------------------------------------------------------- # ○ Set elements to array #-------------------------------------------------------------------------- def attack_element_set result = [] result |= @attack_element_set if @attack_element_set.is_a?(Array) return result end #-------------------------------------------------------------------------- # ● Create Object Damage Value # user : User # obj : Target # @hp_damage, @mp_damage, and absorbtion must be set. #-------------------------------------------------------------------------- alias make_obj_damage_value_KGC_SetAttackElement make_obj_damage_value def make_obj_damage_value(user, obj) # Temporarily duplicate set element last_element_set = obj.element_set.clone # Inherit set element obj.element_set = get_inherited_element_set(user, obj) make_obj_damage_value_KGC_SetAttackElement(user, obj) # Set element from cloned array obj.element_set = last_element_set end #-------------------------------------------------------------------------- # ○ Obtain Inherited Set Elements # user : User # obj : Target #-------------------------------------------------------------------------- def get_inherited_element_set(user, obj) result = obj.element_set.clone return result unless obj.attack_element_inherit? result |= (user.element_set - KGC::SetAttackElement::IGNORE_ELEMENT_ID_LIST) return result end end #=================================================# #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● Determine Attack Element #-------------------------------------------------------------------------- alias element_set_KGC_SetAttackElement element_set def element_set return (element_set_KGC_SetAttackElement | attack_element_set) end #-------------------------------------------------------------------------- # ○ Set Attack Element #-------------------------------------------------------------------------- def attack_element_set result = super elements = KGC::SetAttackElement::ACTOR_ELEMENT[self.id] result |= elements if elements.is_a?(Array) return result end end #=================================================# #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ○ Set Attack Element #-------------------------------------------------------------------------- def attack_element_set return (super | enemy.attack_element_set) end end #=================================================#