mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
Document Probability Distribution of Calls to rand_int (#1063)
* document probability of the majority of conditional calls to rand_int * update positions of else/elseif comments * remove unneeded documentation
This commit is contained in:
parent
c3690e380e
commit
d65dce43df
@ -915,7 +915,7 @@ typedef struct BattleStatus {
|
||||
/* 0x09F */ char unk_9F;
|
||||
/* 0x0A0 */ struct EffectInstance* waterBlockEffect;
|
||||
/* 0x0A4 */ s8 cloudNineTurnsLeft;
|
||||
/* 0x0A5 */ s8 cloudNineDodgeChance; /* = 50% */
|
||||
/* 0x0A5 */ s8 cloudNineDodgeChance; /* = 50/101 ≈ 49.5% */
|
||||
/* 0x0A6 */ char unk_A6[2];
|
||||
/* 0x0A8 */ struct EffectInstance* cloudNineEffect;
|
||||
/* 0x0AC */ s8 merleeAttackBoost;
|
||||
|
42
src/16F740.c
42
src/16F740.c
@ -47,29 +47,30 @@ void btl_merlee_on_start_turn(void) {
|
||||
|
||||
if (currentEncounter->currentEnemy != NULL) {
|
||||
if (currentEncounter->currentEnemy->flags & ACTOR_FLAG_NO_HEALTH_BAR) {
|
||||
// 46/101 ≈ 45.5%
|
||||
if (temp <= 45) {
|
||||
playerData->merleeSpellType = MERLEE_SPELL_1;
|
||||
} else if (temp <= 90) {
|
||||
} else if (temp <= 90) { // 45/101 ≈ 44.6%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_2;
|
||||
} else {
|
||||
} else { // 10/101 ≈ 9.9%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
|
||||
}
|
||||
} else if (temp <= 30) {
|
||||
} else if (temp <= 30) { // 31/101 ≈ 30.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_1;
|
||||
} else if (temp <= 60) {
|
||||
} else if (temp <= 60) { // 30/101 ≈ 29.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_2;
|
||||
} else if (temp <= 80) {
|
||||
} else if (temp <= 80) { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
|
||||
} else {
|
||||
} else { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_COIN_BOOST;
|
||||
}
|
||||
} else if (temp <= 30) {
|
||||
} else if (temp <= 30) { // 31/101 ≈ 30.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_1;
|
||||
} else if (temp <= 60) {
|
||||
} else if (temp <= 60) { // 30/101 ≈ 29.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_2;
|
||||
} else if (temp <= 80) {
|
||||
} else if (temp <= 80) { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
|
||||
} else {
|
||||
} else { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_COIN_BOOST;
|
||||
}
|
||||
|
||||
@ -104,29 +105,30 @@ void btl_merlee_on_first_strike(void) {
|
||||
|
||||
if (currentEncounter->currentEnemy != NULL) {
|
||||
if (currentEncounter->currentEnemy->flags & ACTOR_FLAG_NO_HEALTH_BAR) {
|
||||
// 46/101 ≈ 45.5%
|
||||
if (temp <= 45) {
|
||||
playerData->merleeSpellType = MERLEE_SPELL_1;
|
||||
} else if (temp <= 90) {
|
||||
} else if (temp <= 90) { // 45/101 ≈ 44.6%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_2;
|
||||
} else {
|
||||
} else { // 10/101 ≈ 9.9%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
|
||||
}
|
||||
} else if (temp <= 30) {
|
||||
} else if (temp <= 30) { // 31/101 ≈ 30.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_1;
|
||||
} else if (temp <= 60) {
|
||||
} else if (temp <= 60) { // 30/101 ≈ 29.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_2;
|
||||
} else if (temp <= 80) {
|
||||
} else if (temp <= 80) { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
|
||||
} else {
|
||||
} else { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_COIN_BOOST;
|
||||
}
|
||||
} else if (temp <= 30) {
|
||||
} else if (temp <= 30) { // 31/101 ≈ 30.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_1;
|
||||
} else if (temp <= 60) {
|
||||
} else if (temp <= 60) { // 30/101 ≈ 29.7%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_2;
|
||||
} else if (temp <= 80) {
|
||||
} else if (temp <= 80) { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
|
||||
} else {
|
||||
} else { // 20/101 ≈ 19.8%
|
||||
playerData->merleeSpellType = MERLEE_SPELL_COIN_BOOST;
|
||||
}
|
||||
|
||||
|
@ -2424,6 +2424,7 @@ void render_with_fear_palettes(b32 isNpcSprite, ActorPart* part, s32 yaw, Matrix
|
||||
part->palAnimPosOffset[0] = FearPaletteAnimXOffsets[abs(decorationTable->nextPalTime)];
|
||||
if (part->palAnimPosOffset[0] == PAL_ANIM_END) {
|
||||
part->palAnimPosOffset[0] = 0;
|
||||
// 30-90
|
||||
decorationTable->nextPalTime = rand_int(60) + 30;
|
||||
}
|
||||
}
|
||||
@ -2563,6 +2564,7 @@ void render_with_paralyze_palettes(b32 isNpcSprite, ActorPart* part, s32 yaw, Ma
|
||||
part->palAnimPosOffset[1] = ParalyzePaletteAnimXOffsets[abs(decorationTable->nextPalTime)];
|
||||
if (part->palAnimPosOffset[1] == PAL_ANIM_END) {
|
||||
part->palAnimPosOffset[1] = 0;
|
||||
// 30-90
|
||||
decorationTable->nextPalTime = rand_int(60) + 30;
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ typedef struct Stage {
|
||||
/* 0x18 */ s32* foregroundModelList;
|
||||
/* 0x1C */ s32 stageEnemyCount; // number of enemies in the stageFormation
|
||||
/* 0x20 */ Formation* stageFormation; // extra enemies native to this stage
|
||||
/* 0x24 */ s32 stageEnemyChance; // chance for stageFormation enemies to spawn: N = 0 means always, N > 0 is 1/N chance
|
||||
/* 0x24 */ s32 stageEnemyChance; // 1/(N+1) chance for stageFormation enemies to spawn
|
||||
} Stage; // size = 0x28
|
||||
|
||||
/// Zero-terminated.
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
API_CALLABLE(N(func_802A123C_71D9AC)) {
|
||||
s32 t1 = 200;
|
||||
s32 r1 = rand_int(t1) + 100; // 100-299
|
||||
s32 r2 = rand_int(40); // 0-39
|
||||
s32 r1 = rand_int(t1) + 100; // 100-300
|
||||
s32 r2 = rand_int(40); // 0-40
|
||||
f32 var_f22;
|
||||
|
||||
if ((script->varTable[0] % 4) != 0) {
|
||||
|
@ -152,6 +152,7 @@ void step_game_loop(void) {
|
||||
gOverrideFlags &= ~GLOBAL_OVERRIDES_8000;
|
||||
}
|
||||
|
||||
// Unused rand_int used to advance the global random seed each visual frame
|
||||
rand_int(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user