Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XCX] Various New Mods #675

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
104 changes: 104 additions & 0 deletions src/XenobladeChroniclesX/Mods/BattleTensionPoints/patch_tphp_data.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[XCX_BootWithTP_Data]
moduleMatches = 0xF882D5CF, 0x30B6E091, 0x7672271D, 0x218F6E07, 0xAB97DE6B, 0x676EB33E, 0x785CA8A9 ; 1.0.1E, 1.0.2U, 1.0.2J, 1.0.0E, 1.0.1U, 1.0.0U, 1.0.0J
.origin = codecave
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the data file just stores a whole bunch of data that the mod needs to work.


;adress offsets for all the various stats a character has
currentHP = 0x84
currentTP = 0x94
maxHP = 0x88
maxTP = 0x98
meleeAttack = 0x9C
rangedAttack = 0xA0
potential = 0xA4
defence = 0xA8
meleeAccuracy = 0xAC
rangedAccuracy = 0xB0
evasion = 0xB4

;array of flags that check if applied max tp on boot to a specific character/skell
BoolBootWithTP:
.byte $QoL-1, $QoL-1, $QoL-1, $QoL-1, $QoLSkell-1, $QoLSkell-1, $QoLSkell-1, $QoLSkell-1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

has an array of bools to check if tp has been updated, so that it only updates once at boot

