mirror of
https://github.com/FelipePrado0/SpartanPort.git
synced 2026-11-07 10:45:59 -10:00
main
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
68012b2bc3 |
Feat(Controls/Gameplay Enhancement): Switch Attacks On-Demand Instead of Cycled (#749)
An opt-in Controls option (GOW3_SWITCH_ATTACKS=1). L1 + d-pad direction switches to that weapon with its switch attack (the weapon in Kratos' hands does its attack again); L1 + Cross does the switch attack of the weapon in his hands instead of cycling. The d-pad alone switches as before. # Switch attacks on L1 + d-pad and L1 + Cross [Video Showcase.webm](https://github.com/user-attachments/assets/306dece5-b2e4-4bbb-865d-bbaba9c214ed) In the game, L1 + Cross cycles to the next weapon with that weapon's switch attack, and the d-pad switches weapons with no attack. This PR adds an opt-in option, *Switch attacks on L1 + d-pad and L1 + Cross* on the Controls page (`SPARTAN_SWITCH_ATTACKS=1`), off by default, that puts every switch attack on demand: - **L1 + a d-pad direction** switches to that weapon with its switch attack. With the weapon already in Kratos' hands, it does its attack again. - **L1 + Cross** does the switch attack of the weapon in his hands instead of cycling to the next one. - **The same weapon's switch attack again** waits 0.8 seconds after the last one. In the game each L1 + Cross also changed the weapon, so the attacks' short recovery could not be repeated. Switching to another weapon's attack is not held back. - **The d-pad alone** switches as before. Nothing presses buttons for the player. The game's own move system takes the game's own branches to the switch attacks. Only the input that takes them and the weapon they go to change: - **The data.** Holding L1 puts Kratos in a block move. Block moves hold ordinary "Cross just pressed" (and in a few moves "Cross held") branches to the switch-attack moves (`MOV_*Transition`), one per weapon that follows in the cycle. Each weapon has two switch-attack moves, a common one and a rarer one. The switch-attack move's script selects its weapon (`SCR_EnableWeapon`). - **Input check hook (`0xeb290`).** Those branches answer the pad's request instead of Cross. The game also checks them from a second loop (`0xe9a70`, in the air among others), where they are never taken, so Cross cycles nowhere. Every other condition of the move stays the game's: when he can switch, ownership, the timing window. - **Input queue hook (`0xe4063`).** The branch the move chose is swapped for one of the game's own branches to the requested weapon's switch attack, of the same kind and, when there is one, the same timing. The branches are found once, by scanning the hero's move data (all 42 are found in game: 36 for Cross just pressed, 6 for Cross held). - **D-pad select hook (`0x6b240`).** Notes the player stats (weapon in hand, weapons owned). - **Stubs that call C.** The hooks are written in `tools/switch_stubs.s` and call C functions in `runtime_pad.c` through `sysv_abi`, saving the registers that are live at each site. `tests/test_switch_hook.cpp` runs every stub from frames laid out like the game's, and finds the sites in the reference eboot. - **Tutorial text.** The Weapon Switching tutorial cards (texts 190, 283, 286) now end with "Hold [L1Button] to attack when switching weapons. / Use [L1Button] and [XButton] to repeat switch attacks." This covers all 16 `R_LANG_*.WAD` files, on copies mounted by `run.py` only while the option is on (`scripts/switch_text.py`). The game folder is never written. A language whose font lacks one of the new characters keeps its own text. - **More mounts.** The probe now takes up to 24 `--mount` arguments (was 8) and the runtime up to 32 mounts (was 16), so the glyphs' copies and the 16 language copies fit together. - **Research for whoever changes combat next.** `docs/moves.md` records how the game picks Kratos' next move: the move and branch layouts, input kinds, the input queue, the player stats offsets, the d-pad and weapon functions, and the method that found them. That method was a record-only build that logs what the move system does, described there so it can be rebuilt. Tested in game: L1 + Cross with each weapon, L1 + each owned direction from each weapon (standing and mid-combo), and the d-pad alone, with the Cestus, Claws and Blades. The log shows every request reaching the requested weapon's switch attack. A press during a move that cannot switch does nothing, as in the game (L1 + Triangle, then L1 + Cross, jumps there as it does without the option). The English tutorial text has been checked in game. German has been reviewed by a native speaker. The other languages are my translations and would benefit from a native check. The C++ tests pass; the Python suite fails only the tests that fail on an unmodified main in the same environment (tkinter, network share). --------- Co-authored-by: Claude Opus 5.5 <[email protected]> |