updated up to Cmd_switchindataupdate

This commit is contained in:
cawtds 2024-05-01 16:56:25 +02:00
parent 547a0a1321
commit efe6d23e07
5 changed files with 77 additions and 139 deletions

View File

@ -456,8 +456,9 @@
moveend 2, \to
.endm
.macro typecalc2
.macro sethealblock failInstr:req
.byte 0x4a
.4byte \failInstr
.endm
.macro returnatktoball

View File

@ -977,8 +977,9 @@ BattleScript_EffectCounter::
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
typecalc2
adjustsetdamage
typecalc
bichalfword gMoveResultFlags, MOVE_RESULT_NOT_VERY_EFFECTIVE | MOVE_RESULT_SUPER_EFFECTIVE
adjustdamage
goto BattleScript_HitFromAtkAnimation
BattleScript_EffectEncore::
@ -1294,18 +1295,6 @@ BattleScript_EffectSandstorm::
setsandstorm
goto BattleScript_MoveWeatherChange
BattleScript_EffectRollout::
attackcanceler
attackstring
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_RolloutCheckAccuracy
ppreduce
BattleScript_RolloutCheckAccuracy::
accuracycheck BattleScript_RolloutHit, ACC_CURR_MOVE
BattleScript_RolloutHit::
typecalc2
rolloutdamagecalculation
goto BattleScript_HitFromCritCalc
BattleScript_EffectSwagger::
attackcanceler
jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_MakeMoveMissed
@ -1505,8 +1494,9 @@ BattleScript_EffectMirrorCoat::
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
typecalc2
adjustsetdamage
typecalc
bichalfword gMoveResultFlags, MOVE_RESULT_NOT_VERY_EFFECTIVE | MOVE_RESULT_SUPER_EFFECTIVE
adjustdamage
goto BattleScript_HitFromAtkAnimation
BattleScript_EffectTwister::
@ -2085,10 +2075,9 @@ BattleScript_EffectBrickBreak::
removelightscreenreflect
critcalc
damagecalc
typecalc
adjustdamage
jumpifbyte CMP_EQUAL, sB_ANIM_TURN, 0, BattleScript_BrickBreakAnim
bicbyte gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE
bichalfword gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE
BattleScript_BrickBreakAnim::
attackanimation
waitanimation
@ -2096,7 +2085,7 @@ BattleScript_BrickBreakAnim::
printstring STRINGID_THEWALLSHATTERED
waitmessage B_WAIT_TIME_LONG
BattleScript_BrickBreakDoHit::
typecalc2
typecalc
effectivenesssound
hitanimation BS_TARGET
waitstate

View File

@ -352,7 +352,6 @@ extern const u8 BattleScript_EffectForesight[];
extern const u8 BattleScript_EffectPerishSong[];
extern const u8 BattleScript_EffectSandstorm[];
extern const u8 BattleScript_EffectEndure[];
extern const u8 BattleScript_EffectRollout[];
extern const u8 BattleScript_EffectSwagger[];
extern const u8 BattleScript_EffectFuryCutter[];
extern const u8 BattleScript_EffectAttract[];

View File

