Announcement
Announcement
| 2nd Quarter Contest Announcement posted! See the Community Announcements section. |
New threads (complete scripts) here will go into a moderation queue. You will not see your thread appear when you create it. A moderator will decide if it will be approved or denied.
![]() ![]() |
May 10 2008, 04:36 AM
Post
#1
|
|
![]() †Crîtîcâl Bréâkér† ![]() Type: Spriter |
Phew.. I finished it atlas. I guess while Mr. A is out for a while we must learn od something right. So i decided to translate the KGC counter even though Mr. A had already translated it for his next demo. I know that I'm not good as Mr. A but I guess I must try my best. So here it goes....
CODE #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Counter - KGC_Counter ◆ VX ◆ #_/ ◇ Last update : 2008/04/27 ◇ #_/---------------------------------------------------------------------------- #_/ The counter for the conduct of specification is drawn up. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #============================================================================== # ★ Customization item - Customize ★ #============================================================================== module KGC module Counter # ◆ Counter frequency is restricted # true : As for the counter concerning the action of 1 time only 1 time. # false : Equal to a quantity which satisfies condition counter motion. RESTRICT_COUNTER = true end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ $imported = {} if $imported == nil $imported["Counter"] = true module KGC module Counter module Regexp # Start of counter definition BEGIN_COUNTER = /<(?:COUNTER|Counter)\s*([ASI])(\s*\:\s*\d+)? (\s+\d+[%%])?(\s*\/)?>/ix # Counter definition end END_COUNTER = /<\/(?:COUNTER|Counter))>/i # ? Counter condition? # Conduct classification KIND = /^\s*(?:KIND|Classification)\s*([ASI])/i # Attack type ATTACK_TYPE = /^\s*(PHYSICAL|MAGICAL|Physics|Magic)(?:_ATTACK|Attack)/i # Attribute ELEMENT = /^\s*(?:ELEMENT|Attribute)\s*(\d+(?:\s*,\s*\d+)*)/i # Degree of relationship of shock ATK_F = /^\s*(?:ATK_F|Degree of relationship of shock)\s*(\d+)(?:\s*Above)?/i # Degree of relationship of mind SPI_F = /^\s*(?:SPI_F|Degree of relationship of mind)\s*(\d+)(?:\s*Above)?/i end KIND_ALL = -1 # Classification: ALL KIND_BASIC = 0 # Classification: Basis KIND_SKILL = 1 # Classification: Skill KIND_ITEM = 2 # Classification: Item TYPE_ALL = -1 # Attack attack type: ALL TYPE_PHYSICAL = 0 # Attack type: Physics TYPE_MAGICAL = 1 # Attack type: Magic # Classification conversion table COUNTER_KINDS = { "A" => KIND_BASIC, "S" => KIND_SKILL, "I" => KIND_ITEM } # Attack type conversion table COUNTER_TYPES = { "PHYSICAL" => TYPE_PHYSICAL, "Physics" => TYPE_PHYSICAL, "MAGICAL" => TYPE_MAGICAL, "Magic" => TYPE_MAGICAL } #-------------------------------------------------------------------------- # ○ Compilation of counter conduct list # note : Memo column #-------------------------------------------------------------------------- def self.create_counter_action_list(note) result = [] counter_flag = false action = nil note.split(/[\r\n]+/).each { |line| if line =~ KGC::Counter::Regexp::BEGIN_COUNTER # Start of counter definition action = Game_CounterAction.new if $1 != nil action.kind = COUNTER_KINDS[$1.upcase] end case action.kind when KIND_SKILL next if $2 == nil action.skill_id = $2[/\d+/].to_i when KIND_ITEM next if $2 == nil action.item_id = $2[/\d+/].to_i end if $3 != nil action.execute_prob = $3[/\d+/].to_i end counter_flag = true if $4 != nil # That way definition end result << action counter_flag = false end end next unless counter_flag case line when KGC::Counter::Regexp::END_COUNTER # Counter definition end result << action counter_flag = false when KGC::Counter::Regexp::KIND # Conduct classification action.condition.kind = COUNTER_KINDS[$1.upcase] when KGC::Counter::Regexp::ATTACK_TYPE # Attack type action.condition.type = COUNTER_TYPES[$1.upcase] when KGC::Counter::Regexp::ELEMENT # Attribute elements = [] $1.scan(/\d+/).each { |num| elements << num.to_i } action.condition.element_set |= elements when KGC::Counter::Regexp::ATK_F # Degree of relationship of shock action.condition.atk_f = $1.to_i when KGC::Counter::Regexp::SPI_F # Degree of relationship of mind action.condition.spi_f = $1.to_i end } return result end end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ RPG::BaseItem #============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # ○ Counter conduct list #-------------------------------------------------------------------------- def counter_actions if @__counter_actions == nil @__counter_actions = KGC::Counter.create_counter_action_list(self.note) end return @__counter_actions end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ RPG::Enemy #============================================================================== class RPG::Enemy #-------------------------------------------------------------------------- # ○ Counter conduct list #-------------------------------------------------------------------------- def counter_actions if @__counter_actions == nil @__counter_actions = KGC::Counter.create_counter_action_list(self.note) end return @__counter_actions end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ RPG::State #============================================================================== class RPG::State #-------------------------------------------------------------------------- # ○ Counter conduct list #-------------------------------------------------------------------------- def counter_actions if @__counter_actions == nil @__counter_actions = KGC::Counter.create_counter_action_list(self.note) end return @__counter_actions end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # □ Game_CounterAction #------------------------------------------------------------------------------ # It is the class which handles counter conduct. #============================================================================== class Game_CounterAction #-------------------------------------------------------------------------- # ○ Open instance variable #-------------------------------------------------------------------------- attr_accessor: Kind # classification (basis/skill/item) attr_accessor: Basic # basis (attacking/defending/fleeing/waiting) attr_accessor: Skill_id # skill ID attr_accessor: Item_id # item ID attr_accessor: Execute_prob # motion probability attr_accessor: Condition # motion condition #-------------------------------------------------------------------------- # ○Object initialization #-------------------------------------------------------------------------- def initialize clear end #-------------------------------------------------------------------------- # ○ Clearing #-------------------------------------------------------------------------- def clear @kind = KGC::Counter::KIND_BASIC @basic = 0 @skill_id = 0 @item_id = 0 @execute_prob = 100 @condition = Game_CounterCondition.new end #-------------------------------------------------------------------------- # ○ Validity decision # attacker : Attack person # defender : Suffering attack person #-------------------------------------------------------------------------- def valid?(attacker, defender) return false if attacker.class == defender.class # Attack from friend return false if execute_prob <= rand(100) # Motion ratio decision return condition.valid?(attacker, defender) end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # □ Game_CounterCondition #------------------------------------------------------------------------------ # It is the class which handles counter condition. #============================================================================== class Game_CounterCondition #-------------------------------------------------------------------------- # ○ Open instance variable #-------------------------------------------------------------------------- attr_accessor :kind # Classification (ALL/basis/skill/item) attr_accessor :type # Attack type (ALL/physics/magic) attr_accessor :element_set # Attribute attr_accessor :atk_f # Degree of relationship of shock attr_accessor :spi_f # Degree of relationship of mind #-------------------------------------------------------------------------- # ○ Object initialization #-------------------------------------------------------------------------- def initialize clear end #-------------------------------------------------------------------------- # ○ Clearing #-------------------------------------------------------------------------- def clear @kind = KGC::Counter::KIND_ALL @type = KGC::Counter::TYPE_ALL @element_set = [] @atk_f = 0 @spi_f = 0 end #-------------------------------------------------------------------------- # ○ Validity decision # attacker : 攻撃者 # defender : 被攻撃者 #-------------------------------------------------------------------------- def valid?(attacker, defender) action_item = nil if attacker.action.skill? action_item = attacker.action.skill elsif attacker.action.item? action_item = attacker.action.item end return false unless kind_valid?(attacker, defender, action_item) return false unless attack_type_valid?(attacker, defender, action_item) return false unless element_valid?(attacker, defender, action_item) return false unless atk_f_valid?(attacker, defender, action_item) return false unless spi_f_valid?(attacker, defender, action_item) return true end #-------------------------------------------------------------------------- # ○ Classification effective decision # attacker : 攻撃者 # defender : 被攻撃者 # obj : Skill or item #-------------------------------------------------------------------------- def kind_valid?(attacker, defender, obj) return true if self.kind == KGC::Counter::KIND_ALL return (self.kind == attacker.action.kind) end #-------------------------------------------------------------------------- # ○ Attack type effective decision # attacker : 攻撃者 # defender : 被攻撃者 # obj : スキルまたはアイテム #-------------------------------------------------------------------------- def attack_type_valid?(attacker, defender, obj) return true if self.type == KGC::Counter::TYPE_ALL if obj == nil # It is not the physical counter return false if self.type != KGC::Counter::TYPE_PHYSICAL else # [Physical attack] If if physics, so is not, magical counter decision if self.type != (obj.physical_attack ? KGC::Counter::TYPE_PHYSICAL : KGC::Counter::TYPE_MAGICAL) return false end end return true end #-------------------------------------------------------------------------- # ○ Attribute effective decision # attacker : 攻撃者 # defender : 被攻撃者 # obj : スキルまたはアイテム #-------------------------------------------------------------------------- def element_valid?(attacker, defender, obj) return true if self.element_set.empty? if attacker.action.attack? elements = attacker.element_set else return false if obj == nil # Attribute list acquisition if $imported["SetAttackElement"] elements = defender.get_inherited_element_set(attacker, obj) else elements = obj.element_set end end return !(self.element_set & elements).empty? end #-------------------------------------------------------------------------- # ○ Shock-degree of related effective decision # attacker : Attack person # defender : Suffering attack person # obj : Skill or item #-------------------------------------------------------------------------- def atk_f_valid?(attacker, defender, obj) return true if self.atk_f == 0 n = (attacker.action.attack? ? 100 : (obj != nil ? obj.atk_f : 0) ) return (self.atk_f <= n) end #-------------------------------------------------------------------------- # ○ Spiritual-degree of related effective decision # attacker : Attack person # defender : Suffering attack person # obj : Skill or item #-------------------------------------------------------------------------- def spi_f_valid?(attacker, defender, obj) return true if self.spi_f == 0 n = (attacker.action.attack? ? 0 : (obj != nil ? obj.spi_f : 0) ) return (self.spi_f <= n) end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # □ Game_CounterInfo #------------------------------------------------------------------------------ # It is the class which handles counter information. #============================================================================== class Game_CounterInfo #-------------------------------------------------------------------------- # ○ Open instance variable #-------------------------------------------------------------------------- attr_accessor :battler # Conduct person attr_accessor :action # Counter conduct attr_accessor :target_index # Object index #-------------------------------------------------------------------------- # ○ Object initialization #-------------------------------------------------------------------------- def initialize @battler = nil @action = nil @target_index = 0 end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ Acquisition of counter conduct list #-------------------------------------------------------------------------- def counter_actions result = [] states.each { |state| result += state.counter_actions } return result end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ○ Acquisition of counter conduct list #-------------------------------------------------------------------------- def counter_actions result = super equips.compact.each { |item| result += item.counter_actions } return result end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ○ Acquisition of counter conduct list #-------------------------------------------------------------------------- def counter_actions return (super + enemy.counter_actions) end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● Start processing #-------------------------------------------------------------------------- alias start_KGC_Counter start def start start_KGC_Counter @counter_added = false @counter_infos = [] end #-------------------------------------------------------------------------- # ● Processing of combat activity #-------------------------------------------------------------------------- alias process_action_KGC_Counter process_action def process_action process_action_KGC_Counter unset_counter_action end #-------------------------------------------------------------------------- # ○ Cancellation of counter conduct #-------------------------------------------------------------------------- def unset_counter_action return unless @counter_exec # You reset on the basis of conduct @active_battler.action.forcing = @former_action.forcing @active_battler.action.kind = @former_action.kind @active_battler.action.basic = @former_action.basic @active_battler.action.skill_id = @former_action.skill_id @active_battler.action.item_id = @former_action.item_id @active_battler.action.target_index = @former_action.target_index @former_action = nil @counter_exec = false end #-------------------------------------------------------------------------- # ● Setting of the butler who should act next #-------------------------------------------------------------------------- alias set_next_active_battler_KGC_Counter set_next_active_battler def set_next_active_battler set_counter_action if @active_battler == nil set_next_active_battler_KGC_Counter end end #-------------------------------------------------------------------------- # ○ Compilation of counter conduct #-------------------------------------------------------------------------- def set_counter_action @active_battler = nil @former_action = nil @counter_exec = false @counter_added = false counter = @counter_infos.shift return if counter == nil @active_battler = counter.battler # Evacuating the conduct of the origin @former_action = @active_battler.action.clone @counter_exec = true # Setting counter conduct @active_battler.action.kind = counter.action.kind @active_battler.action.basic = counter.action.basic @active_battler.action.skill_id = counter.action.skill_id @active_battler.action.item_id = counter.action.item_id # Setting the counter object target_index = counter.target_index # If the object friend it moves vis-a-vis by your if @active_battler.action.for_friend? target_index = @active_battler.index end @active_battler.action.target_index = target_index unless @active_battler.action.valid? # If counter motion failure cancellation unset_counter_action @active_battler = nil else @active_battler.action.forcing = true end end #-------------------------------------------------------------------------- # ● Indication of conduct result # target : Object person # obj : Skill or item #-------------------------------------------------------------------------- alias display_action_effects_KGC_Counter display_action_effects def display_action_effects(target, obj = nil) display_action_effects_KGC_Counter(target, obj) unless target.skipped execute_counter_action(target) end end #-------------------------------------------------------------------------- # ○ Execution of counter conduct # target : Object person #-------------------------------------------------------------------------- def execute_counter_action(target) return if @counter_exec # It does not do the counter for the counter return unless target.movable? # Incapacitation target.counter_actions.each { |counter| break if KGC::Counter::RESTRICT_COUNTER && @counter_added # Setting effective counter conduct if counter.valid?(@active_battler, target) info = Game_CounterInfo.new info.battler = target info.action = counter info.target_index = @active_battler.index @counter_infos << info @counter_added = true end } end end I cant decipher the example X_X so would anybody explain it to me? ex. # It is usually counterattacked by attack for physics attack Counter A Physics attack A / counter # Attribute ID: For 8, mind-related degree 50 magic more than it # Skill ID: It is counterattack counter S: with 60 60 Magic attack Attribute 8 More than mind-related degree 50 A / counter # It is skill ID for every attack: I counterattack it with 50 # Motion rate: 80% Counter S: 50 80% A / counter T_T My head keeps on spinning. i guess I'll decipher it first |
|
|
|
May 10 2008, 06:16 AM
Post
#2
|
|
![]() A Certain Lazy Student ![]() Type: Designer Alignment: Chaotic Evil |
i'm kinda confused.... and... what's this for? a counter attack?
anyway, you should post this in the KGC Scripts thread! -------------------- Pokeplushy
Spoiler: Quotes (big, black, bullshit) Spoiler: |
|
|
|
May 25 2008, 01:45 AM
Post
#3
|
|
![]() Jack of all Trades ![]() Type: Designer Alignment: Lawful Good |
Any progress on this one ZheiN?
|
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 25th May 2013 - 08:34 PM |
|
|