- 23
- Posts
- 6
- Years
- Seen Nov 28, 2023
Hi all,
I am trying to modify IV inheritance to include a Destiny Knot type of mechanism. I am modifying the file src/daycare.c, and I'm getting a syntax error at make. The thing is, I can see which line the error comes from, but I cannot understand what the syntax error is. I've tried looking up similar lines elsewhere from the decomp, but for some reason this won't work.
Here is my code:
And here is the error I get at make:
Line 549 is
so something goes wrong when the items of the parents are checked. If I comment out those lines, everything works. So, my question is, what is the syntax error here? I'm sure it's something simple, but this is driving me nuts. I even checked that there are no mixed whitespaces.
I would greatly appreciate any help! Thank you in advance for anyone who reads this.
I am trying to modify IV inheritance to include a Destiny Knot type of mechanism. I am modifying the file src/daycare.c, and I'm getting a syntax error at make. The thing is, I can see which line the error comes from, but I cannot understand what the syntax error is. I've tried looking up similar lines elsewhere from the decomp, but for some reason this won't work.
Here is my code:
Code:
static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
{
int n = INHERITED_IV_COUNT;
u32 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM);
u32 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM);
// the offending lines are this block
if (motherItem == ITEM_POTION || fatherItem == ITEM_POTION)
{
n = 5;
}
if (motherItem == ITEM_POKE_BALL || fatherItem == ITEM_POKE_BALL)
{
n = 6;
}
u8 i;
u8 selectedIvs[n];
u8 availableIVs[NUM_STATS];
u8 whichParents[n];
u8 iv;
// Initialize a list of IV indices.
for (i = 0; i < NUM_STATS; i++)
{
availableIVs[i] = i;
}
// Select the 3 IVs that will be inherited.
for (i = 0; i < n; i++)
{
// Randomly pick an IV from the available list and stop from being chosen again.
selectedIvs[i] = availableIVs[Random() % (NUM_STATS - i)];
RemoveIVIndexFromList(availableIVs, i);
}
// Determine which parent each of the selected IVs should inherit from.
for (i = 0; i < n; i++)
{
whichParents[i] = Random() % DAYCARE_MON_COUNT;
}
// Set each of inherited IVs on the egg mon.
for (i = 0; i < n; i++)
{
switch (selectedIvs[i])
{
case 0:
iv = GetBoxMonData(&daycare->mons[whichParents[i]].mon, MON_DATA_HP_IV);
SetMonData(egg, MON_DATA_HP_IV, &iv);
break;
case 1:
iv = GetBoxMonData(&daycare->mons[whichParents[i]].mon, MON_DATA_ATK_IV);
SetMonData(egg, MON_DATA_ATK_IV, &iv);
break;
case 2:
iv = GetBoxMonData(&daycare->mons[whichParents[i]].mon, MON_DATA_DEF_IV);
SetMonData(egg, MON_DATA_DEF_IV, &iv);
break;
case 3:
iv = GetBoxMonData(&daycare->mons[whichParents[i]].mon, MON_DATA_SPEED_IV);
SetMonData(egg, MON_DATA_SPEED_IV, &iv);
break;
case 4:
iv = GetBoxMonData(&daycare->mons[whichParents[i]].mon, MON_DATA_SPATK_IV);
SetMonData(egg, MON_DATA_SPATK_IV, &iv);
break;
case 5:
iv = GetBoxMonData(&daycare->mons[whichParents[i]].mon, MON_DATA_SPDEF_IV);
SetMonData(egg, MON_DATA_SPDEF_IV, &iv);
break;
}
}
}
And here is the error I get at make:
Code:
$ make
src/daycare.c: In function `InheritIVs':
src/daycare.c:549: syntax error before `i'
src/daycare.c:556: `i' undeclared (first use in this function)
src/daycare.c:556: (Each undeclared identifier is reported only once
src/daycare.c:556: for each function it appears in.)
src/daycare.c:558: `availableIVs' undeclared (first use in this function)
src/daycare.c:565: `selectedIvs' undeclared (first use in this function)
src/daycare.c:572: `whichParents' undeclared (first use in this function)
src/daycare.c:581: `iv' undeclared (first use in this function)
agbcc: warnings being treated as errors
src/daycare.c:582: warning: unreachable code at beginning of switch statement
make: *** [Makefile:250: build/emerald/src/daycare.o] Virhe 1
Line 549 is
Code:
u8 i;
I would greatly appreciate any help! Thank you in advance for anyone who reads this.