Howdy once again! I was working on a script this morning that would track the distance of a falling object (the x and y distance of a falling chopper) from its original starting point in the air. I got most of the bugs out of the script (and will eventually try to make a calculation for the height of the chopper) but run into wierd results during the tests. For the x and y distance i get 1E010 (with a small capital E making me think the answer is in scientific notation) and a similar answer for the Total Distance (hypotenuse of the triangle).
I am bringing the two scripts here because i think you guys can answer it for me.
BTW: The origin is a gamelogic point
;calc.sqs
#start
_ocalc1x = getpos origin select 0
_ocalc1y = getpos origin select 1
_ocalc1z = getpos origin select 2
_ycalc1x = getpos bob select 0
_ycalc1y = getpos bob select 1
_ycalc1z = getpos bob select 2
_xcalc1x = getpos bob select 0
_xcalc1y = getpos bob select 1
_xcalc1z = getpos bob select 2
this exec "hint.sqs"
#alive
?(bob == objNULL): exit
#ydistance
_x1 = ((_ycalc1x) - (_ocalc1x))
_y1 = ((_ycalc1y) - (_ocalc1y))
marky = "Gamelogic" CamCreate [(_x1),(_y1),1]
leg1 = marky distance origin
#xdistance
_x2 = ((_xcalc1x) - (_ocalc1x))
_y2 = ((_xcalc1y) - (_ocalc1y))
markx = "Gamelogic" CamCreate [(_x2),(_y2),1]
leg2 = markx distance origin
#hypdistance
_hyp1 = (((leg1)^2) + ((leg2)^2))
hyp2 = (sqrt _hyp1)
#restart
~0.15
camdestroy marky
camdestroy markx
goto "alive"
And this last one is a hint format script that displays the answers:
#hint.sqs
#Start
?(bob == objNULL): exit
#hint
~0.05
hint format ["Helicopter position:\n X: %1 \n y: %2 \n Total Distance: %3",leg1,leg2,hyp2]
goto "Start"
I will be glad to learn where and what the error is! Thanks in advance!