Jump to content

Applying scripts to multiple NPCs?


ashjay101

Recommended Posts

Hi all, Iâm looking to make a mod that will debuff companions, and apply this effect to *all* companions, whether vanilla or modded. My first thought on how to do this would be to run a script that gives a new perk or effect to anyone registered as a playerteammate, only problem is, ive played around with this a bit and havent been able to figure out how to do it. Anyone have any ideas?
Link to comment
Share on other sites

I haven't played around with it much, but there is a hidden switch to addperk.

 

Normally, you do something like player.addperk PerkID and the perk gets added to the player. While you can add a perk to an NPC, it doesn't actually do anything if you do. Some of the developers at Obsidian obviously didn't understand this because they do add perks to NPCs in the game.

 

If you add a 1 after the addperk function though, this perk then goes on a special list that only affects player teammates.

 

In other words, instead of: player.addperk PerkID

do this: player.addperk PerkID 1

 

I haven't played around with it enough to know what kinds of things work fine with NPCs when you do this and what things don't work, but you can try it and see what happens.

Link to comment
Share on other sites

Your question implies you think an NPC can become a "companion" without being "hired", which is not true. Someone just "tagging along (e.g. as part of a quest as in "Honest Hearts" or "Dead Money") is not technically a "companion" but rather a "follower". Different beast as far as the game engine is concerned. (Terminology is crucial when speaking about technicalities.) Perhaps if you gave a specific instance you are thinking about?

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

Yeah thanks dude, I got that bit, the part I'm having trouble with is with applying it to the NPCs I want, I want it to be automatically applied to anyone who is a player teammate or in the playerfollower faction, any idea how to do that?

Just to clarify one thing here. You might understand it or you might not, I'm not sure, so just ignore this if you already understand it.

 

When you add a perk to the player with the optional flag at the end (player.addperk PerkID 1), the perk is added to the player, but the perk affects all NPCs that are teammates. The perk does not affect the player, only the player's teammates. All teammates are affected by the perk, whether you want them to be or not. It's all or nothing. You can't select which NPCs receive the perk's effect.

 

You can't add a perk directly to an NPC. SomeNPCref.addperk PerkID does nothing.

 

As Dubious said, adding a perk to the NPC teammate list (player.addperk PerkID 1) also only affects NPCs that are teammates. If the NPC hasn't had SetPlayerTeammate called on them, then the perk will not affect them. It is possible to create an NPC that will follow you just because they have a follow package running, but they aren't teammates. An easy way to tell is whether or not the command wheel comes up when you try to talk to the NPC. The command wheel only comes up for teammates.

 

I am not aware of any way to add a perk to an NPC that is just following the player and is not a teammate.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...