Commit Graph

71 Commits

Author SHA1 Message Date
RoosterDragon
2ed0656d1b Introduce MoveCooldownHelper to prevent lag spikes from failed pathfinding
Several activities that queue child Move activities can get into a bad scenario where the actor is pathfinding and then gets stuck because the destination is unreachable. When the Move activity then completes, then parent activity sees it has yet to reach the destination and tries to move again. However, the actor is still blocked in the same spot as before and thus the movment finishes immediately. This causes a performance death spiral where the actor attempts to pathfind every tick. The pathfinding attempt can also be very expensive if it must exhaustively check the whole map to determine no route is possible.

In order to prevent blocked actors from running into this scenario, we introduce MoveCooldownHelper. In its default setup it allows the parent activity to bail out if the actor was blocked during a pathfinding attempt. This means the activity will be dropped rather than trying to move endlessly. It also has an option to allow retrying if pathfinding was blocked, but applies a cooldown to avoid the performance penalty. For activities such as Enter, this means the actors will still try and enter their target if it is unreachable, but will only attempt once a second now rather than every tick.

MoveAdjacentTo will now cancel if it fails to reach the destination. This fixes MoveOntoAndTurn to skip the Turn if the move didn't reach the intended destination. Any other derived classes will similarly benefit from skipping follow-up actions.
2024-07-01 15:56:11 +03:00
Gustas
1a4f366e4b Make notifyAttacks more consistent 2024-02-07 15:30:41 +01:00
RoosterDragon
360f24f609 Fix IDE0055
This rule no longer appears to be buggy, so enforce it. Some of the automated fixes are adjusted in order to improve the result. #pragma directives have no option to control indentation, so remove them where possible.
2023-11-16 08:45:10 +02:00
Gustas
4dec79a5fb Fix Armament not working properly with value 0 in BurstDelays 2023-09-23 14:33:27 +02:00
RoosterDragon
3275875ae5 Fix CA1851 2023-08-20 20:41:27 +02:00
Gustas
69867b6c06 Fix EMP'ed units turning 2023-06-21 20:55:52 +02:00
darkademic
19fa03435b Only consider non-paused armaments (if any exist) when determining min/max range. 2023-06-20 16:46:21 +02:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
abcdefg30
d8349a429a Remove unnecessary uses of Exts.IsTraitEnabled 2022-10-14 13:50:57 +03:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
teinarss
d60c05eff3 Change to use pattern matching 2021-03-27 17:29:20 +01:00
Andre Mohren
1f6e0f582a Fixed aiming not propertly stopped. 2021-03-20 18:33:04 +01:00
abcdefg30
4953ce314b Make Attack turn during its own tick 2020-12-05 16:41:30 +00:00
Paul Chote
77ffc20a5f Convert Attack*.FacingTolerance to WAngle. 2020-11-30 16:39:48 +01:00
teinarss
13581c030d Use in parameter for Target 2020-11-06 22:02:24 +01:00
teinarss
27f1a7ab27 Use out var syntax 2020-08-19 18:11:07 +01:00
Matthias Mailänder
3bce55ac44 Cancel the attack when no traits are active. 2020-06-19 13:43:03 +02:00
Paul Chote
6adf45bcb4 Convert IFacing.Facing and TurnSpeed to WAngle. 2020-06-12 18:35:41 +02:00
abcdefg30
23b3c237b7 Update the year numbers in all license headers to 2020 2020-01-05 17:00:34 +00:00
abcdefg30
1e138a9774 Drop invisible invalid targets immediately when changing stance 2019-12-14 17:17:36 +01:00
tovl
4a609bbee8 Allow units to give way when path is blocked by oncoming unit. 2019-09-15 17:51:34 +01:00
Turupawn
3240b1e9eb Overhaul target line rendering:
- Targets are now defined by the activities
- Queued activities are shown
- Support custom attack colors
2019-08-05 02:53:09 +01:00
tovl
3790169db9 Make Tick return bool 2019-07-03 20:42:19 +02:00
tovl
b9c302a73a Move ChildActivity handling into base Activity class. 2019-07-03 20:42:19 +02:00
Paul Chote
3ca9d4b773 Drop targets when switching to a more restrictive stance. 2019-05-21 15:52:55 +02:00
tovl
9abf715fd7 Allow opportunity fire for aircraft. 2019-05-04 23:40:16 +02:00
Lars Beckers
e6750bf19c Fix attack behaviour of disabled units. 2019-04-20 02:28:27 +02:00
tovl
6f213dddec Make Attack use ChildActivities 2019-03-10 20:51:47 +01:00
tovl
a17cd0fa06 Replaced Canceled state with Canceling state. 2019-03-09 21:47:43 +00:00
tovl
8191a6566b Add missing self and optional pretick parameters to Queue, QueueChild and PrintActivity methods.
This means sequenceActivities needs to accept self as well.
2019-03-09 21:47:43 +00:00
Paul Chote
ab4a7e3558 Replace System.Drawing primitives with our own. 2019-03-04 18:26:42 +00:00
Paul Chote
49621bebd0 Abort activities when we don't know how close to move to a target. 2019-02-09 19:20:10 +01:00
Paul Chote
0a57fbda3c Prefer target to lastVisible target if it is visible. 2019-02-03 16:32:25 +01:00
Paul Chote
7c52a6f498 Fix target invalidation and reacquisition in Attack. 2019-01-26 22:53:46 +00:00
Paul Chote
d03c5b1c48 Split Target.Recalculate into methods with and without invalidation.
TargetExtensions is moved into its own file.
2019-01-26 22:53:46 +00:00
Paul Chote
b2d960ec19 Pass target line color to inner move activities. 2019-01-26 22:53:46 +00:00
abcdefg30
cadbd0d9ab Change the year number in all cs headers from 2018 to 2019 2019-01-26 23:15:21 +01:00
Paul Chote
6fc291a634 Disable target recalculation for bots.
This fixes bot-controlled units freezing when they
lock on to units that aren't visible.
2019-01-03 02:04:08 +01:00
Paul Chote
c34dd4b824 Allow Attack activities to target FrozenActors directly.
Removing the legacy FrozenActor to Actor workaround
fixes a number of long-standing bugs.

