jonathan-robertson / amnesia

7 Days to Die mod: Reset player progress after dying under a configurable set of circumstances
https://discord.gg/hYa2sNHXya
MIT License
2 stars 0 forks source link

⚔️ Remove Quests the Right Way! 🎉 #57

Closed jonathan-robertson closed 1 year ago

jonathan-robertson commented 2 years ago

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));
jonathan-robertson commented 1 year ago

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)

jonathan-robertson commented 1 year ago

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()}");
    }
}
jonathan-robertson commented 1 year ago

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

jonathan-robertson commented 1 year ago

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