Grenade Angles

Started by
1 comment, last by Mushu 20 years, 5 months ago
Is there any way to calculate the angle for a certain range?? This is my first time using C++ so I have no idea how to output the stuff req''d to find it (ie distance of enemy + experimental angle -> how far off)...I''ve been using a nested if structure (which works kinda okay except when it blows my bot up).. I understand that I am the enemy, but for the sake of helpfulness?? hehe? -------
Advertisement
I made a polynomial to approximate it.. basically I tested the range at a variety of angles, and made a cubic best fit line in Excel... this was the result:

0.0002f*x^3 - 0.0622f*x^2 + 3.6339f*x + 49.691f

Note that sometimes the grenades bounce. this is only an estimate of the range. (x is the launch angle)

EDIT: obviously this gives the range for a given launch angle... you would need to inverse it, this is probably not good to do as it needs a cube/square root. You could obviously get a taylor expansion of the result.. or of course make a similar function for the inverse.

To output numerical info, I do this...

std::ostringstream output;
output<<(info to output here, to be converted to text);
Taunt(output.c_str());

So in your case, simply output the range of any grenade in view and it will appear in your bots speech output. To find out how you do this bit, read the readme. If you can't get it working.. then you probably need to work a bit more on your C++ skills before entering.

[edited by - dmounty on October 22, 2003 2:29:06 PM]
Ahh... so that''s how it works...

Thanks for the equation, dmounty.. I''ll plug that in for my final version happily...

Best of luck finishing your bot! Looks impressive, and should rip if you code it all!!

-------

This topic is closed to new replies.

Advertisement