This also prevents units from losing their target when
it transforms into a different actor type.
2018-12-17 22:19:26 +01:00
Paul Chote
2ac7e451b4 Remove AttackBase.IgnoresVisibility.
This was a workaround for D2K sandworms, which is
now implemented using a custom attack activity.
2018-12-17 22:19:26 +01:00
Arular101
8a60918841 Update copyright notice year to 2018 2018-01-17 00:47:34 +01:00
Paul Chote
b898b5001a Rename AttackBase.IsAttacking to IsAiming to make its uses and assumptions clear. 2017-11-26 15:58:00 +01:00
Paul Chote
ea05221180 Count AttackStatus.NeedsToTurn as valid for AttackBase.IsAttacking. 2017-11-26 15:58:00 +01:00
Paul Chote
1376ad674e Remove Player.CanViewActor and .CanTargetActor. 2017-11-03 09:56:00 +01:00
forcecore
d1328212c6 AttackFrontal's FacingTolerance is now in effect 2017-08-07 10:26:26 +02:00
Forcecore
801796b184 FIX game hanging when units with 0 min-range attack units at 0 range.
Fixes #13307
2017-07-12 20:51:35 +02:00
reaperrr
33e8bf9928 Adapt Attack logic to Weapon.TargetActorCenter 2017-06-24 11:24:17 +01:00
reaperrr
da7433a95f Add plumbing for targeting of target center instead of closest targetable position
Note: Projectiles that can track their target need minor additional changes, but for InstantHit (which already implemented support for this) and unguided projectiles (Bullet, GravityBomb) this commit is already sufficient.
2017-06-15 01:32:37 +02:00
reaperrr
6a212eea53 Make attacking actors/turrets face the targeted position 2017-06-05 14:22:47 +02:00