-
Notifications
You must be signed in to change notification settings - Fork 6
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
33 changed files
with
1,322 additions
and
717 deletions.
There are no files selected for viewing
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,84 @@ | ||
{ | ||
"Commands": { | ||
"DestroyMyDino_Chat": { | ||
"Command": "/destroymydino", | ||
"Enabled": true, | ||
"Permissions": false, | ||
"Method": "destroy" | ||
}, | ||
"DoRespec_Console": { | ||
"Command": "DoRespec", | ||
"Enabled": true | ||
}, | ||
"DoRespec_Rcon": { | ||
"Command": "DoRespec", | ||
"Enabled": true | ||
}, | ||
"DestroyAllStructuresForTeamId_Console": { | ||
"Command": "DestroyAllStructuresForTeamId", | ||
"Enabled": true | ||
}, | ||
"DestroyAllStructuresForTeamId_Rcon": { | ||
"Command": "DestroyAllStructuresForTeamId", | ||
"Enabled": true | ||
}, | ||
"DestroyStructuresForTeamIdAtPosition_Console": { | ||
"Command": "DestroyStructuresForTeamIdAtPosition", | ||
"Enabled": true | ||
}, | ||
"DestroyStructuresForTeamIdAtPosition_Rcon": { | ||
"Command": "DestroyStructuresForTeamIdAtPosition", | ||
"Enabled": true | ||
}, | ||
"DestroyDinosForTeamId_Console": { | ||
"Command": "DestroyDinosForTeamId", | ||
"Enabled": true | ||
}, | ||
"DestroyDinosForTeamId_Rcon": { | ||
"Command": "DestroyDinosForTeamId", | ||
"Enabled": true | ||
}, | ||
"DroppedEggs_Console": { | ||
"Command": "DroppedEggs", | ||
"Enabled": true, | ||
"ClassNames": [ | ||
"DroppedItemGeneric_FertilizedEgg_Wyvern_C", | ||
"DroppedItemGeneric_FertilizedEgg_RockDrake_C" | ||
] | ||
}, | ||
"DroppedEggs_Rcon": { | ||
"Command": "DroppedEggs", | ||
"Enabled": true, | ||
"ClassNames": [ | ||
"DroppedItemGeneric_FertilizedEgg_Wyvern_C", | ||
"DroppedItemGeneric_FertilizedEgg_RockDrake_C" | ||
] | ||
}, | ||
"FeedDinosForTeamId_Console": { | ||
"Command": "FeedDinosForTeamId", | ||
"Enabled": true | ||
}, | ||
"FeedDinosForTeamId_Rcon": { | ||
"Command": "FeedDinosForTeamId", | ||
"Enabled": true | ||
}, | ||
"ImprintOn_Console": { | ||
"Command": "ImprintOn", | ||
"Enabled": true | ||
}, | ||
"MyDinoStats_Chat": { | ||
"Command": "/mydinostats", | ||
"Enabled": true, | ||
"Permissions": false | ||
}, | ||
"NextImprint_Console": { | ||
"Command": "NextImprint", | ||
"Enabled": true | ||
}, | ||
"Suicide_Chat": { | ||
"Command": "/suicide", | ||
"Enabled": true, | ||
"Permissions": false | ||
} | ||
} | ||
} |
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 @@ | ||
{ | ||
"FullName":"Improved Commands", | ||
"Description": "", | ||
"Version":2.0, | ||
"MinApiVersion":2.0, | ||
"Dependencies":[ | ||
"Permissions" | ||
] | ||
} |
77 changes: 77 additions & 0 deletions
77
ImprovedCommands/Commands/DestroyAllStructuresForTeamIdCommand.cpp
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,77 @@ | ||
#include "DestroyAllStructuresForTeamIdCommand.h" | ||
#include <sstream> | ||
|
||
void DestroyAllStructuresForTeamIdRconCommand(RCONClientConnection* rconClientConnection, RCONPacket* rconPacket, UWorld* uWorld) | ||
{ | ||
FString msg = rconPacket->Body; | ||
|
||
auto result = DestroyAllStructuresForTeamIdInternal(&msg); | ||
if (result.length() == 0) return; | ||
|
||
FString reply(result.c_str()); | ||
reply.AppendChar(L'\n'); | ||
rconClientConnection->SendMessageW(rconPacket->Id, 0, &reply); | ||
} | ||
|
||
void DestroyAllStructuresForTeamIdConsoleCommand(APlayerController* aPlayerController, FString* cmd, bool bWriteToLog) | ||
{ | ||
auto result = DestroyAllStructuresForTeamIdInternal(cmd); | ||
if (result.length() == 0) return; | ||
|
||
auto aShooterPlayerController = static_cast<AShooterPlayerController*>(aPlayerController); | ||
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", result.c_str()); | ||
} | ||
|
||
std::wstring DestroyAllStructuresForTeamIdInternal(FString* cmd) | ||
{ | ||
TArray<FString> Parsed; | ||
cmd->ParseIntoArray(Parsed, L" ", true); | ||
|
||
if (Parsed.IsValidIndex(1)) | ||
{ | ||
__int64 teamId; | ||
|
||
try | ||
{ | ||
teamId = std::stoull(*Parsed[1]); | ||
} | ||
catch (const std::exception&) | ||
{ | ||
return {}; | ||
} | ||
|
||
if (teamId < 50000) return {}; | ||
|
||
UWorld* world = ArkApi::GetApiUtils().GetWorld(); | ||
if (!world) return {}; | ||
|
||
TArray<AActor*>* FoundActors = new TArray<AActor*>(); | ||
|
||
UGameplayStatics::GetAllActorsOfClass(world, APrimalStructure::GetPrivateStaticClass(), FoundActors); | ||
|
||
std::stringstream ss; | ||
|
||
//todo: maybe destroy rafts aswell? | ||
int num = 0; | ||
for (uint32_t i = 0; i < FoundActors->Num(); i++) | ||
{ | ||
AActor* actor = (*FoundActors)[i]; | ||
|
||
APrimalStructure* structure = static_cast<APrimalStructure*>(actor); | ||
|
||
int structureTeam = structure->TargetingTeamField()(); | ||
if (structureTeam == teamId) | ||
{ | ||
structure->Destroy(false, true); | ||
num++; | ||
} | ||
} | ||
|
||
ss << "Destroyed " << num << " structures belonging to team " << teamId; | ||
|
||
delete FoundActors; | ||
return ArkApi::Tools::ConvertToWideStr(ss.str()); | ||
} | ||
|
||
return {}; | ||
} |
9 changes: 9 additions & 0 deletions
9
ImprovedCommands/Commands/DestroyAllStructuresForTeamIdCommand.h
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 "../Utils.h" | ||
|
||
DECLARE_COMMAND(DestroyAllStructuresForTeamId_Rcon); | ||
DECLARE_COMMAND(DestroyAllStructuresForTeamId_Console); | ||
|
||
void DestroyAllStructuresForTeamIdRconCommand(RCONClientConnection* rconClientConnection, RCONPacket* rconPacket, UWorld* uWorld); | ||
void DestroyAllStructuresForTeamIdConsoleCommand(APlayerController* aPlayerController, FString* cmd, bool bWriteToLog); | ||
std::wstring DestroyAllStructuresForTeamIdInternal(FString* cmd); |
75 changes: 75 additions & 0 deletions
75
ImprovedCommands/Commands/DestroyDinosForTeamIdCommand.cpp
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,75 @@ | ||
#include "DestroyDinosForTeamIdCommand.h" | ||
#include <sstream> | ||
|
||
void DestroyDinosForTeamIdRconCommand(RCONClientConnection* rconClientConnection, RCONPacket* rconPacket, UWorld* uWorld) | ||
{ | ||
FString msg = rconPacket->Body; | ||
|
||
auto result = DestroyDinosForTeamIdInternal(&msg); | ||
if (result.length() == 0) return; | ||
|
||
FString reply(result.c_str()); | ||
reply.AppendChar(L'\n'); | ||
rconClientConnection->SendMessageW(rconPacket->Id, 0, &reply); | ||
} | ||
|
||
void DestroyDinosForTeamIdConsoleCommand(APlayerController* aPlayerController, FString* cmd, bool bWriteToLog) | ||
{ | ||
auto result = DestroyDinosForTeamIdInternal(cmd); | ||
if (result.length() == 0) return; | ||
|
||
auto aShooterPlayerController = static_cast<AShooterPlayerController*>(aPlayerController); | ||
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", result.c_str()); | ||
} | ||
|
||
std::wstring DestroyDinosForTeamIdInternal(FString* cmd) | ||
{ | ||
TArray<FString> Parsed; | ||
cmd->ParseIntoArray(Parsed, L" ", true); | ||
|
||
if (Parsed.IsValidIndex(1)) | ||
{ | ||
__int64 teamId; | ||
|
||
try | ||
{ | ||
teamId = std::stoull(*Parsed[1]); | ||
} | ||
catch (const std::exception&) | ||
{ | ||
return {}; | ||
} | ||
|
||
if (teamId < 50000) return {}; | ||
|
||
UWorld* world = ArkApi::GetApiUtils().GetWorld(); | ||
if (!world) return {}; | ||
|
||
TArray<AActor*>* FoundActors = new TArray<AActor*>(); | ||
UGameplayStatics::GetAllActorsOfClass(world, APrimalDinoCharacter::GetPrivateStaticClass(), FoundActors); | ||
|
||
std::stringstream ss; | ||
|
||
int num = 0; | ||
for (uint32_t i = 0; i < FoundActors->Num(); i++) | ||
{ | ||
AActor* actor = (*FoundActors)[i]; | ||
|
||
APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(actor); | ||
|
||
int dinoTeam = dino->TargetingTeamField()(); | ||
if (dinoTeam == teamId) | ||
{ | ||
dino->Destroy(false, true); | ||
num++; | ||
} | ||
} | ||
|
||
ss << "Destroyed " << num << " dinos belonging to team " << teamId; | ||
|
||
delete FoundActors; | ||
return ArkApi::Tools::ConvertToWideStr(ss.str()); | ||
} | ||
|
||
return {}; | ||
} |
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 "../Utils.h" | ||
|
||
DECLARE_COMMAND(DestroyDinosForTeamId_Rcon); | ||
DECLARE_COMMAND(DestroyDinosForTeamId_Console); | ||
|
||
void DestroyDinosForTeamIdRconCommand(RCONClientConnection* rconClientConnection, RCONPacket* rconPacket, UWorld* uWorld); | ||
void DestroyDinosForTeamIdConsoleCommand(APlayerController* aPlayerController, FString* cmd, bool bWriteToLog); | ||
std::wstring DestroyDinosForTeamIdInternal(FString* 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,46 @@ | ||
#include "DestroyMyDinoCommand.h" | ||
#include <sstream> | ||
|
||
// Note: This command does not check tribe permissions | ||
void DestroyMyDinoChatCommand(AShooterPlayerController* aShooterPlayerController, FString* message, EChatSendMode::Type mode) | ||
{ | ||
auto cmd = ArkLibrary::GetCommand(CommandName_DestroyMyDino_Chat); | ||
const uint64 steam_id = ArkApi::IApiUtils::GetSteamIdFromController(aShooterPlayerController); | ||
if (cmd && cmd->Permissions == true && !CheckPermission(steam_id, "ImprovedCommands.DestroyMyDino", aShooterPlayerController)) return; | ||
|
||
bool methodSuicide = cmd && cmd->Json.value("Method", "destroy").compare("suicide") == 0; | ||
|
||
UWorld* world = ArkApi::GetApiUtils().GetWorld(); | ||
if (!world) return; | ||
if (!aShooterPlayerController) return; | ||
|
||
ACharacter* character = aShooterPlayerController->CharacterField()(); | ||
if (!character || !character->IsA(APrimalCharacter::GetPrivateStaticClass())) return; | ||
|
||
APrimalCharacter* primalCharacter = static_cast<APrimalCharacter*>(character); | ||
AActor* actor = primalCharacter->GetAimedActor(ECollisionChannel::ECC_GameTraceChannel2, 0i64, 0.0, 0.0, 0i64, 0i64, 0, 0); | ||
if (!actor || !actor->IsA(APrimalDinoCharacter::GetPrivateStaticClass())) return; | ||
|
||
APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(actor); | ||
int dinoTeam = dino->TargetingTeamField()(); | ||
int playerTeam = aShooterPlayerController->TargetingTeamField()(); | ||
if (dinoTeam != playerTeam) return; | ||
|
||
FString* className = new FString(); | ||
dino->DinoNameTagField()().ToString(className); //species name | ||
std::string name = dino->TamedNameField()().ToString(); //tamed name | ||
std::string classNameStr = className->ToString(); | ||
|
||
if (methodSuicide) dino->Suicide(); | ||
else dino->Destroy(false, true); | ||
|
||
std::stringstream ss; | ||
|
||
if (name.length() > 0) ss << "Destroyed creature '" << name << "' (" << classNameStr << ")"; | ||
else ss << "Destroyed targeted creature (" << classNameStr << ")"; | ||
|
||
auto wcstring = ArkApi::Tools::ConvertToWideStr(ss.str()); | ||
ArkApi::GetApiUtils().SendChatMessage(aShooterPlayerController, L"[system]", wcstring.c_str()); | ||
|
||
delete className; | ||
} |
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,6 @@ | ||
#pragma once | ||
#include "../Utils.h" | ||
|
||
DECLARE_COMMAND(DestroyMyDino_Chat); | ||
|
||
void DestroyMyDinoChatCommand(AShooterPlayerController* aShooterPlayerController, FString* message, EChatSendMode::Type mode); |
Oops, something went wrong.