Jump to content

My alias is definitely filled, but my Papyrus.0 file says that it'


Topazanite

Recommended Posts

So, I'm trying to make my follower target the weakest enemy in a fight. I made a set of 5 reference aliases that target the 5 closest hostile actors, and this part of the mod works swimmingly. I know these reference aliases are properly filled and attached, because I attached a script to them. Every time I whack once of these aliases in game, a message box pops up, and sure enough all my combat enemies are spawning pop-up boxes.

 

Great! Then I added the below script to my mod:

ReferenceAlias Property rCoreFollower Auto

float Property fEnemy1HP Auto
float Property fEnemy2HP Auto
float Property fEnemy3HP Auto
float Property fEnemy4HP Auto
float Property fEnemy5HP Auto

float Property fEnemytoTarget Auto
float Property fEnemytoTargetHP Auto

ReferenceAlias Property CombatEnemy1 Auto
ReferenceAlias Property CombatEnemy2 Auto
ReferenceAlias Property CombatEnemy3 Auto
ReferenceAlias Property CombatEnemy4 Auto
ReferenceAlias Property CombatEnemy5 Auto


Function TargetPriorityTankingAI()
	if CombatEnemy1 != None 
		Debug.Trace("Follower is facing the enemy, determining the weakest foe...")
		fEnemy1HP = (CombatEnemy1.GetActorRef()).GetActorValue("health")
		fEnemytoTargetHP = fEnemy1HP
		fEnemytoTarget = 1.0
			if CombatEnemy2 != None 
				fEnemy2HP = (CombatEnemy2.GetActorRef()).GetActorValue("health")
					if fEnemy2hp > fEnemytoTargetHP
						fEnemytoTargetHP = fEnemy2hp
						fEnemytoTarget = 2.0
					endif
			endif
			if CombatEnemy3 != None 
				fEnemy3HP = (CombatEnemy3.GetActorRef()).GetActorValue("health")
					if fEnemy3hp > fEnemytoTargetHP
						fEnemytoTargetHP = fEnemy3hp
						fEnemytoTarget = 3.0
					endif
			endif
			if CombatEnemy4 != None 
				fEnemy4HP = (CombatEnemy4.GetActorRef()).GetActorValue("health")
					if fEnemy4hp > fEnemytoTargetHP
						fEnemytoTargetHP = fEnemy4hp
						fEnemytoTarget = 4.0
					endif
			endif
			if CombatEnemy5 != None 
				fEnemy5HP = (CombatEnemy5.GetActorRef()).GetActorValue("health")
					if fEnemy5hp > fEnemytoTargetHP
						fEnemytoTargetHP = fEnemy5hp
						fEnemytoTarget = 5.0
					endif
			endif
		Actor FollowerActor = rCoreFollower.GetActorRef()
		FollowerActor.StopCombatAlarm()	
		FollowerActor.StopCombat()		
			if fEnemytoTarget == 1.0
				Debug.Trace("Weakest foe 1 targeted, going in for the kill!")
				FollowerActor.StartCombat(CombatEnemy1.GetActorRef())
			elseif fEnemytoTarget == 2.0
				Debug.Trace("Weakest foe 2 targeted, going in for the kill!")
				FollowerActor.StartCombat(CombatEnemy2.GetActorRef())
			elseif fEnemytoTarget == 3.0
				Debug.Trace("Weakest foe 3 targeted, going in for the kill!")
				FollowerActor.StartCombat(CombatEnemy3.GetActorRef())
			elseif fEnemytoTarget == 4.0
				Debug.Trace("Weakest foe 4 targeted, going in for the kill!")
				FollowerActor.StartCombat(CombatEnemy4.GetActorRef())
			elseif fEnemytoTarget == 5.0
				Debug.Trace("Weakest foe 5 targeted, going in for the kill!")
				FollowerActor.StartCombat(CombatEnemy5.GetActorRef())
			endif
	elseif CombatEnemy1 == None
		;do nothing
	endif		
EndFunction

It's supposed to register all my enemy aliases' health, and force my companion to attack the lowest number. The script compiles, and obviously, the CombatEnemy referencealias properties are filled with my enemy reference aliases. The game is definitely registering the fact that they're filled because the code line "if CombatEnemy1 != None" seems to be running properly, and it's only the NEXT line of code that has issues. My Papyrus.0 file reads this:

[08/30/2013 - 12:18:52PM] Follower is facing the enemy, determining the weakest foe...


[08/30/2013 - 12:18:52PM] error: Cannot call GetActorValue() on a None object, aborting function call
stack:
	[FunctionalityQUST (08011107)].followerfunctionscript.TargetPriorityTankingAI() - "FollowerFunctionScript.psc" Line 146
	[alias Follower on quest FollowerAliasingQuest (08012C0F)].FollowAliasFollowingScript.OnCombatStateChanged() - "FollowAliasFollowingScript.psc" Line 51


[08/30/2013 - 12:18:52PM] warning: Assigning None to a non-object variable named "::temp36"
stack:
	[FunctionalityQUST (08011107)].followerfunctionscript.TargetPriorityTankingAI() - "FollowerFunctionScript.psc" Line 146
	[alias Follower on quest FollowerAliasingQuest (08012C0F)].FollowAliasFollowingScript.OnCombatStateChanged() - "FollowAliasFollowingScript.psc" Line 51


