Skip to content

Spring.DestroyUnit() bypasses killing buildee unit from factory #2772

@Fx-Doo

Description

@Fx-Doo
void CFactory::KillUnit(CUnit* attacker, bool selfDestruct, bool reclaimed, int weaponDefID)
{
	RECOIL_DETAILED_TRACY_ZONE;
	if (curBuild != nullptr) {
		curBuild->KillUnit(nullptr, false, true, -CSolidObject::DAMAGE_FACTORY_KILLED);
		curBuild = nullptr;
	}

	CUnit::KillUnit(attacker, selfDestruct, reclaimed, weaponDefID);
}

This patch of code supposedly is responsible for killing buildee from a lab upon death.
But when the death is caused by Spring.DestroyUnit, unit->ForcedKillUnit() is called and this isn't, meaning a buildee will stay alive.
unit->ForcedKillUnit(attacker, selfDestr, reclaimed, -CSolidObject::DAMAGE_KILLED_LUA);
Maybe add an exception for factories that would have to call both unit->ForcedKillUnit() and factory->curBuild -> KillUnit ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions