Checking for followers/companions

Post » Wed Mar 30, 2011 6:40 am

Hello modders.

So I've got this mod (SDR), and it works great, except when it comes to NPCs that are following/accompanying the player. The balance gets thrown off, and I'd like to tweak that back into line.

I'm still learning how to mod, but from searching the CS wiki, it seems as though the following might be the best bet:

Each NPC is given a token already.
Since the token is running all the time, it could check to see if the current ai package type is either a "follow" or an "accompany".
If so, it could then check to see if the package target is the player.
If so, it would flag the NPC / Companion in follow mode, and I could then use that flag to turn on/off various bonuses/adjustments/features.

Does that sound right? Is there a possible problem with NPCs that are hunting you down like assassins or guards, or are they using totally different package types?

Any feedback from follower/companion experts would be greatly appreciated as I am getting a lot of requests to make my mod companion friendly.

saebel
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am

Post » Wed Mar 30, 2011 1:28 am

I check for followers to add them to my companion's factions. This keeps the in-fighting down. I use some OBSE stuff to do it. This might work for your situation. Whatever check you need to do, maybe you can just see if they're in special faction you add them to.


ref CompRefshort bCompNumshort bRunCompCntshort bFactChecker;Follower Check - Adds followers to Illi's faction if they're not in his faction.  This should significantly cut down on the in-fighting;if Illi is used with other companion mods.if GGIlliRef.bIsCompanion == 1 && GGIlliRef.bInitSetup > 0     set bCompNum to Player.GetNumFollowers     if bCompNum > bRunCompCnt || bCompNum < bRunCompCnt          set bRunCompCnt to bCompNum          set bFactChecker to 1     endifendif;Loop that sorts through NPCs currently following the player.  If the NPC is not a member of Illi's faction they are added to it.if bFactChecker == 1     set lCompIndex to 0     while lCompIndex < (bRunCompCnt + 1)          set CompRef to Player.GetNthFollower lCompIndex          if CompRef.GetFactionRank GGIlliFaction == -1 && CompRef.IsActor == 1               CompRef.SetFactionRank GGIlliFaction, 0          endif	     set lCompIndex to lCompIndex + 1     loop	set CompRef to 0     set bFactChecker to 0endif


Hopefully that helps some.
User avatar
Multi Multi
 
Posts: 3382
Joined: Mon Sep 18, 2006 4:07 pm

Post » Wed Mar 30, 2011 11:28 am

Hmm. I might be able to do something with that. Perhaps I could use that second part to construct an array of followers that is stored as a player quest variable. The variable is only updated if the followers change, and that would be a function on the player token side. On the NPC token side, it could check to see if the NPC is a member of that array, and, if so, set the follower flag to 1 before running the rest of the NPC token script.

Again, I say hmm. Thanks for the reply. I'll mess around with that.
User avatar
Franko AlVarado
 
Posts: 3473
Joined: Sun Nov 18, 2007 7:49 pm

Post » Wed Mar 30, 2011 4:54 am

No problem. I hope you can make use of that.

You did say you had just started modding so I didn't mention arrays. An array would probably be the best route to handle what you're wanting to do. You might check with some of the coding gurus around here - ShadeMe is one that immediately comes to mind. He helped a lot with my companion's combat arrays. He might have a simpler solution for your problem.

Best of luck with your mod.

-Deep
User avatar
sarah taylor
 
Posts: 3490
Joined: Thu Nov 16, 2006 3:36 pm

Post » Wed Mar 30, 2011 8:19 am

I'm relatively new to modding. Well, I guess maybe not anymore, 'cause lord knows I've probably put in well over a hundred hours into this thing by now, if not more. I'm using arrays already for several features, so I have a fairly solid grip on them. Also, my background is as a database designer, so scripting and data models are fairly straight forward. It's really just a matter of learning the secret tricks of the CS and variants on vocabulary. Kind of like a swing dancer learning how to salsa. I understand the basic principles, but I don't know all the techniques and special tricks yet.

Anyhow, I think your lead will get me where I'm going, and without too much coding. So muchas gracias! :thumbsup:
User avatar
Amanda Furtado
 
Posts: 3454
Joined: Fri Dec 15, 2006 4:22 pm


Return to IV - Oblivion