[08/30/2013 - 12:18:52PM] error: Cannot call GetActorValue() on a None object, aborting function call
stack:
	[FunctionalityQUST (08011107)].followerfunctionscript.TargetPriorityTankingAI() - "FollowerFunctionScript.psc" Line 150
	[alias Follower on quest FollowerAliasingQuest (08012C0F)].FollowAliasFollowingScript.OnCombatStateChanged() - "FollowAliasFollowingScript.psc" Line 51

The OnCombatStateChanged event is the separate quest script that calls the function, and isn't the issue. I have no idea whats going on. My CombatEnemy aliases are registering as none, even as I'm inundated with annoying pop-up boxes every time I smack one, proving that they ARE filled. My properties are definitely filled, and I've started over with a clean save to make sure that my test save wasn't corrupt. Does anyone have any advice?

Link to comment
Share on other sites

This is a wild guess...

 

Instead of

 

fEnemy1HP = (CombatEnemy1.GetActorRef()).GetActorValue("health")

try

 

Actor Enemy1 = CombatEnemy1.GetReference() as Actor
fEnemy1HP = Enemy1.GetActorValue("health")

 

And add debug.trace statements that list out the values of all your variables, might help to further narrow down where the problem lies.

Link to comment
Share on other sites

Changed code to this:

		Actor Enemy1 = CombatEnemy1.GetReference() as Actor
			Debug.Trace("Translated Enemy1 alias to actor.")
		fEnemy1HP = Enemy1.GetActorValue("health")
		fEnemytoTargetHP = fEnemy1HP
		fEnemytoTarget = 1.0

And the Papyrus.0 output is this:

[08/31/2013 - 09:18:26AM] Translated Enemy1 alias to actor.


[08/31/2013 - 09:18:26AM] error: Cannot call GetActorValue() on a None object, aborting function call
stack:
	[FunctionalityQUST (08011107)].followerfunctionscript.TargetPriorityTankingAI() - "FollowerFunctionScript.psc" Line 148
	[alias Follower on quest FollowerAliasingQuest (08012C0F)].FollowAliasFollowingScript.OnCombatStateChanged() - "FollowAliasFollowingScript.psc" Line 51

My companion keeps drawing and sheathing her weapon, starting and stopping combat continuously. So the game is determining that CombatEnemy1 does not equal none, and is running the rest of that block of code, but for some reason isn't liking the rest of it. The problem isn't my float, because the game says it's failing at calling the GetActorValue function on the "none" object. Therefore, CombatEnemy1 is the none object, but it clearly isn't none, or that part of the script wouldn't have run in the first place.

 

The CombatEnemy1 reference alias I'm calling belongs to a different quest than the function. Do I need to move my aliases, or would that do anything?

Link to comment
Share on other sites

 

 

The CombatEnemy1 reference alias I'm calling belongs to a different quest than the function. Do I need to move my aliases, or would that do anything?
Not knowing exactly how you have it set up.... no idea.

 

But I was looking at some Dawnguard quests for someone else and noticed that they use a lot of alias refs that point to alias refs on other quests. You could try that. Make new ref aliases on the quest with this script and fill it with the "External Alias Reference" pointing to the original alias refs on the first quest.

Link to comment
Share on other sites

Tried it and no dice. After that attempt, I was hunting in the Papyrus.0 file for anything new, and noticed in the long strong of errors that the script managed to complete correctly at least once:

[08/31/2013 - 11:31:04AM] Follower is facing the enemy, determining the weakest foe...

[08/31/2013 - 11:31:04AM] Translated Enemy1 alias to actor.

[08/31/2013 - 11:31:04AM] Weakest foe 2 targeted, going in for the kill!

The quest that I have my Enemy reference aliases attached to is set to restart itself every 5 seconds, to update its aliases with current nearby hostiles. I thought that maybe I've been completely retarded this whole time, and these errors are spawning from the periods of time that the quest is down and in the middle of restarting. So, I added two lines of code so that my function would only run if my enemy alias quest was also running, and lo and behold, the code worked! There were still smaller blocks of time that produced errors (I'm assuming from where the function starts to run and the quest switches off in the middle) but it was a vasty improvement.

 

So mystery solved. Of course I find the answer only after posting it on the forums, even though I've been working on the problem for days. :blush: Thank you for your help Ishara, I appreciate it.

 

Maybe I can set the quest so that it won't restart if the player is already in combat, but this means that the follower won't be able to register new opponents that enter the arena mid-combat. Bah, new problems.

Link to comment
Share on other sites

It's supposed to register all my enemy aliases' health, and force my companion to attack the lowest number. The script compiles, and obviously, the CombatEnemy referencealias properties are filled with my enemy reference aliases. The game is definitely registering the fact that they're filled because the code line "if CombatEnemy1 != None" seems to be running properly, and it's

The alias itself exists (although it isn't necessarily filled) so "if CombatEnemy1 != None" will be true. However, the Reference that the alias is meant to point to will be None whenever the quest isn't running, which will cause "CombatEnemy1.GetActorRef()" to be None. So you need to test "if CombatEnemy1 != None && CombatEnemy1.GetActorRef() != None".

Link to comment
Share on other sites

  • Recently Browsing   0 members

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