Skip to content

Commit

Permalink
Analytics: Add crowd control events
Browse files Browse the repository at this point in the history
  • Loading branch information
Sejsel committed Jun 28, 2024
1 parent 0d5c182 commit af1092b
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 51 deletions.
1 change: 1 addition & 0 deletions ArcdpsLogManager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This is the full changelog of the arcdps Log Manager.
- 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.
- Added CrowdControlEvent (crowd control against non-defiant enemies); requires arcdps 2024-06-27 or newer.

## Log Manager v1.11.1

Expand Down
21 changes: 21 additions & 0 deletions EVTCAnalytics/Events/DamageEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,25 @@ public abstract class DamageEvent(
public bool IsNinety { get; } = isNinety;
public bool IsFlanking { get; } = isFlanking;
}

/// <summary>
/// A crowd control event affecting an enemy without a defiance bar.
/// </summary>
public class CrowdControlEvent(
long time,
Agent attacker,
Agent defender,
Skill skill,
bool isMoving,
bool isNinety,
bool isFlanking)
: Event(time)
{
public Skill Skill { get; } = skill;
public Agent Attacker { get; internal set; } = attacker;
public Agent Defender { get; internal set; } = defender;
public bool IsMoving { get; } = isMoving;
public bool IsNinety { get; } = isNinety;
public bool IsFlanking { get; } = isFlanking;
}
}
2 changes: 2 additions & 0 deletions EVTCAnalytics/Parsed/Enums/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public enum Result : byte
KillingBlow = 8,
Downed = 9,
DefianceBar = 10,
Activation = 11,
CrowdControl = 12, // Introduced in arcdps 20240627.
}
}
8 changes: 8 additions & 0 deletions EVTCAnalytics/Parsing/CombatItemFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ private static IEnumerable<StateChange> GetDirectStateChangesForEventType(Type e

if (eventType == typeof(RewardEvent)) return [StateChange.Reward];

if (eventType == typeof(CrowdControlEvent)) return [];

if (eventType == typeof(SkillCastEvent)) return [];
if (eventType == typeof(EndSkillCastEvent)) return [];
if (eventType == typeof(StartSkillCastEvent)) return [];
Expand Down Expand Up @@ -332,6 +334,8 @@ private static bool IsDirectBuffDamage(Type eventType)
if (eventType == typeof(OffCycleBuffDamageEvent)) return true;
if (eventType == typeof(DefianceBarDamageEvent)) return false; // This is a physical event, even "soft CC".

if (eventType == typeof(CrowdControlEvent)) return false;

if (eventType == typeof(RewardEvent)) return false;

if (eventType == typeof(SkillCastEvent)) return false;
Expand Down Expand Up @@ -401,6 +405,8 @@ private static bool IsDirectSkillCast(Type eventType)
if (eventType == typeof(BuffDamageEvent)) return false;
if (eventType == typeof(OffCycleBuffDamageEvent)) return false;
if (eventType == typeof(DefianceBarDamageEvent)) return false;

if (eventType == typeof(CrowdControlEvent)) return false;

if (eventType == typeof(RewardEvent)) return false;

Expand Down Expand Up @@ -471,6 +477,8 @@ private static IEnumerable<Result> GetDirectPhysicalResultsForEventType(Type eve
if (eventType == typeof(BuffDamageEvent)) return [];
if (eventType == typeof(OffCycleBuffDamageEvent)) return [];
if (eventType == typeof(DefianceBarDamageEvent)) return [Result.DefianceBar];

if (eventType == typeof(CrowdControlEvent)) return [Result.CrowdControl];

if (eventType == typeof(RewardEvent)) return [];

Expand Down
32 changes: 15 additions & 17 deletions EVTCAnalytics/Processing/LogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ static WeaponSet WeaponSetFromId(long id)
// TODO: Rewrite
bool ignored = false;
bool defianceBar = false;
bool crowdControl = false;
var hitResult = PhysicalDamageEvent.Result.Normal;
var ignoreReason = IgnoredPhysicalDamageEvent.Reason.Absorbed;
switch (item.Result)
Expand Down Expand Up @@ -1474,28 +1475,25 @@ static WeaponSet WeaponSetFromId(long id)
case Result.DefianceBar:
defianceBar = true;
break;
case Result.CrowdControl:
crowdControl = true;
break;
default:
return new UnknownEvent(item.Time, item);
}

if (!defianceBar)
{
if (!ignored)
{
return new PhysicalDamageEvent(item.Time, attacker, defender, skill, damage, isMoving,
isNinety, isFlanking, shieldDamage, hitResult);
}
else
{
return new IgnoredPhysicalDamageEvent(item.Time, attacker, defender, skill, damage,
isMoving, isNinety, isFlanking, shieldDamage, ignoreReason);
}
}
else
return (defianceBar, crowdControl, ignored) switch
{
return new DefianceBarDamageEvent(item.Time, attacker, defender, skill, damage, isMoving,
isNinety, isFlanking);
}
(true, true, true) => throw new InvalidOperationException(),
(true, true, false) => throw new InvalidOperationException(),
(true, false, false) => new DefianceBarDamageEvent(item.Time, attacker, defender, skill, damage, isMoving, isNinety, isFlanking),
(true, false, true) => throw new InvalidOperationException(),
(false, true, false) => new CrowdControlEvent(item.Time, attacker, defender, skill, isMoving, isNinety, isFlanking),
(false, true, true) => throw new InvalidOperationException(),
(false, false, false) => new PhysicalDamageEvent(item.Time, attacker, defender, skill, damage, isMoving,
isNinety, isFlanking, shieldDamage, hitResult),
(false, false, true) => new IgnoredPhysicalDamageEvent(item.Time, attacker, defender, skill, damage, isMoving, isNinety, isFlanking, shieldDamage, ignoreReason)
};
}

