Modified spawn level distribution compatibility

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Public Service Announcement

    Hey Guest, I’ve got some exciting news to share! 🎉

    Starting this December, I’ll be moving the entire GameServersHub website away from WordPress and rebuilding it in Next.js! This upgrade will bring incredibly faster speeds, smoother performance, and a modern user experience that sets the stage for everything coming next.

    In 2026, GameServersHub will be entering a new era. I’ll be revamping the entire platform from the ground up and launching a brand-new, fully modernized marketplace. It’ll feature a cleaner design, improved functionality, and better tools for both creators and server owners.

    On top of that, development has already started on the GameServerListing project at https://gsl-six.vercel.app/, which is expected to launch in early Q1 2026. This new system will make discovering and managing servers easier than ever before.


    👉 Stay in the loop!
    Join our Discord for behind-the-scenes updates, early previews, and community discussions.

    » Click here to join our Discord! «

    ~ MrOwlSky

SkyLex

Well-known member
Joined
Sep 14, 2018
Messages
3
Hello there
We are trying to make this plugin work with new version of api - unfortunately unsuccessful so far. It's compile without errors, loading to the server, but seems not changing anything. Please take a look, where may we be wrong?

C++:
#include <API/ARK/Ark.h>
#include <API/Base.h>

#pragma comment(lib, "ArkApi.lib")

DECLARE_HOOK(APrimalDinoCharacter_GetRandomBaseLevel, int, APrimalDinoCharacter*, float);

//int _cdecl Hook_APrimalDinoCharacter_GetRandomBaseLevel(APrimalDinoCharacter* _APrimalDinoCharacter, float ForceRand_NotUsed)

int Hook_APrimalDinoCharacter_GetRandomBaseLevel(APrimalDinoCharacter* _APrimalDinoCharacter, float ForceRand_NotUsed)
{
    TArray<FDinoBaseLevelWeightEntry> baseLevelWeightEntries = _APrimalDinoCharacter->DinoBaseLevelWeightEntriesField();
   
    //standard creatures
    if (baseLevelWeightEntries.Num() == 4
        && baseLevelWeightEntries[0].EntryWeight == 1.0
        && (baseLevelWeightEntries[0].BaseLevelMinRange == 1.0 || baseLevelWeightEntries[0].BaseLevelMinRange == 5.0)
        && baseLevelWeightEntries[0].BaseLevelMaxRange == 5.0

        && baseLevelWeightEntries[1].EntryWeight == 0.5
        && baseLevelWeightEntries[1].BaseLevelMinRange == 6.0
        && baseLevelWeightEntries[1].BaseLevelMaxRange == 12.0

        && baseLevelWeightEntries[2].EntryWeight == 0.25
        && baseLevelWeightEntries[2].BaseLevelMinRange == 13.0
        && baseLevelWeightEntries[2].BaseLevelMaxRange == 20.0

        && fabs(baseLevelWeightEntries[3].EntryWeight - 0.1) < 0.00001
        && baseLevelWeightEntries[3].BaseLevelMinRange == 21.0
        && baseLevelWeightEntries[3].BaseLevelMaxRange == 30.0)
    {
        baseLevelWeightEntries[0].EntryWeight = 1.0;
        baseLevelWeightEntries[0].BaseLevelMinRange = 3.0;
        baseLevelWeightEntries[0].BaseLevelMaxRange = 5.0;

        baseLevelWeightEntries[1].EntryWeight = 0.75;
        baseLevelWeightEntries[1].BaseLevelMinRange = 9.0;
        baseLevelWeightEntries[1].BaseLevelMaxRange = 12.0;

        baseLevelWeightEntries[2].EntryWeight = 0.625;
        baseLevelWeightEntries[2].BaseLevelMinRange = 16.5;
        baseLevelWeightEntries[2].BaseLevelMaxRange = 20.0;

        baseLevelWeightEntries[3].EntryWeight = 0.55;
        baseLevelWeightEntries[3].BaseLevelMinRange = 25.5;
        baseLevelWeightEntries[3].BaseLevelMaxRange = 30.0;
    }

    //scorched earth wyverns
    else if (baseLevelWeightEntries.Num() == 4
        && fabs(baseLevelWeightEntries[0].EntryWeight - 0.600000023841858) < 0.00001
        && baseLevelWeightEntries[0].BaseLevelMinRange == 1.0
        && baseLevelWeightEntries[0].BaseLevelMaxRange == 5.0

        && fabs(baseLevelWeightEntries[1].EntryWeight - 0.300000011920929) < 0.00001
        && baseLevelWeightEntries[1].BaseLevelMinRange == 6.0
        && baseLevelWeightEntries[1].BaseLevelMaxRange == 12.0

        && fabs(baseLevelWeightEntries[2].EntryWeight - 0.300000011920929) < 0.00001
        && baseLevelWeightEntries[2].BaseLevelMinRange == 13.0
        && baseLevelWeightEntries[2].BaseLevelMaxRange == 20.0

        && fabs(baseLevelWeightEntries[3].EntryWeight - 0.300000011920929) < 0.00001
        && baseLevelWeightEntries[3].BaseLevelMinRange == 21.0
        && baseLevelWeightEntries[3].BaseLevelMaxRange == 38.0)
    {
        baseLevelWeightEntries[0].EntryWeight = 1.0;
        baseLevelWeightEntries[0].BaseLevelMinRange = 3.0;
        baseLevelWeightEntries[0].BaseLevelMaxRange = 5.0;

        baseLevelWeightEntries[1].EntryWeight = 0.825;
        baseLevelWeightEntries[1].BaseLevelMinRange = 9.0;
        baseLevelWeightEntries[1].BaseLevelMaxRange = 12.0;

        baseLevelWeightEntries[2].EntryWeight = 0.820;
        baseLevelWeightEntries[2].BaseLevelMinRange = 16.5;
        baseLevelWeightEntries[2].BaseLevelMaxRange = 20.0;

        baseLevelWeightEntries[3].EntryWeight = 0.815;
        baseLevelWeightEntries[3].BaseLevelMinRange = 29.5;
        baseLevelWeightEntries[3].BaseLevelMaxRange = 38.0;
    }

    int randomBaseLevel = APrimalDinoCharacter_GetRandomBaseLevel_original(_APrimalDinoCharacter, ForceRand_NotUsed);

    return randomBaseLevel;
}


// Ark::SetHook("APrimalDinoCharacter", "GetRandomBaseLevel", &Hook_APrimalDinoCharacter_GetRandomBaseLevel, reinterpret_cast<LPVOID*>(&APrimalDinoCharacter_GetRandomBaseLevel_original));

void Load()
{
    ArkApi::GetHooks().SetHook("APrimalDinoCharacter.GetRandomBaseLevel", &Hook_APrimalDinoCharacter_GetRandomBaseLevel, &APrimalDinoCharacter_GetRandomBaseLevel_original);
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        Load();
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
        break;
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

Thank you in advice for help and amazing work done with API and community around it )
 
Last edited:
That could be because you are creating a copy of the array.
Try to change that line to TArray<FDinoBaseLevelWeightEntry>& baseLevelWeightEntries = _APrimalDinoCharacter->DinoBaseLevelWeightEntriesField();.
 
Thank you very much for prompt reply)))
We will try it at the next server restart
 
And it's work now!
Thank you very much again Sir Michidu - you are the best (y)
 
Back
Top