Help with KGC_RankConception script

Started by Keyren, April 16, 2012, 07:44:14 am

Previous topic - Next topic

Keyren

Hi!!I found this Japanese script, which lets you change the position of the character in battle(front, middle and back) is the option you choose in the database ]in the section class.The script works, but I do not know how to change the position in battle, as I understandwe need to create a skill and some attibuti in the System section of the database, but after many attempts did not succeed. Maybe a more experienced person can understand something =) thanks in advance^^


#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 隊列概念 - KGC_RankConception ◆
#_/ ◇ Last update : 2008/05/11 ◇
#_/----------------------------------------------------------------------------
#_/ 戦闘時に隊列・射程の概念を追加します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================

module KGC
# ◆射程未設定時の射程距離
RC_DEFAULT_RANGE = 4

# ◆隊列用画像
# "Graphics/Pictures" から読み込む。拡張子省略可。
RC_RANK_IMAGE = "position"
# ◆隊列画像表示位置補正値
# 通常は 120。
# ≪多人数パーティ≫などを併用する時は微調整。
RC_RANK_OFFSET = 120
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["RankConception"] = true

if $game_special_elements == nil
$game_special_elements = {}
$data_system = load_data("Data/System.rxdata")
end
# 隊列属性
$game_special_elements["rank"] = $data_system.elements.index("隊列")
# 射程属性
$game_special_elements["range"] = /射程(\d)/
# 隊列移動属性
$game_special_elements["move_rank"] = /(前|中|後)衛移動/

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● セットアップ
# actor_id : アクター ID
#--------------------------------------------------------------------------
alias setup_KGC_RankConception setup
def setup(actor_id)
setup_KGC_RankConception(actor_id)

# 隊列を初期化
@position = $data_classes[@class_id].position
end
#--------------------------------------------------------------------------
# ● 隊列の取得
#--------------------------------------------------------------------------
def position
@position = $data_classes[@class_id].position if @position == nil
return @position
end
#--------------------------------------------------------------------------
# ● 隊列の設定
#--------------------------------------------------------------------------
def position=(p)
@position = p
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★


#==============================================================================
# ■ Game_Battler (分割定義 2)
#==============================================================================

class Game_Battler
#--------------------------------------------------------------------------
# ● 射程有効判定
# attacker : 攻撃者
# action : 処理行動
#--------------------------------------------------------------------------
def within_range?(attacker, action = nil)
# 射程を取得
if action != nil
for element in action.element_set.compact
element_name = $data_system.elements[element]
# 射程属性を持っている場合
if $game_special_elements["range"] =~ element_name
range = $1.to_i if $1 != nil
break
end
end
end
# 射程が無い場合
if action == nil || range == nil
range = KGC::RC_DEFAULT_RANGE
end
# 攻撃者の隊列を取得
if attacker.is_a?(Game_Actor)
a_pos = attacker.position
else
if $game_special_elements["rank"] != nil
case $data_enemies[attacker.id].element_ranks[$game_special_elements["rank"]]
when 1..2 # 前衛(A,B)
a_pos = 0
when 3 # 中衛(C)
a_pos = 1
when 4..6 # 後衛(D,E,F)
a_pos = 2
end
else
a_pos = 1
end
end
# 攻撃対象の隊列を取得
if self.is_a?(Game_Actor)
t_pos = self.position
else
if $game_special_elements["rank"] != nil
case $data_enemies[self.id].element_ranks[$game_special_elements["rank"]]
when 1..2 # 前衛(A,B)
t_pos = 0
when 3 # 中衛(C)
t_pos = 1
when 4..6 # 後衛(D,E,F)
t_pos = 2
end
else
t_pos = 1
end
end
# 有効射程を判定
return a_pos + t_pos <= range
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Game_Battler (分割定義 3)
#==============================================================================

class Game_Battler
#--------------------------------------------------------------------------
# ● 通常攻撃の効果適用
#--------------------------------------------------------------------------
alias attack_effect_KGC_RankConception attack_effect
def attack_effect(attacker)
# 射程外の場合
action = attacker.is_a?(Game_Actor) ? ($imported["EquipExtension"] ?
$data_weapons[attacker.weapon_id(attacker.attack_count)] :
$data_weapons[attacker.weapon_id]) : nil
unless self.within_range?(attacker, action)
# ダメージに "Miss" を設定
self.damage = "Miss"
# クリティカルフラグをクリア
self.critical = false
# 偽を返す
return false
end

# 元の処理を実行
return attack_effect_KGC_RankConception(attacker)
end
#--------------------------------------------------------------------------
# ● スキルの効果適用
#--------------------------------------------------------------------------
alias skill_effect_KGC_RankConception skill_effect
def skill_effect(user, skill)
# 射程外の場合
unless self.within_range?(user, skill)
# ダメージに "Miss" を設定
self.damage = "Miss"
# クリティカルフラグをクリア
self.critical = false
# 偽を返す
return false
end
# 隊列移動属性判定
for element in skill.element_set.compact
element_name = $data_system.elements[element]
# 射程属性を持っている場合
if $game_special_elements["move_rank"] =~ element_name
move_position = $1
break
end
end
# 隊列移動属性を持っていない場合
if move_position == nil
# 元の処理を実行
return skill_effect_KGC_RankConception(user, skill)
end

# クリティカルフラグをクリア
self.critical = false
# スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
# またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
if ((skill.scope == 3 || skill.scope == 4) && self.hp == 0) ||
((skill.scope == 5 || skill.scope == 6) && self.hp >= 1)
# メソッド終了
return false
end
# 有効フラグをクリア
@effective = false
# コモンイベント ID が有効の場合は有効フラグをセット
@effective |= skill.common_event_id > 0
# 第一命中判定
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# 不確実なスキルの場合は有効フラグをセット
@effective |= hit < 100
# 命中の場合
if hit_result == true
# ステート変化
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# 指定位置に移動
case move_position
when "前"
if self.is_a?(Game_Actor)
self.position = 0
else
self.element_ranks[$game_special_elements["rank"]] = 1
end
when "中"
if self.is_a?(Game_Actor)
self.position = 1
else
self.element_ranks[$game_special_elements["rank"]] = 3
end
when "後"
if self.is_a?(Game_Actor)
self.position = 2
else
self.element_ranks[$game_special_elements["rank"]] = 4
end
end
# 戻る
return true
end
return false
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_BattleStatus
#==============================================================================

class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 名前の描画
#--------------------------------------------------------------------------
alias draw_actor_name_KGC_RankConception draw_actor_name unless $@
def draw_actor_name(actor, x, y)
draw_actor_name_KGC_RankConception(actor, x, y)

draw_actor_position(actor, x, y, KGC::RC_RANK_OFFSET)
end
#--------------------------------------------------------------------------
# ● 隊列の描画
#--------------------------------------------------------------------------
def draw_actor_position(actor, x, y, width)
image = RPG::Cache.picture(KGC::RC_RANK_IMAGE)
src_rect = Rect.new(actor.position * 32, 0, 32, 32)
self.contents.blt(x + width - 32, y, image, src_rect)
end
end