;keeps track if entered a function from ground or skell so that code that only applies to one can be conditionally executed
BoolIsInnerOrDoll:
.uint 0
;prevents a bug of delayed character getting max tp after boot
;if a character position is not in your party at boot and then you add a character to that position
;its flag was never set and so that character then gets the mod applied to them way later than expected.
;with this fix it is still possible to trigure it by starting with exactly 1 character in your party and then recruiting a character within 1 skip travel
;the bug can also happen by seeing a loading screen over 2 billion times to loop to negative (end even then won't apply to positions that its already applies before)
;that is such specific circumstances with such a minor bug that I don't care to fix it further
;the proper way to fix this would be to find a section of code that runs after ground boot and skell boot, does not need skell boot to happen to run, and does not get called in any other section of the game.
;then uses that spot set the flags above and nothing else. currently not worth it for such a minor bug
NumOfTimesLoadingScreenRan:
.uint 0
;array of cheat settings for ground
InnerCheatSettingsArray:
.short $TPCheat, $HPCheat, $noHPcheatnodieifdamagelt, $TPupdatecheatdieat0TP, $TPupdatecheatnegative, $HPupdatecheatnegative
;array of cheat settings for skell
DollCheatSettingsArray:
.short $TPCheatSkell, $HPCheatSkell, $noHPcheatnodieifdamageltSkell, $TPupdatecheatdieat0TPSkell, $TPupdatecheatnegativeSkell, $HPupdatecheatnegativeSkell
;array of syncronous settings for ground
InnerSyncSettingsArray:
.byte $HPboundtoTP, $HPboundtoTPNegative, $TPboundtoHP, $TPboundtoHPNegative
;array of syncronous settings for skell
DollSyncSettingsArray:
.byte $HPboundtoTPSkell, $HPboundtoTPNegativeSkell, $TPboundtoHPSkell, $TPboundtoHPNegativeSkell
Copy link
Contributor Author

Choose a reason for hiding this comment

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

has a whole bunch of arrays that store the settings from the rules.txt so they can be accessed easily and I dont need sperate code for ground characters and skells

;array of after battle heal settings for ground
InnerSlipHealSettingsArray:
.byte $afterbattleheal, $afterbattlerestoretp, $skiptravelheal
;array of after battle heal settings for ground
DollSlipHealSettingsArray:
.byte $afterbattleheal, $afterbattlerestoretp, $skiptravelhealSkell
;storage space for current hp for each character
StoreCurrentHP:
.uint 0, 0, 0, 0
;storage space for current hp for each skell
StoreCurrentHPDoll:
.uint 0, 0, 0, 0
;array of pointers to the storage space for characters stats
;below that, the stprage space for each characters stats
StoreCharacterStatsPointers:
.uint StoreCharacter0Stats, StoreCharacter1Stats, StoreCharacter2Stats, StoreCharacter3Stats
StoreCharacter0Stats:
.uint 0, 0, 0, 0, 0, 0, 0, 0
StoreCharacter1Stats:
.uint 0, 0, 0, 0, 0, 0, 0, 0
StoreCharacter2Stats:
.uint 0, 0, 0, 0, 0, 0, 0, 0
StoreCharacter3Stats:
.uint 0, 0, 0, 0, 0, 0, 0, 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to store a lot of data to identify what character we want to update the HP of
there needs to be a constant track of our hp for the disable healing when skip traveling mod

;array of pointers to the storage space for skells stats
;below that, the stprage space for each skells stats
StoreCharacterStatsDollPointers:
.uint StoreCharacter0StatsDoll, StoreCharacter1StatsDoll, StoreCharacter2StatsDoll, StoreCharacter3StatsDoll
StoreCharacter0StatsDoll:
.uint 0, 0, 0, 0, 0, 0, 0, 0
StoreCharacter1StatsDoll:
.uint 0, 0, 0, 0, 0, 0, 0, 0
StoreCharacter2StatsDoll:
.uint 0, 0, 0, 0, 0, 0, 0, 0
StoreCharacter3StatsDoll:
.uint 0, 0, 0, 0, 0, 0, 0, 0
;array of offsets for each of the stats. used to lower code duplication
PointerStatsOffsets:
.short maxHP, meleeAttack, rangedAttack, potential, defence, meleeAccuracy, rangedAccuracy, evasion
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this array is used when storing stats and checking stats.
the max tp stat is missing because there is a condition that is only used by 1 specific enemy that changes it
I do not think any of the other stats can change without going into a menu, and every menu calls the boot section of the mod pretty much

;multiple function pointers arrays used to make the checksetting function usable for all setting types from all sections:
FunctionPointerArrayCheatBoot:
.uint NoTensionCheat, InfiniteTensionCheat, TensionEqualsHealthCheat, HPTPMod_blr, NoHealthCheat, InfiniteHealthCheat, HealthEqualsTensionCheat, HPTPMod_blr
FunctionPointerArrayCheatTP:
.uint NoTensionCheat, InfiniteTensionCheat, TensionEqualsHealthCheat, TensionUpdatesFromHealthCheatTP, NoHealthCheat, InfiniteHealthCheat, HealthEqualsTensionCheatTP, HealthUpdatesFromTensionCheatTP
FunctionPointerArrayCheatHP:
.uint NoTensionCheat, InfiniteTensionCheat, TensionEqualsHealthCheat, TensionUpdatesFromHealthCheatHP, NoHealthCheatHP, InfiniteHealthCheat, HealthEqualsTensionCheat, HealthUpdatesFromTensionCheatHP
FunctionPointerArraySync:
.uint addTPHPSynchronous, addTPHPAsynchronous, addTPHPDecreaseOnly, addTPHPIncreaseOnly
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lookup tables full of function pointers. reduces code duplication by a lot for the cheat settings

;lookup table for all the settings above if applying to ground characters
LookupTableforInner:
.uint InnerCheatSettingsArray, InnerSyncSettingsArray, InnerSlipHealSettingsArray, BoolBootWithTP, StoreCurrentHP, StoreCharacterStatsPointers
;lookup table for all the settings above if applying to skells
LookupTableforDoll:
.uint DollCheatSettingsArray, DollSyncSettingsArray, DollSlipHealSettingsArray, BoolBootWithTP+4, StoreCurrentHPDoll, StoreCharacterStatsDollPointers
Copy link
Contributor Author

Choose a reason for hiding this comment

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

array of pointers for the data above.
the mod grabs one of these based on if the game is calling something for an on-ground character or a skell


;only piece of data used in the tphp_features file
;is used to tell the update hp function of the mod if the current heal is an out of battle heal
CurrentSlipHealPosition:
.uint 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[XCX_BootWithTP_Features]
moduleMatches = 0xF882D5CF, 0x30B6E091, 0x7672271D, 0x218F6E07, 0xAB97DE6B, 0x676EB33E, 0x785CA8A9 ; 1.0.1E, 1.0.2U, 1.0.2J, 1.0.0E, 1.0.1U, 1.0.0U, 1.0.0J
.origin = codecave
;currently missing features:
;a way to ignore max hp / max tp
;a way to fix your character health being shown on screen after battle if continously below its max
;a way to detect if the slip heal function is currently appling to a human or skell
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a list of features that should be added to the features file in the future.
I think what I have is good enough for right now and I want to move on

but will prolly be back to implement these in a month or 2



;This function is the exact same as 0x021D50F4 = nop
;the extra code is needed to make the cheat only apply when the apropriate option is selected in the rules.txt
;prevents skells from losing 50 GP/sec while out of them
StopSkellLosingGP:
li r4, $disableSkellLosingGP
cmpwi r4, 0
beq _StopSkellLosingGPExit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simple check for a setting that does nothing if the setting is disabled, and branches over a function call if setting is enabled

mflr r4
addi r4, r4, 8
mtlr r4
blr
_StopSkellLosingGPExit:
lwz r3, 0x24(r30)
blr

;no healing is the exact same as 0x021764F4 = blr
;prevents RegistDamage::HealHide::DamageSystem::HandleKey from ever being called
;the extra code is needed to make the dont update TP option work
;stops out of battle heals, and can also stop TP udating from out of battle heals in the sync settings
DontUpdateHP:
li r11, $afterbattleheal
cmpwi r11, 0
bne _DontUpdateHPExit
mtlr r0
blr
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simple check for a setting that does nothing if the setting is disabled, and if the setting is enabled prevents this function from being called from anywhere

_DontUpdateHPExit:
li r11, $afterbattlerestoretp
cmpwi r11, 0
bne _SkipDontUpdateTPslip
lis r9, CurrentSlipHealPosition@ha
lwz r11, CurrentSlipHealPosition@l(r9)
addi r11, r11, 1
cmpwi r11, 8
blt+ _CheckIFCountTooHigh
li r11, 0
_CheckIFCountTooHigh:
stw r11, CurrentSlipHealPosition@l(r9)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in my testing with the mod, the count never goes above 8 (1 for each of the 4 party members and 1 for each skell). it would be a glitch if it ever does. I have never encountered this glitching, but just incase it does, there is a check to zero the tracker count so that the game can fix its self

the count is to detect if a out of battle heal is happening and if so to not update TP if asynchronously bound

_SkipDontUpdateTPslip:
or r11, r1, r1
blr

[XCX_BootWithTP_Features_v101E_v102U]
moduleMatches = 0xF882D5CF, 0x30B6E091, 0x218F6E07 ; 1.0.1E, 1.0.2U, 1.0.0E
;prevents skells from losing 50 GP/sec while out of them
0x021D50EC = bla StopSkellLosingGP
;stops out of battle heals
0x021764F8 = bla DontUpdateHP

[XCX_BootWithTP_Features_v102J]
moduleMatches = 0x7672271D ; 1.0.2J
0x021D4BB8 = bla StopSkellLosingGP
0x02175FC4 = bla DontUpdateHP

[XCX_BootWithTP_Features_v100U]
moduleMatches = 0xAB97DE6B, 0x676EB33E ; 1.0.1U, 1.0.0U
0x021D50EC = bla StopSkellLosingGP
0x021764F8 = bla DontUpdateHP

[XCX_BootWithTP_Features_v100J]
moduleMatches = 0x785CA8A9 ; 1.0.0J
0x021D4934 = bla StopSkellLosingGP
0x02175D40 = bla DontUpdateHP
Loading