mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-26 22:40:33 +00:00
Decompile DRA func_800FDE20 (#461)
This is a cool one! This runs every frame, and checks if you have enough EXP to level up. If you do, then it increases your level and gives you the stat bonuses for it. Therefore, I think `CheckAndDoLevelUp` might be a good name? I've held off on renaming; if reviewers are okay with the name then I'll update the PR with this. I don't know what the 3 values being checked at the beginning are. I might dig into those next. D_800A2EC0 is a table which tells how much to increase max HP for each level. Its values are 1, 3, 6, 10, 20, 30, 40, 50, 100, 200. So the first 10 levelups you get, you'll gain one max HP, then the next 10 give you 3 each, etc. I think this should be called LevelUpHPIncreaseTable, but again, holding off on renaming. I'm not sure if there's a way to include this as an array in the code rather than as an extern. I've also included updating the repo to the latest maspsx as part of this PR, let me know if that should be removed.
This commit is contained in:
parent
1ae33eee29
commit
bdddb80978
@ -29,6 +29,8 @@ segments:
|
||||
subalign: 4
|
||||
subsegments:
|
||||
- [0x0, data]
|
||||
- [0x2ED0, .data, 5D6C4]
|
||||
- [0x2EF8, data]
|
||||
- [0x3B458, .rodata, 42398]
|
||||
- [0x3B618, .rodata, play]
|
||||
- [0x3B648, rodata, gameover] # jtbl_800DB648
|
||||
|
@ -32,6 +32,8 @@ segments:
|
||||
- [0x518, data]
|
||||
- [0x1F18, data]
|
||||
- [0x2BC0, data]
|
||||
- [0x2EC0, .data, 5D6C4]
|
||||
- [0x2EE8, data]
|
||||
- [0x3C40, data]
|
||||
- [0x4A00, data]
|
||||
- [0x4B04, equipment, equipments]
|
||||
|
@ -18,6 +18,7 @@ D_800A2D7C = 0x800A2D94;
|
||||
D_800A2D80 = 0x800A2D98;
|
||||
D_800A2D98 = 0x800A2DA8;
|
||||
MenuContextData = 0x800A2E10;
|
||||
g_LevelHPIncrease = 0x800A2ED0;
|
||||
D_800A2EE8 = 0x800A2EF8;
|
||||
D_800A2EED = 0x800A2EFD;
|
||||
D_800A2EF8 = 0x800A2F08;
|
||||
@ -440,7 +441,7 @@ CastSpell = 0x800FDC48;
|
||||
LearnSpell = 0x800FDC94;
|
||||
func_800FDD44 = 0x800FDCF8;
|
||||
func_800FDE00 = 0x800FDDB4;
|
||||
func_800FDE20 = 0x800FDDD4;
|
||||
CheckAndDoLevelUp = 0x800FDDD4;
|
||||
func_800FE044 = 0x800FDFF8;
|
||||
func_800FE3A8 = 0x800FE360;
|
||||
func_800FE3C4 = 0x800FE37C;
|
||||
|
@ -22,6 +22,7 @@ D_800A2C0C = 0x800A2C0C;
|
||||
c_chPlaystationButtons = 0x800A2D70;
|
||||
c_chShoulderButtons = 0x800A2D74;
|
||||
MenuContextData = 0x800A2E00;
|
||||
g_LevelHPIncrease = 0x800A2EC0;
|
||||
g_CheatCodes = 0x800A300C;
|
||||
D_800A3134 = 0x800A3134;
|
||||
D_800A3144 = 0x800A3144;
|
||||
@ -978,6 +979,7 @@ AddToInventory = 0x800FD874;
|
||||
GetStatusAilmentTimer = 0x800FDB18;
|
||||
CastSpell = 0x800FDC94;
|
||||
LearnSpell = 0x800FDCE0;
|
||||
CheckAndDoLevelUp = 0x800FDE20;
|
||||
GetEquipProperties = 0x800FE728;
|
||||
HasEnoughMp = 0x800FE8B4;
|
||||
AddHearts = 0x800FE914;
|
||||
|
@ -231,7 +231,63 @@ void func_800FDE00(void) {
|
||||
D_80137968 = 0;
|
||||
}
|
||||
|
||||
INCLUDE_ASM("dra/nonmatchings/5D6C4", func_800FDE20);
|
||||
s32 g_LevelHPIncrease[] = {1, 3, 6, 10, 20, 30, 40, 50, 100, 200};
|
||||
|
||||
u32 CheckAndDoLevelUp(void) {
|
||||
s32 i;
|
||||
s32 statsGained;
|
||||
s32 statgain;
|
||||
|
||||
if (D_80137960 != 0) {
|
||||
D_80137960 -= 1;
|
||||
return 3;
|
||||
}
|
||||
if (D_80137964 != 0) {
|
||||
D_80137964 -= 1;
|
||||
return 2;
|
||||
}
|
||||
if (D_80137968 != 0) {
|
||||
D_80137968 -= 1;
|
||||
return 4;
|
||||
}
|
||||
if (g_Status.level == 99) {
|
||||
return 0;
|
||||
}
|
||||
if (c_arrExpNext[g_Status.level] <= g_Status.exp) {
|
||||
g_Status.level++;
|
||||
statsGained = 0;
|
||||
g_Status.mpMax += 4 + (rand() & 1);
|
||||
g_Status.hp += g_LevelHPIncrease[(s32)g_Status.level / 10];
|
||||
g_Status.hpMax += g_LevelHPIncrease[(s32)g_Status.level / 10];
|
||||
g_Status.heartsMax += 2;
|
||||
// Run again, in case we have enough EXP to level up twice
|
||||
CheckAndDoLevelUp();
|
||||
for (i = 0; i < LEN(g_Status.statsBase); i++) {
|
||||
// Flip a coin to decide if you will gain a stat here
|
||||
statgain = rand() & 1;
|
||||
g_Status.statsBase[i] += statgain;
|
||||
|
||||
if (g_Status.statsBase[i] > 99) {
|
||||
g_Status.statsBase[i] = 99;
|
||||
statgain = 0;
|
||||
}
|
||||
statsGained += statgain;
|
||||
}
|
||||
// If we gained less than 2 stats (got unlucky) give a mercy point to
|
||||
// random stat
|
||||
if (statsGained < 2) {
|
||||
// Note this is its own random event, so there's a chance to get +2
|
||||
// to one stat.
|
||||
i = rand() & 3;
|
||||
g_Status.statsBase[i]++;
|
||||
if (g_Status.statsBase[i] > 99) {
|
||||
g_Status.statsBase[i] = 99;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_800FE044(s32 amount, s32 type) {
|
||||
s32 oldHeartMax;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ed1f250291d2b25d3ec291a5d520fbd48e182c13
|
||||
Subproject commit 11399aa16fcaedd482486afbd7847cc30b97125f
|
Loading…
Reference in New Issue
Block a user