Please help with my probably entirely wrong direction detect

Post » Mon Mar 25, 2013 10:50 am

So I'm currently putting together this nifty spell that throws a rune in the air and then after a short delay, spits death-by-fire out of itself in the direction the player cast it in, right now I'm using a projectile & explosion to place an activator that has this script I shamelessly copied and attempted to modify from another thread.
SPELL Property VoiceDragonFire05 AutoObjectReference Property CFXMarkerSource Auto  ObjectReference Property CFXMarker AutoACTOR Property PlayerRef AutoEvent OnInit(); Store all player camera anglesfloat AngleX = Math.Abs(PlayerRef.GetAngleX()) * -1float AngleY = PlayerRef.GetAngleY()float AngleZ = PlayerRef.GetAngleZ(); Create our distance variablesfloat SourceDistance = 10.0float TargetDistance = 2000.0; Calculate source positionfloat OffsetZ = SourceDistance * Math.Sin(AngleX)float DistanceXY = SourceDistance * Math.Cos(AngleX)float OffsetX = DistanceXY * Math.Sin(AngleZ)float OffsetY = DistanceXY * Math.Cos(AngleZ); Calculate the target positionOffsetZ = TargetDistance * Math.Sin(AngleX)DistanceXY = TargetDistance * Math.Cos(AngleX)OffsetX = DistanceXY * Math.Sin(AngleZ)OffsetY = DistanceXY * Math.Sin(AngleZ)Utility.Wait(1.5); Place CFXMarkerSource in front of Runefloat Mult = SourceDistance / TargetDistanceCFXMarkerSource.Enable()CFXMarkerSource.MoveTo(Self, OffsetX * Mult, OffsetY * Mult, OffsetZ * Mult)CFXMarkerSource.SetAngle(AngleX, AngleY, AngleZ); DESIGNATE YOUR LASER\Place CFXMarker at target positionCFXMarker.Enable()CFXMarker.MoveTo(Self, OffsetX, OffsetY, OffsetZ)VoiceDragonFire05.RemoteCast(CFXMarkerSource, PlayerRef, CFXMarker)Utility.Wait(0.5)CFXMarker.Disable()CFXMarkerSource.Disable()Self.Disable()Self.Delete()EndEvent

I know I've probably just butchered the script somewhere in my copying/changing, but I can't for the life of me find where, as it stands right now my spell will fire in different directions, but they're kind of all over the place, so I assume I just borked the mathematics and am too math challenged to find and understand where.

You guys are a clever bunch, what did I screw up? : )
User avatar
Catherine N
 
Posts: 3407
Joined: Sat Jan 27, 2007 9:58 pm

Return to V - Skyrim