Registrarse

[pokeemerald] Simplificar rematches

Jaizu

Usuario mítico
Aviso: El script que yo uso para el trainer está hecho en poryscript, no funcionará con los .inc.
Enlace a poryscript


Como bien sabéis, las rematches en Pokémon Emerald son algo speciales, pues van lidiadas al PokeNav.

Para conseguir un rematch en un emerald vanilla necesitamos:
  • Tener 5 medallas
  • Tener la flag FLAG_HAS_MATCH_CALL activada
  • Haber dado 255 pasos en el mapa del trainer, indicado en una tabla
  • Haber derrotado al trainer para tener la siguiente batalla de revancha
  • Haber registrado al trainer en el PokeNav
  • Refrescar el mapa (el porcentaje de obtener una revancha al refrescar el mapa es del 31%)
Como podéis ver, eso es un maldito coñazo, así que vamos a cargarnos muchas cosas para simplificarlas.

Yo para este tutorial yo usaré a la trainer Haley, situada en la Ruta 104, pero bueno, primero vamos a simplificarlo todo.

Primero vamos a eliminar el check de la flag FLAG_HAS_MATCH_CALL
En src/battle_setup.c, en la función RegisterTrainerInMatchCall quitamos el check, nos quedaría tal que así
Código:
static void RegisterTrainerInMatchCall(void)
{
    u32 matchCallFlagId = GetTrainerMatchCallFlag(gTrainerBattleOpponent_A);
    if (matchCallFlagId != 0xFFFF)
        FlagSet(matchCallFlagId);
}
Luego, también quitamos el check en src/match_call.c, en la función TryStartMatchCall, nos quedaría tal que así
Código:
bool32 TryStartMatchCall(void)
{
    if (UpdateMatchCallStepCounter() && UpdateMatchCallMinutesCounter()
     && CheckMatchCallChance() && MapAllowsMatchCall() && SelectMatchCallTrainer())
    {
        StartMatchCall();
        return TRUE;
    }

    return FALSE;
}
Ahora podemos quitar el 31% de posibilidades de conseguir una revancha.
En src/battle_setup.c, en la función UpdateRandomTrainerRematches quitamos el random, nos quedaría tal que así
Código:
static bool32 UpdateRandomTrainerRematches(const struct RematchTrainer *table, u16 mapGroup, u16 mapNum)
{
    s32 i;
    bool32 ret = FALSE;

    for (i = 0; i <= REMATCH_SPECIAL_TRAINER_START; i++)
    {
        if (table[i].mapGroup == mapGroup && table[i].mapNum == mapNum && !sub_80B1D94(i))
        {
            if (gSaveBlock1Ptr->trainerRematches[i] != 0)
            {
                // Trainer already wants a rematch. Don't bother updating it.
                ret = TRUE;
            }
            else if (FlagGet(FLAG_MATCH_CALL_REGISTERED + i))
            {
                SetRematchIdForTrainer(table, i);
                ret = TRUE;
            }
        }
    }

    return ret;
}
Ahora prodecemos a eliminar el check de las 5 medallas.
En src/battle_setup.c eliminamos la función HasAtLeastFiveBadges.
Luego eliminamos los checks de las funciones IncrementRematchStepCounter y IsRematchStepCounterMaxed, tal que así
Código:
void IncrementRematchStepCounter(void)
{
        if (gSaveBlock1Ptr->trainerRematchStepCounter >= STEP_COUNTER_MAX)
            gSaveBlock1Ptr->trainerRematchStepCounter = STEP_COUNTER_MAX;
        else
            gSaveBlock1Ptr->trainerRematchStepCounter++;
}

static bool32 IsRematchStepCounterMaxed(void)
{
    if (gSaveBlock1Ptr->trainerRematchStepCounter >= STEP_COUNTER_MAX)
        return TRUE;
    else
        return FALSE;
}
Otra cosa que deberíamos hacer es eliminar las llamadas del PokeNav, son llamadas que se ejecutan cuando vas caminando por el mapa tranquilamente, ejemplo:


