LowerOffensiveStat

This commit is contained in:
DizzyEggg 2025-10-31 11:26:30 +01:00
parent 40ed4086e7
commit 0e9c298e88
11 changed files with 46 additions and 45 deletions

View File

@ -41,7 +41,7 @@ void CheckRunAwayVisualFlag(Entity *pokemon, bool8 showRunAwayEffect);
u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified);
u8 GetTreatmentBetweenMonstersIgnoreStatus(Entity * pokemon, Entity * target);
bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage);
bool8 sub_8071728(Entity * pokemon, Entity * target, bool8 displayMessage);
bool8 IsProtectedFromStatDrops(Entity * pokemon, Entity * target, bool8 displayMessage);
bool8 sub_80717A4(Entity *pokemon, u16 moveID);
bool8 AbilityIsActive(Entity *pokemon, u8 ability);
bool8 MonsterIsType(Entity *pokemon, u8 type);

View File

@ -28,8 +28,8 @@ void IngrainedStatusTarget(Entity * pokemon, Entity * target);
void WrapTarget(Entity * pokemon, Entity * target);
void sub_8076CB4(s32 param_1);
void PetrifiedStatusTarget(Entity * pokemon, Entity * target);
void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 decrement, u8 param_5, bool8 displayMessage);
void LowerDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected);
void LowerOffensiveStat(Entity * pokemon, Entity * target, struct StatIndex stat, s32 decrement, u8 param_5, bool8 displayMessage);
void LowerDefensiveStat(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected);
void RaiseAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 increment);
void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 increment);
u8 GetFlashFireStatus(Entity *pokemon);

View File

@ -941,8 +941,8 @@ static void GrimyFoodItemAction(Entity *pokemon, Entity * target)
ParalyzeStatusTarget(pokemon, target, TRUE);
break;
case 4:
LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 3, 1, TRUE);
LowerAttackStageTarget(pokemon, target, gStatIndexSpecial, 3, 1, TRUE);
LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 3, TRUE, TRUE);
LowerOffensiveStat(pokemon, target, gStatIndexSpecial, 3, TRUE, TRUE);
break;
}
}

View File

@ -1213,7 +1213,7 @@ bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage
return FALSE;
}
bool8 sub_8071728(Entity * pokemon, Entity * target, bool8 displayMessage)
bool8 IsProtectedFromStatDrops(Entity * pokemon, Entity * target, bool8 displayMessage)
{
if (GetEntInfo(target)->reflectClassStatus.status == STATUS_MIST) {
if (displayMessage) {

View File

@ -1321,7 +1321,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move,
}
if (EntityIsValid(attacker) && GetEntInfo(attacker)->unk155 != 0) {
GetEntInfo(attacker)->unk155 = 0;
LowerAttackStageTarget(attacker, attacker, gStatIndexSpecial, 2, 0, FALSE);
LowerOffensiveStat(attacker, attacker, gStatIndexSpecial, 2, 0, FALSE);
}
}
}

View File

@ -49,7 +49,7 @@ bool8 IronTailMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId
if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) {
flag = TRUE;
if (sub_805727C(pokemon, target, gIronTailSecondaryChance)) {
LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE);
LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE);
}
}
return flag;
@ -372,7 +372,7 @@ bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 it
bool8 FakeTearsMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId)
{
LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 2, 1, TRUE);
LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 2, 1, TRUE);
return TRUE;
}
@ -680,7 +680,7 @@ bool8 ShadowBallMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item
flag = TRUE;
if(sub_805727C(pokemon, target, gShadowBallSecondaryChance))
{
LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 1, 1, FALSE);
LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 1, 1, FALSE);
}
}
return flag;
@ -877,14 +877,14 @@ bool8 SmellingSaltMoveAction(Entity * pokemon, Entity * target, Move * move, s32
bool8 MetalSoundMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
{
LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 3, 1, TRUE);
LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 3, 1, TRUE);
return TRUE;
}
bool8 TickleMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
{
LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
return TRUE;
}

View File

