Skip to content

Commit

Permalink
Fix shared XP
Browse files Browse the repository at this point in the history
- Use correct Tag
- Fix if xp < 0
  • Loading branch information
Lacyway committed Dec 10, 2024
1 parent 2f7ce5e commit 97c180d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 33 deletions.
38 changes: 34 additions & 4 deletions Fika.Core/Coop/Players/CoopBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,47 @@ public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfoStruct
{
base.OnBeenKilledByAggressor(aggressor, damageInfo, bodyPart, lethalDamageType);

if (FikaPlugin.Instance.SharedQuestProgression && FikaPlugin.EasyKillConditions.Value)
if (aggressor.GroupId == "Fika" && !aggressor.IsYourPlayer)
{
if (aggressor.Profile.Info.GroupId == "Fika" && !aggressor.IsYourPlayer)
WildSpawnType role = Profile.Info.Settings.Role;
bool countAsBoss = role.CountAsBossForStatistics() && !(role is WildSpawnType.pmcUSEC or WildSpawnType.pmcBEAR);
int experience = Profile.Info.Settings.Experience;
if (experience < 0)
{
experience = Singleton<BackendConfigSettingsClass>.Instance.Experience.Kill.VictimBotLevelExp;
}

if (FikaPlugin.SharedKillExperience.Value && !countAsBoss)
{
int toReceive = experience / 2;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Received shared kill XP of {toReceive} from {killer.Profile.Nickname}");

Check failure on line 148 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 148 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 148 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 148 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context
#endif

Profile.EftStats.SessionCounters.AddInt(toReceive, SessionCounterTypesAbstractClass.ExpKillBase);
}

if (FikaPlugin.SharedBossExperience.Value && countAsBoss)
{
int toReceive = experience / 2;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Received shared boss XP of {toReceive} from {killer.Profile.Nickname}");

Check failure on line 158 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 158 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 158 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 158 in Fika.Core/Coop/Players/CoopBot.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context
#endif
Profile.EftStats.SessionCounters.AddInt(toReceive, SessionCounterTypesAbstractClass.KilledBoss);
}

if (FikaPlugin.Instance.SharedQuestProgression && FikaPlugin.EasyKillConditions.Value)
{
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo("Handling teammate kill from teammate: " + aggressor.Profile.Nickname);
#endif
CoopPlayer mainPlayer = (CoopPlayer)Singleton<GameWorld>.Instance.MainPlayer;
if (mainPlayer != null)
{
float distance = Vector3.Distance(aggressor.Position, Position);
mainPlayer.HandleTeammateKill(ref damageInfo, bodyPart, Side, Profile.Info.Settings.Role, ProfileId,
mainPlayer.HandleTeammateKill(ref damageInfo, bodyPart, Side, role, ProfileId,
distance, Inventory.EquippedInSlotsTemplateIds, HealthController.BodyPartEffects, TriggerZones,
(CoopPlayer)aggressor, Profile.Info.Settings.Experience);
(CoopPlayer)aggressor);
}
}
}
Expand Down
24 changes: 1 addition & 23 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using EFT.Interactive;
using EFT.InventoryLogic;
using EFT.SynchronizableObjects;
using EFT.UI;
using EFT.Vehicle;
using Fika.Core.Coop.ClientClasses;
using Fika.Core.Coop.ClientClasses.HandsControllers;
Expand Down Expand Up @@ -425,7 +424,7 @@ public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfoStruct
public void HandleTeammateKill(ref DamageInfoStruct damage, EBodyPart bodyPart,
EPlayerSide playerSide, WildSpawnType role, string playerProfileId,
float distance, List<string> targetEquipment,
HealthEffects enemyEffects, List<string> zoneIds, CoopPlayer killer, int experience)
HealthEffects enemyEffects, List<string> zoneIds, CoopPlayer killer)
{
if (!HealthController.IsAlive)
{
Expand Down Expand Up @@ -478,27 +477,6 @@ public void HandleTeammateKill(ref DamageInfoStruct damage, EBodyPart bodyPart,
bodyPart, Location, distance, role.ToStringNoBox(), hour, enemyEffects,
killer.HealthController.BodyPartEffects, zoneIds, killer.HealthController.ActiveBuffsNames());*/
}

bool countAsBoss = role.CountAsBossForStatistics() && !(role is WildSpawnType.pmcUSEC or WildSpawnType.pmcBEAR);

if (FikaPlugin.SharedKillExperience.Value && !countAsBoss)
{
int toReceive = experience / 2;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Received shared kill XP of {toReceive} from {killer.Profile.Nickname}");
#endif
Profile.EftStats.SessionCounters.AddInt(toReceive, SessionCounterTypesAbstractClass.Kills);
return;
}

if (FikaPlugin.SharedBossExperience.Value && countAsBoss)
{
int toReceive = experience / 2;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Received shared boss XP of {toReceive} from {killer.Profile.Nickname}");
#endif
Profile.EftStats.SessionCounters.AddInt(toReceive, SessionCounterTypesAbstractClass.KilledBoss);
}
}

