#2155: units shoot too early when coming around corners - analysis and fix proposal ------------------------------------------------+--------------------------- Reporter: corvusco...@… | Type: to-do (no feature requests!) Status: new | Priority: major Milestone: 2.3.x | Component: Engine: other Version: trunk and 2.3 | Keywords: corners ground shooting Operating System: All/Non-Specific | Blocked By: Blocking: | ------------------------------------------------+--------------------------- 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! 1. 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! 2. 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) 3. 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 -- Ticket URL: <http://developer.wz2100.net/ticket/2155> Warzone 2100 Trac <http://developer.wz2100.net/> The Warzone 2100 Project _______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev