Skip to content

Commit

Permalink
Fix dual blade normal attack not having damagePerMob of 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 29, 2023
1 parent 1df1bb5 commit 44ec368
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ IAttackMobEntry attackMob
: 0
: 0;
var weaponType = ItemConstants.GetWeaponType(weapon);
var attackCount = attack.Type == AttackType.Shoot
var damagePerMob = attack.Type == AttackType.Shoot
? skillLevel?.BulletCount ?? 1
: skillLevel?.AttackCount ?? 1;

attackCount = Math.Max((short)1, attackCount);
damagePerMob = Math.Max((short)1, damagePerMob);

if (attack is { SkillID: 0, AttackActionType: 10 })
damagePerMob = 2;

_rndGenForCharacter.Next(random.Array);

Expand All @@ -101,9 +104,9 @@ IAttackMobEntry attackMob
character.HP >= stats.MaxHP * darkForceLevel.X / 100;

if (isDarkForce && attack.SkillID == Skill.DragonknightDragonBurster)
attackCount += darkForceLevel?.Y ?? 0;
damagePerMob += darkForceLevel?.Y ?? 0;

var result = new IDamage[attackCount];
var result = new IDamage[damagePerMob];

var totalCr = stats.Cr;
var totalCDMin = stats.CDMin;
Expand Down Expand Up @@ -136,7 +139,7 @@ IAttackMobEntry attackMob
if (mobStats.Level > stats.Level)
hitRate -= 5 * (mobStats.Level - stats.Level);

for (var i = 0; i < attackCount; i++)
for (var i = 0; i < damagePerMob; i++)
{
random.Skip(); // CalcPImmune

Expand Down Expand Up @@ -351,8 +354,8 @@ IAttackMobEntry attackMob
var random = new Rotational<uint>(new uint[RndSize]);
var skill = attack.SkillID > 0 ? await _skills.Retrieve(attack.SkillID) : null;
var skillLevel = skill?[stats.SkillLevels[attack.SkillID]];
var attackCount = skillLevel?.AttackCount ?? 1;
var result = new IDamage[attackCount];
var damagePerMob = skillLevel?.AttackCount ?? 1;
var result = new IDamage[damagePerMob];

_rndGenForCharacter.Next(random.Array);

Expand Down Expand Up @@ -387,7 +390,7 @@ IAttackMobEntry attackMob
if (mobStats.Level > stats.Level)
hitRate -= 5 * (mobStats.Level - stats.Level);

for (var i = 0; i < attackCount; i++)
for (var i = 0; i < damagePerMob; i++)
{
random.Skip(); // CalcMImmune

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ Skill.PriestTeleportMastery or
packet.WriteInt(entry.MobID);
packet.WriteByte(entry.ActionHit);

var isMismatch = false;

if (entry.Damage.Length != adjustedDamage.Length)
{
isMismatch = true;
_logger.LogInformation(
"{Character} triggered a {Type} attack count mismatch with skill id: {Skill} (Client: {Count}, Server: {CountServer})",
message.User.Character.Name,
Expand All @@ -106,10 +110,11 @@ Skill.PriestTeleportMastery or
entry.Damage.Length,
adjustedDamage.Length
);
}

for (var i = 0; i < message.Attack.DamagePerMob; i++)
{
if (entry.Damage[i] != adjustedDamage[i])
if (!isMismatch && entry.Damage[i] != adjustedDamage[i])
_logger.LogInformation(
"{Character} triggered a {Type} attack damage calculation mismatch with skill id: {Skill} (Client: {Damage}, Server: {DamageServer}, Critical: {IsCritical})",
message.User.Character.Name,
Expand All @@ -119,7 +124,8 @@ Skill.PriestTeleportMastery or
adjustedDamage[i],
damage[i].IsCritical
);
packet.WriteBool(damage[i].IsCritical);

packet.WriteBool(!isMismatch && damage[i].IsCritical);
packet.WriteInt(entry.Damage[i]);
}

Expand Down

0 comments on commit 44ec368

Please sign in to comment.