Jump to content

CK activate AI package by keyword count


Recommended Posts

I'm making a plugin for a mod that makes the npcs of said mod go chase the player through Skyrim as soon as they spawn, through a follow player AI package. The problem is that i want to limit the amount of NPCs that get called to go after the player through a condition in the package that checks if there's a certain amount of those types of npcs with a certain keyword/faction in the cell or in combat, and if it is more than a certain number (x) then the package doesn't get activated. Is this possible? If so which condition function needs to be selected?
 

Link to comment

You cannot "count" the actor you enabled, not in a condition function.

 

I suppose the actors are custom NPC you are adding.

In this case (simple way):

* Create a GlobalVariable.

* Every time you spawn an actor (using a script or with a engine generation), increment the global variable (Just put it in the OnInit() event in a script attached to the Actor)

* When an actor dies decrease the global variable (again, you can use an event on the actor script)

Then condition your spawn whatever (but not the package, I think it will be useless) based on the global variable value.

 

(more advanced way)

* Define your controller quest script as Conditional

* Add an Int Conditional Property that will hold the number of spawned actors

* Increase and decrease it in the same way as before.

* Condition your spawning on the conditional variable (getVMQuestVariable, your quest, your variable)

 

Link to comment

You cannot "count" the actor you enabled, not in a condition function.

 

I suppose the actors are custom NPC you are adding.

In this case (simple way):

* Create a GlobalVariable.

* Every time you spawn an actor (using a script or with a engine generation), increment the global variable (Just put it in the OnInit() event in a script attached to the Actor)

* When an actor dies decrease the global variable (again, you can use an event on the actor script)

Then condition your spawn whatever (but not the package, I think it will be useless) based on the global variable value.

 

(more advanced way)

* Define your controller quest script as Conditional

* Add an Int Conditional Property that will hold the number of spawned actors

* Increase and decrease it in the same way as before.

* Condition your spawning on the conditional variable (getVMQuestVariable, your quest, your variable)

Thanks. I managed to get to the script part by using the Rune Axe undead kill count as a template, but i'm don't know what event would need to be created to increase the count as they get spawned.

 

 

 

Scriptname xxxUrukCount extends ActiveMagicEffect  

GLOBALVARIABLE PROPERTY xxxUrukCount AUTO
KEYWORD PROPERTY xxxUrukHai AUTO

OBJECTREFERENCE victim

EVENT OnEffectStart(ACTOR target, ACTOR caster)
	victim = target

ENDEVENT

EVENT OnDying(ACTOR killer)
	if(victim.HasKeyword(xxxUrukHai))
		xxxUrukCount.SetValue(xxxUrukCount.GetValue() - 1)

	endIf

ENDEVENT

 

Above is the template that i modified

 

 

 

OBJECTREFERENCE spawned

EVENT OnInit(???)

ENDEVENT

EVENT ???(???)
	if(spawned.HasKeyword(xxxUrukHai))
		xxxUrukCount.SetValue(xxxUrukCount.GetValue() + 1)

	endIf

ENDEVENT

 

 What needs to be changed in the second spoiler so that it adds 1 to the global every time the NPC spawns/get called?

Link to comment

Do you have an idea of WHAT is spawning your actors?

If not, and your actors are custom, then just add a script to them, and use a line like:

 

Event OnInt()

  myActorsCount.setValueInt(myActorsCount.getValueInt() + 1)

EndEvent

 

Where "myActorsCount" is your global variable, that should be defined as property in this script.

 

Link to comment

Do you have an idea of WHAT is spawning your actors?

If not, and your actors are custom, then just add a script to them, and use a line like:

 

Event OnInt()

  myActorsCount.setValueInt(myActorsCount.getValueInt() + 1)

EndEvent

 

Where "myActorsCount" is your global variable, that should be defined as property in this script.

The actors are placed in the exterior world. The thing i did was add a follow player package to them so that they move out of their stationary positions and follow the player. When their cell resets they respawn and repeat the same procedure.
Link to comment

Are your actors just placed in cells (exterior or interior does not matter)?

Or they are actually SPAWNED? (Created on some conditions?)

 

Because if it is the first case, then you need a completely different approach, that involves useg specific packages for each of them.

If they share the same package, then they will all do the same thing.

 

Link to comment

Are your actors just placed in cells (exterior or interior does not matter)?

Or they are actually SPAWNED? (Created on some conditions?)

 

Because if it is the first case, then you need a completely different approach, that involves useg specific packages for each of them.

If they share the same package, then they will all do the same thing.

