Сап, RPGM.ru, хотелось бы обратиться по поводу пары моментов.
Для начала стоит обозначить источник проблемы - для своего проекта я решил
внаглую скопировать сымитировать систему одноручного/двуручного оружия из Phantasy Star 2. VXA поддерживает данную функцию изначально, однако я слегка ее дополнил, накатив следующие скрипты:
Individual Strikes when Dual Wielding - для того, чтобы каждый удар рассчитывался как отдельная атака:
#==============================================================================
# Individual Strikes when Dual Wielding
# Version: 1.0.1
# Author: modern algebra (rmrk.net)
# Date: 2 February 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script changes the dual wielding option so that, instead of the actor
# attacking only once with increased damage, the actor attacks twice, once
# with each weapon. Additionally, this script allows you to modify the
# damage formula when dual wielding, thus allowing you to, for instance, make
# the actor's proficiency with dual wielding dependent on the actor's
# dexterity or some other stat.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials.
#
# If you wish, you can assign a modifying formula at line 38. What that will
# do is allow you to change the damage formula for a weapon when you are dual
# wielding, and it serves as a way to assign a penalty to dual wielding for
# balance purposes.
#==============================================================================
$imported ||= {}
$imported[:MA_DWIndividualStrikes] = true
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# BEGIN Editable Region
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# By modifying this constant, you are able to modify the damage formula when
# dual wielding. It must be a string, and the original damage formula will
# replace the %s. In other words, if the original damage formula is something
# like "a.atk * 4 - b.def * 2", and you assign the constant to the following:
# MAISDW_DUAL_DAMAGE_MODIFIER = "(%s)*0.75"
# then the formula when dual wielding would be: "(a.atk * 4 - b.def * 2)*0.75"
MAISDW_DUAL_DAMAGE_MODIFIER = "(%s)"
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END Editable Region
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - apply_item_effects
#==============================================================================
class Scene_Battle
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Apply Skill/Item Effect
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias maisdw_aplyitm_2uv7 apply_item_effects
def apply_item_effects(target, item, *args)
# If Actor attacking with more than one weapon
if @subject.actor? && !item.is_a?(RPG::Item) &&
item.id == @subject.attack_skill_id && @subject.weapons.size > 1
@subject.weapons.each { |weapon|
maisdw_dual_wield_attack(target, item, weapon, *args) }
else
maisdw_aplyitm_2uv7(target, item, *args) # Call original method
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dual Wield Attack
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maisdw_dual_wield_attack(target, item, weapon, *args)
# Select from equips to record position, accounting for extra equip
# scripts that might change order.
equips_to_replace = [] # Record which equips are removed
selected = false
for i in 0...@subject.equips.size
equip = @subject.equips
if equip.is_a?(RPG::Weapon)
# Actual identity in case using an instantiated item system
if weapon.equal?(equip) && !selected
selected = true # Only keep it once if two of the same item
next
end
equips_to_replace << [i, equip] # Preserve weapon
@subject.change_equip(i, nil) # Remove weapon
end
end
# Get the attack skill
attack_skill = $data_skills[@subject.attack_skill_id]
attack_skill = item if attack_skill.nil?
real_formula = attack_skill.damage.formula.dup # Preserve Formula
# Modify damage formula
unless MAISDW_DUAL_DAMAGE_MODIFIER.empty?
attack_skill.damage.formula = sprintf(MAISDW_DUAL_DAMAGE_MODIFIER, real_formula)
end
# Call original apply_item_effects method
maisdw_aplyitm_2uv7(target, attack_skill, *args)
attack_skill.damage.formula = real_formula # Restore damage formula
# Replace removed equips
equips_to_replace.each { |i, weapon| @subject.change_equip(i, weapon) }
end
end
Dual wield / two-handed fix - ставился чтобы персонаж не мог экипировать двуручное оружие в два слота одновременно:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Dual wield / two-handed fix
# Author: Trihan
# Version 1
# Release date: 28/06/13
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# ▼ UPDATES
#
# 28/06/13 - First release
#
# ▼ TERMS OF USAGE
#
# This script may be used for any purpose with or without credit, though a
# little mention would be nice.
#
# ▼ INTRODUCTION
#
# This script "fixes" two-handed weapons for dual wielders; by default VX Ace
# has no checks in place to prevent a weapon that seals shield being equipped
# in both hands, because dual wielders have two weapon slots instead of a
# shield slot.
#
# ▼ INSTRUCTIONS
#
# All you have to do is make the weapon you want to make two-handed "seal
# shield" and the script will do the rest for you.
#
# ▼ COMPATIBILITY
#
# There should be few if any compatibility issues with this script; the only
# directly overloaded method is release_unequippable_items, so if you're using
# a script that modifies this some edits may be required.
#
$imported = {} if $imported.nil?
$imported = true
#==============================================================================
# ** RPG::Weapon
#
# Base class for equippable weapons.
# NEW METHOD - two_handed?
#==============================================================================
class RPG::Weapon < RPG::EquipItem
#
# * Determine whether weapon requires two hands (seals shield)
#
def two_handed?
for feature in self.features
if feature.code == 54 && feature.data_id == 1
return true
end
end
return false
end
end
#==============================================================================
# ** Game_BattlerBase
#
# ALIASED METHOD - equippable?
#==============================================================================
class Game_BattlerBase
#
# * Determine if Equippable
#
alias tri_dw2hfix_equippable? equippable?
# Need to add a parameter for slot so we can check slot-specific setups.
def equippable?(item, slot = nil)
if slot != nil
# If the current slot is "off-hand" AND the character dual-wields AND
# the item being equipped is a weapon AND something is already equipped
# in the main hand AND the main hand weapon is two-handed...
if slot == 1 && dual_wield? && item.is_a?(RPG::Weapon) && equips[0] && equips[0].two_handed?
return false
end
end
# Call the original method to continue default equippable checks.
tri_dw2hfix_equippable?(item)
end
end
#==============================================================================
# ** Game_Actor
#
# OVERLOADED METHOD - release_unequippable_items
#==============================================================================
class Game_Actor < Game_Battler
#
# * Remove Equipment that Cannot Be Equipped
# item_gain: Return removed equipment to party.
#
def release_unequippable_items(item_gain = true)
loop do
last_equips = equips.dup
@equips.each_with_index do |item, i|
# Changed to include index as a parameter to equippable? so we know
# which slot is being checked.
if !equippable?(item.object, i) || item.object.etype_id != equip_slots
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
end
end
return if equips == last_equips
end
end
end
#==============================================================================
# ** Window_EquipSlot
#
# ALIASED METHOD - enable?
#==============================================================================
class Window_EquipSlot < Window_Selectable
#
# * Display Equipment Slot in Enabled State?
#
alias tri_dw2hfix_enable? enable?
def enable?(index)
# if the actor dual wields AND current index is that of the off-hand AND
# there's something equipped in the main hand AND it's two-handed...
if @actor.dual_wield? && index == 1 && @actor.equips[0] && @actor.equips[0].two_handed?
return false
end
tri_dw2hfix_enable?(index)
end
end
#==============================================================================
# ** Window_EquipItem
#
# ALIASED METHOD - include?
#==============================================================================
class Window_EquipItem < Window_ItemList
#
# * Include in Item List?
#
alias tri_dw2hfix_include? include?
def include?(item)
# If the actor dual wields AND item is a weapon
if @actor.dual_wield? && item.is_a?(RPG::Weapon)
# Don't show it if we're equipping the off-hand and the actor already has
# a two-handed weapon in the main hand.
if @actor.equips[0] != nil && @actor.equips[0].two_handed? && @slot_id == 1
return false
end
# Also don't show it if we're equipping any slot but the first and the
# item is two-handed (so we can't equip 2H items in the off-hand)
return false if item.two_handed? && @slot_id != 0
end
tri_dw2hfix_include?(item)
end
end
Вероятно, проблема кроется в одном из этих скриптов, однако гарантированно сказать это не могу.
Так вот, суть проблемы:
При покупке товаров в магазинах в качестве уже экипированного на персонаже оружия отображается оружие из второго слота - даже если оружие у персонажа экипировано в первом слоте:
Как фиксить данную проблему? Дело в скриптах?
P.S.
Есть еще одна проблема, связанная с системой двойного владения оружием. Скажите пожалуйста, есть ли возможность отредактировать название второго слота для оружия?
Почему спрашиваю - в моей игре есть щиты, которые экипируются в слот для оружия а-ля та же Phantasy Star II или Final Fantasy II. Так вот, дело в том, что при ношении щита в первом слоте для оружия и, например, одноручного оружия во втором слоте, скрипт на раздельные удары при дуалвилде глючит.
Дело в том, что хоть щит и является оружием, я, с помощью скриптов, сделал так, чтобы щит нельзя было использовать в бою - скилл атаки при его использовании не наносит урон и не может быть использован в бою. Когда в первый слот экипировано оружие, все работает нормально - проходит всего одна атака и все. С другой же стороны, когда в щит экипирован в первый слот, ни одна из атак не может быть использована.
Так как я не знаю, как решить данную проблему, хотелось бы узнать, можно ли как-то дифференцировать первый и второй слоты для оружия? Хз там, чтобы первый слот назывался "левая рука" или "правая рука" там, чисто чтобы игрок мог интуитивно понять, в какую из рук совать оружие, а в какую - оружие второго плана и щиты, например.