@ -149,7 +149,7 @@ bool8 DamageLowerDefMoveAction(Entity *pokemon, Entity *target, Move *move, stru
flag = TRUE;
if(sub_805727C(pokemon, target, gPsychicSecondaryChance))
{
LowerDefenseStageTarget(pokemon, target, stat, 1, 1, FALSE);
LowerDefensiveStat(pokemon, target, stat, 1, 1, FALSE);
}
}
return flag;
@ -163,7 +163,7 @@ bool8 PsychoBoostMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite
flag = TRUE;
if(RollSecondaryEffect(pokemon, 0))
{
LowerAttackStageTarget(pokemon, pokemon, gStatIndexSpecial, 2, 0, FALSE);
LowerOffensiveStat(pokemon, pokemon, gStatIndexSpecial, 2, 0, FALSE);
}
}
return flag;

View File

@ -279,7 +279,7 @@ bool8 AmnesiaMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
bool8 GrowlMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
{
LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
return TRUE;
}
@ -336,7 +336,7 @@ bool8 SunnyDayMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId
bool8 LeerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
{
LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE);
return TRUE;
}
@ -443,8 +443,8 @@ bool8 SuperpowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item
if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) {
flag = TRUE;
if (sub_805727C(pokemon,pokemon,0) != 0) {
LowerAttackStageTarget(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE);
LowerDefenseStageTarget(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE);
LowerOffensiveStat(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE);
LowerDefensiveStat(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE);
}
}
return flag;
@ -709,10 +709,10 @@ bool8 SecretPowerMoveAction(Entity * pokemon, Entity * target, Move *move, s32 i
LowerMovementSpeedTarget(pokemon,target,1,FALSE);
break;
case 3:
LowerAttackStageTarget(pokemon,target,gStatIndexAtkDef,1,1,FALSE);
LowerOffensiveStat(pokemon,target,gStatIndexAtkDef,1,1,FALSE);
break;
case 4:
LowerDefenseStageTarget(pokemon,target,gStatIndexAtkDef,1,1,FALSE);
LowerDefensiveStat(pokemon,target,gStatIndexAtkDef,1,1,FALSE);
break;
case 5:
LowerAccuracyStageTarget(pokemon,target,gStatIndexAtkDef,FALSE);
@ -762,7 +762,7 @@ bool8 ObserverOrbAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
bool8 FeatherDanceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId)
{
LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 2, 1, TRUE);
LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 2, 1, TRUE);
return TRUE;
}
@ -821,7 +821,7 @@ bool8 CrushClawMoveAction(Entity * pokemon, Entity * target, Move *move, s32 ite
if ( HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) {
flag = TRUE;
if (sub_805727C(pokemon,target,gCrushClawSecondaryChance) != 0) {
LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE);
LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE);
}
}
return flag;

View File

@ -77,7 +77,7 @@ bool8 MistBallMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId
if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) {
flag = TRUE;
if (sub_805727C(pokemon,target,gMistBallSecondaryChance) != 0) {
LowerAttackStageTarget(pokemon,target,gStatIndexSpecial,1,1,0);
LowerOffensiveStat(pokemon,target,gStatIndexSpecial,1,1,0);
}
}
return flag;
@ -334,7 +334,7 @@ bool8 LusterPurgeMoveAction(Entity * pokemon, Entity * target, Move * move, s32
flag = TRUE;
if(sub_805727C(pokemon, target, gLusterPurgeSecondaryChance))
{
LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 1, 1, 0);
LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 1, 1, 0);
}
}
return flag;

View File

