Global Variables (question for experienced modders)

#1T3nd0Posted 2/9/2012 12:48:24 AM
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?
#2GalahautPosted 2/9/2012 12:59:25 AM
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.
---
Bobblehunt - http://www.newvegasnexus.com/downloads/file.php?id=35110
Keybards - http://posts.keybards.com
#3SlakrPosted 2/9/2012 1:16:36 AM
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.
#4T3nd0(Topic Creator)Posted 2/9/2012 1:31:52 AM
Thanks for the input so far.

Currently doing some playtesting. Hiring works as it should, dismissing does not (yet).

I'll try to go the quest-skill route and will report back once I've reached either success or a barrier.
#5Dead Guy HubbinPosted 2/9/2012 1:32:14 AM
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.
#6T3nd0(Topic Creator)Posted 2/9/2012 4:23:44 AM
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

9.00000000

- Hire Janessa

~ show playerfollowercount

2.00000000 (???)

- Dismiss Janessa

~show playerfollowercount

1.00000000
____________

In this scenario, Janessa messes up stuff. Anyone has any idea why?
#7T3nd0(Topic Creator)Posted 2/9/2012 10:19:55 AM
Bump and new questions.

Why do I fail when attempting to mod PlayerFollowerCount in a Papyrus Fragment in the perk?

In theory, this should suffice:

PlayerFollowerCount.mod(-1)

But that just gives errors.

Also, does anyone know whether perks fire any events when picked? I have a new idea based on that.