Merge branch 'master' of https://github.com/pret/pokeemerald into pretmergeforpsf
This commit is contained in:
commit
cb4e687917
@ -839,11 +839,24 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER
|
||||
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
#define RESTORE_BATTLER_TYPE(battlerId) \
|
||||
{ \
|
||||
gBattleMons[battlerId].type1 = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; \
|
||||
gBattleMons[battlerId].type2 = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; \
|
||||
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
|
||||
=======
|
||||
#define IS_TYPE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY)
|
||||
#define IS_TYPE_SPECIAL(moveType)(moveType > TYPE_MYSTERY)
|
||||
|
||||
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
|
||||
|
||||
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].types[0] == type || gBattleMons[battlerId].types[1] == type))
|
||||
#define SET_BATTLER_TYPE(battlerId, type) \
|
||||
{ \
|
||||
gBattleMons[battlerId].types[0] = type; \
|
||||
gBattleMons[battlerId].types[1] = type; \
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
}
|
||||
|
||||
#define IS_BATTLER_PROTECTED(battlerId)(gProtectStructs[battlerId].protected \
|
||||
|
||||
@ -125,10 +125,14 @@ struct ChooseMoveStruct
|
||||
u8 currentPp[MAX_MON_MOVES];
|
||||
u8 maxPp[MAX_MON_MOVES];
|
||||
u16 species;
|
||||
<<<<<<< HEAD
|
||||
u8 monType1;
|
||||
u8 monType2;
|
||||
u8 monType3;
|
||||
struct ZMoveData zmove;
|
||||
=======
|
||||
u8 monTypes[2];
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
};
|
||||
|
||||
enum
|
||||
|
||||
@ -322,6 +322,7 @@ struct BattlePokemon
|
||||
/*0x17*/ u32 spDefenseIV:5;
|
||||
/*0x17*/ u32 abilityNum:2;
|
||||
/*0x18*/ s8 statStages[NUM_BATTLE_STATS];
|
||||
<<<<<<< HEAD
|
||||
/*0x20*/ u16 ability;
|
||||
/*0x22*/ u8 type1;
|
||||
/*0x23*/ u8 type2;
|
||||
@ -342,6 +343,25 @@ struct BattlePokemon
|
||||
/*0x55*/ u32 otId;
|
||||
/*0x59*/ u8 metLevel;
|
||||
/*0x5A*/ bool8 isShiny;
|
||||
=======
|
||||
/*0x20*/ u8 ability;
|
||||
/*0x21*/ u8 types[2];
|
||||
/*0x23*/ u8 unknown;
|
||||
/*0x24*/ u8 pp[MAX_MON_MOVES];
|
||||
/*0x28*/ u16 hp;
|
||||
/*0x2A*/ u8 level;
|
||||
/*0x2B*/ u8 friendship;
|
||||
/*0x2C*/ u16 maxHP;
|
||||
/*0x2E*/ u16 item;
|
||||
/*0x30*/ u8 nickname[POKEMON_NAME_LENGTH + 1];
|
||||
/*0x3B*/ u8 ppBonuses;
|
||||
/*0x3C*/ u8 otName[PLAYER_NAME_LENGTH + 1];
|
||||
/*0x44*/ u32 experience;
|
||||
/*0x48*/ u32 personality;
|
||||
/*0x4C*/ u32 status1;
|
||||
/*0x50*/ u32 status2;
|
||||
/*0x54*/ u32 otId;
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
};
|
||||
|
||||
struct Evolution
|
||||
|
||||
@ -1233,8 +1233,16 @@ static u32 GetBestMonTypeMatchup(struct Pokemon *party, int firstId, int lastId,
|
||||
{
|
||||
if (!(gBitTable[i] & invalidMons) && !(gBitTable[i] & bits))
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
u16 species = GetMonData(&party[i], MON_DATA_SPECIES);
|
||||
uq4_12_t typeEffectiveness = UQ_4_12(1.0);
|
||||
=======
|
||||
u8 type1 = gSpeciesInfo[species].types[0];
|
||||
u8 type2 = gSpeciesInfo[species].types[1];
|
||||
u8 typeDmg = TYPE_MUL_NORMAL;
|
||||
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[0], type1, type2, &typeDmg);
|
||||
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[1], type1, type2, &typeDmg);
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
u8 atkType1 = gBattleMons[opposingBattler].type1;
|
||||
u8 atkType2 = gBattleMons[opposingBattler].type2;
|
||||
|
||||
@ -606,9 +606,19 @@ static void HandleInputShowEntireFieldTargets(u32 battler)
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
<<<<<<< HEAD
|
||||
HideAllTargets();
|
||||
if (gBattleStruct->gimmick.playerSelect)
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | RET_GIMMICK | (gMultiUsePlayerCursor << 8));
|
||||
=======
|
||||
if (moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE)
|
||||
{
|
||||
if (moveInfo->monTypes[0] != TYPE_GHOST && moveInfo->monTypes[1] != TYPE_GHOST)
|
||||
moveTarget = MOVE_TARGET_USER;
|
||||
else
|
||||
moveTarget = MOVE_TARGET_SELECTED;
|
||||
}
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
else
|
||||
BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, gMoveSelectionCursor[battler] | (gMultiUsePlayerCursor << 8));
|
||||
HideGimmickTriggerSprite();
|
||||
|
||||
@ -262,7 +262,21 @@ u16 ChooseMoveAndTargetInBattlePalace(u32 battler)
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
moveTarget = GetBattlerMoveTargetType(battler, moveInfo->moves[chosenMoveId]);
|
||||
=======
|
||||
if (moveInfo->moves[chosenMoveId] == MOVE_CURSE)
|
||||
{
|
||||
if (moveInfo->monTypes[0] != TYPE_GHOST && moveInfo->monTypes[1] != TYPE_GHOST)
|
||||
moveTarget = MOVE_TARGET_USER;
|
||||
else
|
||||
moveTarget = MOVE_TARGET_SELECTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
moveTarget = gBattleMoves[moveInfo->moves[chosenMoveId]].target;
|
||||
}
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
if (moveTarget & MOVE_TARGET_USER)
|
||||
chosenMoveId |= (battler << 8);
|
||||
|
||||
@ -3368,9 +3368,14 @@ const u8* FaintClearSetData(u32 battler)
|
||||
|
||||
gBattleResources->flags->flags[battler] = 0;
|
||||
|
||||
<<<<<<< HEAD
|
||||
gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
|
||||
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
|
||||
gBattleMons[battler].type3 = TYPE_MYSTERY;
|
||||
=======
|
||||
gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
|
||||
gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
Ai_UpdateFaintData(battler);
|
||||
TryBattleFormChange(battler, FORM_CHANGE_FAINT);
|
||||
@ -3448,12 +3453,29 @@ static void DoBattleIntro(void)
|
||||
case 2: // Start graphical intro slide.
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
battler = GetBattlerAtPosition(0);
|
||||
BtlController_EmitIntroSlide(battler, BUFFER_A, gBattleTerrain);
|
||||
MarkBattlerForControllerExec(battler);
|
||||
gBattleCommunication[0] = 0;
|
||||
gBattleCommunication[1] = 0;
|
||||
(*state)++;
|
||||
=======
|
||||
u16 *hpOnSwitchout;
|
||||
|
||||
ptr = (u8 *)&gBattleMons[gActiveBattler];
|
||||
for (i = 0; i < sizeof(struct BattlePokemon); i++)
|
||||
ptr[i] = gBattleBufferB[gActiveBattler][4 + i];
|
||||
|
||||
gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
|
||||
gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
|
||||
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
|
||||
hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)];
|
||||
*hpOnSwitchout = gBattleMons[gActiveBattler].hp;
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE;
|
||||
gBattleMons[gActiveBattler].status2 = 0;
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
}
|
||||
break;
|
||||
case 3: // Wait for intro slide.
|
||||
@ -4261,11 +4283,17 @@ static void HandleTurnActionSelectionState(void)
|
||||
{
|
||||
struct ChooseMoveStruct moveInfo;
|
||||
|
||||
<<<<<<< HEAD
|
||||
moveInfo.zmove = gBattleStruct->zmove;
|
||||
moveInfo.species = gBattleMons[battler].species;
|
||||
moveInfo.monType1 = gBattleMons[battler].type1;
|
||||
moveInfo.monType2 = gBattleMons[battler].type2;
|
||||
moveInfo.monType3 = gBattleMons[battler].type3;
|
||||
=======
|
||||
moveInfo.species = gBattleMons[gActiveBattler].species;
|
||||
moveInfo.monTypes[0] = gBattleMons[gActiveBattler].types[0];
|
||||
moveInfo.monTypes[1] = gBattleMons[gActiveBattler].types[1];
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
|
||||
@ -2000,6 +2000,7 @@ static void Cmd_adjustdamage(void)
|
||||
}
|
||||
if (GetBattlerAbility(gBattlerTarget) == ABILITY_ICE_FACE && IS_MOVE_PHYSICAL(gCurrentMove) && gBattleMons[gBattlerTarget].species == SPECIES_EISCUE)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
// Damage deals typeless 0 HP.
|
||||
gMoveResultFlags &= ~(MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE);
|
||||
gBattleMoveDamage = 0;
|
||||
@ -2007,12 +2008,312 @@ static void Cmd_adjustdamage(void)
|
||||
gBattleResources->flags->flags[gBattlerTarget] |= RESOURCE_FLAG_ICE_FACE;
|
||||
// Form change will be done after attack animation in Cmd_resultmessage.
|
||||
goto END;
|
||||
=======
|
||||
gLastUsedAbility = gBattleMons[gBattlerTarget].ability;
|
||||
gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE);
|
||||
gLastLandedMoves[gBattlerTarget] = 0;
|
||||
gLastHitByType[gBattlerTarget] = 0;
|
||||
gBattleCommunication[MISS_TYPE] = B_MSG_GROUND_MISS;
|
||||
RecordAbilityBattle(gBattlerTarget, gLastUsedAbility);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0])
|
||||
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
|
||||
// check type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] &&
|
||||
gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1])
|
||||
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
}
|
||||
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
|
||||
goto END;
|
||||
|
||||
<<<<<<< HEAD
|
||||
holdEffect = GetBattlerHoldEffect(gBattlerTarget, TRUE);
|
||||
param = GetBattlerHoldEffectParam(gBattlerTarget);
|
||||
=======
|
||||
if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattlerAttacker, gCurrentMove) == 2
|
||||
&& (!(gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) || ((gMoveResultFlags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)))
|
||||
&& gBattleMoves[gCurrentMove].power)
|
||||
{
|
||||
gLastUsedAbility = ABILITY_WONDER_GUARD;
|
||||
gMoveResultFlags |= MOVE_RESULT_MISSED;
|
||||
gLastLandedMoves[gBattlerTarget] = 0;
|
||||
gLastHitByType[gBattlerTarget] = 0;
|
||||
gBattleCommunication[MISS_TYPE] = B_MSG_AVOIDED_DMG;
|
||||
RecordAbilityBattle(gBattlerTarget, gLastUsedAbility);
|
||||
}
|
||||
if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE)
|
||||
gProtectStructs[gBattlerAttacker].targetNotAffected = 1;
|
||||
|
||||
gBattlescriptCurrInstr++;
|
||||
}
|
||||
|
||||
static void CheckWonderGuardAndLevitate(void)
|
||||
{
|
||||
u8 flags = 0;
|
||||
s32 i = 0;
|
||||
u8 moveType;
|
||||
|
||||
if (gCurrentMove == MOVE_STRUGGLE || !gBattleMoves[gCurrentMove].power)
|
||||
return;
|
||||
|
||||
GET_MOVE_TYPE(gCurrentMove, moveType);
|
||||
|
||||
if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND)
|
||||
{
|
||||
gLastUsedAbility = ABILITY_LEVITATE;
|
||||
gBattleCommunication[MISS_TYPE] = B_MSG_GROUND_MISS;
|
||||
RecordAbilityBattle(gBattlerTarget, ABILITY_LEVITATE);
|
||||
return;
|
||||
}
|
||||
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check no effect
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
gProtectStructs[gBattlerAttacker].targetNotAffected = 1;
|
||||
}
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] &&
|
||||
gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] &&
|
||||
TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
gProtectStructs[gBattlerAttacker].targetNotAffected = 1;
|
||||
}
|
||||
|
||||
// check super effective
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == 20)
|
||||
flags |= 1;
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
|
||||
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
flags |= 1;
|
||||
|
||||
// check not very effective
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == 5)
|
||||
flags |= 2;
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
|
||||
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
flags |= 2;
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
|
||||
if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattlerAttacker, gCurrentMove) == 2)
|
||||
{
|
||||
if (((flags & 2) || !(flags & 1)) && gBattleMoves[gCurrentMove].power)
|
||||
{
|
||||
gLastUsedAbility = ABILITY_WONDER_GUARD;
|
||||
gBattleCommunication[MISS_TYPE] = B_MSG_AVOIDED_DMG;
|
||||
RecordAbilityBattle(gBattlerTarget, ABILITY_WONDER_GUARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Same as ModulateDmgByType except different arguments
|
||||
static void ModulateDmgByType2(u8 multiplier, u16 move, u8 *flags)
|
||||
{
|
||||
gBattleMoveDamage = gBattleMoveDamage * multiplier / 10;
|
||||
if (gBattleMoveDamage == 0 && multiplier != 0)
|
||||
gBattleMoveDamage = 1;
|
||||
|
||||
switch (multiplier)
|
||||
{
|
||||
case TYPE_MUL_NO_EFFECT:
|
||||
*flags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
*flags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE;
|
||||
*flags &= ~MOVE_RESULT_SUPER_EFFECTIVE;
|
||||
break;
|
||||
case TYPE_MUL_NOT_EFFECTIVE:
|
||||
if (gBattleMoves[move].power && !(*flags & MOVE_RESULT_NO_EFFECT))
|
||||
{
|
||||
if (*flags & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
*flags &= ~MOVE_RESULT_SUPER_EFFECTIVE;
|
||||
else
|
||||
*flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE;
|
||||
}
|
||||
break;
|
||||
case TYPE_MUL_SUPER_EFFECTIVE:
|
||||
if (gBattleMoves[move].power && !(*flags & MOVE_RESULT_NO_EFFECT))
|
||||
{
|
||||
if (*flags & MOVE_RESULT_NOT_VERY_EFFECTIVE)
|
||||
*flags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE;
|
||||
else
|
||||
*flags |= MOVE_RESULT_SUPER_EFFECTIVE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u8 TypeCalc(u16 move, u8 attacker, u8 defender)
|
||||
{
|
||||
s32 i = 0;
|
||||
u8 flags = 0;
|
||||
u8 moveType;
|
||||
|
||||
if (move == MOVE_STRUGGLE)
|
||||
return 0;
|
||||
|
||||
moveType = gBattleMoves[move].type;
|
||||
|
||||
// check stab
|
||||
if (IS_BATTLER_OF_TYPE(attacker, moveType))
|
||||
{
|
||||
gBattleMoveDamage = gBattleMoveDamage * 15;
|
||||
gBattleMoveDamage = gBattleMoveDamage / 10;
|
||||
}
|
||||
|
||||
if (gBattleMons[defender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND)
|
||||
{
|
||||
flags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[defender].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[0])
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
// check type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[1] &&
|
||||
gBattleMons[defender].types[0] != gBattleMons[defender].types[1])
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (gBattleMons[defender].ability == ABILITY_WONDER_GUARD && !(flags & MOVE_RESULT_MISSED)
|
||||
&& AttacksThisTurn(attacker, move) == 2
|
||||
&& (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)))
|
||||
&& gBattleMoves[move].power)
|
||||
{
|
||||
flags |= MOVE_RESULT_MISSED;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility)
|
||||
{
|
||||
s32 i = 0;
|
||||
u8 flags = 0;
|
||||
u8 type1 = gSpeciesInfo[targetSpecies].types[0], type2 = gSpeciesInfo[targetSpecies].types[1];
|
||||
u8 moveType;
|
||||
|
||||
if (move == MOVE_STRUGGLE)
|
||||
return 0;
|
||||
|
||||
moveType = gBattleMoves[move].type;
|
||||
|
||||
if (targetAbility == ABILITY_LEVITATE && moveType == TYPE_GROUND)
|
||||
{
|
||||
flags = MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == type1)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
// check type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == type2 && type1 != type2)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
if (targetAbility == ABILITY_WONDER_GUARD
|
||||
&& (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)))
|
||||
&& gBattleMoves[move].power)
|
||||
flags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
return flags;
|
||||
}
|
||||
|
||||
// Multiplies the damage by a random factor between 85% to 100% inclusive
|
||||
static inline void ApplyRandomDmgMultiplier(void)
|
||||
{
|
||||
u16 rand = Random();
|
||||
u16 randPercent = 100 - (rand % 16);
|
||||
|
||||
if (gBattleMoveDamage != 0)
|
||||
{
|
||||
gBattleMoveDamage *= randPercent;
|
||||
gBattleMoveDamage /= 100;
|
||||
if (gBattleMoveDamage == 0)
|
||||
gBattleMoveDamage = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void UNUSED Unused_ApplyRandomDmgMultiplier(void)
|
||||
{
|
||||
ApplyRandomDmgMultiplier();
|
||||
}
|
||||
|
||||
static void Cmd_adjustnormaldamage(void)
|
||||
{
|
||||
u8 holdEffect, param;
|
||||
|
||||
ApplyRandomDmgMultiplier();
|
||||
|
||||
if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect;
|
||||
param = gEnigmaBerries[gBattlerTarget].holdEffectParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item);
|
||||
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
|
||||
}
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
gPotentialItemEffectBattler = gBattlerTarget;
|
||||
|
||||
@ -5066,11 +5367,18 @@ static void Cmd_setroost(void)
|
||||
{
|
||||
CMD_ARGS();
|
||||
|
||||
<<<<<<< HEAD
|
||||
gBattleResources->flags->flags[gBattlerAttacker] |= RESOURCE_FLAG_ROOST;
|
||||
gBattleStruct->roostTypes[gBattlerAttacker][0] = gBattleMons[gBattlerAttacker].type1;
|
||||
gBattleStruct->roostTypes[gBattlerAttacker][1] = gBattleMons[gBattlerAttacker].type2;
|
||||
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
=======
|
||||
if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[0] || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[1])
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
else
|
||||
gBattlescriptCurrInstr += 7;
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
}
|
||||
|
||||
static void Cmd_jumpifabilitypresent(void)
|
||||
@ -6433,9 +6741,71 @@ static void Cmd_sethealblock(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
gStatuses3[gBattlerTarget] |= STATUS3_HEAL_BLOCK;
|
||||
gDisableStructs[gBattlerTarget].healBlockTimer = 5;
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
=======
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0])
|
||||
{
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
break;
|
||||
}
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE;
|
||||
}
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVE_RESULT_SUPER_EFFECTIVE;
|
||||
}
|
||||
}
|
||||
// check type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1])
|
||||
{
|
||||
if (gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
|
||||
break;
|
||||
}
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
|
||||
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE;
|
||||
}
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
|
||||
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVE_RESULT_SUPER_EFFECTIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
}
|
||||
}
|
||||
|
||||
@ -6485,8 +6855,18 @@ static void Cmd_switchindataupdate(void)
|
||||
for (i = 0; i < sizeof(struct BattlePokemon); i++)
|
||||
monData[i] = gBattleResources->bufferB[battler][4 + i];
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Edge case: the sent out pokemon has 0 HP. This should never happen.
|
||||
if (!IsBattlerAlive(battler))
|
||||
=======
|
||||
gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
|
||||
gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
|
||||
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
|
||||
|
||||
// check knocked off item
|
||||
i = GetBattlerSide(gActiveBattler);
|
||||
if (gWishFutureKnock.knockedOffMons[i] & gBitTable[gBattlerPartyIndexes[gActiveBattler]])
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
{
|
||||
// If it's a test, mark it as invalid.
|
||||
if (gTestRunnerEnabled)
|
||||
@ -12197,7 +12577,12 @@ static void Cmd_tryconversiontypechange(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
if (IS_BATTLER_OF_TYPE(gBattlerAttacker, moveType))
|
||||
=======
|
||||
if (moveType != gBattleMons[gBattlerAttacker].types[0]
|
||||
&& moveType != gBattleMons[gBattlerAttacker].types[1])
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
{
|
||||
gBattlescriptCurrInstr = cmd->failInstr;
|
||||
}
|
||||
@ -12237,6 +12622,10 @@ static void Cmd_tryconversiontypechange(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
while (moveType == gBattleMons[gBattlerAttacker].types[0] || moveType == gBattleMons[gBattlerAttacker].types[1]);
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
if (moveChecked == validMoves)
|
||||
{
|
||||
@ -12426,6 +12815,57 @@ static void Cmd_unused_95(void)
|
||||
|
||||
static void Cmd_unused_96(void)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if (WEATHER_HAS_EFFECT)
|
||||
{
|
||||
if (gBattleWeather & B_WEATHER_SANDSTORM)
|
||||
{
|
||||
if (gBattleMons[gBattlerAttacker].types[0] != TYPE_ROCK
|
||||
&& gBattleMons[gBattlerAttacker].types[0] != TYPE_STEEL
|
||||
&& gBattleMons[gBattlerAttacker].types[0] != TYPE_GROUND
|
||||
&& gBattleMons[gBattlerAttacker].types[1] != TYPE_ROCK
|
||||
&& gBattleMons[gBattlerAttacker].types[1] != TYPE_STEEL
|
||||
&& gBattleMons[gBattlerAttacker].types[1] != TYPE_GROUND
|
||||
&& gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL
|
||||
&& !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND)
|
||||
&& !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER))
|
||||
{
|
||||
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16;
|
||||
if (gBattleMoveDamage == 0)
|
||||
gBattleMoveDamage = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMoveDamage = 0;
|
||||
}
|
||||
}
|
||||
if (gBattleWeather & B_WEATHER_HAIL)
|
||||
{
|
||||
if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE)
|
||||
&& !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND)
|
||||
&& !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER))
|
||||
{
|
||||
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16;
|
||||
if (gBattleMoveDamage == 0)
|
||||
gBattleMoveDamage = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMoveDamage = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gBattleMoveDamage = 0;
|
||||
}
|
||||
|
||||
if (gAbsentBattlerFlags & gBitTable[gBattlerAttacker])
|
||||
gBattleMoveDamage = 0;
|
||||
|
||||
gBattlescriptCurrInstr++;
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
}
|
||||
|
||||
static void Cmd_tryinfatuating(void)
|
||||
|
||||
@ -3659,6 +3659,7 @@ void PokemonToBattleMon(struct Pokemon *src, struct BattlePokemon *dst)
|
||||
dst->pp[i] = GetMonData(src, MON_DATA_PP1 + i, NULL);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
dst->species = GetMonData(src, MON_DATA_SPECIES, NULL);
|
||||
dst->item = GetMonData(src, MON_DATA_HELD_ITEM, NULL);
|
||||
dst->ppBonuses = GetMonData(src, MON_DATA_PP_BONUSES, NULL);
|
||||
@ -3690,6 +3691,39 @@ void PokemonToBattleMon(struct Pokemon *src, struct BattlePokemon *dst)
|
||||
GetMonData(src, MON_DATA_NICKNAME, nickname);
|
||||
StringCopy_Nickname(dst->nickname, nickname);
|
||||
GetMonData(src, MON_DATA_OT_NAME, dst->otName);
|
||||
=======
|
||||
gBattleMons[battlerId].ppBonuses = GetMonData(&gPlayerParty[partyIndex], MON_DATA_PP_BONUSES, NULL);
|
||||
gBattleMons[battlerId].friendship = GetMonData(&gPlayerParty[partyIndex], MON_DATA_FRIENDSHIP, NULL);
|
||||
gBattleMons[battlerId].experience = GetMonData(&gPlayerParty[partyIndex], MON_DATA_EXP, NULL);
|
||||
gBattleMons[battlerId].hpIV = GetMonData(&gPlayerParty[partyIndex], MON_DATA_HP_IV, NULL);
|
||||
gBattleMons[battlerId].attackIV = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ATK_IV, NULL);
|
||||
gBattleMons[battlerId].defenseIV = GetMonData(&gPlayerParty[partyIndex], MON_DATA_DEF_IV, NULL);
|
||||
gBattleMons[battlerId].speedIV = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPEED_IV, NULL);
|
||||
gBattleMons[battlerId].spAttackIV = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPATK_IV, NULL);
|
||||
gBattleMons[battlerId].spDefenseIV = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPDEF_IV, NULL);
|
||||
gBattleMons[battlerId].personality = GetMonData(&gPlayerParty[partyIndex], MON_DATA_PERSONALITY, NULL);
|
||||
gBattleMons[battlerId].status1 = GetMonData(&gPlayerParty[partyIndex], MON_DATA_STATUS, NULL);
|
||||
gBattleMons[battlerId].level = GetMonData(&gPlayerParty[partyIndex], MON_DATA_LEVEL, NULL);
|
||||
gBattleMons[battlerId].hp = GetMonData(&gPlayerParty[partyIndex], MON_DATA_HP, NULL);
|
||||
gBattleMons[battlerId].maxHP = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MAX_HP, NULL);
|
||||
gBattleMons[battlerId].attack = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ATK, NULL);
|
||||
gBattleMons[battlerId].defense = GetMonData(&gPlayerParty[partyIndex], MON_DATA_DEF, NULL);
|
||||
gBattleMons[battlerId].speed = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPEED, NULL);
|
||||
gBattleMons[battlerId].spAttack = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPATK, NULL);
|
||||
gBattleMons[battlerId].spDefense = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPDEF, NULL);
|
||||
gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL);
|
||||
gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL);
|
||||
gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL);
|
||||
gBattleMons[battlerId].types[0] = gSpeciesInfo[gBattleMons[battlerId].species].types[0];
|
||||
gBattleMons[battlerId].types[1] = gSpeciesInfo[gBattleMons[battlerId].species].types[1];
|
||||
gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum);
|
||||
GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname);
|
||||
StringCopy_Nickname(gBattleMons[battlerId].nickname, nickname);
|
||||
GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_NAME, gBattleMons[battlerId].otName);
|
||||
|
||||
hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(battlerId)];
|
||||
*hpSwitchout = gBattleMons[battlerId].hp;
|
||||
>>>>>>> 312749dd3109e607779bb1a15f3669ea2b0979dc
|
||||
|
||||
for (i = 0; i < NUM_BATTLE_STATS; i++)
|
||||
dst->statStages[i] = DEFAULT_STAT_STAGE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user