Scriptname ESG_DetermineHeadshot extends ReferenceAlias Import MathFloat HeadPosXFloat HeadPosYFloat HeadPosZFloat HitPosXFloat HitPosYFloat HitPosZActor TargetBool HitLocReportedBool HeadLocReportedFunction HeadNode(Float PosX, Float PosY, Float PosZ, Actor Victim)HeadPosX = PosXHeadPosY = PosYHeadPosZ = PosZTarget = VictimHeadLocReported = trueIf HitLocReported HeadLocReported = false CalcResult()EndIfEndFunctionFunction HitLocation(Float PosX, Float PosY, Float PosZ)HitPosX = PosXHitPosY = PosYHitPosZ = PosZHitLocReported = trueIf HeadLocReported HitLocReported = false CalcResult()EndIfEndFunctionFunction CalcResult()Float Distance = sqrt(pow((HeadPosX - HitPosX), 2.0) + pow((HeadPosY - HitPosY), 2.0) + pow((HeadPosZ - HitPosZ), 2.0))If Distance < 100 Debug.Notification("Headshot!")Else Debug.Notification("Not a Headshot...")EndIfEndFunctionI also have a spell. This spell has a magic effect with the following script:
Scriptname ESG_HeadNodeFinder extends ActiveMagicEffect ReferenceAlias Property HeadshotLocator AutoEvent OnInit()Actor Target = GetTargetActor()HeadshotLocator.GetRef().MoveToNode(Target, "NPC Head [Head]")(HeadShotLocator as ESG_DetermineHeadshot).HeadNode(HeadShotLocator.GetRef().GetPositionX(), HeadShotLocator.GetRef().GetPositionY(), HeadShotLocator.GetRef().GetPositionZ(), Target)Dispel()EndEvent
The spell uses a custom projectile, that closely mimics Ice Spike, only it has an explosion. This explosion only exists to place another activator, this one is also custom. It has the attached script:
Scriptname ESG_HitPosScript extends ObjectReference ReferenceAlias Property HeadshotMarker AutoEvent OnInit()(HeadshotMarker as ESG_DetermineHeadshot).HitLocation(GetPositionX(), GetpositionY(), GetpositionZ())DisableNoWait()Delete()EndEvent
My problem is as follows: When a target is perfectly still, standing upright, and I shoot them in the head, I get a notification that it was not a headshot.
This tells me that both the magic effect and the projectile are reporting the location of the head node and the location of where the projectile hit, and the script is calculating something. But apparently, it isn't calculating it correctly. Either MoveToNode isn't working on my activator referencealias, or my equation is wrong.
Any help?
