Player character switching?

This wouldn’t be trivial to implement, but it’s not impossible either.

You’d need to write two functions, convert npc_to_player and convert_player_to_npc, or more likely player::serialize_as_npc and npc::serialize_as_pc. players and npcs both inherit class character, so that wouldn’t be too hard, I expect. Then you’d have to add a menu or something to let you switch, which would serialize[1] the player as an NPC and the NPC as the player, and then deserialize them.

I’d start with just the serialize_as functions and a debug menu option to make the switch when you save and reload the game, since that would be easiest to test. When you got that working, you could move it to an in-game menu option within the camp manager dialogue.

Good luck implementing this.

[1] serialize means convert to a JsonObject which can then be saved or loaded; deserialize means convert from a JsonObject.

1 Like