Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors residual damage #4945

Merged
merged 9 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
.byte 0x95
.endm

.macro weatherdamage
.macro unused_96
.byte 0x96
.endm

Expand Down Expand Up @@ -1359,15 +1359,15 @@
.macro restoretarget
callnative BS_RestoreTarget
.endm

.macro saveattacker
callnative BS_SaveAttacker
.endm

.macro restoreattacker
callnative BS_RestoreAttacker
.endm

.macro metalburstdamagecalculator failInstr:req
callnative BS_CalcMetalBurstDmg
.4byte \failInstr
Expand Down Expand Up @@ -1560,10 +1560,6 @@
.4byte \failInstr
.endm

.macro damagenontypes
callnative BS_DamageNonTypes
.endm

.macro trysetstatus1, ptr:req
callnative BS_TrySetStatus1
.4byte \ptr
Expand Down Expand Up @@ -1659,7 +1655,7 @@
.macro removeweather
callnative BS_RemoveWeather
.endm

.macro applyterastallization
callnative BS_ApplyTerastallization
.endm
Expand Down
7 changes: 7 additions & 0 deletions data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ gBattleAnims_General::
.4byte General_Fog @ B_ANIM_FOG_CONTINUES
.4byte General_TeraCharge @ B_ANIM_TERA_CHARGE
.4byte General_TeraActivate @ B_ANIM_TERA_ACTIVATE
.4byte General_SimpleHeal @ B_ANIM_SIMPLE_HEAL

.align 2
gBattleAnims_Special::
Expand Down Expand Up @@ -27347,6 +27348,12 @@ General_WishHeal:
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, F_PAL_BG, 3, 10, 0, RGB_BLACK
end

General_SimpleHeal:
loadspritegfx ANIM_TAG_BLUE_STAR
call HealingEffect
waitforvisualfinish
end

General_IllusionOff:
monbg ANIM_TARGET
createvisualtask AnimTask_TransformMon, 2, 1, 0
Expand Down
53 changes: 13 additions & 40 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -5921,33 +5921,22 @@ BattleScript_DamagingWeatherContinues::
waitmessage B_WAIT_TIME_LONG
playanimation_var BS_ATTACKER, sB_ANIM_ARG1
setbyte gBattleCommunication, 0
BattleScript_DamagingWeatherLoop::
copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 1
weatherdamage
jumpifword CMP_EQUAL, gBattleMoveDamage, 0, BattleScript_DamagingWeatherLoopIncrement
jumpifword CMP_COMMON_BITS gBattleMoveDamage, 1 << 31, BattleScript_DamagingWeatherHeal
end2

BattleScript_DamagingWeather::
printfromtable gSandStormHailDmgStringIds
waitmessage B_WAIT_TIME_LONG
effectivenesssound
hitanimation BS_ATTACKER
goto BattleScript_DamagingWeatherHpChange
BattleScript_DamagingWeatherHeal:
call BattleScript_AbilityPopUp
hitanimation BS_SCRIPTING
goto BattleScript_DoTurnDmg

BattleScript_IceBodyHeal::
call BattleScript_AbilityPopUpScripting
playanimation BS_SCRIPTING, B_ANIM_SIMPLE_HEAL
healthbarupdate BS_SCRIPTING
datahpupdate BS_SCRIPTING
printstring STRINGID_ICEBODYHPGAIN
waitmessage B_WAIT_TIME_LONG
BattleScript_DamagingWeatherHpChange:
orword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
tryfaintmon BS_ATTACKER
checkteamslost BattleScript_DamagingWeatherLoopIncrement
BattleScript_DamagingWeatherLoopIncrement::
jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_DamagingWeatherContinuesEnd
addbyte gBattleCommunication, 1
jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop
BattleScript_DamagingWeatherContinuesEnd::
bicword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE
call BattleScript_ActivateWeatherAbilities
end2

BattleScript_SandStormHailSnowEnds::
Expand Down Expand Up @@ -9834,27 +9823,11 @@ BattleScript_DamageNonTypesStarts::
goto BattleScript_MoveEnd

BattleScript_DamageNonTypesContinues::
setbyte gBattleCommunication, 0
BattleScript_DamageNonTypesLoop::
copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 1
damagenontypes
jumpifword CMP_EQUAL, gBattleMoveDamage, 0, BattleScript_DamageNonTypesLoopIncrement
printfromtable gDamageNonTypesDmgStringIds
waitmessage B_WAIT_TIME_LONG
effectivenesssound
hitanimation BS_ATTACKER
orword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
tryfaintmon BS_ATTACKER
checkteamslost BattleScript_DamageNonTypesLoopIncrement
BattleScript_DamageNonTypesLoopIncrement::
jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_DamageNonTypesContinuesEnd
addbyte gBattleCommunication, 1
jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamageNonTypesLoop
BattleScript_DamageNonTypesContinuesEnd::
bicword gHitMarker, HITMARKER_IGNORE_BIDE | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE | HITMARKER_GRUDGE
end2
hitanimation BS_SCRIPTING
goto BattleScript_DoTurnDmg

