Skip to content

Conversation

@ahasasjeb
Copy link

Added functionality to freeze AI-controlled factory production when under EMP.

Added functionality to freeze AI-controlled factory production when under EMP.
Copy link
Contributor

@TaranDahl TaranDahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More documentation needs to be added. Could look into other PRs.

@ahasasjeb ahasasjeb changed the title fix:Implement freeze for AI factory production under EMP fix:Pause AI building production and spawner aircraft under EMP (respect ImmuneToEMP) Aug 29, 2025
Enhanced EMP handling for AI-owned buildings, ensuring production is paused during EMP effects based on immunity settings.
Comment on lines 163 to 171
if (auto const pBuilding = abstract_cast<BuildingClass*, true>(pOwner))
{
if (pBuilding->Type->Powered && !pBuilding->IsPowerOnline())
return 0;
}

if (const auto pOwnerType = pOwner->GetTechnoType(); pOwnerType && pOwnerType->SpawnRegenRate <= 0)
return 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions:

  • I saw in your doc that you want to prevent the respawn of the spawnee in EMP state, but is this necessary? Will the building still launch them in EMP state?
  • And, you used return 0;, it will not affect any of the vanilla logic, but it will cause issues with the Spawns.Queue logic later on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a clear look at the problem first and do not mark it as resolved at will

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review changes, please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also have the same concern that your code may not work as you expect because it return 0. Have you tested it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code works fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In EMP state, SpawnManagerClass will not make any updates, which means these are unnecessary.
Even if this has any effect, return 0 means continuing to execute the game's vanilla instructions, which will break Spawns.Queue's logic.

What I want to express is that the code here actually has no effect. This approach is no different from the vanilla, as SpawnManagerClass would never work under EMP.
If you want to pause the timer, you can do it like the production. Although this may not be the most efficient approach, it is feasible.

@TaranDahl TaranDahl added ❓Vanilla bug Vanilla game bugs that are requested to be fixed ⚙️T1 T1 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable and removed Needs discussion labels Aug 30, 2025
@ahasasjeb ahasasjeb requested a review from CrimRecya August 30, 2025 09:47
@CrimRecya
Copy link
Contributor

return 0 means continuing to execute the game's vanilla instructions, which will break Spawns.Queue's logic.

return 0 表示继续执行游戏原本的指令,这会损坏 Spawns.Queue 的逻辑。

If you want negative SpawnRegenRate to disable respawn, please set the return address correctly. Then clarify this in the migration document and what's new. In addition, I recommend changing the timer starting behavior when spawnee dies to avoid duplicate check here.

如果你想要让负数的 SpawnRegenRate 能够禁止重生,那么请正确设置返回地址。并在迁移文档、新增内容中明确这一点。另外,我更推荐在子机死亡时就更改设置计时器的行为,避免此处的重复检查。

And, I hope you can first check the content in Files changed yourself and remove outdated contents, as they are no longer needed.

并且,我希望你能够自己先检查下 Files changed 里的内容,移除过时的、不再需要的内容。

@ahasasjeb ahasasjeb closed this Aug 31, 2025
@ahasasjeb ahasasjeb deleted the fixAIemp branch August 31, 2025 05:07
@ahasasjeb ahasasjeb restored the fixAIemp branch August 31, 2025 05:08
@ahasasjeb ahasasjeb deleted the fixAIemp branch August 31, 2025 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️T1 T1 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable ❓Vanilla bug Vanilla game bugs that are requested to be fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants