Jump to content

SL's FindAvailableActor() returns dead NPCs?


Recommended Posts

Posted

I've had some back and forth with skyrimll to try and debug issues with SL Dangerous Nights 2. The remaining outstanding issue is DN2's scan selecting dead NPCs.

 

I believe Ashal said FindAvailableActor's validation should filter out dead NPCs, but if that was the case then DN2 shouldn't be experiencing this problem, as it would take dead NPCs out of the equation at the very beginning.

 

Below is the code where DN2 initializes fills the NPC array:

	Actor[] NPC = new actor[4]
	If MCM.gender == "Both"
		NPC[0] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, -1, Game.GetPlayer())
		NPC[1] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, -1, Game.GetPlayer(), NPC[0])
		NPC[2] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, -1, Game.GetPlayer(), NPC[0], NPC[1])
		NPC[3] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, -1, Game.GetPlayer(), NPC[0], NPC[1], NPC[2])
	elseif MCM.gender == "Females Only"
		NPC[0] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 1, Game.GetPlayer())
		NPC[1] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 1, Game.GetPlayer(), NPC[0])
		NPC[2] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 1, Game.GetPlayer(), NPC[0], NPC[1])
		NPC[3] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 1, Game.GetPlayer(), NPC[0], NPC[1], NPC[2])
	elseif  MCM.gender == "Males Only"
		NPC[0] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 0, Game.GetPlayer())
		NPC[1] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 0, Game.GetPlayer(), NPC[0])
		NPC[2] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 0, Game.GetPlayer(), NPC[0], NPC[1])
		NPC[3] = SexLab.FindAvailableActor(Game.GetPlayer(), 4096.0, 0, Game.GetPlayer(), NPC[0], NPC[1], NPC[2])

Anyone know why the function is returning dead NPCs?

Posted

Technically, they can be dead and still pass. But for a dead actor to pass, they have to have some health left as well, which should only be possible if another mod is giving health to these dead NPC's before they get validated.

elseIf ActorRef.IsDead() && ActorRef.GetActorValue("Health") < 1.0
	Log("ValidateActor("+BaseRef.GetName()+") -- FALSE -- He's dead Jim.")
	return -13

This is to allow necro mods to work without reviving an npc, which would reset them completely.

Posted

from sslActorLibrary:

 

ActorRef.IsDead() && ActorRef.GetActorValue("Health") < 1.0

 

in case a dead actor has health then it MAY be found.

I think it is for necro anims.

 

Posted

Technically, they can be dead and still pass. But for a dead actor to pass, they have to have some health left as well, which should only be possible if another mod is giving health to these dead NPC's before they get validated.

elseIf ActorRef.IsDead() && ActorRef.GetActorValue("Health") < 1.0
	Log("ValidateActor("+BaseRef.GetName()+") -- FALSE -- He's dead Jim.")
	return -13

This is to allow necro mods to work without reviving an npc, which would reset them completely.

 

Okay, that may explain it then. I've noticed dead NPCs with positive health before. If I recall correctly, these were generally NPCs finished by killmoves.

 

There wouldn't happen to be any other way to select NPCs while ignoring the health value, is there? Otherwise I think DN2's NPC selection method will need to be re-written.

 

Simply adding an isDead() check after the NPC array is filled with 4 entries wouldn't work well since it leaves the possibility of a cell having 1 live NPC and 4 "dead" (HP>0 but dead) NPCs, and the NPC array filling with only the 4 dead ones. To do it properly would probably require getting an array of the entire cell's NPCs and then filtering them into a second array using a check for isDead() == false. I'd prefer avoiding having to make too many changes since I only intended to bug fix, not re-code. I'm also not that familiar with Skyrim scripting functions either (though I know enough that one option probably involves using GetNumRef and GetNthRef).

Posted

 

Technically, they can be dead and still pass. But for a dead actor to pass, they have to have some health left as well, which should only be possible if another mod is giving health to these dead NPC's before they get validated.

elseIf ActorRef.IsDead() && ActorRef.GetActorValue("Health") < 1.0
	Log("ValidateActor("+BaseRef.GetName()+") -- FALSE -- He's dead Jim.")
	return -13

This is to allow necro mods to work without reviving an npc, which would reset them completely.

 

...

 

 

Or maybe just a MCM option to fully disable "necro" actors, and change the isValidActor to something like:

 

elseIf (ActorRef.IsDead() && !config.enableNecro) || ActorRef.GetActorValue("Health") < 1.0

 

 

please post in the SexLab development thread, in case you want.

Posted

 

Or maybe just a MCM option to fully disable "necro" actors, and change the isValidActor to something like:

 

elseIf (ActorRef.IsDead() && !config.enableNecro) || ActorRef.GetActorValue("Health") < 1.0

 

 

please post in the SexLab development thread, in case you want.

 

 

Thanks for the suggestion, posted.

 

Additional unrelated thought: Is it possible for NPCs to have non-integer health values? E.g. 0.5, so it's technically < 1.0 but still alive.

Posted

 

Additional unrelated thought: Is it possible for NPCs to have non-integer health values? E.g. 0.5, so it's technically < 1.0 but still alive.

 

 

Yes, technically is possible because ActorValues (Heath is an ActorValue) are floats.

But I am not sure if the game engine rounds them or nor.

Posted

 

 

Additional unrelated thought: Is it possible for NPCs to have non-integer health values? E.g. 0.5, so it's technically < 1.0 but still alive.

 

 

Yes, technically is possible because ActorValues (Heath is an ActorValue) are floats.

But I am not sure if the game engine rounds them or nor.

 

 

Checked using the console during battle. Health values are definitely floats during combat, so it is possible to have 0.0 < HP < 1.0.

 

Technically that's probably a bug in the validation check, though it's a really edge case.

Archived

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

  • Recently Browsing   0 members

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