bencebence Posted August 21, 2011 Share Posted August 21, 2011 Hey everybody!I have a question.I'm writing a script right now, but I'd need a variable (and needed it many times before) that checks all npcs. So something like it checks all the npcs if they're the part of X faction or have Y item. Because I'd need something like that, as I don't want to add all npc's name to check them.Is there something like this, or can I do it any else ways?Thanks in advance,bencebence Link to comment Share on other sites More sharing options...
bencebence Posted August 21, 2011 Author Share Posted August 21, 2011 scn MySCN ref NPCs Begin GameMode set NPCs to GetFirstRef 69 1 while (NPCs) if NPCs GetInFaction Faction1 == 0 || NPCs GetInFaction Faction2 == 0 startcombat MyNPCRef NPCs endif set NPCs to GetNextRef loop end Link to comment Share on other sites More sharing options...
David Brasher Posted August 21, 2011 Share Posted August 21, 2011 So I suppose this is an OBSE script? Does it compile in the CS? Is this an object script or a quest script? What is this script attached to? What are the design parameters of this script? What is supposed to happen in the game? Link to comment Share on other sites More sharing options...
bencebence Posted August 21, 2011 Author Share Posted August 21, 2011 Sorry, I forgot to add description :PYes this is an OBSE script and it does compile.This is a quest script attached to a quest.What do you mean by design parameters...?I wrote what supposed to happen ingame in the original topic:My NPC should attack anyone who is not in faction 1 or 2. Link to comment Share on other sites More sharing options...
WarRatsG Posted August 21, 2011 Share Posted August 21, 2011 (edited) So you want an NPC to attack the people near him, but the people he may attack are completely random? You could temporarily add him to a faction with negative disposition modifiers to certain "town factions" (eg, "Cheydinhal Faction", which covers every resident of Cheydinhal). Then he will attack anyone he sees from those factions on his own. That should cover most towns and cities. Outside of towns everything tends to be hostile anyway, so they would probably attack most things out there too. Anyone he is not supposed to attack just has to be in an "allied" faction. It's always difficult to make something truly random like this. If its not random, then it's even easier - just make a faction for his side, and another faction for whatever other group he is supposed to be fighting. He will take care of the rest himself whenever he sees them. Edited August 21, 2011 by WarRatsG Link to comment Share on other sites More sharing options...
bencebence Posted August 21, 2011 Author Share Posted August 21, 2011 Then I'll go with what you said (I wanted to do that before, but I changed my mind and wanted to use scripts but nevermind :P). It'd be completly random who he attacks, just not from that X and Y faction. Link to comment Share on other sites More sharing options...
WarRatsG Posted August 21, 2011 Share Posted August 21, 2011 Is there a possibility he can attack anyone in the game or can you narrow it down? Will he only be in a certain town but attack people at random within it? High aggression and confidence levels on the NPC help out too, for the record. Link to comment Share on other sites More sharing options...
bencebence Posted August 21, 2011 Author Share Posted August 21, 2011 He'd attack anyone expect people from those 2 factions. Link to comment Share on other sites More sharing options...
fg109 Posted August 22, 2011 Share Posted August 22, 2011 If you want to do it using factions, as WarRatsG suggested, give the NPC 99 aggression and put him in a faction with 100 disposition modifiers to faction 1 and 2. If you wanted to keep using scripts, change it to this: scn example ref NPCs Begin GameMode if (IsInCombat) || (GetDead) Return else set NPCs to GetFirstRef 69 1 while (NPCs) if (NPCs.GetInFaction Faction1 == 0) && (NPCs.GetInFaction Faction2 == 0) StartCombat NPCs Break endif set NPCs to GetNextRef loop endif End Link to comment Share on other sites More sharing options...
Recommended Posts