Jump to content

[Papyrus] How to calm newly spawned actors?


Nymra

Recommended Posts

Posted

I have a little problem here...

I want to make my Naked Defeat mod compatible with mods that dynamically and continuously spawn enemies in dungeons and surface.

These new enemies are usually aggressive.

 

I implemented a scan for those new enemies that fires when the Player is detected as beeing in combat.

But somehow my script fails to recognize the new actors.

 

Meaning the script never comes to the point of adding the actors to the allegiance faction (where the debug trace is).


I have set up the actors in the ESP as properties, there is now 30 slots available and they are in the script like this:

 

ReferenceAlias Property Alias_Enemy04 Auto
ReferenceAlias Property Alias_Enemy10 Auto
ReferenceAlias Property Alias_Enemy09 Auto
ReferenceAlias Property Alias_Enemy08 Auto
ReferenceAlias Property Alias_Enemy12 Auto
ReferenceAlias Property Alias_Enemy07 Auto
ReferenceAlias Property Alias_Enemy00 Auto

...

...

 

Now I wonder what I am missing?
The script successfully calms actors that are already there, but it fails on newly spawned actors, which really I can make no sense of :(

The mod that spawns them is additional encounters (no longer available on nexus) which I think makes duplicates of existing actors.

Could that also be a problem?! 

I mean even duplicates should get their own entries? 

 

thx alot

Function FastCalm()				;#fastcalm
Debug.Trace("NAKED DEFEAT: FastCalm STARTED")
	Actor a									
	Int i = NPC.Length						
	Debug.Trace("NAKED DEFEAT: FastCalm NPC Length"+NPC.Length)										
		while i 	 											
			i -= 1												
			a = NPC[i].GetReference() as Actor	
			
			if a 		
				a.StopCombat()		
				a.StopCombatAlarm()
				if !a.IsInFaction(AllegianceFaction)
					a.AddToFaction(AllegianceFaction)
					Debug.Trace("NAKED DEFEAT: FastCalm a to allegiance:"+a)	
					Debug.Trace("NAKED DEFEAT: FastCalm i to allegiance:"+i)
				endif
				
			;	if !a.IsInFaction(DefeatFaction)
			;	a.AddToFaction(DefeatFaction)
			;	endif
					a.StopCombat()		
					a.StopCombatAlarm()
				
				if a.IsAlerted()
					a.SetAlert(False)
				endif
				
					a.StopCombat()		
					a.StopCombatAlarm()
			endif
		endwhile

EndFunction

 

 

Posted

The ReferenceAlias of the Quest are filled, only and exclusively, when the quest start.

To catch new posible actors in each run you must Stop and Start your Quest.

 

Aditionaly, is not necessary define each ReferenceAlias in you script. Is much more optimal use:

Alias[] list_NPC

list_NPC = Your_Quest_Name.GetAliases()

Posted
43 minutes ago, Andy14 said:

 

Am I blind or where is NPC set?

 

sorry, its an array

 

ReferenceAlias[] Property NPC Auto

Posted
45 minutes ago, alex77r4 said:

The ReferenceAlias of the Quest are filled, only and exclusively, when the quest start.

To catch new posible actors in each run you must Stop and Start your Quest.

 

Aditionaly, is not necessary define each ReferenceAlias in you script. Is much more optimal use:

Alias[] list_NPC

list_NPC = Your_Quest_Name.GetAliases()

 

oh dear...

 

hmm. time to learn how to make completly new quests...

 

Do I understand it correctly then that I can circumvent this by starting a new quest that is responsible for the calming exclusivly?

 

like start quest

 

stage 1

calm stuff

 

stage 1000

endquest

 

repeat any time new actors appear?

 

I just wonder how I can uncalm them then, hmm.

Like remove them from allegiance faction again when the quest that added it already ended?

 

Or can I just run the quest again in reverse, start again from the beginning, just this time remove the faction. 

I mean it should detect actors as before. hmm hmm. 

 

duh... hm

 

or will repeated runs of the same quest conflict with already filled actor slots? or will it just fill more slots that are not already full.

hmm, this is a bit new to me, sorr.y 

Posted
1 hour ago, Nymra said:

hmm, this is a bit new to me, sorr.y 

 

Take a look to any good mod that use the system that you want use, like Aroused, the npc support of DD, Random Sex... 

 

First, you need two quest, one is your main quest with all the hard work, the Player Alias, the main script...

The second is a simple and small quest that only have the Reference Alias.

 

Your main quest have StartGameEnabled and is always running and never stop.

The second quest not start automatically. You start and stop it from the main quest in each run.

In that way, the ReferenceAlias are filled when you start the second quest and cleared when you stop it and filled again when you start it and and cleared when you stop it... Every time the second quest is started the ReferenceAlias are filled again with the new actors that any other mod can create.

 

The system must run every x seconds... In Aroused is made each 11 seconds, in DD each 30 seconds, in Random Sex each minute... How frequent you run your Scan Quest is your decision depending of performance and necessities.

 

1 hour ago, Nymra said:

I just wonder how I can uncalm them then, hmm.

Like remove them from allegiance faction again when the quest that added it already ended?

 

That is another thing that you must make using a totally different system...

 

Is not recommended change the factions of the actors... never... in any way...

You must use a spell like Calm... Make a copy of the Calm spell from the base game and use your own copy.

Put it a fixed large time, like one hour of real time, and add an event to dispel it when you want.

 

The main theory when your main script start a rape is:

 

While RapeIsWorking

   Start your Scan_Quest => the ReferenceAlias are filled with all the actors present

   cast your special calm spell over that actors

   Stop your Scan Quest

   wait x seconds

end while

 

On each round of the while the ReferenceAlias are filled again and any new actor is catched

When the RapeEnd send a event to dispel your special calm spell from all the actors.

You know how works SendModEvent?

 

Posted

Question: If you want every Alias in that Quest to be in that faction, why not just put the Faction into the Alias of the Quest. That way they get that Faction automatically when the Quest adds them into their Alias and removes them when they gone

 

The most you then had to do is add a quick script to the reference itself with StopCombat() and StopCombatAlarm() in an OnInit Event. Since those are all individual instances, it would be faster, more performance friendly and the engine is generally more stable than papyrus, so adding the factions would also be more reliable *shrugz

 

 

If you want to just quickly mass calm a large area duplicating the master calm spell - the one with the cell wide radius - removing all its visual and sound effects and adding the faction adding script in an OnEffectStart() would be even better as it would avoid the Quest Scan

To remove the Factions youd do another AoE spell like that Radius one but it reverses the Faction add effect, removing the faction oneeffectstart(). The Spell effect removing the Faction should ideally have a "GetInFaction()" Condition to avoid the script being triggered on Aliases that dont have the faction to begin with. The Faction application spell could also be conditioned to only affect specific types of NPC to that faction

Yamete uses this system to rob Followers from their PlayerTeammate Faction and it works quite well

Posted

aaaah, thx alot you two. 
Now I have some stuff to work with, much appreciated.

I inherited the calm system from the Mod that I build Naked Defeat on, so I had to understand first how that even was achieved.

So now on to the next step. 


One last question arises tho:

 

7 hours ago, alex77r4 said:

Is not recommended change the factions of the actors... never... in any way...

Why is that? I had no issues at all for years with the AllegianceFaction based Spell. 
Also I think calm spells also work that way. In fact even several mod authors tried on that and it all ended up doing stuff with factions, hmm.

 

Or is there a difference somehow from adding a faction directly or via a spell?

Just curious here.

 

Posted
20 minutes ago, Nymra said:

Or is there a difference somehow from adding a faction directly or via a spell?

No and that statement is wrong

 

Adding Factions to Actors is no problem whatsoever, the important part is to clear the Faction at one point orelse there will be issues (depending on the context, this context here is one where you want to remove them)

I tried all? almost all? methods you can use to manipulate aggression and Factions are the by far most reliable method, Its easy, fast, reliable, stable. All you have to do is add the faction, pull the Actor out of Combat and remove the Faction later on

Posted
43 minutes ago, Scrab said:

No and that statement is wrong

 

Adding Factions to Actors is no problem whatsoever, the important part is to clear the Faction at one point orelse there will be issues (depending on the context, this context here is one where you want to remove them)

I tried all? almost all? methods you can use to manipulate aggression and Factions are the by far most reliable method, Its easy, fast, reliable, stable. All you have to do is add the faction, pull the Actor out of Combat and remove the Faction later on

kk, thx for clarifying, that was my impression for a long time now and we hammered our heads on that issue, so I was a bit worried, haha. 

The only problem i ever noticed with factions is, that changes seem to require a new game, but I never had the time to dig deeper into it, say make a decent test setup. 

and yes, removing the faction again is ofc key, yeah.

 

Posted

The "danger" of fractions is to use existing factions. With your own fractions you should just be careful for what purpose they are used and that you empty them.

Otherwise you can fill the aliases of your quest dynamically in the Quest Alias tab. There "Find Matching Reference" + "In Loaded Area" is the way to dynamically assign the alias.
Aliases are NOT ONLY usable at the start of the quest - that would be tough, even for Bethesda.

Posted
16 minutes ago, Andy14 said:

Otherwise you can fill the aliases of your quest dynamically in the Quest Alias tab. There "Find Matching Reference" + "In Loaded Area" is the way to dynamically assign the alias.
Aliases are NOT ONLY usable at the start of the quest - that would be tough, even for Bethesda.

 

this is the method I use exactly. It does not work on actors that spawned AFTER the quest start. it always returns "none" for those. I even specifically scan for "Is hostile" but not working. 

 

Posted
Just now, Nymra said:

 

this is the method I use exactly. It does not work on actors that spawned AFTER the quest start. it always returns "none" for those. I even specifically scan for "Is hostile" but not working. 

 

Strange since all of my mods work that way.
One question: When do the opponents spawn? Do they already exist when you enter the cell, or do they only appear after that?

Posted
1 hour ago, Andy14 said:

Aliases are NOT ONLY usable at the start of the quest - that would be tough, even for Bethesda.

 

As far as I understand that's how alias work. :) They are automatically filled only when their quest starts. If quest is already running then alias must be filled manually using ForceRefTo(). That's really annoying, since you have to somehow scope desired object or actor to put it in alias.

Posted
1 hour ago, Andy14 said:

Strange since all of my mods work that way.
One question: When do the opponents spawn? Do they already exist when you enter the cell, or do they only appear after that?

 

as I said: the actors spawn AFTER quest start. And they are spawned from other mods, not mine. 
Ofc these mods do not respect shit, be it sexlab scenes, DHLP suspend or whatnot. 

I have a mod that spawns actors continuously (additional encounters). In fact there are dozens of mods that do that on Nexus and Loverslab (SL Pheromones, Additional Encounters, Extra Encounters, Genesis / Sands of Time (never use that shit tho):D etc. etc.) 
So since my mod takes some time, its very likely that some of these mods trigger while the quest is running, spawning actors that I then have to catch. Right now I just end my mod when I detect combat, but that is not ideal. 
 

 

Archived

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

  • Recently Browsing   0 members

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