Skip to content

Commit

Permalink
Fix damage on host
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 19, 2024
1 parent 8e257b8 commit 26ef09d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
13 changes: 9 additions & 4 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,21 @@ public override void ApplyDamageInfo(DamageInfo damageInfo, EBodyPart bodyPartTy

public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct389 shotId)
{
if (damageInfo.DamageType is not EDamageType.Sniper or EDamageType.Landmine)
if (damageInfo.DamageType is EDamageType.Sniper or EDamageType.Landmine)
{
return null;
return SimulatedApplyShot(damageInfo, bodyPartType, colliderType, armorPlateCollider, shotId);
}

if (damageInfo.Player != null && damageInfo.Player.iPlayer is not CoopBot)
if (damageInfo.Player != null && damageInfo.Player.iPlayer is CoopBot)
{
return null;
return SimulatedApplyShot(damageInfo, bodyPartType, colliderType, armorPlateCollider, shotId);
}

return null;
}

private GClass1688 SimulatedApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct389 shotId)
{
ActiveHealthController activeHealthController = ActiveHealthController;
if (activeHealthController != null && !activeHealthController.IsAlive)
{
Expand Down
11 changes: 4 additions & 7 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ public override void ApplyDamageInfo(DamageInfo damageInfo, EBodyPart bodyPartTy

public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartType, EBodyPartColliderType colliderType, EArmorPlateCollider armorPlateCollider, GStruct389 shotId)
{
ShotReactions(damageInfo, bodyPartType);

if (damageInfo.DamageType == EDamageType.Sniper && FikaBackendUtils.IsServer)
{
ShotReactions(damageInfo, bodyPartType);
PacketSender.DamagePackets.Enqueue(new()
{
Damage = damageInfo.Damage,
Expand Down Expand Up @@ -358,7 +359,6 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
damageInfo.DidArmorDamage = num;
}
damageInfo.DidBodyDamage = damageInfo.Damage;
ShotReactions(damageInfo, bodyPartType);
ReceiveDamage(damageInfo.Damage, bodyPartType, damageInfo.DamageType, num, hitInfo.Material);

PacketSender.DamagePackets.Enqueue(new()
Expand Down Expand Up @@ -393,11 +393,8 @@ public override GClass1688 ApplyShot(DamageInfo damageInfo, EBodyPart bodyPartTy
}
return null;
}
else
{
ShotReactions(damageInfo, bodyPartType);
return null;
}

return null;
}

public override void SetControllerInsteadRemovedOne(Item removingItem, Callback callback)
Expand Down

0 comments on commit 26ef09d

Please sign in to comment.