BattleScript_EffectTryReducePP::
tryspiteppreduce BattleScript_MoveEnd
Expand Down
1 change: 0 additions & 1 deletion include/battle_dynamax.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ void BS_SetMaxMoveEffect(void);
void BS_SetSteelsurge(void);
void BS_TrySetStatus1(void);
void BS_TrySetStatus2(void);
void BS_DamageNonTypes(void);
void BS_HealOneSixth(void);
void BS_TryRecycleBerry(void);
void BS_JumpIfDynamaxed(void);
Expand Down
2 changes: 2 additions & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ extern const u8 BattleScript_LevelUp[];
extern const u8 BattleScript_RainContinuesOrEnds[];
extern const u8 BattleScript_SnowContinuesOrEnds[];
extern const u8 BattleScript_DamagingWeatherContinues[];
extern const u8 BattleScript_DamagingWeather[];
extern const u8 BattleScript_IceBodyHeal[];
extern const u8 BattleScript_SandStormHailSnowEnds[];
extern const u8 BattleScript_SunlightContinues[];
extern const u8 BattleScript_SunlightFaded[];
Expand Down
1 change: 1 addition & 0 deletions include/constants/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@
#define B_ANIM_FOG_CONTINUES 49
#define B_ANIM_TERA_CHARGE 50
#define B_ANIM_TERA_ACTIVATE 51
#define B_ANIM_SIMPLE_HEAL 52

// special animations table (gBattleAnims_Special)
#define B_ANIM_LVL_UP 0
Expand Down
18 changes: 0 additions & 18 deletions src/battle_dynamax.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,24 +971,6 @@ void BS_TrySetStatus2(void)
}
}

// Applies the endturn damage effect associated with the "Damage Non-" G-Max moves.
void BS_DamageNonTypes(void)
{
NATIVE_ARGS();
u8 side = GetBattlerSide(gBattlerAttacker);
gBattleMoveDamage = 0;
if (gSideTimers[side].damageNonTypesTimer
&& !IS_BATTLER_OF_TYPE(gBattlerAttacker, gSideTimers[side].damageNonTypesType)
&& IsBattlerAlive(gBattlerAttacker)
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
{
gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 6;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
}
gBattlescriptCurrInstr = cmd->nextInstr;
}

// Heals one-sixth of the target's HP, including for Dynamaxed targets.
void BS_HealOneSixth(void)
{
Expand Down
74 changes: 4 additions & 70 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static void Cmd_setlightscreen(void);
static void Cmd_tryKO(void);
static void Cmd_damagetohalftargethp(void);
static void Cmd_unused_95(void);
static void Cmd_weatherdamage(void);
static void Cmd_unused_96(void);
static void Cmd_tryinfatuating(void);
static void Cmd_updatestatusicon(void);
static void Cmd_setmist(void);
Expand Down Expand Up @@ -749,7 +749,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_tryKO, //0x93
Cmd_damagetohalftargethp, //0x94
Cmd_unused_95, //0x95
Cmd_weatherdamage, //0x96
Cmd_unused_96, //0x96
Cmd_tryinfatuating, //0x97
Cmd_updatestatusicon, //0x98
Cmd_setmist, //0x99
Expand Down Expand Up @@ -12411,74 +12411,8 @@ static void Cmd_unused_95(void)
{
}

static void Cmd_weatherdamage(void)
static void Cmd_unused_96(void)
{
CMD_ARGS();

u32 ability = GetBattlerAbility(gBattlerAttacker);

gBattleMoveDamage = 0;
if (IsBattlerAlive(gBattlerAttacker) && WEATHER_HAS_EFFECT && ability != ABILITY_MAGIC_GUARD)
{
if (gBattleWeather & B_WEATHER_SANDSTORM)
{
if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ROCK)
&& !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GROUND)
&& !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_STEEL)
&& ability != ABILITY_SAND_VEIL
&& ability != ABILITY_SAND_FORCE
&& ability != ABILITY_SAND_RUSH
&& ability != ABILITY_OVERCOAT
&& !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER))
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES)
{
gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
}
}
if (gBattleWeather & B_WEATHER_HAIL)
{
if (ability == ABILITY_ICE_BODY
&& !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER))
&& !BATTLER_MAX_HP(gBattlerAttacker)
&& !(gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK))
{
gBattlerAbility = gBattlerAttacker;
gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
}
else if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE)
&& ability != ABILITY_SNOW_CLOAK
&& ability != ABILITY_OVERCOAT
&& ability != ABILITY_ICE_BODY
&& !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER))
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES)
{
gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
}
}
if (gBattleWeather & B_WEATHER_SNOW)
{
if (ability == ABILITY_ICE_BODY
&& !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER))
&& !BATTLER_MAX_HP(gBattlerAttacker)
&& !(gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK))
{
gBattlerAbility = gBattlerAttacker;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
}
}
}

gBattlescriptCurrInstr = cmd->nextInstr;
}

static void Cmd_tryinfatuating(void)
Expand Down Expand Up @@ -14044,7 +13978,7 @@ u32 GetNaturePowerMove(u32 battler)
move = MOVE_PSYCHIC;
else if (sNaturePowerMoves[gBattleTerrain] == MOVE_NONE)
move = MOVE_TRI_ATTACK;

if (GetActiveGimmick(battler) == GIMMICK_Z_MOVE)
{
gBattleStruct->zmove.baseMoves[gBattlerAttacker] = move;
Expand Down
Loading
Loading