Skip to content

Commit 6b0df0e

Browse files
committed
Updated for 2.0
1 parent eaa2d18 commit 6b0df0e

29 files changed

+1463
-15438
lines changed

ArkGameTestingCommands/ArkGameTestingCommands.cpp

Lines changed: 68 additions & 1221 deletions
Large diffs are not rendered by default.

ArkGameTestingCommands/ArkGameTestingCommands.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

ArkGameTestingCommands/ArkGameTestingCommands.vcxproj

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<VCProjectVersion>15.0</VCProjectVersion>
2323
<ProjectGuid>{1DCA1C38-37D0-4F80-BB0B-3B433E64222F}</ProjectGuid>
2424
<RootNamespace>ArkGameTestingCommands</RootNamespace>
25-
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
25+
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
2626
</PropertyGroup>
2727
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2828
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -70,8 +70,8 @@
7070
</ImportGroup>
7171
<PropertyGroup Label="UserMacros" />
7272
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
73-
<IncludePath>C:\ArkApi\include;$(IncludePath)</IncludePath>
74-
<LibraryPath>C:\ArkApi\lib;$(LibraryPath)</LibraryPath>
73+
<IncludePath>C:\ArkApi2\include;$(IncludePath)</IncludePath>
74+
<LibraryPath>C:\ArkApi2\lib;$(LibraryPath)</LibraryPath>
7575
</PropertyGroup>
7676
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7777
<ClCompile>
@@ -107,6 +107,8 @@
107107
<FunctionLevelLinking>true</FunctionLevelLinking>
108108
<IntrinsicFunctions>true</IntrinsicFunctions>
109109
<SDLCheck>true</SDLCheck>
110+
<LanguageStandard>stdcpp17</LanguageStandard>
111+
<PreprocessorDefinitions>_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
110112
</ClCompile>
111113
<Link>
112114
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -115,17 +117,20 @@
115117
</ItemDefinitionGroup>
116118
<ItemGroup>
117119
<ClCompile Include="ArkGameTestingCommands.cpp" />
118-
<ClCompile Include="GiveCustomItems.cpp" />
119-
<ClCompile Include="SpawnCustomDino.cpp" />
120-
<ClCompile Include="Tools.cpp" />
120+
<ClCompile Include="Commands\HealthCommand.cpp" />
121+
<ClCompile Include="Commands\ItemTemplateCommand.cpp" />
122+
<ClCompile Include="Commands\SpawnTemplateCommand.cpp" />
123+
<ClCompile Include="Commands\TeleportToCommand.cpp" />
124+
<ClCompile Include="Plugin.cpp" />
125+
<ClCompile Include="Utils.cpp" />
121126
</ItemGroup>
122127
<ItemGroup>
123-
<ClInclude Include="ArkGameTestingCommands.h" />
124-
<ClInclude Include="GiveCustomItems.h" />
125-
<ClInclude Include="GiveItemsTemplate.h" />
126-
<ClInclude Include="json.hpp" />
127-
<ClInclude Include="SpawnCustomDino.h" />
128-
<ClInclude Include="Tools.h" />
128+
<ClInclude Include="Commands\HealthCommand.h" />
129+
<ClInclude Include="Commands\ItemTemplateCommand.h" />
130+
<ClInclude Include="Commands\SpawnTemplateCommand.h" />
131+
<ClInclude Include="Commands\TeleportToCommand.h" />
132+
<ClInclude Include="Plugin.h" />
133+
<ClInclude Include="Utils.h" />
129134
</ItemGroup>
130135
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
131136
<ImportGroup Label="ExtensionTargets">

