Jump to content

Summon spell script issue.


Recommended Posts

Hi,

I'm in the making of a script that summons all followers.

I try to make it recognize AmazingFollowerTweaks. But it just gives this error as soon as I try to cast it without having AFT enabled in vortex.

 

[01/26/2024 - 11:40:00PM] warning: Property DialogueFollower on script WellSummonAllFollowersME attached to Active effect 1 on  (00000014) cannot be initialized because the script no longer contains that property
[01/26/2024 - 11:40:00PM] warning: Property CurrentFollowerFaction on script WellSummonAllFollowersME attached to Active effect 1 on  (00000014) cannot be initialized because the script no longer contains that property

This is the whole script. It should return 0 or 1 in notifications if the script exists or not. But it doesnt return anything if the script actually is activated. And yes, I've set the properties in CK. But here's the thing. Whenever I have the if AFTScript part in the script and try to access the properties through CK it just says Errors encountered while attempting to reload the script. So it is almost like CK can't communicate with the script whilst AFT is referred to.

It gets weirder. Because it returns 0 if I have the script activated.

 

Scriptname WellSummonAllFollowersME extends ActiveMagicEffect  

Event OnEffectStart(Actor Target, Actor Caster)
	Actor FollowerActor = (DialogueFollower.getAlias(0) as ReferenceAlias).getReference() as Actor
	if FollowerActor
		SummonToPlayer(FollowerActor)
	endif
	Actor FollowerAnimalActor = (DialogueFollower.getAlias(1) as ReferenceAlias).getReference() as Actor
	if FollowerAnimalActor
		SummonToPlayer(FollowerAnimalActor)
	endif
	
	if (Game.GetFormFromFile(141763, "AmazingFollowerTweaks.esp") as Quest)
	WellAFTCheck.setvalue(1)
	endif
	int AFTCheck = WellAFTCheck.GetValue() as int
	if AFTCheck == 1
		debug.notification(AFTCheck)
	TweakDFScript AFTScript = DialogueFollower as TweakDFScript
	if AFTScript
		ReferenceAlias[] Aliases = aftscript.GetAllFollowers()
		int Count = Aliases.length
		int i = 0
		while i < Count
			Actor Act = Aliases[i].GetReference() as Actor
			if Act 
				SummonToPlayer(Act)
			endif
			i = i + 1
		endWhile
	endif
	else
	debug.notification(AFTCheck)
	SummonTheWells()
	ArissaMove()
	endif

	self.dispel()
EndEvent


function SummonTheWells ()
Actor Oscar = Game.GetFormFromFile(0x006911, "WellOscarCompanion.esp") as Actor
Actor Emelie = Game.GetFormFromFile(0x00A477, "WellEmelieCompanion.esp") as Actor
Actor MrTree = Game.GetFormFromFile(0x00286c, "WellMrTree.esp") as Actor

if  Oscar.IsInFaction(CurrentFollowerFaction) 
		Oscar.MoveTo(Game.GetPlayer()) 
endif

if  Emelie.IsInFaction(CurrentFollowerFaction) 
		Emelie.MoveTo(Game.GetPlayer()) 
endif

if  MrTree.IsInFaction(CurrentFollowerFaction) 
		MrTree.MoveTo(Game.GetPlayer())
endif
endFunction


Function SummonToPlayer (Actor Act) 
		Act.MoveTo(Game.GetPlayer())
endFunction

function ArissaMove ()
Actor Arr = Game.GetFormFromFile(0x0049b3, "CompanionArissa.esm") as Actor

Faction Fact = Game.GetFormFromFile(0x001da4, "CompanionArissa.esm") as Faction	
if  Arr.IsInFaction(Fact)

  Arr.MoveTo(Game.GetPlayer()) 
endif
endFunction



Faction Property CurrentFollowerFaction  Auto
GlobalVariable Property WellAFTCheck  Auto
Quest Property DialogueFollower  Auto


