Code for new evo methods

This commit is contained in:
DizzyEggg 2019-04-03 22:19:18 +02:00
parent 0d6b13759a
commit 5219b7b30a
2 changed files with 120 additions and 5 deletions

View File

@ -407,6 +407,21 @@ enum
#define EVO_LEVEL_NINJASK 0x000d // Pokémon reaches the specified level (special value for Ninjask)
#define EVO_LEVEL_SHEDINJA 0x000e // Pokémon reaches the specified level (special value for Shedinja)
#define EVO_BEAUTY 0x000f // Pokémon levels up with beauty ≥ specified value
#define EVO_LEVEL_FEMALE 0x0010 // Pokémon reaches the specified level, is female
#define EVO_LEVEL_MALE 0x0011 // Pokémon reaches the specified level, is male
#define EVO_LEVEL_NIGHT 0x0012 // Pokémon reaches the specified level, is night
#define EVO_LEVEL_DAY 0x0013 // Pokémon reaches the specified level, is day
#define EVO_LEVEL_DUSK 0x0014 // Pokémon reaches the specified level, is dusk (5-6 P.M)
#define EVO_ITEM_HOLD_DAY 0x0015 // Pokémon levels up, holds specified item at day
#define EVO_ITEM_HOLD_NIGHT 0x0016 // Pokémon levels up, holds specified item at night
#define EVO_MOVE 0x0017 // Pokémon levels up, knows specified move
#define EVO_MOVE_TYPE 0x0018 // Pokémon levels up, knows move with specified type
#define EVO_MAP 0x0019 // Pokémon levels up on specified map
#define EVO_ITEM_MALE 0x001A // specified item is used on a male Pokémon
#define EVO_ITEM_FEMALE 0x001B // specified item is used on a female Pokémon
#define EVO_LEVEL_RAIN 0x001B // Pokémon reaches the specified level while it's raining
#define EVO_SPECIFIC_MON_IN_PARTY 0x001C // Pokémon levels up with a specified Pokémon in party
#define EVO_LEVEL_SPECIFIC_MON_TYPE_IN_PARTY 0x001D // Pokémon levels up with a specified Pokémon in party
struct Evolution
{

View File

@ -12,6 +12,7 @@
#include "event_data.h"
#include "evolution_scene.h"
#include "field_specials.h"
#include "field_weather.h"
#include "item.h"
#include "link.h"
#include "main.h"
@ -44,6 +45,7 @@
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/trainers.h"
#include "constants/weather.h"
struct SpeciesItem
{
@ -5340,7 +5342,7 @@ u8 GetNatureFromPersonality(u32 personality)
u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
{
int i;
int i, j;
u16 targetSpecies = 0;
u16 species = GetMonData(mon, MON_DATA_SPECIES, 0);
u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0);
@ -5378,15 +5380,56 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24 && friendship >= 220)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL_DAY:
RtcCalcLocalTime();
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24 && gEvolutionTable[species][i].param <= level)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_FRIENDSHIP_NIGHT:
RtcCalcLocalTime();
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12 && friendship >= 220)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL_NIGHT:
RtcCalcLocalTime();
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12 && gEvolutionTable[species][i].param <= level)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_ITEM_HOLD_NIGHT:
RtcCalcLocalTime();
if (gLocalTime.hours >= 0 && gLocalTime.hours < 12 && heldItem == gEvolutionTable[species][i].param)
{
heldItem = 0;
SetMonData(mon, MON_DATA_HELD_ITEM, &heldItem);
targetSpecies = gEvolutionTable[species][i].targetSpecies;
}
break;
case EVO_ITEM_HOLD_DAY:
RtcCalcLocalTime();
if (gLocalTime.hours >= 12 && gLocalTime.hours < 24 && heldItem == gEvolutionTable[species][i].param)
{
heldItem = 0;
SetMonData(mon, MON_DATA_HELD_ITEM, &heldItem);
targetSpecies = gEvolutionTable[species][i].targetSpecies;
}
break;
case EVO_LEVEL_DUSK:
RtcCalcLocalTime();
if (gLocalTime.hours >= 17 && gLocalTime.hours < 18 && gEvolutionTable[species][i].param <= level)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL:
if (gEvolutionTable[species][i].param <= level)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL_FEMALE:
if (gEvolutionTable[species][i].param <= level && GetMonGender(mon) == MON_FEMALE)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL_MALE:
if (gEvolutionTable[species][i].param <= level && GetMonGender(mon) == MON_MALE)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_LEVEL_ATK_GT_DEF:
if (gEvolutionTable[species][i].param <= level)
if (GetMonData(mon, MON_DATA_ATK, 0) > GetMonData(mon, MON_DATA_DEF, 0))
@ -5418,6 +5461,54 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
if (gEvolutionTable[species][i].param <= beauty)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_MOVE:
if (MonKnowsMove(mon, gEvolutionTable[species][i].param))
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_MOVE_TYPE:
for (j = 0; j < 4; j++)
{
if (gBattleMoves[GetMonData(mon, MON_DATA_MOVE1 + j, NULL)].type == gEvolutionTable[species][i].param)
{
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
}
}
break;
case EVO_SPECIFIC_MON_IN_PARTY:
for (j = 0; j < PARTY_SIZE; j++)
{
if (GetMonData(&gPlayerParty[j], MON_DATA_SPECIES, NULL) == gEvolutionTable[species][i].param)
{
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
}
}
break;
case EVO_LEVEL_SPECIFIC_MON_TYPE_IN_PARTY:
if (gEvolutionTable[species][i].param <= level)
{
for (j = 0; j < PARTY_SIZE; j++)
{
u16 species = GetMonData(&gPlayerParty[j], MON_DATA_SPECIES, NULL);
if (gBaseStats[species].type1 == gEvolutionTable[species][i].param
|| gBaseStats[species].type2 == gEvolutionTable[species][i].param)
{
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
}
}
}
break;
case EVO_LEVEL_RAIN:
j = GetCurrentWeather();
if (j == WEATHER_RAIN_LIGHT || j == WEATHER_RAIN_MED || j == WEATHER_RAIN_HEAVY)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_MAP:
if (gEvolutionTable[species][i].param <= level && gMapHeader.regionMapSectionId == gEvolutionTable[species][i].param)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
}
}
break;
@ -5433,7 +5524,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
if (gEvolutionTable[species][i].param == heldItem)
{
heldItem = 0;
SetMonData(mon, MON_DATA_HELD_ITEM, (u8 *)&heldItem);
SetMonData(mon, MON_DATA_HELD_ITEM, &heldItem);
targetSpecies = gEvolutionTable[species][i].targetSpecies;
}
break;
@ -5444,10 +5535,19 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
case 3:
for (i = 0; i < EVOS_PER_MON; i++)
{
if (gEvolutionTable[species][i].method == EVO_ITEM
&& gEvolutionTable[species][i].param == evolutionItem)
switch (gEvolutionTable[species][i].method)
{
targetSpecies = gEvolutionTable[species][i].targetSpecies;
case EVO_ITEM:
if (gEvolutionTable[species][i].param == evolutionItem)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_ITEM_FEMALE:
if (GetMonGender(mon) == MON_FEMALE && gEvolutionTable[species][i].param == evolutionItem)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
case EVO_ITEM_MALE:
if (GetMonGender(mon) == MON_MALE && gEvolutionTable[species][i].param == evolutionItem)
targetSpecies = gEvolutionTable[species][i].targetSpecies;
break;
}
}