ArkGameTestingCommands/ArkGameTestingCommands.vcxproj.filters

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,54 @@
1313
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
1414
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
1515
</Filter>
16+
<Filter Include="Header Files\Commands">
17+
<UniqueIdentifier>{077fb3e3-f44f-4490-ae71-65a1f8a90468}</UniqueIdentifier>
18+
</Filter>
19+
<Filter Include="Source Files\Commands">
20+
<UniqueIdentifier>{0cb2b033-1b39-4fde-813c-8f262890551b}</UniqueIdentifier>
21+
</Filter>
1622
</ItemGroup>
1723
<ItemGroup>
1824
<ClCompile Include="ArkGameTestingCommands.cpp">
1925
<Filter>Source Files</Filter>
2026
</ClCompile>
21-
<ClCompile Include="SpawnCustomDino.cpp">
27+
<ClCompile Include="Utils.cpp">
2228
<Filter>Source Files</Filter>
2329
</ClCompile>
24-
<ClCompile Include="Tools.cpp">
25-
<Filter>Source Files</Filter>
30+
<ClCompile Include="Commands\SpawnTemplateCommand.cpp">
31+
<Filter>Source Files\Commands</Filter>
2632
</ClCompile>
27-
<ClCompile Include="GiveCustomItems.cpp">
33+
<ClCompile Include="Plugin.cpp">
2834
<Filter>Source Files</Filter>
2935
</ClCompile>
36+
<ClCompile Include="Commands\HealthCommand.cpp">
37+
<Filter>Source Files\Commands</Filter>
38+
</ClCompile>
39+
<ClCompile Include="Commands\ItemTemplateCommand.cpp">
40+
<Filter>Source Files\Commands</Filter>
41+
</ClCompile>
42+
<ClCompile Include="Commands\TeleportToCommand.cpp">
43+
<Filter>Source Files\Commands</Filter>
44+
</ClCompile>
3045
</ItemGroup>
3146
<ItemGroup>
32-
<ClInclude Include="ArkGameTestingCommands.h">
47+
<ClInclude Include="Utils.h">
3348
<Filter>Header Files</Filter>
3449
</ClInclude>
35-
<ClInclude Include="SpawnCustomDino.h">
36-
<Filter>Header Files</Filter>
50+
<ClInclude Include="Commands\SpawnTemplateCommand.h">
51+
<Filter>Header Files\Commands</Filter>
3752
</ClInclude>
38-
<ClInclude Include="Tools.h">
53+
<ClInclude Include="Plugin.h">
3954
<Filter>Header Files</Filter>
4055
</ClInclude>
41-
<ClInclude Include="json.hpp">
42-
<Filter>Header Files</Filter>
56+
<ClInclude Include="Commands\HealthCommand.h">
57+
<Filter>Header Files\Commands</Filter>
4358
</ClInclude>
44-
<ClInclude Include="GiveItemsTemplate.h">
45-
<Filter>Header Files</Filter>
59+
<ClInclude Include="Commands\ItemTemplateCommand.h">
60+
<Filter>Header Files\Commands</Filter>
4661
</ClInclude>
47-
<ClInclude Include="GiveCustomItems.h">
48-
<Filter>Header Files</Filter>
62+
<ClInclude Include="Commands\TeleportToCommand.h">
63+
<Filter>Header Files\Commands</Filter>
4964
</ClInclude>
5065
</ItemGroup>
5166
</Project>
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#include "HealthCommand.h"
2+
3+
void HealthChatCommand(AShooterPlayerController* aShooterPlayerController, FString* msg, EChatSendMode::Type mode)
4+
{
5+
auto result = HealthInternal(aShooterPlayerController, ArkLibrary::GetCommand(CommandName_Health_Chat));
6+
if (result.size() == 0) return;
7+
8+
for (auto str : result) ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", str.c_str());
9+
}
10+
11+
void HealthConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog)
12+
{
13+
auto aShooterPlayerController = static_cast<AShooterPlayerController*>(aPlayerController);
14+
15+
auto result = HealthInternal(aShooterPlayerController, ArkLibrary::GetCommand(CommandName_Health_Console));
16+
if (result.size() == 0) return;
17+
18+
std::wstringstream ss;
19+
for (auto str : result) ss << ArkApi::Tools::ConvertToWideStr(str) << std::endl;
20+
21+
ArkApi::GetApiUtils().SendNotification(aShooterPlayerController, { 1, 0, 1, 1 }, 0.8f, 30.0f, nullptr, ss.str().c_str());
22+
}
23+
24+
std::list<std::string> HealthInternal(AShooterPlayerController* aShooterPlayerController, ArkLibrary::CommandDefinition *cmd)
25+
{
26+
std::list<std::string> result;
27+
28+
UWorld* world = ArkApi::GetApiUtils().GetWorld();
29+
if (!world) return result;
30+
if (!aShooterPlayerController) return result;
31+
32+
ACharacter* character = aShooterPlayerController->CharacterField()();
33+
if (!character || !character->IsA(APrimalCharacter::GetPrivateStaticClass())) return result;
34+
35+
APrimalCharacter* primalCharacter = static_cast<APrimalCharacter*>(character);
36+
37+
std::map<std::string, std::list<std::tuple<float, float>>> statuses;
38+
FVector* pos = new FVector();
39+
int teamId = aShooterPlayerController->TargetingTeamField()();
40+
FVector playerPos = aShooterPlayerController->DefaultActorLocationField()();
41+
42+
TArray<AActor*>* FoundActors = new TArray<AActor*>();
43+
UGameplayStatics::GetAllActorsOfClass(reinterpret_cast<UObject *>(world), APrimalDinoCharacter::GetPrivateStaticClass(), FoundActors);
44+
45+
for (uint32_t i = 0; i < FoundActors->Num(); i++)
46+
{
47+
AActor* actor = (*FoundActors)[i];
48+
49+
APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(actor);
50+
51+
int dinoTeam = dino->TargetingTeamField()();
52+
53+
dino->RootComponentField()()->GetCustomLocation(pos);
54+
if (dinoTeam == teamId && ArkLibrary::IsPointInside2dCircle(*pos, playerPos.X, playerPos.Y, 5000))
55+
{
56+
FString className;
57+
dino->DinoNameTagField()().ToString(&className); //species name
58+
//std::string name = dino->GetTamedNameField().ToString(); //tamed name
59+
60+
UPrimalCharacterStatusComponent* status = dino->MyCharacterStatusComponentField()();
61+
if (status)
62+
{
63+
float* currentStatValues = status->CurrentStatusValuesField()();
64+
float* maxStatsValues = status->MaxStatusValuesField()();
65+
66+
std::string classNameStr = className.ToString();
67+
68+
if (statuses.find(classNameStr) == statuses.end())
69+
{
70+
auto list = std::list<std::tuple<float, float>>();
71+
list.push_back(std::make_tuple(currentStatValues[0], maxStatsValues[0]));
72+
statuses[classNameStr] = list;
73+
}
74+
else
75+
{
76+
statuses[classNameStr].push_back(std::make_tuple(currentStatValues[0], maxStatsValues[0]));
77+
}
78+
}
79+
}
80+
}
81+
delete FoundActors;
82+
delete pos;
83+
84+
for (std::map<std::string, std::list<std::tuple<float, float>>>::const_iterator it = statuses.begin(), end = statuses.end(); it != end; ++it)
85+
{
86+
std::string name = it->first;
87+
std::list<float> percentages;
88+
double totalHealth = 0.0;
89+
double totalRemaining = 0.0;
90+
double totalDiff = 0.0;
91+
92+
for (std::list<std::tuple<float, float>>::const_iterator it2 = it->second.begin(), end2 = it->second.end(); it2 != end2; ++it2)
93+
{
94+
float currentHealth = std::get<0>(*it2);
95+
float maxHealth = std::get<1>(*it2);
96+
float healthPercentage = currentHealth / maxHealth;
97+
float healthDiff = maxHealth - currentHealth;
98+
99+
totalHealth += maxHealth;
100+
totalRemaining += currentHealth;
101+
totalDiff += healthDiff;
102+
103+
percentages.push_back(healthPercentage);
104+
}
105+
106+
percentages.sort([](const float & a, const float & b) { return a < b; });
107+
108+
std::stringstream ss;
109+
ss << name << " (" << percentages.size() << "): ";
110+
111+
int n = 0;
112+
for (std::list<float>::const_iterator it2 = percentages.begin(), end2 = percentages.end(); it2 != end2; ++it2)
113+
{
114+
if (n > 0) ss << ", ";
115+
ss << std::round(*it2 * 100.0);
116+
117+
n++;
118+
}
119+
120+
result.push_back(ss.str());
121+
ss.str(std::string());
122+
123+
//avoid divide-by-zero exception
124+
if (totalHealth > 0.0)
125+
{
126+
ss << "Remaining: " << std::round((totalRemaining / totalHealth) * 100.0) << "%, Diff: " << std::round(-totalDiff);
127+
}
128+
129+
result.push_back(ss.str());
130+
}
131+
132+
return result;
133+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
#include "../Plugin.h"
3+
4+
DECLARE_COMMAND(Health_Chat);
5+
DECLARE_COMMAND(Health_Console);
6+
7+
void HealthChatCommand(AShooterPlayerController* aShooterPlayerController, FString* msg, EChatSendMode::Type mode);
8+
void HealthConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog);
9+
std::list<std::string> HealthInternal(AShooterPlayerController* aShooterPlayerController, ArkLibrary::CommandDefinition *cmd);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include "ItemTemplateCommand.h"
2+
3+
void ItemTemplateConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog)
4+
{
5+
auto aShooterPlayerController = static_cast<AShooterPlayerController*>(aPlayerController);
6+
7+
auto &plugin = Plugin::Get();
8+
auto cmd = ArkLibrary::GetCommand(CommandName_ItemTemplate_Console);
9+
10+
TArray<FString> Parsed;
11+
msg->ParseIntoArray(Parsed, L" ", true);
12+
13+
if (Parsed.IsValidIndex(1))
14+
{
15+
std::string templateName = Parsed[1].ToString();
16+
17+
auto templatesList = cmd->Json["Templates"];
18+
19+
auto templateEntryIter = templatesList.find(templateName);
20+
if (templateEntryIter == templatesList.end())
21+
{
22+
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", L"The template does not exist! Maybe you forgot to reload..?");
23+
return;
24+
}
25+
26+
auto templateEntry = templateEntryIter.value();
27+
28+
__int64 steamId = ArkApi::GetApiUtils().GetSteamIdFromController(aShooterPlayerController);
29+
30+
int count;
31+
std::list<ArkLibrary::GiveItemDefinition> items;
32+
33+
try
34+
{
35+
count = templateEntry.value("count", 1);
36+
37+
auto itemsMap = templateEntry.value("items", nlohmann::json::array());
38+
for (auto iter = itemsMap.begin(); iter != itemsMap.end(); ++iter)
39+
{
40+
auto item = iter.value();
41+
42+
std::string blueprint = item.value("blueprint", "");
43+
std::list<std::string> blueprints = item.find("blueprints") != item.end() ? item["blueprints"] : std::list<std::string>();
44+
int quantity = item.value("quantity", 0);
45+
int count = item.value("count", 1);
46+
float quality = item.value("quality", 0.0);
47+
48+
ArkLibrary::GiveItemDefinition giveItemDef;
49+
giveItemDef.blueprint = blueprint;
50+
giveItemDef.blueprints = blueprints;
51+
giveItemDef.quantity = quantity;
52+
giveItemDef.count = count;
53+
giveItemDef.quality = quality;
54+
55+
items.push_back(giveItemDef);
56+
}
57+
}
58+
catch (const std::exception&)
59+
{
60+
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", L"Failed to read template...");
61+
return;
62+
}
63+
64+
bool success = true;
65+
for (int i = 0; i < count; i++)
66+
{
67+
bool innerSuccess = GiveCustomItems(steamId, items);
68+
69+
if (!innerSuccess)
70+
{
71+
success = false;
72+
break;
73+
}
74+
}
75+
}
76+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
#include "../Plugin.h"
3+
#include <ArkPluginLibrary/GiveCustomItems.h>
4+
5+
DECLARE_COMMAND(ItemTemplate_Console);
6+
7+
void ItemTemplateConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog);

0 commit comments

Comments
 (0)