Skyrim SE 16.1170
Creation Kit 1.6.1130
AFT Version: v1.66 SSE-3 (https://www.nexusmods.com/skyrimspecialedition/mods/6656?tab=description)

Edited by oscarwellton
Added game version etc.
Link to comment
Share on other sites

Ok. so I've figured out why it returns 0 even if I have AFT enabled. It's because of as quest in 

if (Game.GetFormFromFile(141763, "AmazingFollowerTweaks.esp") as Quest)

It should be 

if Game.GetFormFromFile(141763, "AmazingFollowerTweaks.esp")

So now it returns 1 at least, if AFT is running. But the bigger issue is still there. Why doesn't it recognize that the plugin isnt loaded and acts on the if statements. All I want is that if AFT is loaded, listen to the AFT functions, if its not loaded. Listen to the other functions.

Also 've noticed that it does actually work as intended if I disable it in creations. But not if I disable it in vortex. In other words I can't detect if someone doesnt have a plugin installed. Only if they are not using the plugin they've already installed.

What would be the best way to achieve what I want to do if not like this?

This is the code in its entirely as of this moment.

 

Scriptname WellSummonAllFollowersME extends ActiveMagicEffect  

Event OnEffectStart(Actor Target, Actor Caster)
	Actor FollowerActor = (DialogueFollower.getAlias(0) as ReferenceAlias).getReference() as Actor
	if FollowerActor
		SummonToPlayer(FollowerActor)
	endif
	Actor FollowerAnimalActor = (DialogueFollower.getAlias(1) as ReferenceAlias).getReference() as Actor
	if FollowerAnimalActor
		SummonToPlayer(FollowerAnimalActor)
	endif
	
	if Game.GetFormFromFile(141763, "AmazingFollowerTweaks.esp")
	WellAFTCheck.setvalue(1)
	endif
	int AFTCheck = WellAFTCheck.GetValue() as int
	if AFTCheck == 1
		debug.notification(AFTCheck)
	TweakDFScript AFTScript = DialogueFollower as TweakDFScript
	if AFTScript
		ReferenceAlias[] Aliases = aftscript.GetAllFollowers()
		int Count = Aliases.length
		int i = 0
		while i < Count
			Actor Act = Aliases[i].GetReference() as Actor
			if Act 
				SummonToPlayer(Act)
			endif
			i = i + 1
		endWhile
	endif
	else
	debug.notification(AFTCheck)
	SummonTheWells()
	ArissaMove()
	endif

	self.dispel()
EndEvent


function SummonTheWells ()
Actor Oscar = Game.GetFormFromFile(0x006911, "WellOscarCompanion.esp") as Actor
Actor Emelie = Game.GetFormFromFile(0x00A477, "WellEmelieCompanion.esp") as Actor
Actor MrTree = Game.GetFormFromFile(0x00286c, "WellMrTree.esp") as Actor

if  Oscar.IsInFaction(CurrentFollowerFaction) 
		Oscar.MoveTo(Game.GetPlayer()) 
endif

if  Emelie.IsInFaction(CurrentFollowerFaction) 
		Emelie.MoveTo(Game.GetPlayer()) 
endif

if  MrTree.IsInFaction(CurrentFollowerFaction) 
		MrTree.MoveTo(Game.GetPlayer())
endif
endFunction


Function SummonToPlayer (Actor Act) 
		Act.MoveTo(Game.GetPlayer())
endFunction

function ArissaMove ()
Actor Arr = Game.GetFormFromFile(0x0049b3, "CompanionArissa.esm") as Actor

Faction Fact = Game.GetFormFromFile(0x001da4, "CompanionArissa.esm") as Faction	
if  Arr.IsInFaction(Fact)

  Arr.MoveTo(Game.GetPlayer()) 
endif
endFunction



Faction Property CurrentFollowerFaction  Auto
GlobalVariable Property WellAFTCheck  Auto
Quest Property DialogueFollower  Auto

 

Link to comment
Share on other sites

If you use SKSE you can do the following:

If Game.GetModByName("AmazingFollowerTweaks.esp") != 255
  ;AFT is present - do something
Else
  ;AFT is not present - do something else
EndIf

While GetFormFromFile could be used to determine if a mod is present or not, it is not the best usage for that function.  When the mod in question is not present, GetFormFromFile will fail and print a message to the papyrus log if enabled.  Any conditions using GetFormFromFile would fail and not process as a result.

Link to comment
Share on other sites

Thanks, I'll try that. So I'm best off using skse?

The thing is that I tried remaking the magic effect, and spell. Didn't work. I even replaced it with a script that actually works, but for followers that arent waiting. And even if I used that script in a new file and placed it in the SummonAllFollowers Magic Effect it didnt work. The only thing that is working in that regard is if I use the exact same script file for the one that summons players that arent waiting in the magic effect for the ones that are suposed to summon all followers. But then I cant do anything with it since it belongs to the other magic effect.

To clarify:
I have two magic effects with the exact same settings and a spell and spell book attached to them separetly. WellSummonFollowersMagic and WellSummonAllFollowersMagic.
WellSummonFollowersMagic has a script attatched with the name WellSummonFollowersME.psc
WellSummonAllFollowersMagic has a script attatched with the name WellSummonAllFollowersME.psc

If I use the script WellSummonFollowersME.psc on both of the magic effects it works but it works the same way since it's the same script.
If I copy paste the content of WellSummonFollowersME.psc into the WellSummonAllFollowersME.psc it wont work.

How could it be that it is a single file that work but not another file with the exact same content?

Is it something wrong with the file that actually work perhaps or what is going on? This is driving me crazy. I have restarted my computer several times, started from a clean save when trying using Alternative Start Live Another Life. I have coc:ed right from the menu, I have quicksaved and loaded, and oh, I have the Creation Kit Extended installed as well. https://www.nexusmods.com/skyrimspecialedition/mods/71371/ I even cleared my cache on the computer. Is there any other cache or anything that i'm not aware of that may cause this?

Link to comment
Share on other sites

Magic effect properties are only assigned values when the magic effect is started.  You need to bring down the ME and recast the spell to make your new and/or updated CK properties available to your activemagiceffect script.

 

Link to comment
Share on other sites

How would I go about doing that? What do you mean with bring down the MagicEffect? I mean if I activate the AFT mod it does work. What doesnt work is if I have it disabled in vortex in other words if I dont have the plugin in the data folder.

Link to comment
Share on other sites

I was commenting on your two scripts, and how copying the working script's code into the other file can cause you trouble (if you then load an existing save file).

If you have differences in the properties declared in the two scripts, changing the code on a running activemagiceffect is likely to fail because the new properties will not be filled (unlike a quest; quests will fill new properties from your CK settings on game load).

If this is your case, you need to relaunch the magic effect so that a new script instance is installed, with properties freshly filled as you requested in the CK.

In my own testing, at times, I've had to cripple the magic effect in the CK.  Do a fresh save with the effect off (do check that it is off!).  Enable the new magic effect version.  And reload the save file.  Tedious but effective.

If your magic effect is on an ability, you can simply remove and then re-add the ability.

 

Link to comment
Share on other sites

SOLVED, KINDA.

I solved it by using two scripts in the same magic effect. One with AFT and one with everything else. In that way if AFT fails to load, well it fails to load. Everything else loads no matter what. It feels a bit clunky but this seems to do the job. And this seems to be a hard nut to crack. When I do have AFT on I guess moveto runs twice on the same actor as well. Nothing noticable in game though. It looks at least for me as it does run only once.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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