Jump to content

HasMagicEffect Scripting help


Recommended Posts

I am working on trying to get a mod (http://www.nexusmods.com/skyrim/mods/10067/?) from the original Skyrim to work in SE with a few additional features. I have managed to add the ingredients from the DLC to the mod with no issues. The difficulty I am having is trying to prevent the mod from breaking the ability to be ethereal. As it happens now, when the auto harvest triggers, the character is dropped out of ethereal form. My idea is to check the HasMagicEffect field for ethereal and if it is true prevent harvesting.

Scriptname AutoHarvestQuest extends Quest

FormList Property floraList Auto
Quest Property AutoHarvest Auto  
Float Property HarvestDistance = 5000.0 Auto
Float Property HarvestDistMult = 0.5 Auto
MagicEffect Property ethereal Auto

Event OnUpdate()

	Actor plyr = Game.GetPlayer()
	
	; Get Harvest Distance
	float distMultPerc = plyr.GetActorValuePercentage("alchemy")
	float distTotal = HarvestDistance * (1 + (HarvestDistMult * distMultPerc))
	
	ObjectReference floraRef = none
	
	int loop = 0
	If (plyr.HasMagicEffect(ethereal))
		loop = 4
	EndIf
	
	while (loop < 3)
		floraRef = Game.FindRandomReferenceOfAnyTypeInListFromRef(floraList, plyr, distTotal)
		floraList.Revert()	;Needed to find the next herb.  Otherwise, we keep returning a null ref for some reason.
		
		If (floraRef != none)
			If ((floraRef.GetActorOwner() == none) && (floraRef.GetFactionOwner() == none))
				
				Cell pCell = floraRef.GetParentCell()
				
				If ((pCell.GetActorOwner() == none) && (pCell.GetFactionOwner() == none))
					floraRef.Activate(plyr)
					return
				EndIf
			EndIf
		EndIf
		
		loop += 1
	endWhile
endEvent

In the CK I have set the Property for ethereal to Ethereal and all other variants of it but always get the same papyrus log output:

[05/15/2017 - 03:35:35PM] Error: HasMagicEffect called with invalid Magic Effect
stack:
[ (00000014)].Actor.HasMagicEffect() - "<native>" Line ?
[AutoHarvestQuest (40002851)].AutoHarvestQuest.OnUpdate() - "autoharvestquest.psc" Line 20
[05/15/2017 - 03:35:51PM] VM is freezing...
I am new to papyrus and any help would be greatly appreciated
Link to comment
Share on other sites

You may need to adjust your code to check for all three versions. If I recall, Ethereal Form has three levels, so it will have magic effects for all three.

MagicEffects do not stick around long and are notoriously difficult to track.

Edit: OK this shout has three SPELLS for the 3 levels, instead of separate effects like the other shouts. That's tough since spells are easy to track if they are abilities. These spell types are Voice Power.

This is a guess but seems logical. The archtype "Etherealize" may tick the flag "is Ghost" or "Is Invulnerable"..

You can instead check for those flags.

http://www.creationkit.com/index.php?title=IsGhost_-_Actor
http://www.creationkit.com/index.php?title=IsInvulnerable_-_ActorBase

Edited by TheDungeonDweller
Link to comment
Share on other sites

  • Recently Browsing   0 members

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