Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(verse): add the VerseCore shared types, coordinate module and contract tests (#1127)

Ruben Lütke2f59c1d98efe
diff --git a/unreal/Verse/Source/VerseCore/Private/Bot/VerseBotAdaptiveConfig.cpp b/unreal/Verse/Source/VerseCore/Private/Bot/VerseBotAdaptiveConfig.cpp
new file mode 100644
index 0000000000..96768d4595
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Bot/VerseBotAdaptiveConfig.cpp
@@ -0,0 +1,56 @@
+#include "Bot/VerseBotAdaptiveConfig.h"
+
+#include "Bot/VerseBotTier.h"
+#include "UObject/UnrealType.h"
+
+float UVerseBotAdaptiveConfig::NextSkill(float CurrentSkill, float PersonShare, int32 KillsSoFar) const
+{
+ const float S = FMath::Clamp(CurrentSkill, 0.f, 1.f);
+ if (KillsSoFar < WarmupKills || FMath::Abs(PersonShare - TargetPersonShare) <= Deadband)
+ {
+ return S;
+ }
+ const float Step = FMath::Clamp(Gain * (PersonShare - TargetPersonShare), -MaxStepPerKill, MaxStepPerKill);
+ return FMath::Clamp(S + Step, 0.f, 1.f);
+}
+
+void UVerseBotAdaptiveConfig::InterpolateTier(const UVerseBotTier& Normal, const UVerseBotTier& Hard, const UVerseBotTier& Elite,
+ float S, UVerseBotTier& Out)
+{
+ const float Clamped = FMath::Clamp(S, 0.f, 1.f);
+ const bool bLowerHalf = Clamped <= 0.5f;
+ const UVerseBotTier& From = bLowerHalf ? Normal : Hard;
+ const UVerseBotTier& To = bLowerHalf ? Hard : Elite;
+ const float T = bLowerHalf ? Clamped * 2.f : (Clamped - 0.5f) * 2.f;
+
+ for (TFieldIterator<FProperty> It(UVerseBotTier::StaticClass()); It; ++It)
+ {
+ const FProperty* Prop = *It;
+ if (Prop->GetOwnerClass() != UVerseBotTier::StaticClass())
+ {
+ continue;
+ }
+ if (const FFloatProperty* FloatProp = CastField<FFloatProperty>(Prop))
+ {
+ const float A = FloatProp->GetPropertyValue_InContainer(&From);
+ const float B = FloatProp->GetPropertyValue_InContainer(&To);
+ FloatProp->SetPropertyValue_InContainer(&Out, FMath::Lerp(A, B, T));
+ }
+ else if (const FIntProperty* IntProp = CastField<FIntProperty>(Prop))
+ {
+ const int32 A = IntProp->GetPropertyValue_InContainer(&From);
+ const int32 B = IntProp->GetPropertyValue_InContainer(&To);
+ IntProp->SetPropertyValue_InContainer(&Out, FMath::RoundToInt(FMath::Lerp(float(A), float(B), T)));
+ }
+ else if (const FStructProperty* StructProp = CastField<FStructProperty>(Prop))
+ {
+ if (StructProp->Struct && StructProp->Struct->GetFName() == FName(TEXT("Vector2f")))
+ {
+ const FVector2f& A = *StructProp->ContainerPtrToValuePtr<FVector2f>(&From);
+ const FVector2f& B = *StructProp->ContainerPtrToValuePtr<FVector2f>(&To);
+ *StructProp->ContainerPtrToValuePtr<FVector2f>(&Out) = FMath::Lerp(A, B, T);
+ }
+ }
+ }
+ Out.TierId = TEXT("adaptive");
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Bot/VerseBotTier.cpp b/unreal/Verse/Source/VerseCore/Private/Bot/VerseBotTier.cpp
new file mode 100644
index 0000000000..9671097fcd
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Bot/VerseBotTier.cpp
@@ -0,0 +1,196 @@
+#include "Bot/VerseBotTier.h"
+
+bool UVerseBotTier::ApplyStartValues(FName InTierId, UVerseBotTier& Out)
+{
+ if (InTierId == TEXT("normal"))
+ {
+ Out.ReactionMs = FVector2f(320.0f, 60.0f);
+ Out.PeripheralReactionMul = 1.6f;
+ Out.PartialExposureAcquireMul = 1.5f;
+ Out.TrackLatencyMs = 150.0f;
+ Out.HearingErrorBaseM = 3.0f;
+ Out.HearingErrorPerM = 0.1f;
+ Out.AimNoiseDeg = 1.4f;
+ Out.AimNoiseRate = 1.6f;
+ Out.AcquireErrorDeg = 6.0f;
+ Out.AcquireMs = 650.0f;
+ Out.TurnRateDegS = 450.0f;
+ Out.AimStiffness = 8.0f;
+ Out.LeadSkill = 0.6f;
+ Out.LeadNoise = 0.35f;
+ Out.MotionWindowMs = 0.0f;
+ Out.RecoilPatternComp = 0.35f;
+ Out.RecoilResidualGain = 0.3f;
+ Out.FireTolerance = 2.0f;
+ Out.HeadAimChance = 0.05f;
+ Out.AdsRangeM = 12.0f;
+ Out.BurstRangeM = 30.0f;
+ Out.MaxBurstShots = 8;
+ Out.DecisionMs = 320.0f;
+ Out.UtilityNoise = 0.08f;
+ Out.Aggression = 0.5f;
+ Out.CoverUse = 0.4f;
+ Out.FlankUse = 0.2f;
+ Out.PreferredRangeM = 14.0f;
+ Out.StrafeMs = FVector2f(700.0f, 1500.0f);
+ Out.LeanUse = 0.2f;
+ Out.CrouchPeekUse = 0.2f;
+ Out.ProneUse = 0.05f;
+ Out.SlideUse = 0.1f;
+ Out.NavLinkCostMul = 2.0f;
+ Out.SoundDiscipline = 0.1f;
+ Out.PeekRepeatPenalty = 0.1f;
+ Out.BulwarkUse = 0.2f;
+ Out.BreachUse = 0.1f;
+ Out.WallbangUse = 0.15f;
+ Out.WallbangMinBelief = 0.55f;
+ Out.WallbangMaxSourceAgeS = 1.5f;
+ Out.WallbangMinDamageFrac = 0.3f;
+ Out.PrefireChance = 0.1f;
+ Out.StalkUse = 0.1f;
+ Out.MaxStalkS = 4.0f;
+ Out.FinisherCommitConfidence = 0.8f;
+ Out.KnifeChoice = 0.2f;
+ Out.TacticalReloadAtFrac = 0.25f;
+ Out.ReloadOnlyWhenSafe = 0.3f;
+ Out.PistolSwitchChance = 0.2f;
+ Out.LearnWeightMax = 0.1f;
+ Out.LearnSamplesHalf = 12.0f;
+ Out.HabitHalfLifeS = 180.0f;
+ Out.ExplorationRate = 0.25f;
+ }
+ else if (InTierId == TEXT("hard"))
+ {
+ Out.ReactionMs = FVector2f(270.0f, 50.0f);
+ Out.PeripheralReactionMul = 1.5f;
+ Out.PartialExposureAcquireMul = 1.35f;
+ Out.TrackLatencyMs = 120.0f;
+ Out.HearingErrorBaseM = 1.9f;
+ Out.HearingErrorPerM = 0.065f;
+ Out.AimNoiseDeg = 1.0f;
+ Out.AimNoiseRate = 1.9f;
+ Out.AcquireErrorDeg = 3.9f;
+ Out.AcquireMs = 450.0f;
+ Out.TurnRateDegS = 620.0f;
+ Out.AimStiffness = 12.0f;
+ Out.LeadSkill = 0.8f;
+ Out.LeadNoise = 0.22f;
+ Out.MotionWindowMs = 200.0f;
+ Out.RecoilPatternComp = 0.7f;
+ Out.RecoilResidualGain = 0.5f;
+ Out.FireTolerance = 1.6f;
+ Out.HeadAimChance = 0.2f;
+ Out.AdsRangeM = 9.0f;
+ Out.BurstRangeM = 22.0f;
+ Out.MaxBurstShots = 5;
+ Out.DecisionMs = 220.0f;
+ Out.UtilityNoise = 0.06f;
+ Out.Aggression = 0.6f;
+ Out.CoverUse = 0.65f;
+ Out.FlankUse = 0.45f;
+ Out.PreferredRangeM = 12.0f;
+ Out.StrafeMs = FVector2f(450.0f, 1050.0f);
+ Out.LeanUse = 0.6f;
+ Out.CrouchPeekUse = 0.5f;
+ Out.ProneUse = 0.1f;
+ Out.SlideUse = 0.3f;
+ Out.NavLinkCostMul = 1.3f;
+ Out.SoundDiscipline = 0.5f;
+ Out.PeekRepeatPenalty = 0.4f;
+ Out.BulwarkUse = 0.5f;
+ Out.BreachUse = 0.4f;
+ Out.WallbangUse = 0.5f;
+ Out.WallbangMinBelief = 0.4f;
+ Out.WallbangMaxSourceAgeS = 2.5f;
+ Out.WallbangMinDamageFrac = 0.3f;
+ Out.PrefireChance = 0.35f;
+ Out.StalkUse = 0.35f;
+ Out.MaxStalkS = 6.0f;
+ Out.FinisherCommitConfidence = 0.7f;
+ Out.KnifeChoice = 0.35f;
+ Out.TacticalReloadAtFrac = 0.35f;
+ Out.ReloadOnlyWhenSafe = 0.7f;
+ Out.PistolSwitchChance = 0.6f;
+ Out.LearnWeightMax = 0.22f;
+ Out.LearnSamplesHalf = 8.0f;
+ Out.HabitHalfLifeS = 300.0f;
+ Out.ExplorationRate = 0.15f;
+ }
+ else if (InTierId == TEXT("elite"))
+ {
+ Out.ReactionMs = FVector2f(225.0f, 40.0f);
+ Out.PeripheralReactionMul = 1.4f;
+ Out.PartialExposureAcquireMul = 1.25f;
+ Out.TrackLatencyMs = 95.0f;
+ Out.HearingErrorBaseM = 1.1f;
+ Out.HearingErrorPerM = 0.04f;
+ Out.AimNoiseDeg = 0.8f;
+ Out.AimNoiseRate = 2.2f;
+ Out.AcquireErrorDeg = 3.1f;
+ Out.AcquireMs = 340.0f;
+ Out.TurnRateDegS = 850.0f;
+ Out.AimStiffness = 17.0f;
+ Out.LeadSkill = 0.9f;
+ Out.LeadNoise = 0.14f;
+ Out.MotionWindowMs = 300.0f;
+ Out.RecoilPatternComp = 0.85f;
+ Out.RecoilResidualGain = 0.65f;
+ Out.FireTolerance = 1.3f;
+ Out.HeadAimChance = 0.35f;
+ Out.AdsRangeM = 7.0f;
+ Out.BurstRangeM = 16.0f;
+ Out.MaxBurstShots = 4;
+ Out.DecisionMs = 160.0f;
+ Out.UtilityNoise = 0.05f;
+ Out.Aggression = 0.7f;
+ Out.CoverUse = 0.85f;
+ Out.FlankUse = 0.7f;
+ Out.PreferredRangeM = 11.0f;
+ Out.StrafeMs = FVector2f(300.0f, 820.0f);
+ Out.LeanUse = 0.9f;
+ Out.CrouchPeekUse = 0.7f;
+ Out.ProneUse = 0.15f;
+ Out.SlideUse = 0.45f;
+ Out.NavLinkCostMul = 1.0f;
+ Out.SoundDiscipline = 0.85f;
+ Out.PeekRepeatPenalty = 0.7f;
+ Out.BulwarkUse = 0.8f;
+ Out.BreachUse = 0.7f;
+ Out.WallbangUse = 0.8f;
+ Out.WallbangMinBelief = 0.3f;
+ Out.WallbangMaxSourceAgeS = 3.5f;
+ Out.WallbangMinDamageFrac = 0.3f;
+ Out.PrefireChance = 0.6f;
+ Out.StalkUse = 0.6f;
+ Out.MaxStalkS = 8.0f;
+ Out.FinisherCommitConfidence = 0.6f;
+ Out.KnifeChoice = 0.5f;
+ Out.TacticalReloadAtFrac = 0.45f;
+ Out.ReloadOnlyWhenSafe = 0.9f;
+ Out.PistolSwitchChance = 0.85f;
+ Out.LearnWeightMax = 0.35f;
+ Out.LearnSamplesHalf = 6.0f;
+ Out.HabitHalfLifeS = 420.0f;
+ Out.ExplorationRate = 0.1f;
+ }
+ else
+ {
+ return false;
+ }
+ Out.TierId = InTierId;
+ return true;
+}
+
+bool UVerseBotTier::SatisfiesContractBounds() const
+{
+ return WallbangMinBelief >= WallbangMinBeliefFloor
+ && WallbangMaxSourceAgeS <= WallbangMaxSourceAgeCapS
+ && LearnWeightMax <= LearnWeightMaxCap;
+}
+
+void UVerseBotTier::ClampToContract()
+{
+ WallbangMinBelief = FMath::Max(WallbangMinBelief, WallbangMinBeliefFloor);
+ WallbangMaxSourceAgeS = FMath::Min(WallbangMaxSourceAgeS, WallbangMaxSourceAgeCapS);
+ LearnWeightMax = FMath::Min(LearnWeightMax, LearnWeightMaxCap);
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Combat/VerseWeaponDefinition.cpp b/unreal/Verse/Source/VerseCore/Private/Combat/VerseWeaponDefinition.cpp
new file mode 100644
index 0000000000..3b302b54cf
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Combat/VerseWeaponDefinition.cpp
@@ -0,0 +1,32 @@
+#include "Combat/VerseWeaponDefinition.h"
+
+namespace
+{
+ float EvalCurve(const FRuntimeFloatCurve& Curve, float X)
+ {
+ const FRichCurve* Rich = Curve.GetRichCurveConst();
+ return (Rich && Rich->GetNumKeys() > 0) ? Rich->Eval(X) : 0.f;
+ }
+}
+
+FVector2f UVerseWeaponDefinition::PatternAt(int32 ShotIndex) const
+{
+ const float X = float(FMath::Max(0, ShotIndex));
+ return FVector2f(EvalCurve(RecoilPitchCurve, X), EvalCurve(RecoilYawCurve, X));
+}
+
+bool UVerseWeaponDefinition::SatisfiesRecoveryBelowKick(float MinMultiplier, int32 MaxShot) const
+{
+ if (RPM <= 0.f || MaxShot < 1)
+ {
+ return false;
+ }
+ float KMinPitch = TNumericLimits<float>::Max();
+ for (int32 N = 1; N <= MaxShot; ++N)
+ {
+ const FVector2f P = PatternAt(N);
+ KMinPitch = FMath::Min(KMinPitch, MinMultiplier * (P.X - RecoilRandomFraction * P.Size()));
+ }
+ const float RecoveryBetweenShots = RecoilRecoveryRate * FMath::Max(0.f, FireInterval() - RecoilRecoveryDelay);
+ return RecoveryBetweenShots <= 0.5f * KMinPitch;
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Destruction/VerseDestructionTuning.cpp b/unreal/Verse/Source/VerseCore/Private/Destruction/VerseDestructionTuning.cpp
new file mode 100644
index 0000000000..11a7d75061
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Destruction/VerseDestructionTuning.cpp
@@ -0,0 +1,39 @@
+#include "Destruction/VerseDestructionTuning.h"
+
+namespace
+{
+ FVersePieceClassTuning MakeClass(EVersePenetrationMaterial Material, float MaxHp, bool bDamagedOnFirstHit,
+ float HoledAt, bool bBreached, bool bDestroyedAtZero, bool bDestroyedByCharge, bool bMeleeGlass, float RepairS)
+ {
+ FVersePieceClassTuning Row;
+ Row.Material = Material;
+ Row.MaxHp = MaxHp;
+ Row.bDamagedOnFirstHit = bDamagedOnFirstHit;
+ Row.HoledAtOrBelowHp = HoledAt;
+ Row.bBreachedByCharge = bBreached;
+ Row.bDestroyedAtZeroHp = bDestroyedAtZero;
+ Row.bDestroyedByCharge = bDestroyedByCharge;
+ Row.bDestroyedByMeleeWhenDamaged = bMeleeGlass;
+ Row.RepairTimeS = RepairS;
+ return Row;
+ }
+}
+
+UVerseDestructionTuning::UVerseDestructionTuning()
+{
+ Classes = MakeContractClasses();
+}
+
+TMap<EVersePieceClass, FVersePieceClassTuning> UVerseDestructionTuning::MakeContractClasses()
+{
+ using C = EVersePieceClass;
+ using M = EVersePenetrationMaterial;
+ TMap<C, FVersePieceClassTuning> Out;
+ Out.Add(C::WallPanel, MakeClass(M::SheetMetal, 200.f, true, 100.f, true, false, false, false, 8.f));
+ Out.Add(C::CladdingWall, MakeClass(M::CladdingPanel, 250.f, true, 125.f, true, false, false, false, 8.f));
+ Out.Add(C::ContainerWall, MakeClass(M::ContainerWall, 300.f, true, 150.f, true, false, false, false, 8.f));
+ Out.Add(C::GlassPane, MakeClass(M::Glass, 20.f, true, -1.f, false, true, true, true, 4.f));
+ Out.Add(C::CatwalkSegment, MakeClass(M::CatwalkGrating, 0.f, false, -1.f, false, false, true, false, 10.f));
+ Out.Add(C::CeilingPanel, MakeClass(M::CeilingPanel, 60.f, true, -1.f, false, true, true, false, 5.f));
+ return Out;
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Destruction/VerseDestructionTypes.cpp b/unreal/Verse/Source/VerseCore/Private/Destruction/VerseDestructionTypes.cpp
new file mode 100644
index 0000000000..0642a737b2
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Destruction/VerseDestructionTypes.cpp
@@ -0,0 +1,110 @@
+#include "Destruction/VerseDestructionTypes.h"
+
+namespace Verse::Destruction
+{
+ float FractureLoudness(EVerseFractureNoise Kind)
+ {
+ switch (Kind)
+ {
+ case EVerseFractureNoise::Breach:
+ return 1.0f;
+ case EVerseFractureNoise::WallBreak:
+ return 0.7f;
+ case EVerseFractureNoise::Glass:
+ return 0.6f;
+ case EVerseFractureNoise::Tile:
+ return 0.5f;
+ case EVerseFractureNoise::BoltHole:
+ return 0.2f;
+ }
+ return 1.0f;
+ }
+
+ uint8 QuantizeHealth(float Hp, float MaxHp)
+ {
+ if (MaxHp <= 0.f)
+ {
+ return 0;
+ }
+ return uint8(FMath::Clamp(FMath::RoundToInt(255.f * Hp / MaxHp), 0, 255));
+ }
+
+ void EncodeOctahedral(const FVector& Direction, int8& OutX, int8& OutY)
+ {
+ const FVector N = Direction.GetSafeNormal(UE_DOUBLE_SMALL_NUMBER, FVector::ForwardVector);
+ const double L1 = FMath::Abs(N.X) + FMath::Abs(N.Y) + FMath::Abs(N.Z);
+ double X = N.X / L1;
+ double Y = N.Y / L1;
+ if (N.Z < 0.0)
+ {
+ const double OX = (1.0 - FMath::Abs(Y)) * (X >= 0.0 ? 1.0 : -1.0);
+ const double OY = (1.0 - FMath::Abs(X)) * (Y >= 0.0 ? 1.0 : -1.0);
+ X = OX;
+ Y = OY;
+ }
+ OutX = int8(FMath::Clamp(FMath::RoundToInt(X * 127.0), -127, 127));
+ OutY = int8(FMath::Clamp(FMath::RoundToInt(Y * 127.0), -127, 127));
+ }
+
+ FVector DecodeOctahedral(int8 QX, int8 QY)
+ {
+ double X = double(QX) / 127.0;
+ double Y = double(QY) / 127.0;
+ const double Z = 1.0 - FMath::Abs(X) - FMath::Abs(Y);
+ if (Z < 0.0)
+ {
+ const double OX = (1.0 - FMath::Abs(Y)) * (X >= 0.0 ? 1.0 : -1.0);
+ const double OY = (1.0 - FMath::Abs(X)) * (Y >= 0.0 ? 1.0 : -1.0);
+ X = OX;
+ Y = OY;
+ }
+ return FVector(X, Y, Z).GetSafeNormal(UE_DOUBLE_SMALL_NUMBER, FVector::ForwardVector);
+ }
+}
+
+FVector FVerseBoltHole::GetAxisPointCm() const
+{
+ return FVector(AxisPositionMm[0], AxisPositionMm[1], AxisPositionMm[2]) / 10.0;
+}
+
+FVector FVerseBoltHole::GetAxisDirection() const
+{
+ return Verse::Destruction::DecodeOctahedral(AxisDirectionOct[0], AxisDirectionOct[1]);
+}
+
+bool FVerseBoltHole::ContainsPoint(const FVector& PieceLocalCm) const
+{
+ const FVector Dir = GetAxisDirection();
+ const FVector Rel = PieceLocalCm - GetAxisPointCm();
+ const double DistSq = (Rel - Dir * FVector::DotProduct(Rel, Dir)).SizeSquared();
+ const double RadiusCm = double(RadiusMm) / 10.0;
+ return DistSq <= RadiusCm * RadiusCm;
+}
+
+FVerseBoltHole FVerseBoltHole::Make(uint16 InPieceIndex, const FVector& AxisPointCm, const FVector& AxisDirection,
+ uint8 InRadiusMm, uint32 InServerTimeMs, uint16 InEpoch)
+{
+ FVerseBoltHole Hole;
+ Hole.PieceIndex = InPieceIndex;
+ for (int32 Axis = 0; Axis < 3; ++Axis)
+ {
+ Hole.AxisPositionMm[Axis] = int16(FMath::Clamp(FMath::RoundToInt(AxisPointCm[Axis] * 10.0), -32768, 32767));
+ }
+ Verse::Destruction::EncodeOctahedral(AxisDirection, Hole.AxisDirectionOct[0], Hole.AxisDirectionOct[1]);
+ Hole.RadiusMm = InRadiusMm;
+ Hole.ServerTimeMs = InServerTimeMs;
+ Hole.Epoch = InEpoch;
+ return Hole;
+}
+
+bool FVerseBoltHole::RayPassesHoles(TConstArrayView<FVerseBoltHole> Holes, const FVector& EntryLocalCm, const FVector& ExitLocalCm)
+{
+ for (const FVerseBoltHole& Hole : Holes)
+ {
+ if (Hole.ContainsPoint(EntryLocalCm) && Hole.ContainsPoint(ExitLocalCm))
+ {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Destruction/VersePenetrationTable.cpp b/unreal/Verse/Source/VerseCore/Private/Destruction/VersePenetrationTable.cpp
new file mode 100644
index 0000000000..7eb8f30b21
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Destruction/VersePenetrationTable.cpp
@@ -0,0 +1,53 @@
+#include "Destruction/VersePenetrationTable.h"
+
+#include "VerseGameplayTags.h"
+
+namespace
+{
+ FVersePenetrationRow MakeRow(EVersePenetrationMaterial Id, float RefCm, float Cost, float Multiplier,
+ bool bBullets, bool bBreach, EVerseDebrisType Debris)
+ {
+ FVersePenetrationRow Row;
+ Row.MaterialTag = VerseTags::AllMaterialTags()[uint8(Id)];
+ Row.WireId = Id;
+ Row.RefThicknessCm = RefCm;
+ Row.PenetrationCost = Cost;
+ Row.DamageMultiplier = Multiplier;
+ Row.bBreakableByBullets = bBullets;
+ Row.bBreakableByBreach = bBreach;
+ Row.DebrisType = Debris;
+ return Row;
+ }
+}
+
+UVersePenetrationTable::UVersePenetrationTable()
+{
+ Rows = MakeContractRows();
+}
+
+TArray<FVersePenetrationRow> UVersePenetrationTable::MakeContractRows()
+{
+ using M = EVersePenetrationMaterial;
+ using D = EVerseDebrisType;
+ return {
+ MakeRow(M::SheetMetal, 0.3f, 15.f, 0.85f, true, true, D::MetalShards),
+ MakeRow(M::ContainerWall, 0.4f, 25.f, 0.75f, true, true, D::CorrugatedChunks),
+ MakeRow(M::Glass, 2.4f, 5.f, 0.95f, true, true, D::GlassShards),
+ MakeRow(M::CladdingPanel, 4.0f, 30.f, 0.70f, true, true, D::PanelChunks),
+ MakeRow(M::CatwalkGrating, 3.0f, 10.f, 0.90f, false, true, D::GratingTwisted),
+ MakeRow(M::CeilingPanel, 2.5f, 8.f, 0.90f, true, true, D::CeilingTile),
+ MakeRow(M::Concrete, 30.f, 400.f, 0.f, false, false, D::DustChips),
+ MakeRow(M::ArmorSteel, 2.5f, 10000.f, 0.f, false, false, D::SparksOnly),
+ };
+}
+
+const FVersePenetrationRow* UVersePenetrationTable::FindRow(uint8 WireId) const
+{
+ return Rows.IsValidIndex(WireId) ? &Rows[WireId] : nullptr;
+}
+
+float UVersePenetrationTable::PassCost(const FVersePenetrationRow& Row, float TracedThicknessCm)
+{
+ const float Ratio = Row.RefThicknessCm > 0.f ? TracedThicknessCm / Row.RefThicknessCm : 1.f;
+ return Row.PenetrationCost * FMath::Clamp(Ratio, 0.5f, 3.0f);
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Events/VerseEventHub.cpp b/unreal/Verse/Source/VerseCore/Private/Events/VerseEventHub.cpp
new file mode 100644
index 0000000000..633273550c
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Events/VerseEventHub.cpp
@@ -0,0 +1,31 @@
+#include "Events/VerseEventHub.h"
+
+#include "Engine/Engine.h"
+#include "Engine/World.h"
+
+UVerseEventHub* UVerseEventHub::Get(const UObject* WorldContextObject)
+{
+ if (!WorldContextObject || !GEngine)
+ {
+ return nullptr;
+ }
+ const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
+ return World ? World->GetSubsystem<UVerseEventHub>() : nullptr;
+}
+
+void UVerseEventHub::Deinitialize()
+{
+ OnFire.Clear();
+ OnHit.Clear();
+ OnPenetration.Clear();
+ OnDeath.Clear();
+ OnFinisher.Clear();
+ OnNoise.Clear();
+ OnReload.Clear();
+ OnGadget.Clear();
+ OnFracture.Clear();
+ OnArenaSwitch.Clear();
+ OnSetEnded.Clear();
+ OnStationUsed.Clear();
+ Super::Deinitialize();
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Noise/VerseAudibilityTable.cpp b/unreal/Verse/Source/VerseCore/Private/Noise/VerseAudibilityTable.cpp
new file mode 100644
index 0000000000..1d12a77836
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Noise/VerseAudibilityTable.cpp
@@ -0,0 +1,69 @@
+#include "Noise/VerseAudibilityTable.h"
+
+#include "Destruction/VerseDestructionTypes.h"
+#include "VerseGameplayTags.h"
+
+namespace
+{
+ FVerseAudibilityRow MakeRow(const FGameplayTag& Noise, float RangeM, float ErrorMultiplier,
+ bool bWholeArena = false, bool bScales = false)
+ {
+ FVerseAudibilityRow Row;
+ Row.Noise = Noise;
+ Row.RangeM = RangeM;
+ Row.ErrorMultiplier = ErrorMultiplier;
+ Row.bWholeArena = bWholeArena;
+ Row.bRangeScalesWithLoudness = bScales;
+ return Row;
+ }
+}
+
+UVerseAudibilityTable::UVerseAudibilityTable()
+{
+ Rows = MakeContractRows();
+}
+
+TArray<FVerseAudibilityRow> UVerseAudibilityTable::MakeContractRows()
+{
+ using namespace VerseTags;
+ const float FractureRange = Verse::Destruction::FractureRangePerLoudnessM;
+ return {
+ MakeRow(Noise_Shot, 0.f, 1.0f, true),
+ MakeRow(Noise_Footstep_Sprint, 20.f, 1.3f),
+ MakeRow(Noise_Footstep_Run, 10.f, 1.3f),
+ MakeRow(Noise_Footstep_Walk, 4.f, 1.5f),
+ MakeRow(Noise_Move_Slide, 12.f, 1.2f),
+ MakeRow(Noise_Move_Land, 12.f, 1.2f),
+ MakeRow(Noise_Move_Mantle, 12.f, 1.2f),
+ MakeRow(Noise_Reload, 7.f, 1.0f),
+ MakeRow(Noise_Gadget_BulwarkDeploy, 15.f, 1.0f),
+ MakeRow(Noise_Gadget_BulwarkHum, 5.f, 1.0f),
+ MakeRow(Noise_Gadget_BreachPlant, 10.f, 1.0f),
+ MakeRow(Noise_Gadget_BreachDetonate, 0.f, 0.5f, true),
+ MakeRow(Noise_Fracture, FractureRange, 1.0f, false, true),
+ MakeRow(Noise_Drone, FractureRange, 1.0f, false, true),
+ MakeRow(Noise_Melee, 8.f, 1.0f),
+ MakeRow(Noise_Finisher, 8.f, 1.0f),
+ // Bolt impact within 3 m of the listener: always heard, at the impact point.
+ MakeRow(Noise_Impact, 3.f, 0.0f),
+ };
+}
+
+const FVerseAudibilityRow* UVerseAudibilityTable::FindRow(const FGameplayTag& Noise) const
+{
+ return Rows.FindByPredicate([&Noise](const FVerseAudibilityRow& Row) { return Row.Noise == Noise; });
+}
+
+float UVerseAudibilityTable::GetAudibleRangeM(const FGameplayTag& Noise, float Loudness) const
+{
+ const FVerseAudibilityRow* Row = FindRow(Noise);
+ if (!Row)
+ {
+ return 0.f;
+ }
+ if (Row->bWholeArena)
+ {
+ return WholeArenaRangeM;
+ }
+ return Row->bRangeScalesWithLoudness ? Row->RangeM * FMath::Max(0.f, Loudness) : Row->RangeM;
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Qa/VerseQaRegistry.cpp b/unreal/Verse/Source/VerseCore/Private/Qa/VerseQaRegistry.cpp
new file mode 100644
index 0000000000..262b314aa6
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Qa/VerseQaRegistry.cpp
@@ -0,0 +1,189 @@
+#include "Qa/VerseQaRegistry.h"
+
+#include "Engine/Engine.h"
+#include "HAL/IConsoleManager.h"
+#include "Misc/OutputDevice.h"
+#include "VerseLog.h"
+
+namespace
+{
+ FString ErrorJson(const FString& Message)
+ {
+ FString Escaped;
+ for (const TCHAR Ch : Message)
+ {
+ if (Ch == TEXT('"') || Ch == TEXT('\\'))
+ {
+ Escaped.AppendChar(TEXT('\\'));
+ Escaped.AppendChar(Ch);
+ }
+ else if (Ch >= 0x20)
+ {
+ Escaped.AppendChar(Ch);
+ }
+ }
+ return FString::Printf(TEXT("{\"error\": \"%s\"}"), *Escaped);
+ }
+}
+
+TConstArrayView<FString> UVerseQaRegistry::KnownCommands()
+{
+ static const TArray<FString> Names = {
+ TEXT("Verse.QA.Stats"),
+ TEXT("Verse.QA.Dump"),
+ TEXT("Verse.QA.SetDuty"),
+ TEXT("Verse.QA.Duel.Start"),
+ TEXT("Verse.QA.Duel.Leave"),
+ TEXT("Verse.QA.Duel.Place"),
+ TEXT("Verse.QA.Duel.Look"),
+ TEXT("Verse.QA.Duel.Hold"),
+ TEXT("Verse.QA.Duel.Press"),
+ TEXT("Verse.QA.Duel.State"),
+ TEXT("Verse.QA.Duel.Bodies"),
+ TEXT("Verse.QA.View.Set"),
+ TEXT("Verse.QA.View.Look"),
+ TEXT("Verse.QA.View.Zoom"),
+ TEXT("Verse.QA.View.State"),
+ TEXT("Verse.QA.Tune"),
+ TEXT("Verse.QA.Materials"),
+ TEXT("Verse.QA.Space.Set"),
+ TEXT("Verse.QA.Space.State"),
+ TEXT("Verse.QA.Viewmodel"),
+ };
+ return Names;
+}
+
+UVerseQaRegistry* UVerseQaRegistry::Get()
+{
+ return GEngine ? GEngine->GetEngineSubsystem<UVerseQaRegistry>() : nullptr;
+}
+
+bool UVerseQaRegistry::Register(const FString& Command, const FString& Help, FVerseQaHandler Handler)
+{
+ if (!Command.StartsWith(CommandPrefix(), ESearchCase::CaseSensitive) || Command.Len() <= FCString::Strlen(CommandPrefix()))
+ {
+ UE_LOG(LogVerseQa, Error, TEXT("QA command '%s' refused: names start with %s"), *Command, CommandPrefix());
+ return false;
+ }
+ if (!Handler)
+ {
+ UE_LOG(LogVerseQa, Error, TEXT("QA command '%s' refused: no handler"), *Command);
+ return false;
+ }
+ if (Commands.Contains(Command))
+ {
+ UE_LOG(LogVerseQa, Error, TEXT("QA command '%s' refused: already registered"), *Command);
+ return false;
+ }
+
+ FEntry& Entry = Commands.Add(Command);
+ Entry.Help = Help;
+ Entry.Handler = MoveTemp(Handler);
+
+#if !UE_BUILD_SHIPPING
+ const FString Name = Command;
+ Entry.ConsoleObject = IConsoleManager::Get().RegisterConsoleCommand(
+ *Command, *Help,
+ FConsoleCommandWithWorldArgsAndOutputDeviceDelegate::CreateWeakLambda(this,
+ [this, Name](const TArray<FString>& Args, UWorld*, FOutputDevice& Ar)
+ {
+ FString Result;
+ Execute(Name, Args, Result);
+ Ar.Log(Result);
+ }),
+ ECVF_Default);
+#endif
+ return true;
+}
+
+bool UVerseQaRegistry::Unregister(const FString& Command)
+{
+ FEntry Entry;
+ if (!Commands.RemoveAndCopyValue(Command, Entry))
+ {
+ return false;
+ }
+ if (Entry.ConsoleObject)
+ {
+ IConsoleManager::Get().UnregisterConsoleObject(Entry.ConsoleObject, false);
+ }
+ return true;
+}
+
+bool UVerseQaRegistry::IsRegistered(const FString& Command) const
+{
+ return Commands.Contains(Command);
+}
+
+TArray<FString> UVerseQaRegistry::GetRegisteredCommands() const
+{
+ TArray<FString> Names;
+ Commands.GetKeys(Names);
+ Names.Sort();
+ return Names;
+}
+
+bool UVerseQaRegistry::Execute(const FString& Command, const TArray<FString>& Args, FString& OutResult) const
+{
+ const FEntry* Entry = Commands.Find(Command);
+ if (!Entry)
+ {
+ OutResult = ErrorJson(FString::Printf(TEXT("unknown command %s"), *Command));
+ return false;
+ }
+ OutResult = Entry->Handler(Args);
+ return true;
+}
+
+bool UVerseQaRegistry::ExecuteLine(const FString& Line, FString& OutResult) const
+{
+ TArray<FString> Tokens;
+ FString Current;
+ bool bInQuotes = false;
+ bool bHasToken = false;
+ for (const TCHAR Ch : Line)
+ {
+ if (Ch == TEXT('"'))
+ {
+ bInQuotes = !bInQuotes;
+ bHasToken = true;
+ }
+ else if (!bInQuotes && FChar::IsWhitespace(Ch))
+ {
+ if (bHasToken)
+ {
+ Tokens.Add(MoveTemp(Current));
+ Current.Reset();
+ bHasToken = false;
+ }
+ }
+ else
+ {
+ Current.AppendChar(Ch);
+ bHasToken = true;
+ }
+ }
+ if (bHasToken)
+ {
+ Tokens.Add(MoveTemp(Current));
+ }
+ if (Tokens.IsEmpty())
+ {
+ OutResult = ErrorJson(TEXT("empty command"));
+ return false;
+ }
+ const FString Command = Tokens[0];
+ Tokens.RemoveAt(0);
+ return Execute(Command, Tokens, OutResult);
+}
+
+void UVerseQaRegistry::Deinitialize()
+{
+ TArray<FString> Names;
+ Commands.GetKeys(Names);
+ for (const FString& Name : Names)
+ {
+ Unregister(Name);
+ }
+ Super::Deinitialize();
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Stubs/VerseNullStubs.cpp b/unreal/Verse/Source/VerseCore/Private/Stubs/VerseNullStubs.cpp
new file mode 100644
index 0000000000..70a58ec1d9
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Stubs/VerseNullStubs.cpp
@@ -0,0 +1,60 @@
+#include "Stubs/VerseNullStubs.h"
+
+TArray<FVersePenetrationHit> UVerseNullPenetrationQuery::TraceBolt(const FVector&, const FVector&, float, float, float, uint8, int32) const
+{
+ return {};
+}
+
+bool UVerseNullPenetrationQuery::TestSight(const FVector&, const FVector&) const
+{
+ return true;
+}
+
+void UVerseNullPieceDamage::ApplyPieceDamage(const FVersePieceDamage&)
+{
+}
+
+EVersePieceState UVerseNullPieceQuery::GetPieceState(uint16) const
+{
+ return EVersePieceState::Intact;
+}
+
+EVersePenetrationMaterial UVerseNullPieceQuery::GetPieceMaterial(uint16) const
+{
+ return EVersePenetrationMaterial::Concrete;
+}
+
+FBox UVerseNullPieceQuery::GetPieceBounds(uint16) const
+{
+ return FBox(ForceInit);
+}
+
+TArray<uint16> UVerseNullPieceQuery::GetPiecesInBox(const FBox&) const
+{
+ return {};
+}
+
+EVerseStance UVerseNullMovementQuery::GetStance() const
+{
+ return EVerseStance::Stand;
+}
+
+bool UVerseNullMovementQuery::IsSprinting() const
+{
+ return false;
+}
+
+bool UVerseNullMovementQuery::IsAirborne() const
+{
+ return false;
+}
+
+bool UVerseNullMovementQuery::IsMantling() const
+{
+ return false;
+}
+
+int8 UVerseNullMovementQuery::GetLeanQuantized() const
+{
+ return 0;
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/Tests/VerseCoordsTest.cpp b/unreal/Verse/Source/VerseCore/Private/Tests/VerseCoordsTest.cpp
new file mode 100644
index 0000000000..52f5909ab7
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Tests/VerseCoordsTest.cpp
@@ -0,0 +1,512 @@
+#include "Dom/JsonObject.h"
+#include "Misc/AutomationTest.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Serialization/JsonReader.h"
+#include "Serialization/JsonSerializer.h"
+#include "VerseCoords.h"
+#include "VerseRng.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+// Verse.Contract.Coords.*: the required tests of contracts/coordinates.md section 5 (1 to 13;
+// 14 is a CI script). Tolerances: positions 1e-6 cm, directions and quaternion components
+// 1e-12, angles 1e-9 deg.
+
+#define VERSE_COORDS_TEST_FLAGS (EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter)
+
+namespace VerseCoordsTest
+{
+ using namespace Verse::Coords;
+
+ constexpr double PosTol = 1e-6;
+ constexpr double DirTol = 1e-12;
+ constexpr double AngTol = 1e-9;
+ constexpr uint64 Seed = 0x5645525345ull;
+
+ FVerseThreeVector T(double X, double Y, double Z) { return FVerseThreeVector(X, Y, Z); }
+
+ FVector MOf(const FVerseThreeVector& V) { return FVector(V.X, V.Z, V.Y); }
+
+ FVerseThreeVector Cross(const FVerseThreeVector& A, const FVerseThreeVector& B)
+ {
+ return T(A.Y * B.Z - A.Z * B.Y, A.Z * B.X - A.X * B.Z, A.X * B.Y - A.Y * B.X);
+ }
+
+ FVerseThreeVector DirFromAngles(double Yaw, double Pitch)
+ {
+ const double C = FMath::Cos(Pitch);
+ return T(FMath::Sin(Yaw) * C, FMath::Sin(Pitch), FMath::Cos(Yaw) * C);
+ }
+
+ bool Near(FAutomationTestBase& Test, const FString& What, const FVector& Actual, const FVector& Expected, double Tol)
+ {
+ const bool bOk = FMath::Abs(Actual.X - Expected.X) <= Tol && FMath::Abs(Actual.Y - Expected.Y) <= Tol
+ && FMath::Abs(Actual.Z - Expected.Z) <= Tol;
+ if (!bOk)
+ {
+ Test.AddError(FString::Printf(TEXT("%s: got (%.15g, %.15g, %.15g), expected (%.15g, %.15g, %.15g)"), *What,
+ Actual.X, Actual.Y, Actual.Z, Expected.X, Expected.Y, Expected.Z));
+ }
+ return bOk;
+ }
+
+ bool Near(FAutomationTestBase& Test, const FString& What, const FVerseThreeVector& Actual, const FVerseThreeVector& Expected, double Tol)
+ {
+ return Near(Test, What, FVector(Actual.X, Actual.Y, Actual.Z), FVector(Expected.X, Expected.Y, Expected.Z), Tol);
+ }
+
+ bool Near(FAutomationTestBase& Test, const FString& What, double Actual, double Expected, double Tol)
+ {
+ if (FMath::Abs(Actual - Expected) > Tol)
+ {
+ Test.AddError(FString::Printf(TEXT("%s: got %.17g, expected %.17g"), *What, Actual, Expected));
+ return false;
+ }
+ return true;
+ }
+
+ /** Angles compared on the circle, so 180 and -180 + epsilon agree. */
+ bool NearAngle(FAutomationTestBase& Test, const FString& What, double ActualDeg, double ExpectedDeg, double Tol)
+ {
+ const double Delta = FMath::FindDeltaAngleDegrees(ExpectedDeg, ActualDeg);
+ if (FMath::Abs(Delta) > Tol)
+ {
+ Test.AddError(FString::Printf(TEXT("%s: got %.17g deg, expected %.17g deg"), *What, ActualDeg, ExpectedDeg));
+ return false;
+ }
+ return true;
+ }
+
+ bool NearQuat(FAutomationTestBase& Test, const FString& What, const FQuat& A, const FQuat& B, double Tol)
+ {
+ if (FMath::Abs(A.X - B.X) > Tol || FMath::Abs(A.Y - B.Y) > Tol || FMath::Abs(A.Z - B.Z) > Tol || FMath::Abs(A.W - B.W) > Tol)
+ {
+ Test.AddError(FString::Printf(TEXT("%s: got (%.15g, %.15g, %.15g, %.15g), expected (%.15g, %.15g, %.15g, %.15g)"), *What,
+ A.X, A.Y, A.Z, A.W, B.X, B.Y, B.Z, B.W));
+ return false;
+ }
+ return true;
+ }
+
+ FVerseThreeVector RandomThree(FVerseRng& Rng, double Extent)
+ {
+ return T(Rng.Range(-Extent, Extent), Rng.Range(-Extent, Extent), Rng.Range(-Extent, Extent));
+ }
+
+ FQuat RandomUnitQuat(FVerseRng& Rng)
+ {
+ FQuat Q(Rng.Gaussian(), Rng.Gaussian(), Rng.Gaussian(), Rng.Gaussian());
+ Q.Normalize();
+ return Q;
+ }
+
+ TSharedPtr<FJsonObject> LoadGolden(FAutomationTestBase& Test)
+ {
+ const FString Path = FPaths::Combine(FPaths::ProjectDir(), TEXT("Tests/Data/coords_golden.json"));
+ FString Text;
+ if (!FFileHelper::LoadFileToString(Text, *Path))
+ {
+ Test.AddError(FString::Printf(TEXT("cannot read %s"), *Path));
+ return nullptr;
+ }
+ TSharedPtr<FJsonObject> Root;
+ const TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Text);
+ if (!FJsonSerializer::Deserialize(Reader, Root) || !Root.IsValid())
+ {
+ Test.AddError(FString::Printf(TEXT("cannot parse %s"), *Path));
+ return nullptr;
+ }
+ Test.TestEqual(TEXT("golden schema"), Root->GetStringField(TEXT("schema")), FString(TEXT("verse.coords_golden/1")));
+ return Root;
+ }
+
+ TArray<double> Numbers(const TSharedPtr<FJsonObject>& Object, const TCHAR* Field)
+ {
+ TArray<double> Out;
+ const TArray<TSharedPtr<FJsonValue>>* Values = nullptr;
+ if (Object->TryGetArrayField(Field, Values))
+ {
+ for (const TSharedPtr<FJsonValue>& Value : *Values)
+ {
+ Out.Add(Value->AsNumber());
+ }
+ }
+ return Out;
+ }
+
+ FVector Vec(const TSharedPtr<FJsonObject>& Object, const TCHAR* Field)
+ {
+ const TArray<double> N = Numbers(Object, Field);
+ return N.Num() == 3 ? FVector(N[0], N[1], N[2]) : FVector(TNumericLimits<double>::Max());
+ }
+
+ FVerseThreeVector Three(const TSharedPtr<FJsonObject>& Object, const TCHAR* Field)
+ {
+ const FVector V = Vec(Object, Field);
+ return T(V.X, V.Y, V.Z);
+ }
+
+ TArray<TSharedPtr<FJsonObject>> Rows(const TSharedPtr<FJsonObject>& Root, const TCHAR* Field)
+ {
+ TArray<TSharedPtr<FJsonObject>> Out;
+ const TArray<TSharedPtr<FJsonValue>>* Values = nullptr;
+ if (Root.IsValid() && Root->TryGetArrayField(Field, Values))
+ {
+ for (const TSharedPtr<FJsonValue>& Value : *Values)
+ {
+ Out.Add(Value->AsObject());
+ }
+ }
+ return Out;
+ }
+
+ /** Positions of the given table ("3.1", "3.2"), or every row when Table is empty. Returns the row count. */
+ int32 CheckPositions(FAutomationTestBase& Test, const TSharedPtr<FJsonObject>& Root, const FString& Table)
+ {
+ int32 Count = 0;
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("positions")))
+ {
+ if (!Table.IsEmpty() && Row->GetStringField(TEXT("table")) != Table)
+ {
+ continue;
+ }
+ const FString Name = Row->GetStringField(TEXT("name"));
+ FVerseDeckFrame Deck;
+ Deck.OriginCm = Vec(Row, TEXT("deck_origin_cm"));
+ const FVerseThreeVector In = Three(Row, TEXT("three"));
+ const FVector Expected = Vec(Row, TEXT("unreal"));
+ Near(Test, Name + TEXT(" T->U"), ToUnrealPosition(In, Deck), Expected, PosTol);
+ Near(Test, Name + TEXT(" U->T"), ToThreePosition(Expected, Deck), In, PosTol / 100.0);
+ ++Count;
+ }
+ return Count;
+ }
+}
+
+using namespace VerseCoordsTest;
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsBasisTest, "Verse.Contract.Coords.Basis", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsBasisTest::RunTest(const FString&)
+{
+ Near(*this, TEXT("T +X"), ToUnrealPosition(T(1, 0, 0)), FVector(100, 0, 0), PosTol);
+ Near(*this, TEXT("T +Y"), ToUnrealPosition(T(0, 1, 0)), FVector(0, 0, 100), PosTol);
+ Near(*this, TEXT("T +Z"), ToUnrealPosition(T(0, 0, 1)), FVector(0, 100, 0), PosTol);
+ Near(*this, TEXT("MetresToCm"), MetresToCm(1.0), 100.0, PosTol);
+ Near(*this, TEXT("CmToMetres"), CmToMetres(250.0), 2.5, PosTol);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsHandednessTest, "Verse.Contract.Coords.Handedness", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsHandednessTest::RunTest(const FString&)
+{
+ // det(M) with M's columns the images of the T basis.
+ const FMatrix M(ToUnrealDirection(T(1, 0, 0)), ToUnrealDirection(T(0, 1, 0)), ToUnrealDirection(T(0, 0, 1)), FVector::ZeroVector);
+ Near(*this, TEXT("det(M)"), M.Determinant(), -1.0, DirTol);
+
+ FVerseRng Rng(Seed, 0, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 1000; ++I)
+ {
+ const FVerseThreeVector A = RandomThree(Rng, 10.0);
+ const FVerseThreeVector B = RandomThree(Rng, 10.0);
+ const FVector Lhs = ToUnrealDirection(Cross(A, B));
+ const FVector Rhs = -FVector::CrossProduct(ToUnrealDirection(A), ToUnrealDirection(B));
+ if (!Near(*this, FString::Printf(TEXT("cross pair %d"), I), Lhs, Rhs, 1e-12 * 100.0))
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsRoundTripTest, "Verse.Contract.Coords.RoundTripPosition", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsRoundTripTest::RunTest(const FString&)
+{
+ FVerseRng Rng(Seed, 1, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 10000; ++I)
+ {
+ FVerseDeckFrame Deck;
+ Deck.OriginCm = FVector(Rng.Range(-1e6, 1e6), Rng.Range(-1e6, 1e6), Rng.Range(-1e5, 1e5));
+ const FVerseThreeVector P = RandomThree(Rng, 10000.0); // +-10 km
+ const FVector U = ToUnrealPosition(P, Deck);
+ const FVector UBack = ToUnrealPosition(ToThreePosition(U, Deck), Deck);
+ const bool bOk = Near(*this, FString::Printf(TEXT("T->U->T %d"), I), ToThreePosition(U, Deck), P, PosTol / 100.0)
+ && Near(*this, FString::Printf(TEXT("U->T->U %d"), I), UBack, U, PosTol);
+ if (!bOk)
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsHangarGoldenTest, "Verse.Contract.Coords.HangarGolden", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsHangarGoldenTest::RunTest(const FString&)
+{
+ const TSharedPtr<FJsonObject> Root = LoadGolden(*this);
+ if (!Root)
+ {
+ return false;
+ }
+ TestEqual(TEXT("table 3.1 rows"), CheckPositions(*this, Root, TEXT("3.1")), 13);
+ TestEqual(TEXT("table 3.2 rows"), CheckPositions(*this, Root, TEXT("3.2")), 4);
+
+ int32 Spawns = 0;
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("headings")))
+ {
+ if (Row->GetStringField(TEXT("table")) != TEXT("3.2"))
+ {
+ continue;
+ }
+ const FString Name = Row->GetStringField(TEXT("name"));
+ const double YawDeg = Row->GetNumberField(TEXT("three_yaw_deg"));
+ Near(*this, Name + TEXT(" heading"), ToUnrealHeadingDegFromDeg(YawDeg), Row->GetNumberField(TEXT("unreal_heading_deg")), AngTol);
+ Near(*this, Name + TEXT(" mesh yaw"), UVerseCoordsLibrary::ThreeYawDegToUnrealMeshYaw(YawDeg), Row->GetNumberField(TEXT("unreal_mesh_yaw_deg")), AngTol);
+ ++Spawns;
+ }
+ TestEqual(TEXT("table 3.2 spawn headings"), Spawns, 3);
+
+ // The commander spawn as a manifest socket, both uses.
+ const FTransform Heading = ToUnrealSocketTransform(T(70, 0, 54.2), 0.0, ESocketUse::Heading);
+ const FTransform Mesh = ToUnrealSocketTransform(T(70, 0, 54.2), 0.0, ESocketUse::Mesh);
+ Near(*this, TEXT("socket location"), Heading.GetLocation(), FVector(7000, 5420, 0), PosTol);
+ NearAngle(*this, TEXT("socket heading yaw"), Heading.Rotator().Yaw, 90.0, AngTol);
+ NearAngle(*this, TEXT("socket mesh yaw"), Mesh.Rotator().Yaw, 0.0, AngTol);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsHeadingDirTest, "Verse.Contract.Coords.HeadingMatchesDirFromAngles", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsHeadingDirTest::RunTest(const FString&)
+{
+ FVerseRng Rng(Seed, 2, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 10000; ++I)
+ {
+ const double Yaw = Rng.Range(-UE_DOUBLE_PI, UE_DOUBLE_PI);
+ const double Pitch = Rng.Range(-0.49 * UE_DOUBLE_PI, 0.49 * UE_DOUBLE_PI);
+ if (!Near(*this, FString::Printf(TEXT("view %d"), I), ToUnrealViewRotation(Yaw, Pitch).Vector(),
+ ToUnrealDirection(DirFromAngles(Yaw, Pitch)), DirTol))
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsRightAxisTest, "Verse.Contract.Coords.RightAxisParity", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsRightAxisTest::RunTest(const FString&)
+{
+ FVerseRng Rng(Seed, 3, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 10000; ++I)
+ {
+ const double Yaw = Rng.Range(-UE_DOUBLE_PI, UE_DOUBLE_PI);
+ const FVector Right = ToUnrealDirection(T(-FMath::Cos(Yaw), 0.0, FMath::Sin(Yaw)));
+ const double HeadingRad = FMath::DegreesToRadians(ToUnrealHeadingDeg(Yaw));
+ // The pawn's right axis of yaw phi is (-sin phi, cos phi, 0), exact in double.
+ const FVector Exact(-FMath::Sin(HeadingRad), FMath::Cos(HeadingRad), 0.0);
+ // FRotationMatrix evaluates its sines in single precision, so it agrees to 1e-6 only.
+ const FVector Engine = FRotationMatrix(FRotator(0.0, ToUnrealHeadingDeg(Yaw), 0.0)).GetUnitAxis(EAxis::Y);
+ const bool bOk = Near(*this, FString::Printf(TEXT("right %d"), I), Right, Exact, DirTol)
+ && Near(*this, FString::Printf(TEXT("engine right axis %d"), I), Right, Engine, 1e-6);
+ if (!bOk)
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsYawWrapTest, "Verse.Contract.Coords.YawWrap", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsYawWrapTest::RunTest(const FString&)
+{
+ Near(*this, TEXT("psi -90 -> 180"), ToUnrealHeadingDeg(-UE_DOUBLE_HALF_PI), 180.0, AngTol);
+ Near(*this, TEXT("psi 180 -> -90"), ToUnrealHeadingDeg(UE_DOUBLE_PI), -90.0, AngTol);
+ Near(*this, TEXT("WrapPi(-pi) = pi"), WrapPi(-UE_DOUBLE_PI), UE_DOUBLE_PI, DirTol);
+ Near(*this, TEXT("Normalize(-180) = 180"), NormalizeDeg(-180.0), 180.0, AngTol);
+
+ FVerseRng Rng(Seed, 4, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 10000; ++I)
+ {
+ const double Yaw = Rng.Range(-20.0, 20.0);
+ const double Heading = ToUnrealHeadingDeg(Yaw);
+ const double Back = ToThreeYawRad(Rng.Range(-1000.0, 1000.0));
+ const bool bOk = TestTrue(TEXT("heading in (-180, 180]"), Heading > -180.0 && Heading <= 180.0)
+ && TestTrue(TEXT("three yaw in (-pi, pi]"), Back > -UE_DOUBLE_PI && Back <= UE_DOUBLE_PI)
+ && Near(*this, TEXT("round trip"), ToThreeYawRad(Heading), WrapPi(Yaw), 1e-12);
+ if (!bOk)
+ {
+ break;
+ }
+ }
+
+ const TSharedPtr<FJsonObject> Root = LoadGolden(*this);
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("headings")))
+ {
+ const FString Name = Row->GetStringField(TEXT("name"));
+ const double YawRad = Row->GetNumberField(TEXT("three_yaw_rad"));
+ const double Heading = Row->GetNumberField(TEXT("unreal_heading_deg"));
+ Near(*this, Name + TEXT(" heading"), ToUnrealHeadingDeg(YawRad), Heading, AngTol);
+ Near(*this, Name + TEXT(" back"), ToThreeYawRad(Heading), Row->GetNumberField(TEXT("three_yaw_rad_back")), 1e-12);
+ Near(*this, Name + TEXT(" round trip"), ToThreeYawRad(ToUnrealHeadingDeg(YawRad)), WrapPi(YawRad), 1e-12);
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsQuatTest, "Verse.Contract.Coords.QuatConjugation", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsQuatTest::RunTest(const FString&)
+{
+ FVerseRng Rng(Seed, 5, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 10000; ++I)
+ {
+ const FQuat QT = RandomUnitQuat(Rng);
+ const FVerseThreeVector V = RandomThree(Rng, 5.0);
+ const FVector TRotated = QT.RotateVector(FVector(V.X, V.Y, V.Z));
+ const FVector Lhs = ToUnrealQuat(QT).RotateVector(MOf(V));
+ const FVector Rhs = MOf(T(TRotated.X, TRotated.Y, TRotated.Z));
+ const bool bOk = Near(*this, FString::Printf(TEXT("conjugation %d"), I), Lhs, Rhs, 1e-12 * 10.0)
+ && NearQuat(*this, FString::Printf(TEXT("inverse %d"), I), ToThreeQuat(ToUnrealQuat(QT)), QT, 0.0);
+ if (!bOk)
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsMeshYawTest, "Verse.Contract.Coords.MeshYawIsHeadingMinus90", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsMeshYawTest::RunTest(const FString&)
+{
+ FVerseRng Rng(Seed, 6, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 10000; ++I)
+ {
+ const double Yaw = I < 8 ? double(I - 4) * UE_DOUBLE_HALF_PI * 0.5 : Rng.Range(-UE_DOUBLE_PI, UE_DOUBLE_PI);
+ const double MeshYaw = ToUnrealMeshYawDeg(Yaw);
+ const FQuat YawOnly(0.0, FMath::Sin(0.5 * Yaw), 0.0, FMath::Cos(0.5 * Yaw)); // about three.js +Y
+ const bool bOk = NearAngle(*this, FString::Printf(TEXT("heading - 90, %d"), I), NormalizeDeg(ToUnrealHeadingDeg(Yaw) - 90.0), MeshYaw, AngTol)
+ && NearAngle(*this, FString::Printf(TEXT("quaternion route, %d"), I), ToUnrealQuat(YawOnly).Rotator().Yaw, MeshYaw, 1e-8)
+ && TestTrue(TEXT("mesh yaw in (-180, 180]"), MeshYaw > -180.0 && MeshYaw <= 180.0);
+ if (!bOk)
+ {
+ break;
+ }
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsBoxOrderTest, "Verse.Contract.Coords.BoxOrder", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsBoxOrderTest::RunTest(const FString&)
+{
+ const TSharedPtr<FJsonObject> Root = LoadGolden(*this);
+ const TArray<TSharedPtr<FJsonObject>> Boxes = Rows(Root, TEXT("arena_boxes"));
+ TestTrue(TEXT("golden file has arena boxes"), Boxes.Num() > 0);
+ for (const TSharedPtr<FJsonObject>& Row : Boxes)
+ {
+ const FString Id = Row->GetStringField(TEXT("id"));
+ const TSharedPtr<FJsonObject> B = Row->GetObjectField(TEXT("three"));
+ const FBox Box = ToUnrealBox(B->GetNumberField(TEXT("x0")), B->GetNumberField(TEXT("x1")), B->GetNumberField(TEXT("y0")),
+ B->GetNumberField(TEXT("y1")), B->GetNumberField(TEXT("z0")), B->GetNumberField(TEXT("z1")));
+ TestTrue(Id + TEXT(" min <= max"), Box.Min.X <= Box.Max.X && Box.Min.Y <= Box.Max.Y && Box.Min.Z <= Box.Max.Z);
+ Near(*this, Id + TEXT(" min"), Box.Min, Vec(Row, TEXT("unreal_min")), PosTol);
+ Near(*this, Id + TEXT(" max"), Box.Max, Vec(Row, TEXT("unreal_max")), PosTol);
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsDeckFrameTest, "Verse.Contract.Coords.DeckFrameTranslationOnly", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsDeckFrameTest::RunTest(const FString&)
+{
+ FVerseRng Rng(Seed, 7, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 1000; ++I)
+ {
+ FVerseDeckFrame Deck;
+ Deck.OriginCm = FVector(Rng.Range(-1e6, 1e6), Rng.Range(-1e6, 1e6), Rng.Range(-1e5, 1e5));
+ const FVerseThreeVector P = RandomThree(Rng, 100.0);
+ const double YawDeg = Rng.Range(-180.0, 180.0);
+ const bool bOk = Near(*this, TEXT("offset is exactly OriginCm"), ToUnrealPosition(P, Deck) - ToUnrealPosition(P), Deck.OriginCm, PosTol)
+ && Near(*this, TEXT("box min offset"), ToUnrealBox(P.X, P.X + 1, P.Y, P.Y + 1, P.Z, P.Z + 1, Deck).Min,
+ ToUnrealBox(P.X, P.X + 1, P.Y, P.Y + 1, P.Z, P.Z + 1).Min + Deck.OriginCm, PosTol)
+ && NearQuat(*this, TEXT("socket rotation unchanged"),
+ ToUnrealSocketTransform(P, YawDeg, ESocketUse::Heading, Deck).GetRotation(),
+ ToUnrealSocketTransform(P, YawDeg, ESocketUse::Heading).GetRotation(), 0.0);
+ if (!bOk)
+ {
+ break;
+ }
+ }
+ // Directions, headings and quaternions take no frame at all: the API has no deck parameter for them.
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsYawRateTest, "Verse.Contract.Coords.YawRateSign", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsYawRateTest::RunTest(const FString&)
+{
+ Near(*this, TEXT("+1 rad/s"), ToUnrealYawRateDeg(1.0), -57.29577951308232, AngTol);
+ Near(*this, TEXT("+2 rad/s"), ToUnrealYawRateDeg(2.0), -114.59155902616465, AngTol);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseCoordsCrossLanguageTest, "Verse.Contract.Coords.CrossLanguageGolden", VERSE_COORDS_TEST_FLAGS)
+bool FVerseCoordsCrossLanguageTest::RunTest(const FString&)
+{
+ const TSharedPtr<FJsonObject> Root = LoadGolden(*this);
+ if (!Root)
+ {
+ return false;
+ }
+ TestTrue(TEXT("positions"), CheckPositions(*this, Root, FString()) > 0);
+
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("directions")))
+ {
+ const FString Name = Row->GetStringField(TEXT("name"));
+ Near(*this, Name + TEXT(" T->U"), ToUnrealDirection(Three(Row, TEXT("three"))), Vec(Row, TEXT("unreal")), DirTol);
+ Near(*this, Name + TEXT(" U->T"), ToThreeDirection(Vec(Row, TEXT("unreal"))), Three(Row, TEXT("three")), DirTol);
+ }
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("headings")))
+ {
+ const FString Name = Row->GetStringField(TEXT("name"));
+ const double YawRad = Row->GetNumberField(TEXT("three_yaw_rad"));
+ Near(*this, Name + TEXT(" heading"), ToUnrealHeadingDeg(YawRad), Row->GetNumberField(TEXT("unreal_heading_deg")), AngTol);
+ NearAngle(*this, Name + TEXT(" mesh yaw"), ToUnrealMeshYawDeg(YawRad), Row->GetNumberField(TEXT("unreal_mesh_yaw_deg")), AngTol);
+ Near(*this, Name + TEXT(" forward"), ToUnrealViewRotation(YawRad, 0.0).Vector(), Vec(Row, TEXT("unreal_forward")), DirTol);
+ Near(*this, Name + TEXT(" forward via M"), ToUnrealDirection(Three(Row, TEXT("three_forward"))), Vec(Row, TEXT("unreal_forward")), DirTol);
+ }
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("views")))
+ {
+ const FString Name = Row->GetStringField(TEXT("name"));
+ const FRotator R = ToUnrealViewRotation(Row->GetNumberField(TEXT("three_yaw_rad")), Row->GetNumberField(TEXT("three_pitch_rad")));
+ const FVector Pyr = Vec(Row, TEXT("unreal_rotator_pyr"));
+ Near(*this, Name + TEXT(" pitch"), R.Pitch, Pyr.X, AngTol);
+ NearAngle(*this, Name + TEXT(" yaw"), R.Yaw, Pyr.Y, AngTol);
+ Near(*this, Name + TEXT(" roll"), R.Roll, Pyr.Z, AngTol);
+ Near(*this, Name + TEXT(" forward"), R.Vector(), Vec(Row, TEXT("unreal_forward")), DirTol);
+ }
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("quaternions")))
+ {
+ const FString Name = Row->GetStringField(TEXT("name"));
+ const TArray<double> QT = Numbers(Row, TEXT("three_xyzw"));
+ const TArray<double> QU = Numbers(Row, TEXT("unreal_xyzw"));
+ if (!TestTrue(Name + TEXT(" has 4 components"), QT.Num() == 4 && QU.Num() == 4))
+ {
+ continue;
+ }
+ const FQuat QThree(QT[0], QT[1], QT[2], QT[3]);
+ const FQuat QUnreal(QU[0], QU[1], QU[2], QU[3]);
+ NearQuat(*this, Name + TEXT(" T->U"), ToUnrealQuat(QThree), QUnreal, DirTol);
+ NearQuat(*this, Name + TEXT(" U->T"), ToThreeQuat(QUnreal), QThree, DirTol);
+ double ExpectedYaw = 0.0;
+ if (Row->TryGetNumberField(TEXT("unreal_yaw_deg"), ExpectedYaw))
+ {
+ NearAngle(*this, Name + TEXT(" yaw"), ToUnrealQuat(QThree).Rotator().Yaw, ExpectedYaw, 1e-8);
+ }
+ }
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("yaw_rates")))
+ {
+ Near(*this, TEXT("yaw rate"), ToUnrealYawRateDeg(Row->GetNumberField(TEXT("three_rad_s"))), Row->GetNumberField(TEXT("unreal_deg_s")), AngTol);
+ }
+ for (const TSharedPtr<FJsonObject>& Row : Rows(Root, TEXT("speeds")))
+ {
+ Near(*this, Row->GetStringField(TEXT("name")), MetresToCm(Row->GetNumberField(TEXT("three_m_s"))), Row->GetNumberField(TEXT("unreal_cm_s")), PosTol);
+ }
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseCore/Private/Tests/VerseCoreContractTest.cpp b/unreal/Verse/Source/VerseCore/Private/Tests/VerseCoreContractTest.cpp
new file mode 100644
index 0000000000..556a543246
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/Tests/VerseCoreContractTest.cpp
@@ -0,0 +1,781 @@
+#include "Bot/VerseBotAdaptiveConfig.h"
+#include "Bot/VerseBotTier.h"
+#include "Bot/VersePerceptTypes.h"
+#include "Combat/VerseCombatTypes.h"
+#include "Combat/VerseGadgetDefinition.h"
+#include "Combat/VerseMeleeDefinition.h"
+#include "Combat/VerseWeaponDefinition.h"
+#include "Destruction/VerseDestructionTuning.h"
+#include "Destruction/VersePenetrationTable.h"
+#include "Engine/Engine.h"
+#include "Engine/World.h"
+#include "Events/VerseEventHub.h"
+#include "GameplayTagsManager.h"
+#include "Misc/AutomationTest.h"
+#include "Noise/VerseAudibilityTable.h"
+#include "Qa/VerseQaRegistry.h"
+#include "Stubs/VerseNullStubs.h"
+#include "UObject/UnrealType.h"
+#include "VerseGameplayTags.h"
+#include "VerseLog.h"
+#include "VerseRng.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+// Verse.Contract.*: the shared types of VerseCore answer as the contracts say (orchestration.md
+// 0.4): enum order, field order of replicated and bridged structs, struct defaults, the frozen
+// tags, the data asset schemas and their contract tables, the hub, the QA registry, the stubs.
+
+#define VERSE_CONTRACT_TEST_FLAGS (EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter)
+
+namespace VerseContractTest
+{
+ void CheckEnum(FAutomationTestBase& Test, const UEnum* Enum, std::initializer_list<const TCHAR*> Names)
+ {
+ if (!Test.TestNotNull(TEXT("enum is reflected"), Enum))
+ {
+ return;
+ }
+ const int32 Count = int32(Names.size());
+ // NumEnums includes the generated _MAX entry.
+ Test.TestEqual(FString::Printf(TEXT("%s entry count"), *Enum->GetName()), Enum->NumEnums() - 1, Count);
+ int32 Index = 0;
+ for (const TCHAR* Name : Names)
+ {
+ Test.TestEqual(FString::Printf(TEXT("%s[%d]"), *Enum->GetName(), Index), Enum->GetNameStringByIndex(Index), FString(Name));
+ Test.TestEqual(FString::Printf(TEXT("%s::%s value"), *Enum->GetName(), Name), Enum->GetValueByIndex(Index), int64(Index));
+ ++Index;
+ }
+ }
+
+ void CheckFields(FAutomationTestBase& Test, const UScriptStruct* Struct, std::initializer_list<const TCHAR*> Names)
+ {
+ if (!Test.TestNotNull(TEXT("struct is reflected"), Struct))
+ {
+ return;
+ }
+ TArray<FString> Actual;
+ for (TFieldIterator<FProperty> It(Struct, EFieldIteratorFlags::IncludeSuper); It; ++It)
+ {
+ Actual.Add(It->GetName());
+ }
+ TArray<FString> Expected;
+ for (const TCHAR* Name : Names)
+ {
+ Expected.Add(Name);
+ }
+ Test.TestEqual(FString::Printf(TEXT("%s field order"), *Struct->GetName()),
+ FString::Join(Actual, TEXT(",")), FString::Join(Expected, TEXT(",")));
+ }
+
+ bool IsTag(const FGameplayTag& Tag, const TCHAR* Name)
+ {
+ return Tag.IsValid() && Tag.GetTagName() == FName(Name);
+ }
+
+ /** A bare game world with its subsystems; destroyed by the caller. */
+ UWorld* MakeWorld()
+ {
+ UWorld* World = UWorld::CreateWorld(EWorldType::Game, false, TEXT("VerseContractTestWorld"));
+ return World;
+ }
+}
+
+using namespace VerseContractTest;
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractCombatEnums, "Verse.Contract.Combat.EnumOrder", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractCombatEnums::RunTest(const FString&)
+{
+ CheckEnum(*this, StaticEnum<EVerseStance>(), {TEXT("Stand"), TEXT("Crouch"), TEXT("Prone"), TEXT("Slide")});
+ CheckEnum(*this, StaticEnum<EVerseHitZone>(), {TEXT("None"), TEXT("Head"), TEXT("Neck"), TEXT("UpperTorso"), TEXT("LowerTorso"), TEXT("Arm"), TEXT("Leg")});
+ CheckEnum(*this, StaticEnum<EVerseFireMode>(), {TEXT("Semi"), TEXT("Burst"), TEXT("Auto")});
+ CheckEnum(*this, StaticEnum<EVerseLoadoutSlot>(), {TEXT("Primary"), TEXT("Secondary"), TEXT("Melee"), TEXT("GadgetA"), TEXT("GadgetB")});
+ CheckEnum(*this, StaticEnum<EVerseCombatPhase>(), {TEXT("Alive"), TEXT("Dead"), TEXT("FinisherAttacker"), TEXT("FinisherVictim")});
+ CheckEnum(*this, StaticEnum<EVerseDamageSource>(), {TEXT("Bolt"), TEXT("Melee"), TEXT("Finisher"), TEXT("Gadget"), TEXT("World")});
+ CheckEnum(*this, StaticEnum<EVerseShotResult>(), {TEXT("Miss"), TEXT("HitBody"), TEXT("HitPiece"), TEXT("Blocked"), TEXT("Rejected")});
+ CheckEnum(*this, StaticEnum<EVerseFinisherPhase>(), {TEXT("Locked"), TEXT("Takedown"), TEXT("Struggle"), TEXT("Kill"), TEXT("Recover"), TEXT("Aborted")});
+ CheckEnum(*this, StaticEnum<EVerseGoreLevel>(), {TEXT("Full"), TEXT("Reduced")});
+ CheckEnum(*this, StaticEnum<EVerseGadgetEventKind>(), {TEXT("Deploy"), TEXT("Destroyed"), TEXT("Expired"), TEXT("Plant"), TEXT("Detonate")});
+ CheckEnum(*this, StaticEnum<EVerseSetOutcome>(), {TEXT("Won"), TEXT("Lost"), TEXT("Unfinished")});
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractInputButtons, "Verse.Contract.Combat.InputButtons", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractInputButtons::RunTest(const FString&)
+{
+ const TPair<EVerseInputButton, int32> Bits[] = {
+ {EVerseInputButton::Fire, 0}, {EVerseInputButton::Ads, 1}, {EVerseInputButton::Reload, 2}, {EVerseInputButton::Melee, 3},
+ {EVerseInputButton::Jump, 4}, {EVerseInputButton::Crouch, 5}, {EVerseInputButton::Prone, 6}, {EVerseInputButton::Sprint, 7},
+ {EVerseInputButton::LeanLeft, 8}, {EVerseInputButton::LeanRight, 9}, {EVerseInputButton::GadgetA, 10}, {EVerseInputButton::GadgetB, 11},
+ {EVerseInputButton::SlotPrimary, 12}, {EVerseInputButton::SlotSecondary, 13}, {EVerseInputButton::SlotMelee, 14},
+ {EVerseInputButton::Interact, 15},
+ };
+ for (const TPair<EVerseInputButton, int32>& Bit : Bits)
+ {
+ TestEqual(FString::Printf(TEXT("button bit %d"), Bit.Value), uint32(Bit.Key), uint32(1) << Bit.Value);
+ }
+ TestEqual(TEXT("None is 0"), uint32(EVerseInputButton::None), uint32(0));
+
+ FVerseInputFrame Frame;
+ TestEqual(TEXT("default buttons"), Frame.Buttons, uint32(0));
+ TestEqual(TEXT("default move"), Frame.Move, FVector2f::ZeroVector);
+ Frame.Buttons = uint32(EVerseInputButton::Fire | EVerseInputButton::Sprint);
+ Frame.Pressed = uint32(EVerseInputButton::Fire);
+ TestTrue(TEXT("fire held"), Frame.IsHeld(EVerseInputButton::Fire));
+ TestTrue(TEXT("sprint held"), Frame.IsHeld(EVerseInputButton::Sprint));
+ TestFalse(TEXT("ads not held"), Frame.IsHeld(EVerseInputButton::Ads));
+ TestTrue(TEXT("fire pressed"), Frame.WasPressed(EVerseInputButton::Fire));
+ TestFalse(TEXT("sprint not pressed"), Frame.WasPressed(EVerseInputButton::Sprint));
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractCombatFields, "Verse.Contract.Combat.StructFields", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractCombatFields::RunTest(const FString&)
+{
+ CheckFields(*this, FVerseInputFrame::StaticStruct(), {TEXT("Move"), TEXT("LookDeltaDeg"), TEXT("Buttons"), TEXT("Pressed"), TEXT("ServerTimeMs")});
+ CheckFields(*this, FVerseFireEvent::StaticStruct(), {TEXT("ShooterId"), TEXT("WeaponId"), TEXT("ShotCounter"), TEXT("Seed"), TEXT("Origin"), TEXT("Direction"), TEXT("ServerTime")});
+ CheckFields(*this, FVerseHitEvent::StaticStruct(), {TEXT("InstigatorId"), TEXT("VictimId"), TEXT("WeaponId"), TEXT("Source"), TEXT("ShotCounter"),
+ TEXT("Zone"), TEXT("Bone"), TEXT("ImpactWorld"), TEXT("ImpactBoneLocal"), TEXT("Direction"), TEXT("DistanceM"), TEXT("Damage"),
+ TEXT("PenetrationCount"), TEXT("bHeadshot"), TEXT("bKillingBlow"), TEXT("bBlockedBySpawnProtection"), TEXT("ServerTime")});
+ CheckFields(*this, FVersePenetrationEvent::StaticStruct(), {TEXT("ShooterId"), TEXT("ShotCounter"), TEXT("PieceIndex"), TEXT("MaterialWireId"),
+ TEXT("Entry"), TEXT("Exit"), TEXT("ThicknessCm"), TEXT("PowerBefore"), TEXT("PowerAfter"), TEXT("DamageFactorAfter"), TEXT("bPassed")});
+ CheckFields(*this, FVerseDeathEvent::StaticStruct(), {TEXT("VictimId"), TEXT("KillerId"), TEXT("Cause"), TEXT("WeaponId"), TEXT("LastZone"), TEXT("ServerTime"), TEXT("RespawnAt")});
+ CheckFields(*this, FVerseFinisherEvent::StaticStruct(), {TEXT("AttackerId"), TEXT("VictimId"), TEXT("Phase"), TEXT("SequenceStartServerTime"), TEXT("WarpTarget")});
+ CheckFields(*this, FVerseNoiseEvent::StaticStruct(), {TEXT("Noise"), TEXT("SourceId"), TEXT("Location"), TEXT("Loudness"), TEXT("ServerTime")});
+ CheckFields(*this, FVerseReloadEvent::StaticStruct(), {TEXT("PlayerId"), TEXT("WeaponId"), TEXT("bTactical"), TEXT("StartServerTime"), TEXT("EndServerTime"), TEXT("bCancelled")});
+ CheckFields(*this, FVerseGadgetEvent::StaticStruct(), {TEXT("Kind"), TEXT("GadgetId"), TEXT("OwnerId"), TEXT("Location"), TEXT("ServerTime")});
+ CheckFields(*this, FVerseArenaSwitchEvent::StaticStruct(), {TEXT("bArenaOn"), TEXT("Deck"), TEXT("ServerTime")});
+ CheckFields(*this, FVerseStationUsedEvent::StaticStruct(), {TEXT("StationId"), TEXT("Kind"), TEXT("UserId")});
+ CheckFields(*this, FVerseSetLine::StaticStruct(), {TEXT("PlayerId"), TEXT("bIsBot"), TEXT("Kills"), TEXT("Deaths"), TEXT("Headshots"), TEXT("Finishers"),
+ TEXT("MeleeKills"), TEXT("ShotsFired"), TEXT("ShotsHit"), TEXT("DamageDealt"), TEXT("DamageTaken"), TEXT("WallsBreached"),
+ TEXT("BulwarksPlaced"), TEXT("BestStreak"), TEXT("PerWeapon")});
+ CheckFields(*this, FVerseSetSummary::StaticStruct(), {TEXT("MatchId"), TEXT("SessionId"), TEXT("SetIndex"), TEXT("RulesetId"), TEXT("BotTier"),
+ TEXT("Outcome"), TEXT("StartedAtUnix"), TEXT("EndedAtUnix"), TEXT("MatchTimeS"), TEXT("Person"), TEXT("Opponent")});
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractCombatDefaults, "Verse.Contract.Combat.StructDefaults", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractCombatDefaults::RunTest(const FString&)
+{
+ const FVerseFireEvent Fire;
+ TestEqual(TEXT("fire shooter"), Fire.ShooterId, 0);
+ TestTrue(TEXT("fire weapon none"), Fire.WeaponId.IsNone());
+ TestEqual(TEXT("fire counter"), Fire.ShotCounter, uint16(0));
+ TestEqual(TEXT("fire seed"), Fire.Seed, uint32(0));
+ TestEqual(TEXT("fire origin"), FVector(Fire.Origin), FVector::ZeroVector);
+ TestEqual(TEXT("fire time"), Fire.ServerTime, 0.f);
+
+ const FVerseHitEvent Hit;
+ TestEqual(TEXT("hit source"), Hit.Source, EVerseDamageSource::Bolt);
+ TestEqual(TEXT("hit zone"), Hit.Zone, EVerseHitZone::None);
+ TestTrue(TEXT("hit bone none"), Hit.Bone.IsNone());
+ TestEqual(TEXT("hit impact"), FVector(Hit.ImpactWorld), FVector::ZeroVector);
+ TestEqual(TEXT("hit damage"), Hit.Damage, 0.f);
+ TestEqual(TEXT("hit penetrations"), Hit.PenetrationCount, uint8(0));
+ TestFalse(TEXT("hit headshot"), Hit.bHeadshot != 0);
+ TestFalse(TEXT("hit killing blow"), Hit.bKillingBlow != 0);
+ TestFalse(TEXT("hit blocked"), Hit.bBlockedBySpawnProtection != 0);
+
+ const FVersePenetrationEvent Pen;
+ TestEqual(TEXT("penetration factor"), Pen.DamageFactorAfter, 1.f);
+ TestFalse(TEXT("penetration passed"), Pen.bPassed);
+
+ const FVerseDeathEvent Death;
+ TestEqual(TEXT("death cause"), Death.Cause, EVerseDamageSource::Bolt);
+ TestEqual(TEXT("death zone"), Death.LastZone, EVerseHitZone::None);
+ TestEqual(TEXT("death respawn"), Death.RespawnAt, 0.f);
+
+ const FVerseFinisherEvent Finisher;
+ TestEqual(TEXT("finisher phase"), Finisher.Phase, EVerseFinisherPhase::Locked);
+ TestTrue(TEXT("finisher warp identity"), Finisher.WarpTarget.Equals(FTransform::Identity));
+
+ const FVerseNoiseEvent Noise;
+ TestFalse(TEXT("noise tag unset"), Noise.Noise.IsValid());
+ TestEqual(TEXT("noise source"), Noise.SourceId, 0);
+ TestEqual(TEXT("noise location"), Noise.Location, FVector::ZeroVector);
+ TestEqual(TEXT("noise loudness"), Noise.Loudness, 1.f);
+
+ const FVerseReloadEvent Reload;
+ TestTrue(TEXT("reload tactical"), Reload.bTactical);
+ TestFalse(TEXT("reload cancelled"), Reload.bCancelled);
+
+ const FVerseGadgetEvent Gadget;
+ TestEqual(TEXT("gadget kind"), Gadget.Kind, EVerseGadgetEventKind::Deploy);
+ TestEqual(TEXT("gadget location"), FVector(Gadget.Location), FVector::ZeroVector);
+
+ const FVerseArenaSwitchEvent Arena;
+ TestFalse(TEXT("arena off"), Arena.bArenaOn);
+ TestTrue(TEXT("arena deck none"), Arena.Deck.IsNone());
+
+ const FVerseStationUsedEvent Station;
+ TestEqual(TEXT("station user"), Station.UserId, 0);
+
+ const FVerseSetSummary Summary;
+ TestEqual(TEXT("summary outcome"), Summary.Outcome, EVerseSetOutcome::Unfinished);
+ TestEqual(TEXT("summary set index"), Summary.SetIndex, 0);
+ TestTrue(TEXT("summary match id empty"), Summary.MatchId.IsEmpty());
+ TestEqual(TEXT("summary match time"), Summary.MatchTimeS, 0.f);
+ TestFalse(TEXT("person is not a bot"), Summary.Person.bIsBot);
+ TestEqual(TEXT("person kills"), Summary.Person.Kills, 0);
+ TestEqual(TEXT("person weapons"), Summary.Person.PerWeapon.Num(), 0);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractCombatAssets, "Verse.Contract.Combat.DataAssets", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractCombatAssets::RunTest(const FString&)
+{
+ const UVerseWeaponDefinition* Weapon = GetDefault<UVerseWeaponDefinition>();
+ TestEqual(TEXT("weapon fire interval"), Weapon->FireInterval(), 0.1f);
+ TestEqual(TEXT("weapon power anchor"), Weapon->PenetrationPower, 100.f);
+ TestEqual(TEXT("weapon max penetrations"), Weapon->GetEffectiveMaxPenetrations(), 3);
+ TestEqual(TEXT("weapon hole radius"), Weapon->HoleRadiusMm, uint8(15));
+ TestEqual(TEXT("weapon recoil random fraction"), Weapon->RecoilRandomFraction, 0.15f);
+ TestEqual(TEXT("empty pattern is zero"), Weapon->PatternAt(4), FVector2f::ZeroVector);
+
+ // R1 with the Graveline start values: 690 RPM, d_r 0.12 s, rho 5 deg/s, pitch 0.45 rising to 0.62.
+ UVerseWeaponDefinition* Graveline = NewObject<UVerseWeaponDefinition>();
+ Graveline->RPM = 690.f;
+ Graveline->MagazineSize = 30;
+ Graveline->RecoilRecoveryRate = 5.f;
+ Graveline->RecoilRecoveryDelay = 0.12f;
+ Graveline->RecoilPitchCurve.GetRichCurve()->AddKey(0.f, 0.45f);
+ Graveline->RecoilPitchCurve.GetRichCurve()->AddKey(8.f, 0.62f);
+ Graveline->RecoilYawCurve.GetRichCurve()->AddKey(0.f, 0.10f);
+ Graveline->RecoilYawCurve.GetRichCurve()->AddKey(10.f, -0.15f);
+ TestTrue(TEXT("Graveline satisfies R1"), Graveline->SatisfiesRecoveryBelowKick(0.65f * 0.8f, Graveline->MagazineSize));
+ TestEqual(TEXT("pattern holds beyond the last key"), Graveline->PatternAt(40).X, 0.62f);
+ Graveline->MaxPenetrations = 7;
+ TestEqual(TEXT("max penetrations clamp to 3"), Graveline->GetEffectiveMaxPenetrations(), 3);
+
+ // The three.js blaster of combat-state.md 4.3 breaks R1: 5 shots/s, recovery 9 deg/s from 4/60 s, kick 0.55.
+ UVerseWeaponDefinition* Blaster = NewObject<UVerseWeaponDefinition>();
+ Blaster->RPM = 300.f;
+ Blaster->RecoilRecoveryRate = 9.f;
+ Blaster->RecoilRecoveryDelay = 4.f / 60.f;
+ Blaster->RecoilRandomFraction = 0.f;
+ Blaster->RecoilPitchCurve.GetRichCurve()->AddKey(0.f, 0.55f);
+ TestFalse(TEXT("blaster breaks R1"), Blaster->SatisfiesRecoveryBelowKick(1.f, 20));
+
+ const UVerseMeleeDefinition* Melee = GetDefault<UVerseMeleeDefinition>();
+ TestEqual(TEXT("strike damage"), Melee->StrikeDamage, 55.f);
+ TestTrue(TEXT("two strikes kill 100 hp, one does not"), Melee->StrikeDamage < 100.f && 2.f * Melee->StrikeDamage >= 100.f);
+ TestEqual(TEXT("finisher range"), Melee->FinisherRange, 1.5f);
+ TestEqual(TEXT("finisher kill time"), Melee->FinisherKillTime, 2.1f);
+ TestEqual(TEXT("finisher duration"), Melee->FinisherDuration, 2.5f);
+
+ const UVerseGadgetDefinition* Bulwark = GetDefault<UVerseGadgetDefinition>();
+ TestEqual(TEXT("bulwark health"), Bulwark->MaxHealth, 400.f);
+ TestEqual(TEXT("bulwark size"), Bulwark->Size, FVector3f(1.8f, 1.4f, 0.1f));
+ TestEqual(TEXT("bulwark pawn damage"), Bulwark->PawnDamageAt(0.f), 0.f);
+
+ // GD3 formula: 120 hp at the centre, linear to 0 at 3.0 m.
+ UVerseGadgetDefinition* Breach = NewObject<UVerseGadgetDefinition>();
+ Breach->PawnDamage = 120.f;
+ Breach->PawnRadius = 3.f;
+ TestNearlyEqual(TEXT("breach at 0 m"), Breach->PawnDamageAt(0.f), 120.f, 1e-4f);
+ TestNearlyEqual(TEXT("breach at 1.5 m"), Breach->PawnDamageAt(1.5f), 60.f, 1e-4f);
+ TestNearlyEqual(TEXT("breach at 3.0 m"), Breach->PawnDamageAt(3.f), 0.f, 1e-4f);
+ TestNearlyEqual(TEXT("breach beyond"), Breach->PawnDamageAt(5.f), 0.f, 1e-4f);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractDestructionTypes, "Verse.Contract.Destruction.Types", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractDestructionTypes::RunTest(const FString&)
+{
+ CheckEnum(*this, StaticEnum<EVersePieceState>(), {TEXT("Intact"), TEXT("Damaged"), TEXT("Holed"), TEXT("Breached"), TEXT("Destroyed"), TEXT("Repairing")});
+ CheckEnum(*this, StaticEnum<EVersePenetrationMaterial>(), {TEXT("SheetMetal"), TEXT("ContainerWall"), TEXT("Glass"), TEXT("CladdingPanel"),
+ TEXT("CatwalkGrating"), TEXT("CeilingPanel"), TEXT("Concrete"), TEXT("ArmorSteel")});
+ CheckEnum(*this, StaticEnum<EVerseFractureCause>(), {TEXT("Bolt"), TEXT("Breach"), TEXT("Melee"), TEXT("Repair"), TEXT("Reset")});
+ CheckEnum(*this, StaticEnum<EVersePieceClass>(), {TEXT("WallPanel"), TEXT("CladdingWall"), TEXT("ContainerWall"), TEXT("GlassPane"),
+ TEXT("CatwalkSegment"), TEXT("CeilingPanel")});
+
+ CheckFields(*this, FVerseFractureEvent::StaticStruct(), {TEXT("PieceIndex"), TEXT("FromState"), TEXT("ToState"), TEXT("Cause"), TEXT("Variant"),
+ TEXT("Seed"), TEXT("Impulse"), TEXT("Location"), TEXT("Radius"), TEXT("Instigator"), TEXT("ServerTimeMs"), TEXT("Epoch")});
+ CheckFields(*this, FVerseBoltHole::StaticStruct(), {TEXT("PieceIndex"), TEXT("AxisPositionMm"), TEXT("AxisDirectionOct"), TEXT("RadiusMm"),
+ TEXT("ServerTimeMs"), TEXT("Epoch")});
+ CheckFields(*this, FVersePenetrationHit::StaticStruct(), {TEXT("PieceIndex"), TEXT("MaterialWireId"), TEXT("Entry"), TEXT("Exit"),
+ TEXT("TracedThicknessCm"), TEXT("PowerLeft"), TEXT("DamageLeft"), TEXT("bPassed")});
+ CheckFields(*this, FVersePieceDamage::StaticStruct(), {TEXT("PieceIndex"), TEXT("Amount"), TEXT("Cause"), TEXT("Location"), TEXT("Direction"),
+ TEXT("InstigatorId"), TEXT("BreachRadiusCm")});
+
+ const FVerseFractureEvent Fracture;
+ TestEqual(TEXT("fracture instigator is world"), Fracture.Instigator, uint8(0xFF));
+ TestEqual(TEXT("fracture impulse zero"), int32(Fracture.Impulse[0] | Fracture.Impulse[1] | Fracture.Impulse[2]), 0);
+ TestEqual(TEXT("fracture from"), Fracture.FromState, EVersePieceState::Intact);
+ TestEqual(TEXT("all pieces id"), Verse::Destruction::AllPieces, uint16(0xFFFF));
+ TestEqual(TEXT("impulse array dim"), FVerseFractureEvent::StaticStruct()->FindPropertyByName(TEXT("Impulse"))->ArrayDim, 3);
+
+ TestEqual(TEXT("breach loudness"), Verse::Destruction::FractureLoudness(EVerseFractureNoise::Breach), 1.0f);
+ TestEqual(TEXT("wall loudness"), Verse::Destruction::FractureLoudness(EVerseFractureNoise::WallBreak), 0.7f);
+ TestEqual(TEXT("glass loudness"), Verse::Destruction::FractureLoudness(EVerseFractureNoise::Glass), 0.6f);
+ TestEqual(TEXT("tile loudness"), Verse::Destruction::FractureLoudness(EVerseFractureNoise::Tile), 0.5f);
+ TestEqual(TEXT("hole loudness"), Verse::Destruction::FractureLoudness(EVerseFractureNoise::BoltHole), 0.2f);
+
+ TestEqual(TEXT("HealthQ full"), Verse::Destruction::QuantizeHealth(200.f, 200.f), uint8(255));
+ TestEqual(TEXT("HealthQ half"), Verse::Destruction::QuantizeHealth(100.f, 200.f), uint8(128));
+ TestEqual(TEXT("HealthQ empty"), Verse::Destruction::QuantizeHealth(0.f, 200.f), uint8(0));
+ TestEqual(TEXT("HealthQ clamps"), Verse::Destruction::QuantizeHealth(500.f, 200.f), uint8(255));
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractBoltHoles, "Verse.Contract.Destruction.BoltHoleSightline", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractBoltHoles::RunTest(const FString&)
+{
+ // Octahedral round trip over seeded directions: within one quantum (about 1 degree).
+ FVerseRng Rng(42, 0, EVerseRngSalt::Harness);
+ for (int32 I = 0; I < 2000; ++I)
+ {
+ const FVector Dir = Rng.UnitVector();
+ int8 X = 0, Y = 0;
+ Verse::Destruction::EncodeOctahedral(Dir, X, Y);
+ const FVector Back = Verse::Destruction::DecodeOctahedral(X, Y);
+ if (!TestTrue(FString::Printf(TEXT("octahedral %d within 1.5 deg"), I), FVector::DotProduct(Dir, Back) >= FMath::Cos(FMath::DegreesToRadians(1.5))))
+ {
+ break;
+ }
+ }
+
+ // A 15 mm hole through a 4 cm panel along +X at the piece origin.
+ const FVerseBoltHole Hole = FVerseBoltHole::Make(7, FVector::ZeroVector, FVector::ForwardVector, 15, 1000, 2);
+ TestEqual(TEXT("hole piece"), Hole.PieceIndex, uint16(7));
+ TestEqual(TEXT("hole radius"), Hole.RadiusMm, uint8(15));
+ TestTrue(TEXT("axis direction"), Hole.GetAxisDirection().Equals(FVector::ForwardVector, 1e-6));
+ const TArray<FVerseBoltHole> Holes = {Hole};
+ TestTrue(TEXT("straight through passes"), FVerseBoltHole::RayPassesHoles(Holes, FVector(-2, 0.5, 0), FVector(2, 0.5, 0)));
+ TestTrue(TEXT("slanted within radius passes"), FVerseBoltHole::RayPassesHoles(Holes, FVector(-2, -1.4, 0), FVector(2, 1.4, 0)));
+ TestFalse(TEXT("exit outside the radius is blocked"), FVerseBoltHole::RayPassesHoles(Holes, FVector(-2, 0, 0), FVector(2, 2.0, 0)));
+ TestFalse(TEXT("entry outside the radius is blocked"), FVerseBoltHole::RayPassesHoles(Holes, FVector(-2, 0, 1.6), FVector(2, 0, 0)));
+ TestFalse(TEXT("no holes blocks"), FVerseBoltHole::RayPassesHoles({}, FVector(-2, 0, 0), FVector(2, 0, 0)));
+
+ // Thin sheet metal gives a wider view cone through the same hole than a thick panel.
+ const double SheetHalfCm = 0.15;
+ const double PanelHalfCm = 2.0;
+ const double Slope = 4.0; // cm lateral per cm of depth
+ TestTrue(TEXT("steep ray through thin sheet"), FVerseBoltHole::RayPassesHoles(Holes,
+ FVector(-SheetHalfCm, -Slope * SheetHalfCm, 0), FVector(SheetHalfCm, Slope * SheetHalfCm, 0)));
+ TestFalse(TEXT("steep ray through thick panel"), FVerseBoltHole::RayPassesHoles(Holes,
+ FVector(-PanelHalfCm, -Slope * PanelHalfCm, 0), FVector(PanelHalfCm, Slope * PanelHalfCm, 0)));
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractPenetrationTable, "Verse.Contract.Destruction.PenetrationTable", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractPenetrationTable::RunTest(const FString&)
+{
+ const UVersePenetrationTable* Table = GetDefault<UVersePenetrationTable>();
+ if (!TestEqual(TEXT("eight materials"), Table->Rows.Num(), 8))
+ {
+ return false;
+ }
+ for (int32 Wire = 0; Wire < Table->Rows.Num(); ++Wire)
+ {
+ const FVersePenetrationRow& Row = Table->Rows[Wire];
+ TestEqual(FString::Printf(TEXT("row %d wire id"), Wire), int32(Row.WireId), Wire);
+ TestTrue(FString::Printf(TEXT("row %d tag"), Wire), Row.MaterialTag == VerseTags::AllMaterialTags()[Wire]);
+ TestTrue(FString::Printf(TEXT("row %d positive reference thickness"), Wire), Row.RefThicknessCm > 0.f);
+ }
+ TestNull(TEXT("unknown wire id"), Table->FindRow(8));
+
+ const FVersePenetrationRow& Container = *Table->FindRow(uint8(EVersePenetrationMaterial::ContainerWall));
+ TestEqual(TEXT("container at reference"), UVersePenetrationTable::PassCost(Container, 0.4f), 25.f);
+ TestEqual(TEXT("cost floor 0.5"), UVersePenetrationTable::PassCost(Container, 0.01f), 12.5f);
+ TestEqual(TEXT("cost cap 3.0"), UVersePenetrationTable::PassCost(Container, 40.f), 75.f);
+
+ // The rifle (100) passes two container walls and keeps 0.5625 of its damage (destruction.md 2).
+ float Power = 100.f;
+ float Factor = 1.f;
+ for (int32 Pass = 0; Pass < 2; ++Pass)
+ {
+ const float Cost = UVersePenetrationTable::PassCost(Container, 0.4f);
+ TestTrue(TEXT("rifle passes a container wall"), Power >= Cost);
+ Power -= Cost;
+ Factor *= Container.DamageMultiplier;
+ }
+ TestNearlyEqual(TEXT("rifle damage after two walls"), Factor, 0.5625f, 1e-6f);
+
+ // The pistol (50) passes one container wall, or glass plus sheet metal.
+ const FVersePenetrationRow& Glass = *Table->FindRow(uint8(EVersePenetrationMaterial::Glass));
+ const FVersePenetrationRow& Sheet = *Table->FindRow(uint8(EVersePenetrationMaterial::SheetMetal));
+ TestTrue(TEXT("pistol passes glass and sheet"), 50.f - UVersePenetrationTable::PassCost(Glass, 2.4f) - UVersePenetrationTable::PassCost(Sheet, 0.3f) >= 0.f);
+
+ // Nothing passes concrete or armor steel, even at the thinnest clamp.
+ for (const EVersePenetrationMaterial Hard : {EVersePenetrationMaterial::Concrete, EVersePenetrationMaterial::ArmorSteel})
+ {
+ const FVersePenetrationRow& Row = *Table->FindRow(uint8(Hard));
+ TestTrue(TEXT("rifle stops"), UVersePenetrationTable::PassCost(Row, 0.f) > 100.f);
+ TestEqual(TEXT("no damage after"), Row.DamageMultiplier, 0.f);
+ TestFalse(TEXT("never breaks by bullets"), Row.bBreakableByBullets);
+ TestFalse(TEXT("never breaks by breach"), Row.bBreakableByBreach);
+ }
+ TestFalse(TEXT("grating does not break by bullets"), Table->FindRow(uint8(EVersePenetrationMaterial::CatwalkGrating))->bBreakableByBullets);
+
+ const UVerseDestructionTuning* Tuning = GetDefault<UVerseDestructionTuning>();
+ TestEqual(TEXT("six piece classes"), Tuning->Classes.Num(), 6);
+ TestEqual(TEXT("wall panel hp"), Tuning->Classes.FindChecked(EVersePieceClass::WallPanel).MaxHp, 200.f);
+ TestEqual(TEXT("wall panel holed at"), Tuning->Classes.FindChecked(EVersePieceClass::WallPanel).HoledAtOrBelowHp, 100.f);
+ TestEqual(TEXT("container hp"), Tuning->Classes.FindChecked(EVersePieceClass::ContainerWall).MaxHp, 300.f);
+ TestTrue(TEXT("glass breaks by melee"), Tuning->Classes.FindChecked(EVersePieceClass::GlassPane).bDestroyedByMeleeWhenDamaged);
+ TestFalse(TEXT("catwalk ignores bullets"), Tuning->Classes.FindChecked(EVersePieceClass::CatwalkSegment).bDamagedOnFirstHit);
+ TestEqual(TEXT("repair delay"), Tuning->RepairDelayS, 60.f);
+ TestEqual(TEXT("holes per piece"), Tuning->HolesPerPiece, 24);
+ TestEqual(TEXT("holes per arena"), Tuning->HolesPerArena, 512);
+ TestEqual(TEXT("drones"), Tuning->MaxActiveDrones, 3);
+ TestEqual(TEXT("drone hp"), Tuning->DroneMaxHp, 30.f);
+ for (const TPair<EVersePieceClass, FVersePieceClassTuning>& Pair : Tuning->Classes)
+ {
+ const FVersePenetrationRow* Row = Table->FindRow(uint8(Pair.Value.Material));
+ TestTrue(TEXT("class material is breakable by breach"), Row && Row->bBreakableByBreach);
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractTags, "Verse.Contract.Tags", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractTags::RunTest(const FString&)
+{
+ const TCHAR* NoiseNames[] = {
+ TEXT("Noise.Shot"), TEXT("Noise.Footstep.Sprint"), TEXT("Noise.Footstep.Run"), TEXT("Noise.Footstep.Walk"),
+ TEXT("Noise.Move.Slide"), TEXT("Noise.Move.Land"), TEXT("Noise.Move.Mantle"), TEXT("Noise.Reload"),
+ TEXT("Noise.Gadget.BulwarkDeploy"), TEXT("Noise.Gadget.BulwarkHum"), TEXT("Noise.Gadget.BreachPlant"),
+ TEXT("Noise.Gadget.BreachDetonate"), TEXT("Noise.Fracture"), TEXT("Noise.Drone"), TEXT("Noise.Melee"),
+ TEXT("Noise.Finisher"), TEXT("Noise.Impact"),
+ };
+ const TConstArrayView<FGameplayTag> Noise = VerseTags::AllNoiseTags();
+ if (TestEqual(TEXT("noise tag count (bot.md 3.2)"), Noise.Num(), int32(UE_ARRAY_COUNT(NoiseNames))))
+ {
+ for (int32 I = 0; I < Noise.Num(); ++I)
+ {
+ TestTrue(FString::Printf(TEXT("noise tag %s"), NoiseNames[I]), IsTag(Noise[I], NoiseNames[I]));
+ TestTrue(FString::Printf(TEXT("%s is registered"), NoiseNames[I]),
+ UGameplayTagsManager::Get().RequestGameplayTag(FName(NoiseNames[I]), false).IsValid());
+ }
+ }
+
+ const TCHAR* States[] = {TEXT("Attack"), TEXT("Hold"), TEXT("Flank"), TEXT("StalkForFinisher"), TEXT("Retreat"),
+ TEXT("Reload"), TEXT("DeployBulwark"), TEXT("Breach"), TEXT("Wallbang"), TEXT("Search")};
+ const TConstArrayView<FGameplayTag> Bot = VerseTags::AllBotStateTags();
+ if (TestEqual(TEXT("bot state tag count (bot.md 5.1)"), Bot.Num(), int32(UE_ARRAY_COUNT(States))))
+ {
+ for (int32 I = 0; I < Bot.Num(); ++I)
+ {
+ TestTrue(FString::Printf(TEXT("bot state %s"), States[I]), IsTag(Bot[I], *FString::Printf(TEXT("Bot.State.%s"), States[I])));
+ }
+ }
+
+ const TCHAR* Materials[] = {TEXT("sheet_metal"), TEXT("container_wall"), TEXT("glass"), TEXT("cladding_panel"),
+ TEXT("catwalk_grating"), TEXT("ceiling_panel"), TEXT("concrete"), TEXT("armor_steel")};
+ const TConstArrayView<FGameplayTag> Mats = VerseTags::AllMaterialTags();
+ if (TestEqual(TEXT("material tag count"), Mats.Num(), int32(UE_ARRAY_COUNT(Materials))))
+ {
+ for (int32 I = 0; I < Mats.Num(); ++I)
+ {
+ TestTrue(FString::Printf(TEXT("material %s"), Materials[I]), IsTag(Mats[I], *FString::Printf(TEXT("Verse.Material.%s"), Materials[I])));
+ }
+ }
+
+ // Every noise tag has exactly one audibility row, and every row is a noise tag.
+ const UVerseAudibilityTable* Audibility = GetDefault<UVerseAudibilityTable>();
+ TestEqual(TEXT("one audibility row per noise tag"), Audibility->Rows.Num(), Noise.Num());
+ for (const FGameplayTag& Tag : Noise)
+ {
+ TestNotNull(*FString::Printf(TEXT("audibility row for %s"), *Tag.ToString()), Audibility->FindRow(Tag));
+ }
+ TestEqual(TEXT("sprint 20 m"), Audibility->GetAudibleRangeM(VerseTags::Noise_Footstep_Sprint, 1.f), 20.f);
+ TestEqual(TEXT("walk 4 m"), Audibility->GetAudibleRangeM(VerseTags::Noise_Footstep_Walk, 1.f), 4.f);
+ TestEqual(TEXT("breach fracture 40 m"), Audibility->GetAudibleRangeM(VerseTags::Noise_Fracture, 1.f), 40.f);
+ TestNearlyEqual(TEXT("bolt hole fracture 8 m"), Audibility->GetAudibleRangeM(VerseTags::Noise_Fracture, 0.2f), 8.f, 1e-5f);
+ TestNearlyEqual(TEXT("drone 6 m"), Audibility->GetAudibleRangeM(VerseTags::Noise_Drone, Verse::Destruction::DroneLoudness), 6.f, 1e-5f);
+ TestTrue(TEXT("shot is whole arena"), Audibility->FindRow(VerseTags::Noise_Shot)->bWholeArena);
+ TestEqual(TEXT("detonation error x 0.5"), Audibility->FindRow(VerseTags::Noise_Gadget_BreachDetonate)->ErrorMultiplier, 0.5f);
+ TestEqual(TEXT("impact error 0"), Audibility->FindRow(VerseTags::Noise_Impact)->ErrorMultiplier, 0.f);
+ TestEqual(TEXT("unknown tag 0 m"), Audibility->GetAudibleRangeM(FGameplayTag(), 1.f), 0.f);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractBotTypes, "Verse.Contract.Bot.Types", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractBotTypes::RunTest(const FString&)
+{
+ CheckEnum(*this, StaticEnum<EVerseSightSample>(), {TEXT("Head"), TEXT("Neck"), TEXT("UpperTorso"), TEXT("Pelvis"),
+ TEXT("ShoulderLeft"), TEXT("ShoulderRight"), TEXT("KneeLeft"), TEXT("KneeRight")});
+ CheckFields(*this, FVersePerceptFrame::StaticStruct(), {TEXT("ServerTimeMs"), TEXT("Self"), TEXT("Sightings"), TEXT("Bolts"),
+ TEXT("Heard"), TEXT("bHasHurt"), TEXT("Hurt"), TEXT("Hud")});
+ CheckFields(*this, FVerseHeardPercept::StaticStruct(), {TEXT("PerceptId"), TEXT("Noise"), TEXT("Location"), TEXT("ErrorSdM"),
+ TEXT("LevelGuess"), TEXT("ServerTimeMs")});
+
+ // A percept never carries truth it must not: no health, ammo, tier or controller field on a sighting.
+ for (const TCHAR* Forbidden : {TEXT("Health"), TEXT("Magazine"), TEXT("Reserve"), TEXT("Tier"), TEXT("Controller"), TEXT("TrueLocation")})
+ {
+ TestNull(*FString::Printf(TEXT("sighting has no %s"), Forbidden), FVerseSightPercept::StaticStruct()->FindPropertyByName(Forbidden));
+ TestNull(*FString::Printf(TEXT("heard percept has no %s"), Forbidden), FVerseHeardPercept::StaticStruct()->FindPropertyByName(Forbidden));
+ }
+ const FVersePerceptFrame Frame;
+ TestFalse(TEXT("frame has no hurt by default"), Frame.bHasHurt);
+ TestEqual(TEXT("frame empty"), Frame.Sightings.Num() + Frame.Bolts.Num() + Frame.Heard.Num() + Frame.Hud.Num(), 0);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractBotTiers, "Verse.Contract.Bot.Tiers", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractBotTiers::RunTest(const FString&)
+{
+ UVerseBotTier* Normal = NewObject<UVerseBotTier>();
+ UVerseBotTier* Hard = NewObject<UVerseBotTier>();
+ UVerseBotTier* Elite = NewObject<UVerseBotTier>();
+ TestTrue(TEXT("normal start values"), UVerseBotTier::ApplyStartValues(TEXT("normal"), *Normal));
+ TestTrue(TEXT("hard start values"), UVerseBotTier::ApplyStartValues(TEXT("hard"), *Hard));
+ TestTrue(TEXT("elite start values"), UVerseBotTier::ApplyStartValues(TEXT("elite"), *Elite));
+ TestFalse(TEXT("unknown tier"), UVerseBotTier::ApplyStartValues(TEXT("legendary"), *Elite));
+
+ // The class defaults are the normal tier.
+ const UVerseBotTier* Defaults = GetDefault<UVerseBotTier>();
+ TestEqual(TEXT("default reaction"), Defaults->ReactionMs, Normal->ReactionMs);
+ TestEqual(TEXT("default turn rate"), Defaults->TurnRateDegS, Normal->TurnRateDegS);
+
+ TestEqual(TEXT("hard reaction mean"), Hard->ReactionMs.X, 270.f);
+ TestEqual(TEXT("elite turn rate"), Elite->TurnRateDegS, 850.f);
+ TestEqual(TEXT("elite bursts"), Elite->MaxBurstShots, 4);
+ for (const UVerseBotTier* Tier : {Normal, Hard, Elite})
+ {
+ TestTrue(*FString::Printf(TEXT("%s within contract bounds"), *Tier->TierId.ToString()), Tier->SatisfiesContractBounds());
+ }
+ // Higher tiers react faster and turn faster.
+ TestTrue(TEXT("reaction ladder"), Normal->ReactionMs.X > Hard->ReactionMs.X && Hard->ReactionMs.X > Elite->ReactionMs.X);
+ TestTrue(TEXT("turn ladder"), Normal->TurnRateDegS < Hard->TurnRateDegS && Hard->TurnRateDegS < Elite->TurnRateDegS);
+
+ UVerseBotTier* Loose = NewObject<UVerseBotTier>();
+ Loose->WallbangMinBelief = 0.1f;
+ Loose->WallbangMaxSourceAgeS = 9.f;
+ Loose->LearnWeightMax = 0.9f;
+ TestFalse(TEXT("loose tier breaks bounds"), Loose->SatisfiesContractBounds());
+ Loose->ClampToContract();
+ TestTrue(TEXT("clamped tier holds bounds"), Loose->SatisfiesContractBounds());
+ TestEqual(TEXT("belief floor"), Loose->WallbangMinBelief, UVerseBotTier::WallbangMinBeliefFloor);
+
+ // Adaptive interpolation (bot.md 9.2).
+ UVerseBotTier* Out = NewObject<UVerseBotTier>();
+ UVerseBotAdaptiveConfig::InterpolateTier(*Normal, *Hard, *Elite, 0.f, *Out);
+ TestEqual(TEXT("s = 0 is normal"), Out->TurnRateDegS, Normal->TurnRateDegS);
+ TestEqual(TEXT("adaptive id"), Out->TierId, FName(TEXT("adaptive")));
+ UVerseBotAdaptiveConfig::InterpolateTier(*Normal, *Hard, *Elite, 0.5f, *Out);
+ TestTrue(TEXT("s = 0.5 is hard"), Out->ReactionMs.Equals(Hard->ReactionMs, 1e-4f));
+ TestEqual(TEXT("s = 0.5 bursts"), Out->MaxBurstShots, Hard->MaxBurstShots);
+ UVerseBotAdaptiveConfig::InterpolateTier(*Normal, *Hard, *Elite, 1.f, *Out);
+ TestEqual(TEXT("s = 1 is elite"), Out->AimNoiseDeg, Elite->AimNoiseDeg);
+ UVerseBotAdaptiveConfig::InterpolateTier(*Normal, *Hard, *Elite, 0.25f, *Out);
+ TestNearlyEqual(TEXT("s = 0.25 halfway normal-hard"), Out->TurnRateDegS, 0.5f * (Normal->TurnRateDegS + Hard->TurnRateDegS), 1e-3f);
+ TestEqual(TEXT("int fields round"), Out->MaxBurstShots, FMath::RoundToInt(0.5f * (Normal->MaxBurstShots + Hard->MaxBurstShots)));
+ UVerseBotAdaptiveConfig::InterpolateTier(*Normal, *Hard, *Elite, 7.f, *Out);
+ TestEqual(TEXT("never above elite"), Out->TurnRateDegS, Elite->TurnRateDegS);
+ UVerseBotAdaptiveConfig::InterpolateTier(*Normal, *Hard, *Elite, -3.f, *Out);
+ TestEqual(TEXT("never below normal"), Out->TurnRateDegS, Normal->TurnRateDegS);
+
+ const UVerseBotAdaptiveConfig* Adaptive = GetDefault<UVerseBotAdaptiveConfig>();
+ TestEqual(TEXT("start skill"), Adaptive->StartSkill, 0.5f);
+ TestEqual(TEXT("warm-up holds"), Adaptive->NextSkill(0.5f, 1.f, 2), 0.5f);
+ TestEqual(TEXT("deadband holds"), Adaptive->NextSkill(0.5f, 0.55f, 8), 0.5f);
+ TestNearlyEqual(TEXT("step is capped"), Adaptive->NextSkill(0.5f, 1.f, 8), 0.55f, 1e-6f);
+ TestNearlyEqual(TEXT("small step"), Adaptive->NextSkill(0.5f, 0.6f, 8), 0.525f, 1e-6f);
+ TestEqual(TEXT("clamped at 1"), Adaptive->NextSkill(0.99f, 1.f, 8), 1.f);
+ TestEqual(TEXT("clamped at 0"), Adaptive->NextSkill(0.01f, 0.f, 8), 0.f);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractRng, "Verse.Contract.Rng", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractRng::RunTest(const FString&)
+{
+ FVerseRng A(1234);
+ FVerseRng B(1234);
+ for (int32 I = 0; I < 1000; ++I)
+ {
+ if (!TestEqual(TEXT("same seed, same stream"), A.NextU64(), B.NextU64()))
+ {
+ break;
+ }
+ }
+ TestNotEqual(TEXT("different seeds differ"), FVerseRng(1).NextU64(), FVerseRng(2).NextU64());
+ TestNotEqual(TEXT("salts separate streams"), FVerseRng(9, 3, EVerseRngSalt::Recoil).NextU64(), FVerseRng(9, 3, EVerseRngSalt::Spread).NextU64());
+ TestNotEqual(TEXT("indices separate streams"), FVerseRng(9, 3).NextU64(), FVerseRng(9, 4).NextU64());
+ TestEqual(TEXT("indexed stream is reproducible"), FVerseRng(9, 3, EVerseRngSalt::Spread).NextU64(), FVerseRng(9, 3, EVerseRngSalt::Spread).NextU64());
+ TestNotEqual(TEXT("hash is order-sensitive"), FVerseRng::Hash(1, 2, 3), FVerseRng::Hash(3, 2, 1));
+ TestEqual(TEXT("hash is stable"), FVerseRng::Hash(1, 2, 3), FVerseRng::Hash(1, 2, 3));
+
+ // Golden values pin the algorithm: a change here breaks every recorded replay (BR1).
+ FVerseRng Golden(0);
+ TestEqual(TEXT("SplitMix64(0) first draw"), Golden.NextU64(), uint64(0xE220A8397B1DCDAFull));
+
+ FVerseRng Rng(77, 0, EVerseRngSalt::Harness);
+ double Sum = 0.0;
+ double DiskX = 0.0;
+ double GaussSum = 0.0;
+ double GaussSq = 0.0;
+ const int32 N = 20000;
+ for (int32 I = 0; I < N; ++I)
+ {
+ const double U = Rng.NextUnit();
+ TestTrue(TEXT("unit in [0, 1)"), U >= 0.0 && U < 1.0);
+ Sum += U;
+ const FVector2D D = Rng.UnitDisk();
+ TestTrue(TEXT("disk point inside"), D.SizeSquared() <= 1.0);
+ DiskX += D.X;
+ const double G = Rng.Gaussian();
+ GaussSum += G;
+ GaussSq += G * G;
+ const int32 R = Rng.RangeInt(-3, 3);
+ TestTrue(TEXT("range int inclusive"), R >= -3 && R <= 3);
+ const FVector Cone = Rng.ConeDirection(FVector::ForwardVector, 2.0);
+ TestTrue(TEXT("cone direction within half-angle"), FVector::DotProduct(Cone, FVector::ForwardVector) >= FMath::Cos(FMath::DegreesToRadians(2.0)) - 1e-12);
+ }
+ TestNearlyEqual(TEXT("unit mean"), Sum / N, 0.5, 0.01);
+ TestNearlyEqual(TEXT("disk mean x"), DiskX / N, 0.0, 0.01);
+ TestNearlyEqual(TEXT("gaussian mean"), GaussSum / N, 0.0, 0.03);
+ TestNearlyEqual(TEXT("gaussian variance"), GaussSq / N, 1.0, 0.05);
+ TestEqual(TEXT("range int with an empty span"), Rng.RangeInt(5, 5), 5);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractEventHub, "Verse.Contract.EventHub", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractEventHub::RunTest(const FString&)
+{
+ UWorld* World = MakeWorld();
+ if (!TestNotNull(TEXT("test world"), World))
+ {
+ return false;
+ }
+ UVerseEventHub* Hub = World->GetSubsystem<UVerseEventHub>();
+ if (TestNotNull(TEXT("hub exists in a game world"), Hub))
+ {
+ int32 Calls = 0;
+ Hub->OnFire.AddLambda([&Calls](const FVerseFireEvent& E) { Calls += E.ShotCounter == 1 ? 1 : 0; });
+ Hub->OnHit.AddLambda([&Calls](const FVerseHitEvent&) { ++Calls; });
+ Hub->OnPenetration.AddLambda([&Calls](const FVersePenetrationEvent&) { ++Calls; });
+ Hub->OnDeath.AddLambda([&Calls](const FVerseDeathEvent&) { ++Calls; });
+ Hub->OnFinisher.AddLambda([&Calls](const FVerseFinisherEvent&) { ++Calls; });
+ Hub->OnNoise.AddLambda([&Calls](const FVerseNoiseEvent& E) { Calls += E.Noise == VerseTags::Noise_Shot ? 1 : 0; });
+ Hub->OnReload.AddLambda([&Calls](const FVerseReloadEvent&) { ++Calls; });
+ Hub->OnGadget.AddLambda([&Calls](const FVerseGadgetEvent&) { ++Calls; });
+ Hub->OnFracture.AddLambda([&Calls](const FVerseFractureEvent&) { ++Calls; });
+ Hub->OnArenaSwitch.AddLambda([&Calls](const FVerseArenaSwitchEvent& E) { Calls += E.bArenaOn ? 1 : 0; });
+ Hub->OnSetEnded.AddLambda([&Calls](const FVerseSetSummary& S) { Calls += S.Outcome == EVerseSetOutcome::Won ? 1 : 0; });
+ Hub->OnStationUsed.AddLambda([&Calls](const FVerseStationUsedEvent&) { ++Calls; });
+
+ FVerseFireEvent Fire;
+ Fire.ShotCounter = 1;
+ Hub->OnFire.Broadcast(Fire);
+ Hub->OnHit.Broadcast(FVerseHitEvent());
+ Hub->OnPenetration.Broadcast(FVersePenetrationEvent());
+ Hub->OnDeath.Broadcast(FVerseDeathEvent());
+ Hub->OnFinisher.Broadcast(FVerseFinisherEvent());
+ FVerseNoiseEvent Noise;
+ Noise.Noise = VerseTags::Noise_Shot;
+ Hub->OnNoise.Broadcast(Noise);
+ Hub->OnReload.Broadcast(FVerseReloadEvent());
+ Hub->OnGadget.Broadcast(FVerseGadgetEvent());
+ Hub->OnFracture.Broadcast(FVerseFractureEvent());
+ FVerseArenaSwitchEvent Arena;
+ Arena.bArenaOn = true;
+ Hub->OnArenaSwitch.Broadcast(Arena);
+ FVerseSetSummary Summary;
+ Summary.Outcome = EVerseSetOutcome::Won;
+ Hub->OnSetEnded.Broadcast(Summary);
+ Hub->OnStationUsed.Broadcast(FVerseStationUsedEvent());
+ TestEqual(TEXT("every delegate of combat-state.md 11.1 relays its event"), Calls, 12);
+ TestEqual(TEXT("Get finds the world's hub"), UVerseEventHub::Get(World), Hub);
+ }
+ World->DestroyWorld(false);
+ TestNull(TEXT("no hub without a world"), UVerseEventHub::Get(nullptr));
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractQaRegistry, "Verse.Contract.QaRegistry", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractQaRegistry::RunTest(const FString&)
+{
+ const TConstArrayView<FString> Known = UVerseQaRegistry::KnownCommands();
+ TestEqual(TEXT("parity.md 19 command count"), Known.Num(), 20);
+ TSet<FString> Unique;
+ for (const FString& Name : Known)
+ {
+ TestTrue(Name + TEXT(" has the prefix"), Name.StartsWith(UVerseQaRegistry::CommandPrefix()));
+ Unique.Add(Name);
+ }
+ TestEqual(TEXT("known commands are unique"), Unique.Num(), Known.Num());
+
+ UVerseQaRegistry* Registry = UVerseQaRegistry::Get();
+ if (!TestNotNull(TEXT("registry exists"), Registry))
+ {
+ return false;
+ }
+ const FString Name = TEXT("Verse.QA.ContractTest.Echo");
+ Registry->Unregister(Name);
+ const bool bRegistered = Registry->Register(Name, TEXT("Echoes its arguments (contract test)."),
+ [](const TArray<FString>& Args) { return FString::Printf(TEXT("{\"args\": \"%s\"}"), *FString::Join(Args, TEXT("|"))); });
+ TestTrue(TEXT("register"), bRegistered);
+ TestTrue(TEXT("registered"), Registry->IsRegistered(Name));
+ TestTrue(TEXT("listed"), Registry->GetRegisteredCommands().Contains(Name));
+
+ AddExpectedError(TEXT("refused"), EAutomationExpectedErrorFlags::Contains, 3);
+ TestFalse(TEXT("duplicate refused"), Registry->Register(Name, TEXT(""), [](const TArray<FString>&) { return FString(); }));
+ TestFalse(TEXT("prefix required"), Registry->Register(TEXT("Verse.Stats"), TEXT(""), [](const TArray<FString>&) { return FString(); }));
+ TestFalse(TEXT("handler required"), Registry->Register(TEXT("Verse.QA.ContractTest.Null"), TEXT(""), FVerseQaHandler()));
+
+ FString Result;
+ TestTrue(TEXT("execute"), Registry->Execute(Name, {TEXT("a"), TEXT("b")}, Result));
+ TestEqual(TEXT("execute result"), Result, FString(TEXT("{\"args\": \"a|b\"}")));
+ TestTrue(TEXT("execute line"), Registry->ExecuteLine(TEXT("Verse.QA.ContractTest.Echo one \"two words\""), Result));
+ TestEqual(TEXT("execute line result"), Result, FString(TEXT("{\"args\": \"one|two words\"}")));
+ TestFalse(TEXT("unknown command"), Registry->Execute(TEXT("Verse.QA.ContractTest.Missing"), {}, Result));
+ TestTrue(TEXT("unknown command answers an error object"), Result.StartsWith(TEXT("{\"error\"")));
+ TestFalse(TEXT("empty line"), Registry->ExecuteLine(TEXT(" "), Result));
+
+ TestTrue(TEXT("unregister"), Registry->Unregister(Name));
+ TestFalse(TEXT("gone"), Registry->IsRegistered(Name));
+ TestFalse(TEXT("second unregister"), Registry->Unregister(Name));
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractStubs, "Verse.Contract.Stubs", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractStubs::RunTest(const FString&)
+{
+ UObject* Pen = NewObject<UVerseNullPenetrationQuery>();
+ IVersePenetrationQuery* PenQuery = Cast<IVersePenetrationQuery>(Pen);
+ if (TestNotNull(TEXT("penetration stub implements the interface"), PenQuery))
+ {
+ TestEqual(TEXT("no pieces entered"), PenQuery->TraceBolt(FVector::ZeroVector, FVector::ForwardVector, 15000.f, 100.f, 28.f, 15, 3).Num(), 0);
+ TestTrue(TEXT("sight is clear"), PenQuery->TestSight(FVector::ZeroVector, FVector(1000, 0, 0)));
+ }
+ IVersePieceDamage* Damage = NewObject<UVerseNullPieceDamage>();
+ if (TestNotNull(TEXT("damage stub implements the interface"), Damage))
+ {
+ Damage->ApplyPieceDamage(FVersePieceDamage());
+ }
+ IVersePieceQuery* Pieces = Cast<IVersePieceQuery>(NewObject<UVerseNullPieceQuery>());
+ if (TestNotNull(TEXT("piece stub implements the interface"), Pieces))
+ {
+ TestEqual(TEXT("state"), Pieces->GetPieceState(3), EVersePieceState::Intact);
+ TestEqual(TEXT("material"), Pieces->GetPieceMaterial(3), EVersePenetrationMaterial::Concrete);
+ TestFalse(TEXT("bounds invalid"), bool(Pieces->GetPieceBounds(3).IsValid));
+ TestEqual(TEXT("no pieces in a box"), Pieces->GetPiecesInBox(FBox(FVector(-1e5), FVector(1e5))).Num(), 0);
+ }
+ const IVerseMovementQuery* Movement = Cast<IVerseMovementQuery>(GetMutableDefault<UVerseNullMovementQuery>());
+ if (TestNotNull(TEXT("movement stub implements the interface"), Movement))
+ {
+ TestEqual(TEXT("stance"), Movement->GetStance(), EVerseStance::Stand);
+ TestFalse(TEXT("sprinting"), Movement->IsSprinting());
+ TestFalse(TEXT("airborne"), Movement->IsAirborne());
+ TestFalse(TEXT("mantling"), Movement->IsMantling());
+ TestFalse(TEXT("blocks firing"), Movement->BlocksFiring());
+ TestEqual(TEXT("lean"), Movement->GetLeanQuantized(), int8(0));
+ }
+ TestEqual(TEXT("lean quantise full right"), IVerseMovementQuery::QuantizeLean(1.f), int8(127));
+ TestEqual(TEXT("lean quantise clamps"), IVerseMovementQuery::QuantizeLean(-3.f), int8(-127));
+ TestNearlyEqual(TEXT("lean round trip"), IVerseMovementQuery::LeanFromQuantized(IVerseMovementQuery::QuantizeLean(0.5f)), 0.5f, 0.5f / 127.f);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseContractLog, "Verse.Contract.LogCategories", VERSE_CONTRACT_TEST_FLAGS)
+bool FVerseContractLog::RunTest(const FString&)
+{
+ TestEqual(TEXT("core"), LogVerseCore.GetCategoryName(), FName(TEXT("LogVerseCore")));
+ TestEqual(TEXT("combat"), LogVerseCombat.GetCategoryName(), FName(TEXT("LogVerseCombat")));
+ TestEqual(TEXT("bot"), LogVerseBot.GetCategoryName(), FName(TEXT("LogVerseBot")));
+ TestEqual(TEXT("qa"), LogVerseQa.GetCategoryName(), FName(TEXT("LogVerseQa")));
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseCore/Private/VerseCoords.cpp b/unreal/Verse/Source/VerseCore/Private/VerseCoords.cpp
new file mode 100644
index 0000000000..a3fd67d493
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/VerseCoords.cpp
@@ -0,0 +1,136 @@
+#include "VerseCoords.h"
+
+// The only file where the metre/centimetre factor appears (coordinates.md 4, test 14).
+
+namespace Verse::Coords
+{
+ namespace
+ {
+ constexpr double Pi = UE_DOUBLE_PI;
+ constexpr double DegPerRad = 180.0 / UE_DOUBLE_PI;
+ constexpr double RadPerDeg = UE_DOUBLE_PI / 180.0;
+ }
+
+ double MetresToCm(double Metres)
+ {
+ return Metres * CmPerMetre;
+ }
+
+ double CmToMetres(double Cm)
+ {
+ return Cm / CmPerMetre;
+ }
+
+ FVector ToUnrealPosition(const FVerseThreeVector& P, const FVerseDeckFrame& Deck)
+ {
+ return FVector(P.X * CmPerMetre, P.Z * CmPerMetre, P.Y * CmPerMetre) + Deck.OriginCm;
+ }
+
+ FVerseThreeVector ToThreePosition(const FVector& PCm, const FVerseDeckFrame& Deck)
+ {
+ const FVector Local = PCm - Deck.OriginCm;
+ return FVerseThreeVector(Local.X / CmPerMetre, Local.Z / CmPerMetre, Local.Y / CmPerMetre);
+ }
+
+ FVector ToUnrealDirection(const FVerseThreeVector& D)
+ {
+ return FVector(D.X, D.Z, D.Y);
+ }
+
+ FVerseThreeVector ToThreeDirection(const FVector& D)
+ {
+ return FVerseThreeVector(D.X, D.Z, D.Y);
+ }
+
+ FBox ToUnrealBox(double X0, double X1, double Y0, double Y1, double Z0, double Z1, const FVerseDeckFrame& Deck)
+ {
+ const FVector Min = FVector(X0, Z0, Y0) * CmPerMetre + Deck.OriginCm;
+ const FVector Max = FVector(X1, Z1, Y1) * CmPerMetre + Deck.OriginCm;
+ return FBox(Min, Max);
+ }
+
+ double NormalizeDeg(double Deg)
+ {
+ return FRotator::NormalizeAxis(Deg);
+ }
+
+ double WrapPi(double Rad)
+ {
+ double A = FMath::Fmod(Rad, 2.0 * Pi);
+ if (A <= -Pi)
+ {
+ A += 2.0 * Pi;
+ }
+ else if (A > Pi)
+ {
+ A -= 2.0 * Pi;
+ }
+ return A;
+ }
+
+ double ToUnrealHeadingDegFromDeg(double ThreeYawDeg)
+ {
+ return NormalizeDeg(90.0 - ThreeYawDeg);
+ }
+
+ double ToUnrealHeadingDeg(double ThreeYawRad)
+ {
+ return ToUnrealHeadingDegFromDeg(ThreeYawRad * DegPerRad);
+ }
+
+ double ToThreeYawRad(double UnrealYawDeg)
+ {
+ return WrapPi((90.0 - UnrealYawDeg) * RadPerDeg);
+ }
+
+ double ToUnrealYawRateDeg(double ThreeYawRateRad)
+ {
+ return -ThreeYawRateRad * DegPerRad;
+ }
+
+ FRotator ToUnrealViewRotation(double ThreeYawRad, double ThreePitchRad)
+ {
+ return FRotator(ThreePitchRad * DegPerRad, ToUnrealHeadingDeg(ThreeYawRad), 0.0);
+ }
+
+ double ToUnrealMeshYawDeg(double ThreeYawRad)
+ {
+ return NormalizeDeg(-ThreeYawRad * DegPerRad);
+ }
+
+ FQuat ToUnrealQuat(const FQuat& ThreeQuat)
+ {
+ return FQuat(-ThreeQuat.X, -ThreeQuat.Z, -ThreeQuat.Y, ThreeQuat.W);
+ }
+
+ FQuat ToThreeQuat(const FQuat& UnrealQuat)
+ {
+ return FQuat(-UnrealQuat.X, -UnrealQuat.Z, -UnrealQuat.Y, UnrealQuat.W);
+ }
+
+ FTransform ToUnrealSocketTransform(const FVerseThreeVector& P, double ThreeYawDeg, ESocketUse Use, const FVerseDeckFrame& Deck)
+ {
+ const double Yaw = Use == ESocketUse::Heading ? ToUnrealHeadingDegFromDeg(ThreeYawDeg) : NormalizeDeg(-ThreeYawDeg);
+ return FTransform(FRotator(0.0, Yaw, 0.0), ToUnrealPosition(P, Deck), FVector::OneVector);
+ }
+}
+
+FVector UVerseCoordsLibrary::ThreeToUnrealPosition(const FVerseThreeVector& P, const FVerseDeckFrame& Deck)
+{
+ return Verse::Coords::ToUnrealPosition(P, Deck);
+}
+
+FVerseThreeVector UVerseCoordsLibrary::UnrealToThreePosition(const FVector& PCm, const FVerseDeckFrame& Deck)
+{
+ return Verse::Coords::ToThreePosition(PCm, Deck);
+}
+
+double UVerseCoordsLibrary::ThreeYawDegToUnrealHeading(double ThreeYawDeg)
+{
+ return Verse::Coords::ToUnrealHeadingDegFromDeg(ThreeYawDeg);
+}
+
+double UVerseCoordsLibrary::ThreeYawDegToUnrealMeshYaw(double ThreeYawDeg)
+{
+ return Verse::Coords::NormalizeDeg(-ThreeYawDeg);
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/VerseGameplayTags.cpp b/unreal/Verse/Source/VerseCore/Private/VerseGameplayTags.cpp
new file mode 100644
index 0000000000..718d239830
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/VerseGameplayTags.cpp
@@ -0,0 +1,96 @@
+#include "VerseGameplayTags.h"
+
+namespace VerseTags
+{
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Shot, "Noise.Shot", "Weapon shot; audible in the whole arena (bot.md 3.2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Footstep_Sprint, "Noise.Footstep.Sprint", "Sprint footsteps, 20 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Footstep_Run, "Noise.Footstep.Run", "Run footsteps, 10 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Footstep_Walk, "Noise.Footstep.Walk", "Walk footsteps, 4 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Move_Slide, "Noise.Move.Slide", "Slide, 12 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Move_Land, "Noise.Move.Land", "Landing from a jump or drop, 12 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Move_Mantle, "Noise.Move.Mantle", "Mantle, 12 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Reload, "Noise.Reload", "Reload (tactical or empty), 7 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Gadget_BulwarkDeploy, "Noise.Gadget.BulwarkDeploy", "Bulwark deploy, 15 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Gadget_BulwarkHum, "Noise.Gadget.BulwarkHum", "Bulwark hum while active, 5 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Gadget_BreachPlant, "Noise.Gadget.BreachPlant", "Breach charge plant, 10 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Gadget_BreachDetonate, "Noise.Gadget.BreachDetonate", "Breach charge detonation; whole arena");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Fracture, "Noise.Fracture", "Piece fracture; range = loudness x 40 m (destruction.md 6.2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Drone, "Noise.Drone", "Repair drone flight and weld; loudness 0.15");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Melee, "Noise.Melee", "Knife strike or whiff, 8 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Finisher, "Noise.Finisher", "Finisher takedown, 8 m");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Noise_Impact, "Noise.Impact", "Bolt impact within 3 m of the listener; always heard");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Attack, "Bot.State.Attack", "Bot decision state Attack (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Hold, "Bot.State.Hold", "Bot decision state Hold (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Flank, "Bot.State.Flank", "Bot decision state Flank (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_StalkForFinisher, "Bot.State.StalkForFinisher", "Bot decision state StalkForFinisher (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Retreat, "Bot.State.Retreat", "Bot decision state Retreat (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Reload, "Bot.State.Reload", "Bot decision state Reload (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_DeployBulwark, "Bot.State.DeployBulwark", "Bot decision state DeployBulwark (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Breach, "Bot.State.Breach", "Bot decision state Breach (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Wallbang, "Bot.State.Wallbang", "Bot decision state Wallbang (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Bot_State_Search, "Bot.State.Search", "Bot decision state Search (bot.md 5.1)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_SheetMetal, "Verse.Material.sheet_metal", "Penetration table material sheet_metal (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_ContainerWall, "Verse.Material.container_wall", "Penetration table material container_wall (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_Glass, "Verse.Material.glass", "Penetration table material glass (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_CladdingPanel, "Verse.Material.cladding_panel", "Penetration table material cladding_panel (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_CatwalkGrating, "Verse.Material.catwalk_grating", "Penetration table material catwalk_grating (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_CeilingPanel, "Verse.Material.ceiling_panel", "Penetration table material ceiling_panel (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_Concrete, "Verse.Material.concrete", "Penetration table material concrete (destruction.md 2)");
+ UE_DEFINE_GAMEPLAY_TAG_COMMENT(Verse_Material_ArmorSteel, "Verse.Material.armor_steel", "Penetration table material armor_steel (destruction.md 2)");
+
+ TConstArrayView<FGameplayTag> AllNoiseTags()
+ {
+ static const TArray<FGameplayTag> Tags = {
+ Noise_Shot,
+ Noise_Footstep_Sprint,
+ Noise_Footstep_Run,
+ Noise_Footstep_Walk,
+ Noise_Move_Slide,
+ Noise_Move_Land,
+ Noise_Move_Mantle,
+ Noise_Reload,
+ Noise_Gadget_BulwarkDeploy,
+ Noise_Gadget_BulwarkHum,
+ Noise_Gadget_BreachPlant,
+ Noise_Gadget_BreachDetonate,
+ Noise_Fracture,
+ Noise_Drone,
+ Noise_Melee,
+ Noise_Finisher,
+ Noise_Impact,
+ };
+ return Tags;
+ }
+
+ TConstArrayView<FGameplayTag> AllBotStateTags()
+ {
+ static const TArray<FGameplayTag> Tags = {
+ Bot_State_Attack,
+ Bot_State_Hold,
+ Bot_State_Flank,
+ Bot_State_StalkForFinisher,
+ Bot_State_Retreat,
+ Bot_State_Reload,
+ Bot_State_DeployBulwark,
+ Bot_State_Breach,
+ Bot_State_Wallbang,
+ Bot_State_Search,
+ };
+ return Tags;
+ }
+
+ TConstArrayView<FGameplayTag> AllMaterialTags()
+ {
+ static const TArray<FGameplayTag> Tags = {
+ Verse_Material_SheetMetal,
+ Verse_Material_ContainerWall,
+ Verse_Material_Glass,
+ Verse_Material_CladdingPanel,
+ Verse_Material_CatwalkGrating,
+ Verse_Material_CeilingPanel,
+ Verse_Material_Concrete,
+ Verse_Material_ArmorSteel,
+ };
+ return Tags;
+ }
+}
diff --git a/unreal/Verse/Source/VerseCore/Private/VerseLog.cpp b/unreal/Verse/Source/VerseCore/Private/VerseLog.cpp
new file mode 100644
index 0000000000..bbdd88bbfc
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/VerseLog.cpp
@@ -0,0 +1,17 @@
+#include "VerseLog.h"
+
+DEFINE_LOG_CATEGORY(LogVerse);
+DEFINE_LOG_CATEGORY(LogVerseCore);
+DEFINE_LOG_CATEGORY(LogVerseBridge);
+DEFINE_LOG_CATEGORY(LogVerseMovement);
+DEFINE_LOG_CATEGORY(LogVerseDestruction);
+DEFINE_LOG_CATEGORY(LogVerseCombat);
+DEFINE_LOG_CATEGORY(LogVerseGore);
+DEFINE_LOG_CATEGORY(LogVerseDecks);
+DEFINE_LOG_CATEGORY(LogVerseCrew);
+DEFINE_LOG_CATEGORY(LogVerseScreens);
+DEFINE_LOG_CATEGORY(LogVerseBot);
+DEFINE_LOG_CATEGORY(LogVerseUI);
+DEFINE_LOG_CATEGORY(LogVerseStream);
+DEFINE_LOG_CATEGORY(LogVerseHarness);
+DEFINE_LOG_CATEGORY(LogVerseQa);
diff --git a/unreal/Verse/Source/VerseCore/Private/VerseRng.cpp b/unreal/Verse/Source/VerseCore/Private/VerseRng.cpp
new file mode 100644
index 0000000000..1ce87d191a
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Private/VerseRng.cpp
@@ -0,0 +1,111 @@
+#include "VerseRng.h"
+
+namespace
+{
+ constexpr uint64 GoldenGamma = 0x9E3779B97F4A7C15ull;
+ constexpr uint64 IndexKey = 0xD1B54A32D192ED03ull;
+ constexpr uint64 SaltKey = 0x8CB92BA72F3D8DD7ull;
+}
+
+FVerseRng::FVerseRng(uint64 Seed)
+ : State(Mix(Seed))
+{
+}
+
+FVerseRng::FVerseRng(uint64 Seed, uint64 Index, EVerseRngSalt Salt)
+ : State(Mix(Mix(Seed) ^ Mix(Index * IndexKey + (uint64(Salt) + 1) * SaltKey)))
+{
+}
+
+uint64 FVerseRng::Mix(uint64 Z)
+{
+ Z = (Z ^ (Z >> 30)) * 0xBF58476D1CE4E5B9ull;
+ Z = (Z ^ (Z >> 27)) * 0x94D049BB133111EBull;
+ return Z ^ (Z >> 31);
+}
+
+uint32 FVerseRng::Hash(uint32 A, uint32 B, uint32 C)
+{
+ uint64 H = Mix(uint64(A) + GoldenGamma);
+ H = Mix(H ^ (uint64(B) + 2 * GoldenGamma));
+ H = Mix(H ^ (uint64(C) + 3 * GoldenGamma));
+ return uint32(H ^ (H >> 32));
+}
+
+uint64 FVerseRng::NextU64()
+{
+ State += GoldenGamma;
+ return Mix(State);
+}
+
+uint32 FVerseRng::NextU32()
+{
+ return uint32(NextU64() >> 32);
+}
+
+double FVerseRng::NextUnit()
+{
+ return double(NextU64() >> 11) * (1.0 / 9007199254740992.0);
+}
+
+double FVerseRng::Range(double Min, double Max)
+{
+ return Min + (Max - Min) * NextUnit();
+}
+
+int32 FVerseRng::RangeInt(int32 Min, int32 MaxInclusive)
+{
+ if (MaxInclusive <= Min)
+ {
+ return Min;
+ }
+ const uint64 Span = uint64(int64(MaxInclusive) - int64(Min)) + 1;
+ // Lemire's multiply-shift, 32-bit draw; the span of int32 values fits.
+ const uint64 Draw = (uint64(NextU32()) * Span) >> 32;
+ return int32(int64(Min) + int64(Draw));
+}
+
+bool FVerseRng::Chance(double P)
+{
+ return NextUnit() < P;
+}
+
+double FVerseRng::Gaussian(double Mean, double Sd)
+{
+ const double U1 = 1.0 - NextUnit(); // (0, 1]
+ const double U2 = NextUnit();
+ return Mean + Sd * FMath::Sqrt(-2.0 * FMath::Loge(U1)) * FMath::Cos(2.0 * UE_DOUBLE_PI * U2);
+}
+
+FVector2D FVerseRng::UnitDisk()
+{
+ for (;;)
+ {
+ const double X = 2.0 * NextUnit() - 1.0;
+ const double Y = 2.0 * NextUnit() - 1.0;
+ if (X * X + Y * Y <= 1.0)
+ {
+ return FVector2D(X, Y);
+ }
+ }
+}
+
+FVector FVerseRng::UnitVector()
+{
+ const double Z = 2.0 * NextUnit() - 1.0;
+ const double Phi = 2.0 * UE_DOUBLE_PI * NextUnit();
+ const double R = FMath::Sqrt(FMath::Max(0.0, 1.0 - Z * Z));
+ return FVector(R * FMath::Cos(Phi), R * FMath::Sin(Phi), Z);
+}
+
+FVector FVerseRng::ConeDirection(const FVector& Axis, double HalfAngleDeg)
+{
+ const FVector A = Axis.GetSafeNormal(UE_DOUBLE_SMALL_NUMBER, FVector::ForwardVector);
+ const double CosMax = FMath::Cos(FMath::DegreesToRadians(FMath::Clamp(HalfAngleDeg, 0.0, 180.0)));
+ const double CosT = 1.0 - NextUnit() * (1.0 - CosMax);
+ const double SinT = FMath::Sqrt(FMath::Max(0.0, 1.0 - CosT * CosT));
+ const double Phi = 2.0 * UE_DOUBLE_PI * NextUnit();
+ FVector U, V;
+ A.FindBestAxisVectors(U, V);
+ return (A * CosT + U * (SinT * FMath::Cos(Phi)) + V * (SinT * FMath::Sin(Phi))).GetSafeNormal();
+}
diff --git a/unreal/Verse/Source/VerseCore/Public/Bot/VerseBotAdaptiveConfig.h b/unreal/Verse/Source/VerseCore/Public/Bot/VerseBotAdaptiveConfig.h
new file mode 100644
index 0000000000..f96c4d9907
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Bot/VerseBotAdaptiveConfig.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Engine/DataAsset.h"
+
+#include "VerseBotAdaptiveConfig.generated.h"
+
+class UVerseBotTier;
+
+/**
+ * The adaptive mode (bot.md 9.2): unreal/Verse/Data/bot/adaptive.json, asset
+ * /Game/Verse/Bot/Tiers/DA_BotAdaptive. A continuous skill s in [0, 1]: 0 = normal, 0.5 = hard,
+ * 1 = elite. Fields and the interpolation rule are frozen; the values are start values.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseBotAdaptiveConfig : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ /** Hard at match start. */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive", meta = (ClampMin = "0", ClampMax = "1"))
+ float StartSkill = 0.5f;
+
+ /** Rolling window of the last kills (either side). */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ int32 WindowKills = 10;
+
+ /** Person's share of kills in the window the controller aims for. */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ float TargetPersonShare = 0.5f;
+
+ /** No change while the share is within target +- deadband. */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ float Deadband = 0.08f;
+
+ /** ds = Gain x (share - target). */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ float Gain = 0.25f;
+
+ /** Bound on abs(ds). */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ float MaxStepPerKill = 0.05f;
+
+ /** No adjustment before this many kills. */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ int32 WarmupKills = 4;
+
+ /** When a new s is applied: the bot's respawn, never during an engagement. */
+ UPROPERTY(EditDefaultsOnly, Category = "Adaptive")
+ FName ApplyAt = TEXT("bot_respawn");
+
+ /**
+ * The skill after one kill: unchanged during warm-up or inside the deadband, otherwise
+ * s + clamp(Gain x (share - target), -MaxStepPerKill, MaxStepPerKill), clamped to [0, 1].
+ */
+ float NextSkill(float CurrentSkill, float PersonShare, int32 KillsSoFar) const;
+
+ /**
+ * The interpolation rule of 9.2: every numeric field (float, int, float pair) piecewise linear,
+ * normal to hard on [0, 0.5] and hard to elite on [0.5, 1]; int fields round. S is clamped to
+ * [0, 1], so the result is never below normal or above elite. Writes every field of Out except
+ * TierId, which becomes "adaptive".
+ */
+ static void InterpolateTier(const UVerseBotTier& Normal, const UVerseBotTier& Hard, const UVerseBotTier& Elite,
+ float S, UVerseBotTier& Out);
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Bot/VerseBotTier.h b/unreal/Verse/Source/VerseCore/Public/Bot/VerseBotTier.h
new file mode 100644
index 0000000000..b55926658b
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Bot/VerseBotTier.h
@@ -0,0 +1,211 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Engine/DataAsset.h"
+
+#include "VerseBotTier.generated.h"
+
+/**
+ * One bot tier (bot.md 9.1): /Game/Verse/Bot/Tiers/DA_BotTier_Normal, _Hard, _Elite. The source of
+ * truth is unreal/Verse/Data/bot/tiers.json; the commandlet VerseImportBotTiers writes the assets.
+ * Field names, types and groups are frozen, and so are the contract floors and caps below. The
+ * defaults are the normal tier's start values. Units: ms, s, m, deg as the names say.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseBotTier : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ /** Contract floor of WallbangMinBelief (bot.md 4.5). */
+ static constexpr float WallbangMinBeliefFloor = 0.25f;
+ /** Contract cap of WallbangMaxSourceAgeS (bot.md 4.5). */
+ static constexpr float WallbangMaxSourceAgeCapS = 4.f;
+ /** Contract cap of LearnWeightMax (bot.md 7.3). */
+ static constexpr float LearnWeightMaxCap = 0.35f;
+ /** Hysteresis on the current state's utility, fixed for all tiers (bot.md 5). */
+ static constexpr float UtilityHysteresis = 0.18f;
+
+ /** normal, hard, elite (AVersePlayerState::BotTier). */
+ UPROPERTY(EditDefaultsOnly, Category = "Identity")
+ FName TierId = TEXT("normal");
+
+ /** Stimulus to first action, ms: mean, sd */
+ UPROPERTY(EditDefaultsOnly, Category = "Perception")
+ FVector2f ReactionMs = FVector2f(320.0f, 60.0f);
+
+ UPROPERTY(EditDefaultsOnly, Category = "Perception")
+ float PeripheralReactionMul = 1.6f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Perception")
+ float PartialExposureAcquireMul = 1.5f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Perception")
+ float TrackLatencyMs = 150.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Perception")
+ float HearingErrorBaseM = 3.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Perception")
+ float HearingErrorPerM = 0.1f;
+
+ /** OU wander sd */
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AimNoiseDeg = 1.4f;
+
+ /** OU rate k, 1/s */
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AimNoiseRate = 1.6f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AcquireErrorDeg = 6.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AcquireMs = 650.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float TurnRateDegS = 450.0f;
+
+ /** 1/s */
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AimStiffness = 8.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float LeadSkill = 0.6f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float LeadNoise = 0.35f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float MotionWindowMs = 0.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float RecoilPatternComp = 0.35f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float RecoilResidualGain = 0.3f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float FireTolerance = 2.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float HeadAimChance = 0.05f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AdsRangeM = 12.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float BurstRangeM = 30.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ int32 MaxBurstShots = 8;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ float DecisionMs = 320.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ float UtilityNoise = 0.08f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ float Aggression = 0.5f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ float CoverUse = 0.4f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ float FlankUse = 0.2f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ float PreferredRangeM = 14.0f;
+
+ /** min, max */
+ UPROPERTY(EditDefaultsOnly, Category = "Decision")
+ FVector2f StrafeMs = FVector2f(700.0f, 1500.0f);
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float LeanUse = 0.2f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float CrouchPeekUse = 0.2f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float ProneUse = 0.05f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float SlideUse = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float NavLinkCostMul = 2.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float SoundDiscipline = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Movement")
+ float PeekRepeatPenalty = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float BulwarkUse = 0.2f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float BreachUse = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float WallbangUse = 0.15f;
+
+ /** Contract floor 0.25 */
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float WallbangMinBelief = 0.55f;
+
+ /** Contract cap 4 s */
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float WallbangMaxSourceAgeS = 1.5f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float WallbangMinDamageFrac = 0.3f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Gadgets and walls")
+ float PrefireChance = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float StalkUse = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float MaxStalkS = 4.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float FinisherCommitConfidence = 0.8f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float KnifeChoice = 0.2f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float TacticalReloadAtFrac = 0.25f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float ReloadOnlyWhenSafe = 0.3f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Melee and reload")
+ float PistolSwitchChance = 0.2f;
+
+ /** Contract cap 0.35 */
+ UPROPERTY(EditDefaultsOnly, Category = "Learning")
+ float LearnWeightMax = 0.1f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Learning")
+ float LearnSamplesHalf = 12.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Learning")
+ float HabitHalfLifeS = 180.0f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Learning")
+ float ExplorationRate = 0.25f;
+
+ /** Writes the start values of bot.md 9.1 for normal, hard or elite; false for another id. */
+ static bool ApplyStartValues(FName InTierId, UVerseBotTier& Out);
+
+ /** True when every contract floor and cap holds. */
+ bool SatisfiesContractBounds() const;
+
+ /** Clamps the fields that have a contract floor or cap. */
+ void ClampToContract();
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Bot/VersePerceptTypes.h b/unreal/Verse/Source/VerseCore/Public/Bot/VersePerceptTypes.h
new file mode 100644
index 0000000000..72537d9ed8
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Bot/VersePerceptTypes.h
@@ -0,0 +1,323 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+#include "GameplayTagContainer.h"
+
+#include "VersePerceptTypes.generated.h"
+
+// The perception boundary (bot.md 2, 3, frozen interface). UVersePerceptionService (VerseCombat)
+// produces these; the bot and the harness person models read only these. A percept never
+// carries the true location of anything unperceived, nor health, ammo, tier, controller or intent.
+
+/** Bit index in FVerseSightPercept::VisibleMask: the 8 hit-zone sample points of bot.md 3.1. */
+UENUM(BlueprintType)
+enum class EVerseSightSample : uint8
+{
+ Head,
+ Neck,
+ UpperTorso,
+ Pelvis,
+ ShoulderLeft,
+ ShoulderRight,
+ KneeLeft,
+ KneeRight
+};
+
+/** The three arena height levels (README Arena). */
+UENUM(BlueprintType)
+enum class EVerseArenaLevel : uint8
+{
+ Floor,
+ Mid,
+ Upper
+};
+
+/** HUD-visible events (bot.md 3.3): kill feed and hit markers. */
+UENUM(BlueprintType)
+enum class EVerseHudEventKind : uint8
+{
+ Kill,
+ OpponentRespawned,
+ HitMarker,
+ HeadshotMarker,
+ KillMarker
+};
+
+/** What the observer's own HUD shows (bot.md 3.3). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseSelfPercept
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ float Health = 0.f;
+
+ UPROPERTY()
+ float MaxHealth = 0.f;
+
+ UPROPERTY()
+ float Armor = 0.f;
+
+ UPROPERTY()
+ EVerseLoadoutSlot ActiveSlot = EVerseLoadoutSlot::Primary;
+
+ UPROPERTY()
+ int32 Magazine = 0;
+
+ UPROPERTY()
+ bool bChambered = false;
+
+ UPROPERTY()
+ int32 Reserve = 0;
+
+ /** GadgetA, GadgetB. */
+ UPROPERTY()
+ int32 GadgetCharges[2] = {0, 0};
+
+ /** Seconds left, GadgetA, GadgetB. */
+ UPROPERTY()
+ float GadgetCooldownS[2] = {0.f, 0.f};
+
+ UPROPERTY()
+ EVerseStance Stance = EVerseStance::Stand;
+
+ /** Own pawn, world cm. */
+ UPROPERTY()
+ FVector Location = FVector::ZeroVector;
+
+ UPROPERTY()
+ FVector Velocity = FVector::ZeroVector;
+
+ /** Own eye (the Camera bone), world cm. */
+ UPROPERTY()
+ FVector EyeLocation = FVector::ZeroVector;
+
+ UPROPERTY()
+ FRotator ViewRotation = FRotator::ZeroRotator;
+
+ UPROPERTY()
+ EVerseCombatPhase Phase = EVerseCombatPhase::Alive;
+
+ UPROPERTY()
+ bool bSpawnProtected = false;
+};
+
+/** One sighting (bot.md 3.1). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseSightPercept
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint32 PerceptId = 0;
+
+ UPROPERTY()
+ FVector PelvisLocation = FVector::ZeroVector;
+
+ UPROPERTY()
+ FVector Velocity = FVector::ZeroVector;
+
+ UPROPERTY()
+ float FacingYawDeg = 0.f;
+
+ UPROPERTY()
+ float FacingPitchDeg = 0.f;
+
+ UPROPERTY()
+ EVerseStance Stance = EVerseStance::Stand;
+
+ UPROPERTY()
+ int8 LeanQuantized = 0;
+
+ UPROPERTY()
+ bool bAds = false;
+
+ /** The weapon model in the target's hands. */
+ UPROPERTY()
+ FName HeldWeaponId;
+
+ /** The reload animation is visible. */
+ UPROPERTY()
+ bool bReloading = false;
+
+ /** The spawn protection effect is visible. */
+ UPROPERTY()
+ bool bSpawnProtected = false;
+
+ /** Bit per EVerseSightSample visible this tick. */
+ UPROPERTY()
+ uint8 VisibleMask = 0;
+
+ UPROPERTY()
+ bool bPeripheral = false;
+};
+
+/** An opponent bolt segment seen in the cone (bot.md 3.1). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseBoltPercept
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint32 PerceptId = 0;
+
+ UPROPERTY()
+ FVector Position = FVector::ZeroVector;
+
+ UPROPERTY()
+ FVector Direction = FVector::ForwardVector;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+};
+
+/** One heard noise, error already applied (bot.md 3.2). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseHeardPercept
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint32 PerceptId = 0;
+
+ /** The Noise.* tag. */
+ UPROPERTY()
+ FGameplayTag Noise;
+
+ /** Noisy location, never the true one. */
+ UPROPERTY()
+ FVector Location = FVector::ZeroVector;
+
+ /** The position error sd used, metres. */
+ UPROPERTY()
+ float ErrorSdM = 0.f;
+
+ UPROPERTY()
+ EVerseArenaLevel LevelGuess = EVerseArenaLevel::Floor;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+};
+
+/** Damage taken (bot.md 3.2: a hurt percept, not a noise). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseHurtPercept
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint32 PerceptId = 0;
+
+ /** Direction the damage came from, +-8 deg error applied. */
+ UPROPERTY()
+ FVector IncomingDirection = FVector::ForwardVector;
+
+ UPROPERTY()
+ float Damage = 0.f;
+
+ UPROPERTY()
+ EVerseDamageSource Source = EVerseDamageSource::Bolt;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+};
+
+/** Kill feed entry or hit marker (bot.md 3.3). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseHudEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ EVerseHudEventKind Kind = EVerseHudEventKind::HitMarker;
+
+ UPROPERTY()
+ int32 KillerId = 0;
+
+ UPROPERTY()
+ int32 VictimId = 0;
+
+ UPROPERTY()
+ EVerseDamageSource Cause = EVerseDamageSource::Bolt;
+
+ UPROPERTY()
+ FName WeaponId;
+
+ UPROPERTY()
+ bool bWallShot = false;
+
+ /** Set when the kill cam shows where the killer stood. */
+ UPROPERTY()
+ bool bKillerPositionShown = false;
+
+ UPROPERTY()
+ FVector KillerPosition = FVector::ZeroVector;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+};
+
+/** Everything one observer perceives in one server tick (bot.md frozen interface). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePerceptFrame
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+
+ UPROPERTY()
+ FVerseSelfPercept Self;
+
+ UPROPERTY()
+ TArray<FVerseSightPercept> Sightings;
+
+ UPROPERTY()
+ TArray<FVerseBoltPercept> Bolts;
+
+ UPROPERTY()
+ TArray<FVerseHeardPercept> Heard;
+
+ /** Hurt is optional: valid only when bHasHurt. */
+ UPROPERTY()
+ bool bHasHurt = false;
+
+ UPROPERTY()
+ FVerseHurtPercept Hurt;
+
+ UPROPERTY()
+ TArray<FVerseHudEvent> Hud;
+};
+
+/**
+ * What UVersePerceptionService::RegisterObserver gets (bot.md frozen interface): the tier's
+ * hearing and acquisition fields and the seed of the observer's error RNG stream.
+ */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePerceptionProfile
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ float HearingErrorBaseM = 3.0f;
+
+ UPROPERTY()
+ float HearingErrorPerM = 0.10f;
+
+ /** Mean, sd. */
+ UPROPERTY()
+ FVector2f ReactionMs = FVector2f(320.f, 60.f);
+
+ UPROPERTY()
+ float PeripheralReactionMul = 1.6f;
+
+ UPROPERTY()
+ float PartialExposureAcquireMul = 1.5f;
+
+ UPROPERTY()
+ float TrackLatencyMs = 150.f;
+
+ UPROPERTY()
+ uint32 Seed = 0;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Combat/VerseCombatTypes.h b/unreal/Verse/Source/VerseCore/Public/Combat/VerseCombatTypes.h
index 3156b3d243..0063c6bfca 100644
--- a/unreal/Verse/Source/VerseCore/Public/Combat/VerseCombatTypes.h
+++ b/unreal/Verse/Source/VerseCore/Public/Combat/VerseCombatTypes.h
@@ -1,12 +1,53 @@
#pragma once
#include "CoreMinimal.h"
+#include "Engine/NetSerialization.h"
+#include "GameplayTagContainer.h"
#include "VerseCombatTypes.generated.h"
-// Shared combat enums (contracts/combat-state.md 11.1). The order of every entry
-// is frozen: replicated values and saved settings depend on it. G0.3 adds the
-// remaining types of 11.1 to this file.
+// Shared combat enums and event structs (contracts/combat-state.md 11.1). The order of every
+// enum entry and every struct field is frozen: replicated values, saved settings and the
+// bridge codec depend on it. Verse.Contract.Combat.* tests pin both.
+
+UENUM(BlueprintType)
+enum class EVerseStance : uint8
+{
+ Stand,
+ Crouch,
+ Prone,
+ Slide
+};
+
+UENUM(BlueprintType)
+enum class EVerseHitZone : uint8
+{
+ None,
+ Head,
+ Neck,
+ UpperTorso,
+ LowerTorso,
+ Arm,
+ Leg
+};
+
+UENUM(BlueprintType)
+enum class EVerseFireMode : uint8
+{
+ Semi,
+ Burst,
+ Auto
+};
+
+UENUM(BlueprintType)
+enum class EVerseLoadoutSlot : uint8
+{
+ Primary,
+ Secondary,
+ Melee,
+ GadgetA,
+ GadgetB
+};
UENUM(BlueprintType)
enum class EVerseCombatPhase : uint8
@@ -17,9 +58,503 @@ enum class EVerseCombatPhase : uint8
FinisherVictim
};
+UENUM(BlueprintType)
+enum class EVerseDamageSource : uint8
+{
+ Bolt,
+ Melee,
+ Finisher,
+ Gadget,
+ World
+};
+
+UENUM(BlueprintType)
+enum class EVerseShotResult : uint8
+{
+ Miss,
+ HitBody,
+ HitPiece,
+ Blocked,
+ Rejected
+};
+
+UENUM(BlueprintType)
+enum class EVerseFinisherPhase : uint8
+{
+ Locked,
+ Takedown,
+ Struggle,
+ Kill,
+ Recover,
+ Aborted
+};
+
UENUM(BlueprintType)
enum class EVerseGoreLevel : uint8
{
Full,
Reduced
};
+
+UENUM(BlueprintType)
+enum class EVerseGadgetEventKind : uint8
+{
+ Deploy,
+ Destroyed,
+ Expired,
+ Plant,
+ Detonate
+};
+
+UENUM(BlueprintType)
+enum class EVerseSetOutcome : uint8
+{
+ Won,
+ Lost,
+ Unfinished
+};
+
+/** Bit flags in FVerseInputFrame::Buttons and ::Pressed. Values frozen (combat-state.md 11.1). */
+UENUM(meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor = "true"))
+enum class EVerseInputButton : uint32
+{
+ None = 0,
+ Fire = 0x00000001,
+ Ads = 0x00000002,
+ Reload = 0x00000004,
+ Melee = 0x00000008,
+ Jump = 0x00000010,
+ Crouch = 0x00000020,
+ Prone = 0x00000040,
+ Sprint = 0x00000080,
+ LeanLeft = 0x00000100,
+ LeanRight = 0x00000200,
+ GadgetA = 0x00000400,
+ GadgetB = 0x00000800,
+ SlotPrimary = 0x00001000,
+ SlotSecondary = 0x00002000,
+ SlotMelee = 0x00004000,
+ Interact = 0x00008000
+};
+ENUM_CLASS_FLAGS(EVerseInputButton);
+
+/** The one input path for persons, bots and harness models (bot.md B1). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseInputFrame
+{
+ GENERATED_BODY()
+
+ /** -1..1, X forward, Y right (pawn space). */
+ UPROPERTY()
+ FVector2f Move = FVector2f::ZeroVector;
+
+ /** Pitch, yaw added this tick, degrees. */
+ UPROPERTY()
+ FVector2f LookDeltaDeg = FVector2f::ZeroVector;
+
+ /** EVerseInputButton bits held this tick. */
+ UPROPERTY()
+ uint32 Buttons = 0;
+
+ /** Bits that went down this tick. */
+ UPROPERTY()
+ uint32 Pressed = 0;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+
+ bool IsHeld(EVerseInputButton Button) const { return (Buttons & uint32(Button)) != 0; }
+ bool WasPressed(EVerseInputButton Button) const { return (Pressed & uint32(Button)) != 0; }
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseFireEvent
+{
+ GENERATED_BODY()
+
+ /** Player state id. */
+ UPROPERTY()
+ int32 ShooterId = 0;
+
+ UPROPERTY()
+ FName WeaponId;
+
+ UPROPERTY()
+ uint16 ShotCounter = 0;
+
+ UPROPERTY()
+ uint32 Seed = 0;
+
+ /** cm */
+ UPROPERTY()
+ FVector_NetQuantize10 Origin = FVector_NetQuantize10(0.0, 0.0, 0.0);
+
+ UPROPERTY()
+ FVector_NetQuantizeNormal Direction = FVector_NetQuantizeNormal(1.0, 0.0, 0.0);
+
+ UPROPERTY()
+ float ServerTime = 0.f;
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseHitEvent
+{
+ GENERATED_BODY()
+
+ FVerseHitEvent()
+ : bHeadshot(0)
+ , bKillingBlow(0)
+ , bBlockedBySpawnProtection(0)
+ {
+ }
+
+ UPROPERTY()
+ int32 InstigatorId = 0;
+
+ UPROPERTY()
+ int32 VictimId = 0;
+
+ UPROPERTY()
+ FName WeaponId;
+
+ UPROPERTY()
+ EVerseDamageSource Source = EVerseDamageSource::Bolt;
+
+ UPROPERTY()
+ uint16 ShotCounter = 0;
+
+ UPROPERTY()
+ EVerseHitZone Zone = EVerseHitZone::None;
+
+ UPROPERTY()
+ FName Bone;
+
+ /** cm */
+ UPROPERTY()
+ FVector_NetQuantize10 ImpactWorld = FVector_NetQuantize10(0.0, 0.0, 0.0);
+
+ UPROPERTY()
+ FVector_NetQuantize10 ImpactBoneLocal = FVector_NetQuantize10(0.0, 0.0, 0.0);
+
+ UPROPERTY()
+ FVector_NetQuantizeNormal Direction = FVector_NetQuantizeNormal(1.0, 0.0, 0.0);
+
+ UPROPERTY()
+ float DistanceM = 0.f;
+
+ /** After all factors. */
+ UPROPERTY()
+ float Damage = 0.f;
+
+ UPROPERTY()
+ uint8 PenetrationCount = 0;
+
+ UPROPERTY()
+ uint8 bHeadshot : 1;
+
+ UPROPERTY()
+ uint8 bKillingBlow : 1;
+
+ UPROPERTY()
+ uint8 bBlockedBySpawnProtection : 1;
+
+ UPROPERTY()
+ float ServerTime = 0.f;
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePenetrationEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ int32 ShooterId = 0;
+
+ UPROPERTY()
+ uint16 ShotCounter = 0;
+
+ /** DA_PieceManifest index (destruction.md 8). */
+ UPROPERTY()
+ uint16 PieceIndex = 0;
+
+ /** DA_PenetrationTable wire id (destruction.md 2). */
+ UPROPERTY()
+ uint8 MaterialWireId = 0;
+
+ UPROPERTY()
+ FVector_NetQuantize10 Entry = FVector_NetQuantize10(0.0, 0.0, 0.0);
+
+ UPROPERTY()
+ FVector_NetQuantize10 Exit = FVector_NetQuantize10(0.0, 0.0, 0.0);
+
+ UPROPERTY()
+ float ThicknessCm = 0.f;
+
+ UPROPERTY()
+ float PowerBefore = 0.f;
+
+ UPROPERTY()
+ float PowerAfter = 0.f;
+
+ UPROPERTY()
+ float DamageFactorAfter = 1.f;
+
+ UPROPERTY()
+ bool bPassed = false;
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseDeathEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ int32 VictimId = 0;
+
+ UPROPERTY()
+ int32 KillerId = 0;
+
+ UPROPERTY()
+ EVerseDamageSource Cause = EVerseDamageSource::Bolt;
+
+ UPROPERTY()
+ FName WeaponId;
+
+ UPROPERTY()
+ EVerseHitZone LastZone = EVerseHitZone::None;
+
+ UPROPERTY()
+ float ServerTime = 0.f;
+
+ UPROPERTY()
+ float RespawnAt = 0.f;
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseFinisherEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ int32 AttackerId = 0;
+
+ UPROPERTY()
+ int32 VictimId = 0;
+
+ UPROPERTY()
+ EVerseFinisherPhase Phase = EVerseFinisherPhase::Locked;
+
+ /** Phases derive from this plus the fixed offsets of combat-state.md 7.4. */
+ UPROPERTY()
+ float SequenceStartServerTime = 0.f;
+
+ UPROPERTY()
+ FTransform WarpTarget = FTransform::Identity;
+};
+
+/** Declared in architecture.md; fields frozen in combat-state.md 11.1. Server only. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseNoiseEvent
+{
+ GENERATED_BODY()
+
+ /** One Noise.* tag of bot.md 3.2, the DA_Audibility row key. */
+ UPROPERTY()
+ FGameplayTag Noise;
+
+ /** Player state id, -1 = world (pieces, drones). */
+ UPROPERTY()
+ int32 SourceId = 0;
+
+ /** True position; the bot's perception adds error. */
+ UPROPERTY()
+ FVector Location = FVector::ZeroVector;
+
+ /** destruction.md 6.2 loudness for Noise.Fracture and Noise.Drone, else 1. */
+ UPROPERTY()
+ float Loudness = 1.f;
+
+ UPROPERTY()
+ float ServerTime = 0.f;
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseReloadEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ int32 PlayerId = 0;
+
+ UPROPERTY()
+ FName WeaponId;
+
+ /** A round was chambered. */
+ UPROPERTY()
+ bool bTactical = true;
+
+ UPROPERTY()
+ float StartServerTime = 0.f;
+
+ UPROPERTY()
+ float EndServerTime = 0.f;
+
+ UPROPERTY()
+ bool bCancelled = false;
+};
+
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseGadgetEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ EVerseGadgetEventKind Kind = EVerseGadgetEventKind::Deploy;
+
+ UPROPERTY()
+ FName GadgetId;
+
+ UPROPERTY()
+ int32 OwnerId = 0;
+
+ UPROPERTY()
+ FVector_NetQuantize10 Location = FVector_NetQuantize10(0.0, 0.0, 0.0);
+
+ UPROPERTY()
+ float ServerTime = 0.f;
+};
+
+/** Raised by VerseDecks (hangar day/arena switch). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseArenaSwitchEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ bool bArenaOn = false;
+
+ /** "hangar" */
+ UPROPERTY()
+ FName Deck;
+
+ UPROPERTY()
+ float ServerTime = 0.f;
+};
+
+/** Raised by VerseDecks stations; VerseUI opens the matching view. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseStationUsedEvent
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ FName StationId;
+
+ /** Station kind (parity S-01), e.g. "armoury". */
+ UPROPERTY()
+ FName Kind;
+
+ /** Player state id. */
+ UPROPERTY()
+ int32 UserId = 0;
+};
+
+/** One player's numbers in one set. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseSetLine
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ int32 PlayerId = 0;
+
+ UPROPERTY()
+ bool bIsBot = false;
+
+ UPROPERTY()
+ int32 Kills = 0;
+
+ UPROPERTY()
+ int32 Deaths = 0;
+
+ UPROPERTY()
+ int32 Headshots = 0;
+
+ UPROPERTY()
+ int32 Finishers = 0;
+
+ UPROPERTY()
+ int32 MeleeKills = 0;
+
+ UPROPERTY()
+ int32 ShotsFired = 0;
+
+ UPROPERTY()
+ int32 ShotsHit = 0;
+
+ UPROPERTY()
+ int32 DamageDealt = 0;
+
+ UPROPERTY()
+ int32 DamageTaken = 0;
+
+ UPROPERTY()
+ int32 WallsBreached = 0;
+
+ UPROPERTY()
+ int32 BulwarksPlaced = 0;
+
+ UPROPERTY()
+ int32 BestStreak = 0;
+
+ /** Weapon id -> (kills, headshots, shots fired, shots hit). */
+ UPROPERTY()
+ TMap<FName, FIntVector4> PerWeapon;
+};
+
+/** Payload of duel.result (bridge-protocol.md 10), one per set (combat-state.md 9.1). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseSetSummary
+{
+ GENERATED_BODY()
+
+ /** Unique per set result, idempotency key. */
+ UPROPERTY()
+ FString MatchId;
+
+ /** One arena session. */
+ UPROPERTY()
+ FString SessionId;
+
+ /** 1-based index of the set in its session. */
+ UPROPERTY()
+ int32 SetIndex = 0;
+
+ /** "endless/1" */
+ UPROPERTY()
+ FName RulesetId;
+
+ /** As AVersePlayerState::BotTier. */
+ UPROPERTY()
+ FName BotTier;
+
+ /** From the person's side. */
+ UPROPERTY()
+ EVerseSetOutcome Outcome = EVerseSetOutcome::Unfinished;
+
+ UPROPERTY()
+ double StartedAtUnix = 0.0;
+
+ UPROPERTY()
+ double EndedAtUnix = 0.0;
+
+ /** Paused time excluded. */
+ UPROPERTY()
+ float MatchTimeS = 0.f;
+
+ UPROPERTY()
+ FVerseSetLine Person;
+
+ UPROPERTY()
+ FVerseSetLine Opponent;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Combat/VerseGadgetDefinition.h b/unreal/Verse/Source/VerseCore/Public/Combat/VerseGadgetDefinition.h
new file mode 100644
index 0000000000..25f58c6e3d
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Combat/VerseGadgetDefinition.h
@@ -0,0 +1,77 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Engine/DataAsset.h"
+
+#include "VerseGadgetDefinition.generated.h"
+
+/**
+ * One gadget (combat-state.md 2.3): DA_Gadget_Bulwark, DA_Gadget_BreachCharge; text surface
+ * unreal/Verse/Data/weapons/gadgets.json. Fields frozen; the defaults are the Bulwark start values.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseGadgetDefinition : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ /** bulwark, breach_charge */
+ UPROPERTY(EditDefaultsOnly, Category = "Identity")
+ FName GadgetId;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Identity")
+ FText DisplayName;
+
+ /** Per life. */
+ UPROPERTY(EditDefaultsOnly, Category = "Use")
+ int32 Charges = 1;
+
+ /** After the actor is gone. */
+ UPROPERTY(EditDefaultsOnly, Category = "Use", meta = (Units = "s"))
+ float Cooldown = 20.f;
+
+ /** Deploy or plant, interruptible by taking damage. */
+ UPROPERTY(EditDefaultsOnly, Category = "Use", meta = (Units = "s"))
+ float UseTime = 0.6f;
+
+ /** Bulwark lifetime, or the breach charge fuse after the plant completes. */
+ UPROPERTY(EditDefaultsOnly, Category = "Use", meta = (Units = "s"))
+ float Lifetime = 25.f;
+
+ /** From the eye. */
+ UPROPERTY(EditDefaultsOnly, Category = "Use", meta = (Units = "m"))
+ float PlaceRange = 1.5f;
+
+ /** hp; unused by the breach charge (it cannot be shot). */
+ UPROPERTY(EditDefaultsOnly, Category = "Body")
+ float MaxHealth = 400.f;
+
+ /** w x h x d */
+ UPROPERTY(EditDefaultsOnly, Category = "Body", meta = (Units = "m"))
+ FVector3f Size = FVector3f(1.8f, 1.4f, 0.1f);
+
+ /** hp at the centre, linear falloff to 0 at PawnRadius. */
+ UPROPERTY(EditDefaultsOnly, Category = "Damage")
+ float PawnDamage = 0.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Damage", meta = (Units = "m"))
+ float PawnRadius = 0.f;
+
+ /** destruction.md 3.2 */
+ UPROPERTY(EditDefaultsOnly, Category = "Damage", meta = (Units = "cm"))
+ float PieceBreachRadius = 0.f;
+
+ /** The owner takes the same damage. */
+ UPROPERTY(EditDefaultsOnly, Category = "Damage")
+ bool bSelfDamage = false;
+
+ /** The falloff of 2.3: PawnDamage x (1 - r / PawnRadius), 0 at and beyond PawnRadius. */
+ float PawnDamageAt(float DistanceM) const
+ {
+ if (PawnRadius <= 0.f || DistanceM >= PawnRadius)
+ {
+ return 0.f;
+ }
+ return PawnDamage * (1.f - FMath::Max(0.f, DistanceM) / PawnRadius);
+ }
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Combat/VerseMeleeDefinition.h b/unreal/Verse/Source/VerseCore/Public/Combat/VerseMeleeDefinition.h
new file mode 100644
index 0000000000..2e6844aed6
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Combat/VerseMeleeDefinition.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Engine/DataAsset.h"
+
+#include "VerseMeleeDefinition.generated.h"
+
+/** The knife strike and the finisher geometry (combat-state.md 7). Fields frozen; values are start values. */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseMeleeDefinition : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ /** Not a one-shot: two strikes kill. */
+ UPROPERTY(EditDefaultsOnly, Category = "Strike")
+ float StrikeDamage = 55.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Strike", meta = (Units = "s"))
+ float StrikeHitDelay = 0.15f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Strike", meta = (Units = "s"))
+ float StrikeCooldown = 0.7f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Strike", meta = (Units = "m"))
+ float StrikeRange = 2.f;
+
+ /** deg */
+ UPROPERTY(EditDefaultsOnly, Category = "Strike")
+ float StrikeConeHalfAngle = 30.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Finisher", meta = (Units = "m"))
+ float FinisherRange = 1.5f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Finisher", meta = (Units = "m"))
+ float FinisherMaxHeightDelta = 0.6f;
+
+ /** theta at or below this is Front (deg); Back starts at 180 minus this. */
+ UPROPERTY(EditDefaultsOnly, Category = "Finisher")
+ float FrontHalfAngle = 60.f;
+
+ /** phi limit (deg): the attacker must look at the victim. */
+ UPROPERTY(EditDefaultsOnly, Category = "Finisher")
+ float AttackerFacingMax = 45.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Finisher", meta = (Units = "s"))
+ float FinisherDuration = 2.5f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Finisher", meta = (Units = "s"))
+ float FinisherKillTime = 2.1f;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Combat/VerseWeaponDefinition.h b/unreal/Verse/Source/VerseCore/Public/Combat/VerseWeaponDefinition.h
new file mode 100644
index 0000000000..b3c19b6c30
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Combat/VerseWeaponDefinition.h
@@ -0,0 +1,219 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+#include "Curves/CurveFloat.h"
+#include "Engine/DataAsset.h"
+
+#include "VerseWeaponDefinition.generated.h"
+
+/**
+ * One firearm (combat-state.md 3), one asset per weapon (DA_Weapon_<Name>). The JSON export in
+ * unreal/Verse/Data/weapons/ is the merge surface. Field names, types and units are frozen;
+ * the defaults below are placeholders, the start values live in the data.
+ * Data units: metres, m/s, seconds, degrees.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseWeaponDefinition : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ /** The contract cap on pieces a bolt may pass (destruction.md 2). */
+ static constexpr int32 MaxPenetrationsCap = 3;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Identity")
+ FName WeaponId;
+
+ /** Fictional name only. */
+ UPROPERTY(EditDefaultsOnly, Category = "Identity")
+ FText DisplayName;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Identity")
+ EVerseLoadoutSlot Slot = EVerseLoadoutSlot::Primary;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Fire")
+ EVerseFireMode FireMode = EVerseFireMode::Auto;
+
+ /** Rounds per burst (Burst only). */
+ UPROPERTY(EditDefaultsOnly, Category = "Fire")
+ int32 BurstCount = 3;
+
+ /** Cyclic rate, rounds per minute. */
+ UPROPERTY(EditDefaultsOnly, Category = "Fire")
+ float RPM = 600.f;
+
+ /** Rounds in a full magazine, not counting the chamber. */
+ UPROPERTY(EditDefaultsOnly, Category = "Ammo")
+ int32 MagazineSize = 30;
+
+ /** True: a tactical reload keeps one round chambered (magazine + 1). */
+ UPROPERTY(EditDefaultsOnly, Category = "Ammo")
+ bool bClosedBolt = true;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Ammo")
+ int32 ReserveRounds = 90;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Ammo", meta = (Units = "s"))
+ float ReloadTactical = 2.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Ammo", meta = (Units = "s"))
+ float ReloadEmpty = 2.7f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Ammo", meta = (ClampMin = "0", ClampMax = "1"))
+ float ReloadCommitFraction = 0.6f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Handling", meta = (Units = "s"))
+ float EquipTime = 0.5f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Handling", meta = (Units = "s"))
+ float HolsterTime = 0.3f;
+
+ /** Body damage at full range, hp. */
+ UPROPERTY(EditDefaultsOnly, Category = "Damage")
+ float BaseDamage = 25.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Damage")
+ TMap<EVerseHitZone, float> ZoneMultipliers;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Damage", meta = (Units = "m"))
+ float FalloffStart = 20.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Damage", meta = (Units = "m"))
+ float FalloffEnd = 40.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Damage", meta = (ClampMin = "0", ClampMax = "1"))
+ float FalloffMinFraction = 0.7f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Projectile", meta = (Units = "m/s"))
+ float ProjectileSpeed = 300.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Projectile", meta = (Units = "m"))
+ float MaxRange = 150.f;
+
+ /** Power units, 100 = assault rifle (destruction.md 2). */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ float PenetrationPower = 100.f;
+
+ /** Clamped to MaxPenetrationsCap. */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration", meta = (ClampMin = "0", ClampMax = "3"))
+ int32 MaxPenetrations = 3;
+
+ /** Piece hp per hit; anchor 10 for the rifle (destruction.md 3.2). */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ float PieceDamage = 10.f;
+
+ /** Bolt hole radius, mm; anchor 15 for the rifle (destruction.md 5). */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ uint8 HoleRadiusMm = 15;
+
+ /** x = shot index, y = deg: the learnable pattern P_p(n); beyond the last key the value holds. */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil")
+ FRuntimeFloatCurve RecoilPitchCurve;
+
+ /** x = shot index, y = deg: P_y(n). */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil")
+ FRuntimeFloatCurve RecoilYawCurve;
+
+ /** f */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil", meta = (ClampMin = "0", ClampMax = "1"))
+ float RecoilRandomFraction = 0.15f;
+
+ /** t_k */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil", meta = (Units = "s"))
+ float RecoilKickTime = 0.035f;
+
+ /** rho, deg/s */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil")
+ float RecoilRecoveryRate = 5.f;
+
+ /** d_r */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil", meta = (Units = "s"))
+ float RecoilRecoveryDelay = 0.12f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil", meta = (Units = "s"))
+ float PatternResetTime = 0.35f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil")
+ TMap<EVerseStance, float> RecoilStanceMultiplier;
+
+ /** Applied at full ADS blend. */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil")
+ float RecoilAdsMultiplier = 0.8f;
+
+ /** Visual-only camera shake per shot; never moves the aim. */
+ UPROPERTY(EditDefaultsOnly, Category = "Recoil")
+ float ViewPunchScale = 1.f;
+
+ /** Hip to full ADS. */
+ UPROPERTY(EditDefaultsOnly, Category = "Aim", meta = (Units = "s"))
+ float AdsTime = 0.25f;
+
+ /** First-person FOV at full ADS, deg. */
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AdsFov = 60.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Aim")
+ float AdsMoveSpeedMultiplier = 0.6f;
+
+ /** Cone half-angle at rest per stance: X = hip, Y = ADS, deg. */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ TMap<EVerseStance, FVector2f> SpreadBase;
+
+ /** Hip, ADS, deg. */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ FVector2f FirstShotSpread = FVector2f::ZeroVector;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Spread", meta = (Units = "s"))
+ float FirstShotRestTime = 0.3f;
+
+ /** deg per m/s of horizontal speed */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ float SpreadMovePerMps = 0.2f;
+
+ /** deg */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ float SpreadAirborne = 3.f;
+
+ /** deg */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ float BloomPerShot = 0.15f;
+
+ /** deg */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ float BloomMax = 2.f;
+
+ /** deg/s */
+ UPROPERTY(EditDefaultsOnly, Category = "Spread")
+ float BloomRecoveryRate = 4.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Spread", meta = (Units = "s"))
+ float BloomRecoveryDelay = 0.1f;
+
+ /** 0..1, used for the bot's hearing (FVerseNoiseEvent). */
+ UPROPERTY(EditDefaultsOnly, Category = "Noise", meta = (ClampMin = "0", ClampMax = "1"))
+ float NoiseLoudness = 1.f;
+
+ /** Presentation tag for the own bolt (amber, README). */
+ UPROPERTY(EditDefaultsOnly, Category = "Presentation")
+ FGameplayTag BoltColorOwn;
+
+ /** Presentation tag for the opponent bolt (red, README). */
+ UPROPERTY(EditDefaultsOnly, Category = "Presentation")
+ FGameplayTag BoltColorFoe;
+
+ float FireInterval() const { return 60.f / RPM; }
+
+ /** MaxPenetrations clamped to the contract cap of 3. */
+ int32 GetEffectiveMaxPenetrations() const { return FMath::Clamp(MaxPenetrations, 0, MaxPenetrationsCap); }
+
+ /** The pattern P(n) = (P_p(n), P_y(n)) in degrees; beyond the curve end the last value holds. */
+ FVector2f PatternAt(int32 ShotIndex) const;
+
+ /**
+ * R1 as code (combat-state.md 4.3); the harness calls it for every asset. For every shot index
+ * 1 <= n <= MaxShot: rho * max(0, FireInterval - d_r) <= 0.5 * k_min_p with
+ * k_min_p = min_n MinMultiplier * (P_p(n) - f * |P(n)|).
+ */
+ bool SatisfiesRecoveryBelowKick(float MinMultiplier, int32 MaxShot) const;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionInterfaces.h b/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionInterfaces.h
new file mode 100644
index 0000000000..373d0a5420
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionInterfaces.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Destruction/VerseDestructionTypes.h"
+#include "UObject/Interface.h"
+
+#include "VerseDestructionInterfaces.generated.h"
+
+// The destruction query and damage interfaces (destruction.md frozen interface). Declared in
+// Core so Combat, Bot and the harness code against them before VerseDestruction lands; the
+// null stubs are in Stubs/VerseNullStubs.h. VerseDestruction implements them for real.
+// Native only: Blueprints never implement them.
+
+UINTERFACE(MinimalAPI, meta = (CannotImplementInterfaceInBlueprint))
+class UVersePenetrationQuery : public UInterface
+{
+ GENERATED_BODY()
+};
+
+class VERSECORE_API IVersePenetrationQuery
+{
+ GENERATED_BODY()
+
+public:
+ /**
+ * Every piece the bolt segment enters, in order, against the current-state proxies.
+ * Origin and Dir in world cm; MaxDist in cm; Power and Damage at the segment start;
+ * MaxPieces <= 3. Holes are honoured (destruction.md 5).
+ */
+ virtual TArray<FVersePenetrationHit> TraceBolt(const FVector& Origin, const FVector& Dir, float MaxDist,
+ float Power, float Damage, uint8 RadiusMm, int32 MaxPieces) const = 0;
+
+ /** Sight from Eye to Target on VerseSight: holes honoured, intact glass and grating see-through. */
+ virtual bool TestSight(const FVector& Eye, const FVector& Target) const = 0;
+};
+
+/**
+ * A plain native interface, not a UINTERFACE: its reflected twin UVersePieceDamage would share
+ * the engine name of the frozen struct FVersePieceDamage. Implementers hand it out directly.
+ */
+class VERSECORE_API IVersePieceDamage
+{
+public:
+ virtual ~IVersePieceDamage() = default;
+
+ /** Server only (DR1). */
+ virtual void ApplyPieceDamage(const FVersePieceDamage& Damage) = 0;
+};
+
+UINTERFACE(MinimalAPI, meta = (CannotImplementInterfaceInBlueprint))
+class UVersePieceQuery : public UInterface
+{
+ GENERATED_BODY()
+};
+
+/** Piece truth. The bot uses it only behind its perception gate (DR6, bot.md F1). */
+class VERSECORE_API IVersePieceQuery
+{
+ GENERATED_BODY()
+
+public:
+ virtual EVersePieceState GetPieceState(uint16 PieceIndex) const = 0;
+ virtual EVersePenetrationMaterial GetPieceMaterial(uint16 PieceIndex) const = 0;
+ /** World bounds of the current proxy; an invalid box for an unknown piece. */
+ virtual FBox GetPieceBounds(uint16 PieceIndex) const = 0;
+ virtual TArray<uint16> GetPiecesInBox(const FBox& WorldBox) const = 0;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionTuning.h b/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionTuning.h
new file mode 100644
index 0000000000..8ee7fc7835
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionTuning.h
@@ -0,0 +1,143 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Destruction/VerseDestructionTypes.h"
+#include "Engine/DataAsset.h"
+
+#include "VerseDestructionTuning.generated.h"
+
+/** One row of the piece class table (destruction.md 3.2). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePieceClassTuning
+{
+ GENERATED_BODY()
+
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ EVersePenetrationMaterial Material = EVersePenetrationMaterial::SheetMetal;
+
+ /** 0 = the class has no HP (catwalk: breach charge only). */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ float MaxHp = 0.f;
+
+ /** Bullets move Intact to Damaged on the first hit. */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ bool bDamagedOnFirstHit = true;
+
+ /** Bullets move to Holed at or below this HP; negative = never Holed by bullets. */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ float HoledAtOrBelowHp = -1.f;
+
+ /** A breach charge moves the target to Breached (walls). */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ bool bBreachedByCharge = false;
+
+ /** HP 0 moves to Destroyed (glass, ceiling). */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ bool bDestroyedAtZeroHp = false;
+
+ /** A breach charge moves the target to Destroyed (glass, catwalk, ceiling). */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ bool bDestroyedByCharge = false;
+
+ /** Melee on a Damaged piece destroys it (glass only). */
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction")
+ bool bDestroyedByMeleeWhenDamaged = false;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Destruction", meta = (Units = "s"))
+ float RepairTimeS = 8.f;
+};
+
+/**
+ * DA_DestructionTuning: the thresholds, HP, times and budgets of destruction.md 3, 5, 7 and 10.
+ * Fields frozen; values retune only through the contract's change rule. A new asset starts
+ * with the contract values.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseDestructionTuning : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ UVerseDestructionTuning();
+
+ UPROPERTY(EditDefaultsOnly, Category = "Classes")
+ TMap<EVersePieceClass, FVersePieceClassTuning> Classes;
+
+ /** Other breakable pieces within this distance of a detonation go Holed or Destroyed (3.2). */
+ UPROPERTY(EditDefaultsOnly, Category = "Breach", meta = (Units = "cm"))
+ float BreachSideRadiusCm = 150.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Holes")
+ int32 HolesPerPiece = 24;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Holes")
+ int32 HolesPerArena = 512;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Holes")
+ int32 GlowingHolesMax = 128;
+
+ /** Exponential cooling time constant of a hole rim. */
+ UPROPERTY(EditDefaultsOnly, Category = "Holes", meta = (Units = "s"))
+ float HoleGlowTauS = 1.2f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Holes", meta = (Units = "s"))
+ float HoleGlowEndS = 4.f;
+
+ /** After the last state-changing or hole-making damage. */
+ UPROPERTY(EditDefaultsOnly, Category = "Repair", meta = (Units = "s"))
+ float RepairDelayS = 60.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Repair")
+ int32 MaxActiveDrones = 3;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Repair")
+ float DroneMaxHp = 30.f;
+
+ /** Completion waits while a pawn overlaps the Intact proxy bounds plus this. */
+ UPROPERTY(EditDefaultsOnly, Category = "Repair", meta = (Units = "cm"))
+ float RepairEncroachMarginCm = 10.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Repair", meta = (Units = "s"))
+ float RepairEncroachRecheckS = 0.5f;
+
+ /** Old and new proxy bounds grow by this when marking nav tiles dirty (6.1). */
+ UPROPERTY(EditDefaultsOnly, Category = "Nav", meta = (Units = "cm"))
+ float NavDirtyMarginCm = 50.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Nav")
+ int32 NavMaxTilesInFlight = 4;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget")
+ int32 MaxDebrisBodiesHigh = 400;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget")
+ int32 MaxDebrisBodiesLow = 150;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget")
+ int32 MaxBodiesPerFracture = 40;
+
+ /** Fragments smaller than this are Niagara particles, not rigid bodies. */
+ UPROPERTY(EditDefaultsOnly, Category = "Budget", meta = (Units = "cm"))
+ float MinRigidFragmentCm = 5.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget", meta = (Units = "s"))
+ float DebrisSleepS = 3.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget", meta = (Units = "s"))
+ float DebrisDespawnHighS = 10.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget", meta = (Units = "s"))
+ float DebrisDespawnLowS = 6.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget", meta = (Units = "s"))
+ float DebrisFadeS = 0.3f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget")
+ int32 MaxGeometryCollectionActors = 32;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Budget")
+ int32 MaxFractureEventsPerSecond = 64;
+
+ /** The class table of destruction.md 3.2. */
+ static TMap<EVersePieceClass, FVersePieceClassTuning> MakeContractClasses();
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionTypes.h b/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionTypes.h
new file mode 100644
index 0000000000..2dc6f24f54
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Destruction/VerseDestructionTypes.h
@@ -0,0 +1,271 @@
+#pragma once
+
+#include "CoreMinimal.h"
+
+#include "VerseDestructionTypes.generated.h"
+
+// Shared destruction types (contracts/destruction.md). Values and order of every enum are
+// frozen; new materials append. Units: centimetres, Z-up, server time in milliseconds.
+
+/** destruction.md 3.1 */
+UENUM(BlueprintType)
+enum class EVersePieceState : uint8
+{
+ Intact,
+ Damaged,
+ Holed,
+ Breached,
+ Destroyed,
+ Repairing
+};
+
+/** Material wire ids of DA_PenetrationTable (destruction.md 2), in wire order. */
+UENUM(BlueprintType)
+enum class EVersePenetrationMaterial : uint8
+{
+ SheetMetal,
+ ContainerWall,
+ Glass,
+ CladdingPanel,
+ CatwalkGrating,
+ CeilingPanel,
+ Concrete,
+ ArmorSteel
+};
+
+/** Debris type column of the penetration table. */
+UENUM(BlueprintType)
+enum class EVerseDebrisType : uint8
+{
+ MetalShards,
+ CorrugatedChunks,
+ GlassShards,
+ PanelChunks,
+ GratingTwisted,
+ CeilingTile,
+ DustChips,
+ SparksOnly
+};
+
+/** FVerseFractureEvent::Cause and FVersePieceDamage::Cause (destruction.md 4). */
+UENUM(BlueprintType)
+enum class EVerseFractureCause : uint8
+{
+ Bolt,
+ Breach,
+ Melee,
+ Repair,
+ Reset
+};
+
+/** Piece classes of destruction.md 3.2. */
+UENUM(BlueprintType)
+enum class EVersePieceClass : uint8
+{
+ WallPanel,
+ CladdingWall,
+ ContainerWall,
+ GlassPane,
+ CatwalkSegment,
+ CeilingPanel
+};
+
+/** Which destruction change made a Noise.Fracture (destruction.md 6.2). */
+UENUM(BlueprintType)
+enum class EVerseFractureNoise : uint8
+{
+ Breach,
+ WallBreak,
+ Glass,
+ Tile,
+ BoltHole
+};
+
+namespace Verse::Destruction
+{
+ /** PieceIndex meaning "all pieces" (reset only). */
+ inline constexpr uint16 AllPieces = 0xFFFF;
+ /** Instigator slot meaning "world" (repair, reset). */
+ inline constexpr uint8 WorldInstigator = 0xFF;
+ /** One unit of Impulse is 0.1 N s. */
+ inline constexpr double ImpulseUnitNs = 0.1;
+ /** A bolt passes at most this many pieces (destruction.md 2). */
+ inline constexpr int32 MaxPenetrations = 3;
+ /** Audible range of a fracture is loudness x this (bot.md 3.2). */
+ inline constexpr float FractureRangePerLoudnessM = 40.f;
+ /** Repair drone flight and weld loudness (destruction.md 7). */
+ inline constexpr float DroneLoudness = 0.15f;
+
+ /** Loudness carried in FVerseNoiseEvent for Noise.Fracture (destruction.md 6.2). */
+ VERSECORE_API float FractureLoudness(EVerseFractureNoise Kind);
+
+ /** HealthQ = round(255 x hp / maxHp), clamped to 0..255 (destruction.md 3.2). */
+ VERSECORE_API uint8 QuantizeHealth(float Hp, float MaxHp);
+
+ /** Octahedral encoding of a unit direction into two int8 (FVerseBoltHole axis). */
+ VERSECORE_API void EncodeOctahedral(const FVector& Direction, int8& OutX, int8& OutY);
+ VERSECORE_API FVector DecodeOctahedral(int8 X, int8 Y);
+}
+
+/** Replicated and hub-published on every state change, repair and reset (destruction.md 4). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseFractureEvent
+{
+ GENERATED_BODY()
+
+ /** 0xFFFF = all pieces (reset only). */
+ UPROPERTY()
+ uint16 PieceIndex = 0;
+
+ UPROPERTY()
+ EVersePieceState FromState = EVersePieceState::Intact;
+
+ UPROPERTY()
+ EVersePieceState ToState = EVersePieceState::Intact;
+
+ UPROPERTY()
+ EVerseFractureCause Cause = EVerseFractureCause::Bolt;
+
+ /** Chosen proxy variant. */
+ UPROPERTY()
+ uint8 Variant = 0;
+
+ /** Server RNG draw; drives the Chaos strain pattern and Niagara seeds. */
+ UPROPERTY()
+ uint32 Seed = 0;
+
+ /** World space, 0.1 N s per unit. */
+ UPROPERTY()
+ int16 Impulse[3] = {0, 0, 0};
+
+ /** Piece-local, 1 mm; impact or charge point. */
+ UPROPERTY()
+ int16 Location[3] = {0, 0, 0};
+
+ /** Strain field radius, cm. */
+ UPROPERTY()
+ uint8 Radius = 0;
+
+ /** Player slot, 0xFF = world (repair, reset). */
+ UPROPERTY()
+ uint8 Instigator = Verse::Destruction::WorldInstigator;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+
+ /** Events with an old epoch are dropped. */
+ UPROPERTY()
+ uint16 Epoch = 0;
+};
+
+/** One bolt hole (destruction.md 5), about 16 bytes. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseBoltHole
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint16 PieceIndex = 0;
+
+ /** Axis position, piece-local, 1 mm. */
+ UPROPERTY()
+ int16 AxisPositionMm[3] = {0, 0, 0};
+
+ /** Axis direction, octahedral. */
+ UPROPERTY()
+ int8 AxisDirectionOct[2] = {0, 0};
+
+ UPROPERTY()
+ uint8 RadiusMm = 0;
+
+ UPROPERTY()
+ uint32 ServerTimeMs = 0;
+
+ UPROPERTY()
+ uint16 Epoch = 0;
+
+ /** Axis point in piece-local centimetres. */
+ FVector GetAxisPointCm() const;
+ /** Unit axis direction, piece-local. */
+ FVector GetAxisDirection() const;
+ /** True if the piece-local point (cm) lies within RadiusMm of the hole axis. */
+ bool ContainsPoint(const FVector& PieceLocalCm) const;
+
+ /** Builds a record from piece-local centimetres and a direction (quantised to mm and octahedral int8). */
+ static FVerseBoltHole Make(uint16 InPieceIndex, const FVector& AxisPointCm, const FVector& AxisDirection,
+ uint8 InRadiusMm, uint32 InServerTimeMs, uint16 InEpoch);
+
+ /**
+ * The two-point sightline test (destruction.md 5): a sight or bolt ray through a piece passes
+ * only if both its entry and exit points lie within the radius of one hole's axis. Server and
+ * bot use exactly this test.
+ */
+ static bool RayPassesHoles(TConstArrayView<FVerseBoltHole> Holes, const FVector& EntryLocalCm, const FVector& ExitLocalCm);
+};
+
+/** One server piece damage request (IVersePieceDamage::ApplyPieceDamage, destruction.md frozen interface). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePieceDamage
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint16 PieceIndex = 0;
+
+ /** Piece hp. */
+ UPROPERTY()
+ float Amount = 0.f;
+
+ /** Bolt, Breach or Melee. */
+ UPROPERTY()
+ EVerseFractureCause Cause = EVerseFractureCause::Bolt;
+
+ /** World, cm. */
+ UPROPERTY()
+ FVector Location = FVector::ZeroVector;
+
+ UPROPERTY()
+ FVector Direction = FVector::ForwardVector;
+
+ /** Player state id, -1 = world. */
+ UPROPERTY()
+ int32 InstigatorId = -1;
+
+ /** Breach charge radius, cm (0 for bolts and melee). */
+ UPROPERTY()
+ float BreachRadiusCm = 0.f;
+};
+
+/** One piece a bolt trace entered (IVersePenetrationQuery::TraceBolt). */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePenetrationHit
+{
+ GENERATED_BODY()
+
+ UPROPERTY()
+ uint16 PieceIndex = 0;
+
+ UPROPERTY()
+ uint8 MaterialWireId = 0;
+
+ /** World, cm. */
+ UPROPERTY()
+ FVector Entry = FVector::ZeroVector;
+
+ UPROPERTY()
+ FVector Exit = FVector::ZeroVector;
+
+ UPROPERTY()
+ float TracedThicknessCm = 0.f;
+
+ /** Power left after this piece. */
+ UPROPERTY()
+ float PowerLeft = 0.f;
+
+ /** Damage left after this piece. */
+ UPROPERTY()
+ float DamageLeft = 0.f;
+
+ UPROPERTY()
+ bool bPassed = false;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Destruction/VersePenetrationTable.h b/unreal/Verse/Source/VerseCore/Public/Destruction/VersePenetrationTable.h
new file mode 100644
index 0000000000..297a38caf2
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Destruction/VersePenetrationTable.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Destruction/VerseDestructionTypes.h"
+#include "Engine/DataAsset.h"
+#include "GameplayTagContainer.h"
+
+#include "VersePenetrationTable.generated.h"
+
+/** One material row of DA_PenetrationTable (destruction.md 2). Columns frozen. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVersePenetrationRow
+{
+ GENERATED_BODY()
+
+ /** Verse.Material.<id> */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ FGameplayTag MaterialTag;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ EVersePenetrationMaterial WireId = EVersePenetrationMaterial::SheetMetal;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration", meta = (Units = "cm"))
+ float RefThicknessCm = 1.f;
+
+ /** Power units at the reference thickness (100 = assault rifle). */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ float PenetrationCost = 0.f;
+
+ /** Damage multiplier after passing. */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration", meta = (ClampMin = "0", ClampMax = "1"))
+ float DamageMultiplier = 1.f;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ bool bBreakableByBullets = false;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ bool bBreakableByBreach = false;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ EVerseDebrisType DebrisType = EVerseDebrisType::SparksOnly;
+};
+
+/**
+ * DA_PenetrationTable (destruction.md 2): one row per material, indexed by wire id. The cost
+ * formula and the 3-piece limit are frozen; the numbers are retuned only through the contract's
+ * change rule. A new asset starts with the contract table.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVersePenetrationTable : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ UVersePenetrationTable();
+
+ /** Index = wire id. */
+ UPROPERTY(EditDefaultsOnly, Category = "Penetration")
+ TArray<FVersePenetrationRow> Rows;
+
+ /** The table of destruction.md 2, in wire order. */
+ static TArray<FVersePenetrationRow> MakeContractRows();
+
+ /** Row by wire id, nullptr when the id is unknown. */
+ const FVersePenetrationRow* FindRow(uint8 WireId) const;
+
+ /** cost x clamp(traced / ref, 0.5, 3.0) */
+ static float PassCost(const FVersePenetrationRow& Row, float TracedThicknessCm);
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Events/VerseEventHub.h b/unreal/Verse/Source/VerseCore/Public/Events/VerseEventHub.h
new file mode 100644
index 0000000000..11c7b4f362
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Events/VerseEventHub.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+#include "Destruction/VerseDestructionTypes.h"
+#include "Subsystems/WorldSubsystem.h"
+
+#include "VerseEventHub.generated.h"
+
+// The hub delegates of combat-state.md 11.1. All cross-module traffic that goes "up" the module
+// graph travels through these (architecture.md 2, rule 2): Combat never includes Gore, UI or
+// Bot; they subscribe. The hub only relays: it holds no state and never filters.
+
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseFire, const FVerseFireEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseHit, const FVerseHitEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVersePenetration, const FVersePenetrationEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseDeath, const FVerseDeathEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseFinisher, const FVerseFinisherEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseNoise, const FVerseNoiseEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseReload, const FVerseReloadEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseGadget, const FVerseGadgetEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseFracture, const FVerseFractureEvent&); // destruction 4
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseArenaSwitch, const FVerseArenaSwitchEvent&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseSetEnded, const FVerseSetSummary&);
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseStationUsed, const FVerseStationUsedEvent&);
+
+/** Core world subsystem; one per game world (server and each client). */
+UCLASS()
+class VERSECORE_API UVerseEventHub : public UWorldSubsystem
+{
+ GENERATED_BODY()
+
+public:
+ /** The hub of the object's world, or nullptr (no world, or a world type without subsystems). */
+ static UVerseEventHub* Get(const UObject* WorldContextObject);
+
+ FOnVerseFire OnFire;
+ FOnVerseHit OnHit;
+ FOnVersePenetration OnPenetration;
+ FOnVerseDeath OnDeath;
+ FOnVerseFinisher OnFinisher;
+ /** Server only; Bot listens. */
+ FOnVerseNoise OnNoise;
+ FOnVerseReload OnReload;
+ FOnVerseGadget OnGadget;
+ /** Server and clients. */
+ FOnVerseFracture OnFracture;
+ /** Decks raises; Combat rules, Destruction reset, Crew, Bot listen. */
+ FOnVerseArenaSwitch OnArenaSwitch;
+ /** Server; the Bridge duel reporter and the UI listen. */
+ FOnVerseSetEnded OnSetEnded;
+ /** Local; Decks raises, UI and Screens listen (no Decks -> UI include). */
+ FOnVerseStationUsed OnStationUsed;
+
+ virtual void Deinitialize() override;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Movement/VerseMovementQuery.h b/unreal/Verse/Source/VerseCore/Public/Movement/VerseMovementQuery.h
new file mode 100644
index 0000000000..f3a78276aa
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Movement/VerseMovementQuery.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+#include "UObject/Interface.h"
+
+#include "VerseMovementQuery.generated.h"
+
+UINTERFACE(MinimalAPI, meta = (CannotImplementInterfaceInBlueprint))
+class UVerseMovementQuery : public UInterface
+{
+ GENERATED_BODY()
+};
+
+/**
+ * Read-only movement state other modules see (combat-state.md 2.1; architecture 3.3: nothing
+ * else touches the CharacterMovementComponent). VerseMovement implements it on its movement
+ * component; Combat, Bot and the animation layer read it. Combat never writes stance.
+ */
+class VERSECORE_API IVerseMovementQuery
+{
+ GENERATED_BODY()
+
+public:
+ /** Lean is replicated as int8, -127..127 = -1..1; lean > 0 moves toward the pawn's right. */
+ static float LeanFromQuantized(int8 Quantized) { return float(Quantized) / 127.f; }
+ static int8 QuantizeLean(float Lean) { return int8(FMath::Clamp(FMath::RoundToInt(Lean * 127.f), -127, 127)); }
+
+ virtual EVerseStance GetStance() const = 0;
+ virtual bool IsSprinting() const = 0;
+ virtual bool IsAirborne() const = 0;
+ virtual bool IsMantling() const = 0;
+ /** -127..127 */
+ virtual int8 GetLeanQuantized() const = 0;
+ /** Mantling and sprinting block firing (combat-state.md 2.1). */
+ virtual bool BlocksFiring() const { return IsSprinting() || IsMantling(); }
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Noise/VerseAudibilityTable.h b/unreal/Verse/Source/VerseCore/Public/Noise/VerseAudibilityTable.h
new file mode 100644
index 0000000000..6843afc4e5
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Noise/VerseAudibilityTable.h
@@ -0,0 +1,62 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Engine/DataAsset.h"
+#include "GameplayTagContainer.h"
+
+#include "VerseAudibilityTable.generated.h"
+
+/** One noise row (bot.md 3.2): range and position error multiplier for one Noise.* tag. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseAudibilityRow
+{
+ GENERATED_BODY()
+
+ /** The Noise.* tag; the row key. */
+ UPROPERTY(EditDefaultsOnly, Category = "Audibility")
+ FGameplayTag Noise;
+
+ /** Audible range; ignored when bWholeArena. Multiplied by the event loudness when bRangeScalesWithLoudness. */
+ UPROPERTY(EditDefaultsOnly, Category = "Audibility", meta = (Units = "m"))
+ float RangeM = 0.f;
+
+ /** Heard anywhere in the arena. */
+ UPROPERTY(EditDefaultsOnly, Category = "Audibility")
+ bool bWholeArena = false;
+
+ /** Range = loudness x RangeM (Noise.Fracture, Noise.Drone: loudness x 40 m). */
+ UPROPERTY(EditDefaultsOnly, Category = "Audibility")
+ bool bRangeScalesWithLoudness = false;
+
+ /** Multiplier on the tier's hearing error sd (0 = exact, Noise.Impact). */
+ UPROPERTY(EditDefaultsOnly, Category = "Audibility")
+ float ErrorMultiplier = 1.f;
+};
+
+/**
+ * DA_Audibility (bot.md 3.2): one table drives the bot's hearing and the person's audio
+ * attenuation, so both hear the same world (fairness F6). A new asset starts with the
+ * contract table. Crouch walk, prone crawl and standing still raise no noise, so they have no row.
+ */
+UCLASS(BlueprintType)
+class VERSECORE_API UVerseAudibilityTable : public UPrimaryDataAsset
+{
+ GENERATED_BODY()
+
+public:
+ UVerseAudibilityTable();
+
+ UPROPERTY(EditDefaultsOnly, Category = "Audibility")
+ TArray<FVerseAudibilityRow> Rows;
+
+ /** The table of bot.md 3.2, one row per Noise.* tag in table order. */
+ static TArray<FVerseAudibilityRow> MakeContractRows();
+
+ const FVerseAudibilityRow* FindRow(const FGameplayTag& Noise) const;
+
+ /** Audible range in metres for an event; a very large value for whole-arena rows; 0 for an unknown tag. */
+ float GetAudibleRangeM(const FGameplayTag& Noise, float Loudness) const;
+
+ /** Range used for whole-arena rows (larger than any deck). */
+ static constexpr float WholeArenaRangeM = 100000.f;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Qa/VerseQaRegistry.h b/unreal/Verse/Source/VerseCore/Public/Qa/VerseQaRegistry.h
new file mode 100644
index 0000000000..74685b1380
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Qa/VerseQaRegistry.h
@@ -0,0 +1,68 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Subsystems/EngineSubsystem.h"
+
+#include "VerseQaRegistry.generated.h"
+
+class IConsoleObject;
+
+/**
+ * A Verse.QA.* command handler: arguments after the command name in, a JSON result string out.
+ * Handlers return a JSON object; on bad input they return {"error": "..."}.
+ */
+using FVerseQaHandler = TFunction<FString(const TArray<FString>& Args)>;
+
+/**
+ * The registry of the Verse.QA.* commands of parity.md section 19 (work-packages.md 0.2). Each
+ * package registers the commands of its own area from its own Private/QA/ folder; WP17 reaches
+ * them in Shipping through the qa.exec bridge frame (bridge-protocol.md 14) via Execute.
+ * In non-Shipping builds every registered command is also a console command of the same name.
+ */
+UCLASS()
+class VERSECORE_API UVerseQaRegistry : public UEngineSubsystem
+{
+ GENERATED_BODY()
+
+public:
+ /** Every command name parity.md 19 freezes, in table order. */
+ static TConstArrayView<FString> KnownCommands();
+
+ /** Required prefix of every command name. */
+ static const TCHAR* CommandPrefix() { return TEXT("Verse.QA."); }
+
+ /** The registry of the running engine, or nullptr before the engine exists. */
+ static UVerseQaRegistry* Get();
+
+ /**
+ * Registers a handler. Fails (false, logged) when the name lacks the Verse.QA. prefix, is
+ * already registered, or the handler is unset.
+ */
+ bool Register(const FString& Command, const FString& Help, FVerseQaHandler Handler);
+
+ /** Removes a command; false when it was not registered. */
+ bool Unregister(const FString& Command);
+
+ bool IsRegistered(const FString& Command) const;
+
+ /** Registered names, sorted. */
+ TArray<FString> GetRegisteredCommands() const;
+
+ /** Runs a command; false (OutResult = an error JSON) when it is not registered. */
+ bool Execute(const FString& Command, const TArray<FString>& Args, FString& OutResult) const;
+
+ /** Runs "Verse.QA.Name arg1 arg2" (whitespace separated, quotes keep spaces). */
+ bool ExecuteLine(const FString& Line, FString& OutResult) const;
+
+ virtual void Deinitialize() override;
+
+private:
+ struct FEntry
+ {
+ FString Help;
+ FVerseQaHandler Handler;
+ IConsoleObject* ConsoleObject = nullptr;
+ };
+
+ TMap<FString, FEntry> Commands;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/Stubs/VerseNullStubs.h b/unreal/Verse/Source/VerseCore/Public/Stubs/VerseNullStubs.h
new file mode 100644
index 0000000000..7967cf76bd
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/Stubs/VerseNullStubs.h
@@ -0,0 +1,63 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Destruction/VerseDestructionInterfaces.h"
+#include "Movement/VerseMovementQuery.h"
+#include "UObject/Object.h"
+
+#include "VerseNullStubs.generated.h"
+
+// Null implementations of every contract interface (orchestration.md 0.3, work-packages.md 0.3),
+// so every package builds and tests from day one. They describe an empty world: no pieces,
+// nothing blocks sight, a pawn that stands still. Stateless; GetDefault<UVerseNull...>() is a
+// valid instance. A package that needs richer behaviour writes its own FFake<Interface> under
+// Private/Tests/<Area>/Fakes/. Verse.Contract.Stubs.* pins these answers.
+
+/** No pieces: TraceBolt enters nothing, TestSight is always clear. */
+UCLASS()
+class VERSECORE_API UVerseNullPenetrationQuery : public UObject, public IVersePenetrationQuery
+{
+ GENERATED_BODY()
+
+public:
+ virtual TArray<FVersePenetrationHit> TraceBolt(const FVector& Origin, const FVector& Dir, float MaxDist,
+ float Power, float Damage, uint8 RadiusMm, int32 MaxPieces) const override;
+ virtual bool TestSight(const FVector& Eye, const FVector& Target) const override;
+};
+
+/** Ignores every damage request. */
+UCLASS()
+class VERSECORE_API UVerseNullPieceDamage : public UObject, public IVersePieceDamage
+{
+ GENERATED_BODY()
+
+public:
+ virtual void ApplyPieceDamage(const FVersePieceDamage& Damage) override;
+};
+
+/** No pieces: every index answers Intact, concrete, an invalid box; no piece is in any box. */
+UCLASS()
+class VERSECORE_API UVerseNullPieceQuery : public UObject, public IVersePieceQuery
+{
+ GENERATED_BODY()
+
+public:
+ virtual EVersePieceState GetPieceState(uint16 PieceIndex) const override;
+ virtual EVersePenetrationMaterial GetPieceMaterial(uint16 PieceIndex) const override;
+ virtual FBox GetPieceBounds(uint16 PieceIndex) const override;
+ virtual TArray<uint16> GetPiecesInBox(const FBox& WorldBox) const override;
+};
+
+/** Standing, grounded, not sprinting, not mantling, no lean. */
+UCLASS()
+class VERSECORE_API UVerseNullMovementQuery : public UObject, public IVerseMovementQuery
+{
+ GENERATED_BODY()
+
+public:
+ virtual EVerseStance GetStance() const override;
+ virtual bool IsSprinting() const override;
+ virtual bool IsAirborne() const override;
+ virtual bool IsMantling() const override;
+ virtual int8 GetLeanQuantized() const override;
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/VerseCoords.h b/unreal/Verse/Source/VerseCore/Public/VerseCoords.h
new file mode 100644
index 0000000000..3bcbe6d30c
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/VerseCoords.h
@@ -0,0 +1,101 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Kismet/BlueprintFunctionLibrary.h"
+
+#include "VerseCoords.generated.h"
+
+// The one conversion between the three.js Verse frame (T: metres, right-handed, +Y up,
+// yaw 0 faces +Z) and the Unreal frame (U: centimetres, left-handed, +Z up, yaw 0 faces +X).
+// Frozen by docs/verse/unreal/contracts/coordinates.md; nothing else re-derives the mapping.
+
+/** A point or vector in the three.js Verse frame: metres, +Y up, +Z toward the plate camera.
+ * A distinct type so a metre value can never be passed where an Unreal FVector is expected. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseThreeVector
+{
+ GENERATED_BODY()
+
+ FVerseThreeVector() = default;
+ FVerseThreeVector(double InX, double InY, double InZ) : X(InX), Y(InY), Z(InZ) {}
+
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Verse|Coords")
+ double X = 0.0;
+
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Verse|Coords")
+ double Y = 0.0;
+
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Verse|Coords")
+ double Z = 0.0;
+};
+
+/** A deck's world placement: translation only, in centimetres. Owned by VerseDecks. */
+USTRUCT(BlueprintType)
+struct VERSECORE_API FVerseDeckFrame
+{
+ GENERATED_BODY()
+
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Verse|Coords")
+ FVector OriginCm = FVector::ZeroVector;
+
+ static FVerseDeckFrame Local() { return FVerseDeckFrame(); }
+};
+
+namespace Verse::Coords
+{
+ inline constexpr double CmPerMetre = 100.0;
+
+ // Scalars
+ VERSECORE_API double MetresToCm(double Metres);
+ VERSECORE_API double CmToMetres(double Cm);
+
+ // Points (scaled and offset) and directions (swapped only)
+ VERSECORE_API FVector ToUnrealPosition(const FVerseThreeVector& P, const FVerseDeckFrame& Deck = FVerseDeckFrame::Local());
+ VERSECORE_API FVerseThreeVector ToThreePosition(const FVector& PCm, const FVerseDeckFrame& Deck = FVerseDeckFrame::Local());
+ VERSECORE_API FVector ToUnrealDirection(const FVerseThreeVector& D);
+ VERSECORE_API FVerseThreeVector ToThreeDirection(const FVector& D);
+ VERSECORE_API FBox ToUnrealBox(double X0, double X1, double Y0, double Y1, double Z0, double Z1,
+ const FVerseDeckFrame& Deck = FVerseDeckFrame::Local());
+
+ // Heading (gameplay forward, +X)
+ VERSECORE_API double ToUnrealHeadingDeg(double ThreeYawRad); // Normalize(90 - deg(yaw))
+ VERSECORE_API double ToUnrealHeadingDegFromDeg(double ThreeYawDeg); // manifest yaw_deg
+ VERSECORE_API double ToThreeYawRad(double UnrealYawDeg); // WrapPi(rad(90 - yaw))
+ VERSECORE_API double ToUnrealYawRateDeg(double ThreeYawRateRad); // sign flips
+ VERSECORE_API FRotator ToUnrealViewRotation(double ThreeYawRad, double ThreePitchRad);
+
+ // Object rotation (geometry as authored; mesh front = local +Y)
+ VERSECORE_API double ToUnrealMeshYawDeg(double ThreeYawRad); // Normalize(-deg(yaw)) == heading - 90
+ VERSECORE_API FQuat ToUnrealQuat(const FQuat& ThreeQuat); // (-x, -z, -y, w)
+ VERSECORE_API FQuat ToThreeQuat(const FQuat& UnrealQuat); // (-x, -z, -y, w)
+
+ // Manifest sockets: position + yaw_deg in one step
+ enum class ESocketUse : uint8 { Heading, Mesh };
+ VERSECORE_API FTransform ToUnrealSocketTransform(const FVerseThreeVector& P, double ThreeYawDeg, ESocketUse Use,
+ const FVerseDeckFrame& Deck = FVerseDeckFrame::Local());
+
+ /** Angle in degrees normalised to (-180, 180] (FRotator::NormalizeAxis). */
+ VERSECORE_API double NormalizeDeg(double Deg);
+ /** Angle in radians wrapped to (-pi, pi]. */
+ VERSECORE_API double WrapPi(double Rad);
+}
+
+/** Blueprint and editor-utility access; same functions, no extra logic. */
+UCLASS()
+class VERSECORE_API UVerseCoordsLibrary : public UBlueprintFunctionLibrary
+{
+ GENERATED_BODY()
+
+public:
+ UFUNCTION(BlueprintPure, Category = "Verse|Coords")
+ static FVector ThreeToUnrealPosition(const FVerseThreeVector& P, const FVerseDeckFrame& Deck);
+
+ UFUNCTION(BlueprintPure, Category = "Verse|Coords")
+ static FVerseThreeVector UnrealToThreePosition(const FVector& PCm, const FVerseDeckFrame& Deck);
+
+ UFUNCTION(BlueprintPure, Category = "Verse|Coords")
+ static double ThreeYawDegToUnrealHeading(double ThreeYawDeg);
+
+ UFUNCTION(BlueprintPure, Category = "Verse|Coords")
+ static double ThreeYawDegToUnrealMeshYaw(double ThreeYawDeg);
+};
diff --git a/unreal/Verse/Source/VerseCore/Public/VerseGameplayTags.h b/unreal/Verse/Source/VerseCore/Public/VerseGameplayTags.h
new file mode 100644
index 0000000000..87098df6c9
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/VerseGameplayTags.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "NativeGameplayTags.h"
+
+// Native gameplay tags frozen by the contracts. Noise.*: bot.md 3.2 (one tag per FVerseNoiseEvent,
+// the DA_Audibility row key). Bot.State.*: one per decision state of bot.md 5.1.
+// Verse.Material.<id>: the penetration table materials of destruction.md 2, in wire order.
+
+namespace VerseTags
+{
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Shot);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Footstep_Sprint);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Footstep_Run);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Footstep_Walk);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Move_Slide);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Move_Land);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Move_Mantle);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Reload);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Gadget_BulwarkDeploy);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Gadget_BulwarkHum);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Gadget_BreachPlant);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Gadget_BreachDetonate);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Fracture);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Drone);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Melee);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Finisher);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Noise_Impact);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Attack);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Hold);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Flank);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_StalkForFinisher);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Retreat);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Reload);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_DeployBulwark);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Breach);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Wallbang);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Bot_State_Search);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_SheetMetal);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_ContainerWall);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_Glass);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_CladdingPanel);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_CatwalkGrating);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_CeilingPanel);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_Concrete);
+ VERSECORE_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Verse_Material_ArmorSteel);
+
+ /** Every Noise.* tag of bot.md 3.2, in table order. */
+ VERSECORE_API TConstArrayView<FGameplayTag> AllNoiseTags();
+
+ /** Every Bot.State.* tag, in bot.md 5.1 order. */
+ VERSECORE_API TConstArrayView<FGameplayTag> AllBotStateTags();
+
+ /** Verse.Material.* tags indexed by wire id (EVersePenetrationMaterial). */
+ VERSECORE_API TConstArrayView<FGameplayTag> AllMaterialTags();
+}
diff --git a/unreal/Verse/Source/VerseCore/Public/VerseLog.h b/unreal/Verse/Source/VerseCore/Public/VerseLog.h
new file mode 100644
index 0000000000..bd450f5a16
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/VerseLog.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Logging/LogMacros.h"
+
+// One log category per Verse module, declared in Core so every module logs under its own
+// name without new include edges (architecture.md 2). A module uses only its own category.
+
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerse, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseCore, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseBridge, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseMovement, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseDestruction, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseCombat, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseGore, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseDecks, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseCrew, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseScreens, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseBot, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseUI, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseStream, Log, All);
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseHarness, Log, All);
+/** Verse.QA.* console commands and the qa.exec bridge path (parity.md 19). */
+VERSECORE_API DECLARE_LOG_CATEGORY_EXTERN(LogVerseQa, Log, All);
diff --git a/unreal/Verse/Source/VerseCore/Public/VerseRng.h b/unreal/Verse/Source/VerseCore/Public/VerseRng.h
new file mode 100644
index 0000000000..81a52a52c1
--- /dev/null
+++ b/unreal/Verse/Source/VerseCore/Public/VerseRng.h
@@ -0,0 +1,78 @@
+#pragma once
+
+#include "CoreMinimal.h"
+
+#include "VerseRng.generated.h"
+
+/**
+ * Streams of VerseRng. Two uses that draw from the same seed and index but a different
+ * salt get independent numbers (combat-state.md 4.4: VerseRng(seed, n, salt=Spread)).
+ * The order is frozen: the value enters the stream key.
+ */
+UENUM(BlueprintType)
+enum class EVerseRngSalt : uint8
+{
+ None,
+ Recoil,
+ Spread,
+ Spawn,
+ Perception,
+ Aim,
+ Brain,
+ Fracture,
+ Harness
+};
+
+/**
+ * The one seeded random number generator of the Verse (orchestration.md 5.2: tests seed it,
+ * flaky is failed). SplitMix64 over integer arithmetic only, so the integer and unit draws
+ * are bit-identical on every platform and compiler; server and owning client derive the
+ * same recoil and spread from the same seed. Gaussian draws use sqrt, log and cos and are
+ * deterministic per build.
+ */
+struct VERSECORE_API FVerseRng
+{
+ /** A stream for one seed. */
+ explicit FVerseRng(uint64 Seed = 0);
+
+ /** VerseRng(seed, index, salt): the stream for draw `Index` of a seeded sequence. */
+ FVerseRng(uint64 Seed, uint64 Index, EVerseRngSalt Salt = EVerseRngSalt::None);
+
+ /** The SplitMix64 finaliser: a bijective 64-bit mix. */
+ static uint64 Mix(uint64 Value);
+
+ /** Order-sensitive hash of three 32-bit values, e.g. Hash(shooter net id, shot counter, match seed). */
+ static uint32 Hash(uint32 A, uint32 B, uint32 C);
+
+ uint64 NextU64();
+ uint32 NextU32();
+
+ /** Uniform in [0, 1), 53 random bits. */
+ double NextUnit();
+
+ /** Uniform in [Min, Max). */
+ double Range(double Min, double Max);
+
+ /** Uniform integer in [Min, Max] (inclusive); Min when Max < Min. */
+ int32 RangeInt(int32 Min, int32 MaxInclusive);
+
+ /** True with probability P. */
+ bool Chance(double P);
+
+ /** Normal distribution, Box-Muller. */
+ double Gaussian(double Mean = 0.0, double Sd = 1.0);
+
+ /** Point uniformly in the unit disk (rejection sampling; arithmetic only). */
+ FVector2D UnitDisk();
+
+ /** Direction uniformly on the unit sphere. */
+ FVector UnitVector();
+
+ /** Direction uniformly inside the cone of half-angle `HalfAngleDeg` around `Axis` (combat-state.md 4.4). */
+ FVector ConeDirection(const FVector& Axis, double HalfAngleDeg);
+
+ uint64 GetState() const { return State; }
+
+private:
+ uint64 State = 0;
+};
diff --git a/unreal/Verse/Source/VerseCore/VerseCore.Build.cs b/unreal/Verse/Source/VerseCore/VerseCore.Build.cs
index aafa4529ac..68debb7eb3 100644
--- a/unreal/Verse/Source/VerseCore/VerseCore.Build.cs
+++ b/unreal/Verse/Source/VerseCore/VerseCore.Build.cs
@@ -7,6 +7,8 @@ public class VerseCore : ModuleRules
public VerseCore(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
- PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine" });
+ PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "GameplayTags" });
+ // Json: the coordinate golden file test (contracts/coordinates.md 5, test 13).
+ PrivateDependencyModuleNames.AddRange(new string[] { "Json" });
}
}
diff --git a/unreal/Verse/Tests/Data/coords_golden.json b/unreal/Verse/Tests/Data/coords_golden.json
new file mode 100644
index 0000000000..42fd8e181a
--- /dev/null
+++ b/unreal/Verse/Tests/Data/coords_golden.json
@@ -0,0 +1,829 @@
+{
+ "schema": "verse.coords_golden/1",
+ "contract": "docs/verse/unreal/contracts/coordinates.md",
+ "note": "T = three.js frame (metres, +Y up, yaw 0 faces +Z); U = Unreal frame (cm, +Z up, yaw 0 faces +X). Read by Verse.Contract.Coords.CrossLanguageGolden and HangarGolden.",
+ "tolerance": {
+ "position_cm": 1e-06,
+ "direction": 1e-12,
+ "angle_deg": 1e-09
+ },
+ "positions": [
+ {
+ "table": "3.1",
+ "name": "floor_far_left",
+ "three": [
+ 0,
+ 0,
+ 0
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 0.0,
+ 0.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "floor_far_right",
+ "three": [
+ 100,
+ 0,
+ 0
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 10000.0,
+ 0.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "floor_near_left",
+ "three": [
+ 0,
+ 0,
+ 62
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 0.0,
+ 6200.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "floor_near_right",
+ "three": [
+ 100,
+ 0,
+ 62
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 10000.0,
+ 6200.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "ceiling_near_right",
+ "three": [
+ 100,
+ 21,
+ 62
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 10000.0,
+ 6200.0,
+ 2100.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "hero_wall_top_blast_door",
+ "three": [
+ 50,
+ 22,
+ 1.5
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 5000.0,
+ 150.0,
+ 2200.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "launch_well_floor_a",
+ "three": [
+ 8,
+ -26,
+ 8
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 800.0,
+ 800.0,
+ -2600.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "launch_well_floor_b",
+ "three": [
+ 38,
+ -26,
+ 20
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 3800.0,
+ 2000.0,
+ -2600.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "shuttle_pad_centre",
+ "three": [
+ 50,
+ 0,
+ 23.6
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 5000.0,
+ 2360.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "booth_floor_corner",
+ "three": [
+ 3,
+ 1.2,
+ 47.2
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 300.0,
+ 4720.0,
+ 120.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "lift_a_door",
+ "three": [
+ 68,
+ 0,
+ 50.72
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 6800.0,
+ 5072.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "holo_shuttle_tactical",
+ "three": [
+ 50,
+ 2.53,
+ 24.6
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 5000.0,
+ 2460.0,
+ 253.0
+ ]
+ },
+ {
+ "table": "3.1",
+ "name": "eye_height",
+ "three": [
+ 0,
+ 1.65,
+ 0
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 0.0,
+ 0.0,
+ 165.0
+ ]
+ },
+ {
+ "table": "3.2",
+ "name": "spawn_commander",
+ "three": [
+ 70,
+ 0,
+ 54.2
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 7000.0,
+ 5420.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.2",
+ "name": "spawn_arrival",
+ "three": [
+ 50,
+ 0,
+ 38.1
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 5000.0,
+ 3810.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.2",
+ "name": "reactor_side_0",
+ "three": [
+ 38.8,
+ 0,
+ 22
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 3880.0,
+ 2200.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "3.2",
+ "name": "reactor_side_1",
+ "three": [
+ 69.2,
+ 0,
+ 22
+ ],
+ "deck_origin_cm": [
+ 0,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 6920.0,
+ 2200.0,
+ 0.0
+ ]
+ },
+ {
+ "table": "offset",
+ "name": "offset_deck_a",
+ "three": [
+ 12.5,
+ 3.25,
+ -7.75
+ ],
+ "deck_origin_cm": [
+ 100000,
+ -25000,
+ 1500
+ ],
+ "unreal": [
+ 101250.0,
+ -25775.0,
+ 1825.0
+ ]
+ },
+ {
+ "table": "offset",
+ "name": "offset_deck_b",
+ "three": [
+ -1,
+ 0.5,
+ 2
+ ],
+ "deck_origin_cm": [
+ -3333.5,
+ 0.25,
+ -200
+ ],
+ "unreal": [
+ -3433.5,
+ 200.25,
+ -150.0
+ ]
+ }
+ ],
+ "directions": [
+ {
+ "name": "plate_view_D",
+ "three": [
+ 0,
+ -0.8660254037844386,
+ -0.5
+ ],
+ "unreal": [
+ 0,
+ -0.5,
+ -0.8660254037844386
+ ]
+ },
+ {
+ "name": "basis_x",
+ "three": [
+ 1,
+ 0,
+ 0
+ ],
+ "unreal": [
+ 1,
+ 0,
+ 0
+ ]
+ },
+ {
+ "name": "basis_y_up",
+ "three": [
+ 0,
+ 1,
+ 0
+ ],
+ "unreal": [
+ 0,
+ 0,
+ 1
+ ]
+ },
+ {
+ "name": "basis_z",
+ "three": [
+ 0,
+ 0,
+ 1
+ ],
+ "unreal": [
+ 0,
+ 1,
+ 0
+ ]
+ }
+ ],
+ "headings": [
+ {
+ "table": "3.2",
+ "name": "spawn_commander",
+ "three_yaw_deg": 0.0,
+ "three_yaw_rad": 0.0,
+ "unreal_heading_deg": 90.0,
+ "unreal_mesh_yaw_deg": 0.0,
+ "three_forward": [
+ 0.0,
+ 0.0,
+ 1.0
+ ],
+ "unreal_forward": [
+ 6.123233995736766e-17,
+ 1.0,
+ 0.0
+ ],
+ "three_yaw_rad_back": 0.0
+ },
+ {
+ "table": "3.2",
+ "name": "reactor_side_0",
+ "three_yaw_deg": 90.0,
+ "three_yaw_rad": 1.5707963267948966,
+ "unreal_heading_deg": 0.0,
+ "unreal_mesh_yaw_deg": -90.0,
+ "three_forward": [
+ 1.0,
+ 0.0,
+ 6.123233995736766e-17
+ ],
+ "unreal_forward": [
+ 1.0,
+ 0.0,
+ 0.0
+ ],
+ "three_yaw_rad_back": 1.5707963267948966
+ },
+ {
+ "table": "3.2",
+ "name": "reactor_side_1",
+ "three_yaw_deg": -90.0,
+ "three_yaw_rad": -1.5707963267948966,
+ "unreal_heading_deg": 180.0,
+ "unreal_mesh_yaw_deg": 90.0,
+ "three_forward": [
+ -1.0,
+ 0.0,
+ 6.123233995736766e-17
+ ],
+ "unreal_forward": [
+ -1.0,
+ 1.2246467991473532e-16,
+ 0.0
+ ],
+ "three_yaw_rad_back": -1.5707963267948966
+ },
+ {
+ "table": "3.3",
+ "name": "psi_0",
+ "three_yaw_deg": 0.0,
+ "three_yaw_rad": 0.0,
+ "unreal_heading_deg": 90.0,
+ "unreal_mesh_yaw_deg": 0.0,
+ "three_forward": [
+ 0.0,
+ 0.0,
+ 1.0
+ ],
+ "unreal_forward": [
+ 6.123233995736766e-17,
+ 1.0,
+ 0.0
+ ],
+ "three_yaw_rad_back": 0.0
+ },
+ {
+ "table": "3.3",
+ "name": "psi_90",
+ "three_yaw_deg": 90.0,
+ "three_yaw_rad": 1.5707963267948966,
+ "unreal_heading_deg": 0.0,
+ "unreal_mesh_yaw_deg": -90.0,
+ "three_forward": [
+ 1.0,
+ 0.0,
+ 6.123233995736766e-17
+ ],
+ "unreal_forward": [
+ 1.0,
+ 0.0,
+ 0.0
+ ],
+ "three_yaw_rad_back": 1.5707963267948966
+ },
+ {
+ "table": "3.3",
+ "name": "psi_minus_90",
+ "three_yaw_deg": -90.0,
+ "three_yaw_rad": -1.5707963267948966,
+ "unreal_heading_deg": 180.0,
+ "unreal_mesh_yaw_deg": 90.0,
+ "three_forward": [
+ -1.0,
+ 0.0,
+ 6.123233995736766e-17
+ ],
+ "unreal_forward": [
+ -1.0,
+ 1.2246467991473532e-16,
+ 0.0
+ ],
+ "three_yaw_rad_back": -1.5707963267948966
+ },
+ {
+ "table": "3.3",
+ "name": "psi_180",
+ "three_yaw_deg": 180.0,
+ "three_yaw_rad": 3.141592653589793,
+ "unreal_heading_deg": -90.0,
+ "unreal_mesh_yaw_deg": 180.0,
+ "three_forward": [
+ 1.2246467991473532e-16,
+ 0.0,
+ -1.0
+ ],
+ "unreal_forward": [
+ 6.123233995736766e-17,
+ -1.0,
+ 0.0
+ ],
+ "three_yaw_rad_back": 3.141592653589793
+ },
+ {
+ "table": "3.3",
+ "name": "psi_135_ring_1",
+ "three_yaw_deg": 135.0,
+ "three_yaw_rad": 2.356194490192345,
+ "unreal_heading_deg": -45.0,
+ "unreal_mesh_yaw_deg": -135.0,
+ "three_forward": [
+ 0.7071067811865476,
+ 0.0,
+ -0.7071067811865475
+ ],
+ "unreal_forward": [
+ 0.7071067811865476,
+ -0.7071067811865476,
+ 0.0
+ ],
+ "three_yaw_rad_back": 2.356194490192345
+ },
+ {
+ "table": "3.3",
+ "name": "psi_minus_135_ring_2",
+ "three_yaw_deg": -135.0,
+ "three_yaw_rad": -2.356194490192345,
+ "unreal_heading_deg": -135.0,
+ "unreal_mesh_yaw_deg": 135.0,
+ "three_forward": [
+ -0.7071067811865476,
+ 0.0,
+ -0.7071067811865475
+ ],
+ "unreal_forward": [
+ -0.7071067811865475,
+ -0.7071067811865476,
+ 0.0
+ ],
+ "three_yaw_rad_back": -2.356194490192345
+ }
+ ],
+ "views": [
+ {
+ "name": "psi_90_theta_10",
+ "three_yaw_rad": 1.5707963267948966,
+ "three_pitch_rad": 0.17453292519943295,
+ "unreal_rotator_pyr": [
+ 10.0,
+ 0.0,
+ 0.0
+ ],
+ "three_forward": [
+ 0.984807753012208,
+ 0.17364817766693033,
+ 6.030208312509488e-17
+ ],
+ "unreal_forward": [
+ 0.984807753012208,
+ 6.030208312509488e-17,
+ 0.17364817766693033
+ ]
+ },
+ {
+ "name": "psi_minus_45_theta_minus_30",
+ "three_yaw_rad": -0.7853981633974483,
+ "three_pitch_rad": -0.5235987755982988,
+ "unreal_rotator_pyr": [
+ -30.0,
+ 135.0,
+ 0.0
+ ],
+ "three_forward": [
+ -0.6123724356957946,
+ -0.49999999999999994,
+ 0.6123724356957946
+ ],
+ "unreal_forward": [
+ -0.6123724356957946,
+ 0.6123724356957946,
+ -0.49999999999999994
+ ]
+ },
+ {
+ "name": "psi_170_theta_60",
+ "three_yaw_rad": 2.9670597283903604,
+ "three_pitch_rad": 1.0471975511965976,
+ "unreal_rotator_pyr": [
+ 60.0,
+ -80.0,
+ 0.0
+ ],
+ "three_forward": [
+ 0.08682408883346515,
+ 0.8660254037844386,
+ -0.4924038765061041
+ ],
+ "unreal_forward": [
+ 0.08682408883346515,
+ -0.4924038765061041,
+ 0.8660254037844386
+ ]
+ }
+ ],
+ "quaternions": [
+ {
+ "name": "yaw_90_about_y",
+ "three_xyzw": [
+ 0,
+ 0.7071067811865476,
+ 0,
+ 0.7071067811865476
+ ],
+ "unreal_xyzw": [
+ 0,
+ 0,
+ -0.7071067811865476,
+ 0.7071067811865476
+ ],
+ "unreal_yaw_deg": -90.0
+ },
+ {
+ "name": "pitch_30_about_x",
+ "three_xyzw": [
+ 0.25881904510252074,
+ 0,
+ 0,
+ 0.9659258262890683
+ ],
+ "unreal_xyzw": [
+ -0.25881904510252074,
+ 0,
+ 0,
+ 0.9659258262890683
+ ]
+ }
+ ],
+ "yaw_rates": [
+ {
+ "three_rad_s": 2.0,
+ "unreal_deg_s": -114.59155902616465
+ },
+ {
+ "three_rad_s": 1.0,
+ "unreal_deg_s": -57.29577951308232
+ }
+ ],
+ "speeds": [
+ {
+ "name": "run",
+ "three_m_s": 4.8,
+ "unreal_cm_s": 480.0
+ },
+ {
+ "name": "bolt",
+ "three_m_s": 300.0,
+ "unreal_cm_s": 30000.0
+ }
+ ],
+ "arena_boxes": [
+ {
+ "id": "wall_pipes_w",
+ "source": "combat/arenaReactor.ts",
+ "three": {
+ "x0": 33.0,
+ "x1": 45.4,
+ "y0": 0.9,
+ "y1": 2.3,
+ "z0": 2.0,
+ "z1": 2.75
+ },
+ "unreal_min": [
+ 3300.0,
+ 200.0,
+ 90.0
+ ],
+ "unreal_max": [
+ 4540.0,
+ 275.0,
+ 229.99999999999997
+ ]
+ },
+ {
+ "id": "wall_pipes_e",
+ "source": "combat/arenaReactor.ts",
+ "three": {
+ "x0": 62.6,
+ "x1": 82.0,
+ "y0": 0.9,
+ "y1": 2.3,
+ "z0": 2.0,
+ "z1": 2.75
+ },
+ "unreal_min": [
+ 6260.0,
+ 200.0,
+ 90.0
+ ],
+ "unreal_max": [
+ 8200.0,
+ 275.0,
+ 229.99999999999997
+ ]
+ },
+ {
+ "id": "machinery_0",
+ "source": "combat/arenaReactor.ts",
+ "three": {
+ "x0": 45.6,
+ "x1": 50.8,
+ "y0": 0,
+ "y1": 7.2,
+ "z0": 2.0,
+ "z1": 3.1
+ },
+ "unreal_min": [
+ 4560.0,
+ 200.0,
+ 0
+ ],
+ "unreal_max": [
+ 5080.0,
+ 310.0,
+ 720.0
+ ]
+ },
+ {
+ "id": "machinery_1",
+ "source": "combat/arenaReactor.ts",
+ "three": {
+ "x0": 52.6,
+ "x1": 55.6,
+ "y0": 0,
+ "y1": 7.2,
+ "z0": 2.0,
+ "z1": 3.6
+ },
+ "unreal_min": [
+ 5260.0,
+ 200.0,
+ 0
+ ],
+ "unreal_max": [
+ 5560.0,
+ 360.0,
+ 720.0
+ ]
+ },
+ {
+ "id": "machinery_2",
+ "source": "combat/arenaReactor.ts",
+ "three": {
+ "x0": 57.2,
+ "x1": 62.4,
+ "y0": 0,
+ "y1": 7.2,
+ "z0": 2.0,
+ "z1": 3.1
+ },
+ "unreal_min": [
+ 5720.0,
+ 200.0,
+ 0
+ ],
+ "unreal_max": [
+ 6240.0,
+ 310.0,
+ 720.0
+ ]
+ }
+ ]
+}