-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take control of and play as NPC followers #51450
Conversation
It's an interesting functionality with interesting potential applications. However, I think it also has a potential for creating "interesting" bugs, so it probably would need a fair bit of testing by people who can think up more or less weird situations that can cause issues.
|
Seems this feature needs debug currently, and will disable achievement? Can you consider making this a normal action, that can be placed in the player action menu? Consider the current NPC AI, I think this will not be too much harmful to game immersiveness, but will enrich the game play. |
Yes.
Yes.
I am certainly considering that, but I don't make the call about what's allowed in the game. |
Currently this will create an extra character save file if you don't swap back to your original body before saving. This doesn't break the game, but it then shows both character names as load options when you start the game which is confusing. I have an idea about how to fix that, but I need to do a bit more work. |
I wrote #51466 as a pre-requisite to fix the save duplication. I also thought some more about how to make controlling any follower work without accidentally swapping the followers' minds (i.e. if you swap with A, then with B then back with your original character then A and B remain swapped). Instead of thinking of it as a mind-swap, think of it as you (the player) taking control of an NPC, suppressing their (simulated) consciousness. Which means that I'll implement this idea tomorrow. |
To balance this out and not have this amazing feature locked behind a debug menu, this could be added to the faction interface. Swapping characters could be tied to the NPC's opinion of the player and if the NPC decides to mutiny then they would no longer be accessible to swap to. It might also be good to change the current save structure to a party instead of individual characters. |
I believe the debug menu access should be as broad as reasonable, i.e. if possible, it should allow you to control NPCs (and, again if possible, monsters), while a "regular" party feature should be restricted to companions. Introduction of the party application ought to be delayed until the functionality has been tested out via the debug menu. Thus, both avenues ought to use the same functionality, but the party one would be restricted further up in the call chain. The suggestion to tie the structure to your factions (which is what I interpret @Entity-y to mean, rather than a new group level) ought to work well for regular use, but will it work for debug mode without introducing weird side effects or requirements for controlled NPCs to be included into and then kicked out of your faction? |
That's precisely where I want to put it, if it's allowed. That's a good suggestion about handling disgruntled NPCs, I can make it require non-negative reputation. There's a slight issue with that. The npc that takes over when you leave the original character has 0 trust. If you do anything to annoy them you can't change back. [Edit: I bumped that up to 10] That also brings up some other issues with this feature. All NPCs have an "opinion of you", which at the moment doesn't change when you switch bodies. For non-follower NPCs that might make sense, you could say it's their opinion of your faction. But why would your followers accept orders from another member of your faction who isn't the leader? And shouldn't their opinion reset to 0 when you're not in the leader's body? Should I make it so that only the leader can give orders? Or maybe when you switch characters you're also transferring leadership? Until all these issues can be resolved it's probably best to keep it as a debug feature. |
I believe you should always be allowed to switch back to the PC, but companion opinions of each other probably would need further work (probably in a separate PR) before usage of this feature as a party mode is free of that kind of gotchas. Some terminology, to avoid confusion:
|
This is done. I also added book-keeping code to keep faction membership references updated, fixed some post-transfer UI issues and made the feature work beyond the reality bubble. |
b86af51
to
8878407
Compare
Finished testing, found and fixed another bug and now it's ready for review. |
so this finally being a debug feature? |
Yes, you'll be able to use this via the debug menu in the next Experimental release. I've got some plans for making the feature available without debug, but first I want to see if anyone finds bugs that I missed. |
Maybe a mind control mutation or something, or a spell ( Not sure if there's spells in vanilla), so that it can be done immersively? |
I think this is also a way of role-playing, that you are playing a group of survivors. Some games recommend players to play this way, like genshin-impact, Pokémon Mystery Dungeon, and Rimworld. I think even this feature is easily accessible (just like gender change...), we can still enhance the immersive, players can feel this game is telling stories about survivors working together in the world, not just a lonely man walking in the world. This can make the world warmer, and make players feel accompanied. |
Future development (i.e. the plan for taking this out of debug and making it a game feature) is described in #51632 |
When using this feature, it always saying "disable achievement", which is somehow annoying... Can you move it out of the debug menu to make it easier for players to test this feature? @eltank |
Summary
Features "Take control of and play as NPC followers"
Purpose of change
Ever wanted to take control of a follower for a while in order to make use of their abilities? Or just continue playing as that NPC? Well now you can.
This PR adds infrastructure allowing the player to relinquish control of their current avatar character and permanently take control of a follower NPC.
This functionality could be used to give a new option on death (continue playing the character of a follower), or simply to change the way you play the game (switch to controlling a follower at any time no matter where they are).
But for now it's limited to the debug menu as a proof of concept.
Describe the solution
The key idea that enables all of this is the transfer of
Character
data betweenavatar
andnpc
objects (both subclasses ofCharacter
) using theCharacter
move-assignment operator.Add a protected
Character::swap_character(Character&, Character&)
and a publicavatar::control_npc(npc&)
that uses it.Add a
shadow_npc
field toavatar
which stores the suppressed personality of the character being controlled by the avatar. A shadow npc is generated automatically for the "original character" the first time this feature is used. The default shadow NPC has a neutral personality (0 in every personality trait) and a highop_of_u
(10 trust and 10 value).Move the
followers
field fromCharacter
toavatar
.Add a debug menu entry to activate the feature (target any follower NPC including those outside the reality bubble).
Describe alternatives you've considered
Doing more with it, as described above. But I want to collect some feedback first.
Implementing a "possession" spell in Magiclysm. I still want to do that in another PR, but the way that will work will be fundamentally different. The avatar won't change, instead they'll be rooted in place while they "warg" a monster, similar to remote-controlling an RC car or vehicle but seeing through the target's eyes. The range will be limited (less than reality bubble radius). The player should be able to invoke the controlled monster's special attacks and cancel at any time, possibly with negative after-effects, especially if the target took damage. Of course, maintaining possession will also cost mana each turn. Possessing one's own familiar may be cheaper/free.
Testing
Start a new game as Debug. Debug all skills to 5. Using debug Mind Control and NPC spawning acquire 2 followers. Rename them A and B. Tell them to guard. Make note of the 2 NPCs personalities to make sure they remain unchanged.
Take over npc A. Save and quit. In the main menu see only 1 save for the test world, named "Debug" (the save name is unaffected by character change). Load.
Take over npc B, repeat above.
Inspect Debug's personality, check default shadow NPC personality.
Talk to Debug, order them to guard. Switch to Debug. Inspect the personalities of A and B, make sure they were not swapped:
Next, a Z-level test. Swap to A, send them to the basement, swap to B, send them to the roof, swap to Debug and order the npcs to follow.
control_npc3.mp4
Next, a long range test. Order the npcs to guard. Teleport far away, then take control of A.
control_npc4.mp4
Now let's inspect the faction menu. A, being the current leader, is not listed but Debug is.
Swap to Debug and teleport back. Inspect the faction menu again. The list shows A and B.
Finally switch to A and... murder Debug. Observe that the game is not over and you can simply carry on (you monster).
The faction roster is updated.
Additional context
Q: What happens if you switch to a passenger while driving?
A: Your previous character stops driving and the vehicle starts coasting. You can swap places with the former driver and continue driving, if the vehicle doesn't crash into something first.
Q: What happens if you switch while hauling items on the ground?
A: Your previous character pauses hauling, but will resume if you switch back and there are items below them.
Q: What happens if you switch while dragging a cart?
A: The dragging stops (doesn't resume even if you switch back immediately)
Q: What happens if you switch to an npc who is reading a book?
A: You find yourself reading! Press
.
to stop.Q: What happens if you switch to an npc who is deconstructing a vehicle?
A: You find yourself removing vehicle parts. Press
.
to stop.Q: What happens if you switch to an npc who is building something?
A: You find yourself doing construction work. If there are multiple blueprints, you'll do all of them. Press
.
to stop.You can see the pattern here... Switch to an npc who is performing an activity and you'll find yourself doing it.
Note that controlled npcs will burn calories and will eat if they're hungry and they have food when you relinquish control.