I am trying to modify weapon stats (specifically SwingSpeed, ThrustSpeed, and whatever controls ranged weapons' draw/throw speed) for each Agent during a battle. I have found a way to access and set the stats I want, but they don't seem to change anything, except make melee weapons unable to hit at all.
This is the code I have so far, which gets called using a Harmony prefix patch OnAgentHit().
If anyone has any clues on how an attack is calculated to be a hit/miss, or other information on what needs to be called to use the weapons' new stats, it would be greatly appreciated.
This is the code I have so far, which gets called using a Harmony prefix patch OnAgentHit().
C#:
private static void ChangeWeaponSpeeds(Agent agent, double speedMultiplier)
{
speedMultiplier = speedMultiplier < Stamina.Instance.MaximumStaminaDebuff ? Stamina.Instance.MaximumStaminaDebuff : speedMultiplier;
for (int i = 0; i < 3; i++)
{
if (!(agent.Equipment[i].CurrentUsageItem == null))
{
PropertyInfo property = typeof(WeaponComponentData).GetProperty("SwingSpeed");
property.DeclaringType.GetProperty("SwingSpeed");
property.SetValue(agent.Equipment[i].PrimaryItem.PrimaryWeapon, (int)(agent.Equipment[i].PrimaryItem.PrimaryWeapon.SwingSpeed * speedMultiplier), BindingFlags.NonPublic | BindingFlags.Instance, null, null, null);
property = typeof(WeaponComponentData).GetProperty("ThrustSpeed");
property.DeclaringType.GetProperty("ThrustSpeed");
property.SetValue(agent.Equipment[i].PrimaryItem.PrimaryWeapon, (int)(agent.Equipment[i].PrimaryItem.PrimaryWeapon.ThrustSpeed * speedMultiplier), BindingFlags.NonPublic | BindingFlags.Instance, null, null, null);
//property = typeof(WeaponComponentData).GetProperty("MissileSpeed");
//property.DeclaringType.GetProperty("MissileSpeed");
//property.SetValue(agent.Equipment[i].PrimaryItem.PrimaryWeapon, (int)(agent.Equipment[i].PrimaryItem.PrimaryWeapon.SwingSpeed * speedMultiplier), BindingFlags.NonPublic | BindingFlags.Instance, null, null, null);
}
}
}
If anyone has any clues on how an attack is calculated to be a hit/miss, or other information on what needs to be called to use the weapons' new stats, it would be greatly appreciated.