En el archivo src/match_call.c, buscamos la función TryStartMatchCall y hacemos que siempre devuelva FALSE y que no se ejecute el StartMatchCall, tal que así
Código:
bool32 TryStartMatchCall(void)
{
    return FALSE;
}
Finalmente, podemos eliminar el diálogo que nos dice que un entrenador nos ha registrado en el Pokenav.
El script está en data/scripts/trainer_script.inc, yo lo dejé con solo el return:
Código:
Std_RegisteredInMatchCall:: @ 82742C9
    return
Ahora solo necesitamos el script de la entrenadora, en mi caso hice este, aunque debeís usar Poryscript para poder usarlo.
He puesto comentarios en el script para que os resulte más sencillo.
Código:
script Route104_EventScript_Haley_Pory {
    trainerbattle_single(TRAINER_HALEY_1, Route104_Text_HaleyIntro, Route104_Text_HaleyDefeat, Route104_EventScript_TryRegisterHaleyAfterBattle_Pory)
    specialvar(VAR_RESULT, ShouldTryRematchBattle) // Comprobamos si está el rematch listo
    if (var(VAR_RESULT) == TRUE) { // Si el rematch está listo peleamos contra ella
            trainerbattle_rematch(TRAINER_HALEY_1, Route104_Text_HaleyRematchIntro, Route104_Text_HaleyRematchDefeat)
            msgbox(format( // Este es el texto que dice después de que le ganemos el rematch
                "I made the decision to battle, so\n"
                "I can accept this loss with grace.\p"
                "I am still upset about losing!$"
            ), MSGBOX_AUTOCLOSE)
            end
    } else {
        setvar(VAR_0x8004, TRAINER_HALEY_1) // Guardamos el ID del entrenador en una variable
        specialvar(VAR_RESULT, IsTrainerRegistered) // Comprobamos si hemos registrado a la entrenador
        if (var(VAR_RESULT) == FALSE) { // Si no la tenemos registrada...
                call(register_her) // ¡La registramos!
        } else { // Si no simplemente nos muestra el mensaje de que ha perdido
            msgbox(format(
                "If you're faced with a decision and\n"
                "you let someone else choose for you,\l"
                "you will regret it, however things\l"
                "turn out.$"
            ), MSGBOX_DEFAULT)
        }
        release
        end
    }
}

text Route104_Text_HaleyIntro { // Este es el texto de cuando te reta por primera vez
    "Should I…\n"
    "Or shouldn't I?\p"
    "Okay, sure, I will battle!$"
}

text Route104_Text_HaleyDefeat { // Este es el texto de cuando la ganas por primera vez, en batalla
    "I shouldn't have battled…$"
}

text Route104_Text_HaleyRematchIntro { // Este es el texto que tiene en los rematches
    "Come on, battle with me!$"
}

text Route104_Text_HaleyRematchDefeat { // Este es el texto de cuando pierde en batalla, en los rematches
    "Ohh…\n"
    "I thought I could win…$"
}

script Route104_EventScript_TryRegisterHaleyAfterBattle_Pory {
    special(PlayerFaceTrainerAfterBattle)
    waitmovement(0)
    call(register_her)
    release
    end
}

script register_her {
    msgbox(format( // Aquí nos dice que si nos debería registrar para revanchas o no
        "You're strong, but should I register\n"
        "you in my POKéNAV?\l"
        "Maybe I shouldn't…\p"
        "Okay, sure, I will register you!$"
    ), MSGBOX_DEFAULT)
    register_matchcall(TRAINER_HALEY_1)
    return
}
Para escoger el mapa y los entrenadores de revancha debes modificar la tabla RematchTrainer en src/battle_setup.c, ahí nos indica que debemos dar 255 pasos en la ruta 104
Código:
[REMATCH_HALEY] = REMATCH(TRAINER_HALEY_1, TRAINER_HALEY_2, TRAINER_HALEY_3, TRAINER_HALEY_4, TRAINER_HALEY_5, ROUTE104)
 

Xiros

¡Pokémon Omega con actualización del 30/8!
Miembro de honor
Excelente aporte!! Me pareció muy claro.
 
Arriba