Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

units shoot too early when coming around corners - analysis and fix proposal #2155

Closed
wzdev-ci opened this issue Sep 7, 2010 · 6 comments
Closed

Comments

@wzdev-ci
Copy link
Contributor

wzdev-ci commented Sep 7, 2010

keyword_corners_ground_shooting resolution_fixed type_to-do (no feature requests!) | by corvuscorax@...


When a unit (or an army of units) is ordered to attack units out of sight behind a corner, they apparently roll past the corner, see the target appear and shoot - hitting just the edge of the corner they were crossing.

This has the potential of becoming worse with the latest fix for projectile-ground collissions, since the projectiles can no longer "cheat" (and fly through the ground)

Then the enemy sees the units and fires back while the units still recharge. -- what a slaughter!

The reason for that is lineOfFire() called by combFire() in combat.c before shooting at something returns true if at least the top of the unit is visible. And since all edges are angled in WZ (since WZ terrain doesn't allow vertical walls), the first thing to come in sight is the top corner of the opponent.

ProjectileSend() however will shoot at a random height in the center of the target, which at that point necessarily is still occluded. boom! ground hit!

The first guess how to fix this is to make lineOfFire() only return true if the target center is visible. But that would cause another bug:

If towers stand on top of a hill (or worse in second row behind a wall) their center is occluded. That would make such code no longer allow units to target them! (including sensors directing artillery?) while the towers are perfectly able to fire - their muzzle height is located at their top!

Another approach is in projectileSend(). Instead of aiming at a random point in the whole height of the target a check could be made via rayCast which parts of the target are visible and target a random point within that subset.
(Together with a slight alteration in lineOfFire() to require to have the visible section have a minimum size)

Remaining to be fixed would be "homing direct shots", since they always home for the targets center!
They adapt their trajectory with every single projectileInFlight() update, so doing a rayCast() there would be overkill.
However one could easily make a check to adapt the pitch (and vertical speed) of the projectile in every step to stay safely above the ground of the very next point in flight. The result would be sort of a "ground following" projectile that will no longer fly into the ground.

2 and 3 together with a very small adaption to lineOfFire() should fix the "shooting themselves into the foot when walking around corners" problem

regards

CorvusCorax


Issue migrated from trac:2155 at 2022-04-16 06:36:25 -0700

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Sep 8, 2010

corvuscorax@... commented


I added a patch addressing this problem to bug #2151

@wzdev-ci
Copy link
Contributor Author

littleppig commented


what if lineOfFire() return true only if target's muzzle point was visible? that will fixx both the tower problem, and the edges problem. (Theoretically, what maters is the muzzle point, not the base center... xD)

@wzdev-ci
Copy link
Contributor Author

anonymous commented


Likely due to #2832.

@wzdev-ci
Copy link
Contributor Author

Cyp changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

Cyp changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

Cyp commented


Closing, thanks. Please reopen if there's anything that isn't fixed yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant