-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,463 additions
and
15,438 deletions.
There are no files selected for viewing
1,289 changes: 68 additions & 1,221 deletions
1,289
ArkGameTestingCommands/ArkGameTestingCommands.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#include "HealthCommand.h" | ||
|
||
void HealthChatCommand(AShooterPlayerController* aShooterPlayerController, FString* msg, EChatSendMode::Type mode) | ||
{ | ||
auto result = HealthInternal(aShooterPlayerController, ArkLibrary::GetCommand(CommandName_Health_Chat)); | ||
if (result.size() == 0) return; | ||
|
||
for (auto str : result) ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", str.c_str()); | ||
} | ||
|
||
void HealthConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog) | ||
{ | ||
auto aShooterPlayerController = static_cast<AShooterPlayerController*>(aPlayerController); | ||
|
||
auto result = HealthInternal(aShooterPlayerController, ArkLibrary::GetCommand(CommandName_Health_Console)); | ||
if (result.size() == 0) return; | ||
|
||
std::wstringstream ss; | ||
for (auto str : result) ss << ArkApi::Tools::ConvertToWideStr(str) << std::endl; | ||
|
||
ArkApi::GetApiUtils().SendNotification(aShooterPlayerController, { 1, 0, 1, 1 }, 0.8f, 30.0f, nullptr, ss.str().c_str()); | ||
} | ||
|
||
std::list<std::string> HealthInternal(AShooterPlayerController* aShooterPlayerController, ArkLibrary::CommandDefinition *cmd) | ||
{ | ||
std::list<std::string> result; | ||
|
||
UWorld* world = ArkApi::GetApiUtils().GetWorld(); | ||
if (!world) return result; | ||
if (!aShooterPlayerController) return result; | ||
|
||
ACharacter* character = aShooterPlayerController->CharacterField()(); | ||
if (!character || !character->IsA(APrimalCharacter::GetPrivateStaticClass())) return result; | ||
|
||
APrimalCharacter* primalCharacter = static_cast<APrimalCharacter*>(character); | ||
|
||
std::map<std::string, std::list<std::tuple<float, float>>> statuses; | ||
FVector* pos = new FVector(); | ||
int teamId = aShooterPlayerController->TargetingTeamField()(); | ||
FVector playerPos = aShooterPlayerController->DefaultActorLocationField()(); | ||
|
||
TArray<AActor*>* FoundActors = new TArray<AActor*>(); | ||
UGameplayStatics::GetAllActorsOfClass(reinterpret_cast<UObject *>(world), APrimalDinoCharacter::GetPrivateStaticClass(), FoundActors); | ||
|
||
for (uint32_t i = 0; i < FoundActors->Num(); i++) | ||
{ | ||
AActor* actor = (*FoundActors)[i]; | ||
|
||
APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(actor); | ||
|
||
int dinoTeam = dino->TargetingTeamField()(); | ||
|
||
dino->RootComponentField()()->GetCustomLocation(pos); | ||
if (dinoTeam == teamId && ArkLibrary::IsPointInside2dCircle(*pos, playerPos.X, playerPos.Y, 5000)) | ||
{ | ||
FString className; | ||
dino->DinoNameTagField()().ToString(&className); //species name | ||
//std::string name = dino->GetTamedNameField().ToString(); //tamed name | ||
|
||
UPrimalCharacterStatusComponent* status = dino->MyCharacterStatusComponentField()(); | ||
if (status) | ||
{ | ||
float* currentStatValues = status->CurrentStatusValuesField()(); | ||
float* maxStatsValues = status->MaxStatusValuesField()(); | ||
|
||
std::string classNameStr = className.ToString(); | ||
|
||
if (statuses.find(classNameStr) == statuses.end()) | ||
{ | ||
auto list = std::list<std::tuple<float, float>>(); | ||
list.push_back(std::make_tuple(currentStatValues[0], maxStatsValues[0])); | ||
statuses[classNameStr] = list; | ||
} | ||
else | ||
{ | ||
statuses[classNameStr].push_back(std::make_tuple(currentStatValues[0], maxStatsValues[0])); | ||
} | ||
} | ||
} | ||
} | ||
delete FoundActors; | ||
delete pos; | ||
|
||
for (std::map<std::string, std::list<std::tuple<float, float>>>::const_iterator it = statuses.begin(), end = statuses.end(); it != end; ++it) | ||
{ | ||
std::string name = it->first; | ||
std::list<float> percentages; | ||
double totalHealth = 0.0; | ||
double totalRemaining = 0.0; | ||
double totalDiff = 0.0; | ||
|
||
for (std::list<std::tuple<float, float>>::const_iterator it2 = it->second.begin(), end2 = it->second.end(); it2 != end2; ++it2) | ||
{ | ||
float currentHealth = std::get<0>(*it2); | ||
float maxHealth = std::get<1>(*it2); | ||
float healthPercentage = currentHealth / maxHealth; | ||
float healthDiff = maxHealth - currentHealth; | ||
|
||
totalHealth += maxHealth; | ||
totalRemaining += currentHealth; | ||
totalDiff += healthDiff; | ||
|
||
percentages.push_back(healthPercentage); | ||
} | ||
|
||
percentages.sort([](const float & a, const float & b) { return a < b; }); | ||
|
||
std::stringstream ss; | ||
ss << name << " (" << percentages.size() << "): "; | ||
|
||
int n = 0; | ||
for (std::list<float>::const_iterator it2 = percentages.begin(), end2 = percentages.end(); it2 != end2; ++it2) | ||
{ | ||
if (n > 0) ss << ", "; | ||
ss << std::round(*it2 * 100.0); | ||
|
||
n++; | ||
} | ||
|
||
result.push_back(ss.str()); | ||
ss.str(std::string()); | ||
|
||
//avoid divide-by-zero exception | ||
if (totalHealth > 0.0) | ||
{ | ||
ss << "Remaining: " << std::round((totalRemaining / totalHealth) * 100.0) << "%, Diff: " << std::round(-totalDiff); | ||
} | ||
|
||
result.push_back(ss.str()); | ||
} | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include "../Plugin.h" | ||
|
||
DECLARE_COMMAND(Health_Chat); | ||
DECLARE_COMMAND(Health_Console); | ||
|
||
void HealthChatCommand(AShooterPlayerController* aShooterPlayerController, FString* msg, EChatSendMode::Type mode); | ||
void HealthConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog); | ||
std::list<std::string> HealthInternal(AShooterPlayerController* aShooterPlayerController, ArkLibrary::CommandDefinition *cmd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "ItemTemplateCommand.h" | ||
|
||
void ItemTemplateConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog) | ||
{ | ||
auto aShooterPlayerController = static_cast<AShooterPlayerController*>(aPlayerController); | ||
|
||
auto &plugin = Plugin::Get(); | ||
auto cmd = ArkLibrary::GetCommand(CommandName_ItemTemplate_Console); | ||
|
||
TArray<FString> Parsed; | ||
msg->ParseIntoArray(Parsed, L" ", true); | ||
|
||
if (Parsed.IsValidIndex(1)) | ||
{ | ||
std::string templateName = Parsed[1].ToString(); | ||
|
||
auto templatesList = cmd->Json["Templates"]; | ||
|
||
auto templateEntryIter = templatesList.find(templateName); | ||
if (templateEntryIter == templatesList.end()) | ||
{ | ||
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", L"The template does not exist! Maybe you forgot to reload..?"); | ||
return; | ||
} | ||
|
||
auto templateEntry = templateEntryIter.value(); | ||
|
||
__int64 steamId = ArkApi::GetApiUtils().GetSteamIdFromController(aShooterPlayerController); | ||
|
||
int count; | ||
std::list<ArkLibrary::GiveItemDefinition> items; | ||
|
||
try | ||
{ | ||
count = templateEntry.value("count", 1); | ||
|
||
auto itemsMap = templateEntry.value("items", nlohmann::json::array()); | ||
for (auto iter = itemsMap.begin(); iter != itemsMap.end(); ++iter) | ||
{ | ||
auto item = iter.value(); | ||
|
||
std::string blueprint = item.value("blueprint", ""); | ||
std::list<std::string> blueprints = item.find("blueprints") != item.end() ? item["blueprints"] : std::list<std::string>(); | ||
int quantity = item.value("quantity", 0); | ||
int count = item.value("count", 1); | ||
float quality = item.value("quality", 0.0); | ||
|
||
ArkLibrary::GiveItemDefinition giveItemDef; | ||
giveItemDef.blueprint = blueprint; | ||
giveItemDef.blueprints = blueprints; | ||
giveItemDef.quantity = quantity; | ||
giveItemDef.count = count; | ||
giveItemDef.quality = quality; | ||
|
||
items.push_back(giveItemDef); | ||
} | ||
} | ||
catch (const std::exception&) | ||
{ | ||
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", L"Failed to read template..."); | ||
return; | ||
} | ||
|
||
bool success = true; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
bool innerSuccess = GiveCustomItems(steamId, items); | ||
|
||
if (!innerSuccess) | ||
{ | ||
success = false; | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
#include "../Plugin.h" | ||
#include <ArkPluginLibrary/GiveCustomItems.h> | ||
|
||
DECLARE_COMMAND(ItemTemplate_Console); | ||
|
||
void ItemTemplateConsoleCommand(APlayerController* aPlayerController, FString* msg, bool bWriteToLog); |
Oops, something went wrong.