diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.cpp index 519d00f5..eb66f1e4 100644 --- a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.cpp @@ -4,12 +4,14 @@ #include "Game/IW5/InfoString/InfoStringFromStructConverter.h" #include "Game/IW5/InfoString/WeaponFields.h" #include "Game/IW5/ObjConstantsIW5.h" +#include "Weapon/AccuracyGraphWriter.h" #include #include #include #include #include +#include using namespace IW5; @@ -532,6 +534,23 @@ namespace IW5 const WeaponFullDef* m_weapon; }; + + GenericAccuracyGraph ConvertAccuracyGraph(const char* graphName, const vec2_t* originalKnots, const unsigned originalKnotCount) + { + GenericAccuracyGraph graph; + + graph.name = graphName; + graph.knots.resize(originalKnotCount); + + for (auto i = 0u; i < originalKnotCount; i++) + { + auto& knot = graph.knots[i]; + knot.x = originalKnots[i][0]; + knot.y = originalKnots[i][1]; + } + + return graph; + } } // namespace IW5 void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef) @@ -681,6 +700,33 @@ InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* as return converter.Convert(); } +void AssetDumperWeapon::DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) +{ + auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); + const auto weapon = asset->Asset(); + const auto* weapDef = weapon->weapDef; + + if (!weapDef) + return; + + if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsAiGraph( + context, + ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, weapDef->originalAiVsAiAccuracyGraphKnots, weapDef->originalAiVsAiAccuracyGraphKnotCount)); + } + + if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsPlayerGraph(context, + ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, + weapDef->originalAiVsPlayerAccuracyGraphKnots, + weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); + } +} + bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) { return true; @@ -710,4 +756,6 @@ void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset); + static void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset); protected: bool ShouldDump(XAssetInfo* asset) override;