Jojash Posted April 2, 2013 Share Posted April 2, 2013 Is there a way to check which factions an NPC is a member of and then store that information? Short of checking if they are a member of every single faction, I can't think of a way to do this, any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
luthienanarion Posted April 2, 2013 Share Posted April 2, 2013 Here's how I would go about doing that: 1. Make two form lists. Use one as a list of all factions to check for membership, and the other as a temporary list of factions that an NPC is a member of.2. Get a handle to the NPC's reference in a script variable using whatever means you prefer. GetFirstRef/GetNextRef, GetCrosshairRef, GetSelf in an effect script on a weapon, etc.3. Check each faction for membership by iterating through the master faction list like so: set iCount to 0 label 10 if(iCount != listgetcount FactionList) set rFaction to ListGetNthForm FactionList iCount if(rActor.GetInFaction rFaction) ListAddForm NPCFactions rFaction endif set iCount to iCount + 1 goto 10 endif This gives you a form list (NPCFactions) that contains all factions from FactionList that the NPC is a member of. You can do whatever you like with that information at this point. If you are doing this for multiple NPCs, you will need to empty the NPCFactions list each time you switch to a new one: label 20 if(ListGetCount NPCFactions) ListRemoveNthForm NPCFactions 0 goto 20 endif Note that the additions to NPCFactions will not persist through saving and loading. If you need to make a permanent copy of the list that persists, you can do that like so: label 30 if(iCount != ListGetCount NPCFactions) set rFaction to ListGetNthForm NPCFactions iCount AddFormToFormList PermFactionList rFaction set iCount to iCount + 1 goto 30 endif Link to comment Share on other sites More sharing options...
Jojash Posted April 2, 2013 Author Share Posted April 2, 2013 Thank you so much! That's really, really helpful! :D Link to comment Share on other sites More sharing options...
Recommended Posts