Skip to content

Commit

Permalink
Analytics: Add support for old weapon set
Browse files Browse the repository at this point in the history
  • Loading branch information
Sejsel committed Jun 28, 2024
1 parent 7be2e26 commit 0d5c182
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions ArcdpsLogManager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This is the full changelog of the arcdps Log Manager.
- Added SquadGroundMarkerPlace and SquadGroundMarkerRemove events; requires arcdps 2024-03-28 or newer.
- Added AgentGliderOpenEvent and AgentGliderClosedEvent; requires arcdps 2024-06-27 or newer.
- Exact arcdps build is now shown in the Statistics tabs; requires arcdps 2024-06-14 or newer.
- Added old weapon set to AgentWeaponSwapEvent; requires arcdps 2024-06-27 or newer.

## Log Manager v1.11.1

Expand Down
6 changes: 5 additions & 1 deletion EVTCAnalytics/Events/AgentEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ public class AgentHealthUpdateEvent(long time, Agent agent, float healthFraction
/// A weapon set does not necessarily correspond to what players use the weapon swap action for.
/// Swapping to a bundle that provides a set of skills will also trigger this event.
/// </remarks>
public class AgentWeaponSwapEvent(long time, Agent agent, WeaponSet newWeaponSet) : AgentEvent(time, agent)
public class AgentWeaponSwapEvent(long time, Agent agent, WeaponSet newWeaponSet, WeaponSet? oldWeaponSet) : AgentEvent(time, agent)
{
public WeaponSet NewWeaponSet { get; } = newWeaponSet;
/// <summary>
/// Introduced in EVTC20240627. May be null before.
/// </summary>
public WeaponSet? OldWeaponSet { get; } = oldWeaponSet;
}

/// <summary>
Expand Down
36 changes: 15 additions & 21 deletions EVTCAnalytics/Processing/LogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -978,31 +978,25 @@ Skill GetSkillByIdOrAdd(uint id)
return new AgentHealthUpdateEvent(item.Time, GetAgentByAddress(item.SrcAgent),
healthFraction);
case StateChange.WeaponSwap:
WeaponSet newWeaponSet;
switch (item.DstAgent)
static WeaponSet WeaponSetFromId(long id)
{
case 0:
newWeaponSet = WeaponSet.Water1;
break;
case 1:
newWeaponSet = WeaponSet.Water2;
break;
case 4:
newWeaponSet = WeaponSet.Land1;
break;
case 5:
newWeaponSet = WeaponSet.Land2;
break;
default:
newWeaponSet = WeaponSet.Unknown;
break;
return id switch
{
0 => WeaponSet.Water1,
1 => WeaponSet.Water2,
4 => WeaponSet.Land1,
5 => WeaponSet.Land2,
_ => WeaponSet.Unknown
};
}

return new AgentWeaponSwapEvent(item.Time, GetAgentByAddress(item.SrcAgent),
newWeaponSet);
WeaponSet newWeaponSet = WeaponSetFromId((long) item.DstAgent);
bool isOldWeaponSetAvailable = string.Compare(state.EvtcVersion, "EVTC20240627", StringComparison.OrdinalIgnoreCase) >= 0;
WeaponSet? oldWeaponSet = isOldWeaponSetAvailable ? WeaponSetFromId(item.Value) : null;

return new AgentWeaponSwapEvent(item.Time, GetAgentByAddress(item.SrcAgent), newWeaponSet, oldWeaponSet);
case StateChange.MaxHealthUpdate:
return new AgentMaxHealthUpdateEvent(item.Time, GetAgentByAddress(item.SrcAgent),
item.DstAgent);
return new AgentMaxHealthUpdateEvent(item.Time, GetAgentByAddress(item.SrcAgent), item.DstAgent);
case StateChange.Reward:
return new RewardEvent(item.Time, item.DstAgent, item.Value);
case StateChange.BuffInitial:
Expand Down

0 comments on commit 0d5c182

Please sign in to comment.