@@ -8,6 +8,12 @@ namespace ArkApi
88{
99 enum class ServerStatus { Loading, Ready };
1010
11+ struct MapCoords
12+ {
13+ float x = 0 .f;
14+ float y = 0 .f;
15+ };
16+
1117 class ARK_API IApiUtils
1218 {
1319 public:
@@ -734,6 +740,57 @@ namespace ArkApi
734740
735741 return out_actors;
736742 }
743+
744+ /* *
745+ * \brief Converts FVector into coords that are displayed when you view the ingame map
746+ */
747+ FORCEINLINE MapCoords FVectorToCoords (FVector actor_position)
748+ {
749+ AWorldSettings* world_settings = GetWorld ()->GetWorldSettings (false , true );
750+ APrimalWorldSettings* p_world_settings = static_cast <APrimalWorldSettings*>(world_settings);
751+ MapCoords coords;
752+
753+ float lat_scale = p_world_settings->LatitudeScaleField () != 0 ? p_world_settings->LatitudeScaleField () : 800 .0f ;
754+ float lon_scale = p_world_settings->LongitudeScaleField () != 0 ? p_world_settings->LongitudeScaleField () : 800 .0f ;
755+
756+ float lat_origin = p_world_settings->LatitudeOriginField () != 0 ? p_world_settings->LatitudeOriginField () : -400000 .0f ;
757+ float lon_origin = p_world_settings->LongitudeOriginField () != 0 ? p_world_settings->LongitudeOriginField () : -400000 .0f ;
758+
759+ float lat_div = 100 .f / lat_scale;
760+ float lat = (lat_div * actor_position.Y + lat_div * abs (lat_origin)) / 1000 .f ;
761+
762+ float lon_div = 100 .f / lon_scale;
763+ float lon = (lon_div * actor_position.X + lon_div * abs (lon_origin)) / 1000 .f ;
764+
765+ coords.x = std::floor (lon * 10 .0f ) / 10 .0f ;
766+ coords.y = std::floor (lat * 10 .0f ) / 10 .0f ;
767+
768+ return coords;
769+ }
770+
771+ /* *
772+ * \brief obtains the steam ID of an attacker, meant to be used in hooks such as TakeDamage
773+ * \param tribe_check if set to true will return NULL if the target is from the same tribe as the attacker
774+ */
775+ FORCEINLINE uint64 GetAttackerSteamID (AActor* target, AController* killer, AActor* damage_causer, bool tribe_check = true )
776+ {
777+ uint64 steam_id = NULL ;
778+
779+ if (target)
780+ {
781+ if (killer && !killer->IsLocalController () && killer->IsA (AShooterPlayerController::GetPrivateStaticClass ())
782+ && (!tribe_check || (tribe_check && target->TargetingTeamField () != killer->TargetingTeamField ())))
783+ steam_id = GetSteamIdFromController (static_cast <AShooterPlayerController*>(killer));
784+ else if (damage_causer && (!tribe_check || (tribe_check && target->TargetingTeamField () != damage_causer->TargetingTeamField ()))
785+ && damage_causer->IsA (APrimalStructureExplosive::StaticClass ()))
786+ {
787+ APrimalStructureExplosive* explosive = static_cast <APrimalStructureExplosive*>(damage_causer);
788+ steam_id = GetSteamIDForPlayerID (explosive->ConstructorPlayerDataIDField ());
789+ }
790+ }
791+
792+ return steam_id;
793+ }
737794private:
738795 virtual AShooterPlayerController* FindPlayerFromSteamId_Internal (uint64 steam_id) const = 0;
739796 };
0 commit comments