Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ArkApiUtils.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4
5#include <API/ARK/Ark.h>
6#include <../Private/Ark/Globals.h>
8#include "API/Helpers/Helpers.h"
9
10namespace AsaApi
11{
12 enum class ServerStatus { Loading, Ready };
13
14 struct MapCoords
15 {
16 float x = 0.f;
17 float y = 0.f;
18 };
19
21 {
22 public:
23 virtual ~IApiUtils() = default;
24 /**
25 * \brief Returns a pointer to UWorld
26 */
27 virtual UWorld* GetWorld() const = 0;
28
29 /**
30 * \brief Returns a pointer to AShooterGameMode
31 */
33
34 /**
35 * \brief Returns the current server status
36 */
37 virtual ServerStatus GetStatus() const = 0;
38
39 /**
40 * \brief Returns a point to URCON CheatManager
41 */
43 /**
44 * \brief Sends server message to the specific player. Using fmt::format.
45 * \tparam T Either a a char or wchar_t
46 * \tparam Args Optional arguments types
47 * \param player_controller Player
48 * \param msg_color Message color
49 * \param msg Message
50 * \param args Optional arguments
51 */
52 template <typename T, typename... Args>
53 FORCEINLINE void SendServerMessage(AShooterPlayerController* player_controller, FLinearColor msg_color, const T* msg, Args&&... args)
54 {
56 }
57
58 /**
59 * \brief Sends notification (on-screen message) to the specific player. Using fmt::format.
60 * \tparam T Either a a char or wchar_t
61 * \tparam Args Optional arguments types
62 * \param player_controller Player
63 * \param color Message color
64 * \param display_scale Size of text
65 * \param display_time Display time
66 * \param icon Message icon (optional)
67 * \param msg Message
68 * \param args Optional arguments
69 */
70 template <typename T, typename... Args>
71 FORCEINLINE void SendNotification(AShooterPlayerController* player_controller, FLinearColor color, float display_scale,
72 float display_time, UTexture2D* icon, const T* msg, Args&&... args)
73 {
75 }
76
77 /**
78 * \brief Sends chat message to the specific player. Using fmt::format.
79 * \tparam T Either a a char or wchar_t
80 * \tparam Args Optional arguments types
81 * \param player_controller Player
82 * \param sender_name Name of the sender
83 * \param msg Message
84 * \param args Optional arguments
85 */
86 template <typename T, typename... Args>
87 FORCEINLINE void SendChatMessage(AShooterPlayerController* player_controller, const FString& sender_name, const T* msg,
88 Args&&... args)
89 {
91 }
92
93 /**
94 * \brief Sends server message to all players. Using fmt::format.
95 * \tparam T Either a a char or wchar_t
96 * \tparam Args Optional arguments types
97 * \param msg_color Message color
98 * \param msg Message
99 * \param args Optional arguments
100 */
101 template <typename T, typename... Args>
102 FORCEINLINE void SendServerMessageToAll(FLinearColor msg_color, const T* msg, Args&&... args)
103 {
105 }
106
107 /**
108 * \brief Sends notification (on-screen message) to all players. Using fmt::format.
109 * \tparam T Either a a char or wchar_t
110 * \tparam Args Optional arguments types
111 * \param color Message color
112 * \param display_scale Size of text
113 * \param display_time Display time
114 * \param icon Message icon (optional)
115 * \param msg Message
116 * \param args Optional arguments
117 */
118 template <typename T, typename... Args>
119 FORCEINLINE void SendNotificationToAll(FLinearColor color, float display_scale,
120 float display_time, UTexture2D* icon, const T* msg, Args&&... args)
121 {
123 }
124
125 /**
126 * \brief Sends chat message to all players. Using fmt::format.
127 * \tparam T Either a a char or wchar_t
128 * \tparam Args Optional arguments types
129 * \param sender_name Name of the sender
130 * \param msg Message
131 * \param args Optional arguments
132 */
133 template <typename T, typename... Args>
134 FORCEINLINE void SendChatMessageToAll(const FString& sender_name, const T* msg, Args&&... args)
135 {
137 }
138
139 /**
140 * \brief Returns EOS ID from player controller
141 */
143 {
144 FString eos_id = "";
145
146 AShooterPlayerController* playerController = static_cast<AShooterPlayerController*>(controller);
147 if (playerController != nullptr)
148 playerController->GetUniqueNetIdAsString(&eos_id);
149
150 return eos_id;
151 }
152
153 /**
154 * \brief Finds player from the given platform name (can be steam, Playstation, Xbox, etc...)
155 * \param steam_name Platform name
156 * \return Pointer to AShooterPlayerController
157 */
159 {
160 AShooterPlayerController* result = nullptr;
161 const auto& player_controllers = GetWorld()->PlayerControllerListField();
162 for (TWeakObjectPtr<APlayerController> player_controller : player_controllers)
163 {
164 const FString current_name = player_controller->PlayerStateField()->PlayerNamePrivateField();
165 if (current_name == steam_name)
166 {
167 auto* shooter_pc = static_cast<AShooterPlayerController*>(player_controller.Get());
168
169 result = shooter_pc;
170 break;
171 }
172 }
173
174 return result;
175 }
176
177 /**
178 * \brief Finds player controller from the given player character
179 * \param character Player character
180 * \return Pointer to AShooterPlayerController
181 */
183 {
184 AShooterPlayerController* result = nullptr;
185
186 if (character != nullptr && !character->IsDead())
188
189 return result;
190 }
191
192 /**
193 * \brief Finds all matching players from the given character name
194 * \param character_name Character name
195 * \param search Type Defaulted To ESearchCase::Type::IgnoreCase
196 * \param full_match Will match the full length of the string if true
197 * \return Array of AShooterPlayerController*
198 */
201 bool full_match) const
202 {
203 TArray<AShooterPlayerController*> found_players;
204 const auto& player_controllers = GetWorld()->PlayerControllerListField();
205 for (TWeakObjectPtr<APlayerController> player_controller : player_controllers)
206 {
207 auto* shooter_player = static_cast<AShooterPlayerController*>(player_controller.Get());
208 FString char_name = GetCharacterName(shooter_player);
209
210 if (!char_name.IsEmpty() && (full_match
211 ? char_name.Equals(character_name, search)
212 : char_name.StartsWith(character_name, search)))
213 {
214 found_players.Add(shooter_player);
215 }
216 }
217 return found_players;
218 }
219
220 /**
221 * \brief Returns the character name of player
222 * \param player_controller Player
223 */
225 {
226 if (player_controller != nullptr)
227 {
228 FString player_name("");
229 player_controller->GetPlayerCharacterName(&player_name);
230 return player_name;
231 }
232
233 return FString("");
234 }
235
236 /**
237 * \brief Returns the steam name of player
238 * \param player_controller Player
239 */
240 static FORCEINLINE FString GetSteamName(AController* player_controller)
241 {
242 return player_controller != nullptr ? player_controller->PlayerStateField()->PlayerNamePrivateField() : "";
243 }
244
245 /**
246 * \brief Finds player from the given eos id
247 * \param eos_id EOS id
248 * \return Pointer to AShooterPlayerController
249 */
251 {
253 }
254
255 /**
256 * \brief Spawns an item drop
257 * \param blueprint Item simplified BP
258 * Example: '/Game/PrimalEarth/CoreBlueprints/Items/Armor/Riot/PrimalItemArmor_RiotPants.PrimalItemArmor_RiotPants_C'
259 * \param pos Spawn position
260 * \param amount Quantity
261 * \param item_quality Quality
262 * \param force_blueprint Is blueprint
263 * \param life_span Life span
264 * \return Returns true if drop was spawned, false otherwise
265 */
266 FORCEINLINE bool SpawnDrop(const wchar_t* blueprint, FVector pos, int amount, float item_quality = 0.0f,
267 bool force_blueprint = false, float life_span = 0.0f) const
268 {
270 if (!player)
271 return false;
272
273 FString bpFstr(blueprint);
274
275 TSubclassOf<UObject> archetype;
276 UVictoryCore::StringReferenceToClass(&archetype, &bpFstr);
277
278 UPrimalItem* item = UPrimalItem::AddNewItem(archetype.uClass, nullptr, false, false, item_quality, false, amount, force_blueprint, 0, false, nullptr, 0, 0, 0, true);
279
280 if (!item)
281 return false;
282
283 FItemNetInfo* info = AllocateStruct<FItemNetInfo>();
284
285 item->GetItemNetInfo(info, false);
286
287 TSubclassOf<ADroppedItem> archetype_dropped;
288 archetype_dropped.uClass = archetype.uClass;
289
290 FVector zero_vector{ 0, 0, 0 };
291 FRotator rot{ 0, 0, 0 };
292
293 UPrimalInventoryComponent::StaticDropItem(player, info, archetype_dropped, &rot, true, &pos, &rot, true, false, false, true, nullptr, &zero_vector, nullptr, life_span);
294
295 FreeStruct(info);
296 return true;
297 }
298
299 /**
300 * \brief Spawns a dino near player or at specific coordinates
301 * \param player Player. If null, random player will be chosen. At least one player should be on the map
302 * \param blueprint Blueprint path
303 * \param location Spawn position. If null, dino will be spawned near player
304 * \param lvl Level of the dino
305 * \param force_tame Force tame
306 * \param neutered Neuter dino
307 * \return Spawned dino or null
308 */
309 FORCEINLINE APrimalDinoCharacter* SpawnDino(AShooterPlayerController* player, FString blueprint, FVector* location, int lvl,
310 bool force_tame, bool neutered) const
311 {
312 if (player == nullptr)
313 {
315 if (player == nullptr)
316 {
317 return nullptr;
318 }
319 }
320
321 AActor* actor = player->SpawnActor(&blueprint, 100, 0, 0, true);
322 if (actor != nullptr && actor->IsA(APrimalDinoCharacter::GetPrivateStaticClass()))
323 {
324 auto* dino = static_cast<APrimalDinoCharacter*>(actor);
325
326 if (location != nullptr && !location->IsZero())
327 {
328 FRotator rotation{ 0, 0, 0 };
329 dino->TeleportTo(location, &rotation, true, false);
330 }
331
332 if (force_tame)
333 {
335
336 auto* state = static_cast<AShooterPlayerState*>(player->PlayerStateField().Get());
337
338 FString player_name;
339 player->GetPlayerCharacterName(&player_name);
340
341 dino->TamerStringField() = player_name;
342
343 state->SetTribeTamingDinoSettings(dino);
344
345 dino->TameDino(player, true, 0, true, true, false);
346 }
347
348 if (neutered)
349 {
351 }
352
354
355 dino->BeginPlay();
356
357 return dino;
358 }
359 return nullptr;
360 }
361
362 /**
363 * \brief Returns true if character is riding a dino, false otherwise
364 * \param player_controller Player
365 */
366 static FORCEINLINE bool IsRidingDino(AShooterPlayerController* player_controller)
367 {
368 return player_controller != nullptr && player_controller->GetPlayerCharacter() != nullptr
369 && player_controller->GetPlayerCharacter()->GetRidingDino() != nullptr;
370 }
371
372 /**
373 * \brief Returns the dino the character is riding
374 * \param player_controller Player
375 * \return APrimalDinoCharacter*
376 */
378 {
379 return player_controller != nullptr && player_controller->GetPlayerCharacter() != nullptr
380 ? player_controller->GetPlayerCharacter()->GetRidingDino()
381 : nullptr;
382 }
383
384 /**
385 * \brief Returns the position of a player
386 * \param player_controller Player
387 * \return FVector
388 */
389 static FORCEINLINE FVector GetPosition(APlayerController* player_controller)
390 {
391 return player_controller != nullptr && player_controller->PawnField() != nullptr ? player_controller->PawnField()->RootComponentField()->RelativeLocationField() : FVector{0, 0, 0};
392 }
393
394 /**
395 * \brief Teleport one player to another
396 * \param me Player
397 * \param him Other Player
398 * \param check_for_dino If set true prevents players teleporting with dino's or teleporting to a player on a dino
399 * \param max_dist Is the max distance the characters can be away from each other -1 is disabled
400 */
402 bool check_for_dino, float max_dist)
403 {
404 FVector him_position = GetPosition(him);
405 if (!(me != nullptr && him != nullptr && me->GetPlayerCharacter() != nullptr && him->
406 GetPlayerCharacter()
407 != nullptr
408 && !me->GetPlayerCharacter()->IsDead() && !him->GetPlayerCharacter()->IsDead())
409 )
410 {
411 return "One of players is dead";
412 }
413
414 if (check_for_dino && (IsRidingDino(me) || IsRidingDino(him)))
415 {
416 return "One of players is riding a dino";
417 }
418
419 if (max_dist != -1 && FVector::Distance(GetPosition(me), him_position) > max_dist)
420 {
421 return "Person is too far away";
422 }
423
424 if (him_position.IsNearlyZero())
425 {
426 return "Player location is invalid";
427 }
428
429 me->SetPlayerPos((float)him_position.X, (float)him_position.Y, (float)him_position.Z);
430
431 return {};
432 }
433
434 /**
435 * \brief Teleports player to the given position
436 * \param player_controller Player
437 * \param pos New position
438 */
439 static FORCEINLINE bool TeleportToPos(AShooterPlayerController* player_controller, const FVector& pos)
440 {
441 if (player_controller != nullptr && !IsPlayerDead(player_controller))
442 {
443 player_controller->SetPlayerPos((float)pos.X, (float)pos.Y, (float)pos.Z);
444 return true;
445 }
446
447 return false;
448 }
449
450 /**
451 * \brief Counts a specific items quantity
452 * \param player_controller Player
453 * \param item_name The name of the item you want to count the quantity of
454 * \return On success, the function returns amount of items player has. Returns -1 if the function has failed.
455 */
456 static FORCEINLINE int GetInventoryItemCount(AShooterPlayerController* player_controller, const FString& item_name)
457 {
458 if (player_controller == nullptr)
459 {
460 return -1;
461 }
462
463 UPrimalInventoryComponent* inventory_component =
464 player_controller->GetPlayerCharacter()->MyInventoryComponentField();
465 if (inventory_component == nullptr)
466 {
467 return -1;
468 }
469
470 FString name;
471 int item_count = 0;
472
473 for (UPrimalItem* item : inventory_component->InventoryItemsField())
474 {
475 item->GetItemName(&name, true, false, nullptr);
476
477 if (name.Equals(item_name, ESearchCase::IgnoreCase))
478 {
479 item_count += item->GetItemQuantity();
480 }
481 }
482
483 return item_count;
484 }
485
486 /**
487 * \brief Returns IP address of player
488 */
490 {
491 FString addr;
492 if (player)
494 return addr;
495 }
496
497 /**
498 * \brief Returns blueprint from UPrimalItem
499 */
501 {
502 return GetBlueprint(item);
503 }
504
505 /**
506 * \brief Returns true if player is dead, false otherwise
507 */
509 {
510 if (player == nullptr || player->GetPlayerCharacter() == nullptr)
511 {
512 return true;
513 }
514
515 return player->GetPlayerCharacter()->IsDead();
516 }
517
518 static FORCEINLINE uint64 GetPlayerID(APrimalCharacter* character)
519 {
520 auto* shooter_character = static_cast<AShooterCharacter*>(character);
521 return shooter_character != nullptr && shooter_character->GetPlayerData() != nullptr
523 : 0;
524 }
525
526 static FORCEINLINE uint64 GetPlayerID(AController* controller)
527 {
528 auto* player = static_cast<AShooterPlayerController*>(controller);
529 return player != nullptr ? player->LinkedPlayerIDField() : 0;
530 }
531
533 {
534 FString eos_id;
535
536 if (player_id == 0)
537 {
538 return eos_id;
539 }
540
542 if (eos_id.IsEmpty())
543 {
544 const auto& player_controllers = GetWorld()->PlayerControllerListField();
545 for (TWeakObjectPtr<APlayerController> player_controller : player_controllers)
546 {
547 auto* shooter_pc = static_cast<AShooterPlayerController*>(player_controller.Get());
548 if (shooter_pc != nullptr && shooter_pc->LinkedPlayerIDField() == player_id)
549 {
550 shooter_pc->GetUniqueNetIdAsString(&eos_id);
551 break;
552 }
553 }
554
555 if (!eos_id.IsEmpty())
556 {
557 GetShooterGameMode()->AddPlayerID(player_id, &eos_id, false);
558 }
559 }
560
561 return eos_id;
562 }
563
564 /**
565 * \brief Returns blueprint path from any UObject
566 */
568 {
569 if (object != nullptr && object->ClassPrivateField() != nullptr)
570 {
572 return path_name.Replace(L"Default__", L"", ESearchCase::CaseSensitive);
573 }
574
575 return FString("");
576 }
577
578 /**
579 * \brief Returns blueprint path from any UClass
580 */
582 {
583 if (the_class != nullptr)
584 {
585 FString path;
586 auto the_object = UVictoryCore::GetClassDefaultObject(the_class);
587 the_object->GetPathName(nullptr, &path);
588 if (path.EndsWith("_C"))
589 return "Blueprint'" + path.LeftChop(2) + "'";
590 else
591 return "Blueprint'" + path + "'";
592 }
593
594 return FString("");
595 }
596
597 /**
598 * \brief Get Shooter Game State
599 */
601 {
602 return static_cast<AShooterGameState*>(GetWorld()->GameStateField().Get());
603 }
604
605 /**
606 * \brief Get UShooterCheatManager* of player controller
607 */
609 {
610 if (!SPC) return nullptr;
611
612 UCheatManager* cheat = SPC->CheatManagerField().Get();
613
614 if (cheat)
615 {
616 return static_cast<UShooterCheatManager*>(cheat);
617 }
618
619 return nullptr;
620 }
621
622 /**
623 * \brief Get Tribe ID of player controller
624 */
625 static FORCEINLINE int GetTribeID(AShooterPlayerController* player_controller)
626 {
627 int team = 0;
628
629 if (player_controller)
630 {
631 team = player_controller->TargetingTeamField();
632 }
633
634 return team;
635 }
636
637 /**
638 * \brief Get Tribe ID of character
639 */
640 static FORCEINLINE int GetTribeID(AShooterCharacter* player_character)
641 {
642 int team = 0;
643
644 if (player_character)
645 {
646 team = player_character->TargetingTeamField();
647 }
648
649 return team;
650 }
651
652 /**
653 * \brief Returns pointer to Primal Game Data
654 */
656 {
657 UPrimalGlobals* singleton = static_cast<UPrimalGlobals*>(Globals::GEngine()()->GameSingletonField().Get());
658 return (singleton->PrimalGameDataOverrideField() != nullptr) ? singleton->PrimalGameDataOverrideField() : singleton->PrimalGameDataField();
659 }
660
661 /**
662 * \brief Gets all actors in radius at location
663 */
665 {
666 TArray<AActor*> out_actors;
667
668 UVictoryCore::ServerOctreeOverlapActors(&out_actors, GetWorld(), &location, radius, ActorType, true);
669
670 return out_actors;
671 }
672
673 /**
674 * \brief Gets all actors in radius at location, with ignore actors
675 */
677 {
678 TArray<AActor*> out_actors;
679
680 UVictoryCore::ServerOctreeOverlapActors(&out_actors, GetWorld(), &location, radius, ActorType, true);
681
682 for (AActor* ignore : ignores)
683 out_actors.Remove(ignore);
684
685 return out_actors;
686 }
687
688 /**
689 * \brief Converts FVector into coords that are displayed when you view the ingame map
690 */
691 FORCEINLINE MapCoords FVectorToCoords(FVector actor_position)
692 {
693 MapCoords coords;
694 AWorldSettings* world_settings = GetWorld()->GetWorldSettings(false, true);
695 APrimalWorldSettings* p_world_settings = static_cast<APrimalWorldSettings*>(world_settings);
696
697 float lat_scale = p_world_settings->LatitudeScaleField() != 0 ? p_world_settings->LatitudeScaleField() : 800.0f;
698 float lon_scale = p_world_settings->LongitudeScaleField() != 0 ? p_world_settings->LongitudeScaleField() : 800.0f;
699
700 float lat_origin = p_world_settings->LatitudeOriginField() != 0 ? p_world_settings->LatitudeOriginField() : -400000.0f;
701 float lon_origin = p_world_settings->LongitudeOriginField() != 0 ? p_world_settings->LongitudeOriginField() : -400000.0f;
702
703 float lat_div = 100.f / lat_scale;
704 float lat = (lat_div * (float)actor_position.Y + lat_div * abs(lat_origin)) / 1000.f;
705
706 float lon_div = 100.f / lon_scale;
707 float lon = (lon_div * (float)actor_position.X + lon_div * abs(lon_origin)) / 1000.f;
708
709 coords.x = std::floor(lon * 10.0f) / 10.0f;
710 coords.y = std::floor(lat * 10.0f) / 10.0f;
711 return coords;
712 }
713
714 /**
715 * \brief obtains the steam ID of an attacker, meant to be used in hooks such as TakeDamage
716 * \param tribe_check if set to true will return NULL if the target is from the same tribe as the attacker
717 */
718 FORCEINLINE const FString GetAttackerEOSID(AActor* target, AController* killer, AActor* damage_causer, bool tribe_check = true)
719 {
720 FString eos_id = "";
721
722 if (target)
723 {
725 && (!tribe_check || (tribe_check && target->TargetingTeamField() != killer->TargetingTeamField())))
726 eos_id = GetEOSIDFromController(static_cast<AShooterPlayerController*>(killer));
727 else if (damage_causer && (!tribe_check || (tribe_check && target->TargetingTeamField() != damage_causer->TargetingTeamField()))
729 {
730 APrimalStructureExplosive* explosive = static_cast<APrimalStructureExplosive*>(damage_causer);
732 }
733 }
734
735 return eos_id;
736 }
737
738 /**
739 * \brief Create a new object of T, with the correct size
740 * \tparam T struct type. Must have ScriptStruct defined
741 * \return Pointer to T
742 */
743 template<class T>
745 {
746 static int size = GetStructSize<T>();
747 T* obj = static_cast<T*>(FMemory::Malloc(size));
749 return obj;
750 }
751
752 /**
753 * \brief Free a struct allocated
754 * \param obj Pointer to struct
755 */
756 static FORCEINLINE void FreeStruct(void* obj)
757 {
759 }
760
761 /**
762 * \brief Runs a command that is not logged anywhere
763 * \param _this Player controller
764 * \param Command Command to run
765 */
767 {
768 FString result;
769 HideCommand = true;
770 _this->ConsoleCommand(&result, Command, false);
771 HideCommand = false;
772 }
773
774 /**
775 * \brief Gets the current messaging manager for the plugin, without casting
776 * \return MessagingManager
777 */
779 {
780 return GetMessagingManagerInternal(GetDllName());
781 }
782
783 /**
784 * \brief Gets the current messaging manager for the plugin
785 * \tparam T MessagingManager type
786 * \return MessagingManager as T
787 */
788 template <class T>
790 {
791 static_assert(std::is_base_of<MessagingManager, T>::value, "T must inherit from MessagingManager");
793 }
794
795 /**
796 * \brief Sets the messaging manager for the current plugin
797 * \tparam T MessagingManager type
798 */
799 template <class T>
801 {
802 static_assert(std::is_base_of<MessagingManager, T>::value, "T must inherit from MessagingManager");
804 }
805
806 private:
809 virtual void SetMessagingManagerInternal(const FString& forPlugin, std::shared_ptr<MessagingManager> manager) = 0;
810 };
811
812 ARK_API IApiUtils& APIENTRY GetApiUtils();
813} // namespace AsaApi
#define ARK_API
Definition Ark.h:16
bool HideCommand
Definition Globals.h:3
#define FORCEINLINE
Definition Platform.h:644
std::unordered_map< const FString, AShooterPlayerController *, FStringHash, FStringEqual > eos_id_map_
Definition ApiUtils.h:46
void SetStatus(ServerStatus status)
Definition ApiUtils.cpp:41
std::shared_ptr< MessagingManager > GetMessagingManagerInternal(const FString &forPlugin) const override
Definition ApiUtils.cpp:124
void SetCheatManager(UShooterCheatManager *cheatmanager)
Definition ApiUtils.cpp:52
ApiUtils(const ApiUtils &)=delete
std::shared_ptr< MessagingManager > ReadApiMessagingManager()
Definition ApiUtils.cpp:185
UShooterCheatManager * GetCheatManager() const override
Returns a point to URCON CheatManager.
Definition ApiUtils.cpp:119
ApiUtils(ApiUtils &&)=delete
ApiUtils()=default
void CheckMessagingManagersRequirements()
Definition ApiUtils.cpp:155
AShooterPlayerController * FindPlayerFromEOSID_Internal(const FString &eos_id) const override
Definition ApiUtils.cpp:83
AShooterGameMode * GetShooterGameMode() const override
Returns a pointer to AShooterGameMode.
Definition ApiUtils.cpp:34
ApiUtils & operator=(const ApiUtils &)=delete
void SetShooterGameMode(AShooterGameMode *shooter_game_mode)
Definition ApiUtils.cpp:29
void RemoveMessagingManagerInternal(const FString &forPlugin)
Definition ApiUtils.cpp:147
ApiUtils & operator=(ApiUtils &&)=delete
AShooterGameMode * shooter_game_mode_
Definition ApiUtils.h:43
UWorld * GetWorld() const override
Returns a pointer to UWorld.
Definition ApiUtils.cpp:22
void SetMessagingManagerInternal(const FString &forPlugin, std::shared_ptr< MessagingManager > manager) override
Definition ApiUtils.cpp:135
ServerStatus GetStatus() const override
Returns the current server status.
Definition ApiUtils.cpp:46
ServerStatus status_
Definition ApiUtils.h:44
void SetPlayerController(AShooterPlayerController *player_controller)
Definition ApiUtils.cpp:57
UWorld * u_world_
Definition ApiUtils.h:42
void RemovePlayerController(AShooterPlayerController *player_controller)
Definition ApiUtils.cpp:70
~ApiUtils() override=default
void SetWorld(UWorld *uworld)
Definition ApiUtils.cpp:13
UShooterCheatManager * cheatmanager_
Definition ApiUtils.h:45
FORCEINLINE AShooterGameState * GetGameState()
Get Shooter Game State.
virtual UShooterCheatManager * GetCheatManager() const =0
Returns a point to URCON CheatManager.
FORCEINLINE void SendNotificationToAll(FLinearColor color, float display_scale, float display_time, UTexture2D *icon, const T *msg, Args &&... args)
Sends notification (on-screen message) to all players. Using fmt::format.
FORCEINLINE TArray< AActor * > GetAllActorsInRange(FVector location, float radius, EServerOctreeGroup::Type ActorType)
Gets all actors in radius at location.
FORCEINLINE std::shared_ptr< T > GetMessagingManagerCasted() const
Gets the current messaging manager for the plugin.
FORCEINLINE MapCoords FVectorToCoords(FVector actor_position)
Converts FVector into coords that are displayed when you view the ingame map.
FORCEINLINE const FString GetAttackerEOSID(AActor *target, AController *killer, AActor *damage_causer, bool tribe_check=true)
obtains the steam ID of an attacker, meant to be used in hooks such as TakeDamage
static FORCEINLINE FString GetClassBlueprint(UClass *the_class)
Returns blueprint path from any UClass.
FORCEINLINE AShooterPlayerController * FindPlayerFromEOSID(const FString &eos_id) const
Finds player from the given eos id.
virtual ~IApiUtils()=default
FORCEINLINE void SendNotification(AShooterPlayerController *player_controller, FLinearColor color, float display_scale, float display_time, UTexture2D *icon, const T *msg, Args &&... args)
Sends notification (on-screen message) to the specific player. Using fmt::format.
Definition ArkApiUtils.h:71
static FORCEINLINE APrimalDinoCharacter * GetRidingDino(AShooterPlayerController *player_controller)
Returns the dino the character is riding.
FORCEINLINE void SendServerMessageToAll(FLinearColor msg_color, const T *msg, Args &&... args)
Sends server message to all players. Using fmt::format.
static FORCEINLINE int GetTribeID(AShooterCharacter *player_character)
Get Tribe ID of character.
static FORCEINLINE int GetTribeID(AShooterPlayerController *player_controller)
Get Tribe ID of player controller.
static FORCEINLINE uint64 GetPlayerID(AController *controller)
FORCEINLINE TArray< AActor * > GetAllActorsInRange(FVector location, float radius, EServerOctreeGroup::Type ActorType, TArray< AActor * > ignores)
Gets all actors in radius at location, with ignore actors.
FORCEINLINE std::shared_ptr< MessagingManager > GetMessagingManager() const
Gets the current messaging manager for the plugin, without casting.
static FORCEINLINE FVector GetPosition(APlayerController *player_controller)
Returns the position of a player.
FORCEINLINE void SendServerMessage(AShooterPlayerController *player_controller, FLinearColor msg_color, const T *msg, Args &&... args)
Sends server message to the specific player. Using fmt::format.
Definition ArkApiUtils.h:53
FORCEINLINE TArray< AShooterPlayerController * > FindPlayerFromCharacterName(const FString &character_name, ESearchCase::Type search, bool full_match) const
Finds all matching players from the given character name.
static FORCEINLINE bool IsRidingDino(AShooterPlayerController *player_controller)
Returns true if character is riding a dino, false otherwise.
static FORCEINLINE uint64 GetPlayerID(APrimalCharacter *character)
FORCEINLINE UPrimalGameData * GetGameData()
Returns pointer to Primal Game Data.
virtual std::shared_ptr< MessagingManager > GetMessagingManagerInternal(const FString &forPlugin) const =0
static FORCEINLINE void FreeStruct(void *obj)
Free a struct allocated.
static FORCEINLINE UShooterCheatManager * GetCheatManagerByPC(AShooterPlayerController *SPC)
Get UShooterCheatManager* of player controller.
FORCEINLINE AShooterPlayerController * FindControllerFromCharacter(AShooterCharacter *character) const
Finds player controller from the given player character.
static FORCEINLINE FString GetIPAddress(AShooterPlayerController *player)
Returns IP address of player.
static FORCEINLINE std::optional< FString > TeleportToPlayer(AShooterPlayerController *me, AShooterPlayerController *him, bool check_for_dino, float max_dist)
Teleport one player to another.
FORCEINLINE bool SpawnDrop(const wchar_t *blueprint, FVector pos, int amount, float item_quality=0.0f, bool force_blueprint=false, float life_span=0.0f) const
Spawns an item drop.
void SetMessagingManager()
Sets the messaging manager for the current plugin.
static FORCEINLINE bool TeleportToPos(AShooterPlayerController *player_controller, const FVector &pos)
Teleports player to the given position.
virtual void SetMessagingManagerInternal(const FString &forPlugin, std::shared_ptr< MessagingManager > manager)=0
static FORCEINLINE bool IsPlayerDead(AShooterPlayerController *player)
Returns true if player is dead, false otherwise.
virtual AShooterGameMode * GetShooterGameMode() const =0
Returns a pointer to AShooterGameMode.
static FORCEINLINE FString GetSteamName(AController *player_controller)
Returns the steam name of player.
static FORCEINLINE FString GetCharacterName(AShooterPlayerController *player_controller)
Returns the character name of player.
FORCEINLINE void SendChatMessage(AShooterPlayerController *player_controller, const FString &sender_name, const T *msg, Args &&... args)
Sends chat message to the specific player. Using fmt::format.
Definition ArkApiUtils.h:87
FORCEINLINE AShooterPlayerController * FindPlayerFromPlatformName(const FString &steam_name) const
Finds player from the given platform name (can be steam, Playstation, Xbox, etc......
virtual ServerStatus GetStatus() const =0
Returns the current server status.
FORCEINLINE const FString GetEOSIDForPlayerID(int player_id)
FORCEINLINE APrimalDinoCharacter * SpawnDino(AShooterPlayerController *player, FString blueprint, FVector *location, int lvl, bool force_tame, bool neutered) const
Spawns a dino near player or at specific coordinates.
static FORCEINLINE FString GetItemBlueprint(UPrimalItem *item)
Returns blueprint from UPrimalItem.
FORCEINLINE void SendChatMessageToAll(const FString &sender_name, const T *msg, Args &&... args)
Sends chat message to all players. Using fmt::format.
static FORCEINLINE FString GetEOSIDFromController(AController *controller)
Returns EOS ID from player controller.
static FORCEINLINE int GetInventoryItemCount(AShooterPlayerController *player_controller, const FString &item_name)
Counts a specific items quantity.
static FORCEINLINE T * AllocateStruct()
Create a new object of T, with the correct size.
void RunHiddenCommand(AShooterPlayerController *_this, FString *Command)
Runs a command that is not logged anywhere.
static FORCEINLINE FString GetBlueprint(UObjectBase *object)
Returns blueprint path from any UObject.
virtual UWorld * GetWorld() const =0
Returns a pointer to UWorld.
virtual AShooterPlayerController * FindPlayerFromEOSID_Internal(const FString &eos_id) const =0
UE_NODISCARD bool EndsWith(const TCHAR *InSuffix, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
UE_NODISCARD FORCEINLINE friend FString operator+(const TCHAR *Lhs, FString &&Rhs)
UE_NODISCARD FORCEINLINE friend FString operator+(FString &&Lhs, const TCHAR *Rhs)
FString & operator=(FString &&)=default
UE_NODISCARD FORCEINLINE bool IsEmpty() const
ARK_API FString(const WIDECHAR *Str)
Definition String.cpp:250
ARK_API FString(const ANSICHAR *Str)
Definition String.cpp:249
UE_NODISCARD FORCEINLINE friend FString operator+(const TCHAR *Lhs, const FString &Rhs)
UE_NODISCARD FORCEINLINE FString LeftChop(int32 Count) const &
FString & operator=(const FString &)=default
Messaging manager. Allows to send server messages, notifications and chat messages.
IApiUtils & GetApiUtils()
Definition ApiUtils.cpp:206
@ CaseSensitive
Definition CString.h:25
Definition json.hpp:4518
static UClass * GetPrivateStaticClass()
Definition Actor.h:2753
bool IsLocalController()
Definition Actor.h:2237
FString * ConsoleCommand(FString *result, const FString *Cmd, bool bWriteToLog)
Definition Actor.h:2464
FString * GetPlayerNetworkAddress(FString *result)
Definition Actor.h:2656
bool IsDead()
Definition Actor.h:5005
void DoNeuter_Implementation()
Definition Actor.h:7823
void TameDino(AShooterPlayerController *ForPC, bool bIgnoreMaxTameLimit, int OverrideTamingTeamID, bool bPreventNameDialog, bool bSkipAddingTamedLevels, bool bSuppressNotifications)
Definition Actor.h:7631
static UClass * GetPrivateStaticClass()
Definition Actor.h:7399
int & TamingTeamIDField()
Definition Actor.h:6417
FString & TamerStringField()
Definition Actor.h:6258
int & AbsoluteBaseLevelField()
Definition Actor.h:6556
APlayerController * GetOwnerController()
Definition Actor.h:4188
unsigned int & ConstructorPlayerDataIDField()
static UClass * StaticClass()
float & LongitudeOriginField()
Definition GameMode.h:1402
float & LatitudeOriginField()
Definition GameMode.h:1403
float & LongitudeScaleField()
Definition GameMode.h:1397
float & LatitudeScaleField()
Definition GameMode.h:1401
UPrimalPlayerData * GetPlayerData()
Definition Actor.h:5978
void AddPlayerID(int playerDataID, FString *netUniqueString, bool bForce)
Definition GameMode.h:2396
FString * GetSteamIDStringForPlayerID(FString *result, int playerDataID)
Definition GameMode.h:2398
__int64 & LinkedPlayerIDField()
Definition Actor.h:2860
bool IsA(UClass *SomeBase)
Returns if the actor is from SomeBase or a subclass of SomeBase.
static void Free(void *Original)
unsigned __int64 & PlayerDataIDField()
Definition Other.h:2291
Definition UE.h:589
UClass *& ClassPrivateField()
Definition UE.h:191
void GetPathName(const UObject *StopOuter, FString *ResultString)
Definition UE.h:394
Definition UE.h:432
int & TargetingTeamField()
Definition Actor.h:120
UPrimalGameData *& PrimalGameDataField()
Definition GameMode.h:1158
UPrimalGameData *& PrimalGameDataOverrideField()
Definition GameMode.h:1159
FItemNetInfo * GetItemNetInfo(FItemNetInfo *result, bool bIsForSendingToClient)
Definition Inventory.h:529
FPrimalPlayerDataStruct * MyDataField()
Definition Actor.h:6226
static UObject * GetClassDefaultObject(UClass *FromClass)
Definition Other.h:74
TArray< TWeakObjectPtr< APlayerController >, TSizedDefaultAllocator< 32 > > & PlayerControllerListField()
Definition GameMode.h:516
APlayerController * GetFirstPlayerController()
Definition GameMode.h:743
AWorldSettings * GetWorldSettings(bool bCheckStreamingPersistent, bool bChecked)
Definition GameMode.h:750