Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Lead-on distance
Lead-on distance
2002-01-28, 5:59 PM #1
I'm trying to get lead-on distance to work with my bots, but i'm not exactly sure how to start. Given the projectile's velocity, the velocity of the player the bot's firing at, the distance between the player and the bot, how would I do this?
2002-01-28, 7:55 PM #2
You could get the distance by going:

vector ppos local
vector bpos local
flex distance local

ppos = GetThingPos(player);
bpos = GetThingPos(bot);

distance = VectorDist(ppos ,bpos);

Player speed isnt cool... but:

GetThingVel(player); <--returns a vector if I recall correctly

And probably the same with the projectile

GetThingVel(projectile);

So I guess you could work out the time needed for the projectile to get to the player somehow... [http://forums.massassi.net/html/wink.gif]

If GetThingVel(); returned the projectiles forword speed then it would make it easier.

[This message has been edited by Hellcat (edited January 28, 2002).]
Team Battle.
2002-01-29, 1:29 AM #3
..Or you cut out the middle-men....


Distance = Vectordist((Getthingpos(Player), Gtethingpos(Bot));

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2002-01-29, 8:59 AM #4
Seifer posted some excellent code that does just that. Look through the last month's Rbot posts. It's called "bot leading code".

If you have trouble implementing the code, reply here and I'll help you with it. [http://forums.massassi.net/html/wink.gif]

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-29, 10:39 AM #5
Here ya go ........ I fished it up for you ....

Code:
dummy = FireProjectile(rbot, projectile_weap0[curweap], -1, -1, '0 0 0', '0 0 0', 1.0, 0, 0.0, 0.0);	
projVel = GetThingVel(dummy);	
DestroyThing(dummy);	
opVel = GetThingVel(target);	
velDif = VectorSub(projVel, opVel);
speed = VectorDist('0 0 0', velDif);
distance = VectorDist(GetThingPos(target), GetThingPos(rbot));	
time = distance / speed;	
moved = VectorScale(opVel, time);	
meet = VectorAdd(GetThingPos(target), moved);


[EDIT: Stuiped code tags /EDIT]

[This message has been edited by *_Seifer_* (edited January 29, 2002).]
2002-01-29, 12:12 PM #6
Hideki wrote that up fer me when I was helpin Raynar with Rbots 0.2# (fill in # with whatever I put it in) It never did work quite right.... I saw this post and with my newfound knowledge of Vectors thanks to SaberMaster (Thanks again Sabey!), I'm soooooo close to havin it work, I can almost taste it. [http://forums.massassi.net/html/biggrin.gif]
-Hell Raiser
2002-01-29, 12:53 PM #7
Thanks guys!

↑ Up to the top!