Skip to content

Commit

Permalink
#2650 Parsing a combat log now works for SoD
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed Jan 14, 2025
1 parent 16243d3 commit e2bb5f4
Show file tree
Hide file tree
Showing 35 changed files with 1,274 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Logic\CombatLog\CombatEvents\Advanced\Versions\V20\AdvancedDataV20;
use App\Logic\CombatLog\CombatEvents\Advanced\Versions\V22\AdvancedDataV22;
use App\Logic\CombatLog\CombatEvents\Advanced\Versions\V9\AdvancedDataV9;
use App\Logic\CombatLog\CombatEvents\Advanced\Versions\V9SoD\AdvancedDataV9SoD;
use App\Logic\CombatLog\CombatLogVersion;

class AdvancedDataBuilder
Expand All @@ -13,6 +14,7 @@ public static function create(int $combatLogVersion): AdvancedDataInterface
{
return match ($combatLogVersion) {
CombatLogVersion::CLASSIC => new AdvancedDataV9(),
CombatLogVersion::CLASSIC_SOD_1_15_5 => new AdvancedDataV9SoD(),
CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new AdvancedDataV20(),
default => new AdvancedDataV22(),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Advanced\Versions\V9SoD;

use App\Logic\CombatLog\CombatEvents\Advanced\AdvancedDataInterface;
use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;
use App\Logic\CombatLog\Guid\Guid;

/**
* 12/9/2024 18:51:23.3640 SPELL_CAST_SUCCESS,Player-5827-01FF533F,"Nikp-LivingFlame-EU",0x511,0x0,0000000000000000,nil,0x80000000,0x80000000,425600,"Horn of Lordaeron",0x1,Player-5827-01FF533F,0000000000000000,100,100,0,0,0,0,0,-1,0,0,0,-8213.53,2012.04,0,1.3086,72
*
* @author Wouter
*
* @since 08/01/2025
*/
class AdvancedDataV9SoD implements AdvancedDataInterface
{
private ?Guid $infoGuid = null;

private ?Guid $ownerGuid = null;

private int $currentHP;

private int $maxHP;

private int $power;

private int $armor;

private int $unknown1;

private int $unknown2;

private int $absorb;

/** @var int[] */
private array $powerType;

/** @var int[] */
private array $currentPower;

/** @var int[] */
private array $maxPower;

/** @var int[] */
private array $powerCost;

private float $positionX;

private float $positionY;

private int $uiMapId;

private float $facing;

private int $level;

public function getInfoGuid(): ?Guid
{
return $this->infoGuid;
}

public function getOwnerGuid(): ?Guid
{
return $this->ownerGuid;
}

public function getCurrentHP(): int
{
return $this->currentHP;
}

public function getMaxHP(): int
{
return $this->maxHP;
}

public function getAttackPower(): int
{
return $this->power;
}

public function getSpellPower(): int
{
return $this->power;
}

public function getArmor(): int
{
return $this->armor;
}

public function getUnknown1(): int
{
return $this->unknown1;
}

public function getUnknown2(): int
{
return $this->unknown2;
}

public function getAbsorb(): int
{
return $this->absorb;
}

/**
* @return int[]
*/
public function getPowerType(): array
{
return $this->powerType;
}

/**
* @return int[]
*/
public function getCurrentPower(): array
{
return $this->currentPower;
}

/**
* @return int[]
*/
public function getMaxPower(): array
{
return $this->maxPower;
}

/**
* @return int[]
*/
public function getPowerCost(): array
{
return $this->powerCost;
}

public function getPositionX(): float
{
return $this->positionX;
}

public function getPositionY(): float
{
return $this->positionY;
}

public function getUiMapId(): int
{
return $this->uiMapId;
}

public function getFacing(): float
{
return $this->facing;
}

public function getLevel(): int
{
return $this->level;
}

public function setParameters(array $parameters): HasParameters
{
$this->infoGuid = Guid::createFromGuidString($parameters[0]);
$this->ownerGuid = Guid::createFromGuidString($parameters[1]);
$this->currentHP = $parameters[2];
$this->maxHP = $parameters[3];
$this->power = $parameters[4];
$this->armor = $parameters[5];
$this->unknown1 = $parameters[6];
$this->unknown2 = $parameters[7];
$this->absorb = $parameters[8];
$this->powerType = explode('|', (string)$parameters[9]);
$this->currentPower = explode('|', (string)$parameters[10]);
$this->maxPower = explode('|', (string)$parameters[11]);
$this->powerCost = explode('|', (string)$parameters[12]);
// https://forums.combatlogforums.com/t/unit-positions-from-combat-log-solved/822
// Be aware also that the coordinates are rotated 90 degrees for some crazy reason. This means that for the two numbers listed, pos1 and pos2, the following rules apply:
//
// x-position = -pos2
// y-position = pos1
// This fixes the above issue. X and Y are fine after this
$this->positionX = $parameters[14] * -1;
$this->positionY = $parameters[13];
$this->uiMapId = $parameters[15];
$this->facing = $parameters[16];
$this->level = $parameters[17];

return $this;
}

public function getParameterCount(): int
{
return 18;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static function create(int $combatLogVersion): Suffix
{
return match ($combatLogVersion) {
CombatLogVersion::CLASSIC, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageV20($combatLogVersion),
// Includes CombatLogVersion::CLASSIC_SOD_1_15_5
default => new DamageV22($combatLogVersion),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
public static function create(int $combatLogVersion): Suffix
{
return match ($combatLogVersion) {
CombatLogVersion::CLASSIC, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageLandedV20($combatLogVersion),
CombatLogVersion::CLASSIC, CombatLogVersion::CLASSIC_SOD_1_15_5, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageLandedV20($combatLogVersion),
default => new DamageLandedV22($combatLogVersion),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
public static function create(int $combatLogVersion): Suffix
{
return match ($combatLogVersion) {
CombatLogVersion::CLASSIC, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageLandedSupportV20($combatLogVersion),
CombatLogVersion::CLASSIC, CombatLogVersion::CLASSIC_SOD_1_15_5, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageLandedSupportV20($combatLogVersion),
default => new DamageLandedSupportV22($combatLogVersion),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
public static function create(int $combatLogVersion): Suffix
{
return match ($combatLogVersion) {
CombatLogVersion::CLASSIC, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageSupportV20($combatLogVersion),
CombatLogVersion::CLASSIC, CombatLogVersion::CLASSIC_SOD_1_15_5, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new DamageSupportV20($combatLogVersion),
default => new DamageSupportV22($combatLogVersion),
};
}
Expand Down
9 changes: 8 additions & 1 deletion app/Logic/CombatLog/CombatEvents/Suffixes/Leech.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;

/**
* @TODO This seems to be a SpecialEvent that behaves like a regular SPELL_ event with a LEECH suffix. But in V22
* two new unknown fields were added to AdvancedData but only 1 was added to this event? So this suffix is offset by 1
* in that regard - since this is only for SoD I'm not fixing it _now_ but for SoD this event is broken. See the below combat log.
*
* SPELL_LEECH,Creature-0-5208-531-679-15262-0001573C0B,"Obsidian Eradicator",0x10a48,0x0,Player-5827-01CB5FED,"Manta-LivingFlame-EU",0x514,0x0,1215781,"Drain Mana",0x20,Player-5827-01CB5FED,0000000000000000,97,100,0,0,0,0,0,-1,0,0,0,-8204.26,2063.29,0,1.1711,73,125,0,250,3527
*/
class Leech extends Suffix
{
private float $amount;
Expand Down Expand Up @@ -48,6 +55,6 @@ public function getOptionalParameterCount(): int

public function getParameterCount(): int
{
return 3;
return 4;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Logic\CombatLog\CombatEvents\Suffixes\Missed\V20\MissedV20;
use App\Logic\CombatLog\CombatEvents\Suffixes\Missed\V22\MissedV22;
use App\Logic\CombatLog\CombatEvents\Suffixes\Missed\V9SoD\MissedV9SoD;
use App\Logic\CombatLog\CombatEvents\Suffixes\Suffix;
use App\Logic\CombatLog\CombatEvents\Suffixes\SuffixBuilderInterface;
use App\Logic\CombatLog\CombatLogVersion;
Expand All @@ -18,7 +19,9 @@ public function __construct(
public static function create(int $combatLogVersion): Suffix
{
return match ($combatLogVersion) {
CombatLogVersion::CLASSIC_SOD_1_15_5 => new MissedV9SoD($combatLogVersion),
CombatLogVersion::CLASSIC, CombatLogVersion::RETAIL_10_1_0, CombatLogVersion::RETAIL_11_0_2 => new MissedV20($combatLogVersion),
// This includes
default => new MissedV22($combatLogVersion),
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes\Missed\V9SoD;

use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;
use App\Logic\CombatLog\CombatEvents\Suffixes\Missed\MissedInterface;
use App\Logic\CombatLog\CombatEvents\Suffixes\Suffix;
use App\Logic\CombatLog\Guid\Guid;
use App\Logic\CombatLog\Guid\MissType\Block;
use App\Logic\CombatLog\Guid\MissType\Resist;

class MissedV9SoD extends Suffix implements MissedInterface
{
private Guid $missType;

private bool $offhand;

private int $amountMissed;

private int $amountTotal;

private ?string $damageType;

public function getMissType(): Guid
{
return $this->missType;
}

public function isOffHand(): bool
{
return $this->offhand;
}

public function getAmountMissed(): int
{
return $this->amountMissed;
}

public function getAmountTotal(): int
{
return $this->amountTotal;
}

public function getDamageType(): ?string
{
return $this->damageType;
}

public function isCritical(): bool
{
return false;
}


public function setParameters(array $parameters): HasParameters
{
parent::setParameters($parameters);

$this->missType = Guid::createFromGuidString($parameters[0]);
$this->offhand = $parameters[1] !== 'nil';
if (!isset($parameters[2]) || in_array($parameters[2], ['ST', 'AOE'])) {
$this->amountMissed = 0;
$this->amountTotal = 0;
$this->damageType = $parameters[2] ?? null;
} else if ($this->missType instanceof Block || $this->missType instanceof Resist) {
$this->amountMissed = 0;
$this->amountTotal = 0;
$this->damageType = $parameters[2];
} else {
$this->amountMissed = $parameters[2];
$this->amountTotal = $parameters[3] ?? 0;
$this->damageType = $parameters[4] ?? null;
}

return $this;
}

public function getOptionalParameterCount(): int
{
return 3;
}

public function getParameterCount(): int
{
return 5;
}
}
Loading

0 comments on commit e2bb5f4

Please sign in to comment.