Math wizards look here!

The place to discuss scripting and game modifications for X²: The Threat.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Math wizards look here!

Post by Kailric »

This was my first question: Hey I am trying to work a formula for telling if a target is moving away or towards you using..speed, time, and distance between the 2 objects. Any one have any ideas?
Got another math question...

I am assumeing that the script editor does no use decimals...am I correct?

So how could I right an expression to get a return from 80% of say 15500 using the script editor?

If decimals are not use then you could not say...
percent=15500 / (80/100)
But is there another way?
Last edited by Kailric on Sat, 24. Apr 04, 05:50, edited 1 time in total.
blackspell
Posts: 128
Joined: Sat, 6. Mar 04, 20:18
x2

Post by blackspell »

the simple way would be:

$distance = $target->get distance
=wait for 500 ms
$new.distance = $target->get distance

if $new.distance > $distance
* moving away
else
* closing in
end

but that is no real direction check, of course.
for this you have to convert the positional data into vectors
pos1.array = [THIS]->get position as array
=wait for 500 ms
pos2.array = [THIS]->get position as array
v.x = pos1.array[0] - pos2.array[0]
v.y = pos1.array[1] - pos2.array[1]
v.z = pos1.array[2] - pos2.array[2]

this has to be done for both ships, of course.
as ships in 3d space will never move into the exactly same direction, i would rather compare the quadrants of both ships.
if v1.x > 0 AND v1.y > 0 AND v1.z > 0
$ship1.quadrant = right.top.forward
else if v1.x > 0 AND v1.y > 0 AND v1.z < 0
$ship1.quadrant = right.top.back
else if v1.x > 0 AND v1.y < 0 AND v1.z > 0
$ship1.quadrant = right.bottom.forward
... and so on

afther that, you just have to compare the two quadrants of both ships.
i have not tested this out, but it should work ;)
User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Post by Kailric »

thanks , I'll have to wait till morning to cypher all that out..to tired right now. but thanks again for the time
User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Post by Kailric »

Got another math question...

I am assumeing that the script editor does no use decimals...am I correct?

So how could I right an expression to get a return from 80% of say 15500 using the script editor?

If decimals are not use then you could not say...
percent=15500 / (80/100)
But is there another way
"Try not. Do or do not, there is no try."-Yoda

"[Its] time for the human race to enter the solar system"-Dan Quayle
User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Post by Kailric »

Ha ha, I figured it out myself

15500 * 80% =12400

or 15500 (80/100)=12400

or (15500 * 8) / 10=12400


But is there anyother way?
"Try not. Do or do not, there is no try."-Yoda

"[Its] time for the human race to enter the solar system"-Dan Quayle

Return to “X²: The Threat - Scripts and Modding”