Make Pokemon that Require a Fateful Encounter to be Legal to Always Be Set to Legal - pret/pokeemerald GitHub Wiki

By devolov

To prevent people cheating, Gamefreakmade it so Mew and Deoxys must have a MON_DATA_EVENT_LEGAL flag set to be legal, where they'd obey and be tradeable.
Adding these four lines of code will set them to legal the first time they get checked for legality and aren't.

In battle_util.c:

static bool32 IsMonEventLegal(u8 battlerId)
{
    if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
        return TRUE;
    if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_DEOXYS
        && GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_MEW)
            return TRUE;
+   if (!GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_EVENT_LEGAL, NULL)){
+       bool32 isEventLegal = TRUE;
+       SetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_EVENT_LEGAL, &isEventLegal);
+   }
    return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_EVENT_LEGAL, NULL);
}