diff --git a/include/dungeon_logic.h b/include/dungeon_logic.h index 9571782df..396f14615 100644 --- a/include/dungeon_logic.h +++ b/include/dungeon_logic.h @@ -39,7 +39,7 @@ bool8 ShouldMonsterRunAway(Entity *pokemon); bool8 ShouldMonsterRunAwayAndShowEffect(Entity *pokemon, bool8 showRunAwayEffect); void CheckRunAwayVisualFlag(Entity *pokemon, bool8 showRunAwayEffect); u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified); -u8 sub_807167C(Entity * pokemon, Entity * target); +u8 GetTreatmentBetweenMonstersIgnoreStatus(Entity * pokemon, Entity * target); bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage); bool8 sub_8071728(Entity * pokemon, Entity * target, bool8 displayMessage); bool8 sub_80717A4(Entity *pokemon, u16 moveID); diff --git a/src/blow_away.c b/src/blow_away.c index 3889f3e87..0953c8476 100644 --- a/src/blow_away.c +++ b/src/blow_away.c @@ -39,113 +39,109 @@ extern void sub_807BB78(Entity *pokemon); void BlowAwayTarget(Entity *pokemon, Entity *target, u32 direction) { - const Tile *tile; - int iVar8; bool8 flag; - DungeonPos pos; - Move move; - int counter; + s32 counter; Entity *entity; - PixelPos pos32; counter = 10; if (IsCurrentFixedRoomBossFight()) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC9E8); // It couldn't be knocked flying! return; } - else - { - if (pokemon == target) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA10); // {POKEMON_0} couldn't be knocked flying! - return; - } + + if (pokemon == target) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - if (AbilityIsActive(target,ABILITY_SUCTION_CUPS)) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCBCC); // {POKEMON_0} is anchored! It can't be knocked flying! - return; + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA10); // {POKEMON_0} couldn't be knocked flying! + return; + } + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + if (AbilityIsActive(target,ABILITY_SUCTION_CUPS)) { + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCBCC); // {POKEMON_0} is anchored! It can't be knocked flying! + return; + } + + GetEntInfo(target)->action.direction = (direction + 4) & DIRECTION_MASK; + sub_806CDD4(target, 6, (direction + 4) & DIRECTION_MASK); + sub_80421C0(target,0x1a3); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80F8A0C); // {POKEMON_0} was blown away! + flag = TRUE; + entity = NULL; + + while (TRUE) { + s32 i; + const Tile *tile; + PixelPos pos32; + DungeonPos pos = target->pos; + + pos.x += gAdjacentTileOffsets[direction].x; + pos.y += gAdjacentTileOffsets[direction].y; + if (pos.x < 0 || pos.y < 0 || DUNGEON_MAX_SIZE_X <= pos.x || DUNGEON_MAX_SIZE_Y <= pos.y) { + break; } - else - { - (GetEntInfo(target)->action).direction = (direction + 4) & DIRECTION_MASK; - sub_806CDD4(target, 6, (direction + 4) & DIRECTION_MASK); - sub_80421C0(target,0x1a3); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80F8A0C); // {POKEMON_0} was blown away! + + pos32.x = gAdjacentTileOffsets[direction].x << 0xA; + pos32.y = gAdjacentTileOffsets[direction].y << 0xA; + + for (i = 0; i < 6; i++) { + IncreaseEntityPixelPos(target,pos32.x,pos32.y); + if (ShouldDisplayEntity(target) != 0) { + DungeonRunFrameActions(0x19); + } + } + tile = GetTile(pos.x, pos.y); + if (tile->monster != NULL) { + entity = tile->monster; + flag = FALSE; + break; + } + if (sub_80705F0(target,&pos)){ + flag = GetTerrainType(tile) != TERRAIN_TYPE_WALL; + break; + } + sub_80694C0(target,pos.x,pos.y,1); + if (--counter <= 0) { flag = TRUE; - entity = NULL; - - for(; counter > 0; counter--) - { - pos = target->pos; - pos.x += gAdjacentTileOffsets[direction].x; - pos.y += gAdjacentTileOffsets[direction].y; - if ((((pos.x < 0) || (pos.y < 0)) || (DUNGEON_MAX_SIZE_X <= pos.x)) || - (DUNGEON_MAX_SIZE_Y <= pos.y)) goto _0807CF20; - pos32.x = gAdjacentTileOffsets[direction].x << 0xA; - pos32.y = gAdjacentTileOffsets[direction].y << 0xA; - - for(iVar8 = 0; iVar8 < 6; iVar8++) - { - IncreaseEntityPixelPos(target,pos32.x,pos32.y); - if (ShouldDisplayEntity(target) != 0) { - DungeonRunFrameActions(0x19); - } - } - tile = GetTile(pos.x, pos.y); - if (tile->monster != NULL) { - entity = tile->monster; - goto _0807CF26; - } - if (sub_80705F0(target,&pos)){ - flag = (GetTerrainType(tile) != TERRAIN_TYPE_WALL); - goto _0807CF20; - } - sub_80694C0(target,pos.x,pos.y,1); - } - - - flag = TRUE; - _0807CF20: - if (!flag) { - _0807CF26: - - sub_807D068(target,&target->pos); - sub_806F370(pokemon,target,gBlowAwayDmgValue,0,0,0,DUNGEON_EXIT_FAINTED_FROM_BEING_KNOCKED,RESIDUAL_DAMAGE_REGULAR,0,0); - } - if (IsFloorOver()) { - return; - } - if (entity != NULL) { - InitPokemonMove(&move,0x163); - if (!sub_80571F0(entity,&move)) { - TrySendImmobilizeSleepEndMsg(pokemon,entity); - sub_806F370(pokemon,entity,gBlowAwayDmgValue,0,0,0,DUNGEON_EXIT_FELLED_BY_POKEMON_FLYING,RESIDUAL_DAMAGE_REGULAR,0,0); - } - } - if (IsFloorOver()) { - return; - } - if (!EntityIsValid(target)) { - return; - } - sub_806A5B8(target); - if (sub_80706A4(target,&target->pos)) { - WarpTarget(target,target,0,0); - } - if (!EntityIsValid(target)) { - return; - } - sub_806CE68(target,8); - if (GetEntInfo(target)->isTeamLeader) { - gDungeon->unk1 = 0; - gDungeon->unk5C0 = -1; - DiscoverMinimap(&target->pos); - sub_807EC28(FALSE); - } - sub_806A5B8(target); - TryTriggerMonsterHouseWithMsg(target,gDungeon->forceMonsterHouse); + break; } } + + if (!flag) { + sub_807D068(target,&target->pos); + sub_806F370(pokemon,target,gBlowAwayDmgValue,0,0,0,DUNGEON_EXIT_FAINTED_FROM_BEING_KNOCKED,RESIDUAL_DAMAGE_REGULAR,0,0); + } + if (IsFloorOver()) { + return; + } + if (entity != NULL) { + Move move; + + InitPokemonMove(&move, MOVE_REGULAR_ATTACK); + if (!sub_80571F0(entity,&move)) { + TrySendImmobilizeSleepEndMsg(pokemon,entity); + sub_806F370(pokemon,entity,gBlowAwayDmgValue,0,0,0,DUNGEON_EXIT_FELLED_BY_POKEMON_FLYING,RESIDUAL_DAMAGE_REGULAR,0,0); + } + } + if (IsFloorOver()) + return; + if (!EntityIsValid(target)) + return; + + sub_806A5B8(target); + if (sub_80706A4(target,&target->pos)) { + WarpTarget(target,target,0,0); + } + if (!EntityIsValid(target)) { + return; + } + sub_806CE68(target,8); + if (GetEntInfo(target)->isTeamLeader) { + gDungeon->unk1 = 0; + gDungeon->unk5C0 = -1; + DiscoverMinimap(&target->pos); + sub_807EC28(FALSE); + } + sub_806A5B8(target); + TryTriggerMonsterHouseWithMsg(target,gDungeon->forceMonsterHouse); } void sub_807D068(Entity *pokemon, DungeonPos *pos) diff --git a/src/dungeon_logic.c b/src/dungeon_logic.c index a5dfd342e..ece394d8e 100644 --- a/src/dungeon_logic.c +++ b/src/dungeon_logic.c @@ -1176,34 +1176,29 @@ u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ign return gTreatmentData[decoyAITracker][pokemonIsEnemy][targetIsEnemy][targetIsDecoy]; } -u8 sub_807167C(Entity * pokemon, Entity * target) +u8 GetTreatmentBetweenMonstersIgnoreStatus(Entity *monster1, Entity *monster2) { - bool8 cannotUseItems; - EntityInfo * targetEntityInfo; - EntityInfo * pokemonEntityData; + EntityInfo *monster1Info = GetEntInfo(monster1); + EntityInfo *monster2Info = GetEntInfo(monster2); - pokemonEntityData = GetEntInfo(pokemon); - targetEntityInfo = GetEntInfo(target); - if (pokemonEntityData->monsterBehavior != BEHAVIOR_RESCUE_TARGET) { - cannotUseItems = IsExperienceLocked(pokemonEntityData->joinedAt.id); - if (!cannotUseItems && (pokemonEntityData->shopkeeper == SHOPKEEPER_MODE_NORMAL) && (targetEntityInfo->monsterBehavior != BEHAVIOR_RESCUE_TARGET)) { - cannotUseItems = IsExperienceLocked(targetEntityInfo->joinedAt.id); - if (cannotUseItems || (targetEntityInfo->shopkeeper != SHOPKEEPER_MODE_NORMAL)) { -error: - return TREATMENT_IGNORE; - } - else - { - if ((pokemonEntityData->isNotTeamMember) != (targetEntityInfo->isNotTeamMember)) { - return TREATMENT_TREAT_AS_ENEMY; - } - else { - return TREATMENT_TREAT_AS_ALLY; - } - } - } - } - goto error; + if (monster1Info->monsterBehavior == BEHAVIOR_RESCUE_TARGET) + return TREATMENT_IGNORE; + if (IsExperienceLocked(monster1Info->joinedAt.id)) + return TREATMENT_IGNORE; + if (monster1Info->shopkeeper != SHOPKEEPER_MODE_NORMAL) + return TREATMENT_IGNORE; + + if (monster2Info->monsterBehavior == BEHAVIOR_RESCUE_TARGET) + return TREATMENT_IGNORE; + if (IsExperienceLocked(monster2Info->joinedAt.id)) + return TREATMENT_IGNORE; + if (monster2Info->shopkeeper != SHOPKEEPER_MODE_NORMAL) + return TREATMENT_IGNORE; + + if (monster1Info->isNotTeamMember != monster2Info->isNotTeamMember) + return TREATMENT_TREAT_AS_ENEMY; + else + return TREATMENT_TREAT_AS_ALLY; } bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage) diff --git a/src/move_orb_effects_1.c b/src/move_orb_effects_1.c index 35c20f035..7d43c7bec 100644 --- a/src/move_orb_effects_1.c +++ b/src/move_orb_effects_1.c @@ -412,7 +412,7 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FF01C); } - if (sub_807167C(target,entity) == TREATMENT_TREAT_AS_ENEMY) { + if (GetTreatmentBetweenMonstersIgnoreStatus(target,entity) == TREATMENT_TREAT_AS_ENEMY) { // Recurse with the new target BurnedStatusTarget(pokemon,entity,1,displayMessage); } @@ -499,7 +499,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FF01C); } - if (sub_807167C(target,entity) == TREATMENT_TREAT_AS_ENEMY) { + if (GetTreatmentBetweenMonstersIgnoreStatus(target,entity) == TREATMENT_TREAT_AS_ENEMY) { // Recurse with the new target PoisonedStatusTarget(pokemon,entity,displayMessage); } @@ -581,7 +581,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FF01C); } - if (sub_807167C(target,entity) == TREATMENT_TREAT_AS_ENEMY) { + if (GetTreatmentBetweenMonstersIgnoreStatus(target,entity) == TREATMENT_TREAT_AS_ENEMY) { // Recurse with the new target BadlyPoisonedStatusTarget(pokemon,entity,displayMessage); } @@ -728,63 +728,57 @@ void IngrainedStatusTarget(Entity * pokemon, Entity * target) } } -void WrapTarget(Entity * pokemon, Entity * target) +void WrapTarget(Entity *pokemon, Entity *target) { - EntityInfo * targetEntityInfo; - s32 *piVar3; - s32 *iVar5; - EntityInfo * pokemonEntityData; + EntityInfo *targetEntityInfo; + EntityInfo *pokemonEntityData; - if (!EntityIsValid(target)) { - return; - } + if (!EntityIsValid(target)) + return; + if (HasSafeguardStatus(pokemon, target, TRUE)) + return; - if (HasSafeguardStatus(pokemon, target, TRUE)) { - return; - } - pokemonEntityData = GetEntInfo(pokemon); - targetEntityInfo = GetEntInfo(target); - if (pokemonEntityData->frozenClassStatus.status != STATUS_WRAP && pokemonEntityData->frozenClassStatus.status != STATUS_WRAPPED) { - if ((targetEntityInfo->frozenClassStatus.status != STATUS_WRAP)) + pokemonEntityData = GetEntInfo(pokemon); + targetEntityInfo = GetEntInfo(target); + if (pokemonEntityData->frozenClassStatus.status != STATUS_WRAP + && pokemonEntityData->frozenClassStatus.status != STATUS_WRAPPED + && targetEntityInfo->frozenClassStatus.status != STATUS_WRAP + && targetEntityInfo->frozenClassStatus.status != STATUS_WRAPPED) { - if(targetEntityInfo->frozenClassStatus.status != STATUS_WRAPPED) { - pokemonEntityData->frozenClassStatus.status = STATUS_WRAP; - pokemonEntityData->frozenClassStatus.turns = 0x7f; - pokemonEntityData->frozenClassStatus.damageCountdown = 0; - targetEntityInfo->frozenClassStatus.status = STATUS_WRAPPED; - targetEntityInfo->frozenClassStatus.turns = CalculateStatusTurns(target, gWrapTurnRange, TRUE) + 1; - targetEntityInfo->frozenClassStatus.damageCountdown = 0; - iVar5 = &pokemonEntityData->unk9C; - piVar3 = &gDungeon->unk37F4; - *iVar5 = *piVar3; - targetEntityInfo->unk9C = *piVar3; - *piVar3 +=1; - nullsub_69(pokemon, target); + pokemonEntityData->frozenClassStatus.status = STATUS_WRAP; + pokemonEntityData->frozenClassStatus.turns = 0x7f; + pokemonEntityData->frozenClassStatus.damageCountdown = 0; + targetEntityInfo->frozenClassStatus.status = STATUS_WRAPPED; + targetEntityInfo->frozenClassStatus.turns = CalculateStatusTurns(target, gWrapTurnRange, TRUE) + 1; + targetEntityInfo->frozenClassStatus.damageCountdown = 0; + pokemonEntityData->unk9C = gDungeon->unk37F4; + targetEntityInfo->unk9C = gDungeon->unk37F4; + gDungeon->unk37F4++; + nullsub_69(pokemon, target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6D8); + sub_806CE94(target,8); + } + else { + if (pokemonEntityData->frozenClassStatus.status == STATUS_WRAP) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6FC); + } + if (targetEntityInfo->frozenClassStatus.status == STATUS_WRAP) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6D8); - sub_806CE94(target,8); - goto _08076C98; + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6FC); + } + if (pokemonEntityData->frozenClassStatus.status == STATUS_WRAPPED) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB718); + } + if (targetEntityInfo->frozenClassStatus.status == STATUS_WRAPPED) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB718); } } - } - if (pokemonEntityData->frozenClassStatus.status == STATUS_WRAP) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6FC); - } - if (targetEntityInfo->frozenClassStatus.status == STATUS_WRAP) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6FC); - } - if (pokemonEntityData->frozenClassStatus.status == STATUS_WRAPPED) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],pokemon,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB718); - } - if (targetEntityInfo->frozenClassStatus.status == STATUS_WRAPPED) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB718); - } -_08076C98: - EntityUpdateStatusSprites(target); + + EntityUpdateStatusSprites(target); } void sub_8076CB4(s32 param_1) @@ -859,57 +853,60 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage) { - EntityInfo *entityInfo; - s32 attackStage = decrement; + EntityInfo *entityInfo; + s32 attackStage = decrement; - if (!EntityIsValid(target)) { - return; - } - if (index != STAT_STAGE_ATK) { - strcpy(gFormatBuffer_Items[0],gUnknown_80FC0C8); - } - else { - strcpy(gFormatBuffer_Items[0],gUnknown_80FC0B8); - } - if (param_5) { - if (sub_8071728(pokemon,target,displayMessage)) { - return; - } - if (HasHeldItem(target, ITEM_TWIST_BAND)) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FD550); + if (!EntityIsValid(target)) + return; + + if (index != STAT_STAGE_ATK) { + strcpy(gFormatBuffer_Items[0], gUnknown_80FC0C8); } else { - if ((!AbilityIsActive(target, ABILITY_HYPER_CUTTER)) || (index != STAT_STAGE_ATK)) goto _08076EE4; - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA60); + strcpy(gFormatBuffer_Items[0], gUnknown_80FC0B8); } - } - else { -_08076EE4: + + if (param_5) { + if (sub_8071728(pokemon,target,displayMessage)) + return; + + if (HasHeldItem(target, ITEM_TWIST_BAND)) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FD550); + return; + } + + if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && index == STAT_STAGE_ATK) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA60); + return; + } + } + entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); sub_8041F28(target,index); if (decrement == 1) { - strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); + strcpy(gFormatBuffer_Items[1], gUnknown_80FC0E4); } else { - strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); + strcpy(gFormatBuffer_Items[1], gUnknown_80FC0D4); } attackStage = entityInfo->offensiveStages[index]; attackStage -= decrement; if (attackStage < 0) { - attackStage = 0; + attackStage = 0; } + if (entityInfo->offensiveStages[index] != attackStage) { - entityInfo->offensiveStages[index] = attackStage; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC15C); + entityInfo->offensiveStages[index] = attackStage; + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC15C); } else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC274); + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC274); } + EntityUpdateStatusSprites(target); - } } void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage) @@ -917,39 +914,45 @@ void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 d EntityInfo *entityInfo; s32 defenseStage = decrement; - if (!EntityIsValid(target)) { + if (!EntityIsValid(target)) return; - } + if (index != STAT_STAGE_DEF) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C); } - if (!param_5 || !sub_8071728(pokemon,target,displayMessage)) { - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F4C(target,index); - if (decrement == 1) { - strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); - } - else { - strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); - } - defenseStage = entityInfo->defensiveStages[index]; - defenseStage = defenseStage - decrement; - if (defenseStage < 0) { - defenseStage = 0; - } - if (entityInfo->defensiveStages[index] != defenseStage) { - entityInfo->defensiveStages[index] = defenseStage; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC158); - } - else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC248); - } - EntityUpdateStatusSprites(target); - } + + if (param_5) { + if (sub_8071728(pokemon,target,displayMessage)) + return; + } + + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + sub_8041F4C(target,index); + if (decrement == 1) { + strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); + } + else { + strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); + } + defenseStage = entityInfo->defensiveStages[index]; + defenseStage = defenseStage - decrement; + if (defenseStage < 0) { + defenseStage = 0; + } + + if (entityInfo->defensiveStages[index] != defenseStage) { + entityInfo->defensiveStages[index] = defenseStage; + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC158); + } + else { + TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC248); + } + + EntityUpdateStatusSprites(target); } void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment) @@ -1319,7 +1322,7 @@ void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FF01C); } - if (sub_807167C(target,mapPokemonEntity) == 1) { + if (GetTreatmentBetweenMonstersIgnoreStatus(target,mapPokemonEntity) == TREATMENT_TREAT_AS_ENEMY) { ParalyzeStatusTarget(pokemon, mapPokemonEntity, displayMessage); } } diff --git a/src/status_checks.c b/src/status_checks.c index 2438c8020..02e80e170 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -20,15 +20,14 @@ bool8 HasStatusThatPreventsActing(Entity *pokemon) EntityInfo *pokemonInfo = GetEntInfo(pokemon); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], pokemon, 0); SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); - switch (pokemonInfo->sleepClassStatus.status) - { + switch (pokemonInfo->sleepClassStatus.status) { case STATUS_NIGHTMARE: case STATUS_SLEEP: case STATUS_NAPPING: return TRUE; } - switch (pokemonInfo->frozenClassStatus.status) - { + + switch (pokemonInfo->frozenClassStatus.status) { case STATUS_FROZEN: LogMessageByIdWithPopupCheckUser(pokemon, gPtrFrozenMessage); return TRUE; @@ -41,8 +40,8 @@ bool8 HasStatusThatPreventsActing(Entity *pokemon) case STATUS_PETRIFIED: return TRUE; } - switch (pokemonInfo->cringeClassStatus.status) - { + + switch (pokemonInfo->cringeClassStatus.status) { case STATUS_PAUSED: LogMessageByIdWithPopupCheckUser(pokemon, gPtrPausedMessage); return TRUE; @@ -50,45 +49,37 @@ bool8 HasStatusThatPreventsActing(Entity *pokemon) LogMessageByIdWithPopupCheckUser(pokemon, gPtrInfatuatedMessage); return TRUE; } - if (pokemonInfo->bideClassStatus.status == STATUS_BIDE) - { + + if (pokemonInfo->bideClassStatus.status == STATUS_BIDE) { LogMessageByIdWithPopupCheckUser(pokemon, gPtrBideMessage); return TRUE; } - if (pokemonInfo->curseClassStatus.status == STATUS_DECOY) - { + if (pokemonInfo->curseClassStatus.status == STATUS_DECOY) { SetActionPassTurnOrWalk(&pokemonInfo->action, pokemonInfo->id); pokemonInfo->action.direction = DungeonRandInt(NUM_DIRECTIONS); pokemonInfo->targetPos.x = pokemon->pos.x; pokemonInfo->targetPos.y = pokemon->pos.y - 1; return TRUE; } - if (pokemonInfo->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER) - { + if (pokemonInfo->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER) { return TRUE; } - if (pokemonInfo->blinkerClassStatus.status == STATUS_BLINKER) - { - if (!CanMoveInDirection(pokemon, pokemonInfo->action.direction)) - { - if (DungeonRandInt(2) != 0) - { - pokemonInfo->action.direction = DungeonRandInt(NUM_DIRECTIONS); - pokemonInfo->action.direction = pokemonInfo->action.direction & DIRECTION_MASK; - goto walk; - } - } - else - { - walk: + if (pokemonInfo->blinkerClassStatus.status == STATUS_BLINKER) { + if (CanMoveInDirection(pokemon, pokemonInfo->action.direction)) { SetActionPassTurnOrWalk(&pokemonInfo->action, pokemonInfo->id); - return TRUE; } - ChooseAIMove(pokemon); + else if (DungeonRandInt(2) != 0) { + pokemonInfo->action.direction = DungeonRandInt(NUM_DIRECTIONS); + pokemonInfo->action.direction = pokemonInfo->action.direction & DIRECTION_MASK; + SetActionPassTurnOrWalk(&pokemonInfo->action, pokemonInfo->id); + } + else { + ChooseAIMove(pokemon); + } + return TRUE; } - if (pokemonInfo->blinkerClassStatus.status == STATUS_CROSS_EYED) - { + if (pokemonInfo->blinkerClassStatus.status == STATUS_CROSS_EYED) { SetActionPassTurnOrWalk(&pokemonInfo->action, pokemonInfo->id); pokemonInfo->action.direction = DungeonRandInt(NUM_DIRECTIONS); return TRUE; @@ -137,7 +128,7 @@ bool8 sub_80701A4(Entity *pokemon) switch(pokemonInfo->cringeClassStatus.status) { case STATUS_CONFUSED: flag = TRUE; - goto _0807026C; + goto CRINGE_STATUS; case STATUS_PAUSED: LogMessageByIdWithPopupCheckUser(pokemon,gPtrPausedMessage); return TRUE; @@ -148,7 +139,7 @@ bool8 sub_80701A4(Entity *pokemon) case STATUS_NONE: case STATUS_CRINGE: case 8: - _0807026C: + CRINGE_STATUS: if (pokemonInfo->bideClassStatus.status == STATUS_BIDE) { LogMessageByIdWithPopupCheckUser(pokemon,gPtrBideMessage); return TRUE;