mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 20:24:18 +01:00
fix terrain seeds. create generic CompareStat function
This commit is contained in:
parent
7f4accdae4
commit
93e2e09148
@ -7755,12 +7755,13 @@ BattleScript_BerryStatRaiseEnd2::
|
||||
BattleScript_BerryStatRaiseEnd2_AbilityPopup:
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_BerryStatRaiseEnd2_Anim:
|
||||
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseDoStatUp
|
||||
BattleScript_BerryStatRaiseDoStatUp::
|
||||
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseEnd2_End
|
||||
setgraphicalstatchangevalues
|
||||
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1
|
||||
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM
|
||||
call BattleScript_StatUp
|
||||
removeitem BS_ATTACKER
|
||||
BattleScript_BerryStatRaiseEnd2_End::
|
||||
end2
|
||||
|
||||
BattleScript_BerryStatRaiseRet::
|
||||
@ -7769,12 +7770,13 @@ BattleScript_BerryStatRaiseRet::
|
||||
BattleScript_BerryStatRaiseRet_AbilityPopup:
|
||||
call BattleScript_AbilityPopUp
|
||||
BattleScript_BerryStatRaiseRet_Anim:
|
||||
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
|
||||
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End
|
||||
BattleScript_BerryStatRaiseRet_End:
|
||||
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End
|
||||
setgraphicalstatchangevalues
|
||||
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1
|
||||
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM
|
||||
call BattleScript_StatUp
|
||||
removeitem BS_SCRIPTING
|
||||
BattleScript_BerryStatRaiseRet_End:
|
||||
return
|
||||
|
||||
BattleScript_BerryFocusEnergyEnd2::
|
||||
|
@ -148,6 +148,7 @@ bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
|
||||
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
|
||||
bool32 IsBattlerAffectedByHazards(u8 battlerId, bool32 toxicSpikes);
|
||||
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
|
||||
bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind, bool32 checkContrary);
|
||||
|
||||
// ability checks
|
||||
bool32 IsRolePlayBannedAbilityAtk(u16 ability);
|
||||
|
@ -3583,52 +3583,11 @@ static void Cmd_jumpifstat(void)
|
||||
{
|
||||
bool32 ret = 0;
|
||||
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
|
||||
u8 statValue = gBattleMons[battlerId].statStages[gBattlescriptCurrInstr[3]];
|
||||
u8 statId = gBattlescriptCurrInstr[3];
|
||||
u8 cmpTo = gBattlescriptCurrInstr[4];
|
||||
u8 cmpKind = gBattlescriptCurrInstr[2];
|
||||
|
||||
// Because this command is used as a way of checking if a stat can be lowered/raised,
|
||||
// we need to do some modification at run-time.
|
||||
if (GetBattlerAbility(battlerId) == ABILITY_CONTRARY)
|
||||
{
|
||||
if (cmpKind == CMP_GREATER_THAN)
|
||||
cmpKind = CMP_LESS_THAN;
|
||||
else if (cmpKind == CMP_LESS_THAN)
|
||||
cmpKind = CMP_GREATER_THAN;
|
||||
|
||||
if (cmpTo == 0)
|
||||
cmpTo = 0xC;
|
||||
else if (cmpTo == 0xC)
|
||||
cmpTo = 0;
|
||||
}
|
||||
|
||||
switch (cmpKind)
|
||||
{
|
||||
case CMP_EQUAL:
|
||||
if (statValue == cmpTo)
|
||||
ret++;
|
||||
break;
|
||||
case CMP_NOT_EQUAL:
|
||||
if (statValue != cmpTo)
|
||||
ret++;
|
||||
break;
|
||||
case CMP_GREATER_THAN:
|
||||
if (statValue > cmpTo)
|
||||
ret++;
|
||||
break;
|
||||
case CMP_LESS_THAN:
|
||||
if (statValue < cmpTo)
|
||||
ret++;
|
||||
break;
|
||||
case CMP_COMMON_BITS:
|
||||
if (statValue & cmpTo)
|
||||
ret++;
|
||||
break;
|
||||
case CMP_NO_COMMON_BITS:
|
||||
if (!(statValue & cmpTo))
|
||||
ret++;
|
||||
break;
|
||||
}
|
||||
ret = CompareStat(battlerId, statId, cmpTo, cmpKind, TRUE);
|
||||
|
||||
if (ret)
|
||||
gBattlescriptCurrInstr = T2_READ_PTR(gBattlescriptCurrInstr + 5);
|
||||
@ -9279,13 +9238,17 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
index++;
|
||||
gBattleTextBuff2[index] = B_BUFF_EOS;
|
||||
|
||||
gSpecialStatuses[gActiveBattler].statFell = TRUE; // For eject pack
|
||||
if (gBattleMons[gActiveBattler].statStages[statId] == MIN_STAT_STAGE)
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STAT_WONT_DECREASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSpecialStatuses[gActiveBattler].statFell = TRUE; // For eject pack
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL
|
||||
}
|
||||
}
|
||||
}
|
||||
else // stat increase
|
||||
{
|
||||
statValue = GET_STAT_BUFF_VALUE(statValue);
|
||||
|
@ -5569,7 +5569,7 @@ static u8 DamagedStatBoostBerryEffect(u8 battlerId, u8 statId, u8 split)
|
||||
|
||||
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute)
|
||||
{
|
||||
if (gFieldStatuses & terrainFlag && gBattleMons[battler].statStages[statId] < MAX_STAT_STAGE)
|
||||
if (gFieldStatuses & terrainFlag && CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN, TRUE))
|
||||
{
|
||||
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
|
||||
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
|
||||
@ -5826,7 +5826,6 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
RecordItemEffectBattle(battlerId, HOLD_EFFECT_AIR_BALLOON);
|
||||
break;
|
||||
case HOLD_EFFECT_ROOM_SERVICE:
|
||||
|
||||
if (gFieldStatuses & STATUS_FIELD_TRICK_ROOM && gBattleMons[battlerId].statStages[STAT_SPEED] > MIN_STAT_STAGE)
|
||||
{
|
||||
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPEED);
|
||||
@ -8944,3 +8943,55 @@ bool32 TestSheerForceFlag(u8 battler, u16 move)
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// This function is the body of "jumpifstat", but can be used dynamically in a function
|
||||
bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind, bool32 checkContrary)
|
||||
{
|
||||
bool8 ret = FALSE;
|
||||
u8 statValue = gBattleMons[battlerId].statStages[statId];
|
||||
|
||||
// Because this command is used as a way of checking if a stat can be lowered/raised,
|
||||
// we need to do some modification at run-time.
|
||||
if (checkContrary && GetBattlerAbility(battlerId) == ABILITY_CONTRARY)
|
||||
{
|
||||
if (cmpKind == CMP_GREATER_THAN)
|
||||
cmpKind = CMP_LESS_THAN;
|
||||
else if (cmpKind == CMP_LESS_THAN)
|
||||
cmpKind = CMP_GREATER_THAN;
|
||||
|
||||
if (cmpTo == MIN_STAT_STAGE)
|
||||
cmpTo = MAX_STAT_STAGE;
|
||||
else if (cmpTo == MAX_STAT_STAGE)
|
||||
cmpTo = MIN_STAT_STAGE;
|
||||
}
|
||||
|
||||
switch (cmpKind)
|
||||
{
|
||||
case CMP_EQUAL:
|
||||
if (statValue == cmpTo)
|
||||
ret = TRUE;
|
||||
break;
|
||||
case CMP_NOT_EQUAL:
|
||||
if (statValue != cmpTo)
|
||||
ret = TRUE;
|
||||
break;
|
||||
case CMP_GREATER_THAN:
|
||||
if (statValue > cmpTo)
|
||||
ret = TRUE;
|
||||
break;
|
||||
case CMP_LESS_THAN:
|
||||
if (statValue < cmpTo)
|
||||
ret = TRUE;
|
||||
break;
|
||||
case CMP_COMMON_BITS:
|
||||
if (statValue & cmpTo)
|
||||
ret = TRUE;
|
||||
break;
|
||||
case CMP_NO_COMMON_BITS:
|
||||
if (!(statValue & cmpTo))
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user