RPG Maker Forums

Hi there.
I'm working on a new project, but I'm relatively new the the scene. As such as I was hoping for some assistance in using some Scripts I've found, because I don't totally understand how they do what they do, even if what they do is (close) to exactly what I am looking.

I have two problems:

1) Dual Wielding
I'm modifying my Battler Code, to make use of a new combat system, based around DND. Similar to Kotor, a lot of the combat is handled via dice rolls, and comparing Dice Rolls to arbitary numbers, to determine if they hit. I've had no problem implementing this particular feature. (Actually, no, I had many problems. But I solved them.) Using Yanfly's Weapon Attack Replace script, my plan is to have weapon determine many of the features involved in the attack, effectively determining what dice are rolled.

However, damage is proving to be a little more complicated.

I am using the following
#==============================================================================
# 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

In order to attack with the dual wielded weapons separately.
- That there are two weapons equipped is determined.
- As the first attack is made, the second weapon is unequipped.
- As the second attack is made, the first weapon is unequipped, and replaced with the weapon that was unequipped in the previous step.
- When the attacks are finished, both weapons are re-equipped.

All is normal.
Problem is, because during the attack, the character is only using a single weapon at any given time, I have no way of identifying which character is dual wielding.

[Continued in the next line]


- Second Problem;
I am also using Fomar0153's Dual Wield script.
Currently, if the main hand weapon is marked as "Dual Wield", the option to equip a second weapon is turned on. But its an option. I can choose to equip a shield instead, if I wish to.
This means that a player can equip, say, a longsword, and then choose if they want to equip a shield, or a second weapon. Or leave the hand empty. This is great for me. Problem however, is that weapons can only be dual wielded if the Primary weapon is "Dual-Wield". Ideally, I would prefer if it was the weapons in the Off-Hand (Read the Shield Slot) that needs to be selected.
That way, I can designate some weapons, such as Daggers, and Shortswords, as being suitable for wielding in the offhand.

Also, ideally, it would be possible to create a state where this restriction is lifted - eg, for a specific actor.

=begin
Duel Wield -> Free Hands
by Fomar0153
Version 1.1
----------------------
Notes
----------------------
No requirements
Changes dual wielding to allow characters to equip shield or one handed
weapons in the shield slot. Also allows for two handed weapons.
----------------------
Instructions
----------------------
Notetag two handed weapon with <two-handed> and have them
disable the shield slot.
I would recommend changing the slot name to Main Hand and Off Hand
or something similar
----------------------
Change Log
----------------------
1.0 -> 1.1 Fixed a bug where the equip item in the second hand could
overwrite the main hand's equip item.
----------------------
Known bugs
----------------------
None
=end

class Game_Actor

def equip_slots
return [0,1,2,3,4]
end

def change_equip(slot_id, item)
return unless trade_item_with_party(item, equips[slot_id])
return if (item && equip_slots[slot_id] != item.etype_id) and
not (dual_wield? and (equip_slots[slot_id] == 1 and item.etype_id == 0))
@equips[slot_id].object = item
refresh
end

def release_unequippable_items(item_gain = true)
@equips.each_with_index do |item, i|
if !equippable?(item.object,equip_slots) || (item.object.etype_id != equip_slots and
not (dual_wield? and (equip_slots == 1 and item.object.etype_id == 0)))
trade_item_with_party(nil, item.object) if item_gain
item.object = nil
end
end
end

def equippable?(item, slot = nil)
unless slot.nil?
if slot == 1 and dual_wield?
return (super(item) and not equip_type_sealed?(1)) if item.is_a?(RPG::Weapon)
end
end
return super(item)
end

def slot_list(etype_id)
result = []
equip_slots.each_with_index {|e, i| result.push(i) if e == etype_id or ((e == 1 and etype_id == 0) and dual_wield?) }
result
end
end

class RPG::Weapon

def two_handed?
return self.note.include?("<two-handed>")
end

end

class Window_EquipItem < Window_ItemList

def include?(item)
return true if item == nil
return false unless item.is_a?(RPG::EquipItem)
return false if @slot_id < 0
return false if @actor.equip_slots[@slot_id] == 1 and
(item.is_a?(RPG::Weapon) and item.two_handed?)
return false if (item.etype_id != @actor.equip_slots[@slot_id]) and
not (@actor.dual_wield? and (@actor.equip_slots[@slot_id] == 1 and item.etype_id == 0))
return @actor.equippable?(item,@actor.equip_slots[@slot_id])
end