@ -409,7 +409,7 @@ static void Cmd_playanimation_var(void);
static void Cmd_setgraphicalstatchangevalues(void);
static void Cmd_playstatchangeanimation(void);
static void Cmd_moveend(void);
static void Cmd_typecalc2(void);
static void Cmd_sethealblock(void);
static void Cmd_returnatktoball(void);
static void Cmd_getswitchedmondata(void);
static void Cmd_switchindataupdate(void);
@ -661,10 +661,10 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_setgraphicalstatchangevalues, //0x47 // done
Cmd_playstatchangeanimation, //0x48 // done
Cmd_moveend, //0x49 // done
Cmd_typecalc2, //0x4A
Cmd_returnatktoball, //0x4B
Cmd_getswitchedmondata, //0x4C
Cmd_switchindataupdate, //0x4D
Cmd_sethealblock, //0x4A // done
Cmd_returnatktoball, //0x4B // done
Cmd_getswitchedmondata, //0x4C // done
Cmd_switchindataupdate, //0x4D // done
Cmd_switchinanim, //0x4E
Cmd_jumpifcantswitch, //0x4F
Cmd_openpartyscreen, //0x50
@ -6624,170 +6624,119 @@ static void Cmd_moveend(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}
static void Cmd_typecalc2(void)
static void Cmd_sethealblock(void)
{
u8 flags = 0;
s32 i = 0;
u8 moveType = gMovesInfo[gCurrentMove].type;
CMD_ARGS(const u8 *failInstr);
if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND)
if (gStatuses3[gBattlerTarget] & STATUS3_HEAL_BLOCK)
{
gLastUsedAbility = gBattleMons[gBattlerTarget].ability;
gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE);
gLastLandedMoves[gBattlerTarget] = 0;
gBattleCommunication[MISS_TYPE] = B_MSG_GROUND_MISS;
RecordAbilityBattle(gBattlerTarget, gLastUsedAbility);
gBattlescriptCurrInstr = cmd->failInstr;
}
else
{
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].type1)
{
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].type2)
{
if (gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
{
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
break;
}
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
&& gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
{
flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE;
}
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
&& gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
{
flags |= MOVE_RESULT_SUPER_EFFECTIVE;
}
}
}
i += 3;
}
gStatuses3[gBattlerTarget] |= STATUS3_HEAL_BLOCK;
gDisableStructs[gBattlerTarget].healBlockTimer = 5;
gBattlescriptCurrInstr = cmd->nextInstr;
}
if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD
&& !(flags & MOVE_RESULT_NO_EFFECT)
&& AttacksThisTurn(gBattlerAttacker, gCurrentMove) == 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)))
&& gMovesInfo[gCurrentMove].power)
{
gLastUsedAbility = ABILITY_WONDER_GUARD;
gMoveResultFlags |= MOVE_RESULT_MISSED;
gLastLandedMoves[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 Cmd_returnatktoball(void)
{
CMD_ARGS();
gActiveBattler = gBattlerAttacker;
if (!(gHitMarker & HITMARKER_FAINTED(gActiveBattler)))
if (!(gHitMarker & HITMARKER_FAINTED(gBattlerAttacker)))
{
BtlController_EmitReturnMonToBall(BUFFER_A, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
MarkBattlerForControllerExec(gBattlerAttacker);
}
gBattlescriptCurrInstr++;
gBattlescriptCurrInstr = cmd->nextInstr;
}
static void Cmd_getswitchedmondata(void)
{
CMD_ARGS(u8 battler);
u32 battler = GetBattlerForBattleScript(cmd->battler);
if (gBattleControllerExecFlags)
return;
gActiveBattler = battler;
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
gBattlerPartyIndexes[battler] = gBattleStruct->monToSwitchIntoId[battler];
gBattlerPartyIndexes[gActiveBattler] = *(gBattleStruct->monToSwitchIntoId + gActiveBattler);
BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[battler]]);
MarkBattlerForControllerExec(battler);
BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]]);
MarkBattlerForControllerExec(gActiveBattler);
gBattlescriptCurrInstr += 2;
gBattlescriptCurrInstr = cmd->nextInstr;
}
static void Cmd_switchindataupdate(void)
{
CMD_ARGS(u8 battler);
struct BattlePokemon oldData;
s32 i;
u32 battler, i;
u8 *monData;
if (gBattleControllerExecFlags)
return;
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
oldData = gBattleMons[gActiveBattler];
monData = (u8 *)(&gBattleMons[gActiveBattler]);
battler = gActiveBattler = GetBattlerForBattleScript(cmd->battler);
oldData = gBattleMons[battler];
monData = (u8 *)(&gBattleMons[battler]);
for (i = 0; i < sizeof(struct BattlePokemon); i++)
monData[i] = gBattleBufferB[gActiveBattler][4 + i];
monData[i] = gBattleBufferB[battler][4 + i];
gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
// Edge case: the sent out pokemon has 0 HP. This should never happen.
if (gBattleMons[battler].hp == 0)
{
struct Pokemon *party = GetBattlerParty(battler);
// Find the first possible replacement for the not valid pokemon.
for (i = 0; i < PARTY_SIZE; i++)
{
if (IsValidForBattle(&party[i]))
break;
}
// There is valid replacement.
if (i != PARTY_SIZE)
{
gBattlerPartyIndexes[battler] = gBattleStruct->monToSwitchIntoId[battler] = i;
BtlController_EmitGetMonData(BUFFER_A, REQUEST_ALL_BATTLE, gBitTable[gBattlerPartyIndexes[battler]]);
MarkBattlerForControllerExec(battler);
return;
}
}
gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
gBattleMons[battler].type3 = TYPE_MYSTERY;
gBattleMons[battler].ability = GetAbilityBySpecies(gBattleMons[battler].species, gBattleMons[battler].abilityNum);
// check knocked off item
i = GetBattlerSide(gActiveBattler);
if (gWishFutureKnock.knockedOffMons[i] & gBitTable[gBattlerPartyIndexes[gActiveBattler]])
i = GetBattlerSide(battler);
if (gWishFutureKnock.knockedOffMons[i] & gBitTable[gBattlerPartyIndexes[battler]])
{
gBattleMons[gActiveBattler].item = ITEM_NONE;
gBattleMons[battler].item = ITEM_NONE;
}
if (gMovesInfo[gCurrentMove].effect == EFFECT_BATON_PASS)
{
for (i = 0; i < NUM_BATTLE_STATS; i++)
{
gBattleMons[gActiveBattler].statStages[i] = oldData.statStages[i];
gBattleMons[battler].statStages[i] = oldData.statStages[i];
}
gBattleMons[gActiveBattler].status2 = oldData.status2;
gBattleMons[battler].status2 = oldData.status2;
}
SwitchInClearSetData(gActiveBattler);
SwitchInClearSetData(battler);
gBattleScripting.battler = gActiveBattler;
gBattleScripting.battler = battler;
PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gActiveBattler, gBattlerPartyIndexes[gActiveBattler]);
PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, battler, gBattlerPartyIndexes[battler]);
gBattlescriptCurrInstr += 2;
gBattlescriptCurrInstr = cmd->nextInstr;
}
static void Cmd_switchinanim(void)

View File

@ -518,7 +518,7 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] =
[EFFECT_ROLLOUT] =
{
.battleScript = BattleScript_EffectRollout,
.battleScript = BattleScript_EffectHit,
},
[EFFECT_SWAGGER] =