In vanilla Skyrim, there's a global variable PlayerFollowerCount. It's initially set to 0, and switches to 1 once you hire someone. Once your follower leaves, it switches back to 0. As long as it sits at 1, you can't hire more people.
I'm planning to change the way it works. It'll still start at 0, but instead increment by 1 (not "set to 1") once you hire someone. While it's at 1, you can't hire more followers, but, and now comes the main part, I want to include perks and probably a racial ability that reduces PlayerFollowerCount. That would result in negative values, allowing more followers to be hired until 1 is reached.
Question: How can I create perks that affect a global variable exactly once (take perk -> variable changes -> done)?
I have already done pretty much everything else (replace the "set"s with increment/decrement), so I have basic understanding of Papyrus. The main question is: Where do I insert the code?
The method that comes to mind first is using a Perk of the "Quest" type to run a small quest that runs a script that changes the variable's value.
There is also a Papyrus Fragment option for Entry Point perks, but I didn't see any entry points that would work appropriately for your situation. I'm not entirely sure how the fragments work yet, though.
While that sounds like it should work, you might want to test it first. Change it to increment by 1, and set the default to -1. If that won't work, you might have to set the maximum number to a higher integer (x) and set the default to 1 below that (x-1). For example, you can't hire once 6 is reached, and 5 is default (and the perk tree would allow for 5 "-1" perks).
I poisoned my dog so he can't keep chasing that baby giraffe.
I'm trying to get this to work myself. Every dialogue line for potential followers that says they won't join you because you already have a follower has a condition that requires PlayerFollowerCount to be 1. What I'm doing is changing that number to something really high. Similarly, every dialogue line where they accept your invitation to join has a condition that requires the follower count to be 0. I just delete that condition altogether.
I haven't gotten around to testing it out yet, but someone else who's gotten a second follower to join him has had the original follower automatically leave. I don't remember what he changed though.
Partially successful. Now I'm facing strange issues.
Mostly, stuff works. I have successfully managed to hire Cicero, then Mercurio, with both following me. Also, I checked whether PlayerFollowerCount increases correctly ("show playerfollowercount") when hiring someone (it does) and decreases when sending them on their war (it does). Also, when hitting the limits, no more followers can be hired.
However, in the following scenario, strangeness happens:
~ set playerfollowercount to 9 ~ show playerfollowercount
- Hire Janessa
~ show playerfollowercount
- Dismiss Janessa
In this scenario, Janessa messes up stuff. Anyone has any idea why?