end



I am using my own battlescript to simulate such rolls. Its pulls from a number of notetags, <atk:x>, <dmg:y> etc etc, to add the total, from a number of states and/or equipment.

Trouble is, I can't figure out how the scripts are interacting. Because I've defined the Diceroll mechic at the top, I can define the weapons base damage as a roll, eg, a longsword rolls 1d8, so I set its damage formula to "rolldice(1,8)". All other damage bonuses, such as a str bonus, or a bonus from an enraged state, are collated in the damage formula, by pulling from notetags.

class Game_Battler

def rolldice(d,dice)
total = 0
d.times { total += (rand(dice)+1)}
return total
end

def make_damage_value(user, item)

a = user
b = self
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Set D20 -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

baseatkroll = rolldice(1,20)

###--- This calculates the attack bonus, from all stacking sources.
###--- States are Best for this, as they will all stack.
###--- Make sure bonus's from equipment/actors/etc remain static.

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Determine Attack Bonus from Equipment, Classes and States(Feats) -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

val = user.feature_objects.inject(0) do |sum, i|
if i.note[/<atk\s*:\s*(\d+)>/i]
sum + $1.to_i
else
sum + 0 # Default value
end
end
atkbonus = val


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Determin Damage Bonus from Equipment, Classes and States(Feats) -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

val = user.feature_objects.inject(0) do |sum, i|
if i.note[/<dmg\s*:\s*(\d+)>/i]
sum + $1.to_i
else
sum + 0 # Default value
end
end
dmgbonus = val


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Determine Critrange Bonus from Equipment, Classes and States(Feats) -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

val = user.feature_objects.inject(0) do |sum, i|
if i.note[/<crit\s*:\s*(\d+)>/i]
sum + $1.to_i
else
sum + 0 # Default value
end
end
critbonus = val


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Determin if a Crit has occured -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

critrng = 20 - critbonus

if baseatkroll >= critrng
@result.critical = true
elsif baseatkroll == 1
@result.missed = true
return
end


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Add Proficiency Bonus to Attack -
# Only players have P - reflect Enemies' attack in their stats.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if a.actor?
p = a.level/4
p = p.floor
p = p+1
else
p = 0
end


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Determine attack Stat + Dmg Stat
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


if item.note.include?("<use str>")
ak = ( (a.atk - 10)/2).floor + baseatkroll + p
statbonus = a.atk
else
ak = ((a.atk - 10)/2).floor + baseatkroll + p
statbonus = a.atk
end

if item.note.include?("<use int>")

ak = ((a.mat - 10)/2).floor + baseatkroll + p
statbonus = a.mat
end

if item.note.include?("<use dex>")
ak = ((a.agi - 10)/2).floor + baseatkroll + p
statbonus = a.agi
end

if item.note.include?("<use wis>")
ak = ( (a.mdf - 10)/2).floor + baseatkroll + p
statbonus = a.mdf
end

if item.note.include?("<use cha>")
ak = ((a.luk - 10)/2).floor + baseatkroll + p
statbonus = a.luk
end

if item.note.include?("<finess>")
sel = [a.atk,a.agi].max
ak = ((sel - 10)/2).floor + baseatkroll + p
statbonus = sel
end

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Determine if attack Hits
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
val = self.feature_objects.inject(0) do |sum, i|
if i.note[/<def\s*:\s*(\d+)>/i]
sum + $1.to_i
else
sum + 0 # Default value
end
end
# I used this code to check the weapon sizes, to try to figure it out.
#~ if a.actor?
#~ if user.weapons.size >= 2
#~ p 2
#~ elsif user.weapons.size >= 1
#~ p 1
#~ elsif user.weapons.size >= 0
#~ p 0
#~ end
#~ else
#~ p "Not a Player"
#~ end


en_defbonus = val

ac = b.def + en_defbonus
if ak >= ac or @result.critical
value = item.damage.eval(user, self, $game_variables)
value = value + dmgbonus + statbonus
if item.note.include?("<x3crit>") and @result.critical == true
value = (value * 1.5).floor
else
end
@result.make_damage(value.to_i, item)
else
@result.missed = true
end
end
end


The work works fine; but the dual wielding is beginning to become an issue. Any advise on the issue is appreciated.

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top