Issue201

Title 139s attack tux being out of range
Priority minor Status open
Assigned To Keywords
Linked issues Watchers

Submitted on 2011-07-24 19h07 by tracker_migration, last changed by matthiaskrgr.

Messages
Author: tracker_migration Date: 2010-02-14   13h01
Submitted by matthiaskrgr
The 139 bots attack Tux even if he is out of range. So the bullets don't even have a chance to hit him.

rev. 2449

Thank you for your fine work!
Matthias kr\u00fcger
Author: tracker_migration Date: 2010-04-17   01h58
Posted by stedevil
What would be a better/expected behavior?
Author: tracker_migration Date: 2010-04-18   15h26
Posted by matthiaskrgr
To check whether Tux is in range before shooting?
Author: tracker_migration Date: 2010-04-18   17h04
Posted by stedevil
What if Tux moves into range during the time the bullet would have traveled there? And wouldn't that behavior make it very easy for Tux to just stand slightly outside of 139s shot range and soot them dead with a ranged weapon that has longer range? Now at least there is some "stress" about "will that bullet hit me or 'expire' in time?"
Author: tracker_migration Date: 2011-01-24   20h34
Posted by hakzsam
Don't worry it's a very old ticket and let's me to close it.
Author: tracker_migration Date: 2011-01-25   02h38
Posted by salimiles
As of SVN 3782:

Picking a target:
According to map/freedroid.droid_archtypes, the 139 has an attack range of 10 (squares), and uses the "Droid 139 Plasma Trash Vaporiser"  (UK spelling?).

According to enemy.c aggression distance (a) is compared to as follows:
a\u00b2 = x\u00b2 + y\u00b2
So basically the droid will ignore everything outside of a circle >10 squares from it.

Weapon Firing:
According to map/freedroid.item_archtypes, the "Droid 139 Plasma Trash Vaporiser" fires bullets that last for 2.0, and travel at a speed (s) of 12.

The file enemy.c describes the shot firing. Line 1656 says the range is the time*speed (so 24). And line 1658 checks to make certain the Tux is within range before firing. 

In bullet.c, lines 69 & 70 seem to divide this distance in half. Still this means a range of 12 , which means that the above (enemy.c, 1656) has a problem. So reopening.

Additionally, the function set_bullet_speed_to_target_direction() (line 2044) sets a speed of s in one direction, and up to s in the other direction. This means at certain angles the speed is \u221a(s*s + s*s) or  s\u221a(2)  rather than s. Since this is larger, this isn't a problem for us here.

So the range for the weapon actually is:
12-12\u221a(2)
all of which is >10.

So this shouldn't be a problem for the 139, however there is a bug in line 1656 of enemy.c .
Author: tracker_migration Date: 2011-01-25   22h11
Posted by hakzsam
Assigning to Salimiles since he made a new algorithm . :)

Part 1: http://rb.freedroid.org/r/787/
Part 2: http://rb.freedroid.org/r/788/
Author: tracker_migration Date: 2011-01-26   08h24
Posted by ahuillet
We need to fix that properly.

Does it even make sense to define a lifetime for bullets? Speed and range would probably make sense instead.

However it makes sense sometimes to shoot even out of range, when you aren't sure if you are in range or not.
History
Date User Action Args
2011-07-25 20:20:07matthiaskrgrsetpriority: bug -> minor
2011-07-24 19:07:37tracker_migrationcreate