iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> [Live] KGC_Counter, [Posted] Counter atk? not fully translated
ZheiN
post May 10 2008, 04:36 AM
Post #1


†Crξtξcβl Brιβkιr†
Group Icon


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....


Spoiler:

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
Go to the top of the page
 
+Quote Post
   
spike_vii
post May 10 2008, 06:16 AM
Post #2


A Certain Lazy Student
Group Icon


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

Quotes (big, black, bullshit)
Spoiler:
Trying is the first step towards failure.

Pretty women make us buy beer. Ugly women make us drink beer.

Don't send funny greeting cards on birthdays or at Christmas. Save them for funerals when their cheery effect is needed.

Everything is funny as long as it is happening to Somebody Else.

Life is pleasant. Death is peaceful. It's the transition that's troublesome.

Music is what's painting inside you.

If you want a thing done well, do it yourself.

The good ended happily, and the bad unhappily. That is what Fiction means.

Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. That's relativity.

There's no such thing as a soul. It's just something they made up to scare kids, like the boogeyman or Michael Jackson.

Only two things are infinite, the universe and human stupidity and I'm not sure about the former.

Eighty percent of married men cheat in America. The rest cheat in Europe.

Hey, can you take the wheel for a second, I have to scratch my self in two places at once.

Great minds discuss ideas. Average minds discuss events. Small minds discuss people.
Go to the top of the page
 
+Quote Post
   
Cyrus
post May 25 2008, 01:45 AM
Post #3


Jack of all Trades
Group Icon


Type: Designer
Alignment: Lawful Good




Any progress on this one ZheiN?
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 1st September 2014 - 10:24 AM

RPGMakerVX.net is an Privacy Policy, Legal.