Skip to content

(SW) Cooldown Groups - #2387

Open
FS-21 wants to merge 15 commits into
Phobos-developers:developfrom
FS-21:feature/SW-Shared-Countdown
Open

(SW) Cooldown Groups#2387
FS-21 wants to merge 15 commits into
Phobos-developers:developfrom
FS-21:feature/SW-Shared-Countdown

Conversation

@FS-21

@FS-21 FS-21 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
  • Superweapons can be grouped together using SW.CooldownGroup. When any superweapon belonging to a group is launched, all other currently active (IsPresent) superweapons belonging to that group for the firer house will have their countdown timers reset (RechargeTimer), implementing a shared cooldown mechanism.
  • SW.CooldownGroup accepts a comma-separated list of group names, allowing a superweapon to belong to multiple groups simultaneously.
    • The reset is non-transitive: launching a superweapon only resets superweapons that share at least one group with the launched superweapon. Superweapons reset collaterally do not propagate resets to other groups.
  • SW.CooldownGroup.SyncLongest controls whether all present superweapons in the affected group(s) synchronize their cooldown to the longest RechargeTime among the superweapons currently active (built) in the group for that player. If any active superweapon in the group has this set to true, the synchronized longest cooldown applies to the entire group. If all active superweapons in the group have this set to false, each superweapon resets to its own individual recharge time.
  • If the AI has multiple superweapons in the same group ready to fire simultaneously, it automatically and fairly selects one candidate at random each frame rather than always defaulting to the first superweapons defined in [SuperWeaponTypes].

In rulesmd.ini:

[SOMESW]                                ; SuperWeaponType
SW.CooldownGroup=                       ; List of group names (strings separated by commas)
SW.CooldownGroup.SyncLongest=false      ; boolean

FS-21 added 12 commits September 3, 2026 09:18
- Add SW.GroupAs list of group names to [SuperWeaponType]
- Add SW.GroupAs.SyncLongestCooldown boolean tag (default false)
- Reset active superweapons sharing a group with the fired superweapon
- Optionally synchronize all group members to the longest recharge time of active superweapons
- Document new tags in docs/New-or-Enhanced-Logics.md
- Update tags to SW.CooldownGroup and SW.CooldownGroup.SyncLongest
- Update documentation heading to 'Cooldown groups' and clarify superweapons terminology
…apons

- Add HouseExt::AI_TryFireSW wrapper to randomly choose between ready superweapons sharing a cooldown group
- Use synchronized ScenarioClass::Instance->Random to prevent multiplayer desyncs
- Temporarily mask non-chosen superweapons during Ares evaluation loop and restore if not fired
- Wire hooks at 0x4FD799 and 0x4F9038
- Document AI fair selection behavior in docs/New-or-Enhanced-Logics.md
- Rename function to AI_TryFireSW_CooldownGroupAware to prevent confusion
- Add Debug::Log mentioning house ID, group name, and randomly selected candidate
- Clean up PRNG implementation details from documentation
- Use pOtherSuper->Type->RechargeTime to find true maximum base recharge time
- Call SetRechargeTime(maxRechargeTime) before Reset() to set CustomChargeTime
- Add debug logging to report fired superweapon and calculated maximum recharge time
…hold

- Correctly push pSuper->Type->ArrayIndex into SuspendedEMPulseSWs instead of arrayIndex
- Ensures all suspended superweapons are properly resumed when EMP cannon finishes firing
- Hook SuperClass::Grant (0x6CB560) to reset custom charge time when a structure is built/rebuilt
- Hook SuperClass::HasChargeProgressed (0x6CBDCC and 0x6CBDB7) to clear custom charge time once the superweapon reaches 100% Ready
- Ensures rebuilt structures charge with their own native RechargeTime rather than stale group cooldowns
…ooltip

- Display individual base recharge time
- Append (MM:SS) with the longest present group recharge time if it exceeds base time
- Do not append parentheses if group time equals base time
- Add Superweapon cooldown groups to Whats-New.md under 0.6 New (by FS-21)
- Add Superweapon cooldown groups under FS-21 in CREDITS.md
- Explicitly state that if any active superweapon in the group has SyncLongest=true, the synchronized longest cooldown applies to the entire group
- Clarify that individual reset times only occur if all active superweapons in the group have SyncLongest=false
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@Coronia

Coronia commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

I think SW.Link has already achieved similar thing? Maybe not as convenient as a group though, but it would be better to make the implementation based on it instead of reinventing the wheel

- Add RandomizeSuperWeaponPriority boolean tag under [AI] in rulesmd.ini (default false)
- Shuffle ready candidate superweapons using synchronized engine PRNG (Random2Class)
- Fall back gracefully to other ready candidates if first shuffled pick has no valid target
- Add documentation in New-or-Enhanced-Logics.md, entry in Whats-New.md, and credit in CREDITS.md
@FS-21

FS-21 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I think SW.Link has already achieved similar thing? Maybe not as convenient as a group though, but it would be better to make the implementation based on it instead of reinventing the wheel

Yeah, SW.Link.Reset=true can reset another weapon, but trying to simulate cooldown groups with it is a massive pain and misses several key things (Typed with AI for clean explanation):

  • Setup & maintenance: If you have 4 weapons in a group, you have to cross-link all of them manually (A links to B, C, D; B links to A, C, D, etc.), which gets messy very quickly. With groups you just give them the same group name tag.
  • No SyncLongest: SW.Link just resets each weapon to its own individual timer. It can't check which structures are currently on the map and sync all of them to the longest recharge time.
  • No UI / Tooltip info: It doesn't update the cameo tooltips, so the player has no idea the weapon is actually tied to a longer group cooldown.
  • AI selection: For the AI, SW.Link only runs after a weapon is already launched. It doesn't solve the issue where the AI always prioritizes the first weapon in [SuperWeaponTypes] when several are ready at the same time.
    So while you can technically do a basic mutual reset with SW.Link, having a proper group tag is much cleaner to configure and covers the actual gameplay and UI details that SW.Link can't do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants