jonathan-robertson / amnesia

7 Days to Die mod: Reset player progress after dying under a configurable set of circumstances

Home Page:https://discord.gg/hYa2sNHXya

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

βš”οΈ Remove Quests the Right Way! πŸŽ‰

jonathan-robertson opened this issue Β· comments

Found out a very likely approach to removing quests!
Server will be reading player data already on death.
Instead of having to disconnect player so player can come back with manipulated player data file... the server can send the player a console command to have the player's client issue the command instead (which is supported).

ConnectionManager.Instance.Clients.ForEntityId(player.entityId)
?.SendPackage(NetPackageManager.GetPackage<NetPackageConsoleCmdClient>().Setup($"removequest {questId}", true));

Could also be an even better way to do it: NetPackagePlayerData.ProcessPackage
GameManager.SavePlayerData will apply the modified quest journal to the player... possibly... if you set the _cInfo.entityId value to the target player's entityId (i.e. suggest it's a request coming from the client that the player is controlling)

Example listing all quests by ID and POI name (Console Command)

private void ListQuests(CommandSenderInfo senderInfo)
{
    EntityPlayer player;
    if (senderInfo.RemoteClientInfo == null)
    {
        player = GameManager.Instance.World.GetPrimaryPlayer();
        if (player == null)
        {
            SdtdConsole.Instance.Output("No remote or local player could be found.");
            return;
        }
    }
    else if (!GameManager.Instance.World.Players.dict.TryGetValue(senderInfo.RemoteClientInfo.entityId, out player))
    {
        SdtdConsole.Instance.Output("Could not find remote player.");
        return;
    }
            
    for (int i = 0; i < player.QuestJournal.quests.Count; i++)
    {
        SdtdConsole.Instance.Output($"{player.QuestJournal.quests[i].ID}. {player.QuestJournal.quests[i].GetPOIName()}");
    }
}

Confirmed this is working now, but trader relationship doesn't update until log out/in; looking into that now

Dang, it still doesn't seem possible to fully push trader relationship changes unless the player logs out