Placed in cells. There's about 5 types. But i probably going to throw them all into a leveled list which makes easier to spawn the more generic variants and keeping the stronger ones rarer.

So yeah one package for all of them.

Link to comment

At this point you need a different approach.

 

Have a controller quest, create a faction.

Every time you what to have an actor to start, add it to the faction, and increase the global count.

Condition the package for the subject being in the faction.

When the NPC dies remove it from the faction and decrease the count.

 

Link to comment

At this point you need a different approach.

 

Have a controller quest, create a faction.

Every time you what to have an actor to start, add it to the faction, and increase the global count.

Condition the package for the subject being in the faction.

When the NPC dies remove it from the faction and decrease the count.

And control the quest through a spell?

Link to comment

I am not sure i fully understand all circumstances, so i presume the following:

 

- The NPC spawner script is yours, so you can modify it

- At any time, you want to limit the number of NPCs chasing after the player to N

 

So, what about making a quest having N aliases ("optional", maybe also "allow reserved"), with chase packages attached to them.

In you spawner script, add the NPC into one of the quest's aliases, while also clearing any alias having a dead NPC (you'll need to iterate over the aliases, which i think requires SKSE).

- If the alias contains dead NPC, clear it.

- If the alias has been cleared, or was empty to begin with, spawn the NPC and add it into this alias.

- If you do not find empty alias, then just do not spawn the NPC.

 

EDIT: maybe the spawner script can also be attached to this quest, that would make sense, unless the spawner requires its own quest for some reason.

 

EDIT2: i just read the first post more carefully, and saw its not your spawner script, so its probably not a good idea to replace it with your own version, so ...the above is not applicable (at least not completely).

Link to comment

Not really.

 

Do you know what a control quest is?

 

I can provide help tomorrow.

Sorta. I made one with default settings that has 2 stages 0/10. 0 means that the NPC track player effect is off; 10 is on. It is controlled by a spell that casts a toggeable ability in the player and sets the queststage to 10 and when it is off it becomes 0.

Now the only problem is the errors that i get when trying to compile the papyrus fragment that adds/removes the NPCs from the activator faction:

 

 

Faction Property xxxUrukHaiActivator AUTO
Actor Property UrukHaiSoldier Auto
Actor Property UrukHaiCrossbow Auto
Actor Property UrukHaiScout Auto
Actor Property UrukHaiBerserker Auto
Actor Property UrukHaiCommander Auto

EVENT 
     UrukHaiSoldier.AddToFaction(xxxUrukHaiActivator)
     UrukHaiCrossbow.AddToFaction(xxxUrukHaiActivator)
     UrukHaiScout.AddToFaction(xxxUrukHaiActivator)
     UrukHaiBerserker.AddToFaction(xxxUrukHaiActivator)
     UrukHaiCommander.AddToFaction(xxxUrukHaiActivator)
ENDEVENT

 

 

 

ActivatorQuest_04005750.psc(8,8): no viable alternative at input 'Property'

ActivatorQuest_04005750.psc(15,6): extraneous input '\\r\\n' expecting ID

 

 

 

Faction Property xxxUrukHaiActivator AUTO
Actor Property UrukHaiSoldier Auto
Actor Property UrukHaiCrossbow Auto
Actor Property UrukHaiScout Auto
Actor Property UrukHaiBerserker Auto
Actor Property UrukHaiCommander Auto

EVENT
     UrukHaiSoldier.removeFromFaction(xxxUrukHaiActivator)
     UrukHaiCrossbow.removeFromFaction(xxxUrukHaiActivator)
     UrukHaiScout.removeFromFaction(xxxUrukHaiActivator)
     UrukHaiBerserker.removeFromFaction(xxxUrukHaiActivator)
     UrukHaiCommander.removeFromFaction(xxxUrukHaiActivator)
ENDEVENT

 

 

 

Link to comment

I am not sure i fully understand all circumstances, so i presume the following:

 

- The NPC spawner script is yours, so you can modify it

- At any time, you want to limit the number of NPCs chasing after the player to N

 

So, what about making a quest having N aliases, with chase packages attached to them.

In you spawner script, add the NPC into one of the quest's aliases, while also clearing any alias having a dead NPC.

If you do not find empty alias, then just do not spawn the NPC.

It's not a script. The NPCs are placed in the wilderness. The only thing i made was to give follow packages to them. But since they were coming in great numbers i decided to limit the amount that get assigned to the package (only 5 NPCs and hundreds of clones each around Skyrim)

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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