return new UnknownEvent(item.Time, item);
Expand Down
13 changes: 13 additions & 0 deletions EVTCAnalytics/Processing/Steps/MergeSingletonNPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ public void Process(LogProcessorState state)
damageEvent.Defender = resultingAgent;
}
}

if (ev is CrowdControlEvent crowdControlEvent)
{
if (agentsToMerge.Contains(crowdControlEvent.Attacker))
{
crowdControlEvent.Attacker = resultingAgent;
}

if (agentsToMerge.Contains(crowdControlEvent.Defender))
{
crowdControlEvent.Defender = resultingAgent;
}
}

if (ev is EffectStartEvent effectStartEvent)
{
Expand Down
41 changes: 7 additions & 34 deletions EVTCInspector/EventFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,6 @@ namespace GW2Scratch.EVTCInspector
{
public static class EventFilters
{
public static bool IsAgentInEvent(Event ev, string agentName)
{
if (!string.IsNullOrWhiteSpace(agentName))
{
if (ev is AgentEvent agentEvent)
{
var agent = agentEvent.Agent;
if (agent == null)
{
return false;
}

return agent.Name.Contains(agentName);
}
else if (ev is DamageEvent damageEvent)
{
var attacker = damageEvent.Attacker;
var defender = damageEvent.Defender;
if (attacker == null || defender == null)
{
return false;
}

return attacker.Name.Contains(agentName) || defender.Name.Contains(agentName);
}
else
{
return false;
}
}

return true;
}

public static bool IsAgentInEvent(Event ev, Agent agent, bool ifSource = true, bool ifTarget = true)
{
if (ev is BuffEvent buffEvent)
Expand Down Expand Up @@ -74,6 +40,13 @@ public static bool IsAgentInEvent(Event ev, Agent agent, bool ifSource = true, b
return (ifSource && agent == source) || (ifTarget && agent == target);
}

if (ev is CrowdControlEvent crowdControlEvent)
{
var source = crowdControlEvent.Attacker;
var target = crowdControlEvent.Defender;
return (ifSource && agent == source) || (ifTarget && agent == target);
}

return false;
}

Expand Down

0 comments on commit af1092b

Please sign in to comment.