@ -851,10 +851,10 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target)
}
}
void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 decrement, u8 param_5, bool8 displayMessage)
void LowerOffensiveStat(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, u8 checkProtected, bool8 logMsgProtected)
{
EntityInfo *entityInfo;
s32 attackStage = decrement;
s32 newStage;
if (!EntityIsValid(target))
return;
@ -866,8 +866,8 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex
strcpy(gFormatBuffer_Items[0], gUnknown_80FC0B8);
}
if (param_5) {
if (sub_8071728(pokemon,target,displayMessage))
if (checkProtected) {
if (IsProtectedFromStatDrops(pokemon,target,logMsgProtected))
return;
if (HasHeldItem(target, ITEM_TWIST_BAND)) {
@ -886,20 +886,21 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex
entityInfo = GetEntInfo(target);
SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0);
sub_8041F28(target,stat);
if (decrement == 1) {
if (nStages == 1) {
strcpy(gFormatBuffer_Items[1], gUnknown_80FC0E4);
}
else {
strcpy(gFormatBuffer_Items[1], gUnknown_80FC0D4);
}
attackStage = entityInfo->offensiveStages[stat.id];
attackStage -= decrement;
if (attackStage < 0) {
attackStage = 0;
newStage = entityInfo->offensiveStages[stat.id];
newStage -= nStages;
if (newStage < 0) {
newStage = 0;
}
if (entityInfo->offensiveStages[stat.id] != attackStage) {
entityInfo->offensiveStages[stat.id] = attackStage;
if (entityInfo->offensiveStages[stat.id] != newStage) {
entityInfo->offensiveStages[stat.id] = newStage;
TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC15C);
}
else {
@ -909,7 +910,7 @@ void LowerAttackStageTarget(Entity * pokemon, Entity * target, struct StatIndex
EntityUpdateStatusSprites(target);
}
void LowerDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected)
void LowerDefensiveStat(Entity * pokemon, Entity * target, struct StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected)
{
EntityInfo *entityInfo;
s32 newStage;
@ -925,7 +926,7 @@ void LowerDefenseStageTarget(Entity * pokemon, Entity * target, struct StatIndex
}
if (checkProtected) {
if (sub_8071728(pokemon,target,logMsgProtected))
if (IsProtectedFromStatDrops(pokemon,target,logMsgProtected))
return;
}
@ -1083,7 +1084,7 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, struct StatIn
else {
strcpy(gFormatBuffer_Items[0],gUnknown_80FC0B8);
}
if (F248LessThanInt(param_4, 1) && sub_8071728(pokemon,target,displayMessage)) {
if (F248LessThanInt(param_4, 1) && IsProtectedFromStatDrops(pokemon,target,displayMessage)) {
return;
}
@ -1148,7 +1149,7 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, struct StatI
else {
strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C);
}
if (F248LessThanInt(param_4, 1) && sub_8071728(pokemon,target,displayMessage)) {
if (F248LessThanInt(param_4, 1) && IsProtectedFromStatDrops(pokemon,target,displayMessage)) {
return;
}
@ -1220,7 +1221,7 @@ void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, struct StatInde
else {
strcpy(gFormatBuffer_Items[0],gUnknown_80FC084);
}
if (!sub_8071728(pokemon,target,displayMessage)) {
if (!IsProtectedFromStatDrops(pokemon,target,displayMessage)) {
if (AbilityIsActive(target, ABILITY_KEEN_EYE) && (stat.id == STAT_INDEX_ACCURACY)){
if(displayMessage)
{

View File

@ -410,16 +410,16 @@ void HandleMudTrap(Entity *pokemon, Entity *target)
rand = DungeonRandInt(100);
randDef = rand;
if (rand < 25) {
LowerAttackStageTarget(pokemon,target,gStatIndexAtkDef,1,1,1);
LowerOffensiveStat(pokemon,target,gStatIndexAtkDef,1,1,1);
}
else if (rand < 50) {
LowerAttackStageTarget(pokemon,target,gStatIndexSpecial,1,1,1);
LowerOffensiveStat(pokemon,target,gStatIndexSpecial,1,1,1);
}
else if (randDef < 75) {
LowerDefenseStageTarget(pokemon,target,gStatIndexAtkDef,1,1,1);
LowerDefensiveStat(pokemon,target,gStatIndexAtkDef,1,1,1);
}
else {
LowerDefenseStageTarget(pokemon,target,gStatIndexSpecial,1,1,1);
LowerDefensiveStat(pokemon,target,gStatIndexSpecial,1,1,1);
}
}