#if DEBUG
Expand Down
39 changes: 33 additions & 6 deletions Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -901,18 +901,45 @@ public override void HandleDamagePacket(ref DamagePacket packet)
LastDamagedBodyPart = packet.BodyPartType;
}

public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfoStruct DamageInfo, EBodyPart bodyPart, EDamageType lethalDamageType)
public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfoStruct damageInfo, EBodyPart bodyPart, EDamageType lethalDamageType)
{
// Only handle if it was ourselves as otherwise it's irrelevant
if (LastAggressor.IsYourPlayer)
{
base.OnBeenKilledByAggressor(aggressor, DamageInfo, bodyPart, lethalDamageType);
base.OnBeenKilledByAggressor(aggressor, damageInfo, bodyPart, lethalDamageType);
return;
}

if (FikaPlugin.Instance.SharedQuestProgression && FikaPlugin.EasyKillConditions.Value)
if (aggressor.GroupId == "Fika" && !aggressor.IsYourPlayer)
{
if (aggressor.GroupId == "Fika" && !aggressor.IsYourPlayer)
WildSpawnType role = Profile.Info.Settings.Role;
bool countAsBoss = role.CountAsBossForStatistics() && !(role is WildSpawnType.pmcUSEC or WildSpawnType.pmcBEAR);
int experience = Profile.Info.Settings.Experience;
if (experience < 0)
{
experience = Singleton<BackendConfigSettingsClass>.Instance.Experience.Kill.VictimBotLevelExp;
}

if (FikaPlugin.SharedKillExperience.Value && !countAsBoss)
{
int toReceive = experience / 2;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Received shared kill XP of {toReceive} from {killer.Profile.Nickname}");

Check failure on line 927 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 927 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 927 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 927 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context
#endif

Profile.EftStats.SessionCounters.AddInt(toReceive, SessionCounterTypesAbstractClass.ExpKillBase);
}

if (FikaPlugin.SharedBossExperience.Value && countAsBoss)
{
int toReceive = experience / 2;
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo($"Received shared boss XP of {toReceive} from {killer.Profile.Nickname}");

Check failure on line 937 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 937 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 937 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context

Check failure on line 937 in Fika.Core/Coop/Players/ObservedCoopPlayer.cs

View workflow job for this annotation

GitHub Actions / test

The name 'killer' does not exist in the current context
#endif
Profile.EftStats.SessionCounters.AddInt(toReceive, SessionCounterTypesAbstractClass.KilledBoss);
}

if (FikaPlugin.Instance.SharedQuestProgression && FikaPlugin.EasyKillConditions.Value)
{
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo("Handling teammate kill from teammate: " + aggressor.Profile.Nickname);
Expand All @@ -921,9 +948,9 @@ public override void OnBeenKilledByAggressor(IPlayer aggressor, DamageInfoStruct
if (mainPlayer != null)
{
float distance = Vector3.Distance(aggressor.Position, Position);
mainPlayer.HandleTeammateKill(ref DamageInfo, bodyPart, Side, Profile.Info.Settings.Role, ProfileId,
mainPlayer.HandleTeammateKill(ref damageInfo, bodyPart, Side, role, ProfileId,
distance, Inventory.EquippedInSlotsTemplateIds, HealthController.BodyPartEffects, TriggerZones,
(CoopPlayer)aggressor, Profile.Info.Settings.Experience);
(CoopPlayer)aggressor);
}
}
}
Expand Down

0 comments on commit 97c180d

Please sign in to comment.