Second problem is, I need the thing to shoot towards an actor and THEN deal damage. Unfortunately, it seems to deal damage before translating to the actor. So, that's not good. Here's the script, hopefully you guys can show me the error of my ways.
Scriptname PCKP_Script_GravThrownAlias extends ReferenceAlias GlobalVariable Property ShouldThrow autoReferenceAlias Property HitActor autoActor Property PlayerREF autoint DealDamage=0event OnTranslationComplete()float Heading = PlayerRef.GetHeadingAngle(GetReference())if ShouldThrow.GetValue() as int==1 ;GetReference().SplineTranslateToRefNode(PlayerRef, "NPC R Hand [RHnd]", 1, 1024) while ShouldThrow.GetValue() as int==1 ;if GetReference().GetDistance(PlayerREF) >= 128 GetReference().SplineTranslateTo(PlayerRef.GetPositionX() +- (20*Math.asin(Heading)),PlayerRef.GetPositionY() +- (20*(Math.acos(Heading))), PlayerRef.GetPositionZ() +90, 0, 0, 0, 1, 1280) ;else ; Utility.Wait(0.05) ;endIf endWhile elseIf HitActor.GetReference() && DealDamage==0 GetReference().SplineTranslateToRefNode(HitActor.GetReference(), "NPC Head [Head]", 1, 1280) while GetReference().GetDistance(HitActor.GetReference()) > HitActor.GetReference().GetHeight() Utility.Wait(0.05) endWhile DealDamage=1 elseIf DealDamage==1 GetReference().SetMotionType(GetReference().Motion_Dynamic) float DamageDealt = (GetReference().GetMass() * 5.0) if (GetReference().GetBaseObject() as Weapon) || (GetReference().GetBaseObject() as Ammo) DamageDealt = DamageDealt * 2.0 endIf Debug.Notification(DamageDealt) (HitActor.GetReference() as Actor).DamageActorValue("Health", DamageDealt) HitActor.Clear() Clear()else GetReference().SetMotionType(GetReference().Motion_Dynamic) HitActor.Clear() Clear()endIfendEvent
The first if statement is a bit counter-intuitive, as 1 means DON'T throw the object. It's where I want stuff in front of me. Where dealdamage==0 I want the thing to fly at the hit actor, which works about 30% of the time. The rest of the time the thing just falls to the ground, but still deals damage. This implies that the translation function should be happening, but just isn't. Maybe I need a better while condition for testing if the translation to the actor has occurred yet. I dunno.
Thanks in advance,
Alex