Skip to content

Commit

Permalink
Merge pull request #341 from DylanDoesProgramming664/fixes
Browse files Browse the repository at this point in the history
TRAINER_NAME_LEN location. Naming conventions for ov6_02240C9C.
  • Loading branch information
lhearachel authored Jan 19, 2025
2 parents 22f622f + ab15eff commit 72c048f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 81 deletions.
134 changes: 54 additions & 80 deletions src/overlay006/ov6_02240C9C.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,131 +810,105 @@ static BOOL ov6_022418DC(FieldSystem *fieldSystem, u32 encounterRate)
}
}

static u8 ov6_02241904(void)
static u8 GetGroundEncounterSlot(void)
{
u8 v0 = inline_020564D0(100);
u8 roll = inline_020564D0(100); // a common rng function

if (v0 < 20) {
if (roll < 20) {
return 0;
}

if (v0 >= 20 && v0 < 40) {
} else if (roll >= 20 && roll < 40) {
return 1;
}

if (v0 >= 40 && v0 < 50) {
} else if (roll >= 40 && roll < 50) {
return 2;
}

if (v0 >= 50 && v0 < 60) {
} else if (roll >= 50 && roll < 60) {
return 3;
}

if (v0 >= 60 && v0 < 70) {
} else if (roll >= 60 && roll < 70) {
return 4;
}

if (v0 >= 70 && v0 < 80) {
} else if (roll >= 70 && roll < 80) {
return 5;
}

if (v0 >= 80 && v0 < 85) {
} else if (roll >= 80 && roll < 85) {
return 6;
}

if (v0 >= 85 && v0 < 90) {
} else if (roll >= 85 && roll < 90) {
return 7;
}

if (v0 >= 90 && v0 < 94) {
} else if (roll >= 90 && roll < 94) {
return 8;
}

if (v0 >= 94 && v0 < 98) {
} else if (roll >= 94 && roll < 98) {
return 9;
}

if (v0 == 98) {
} else if (roll == 98) {
return 10;
}

return 11;
}

static u8 ov6_022419A0(void)
static u8 GetWaterEncounterSlot(void)
{
u8 v0 = inline_020564D0(100);
u8 roll = inline_020564D0(100); // a common rng function

if (v0 < 60) {
if (roll < 60) {
return 0;
}

if (v0 >= 60 && v0 < 90) {
} else if (roll >= 60 && roll < 90) {
return 1;
}

if (v0 >= 90 && v0 < 95) {
} else if (roll >= 90 && roll < 95) {
return 2;
}

if (v0 >= 95 && v0 < 99) {
} else if (roll >= 95 && roll < 99) {
return 3;
}

return 4;
}

static u8 ov6_022419EC(const int fishingRodType)
static u8 GetRodEncounterSlot(const int fishingRodType)
{
u8 v1 = 0;
u8 encSlot = 0;

u8 v0 = inline_020564D0(100);
u8 roll = inline_020564D0(100); // a common rng function

switch (fishingRodType) {
case FISHING_TYPE_OLD_ROD:
if (v0 < 60) {
v1 = 0;
} else if (v0 < 90) {
v1 = 1;
} else if (v0 < 95) {
v1 = 2;
} else if (v0 < 99) {
v1 = 3;
if (roll < 60) {
encSlot = 0;
} else if (roll < 90) {
encSlot = 1;
} else if (roll < 95) {
encSlot = 2;
} else if (roll < 99) {
encSlot = 3;
} else {
v1 = 4;
encSlot = 4;
}
break;
case FISHING_TYPE_GOOD_ROD:
if (v0 < 40) {
v1 = 0;
} else if (v0 < 80) {
v1 = 1;
} else if (v0 < 95) {
v1 = 2;
} else if (v0 < 99) {
v1 = 3;
if (roll < 40) {
encSlot = 0;
} else if (roll < 80) {
encSlot = 1;
} else if (roll < 95) {
encSlot = 2;
} else if (roll < 99) {
encSlot = 3;
} else {
v1 = 4;
encSlot = 4;
}
break;
case FISHING_TYPE_SUPER_ROD:
if (v0 < 40) {
v1 = 0;
} else if (v0 < 80) {
v1 = 1;
} else if (v0 < 95) {
v1 = 2;
} else if (v0 < 99) {
v1 = 3;
if (roll < 40) {
encSlot = 0;
} else if (roll < 80) {
encSlot = 1;
} else if (roll < 95) {
encSlot = 2;
} else if (roll < 99) {
encSlot = 3;
} else {
v1 = 4;
encSlot = 4;
}
break;
default:
GF_ASSERT(FALSE);
}

return v1;
return encSlot;
}

static void ov6_02241A90(Pokemon *mon, u8 *encounterRate)
Expand Down Expand Up @@ -1113,7 +1087,7 @@ static BOOL ov6_02241DC4(Pokemon *firstPartyMon, const int fishingRodType, const
v0 = ov6_0224222C(firstPartyMon, encounterFieldParams, param3, MAX_GRASS_ENCOUNTERS, TYPE_ELECTRIC, ABILITY_STATIC, &encounterSlot);

if (!v0) {
encounterSlot = ov6_02241904();
encounterSlot = GetGroundEncounterSlot();
}
}

Expand All @@ -1125,7 +1099,7 @@ static BOOL ov6_02241DC4(Pokemon *firstPartyMon, const int fishingRodType, const
v0 = ov6_0224222C(firstPartyMon, encounterFieldParams, param3, MAX_WATER_ENCOUNTERS, TYPE_ELECTRIC, ABILITY_STATIC, &encounterSlot);

if (!v0) {
encounterSlot = ov6_022419A0();
encounterSlot = GetWaterEncounterSlot();
}

level = ov6_02241B40(&param3[encounterSlot], encounterFieldParams);
Expand All @@ -1135,7 +1109,7 @@ static BOOL ov6_02241DC4(Pokemon *firstPartyMon, const int fishingRodType, const
v0 = ov6_0224222C(firstPartyMon, encounterFieldParams, param3, MAX_WATER_ENCOUNTERS, TYPE_ELECTRIC, ABILITY_STATIC, &encounterSlot);

if (!v0) {
encounterSlot = ov6_022419EC(fishingRodType);
encounterSlot = GetRodEncounterSlot(fishingRodType);
}

level = ov6_02241B40(&param3[encounterSlot], encounterFieldParams);
Expand Down Expand Up @@ -1180,7 +1154,7 @@ static BOOL ov6_02241F7C(FieldSystem *fieldSystem, Pokemon *param1, const WildEn
v0 = ov6_0224222C(param1, encounterFieldParams, param3, MAX_GRASS_ENCOUNTERS, TYPE_ELECTRIC, ABILITY_STATIC, &encounterSlot);

if (v0 == 0) {
encounterSlot = ov6_02241904();
encounterSlot = GetGroundEncounterSlot();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/overlay006/ov6_022489E4.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ BOOL ov6_02248CE8(UnkStruct_02095C48 *param0, int param1, const Strbuf *param2)
int v0, v1;
u8 *v2;
BOOL v3;
u16 v4[8];
u16 v4[8]; // Possibly TRAINER_NAME_LEN + 1

v0 = 8 * sizeof(u16);
v1 = 4;
Expand Down

0 comments on commit 72c048f

Please sign in to comment.