Jump to content

Variable help needed


bencebence

Recommended Posts

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

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

Sorry, I forgot to add description :P

Yes 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

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 by WarRatsG
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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