Vinifera
Vinifera copied to clipboard
[Vanilla Bug] AI sells artillery that have `UndeploysInto=none` when they are attacked by something out of range
First Check
- [X] I added a very descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I have attached as much information as possible (screenshots, debug and exception logs, etc).
Description
When the AI has a deployed Tick Tank, Artillery or Juggernaut that is attacked by a ground-based object that is out of the deployed unit's range, the AI undeploys the unit to move their "artillery" unit into range so they can retaliate. This behaviour is tied to the keys TickTank=yes
, Artillary=yes
and IsJuggernaut=yes
.
The undeploying is done by assigning MISSION_DECONSTRUCTION
to the deployed unit (building).
Normally, this is desired behaviour. However, if you, as a modder, create an artillery unit that has UndeploysInto=none
in its deployed form, iow. you remove the artillery's ability to undeploy, this behaviour still applies. Because MISSION_DECONSTRUCTION
is used not only for undeploying, but also for selling the unit, the AI ends up selling the deployed unit. This happens regardless of whether the building type has Sellable=no
.
Removing the TickTank=yes
, Artillary=yes
or IsJuggernaut=yes
keys from the object is no proper solution either, because those keys are necessary for the unit's deploy facing and deploy offset when it's turned into a building.
Required Code (optional)
No response
Steps To Reproduce
- Give the Deployed Tick Tank
DeploysInto=none
. Assign one of them to the AI (can be done through the map editor or through a standard attack script). - Attack the Deployed Tick Tank with something that has higher range. Like a Juggernaut.
Expected Behaviour
The Tick Tank should remain in place, since it cannot undeploy into any unit.
Actual Behaviour
The AI sells the Tick Tank.
Additional Context
BuildingClass::Assign_Target
is missing a check for UndeploysInto == nullptr
at 0x0042C624
. If that is the case, the function should jump to 0x0042C58C
to exit the function instead of assigning MISSION_DECONSTRUCTION
as the building's mission.