mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 12:14:20 +01:00
some more stuff
This commit is contained in:
parent
1bd4f9c7a8
commit
f4dc5e931f
@ -168,6 +168,8 @@ bool32 PartnerMoveIsSameNoTarget(u8 battlerAtkPartner, u16 move, u16 partnerMove
|
|||||||
bool32 ShouldUseWishAromatherapy(u8 battlerAtk, u8 battlerDef, u16 move);
|
bool32 ShouldUseWishAromatherapy(u8 battlerAtk, u8 battlerDef, u16 move);
|
||||||
|
|
||||||
// party logic
|
// party logic
|
||||||
|
struct BattlePokemon *AllocSaveBattleMons(void);
|
||||||
|
void FreeRestoreBattleMons(struct BattlePokemon *savedBattleMons);
|
||||||
s32 AI_CalcPartyMonBestMoveDamage(u32 battlerAtk, u32 battlerDef, struct Pokemon *attackerMon, struct Pokemon *targetMon);
|
s32 AI_CalcPartyMonBestMoveDamage(u32 battlerAtk, u32 battlerDef, struct Pokemon *attackerMon, struct Pokemon *targetMon);
|
||||||
s32 CountUsablePartyMons(u8 battlerId);
|
s32 CountUsablePartyMons(u8 battlerId);
|
||||||
bool32 IsPartyFullyHealedExceptBattler(u8 battler);
|
bool32 IsPartyFullyHealedExceptBattler(u8 battler);
|
||||||
|
@ -788,7 +788,7 @@ void AI_TrySwitchOrUseItem(void)
|
|||||||
|
|
||||||
// If there are two(or more) mons to choose from, always choose one that has baton pass
|
// If there are two(or more) mons to choose from, always choose one that has baton pass
|
||||||
// as most often it can't do much on its own.
|
// as most often it can't do much on its own.
|
||||||
static u32 GetBestMonBatonPass(struct Pokemon *party, int firstId, int lastId, u8 invalidMons, int aliveCount)
|
static u32 GetBestMonBatonPass(struct Pokemon *party, int firstId, int lastId, u8 invalidMons, int aliveCount, u32 opposingBattler)
|
||||||
{
|
{
|
||||||
int i, j, bits = 0;
|
int i, j, bits = 0;
|
||||||
|
|
||||||
@ -796,7 +796,7 @@ static u32 GetBestMonBatonPass(struct Pokemon *party, int firstId, int lastId, u
|
|||||||
{
|
{
|
||||||
if (invalidMons & gBitTable[i])
|
if (invalidMons & gBitTable[i])
|
||||||
continue;
|
continue;
|
||||||
if (IsAiPartyMonOHKOBy(BATTLE_OPPOSITE(gActiveBattler), &party[i]))
|
if (IsAiPartyMonOHKOBy(opposingBattler, &party[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < MAX_MON_MOVES; j++)
|
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||||
@ -980,7 +980,7 @@ u8 GetMostSuitableMonToSwitchInto(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bestMonId = GetBestMonBatonPass(party, firstId, lastId, invalidMons, aliveCount);
|
bestMonId = GetBestMonBatonPass(party, firstId, lastId, invalidMons, aliveCount, opposingBattler);
|
||||||
if (bestMonId != PARTY_SIZE)
|
if (bestMonId != PARTY_SIZE)
|
||||||
return bestMonId;
|
return bestMonId;
|
||||||
|
|
||||||
@ -1161,17 +1161,26 @@ static bool32 AI_OpponentCanFaintAiWithMod(u32 healAmount)
|
|||||||
|
|
||||||
static bool32 IsAiPartyMonOHKOBy(u32 battlerAtk, struct Pokemon *aiMon)
|
static bool32 IsAiPartyMonOHKOBy(u32 battlerAtk, struct Pokemon *aiMon)
|
||||||
{
|
{
|
||||||
struct BattlePokemon *battleMon;
|
bool32 ret = FALSE;
|
||||||
|
struct BattlePokemon *savedBattleMons;
|
||||||
s32 hp = GetMonData(aiMon, MON_DATA_HP);
|
s32 hp = GetMonData(aiMon, MON_DATA_HP);
|
||||||
s32 bestDmg = AI_CalcPartyMonBestMoveDamage(battlerAtk, gActiveBattler, NULL, aiMon);
|
s32 bestDmg = AI_CalcPartyMonBestMoveDamage(battlerAtk, gActiveBattler, NULL, aiMon);
|
||||||
|
|
||||||
switch (GetNoOfHitsToKO(bestDmg, hp))
|
switch (GetNoOfHitsToKO(bestDmg, hp))
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
case 2: // TODO: Compare speeds, if AI mon is faster allow 2 turns
|
break;
|
||||||
return TRUE;
|
case 2: // if AI mon is faster allow 2 turns
|
||||||
|
savedBattleMons = AllocSaveBattleMons();
|
||||||
|
PokemonToBattleMon(aiMon, &gBattleMons[gActiveBattler]);
|
||||||
|
if (AI_WhoStrikesFirst(gActiveBattler, battlerAtk, 0) == AI_IS_SLOWER)
|
||||||
|
ret = TRUE;
|
||||||
|
else
|
||||||
|
ret = FALSE;
|
||||||
|
FreeRestoreBattleMons(savedBattleMons);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3368,16 +3368,27 @@ bool32 ShouldUseWishAromatherapy(u8 battlerAtk, u8 battlerDef, u16 move)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SIZE_G_BATTLE_MONS (sizeof(struct BattlePokemon) * MAX_BATTLERS_COUNT)
|
||||||
|
|
||||||
|
struct BattlePokemon *AllocSaveBattleMons(void)
|
||||||
|
{
|
||||||
|
struct BattlePokemon *savedBattleMons = Alloc(SIZE_G_BATTLE_MONS);
|
||||||
|
memcpy(savedBattleMons, gBattleMons, SIZE_G_BATTLE_MONS);
|
||||||
|
return savedBattleMons;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeRestoreBattleMons(struct BattlePokemon *savedBattleMons)
|
||||||
|
{
|
||||||
|
memcpy(gBattleMons, savedBattleMons, SIZE_G_BATTLE_MONS);
|
||||||
|
Free(savedBattleMons);
|
||||||
|
}
|
||||||
|
|
||||||
// party logic
|
// party logic
|
||||||
s32 AI_CalcPartyMonBestMoveDamage(u32 battlerAtk, u32 battlerDef, struct Pokemon *attackerMon, struct Pokemon *targetMon)
|
s32 AI_CalcPartyMonBestMoveDamage(u32 battlerAtk, u32 battlerDef, struct Pokemon *attackerMon, struct Pokemon *targetMon)
|
||||||
{
|
{
|
||||||
s32 bestDmg, dmg;
|
s32 i, move, bestDmg, dmg;
|
||||||
u32 i, move;
|
|
||||||
u8 effectiveness;
|
u8 effectiveness;
|
||||||
struct BattlePokemon *battleMons = Alloc(sizeof(struct BattlePokemon) * MAX_BATTLERS_COUNT);
|
struct BattlePokemon *savedBattleMons = AllocSaveBattleMons();
|
||||||
|
|
||||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
|
||||||
battleMons[i] = gBattleMons[i];
|
|
||||||
|
|
||||||
if (attackerMon != NULL)
|
if (attackerMon != NULL)
|
||||||
PokemonToBattleMon(attackerMon, &gBattleMons[battlerAtk]);
|
PokemonToBattleMon(attackerMon, &gBattleMons[battlerAtk]);
|
||||||
@ -3399,10 +3410,7 @@ s32 AI_CalcPartyMonBestMoveDamage(u32 battlerAtk, u32 battlerDef, struct Pokemon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
FreeRestoreBattleMons(savedBattleMons);
|
||||||
gBattleMons[i] = battleMons[i];
|
|
||||||
|
|
||||||
Free(battleMons);
|
|
||||||
return dmg;
|
return dmg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3366,39 +3366,25 @@ static const struct TrainerMonItemCustomMoves sParty_Drake[] = {
|
|||||||
|
|
||||||
static const struct TrainerMonItemCustomMoves sParty_Roxanne1[] = {
|
static const struct TrainerMonItemCustomMoves sParty_Roxanne1[] = {
|
||||||
{
|
{
|
||||||
.iv = 46,
|
.iv = 100,
|
||||||
.lvl = 46,
|
.lvl = 12,
|
||||||
.species = SPECIES_SKARMORY,
|
.species = SPECIES_GEODUDE,
|
||||||
.heldItem = ITEM_NONE,
|
.heldItem = ITEM_NONE,
|
||||||
.moves = {MOVE_SPIKES, MOVE_TOXIC, MOVE_WHIRLWIND, MOVE_ROOST}
|
.moves = {MOVE_TACKLE, MOVE_DEFENSE_CURL, MOVE_ROCK_THROW, MOVE_ROCK_TOMB}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.iv = 100,
|
.iv = 100,
|
||||||
.lvl = 46,
|
.lvl = 12,
|
||||||
.species = SPECIES_TROPIUS,
|
.species = SPECIES_GEODUDE,
|
||||||
.heldItem = ITEM_NONE,
|
.heldItem = ITEM_NONE,
|
||||||
.moves = {MOVE_LEAF_TORNADO, MOVE_BODY_SLAM, MOVE_PROTECT, MOVE_ROOST}
|
.moves = {MOVE_TACKLE, MOVE_DEFENSE_CURL, MOVE_ROCK_THROW, MOVE_ROCK_TOMB}
|
||||||
},
|
|
||||||
{
|
|
||||||
.iv = 47,
|
|
||||||
.lvl = 47,
|
|
||||||
.species = SPECIES_HAWLUCHA,
|
|
||||||
.heldItem = ITEM_ORAN_BERRY,
|
|
||||||
.moves = {MOVE_SUPERPOWER, MOVE_ACROBATICS, MOVE_U_TURN, MOVE_ROOST}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.iv = 47,
|
|
||||||
.lvl = 47,
|
|
||||||
.species = SPECIES_MANTINE,
|
|
||||||
.heldItem = ITEM_ORAN_BERRY,
|
|
||||||
.moves = {MOVE_CONFUSE_RAY, MOVE_WATER_PULSE, MOVE_AIR_SLASH, MOVE_ROOST}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.iv = 200,
|
.iv = 200,
|
||||||
.lvl = 48,
|
.lvl = 15,
|
||||||
.species = SPECIES_ALTARIA,
|
.species = SPECIES_NOSEPASS,
|
||||||
.heldItem = ITEM_ORAN_BERRY,
|
.heldItem = ITEM_ORAN_BERRY,
|
||||||
.moves = {MOVE_DRAGON_PULSE, MOVE_TOXIC, MOVE_COTTON_GUARD, MOVE_ROOST}
|
.moves = {MOVE_BLOCK, MOVE_HARDEN, MOVE_TACKLE, MOVE_ROCK_TOMB}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3189,7 +3189,7 @@ const struct Trainer gTrainers[] = {
|
|||||||
.trainerName = _("ROXANNE"),
|
.trainerName = _("ROXANNE"),
|
||||||
.items = {ITEM_POTION, ITEM_POTION, ITEM_NONE, ITEM_NONE},
|
.items = {ITEM_POTION, ITEM_POTION, ITEM_NONE, ITEM_NONE},
|
||||||
.doubleBattle = FALSE,
|
.doubleBattle = FALSE,
|
||||||
.aiFlags = AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_CHECK_VIABILITY | AI_FLAG_RISKY,
|
.aiFlags = AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_CHECK_VIABILITY,
|
||||||
.party = ITEM_CUSTOM_MOVES(sParty_Roxanne1),
|
.party = ITEM_CUSTOM_MOVES(sParty_Roxanne1),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user