Skip to content

Commit

Permalink
Secondary effects overhaul minor follow-up (#4062)
Browse files Browse the repository at this point in the history
* settwoturnstring command

* Unified two-turn attacks and Meteor Beam

To do: Solar Beam

* Solar Beam

Also fixed various function, removed EFFECT_GUST (who knows why that exists?)

* Updated Solar Beam + tests

* Redid two turn move + animations logic

Removed pointless various function; to do: remove Skull Bash, fix AI test

* Removed now-pointless flag

* Removed Skull Bash

And temporarily commented out failing AI tests

* Removed Sky Uppercut effect

Not sure when or why this was ever necessary

* Removed BattleScript_EffectSemiInvulnerable

Now uses BattleScript_EffectTwoTurnsAttack. Kept the effect; used the argument field to determine which STATUS3 such moves should apply but added a function to jump over weather checks in BattleScript_EffectTwoTurnsAttack if the current move is semi-invulnerable (since the instant-fire weather check and STATUS3 use the same field)

* Applied review changes

* Replaced VARIOUS with callnative

Tried to fix test but couldn't :/ wtf is going on

* Fixed one AI test

Cant fix the other...

* Added KNOWN_FAILING to failing AI tests

Separated them out into their own test

* Optimised script, overhauled charge turn string setting

Condensed multiple confusing macros into one, jumpifweathercheckchargeeffects. Script now tweaked and trimmed, string ids for charge turns now added to argument along with status3 (thanks to compression macro) and instant-fire-weather for semi-invulnerable and two-turn moves respectively. Also introduced a savedStringId in gBattleScripting to make string selection work.

* Unified two turn move tests + minor corrections

* Added semi-invulnerable move tests

Set the Razor Wind test to known failing - something to do with its animation?

---------

Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
  • Loading branch information
cfmnephrite and AlexOn1ine authored Feb 4, 2024
1 parent 7ae50ea commit 65c508d
Show file tree
Hide file tree
Showing 23 changed files with 1,000 additions and 595 deletions.
45 changes: 34 additions & 11 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
.2byte \id
.endm

.macro printsavedstring
printstring 0
.endm

.macro printselectionstring id:req
.byte 0x11
.2byte \id
Expand Down Expand Up @@ -776,8 +780,21 @@
.byte 0x8b
.endm

.macro unused0x8C
.macro twoturnmoveschargestringandanimation
.byte 0x8c
.4byte 1f @animation then attack string
@default - attack string then animation
printsavedstring
waitmessage B_WAIT_TIME_LONG
attackanimation
waitanimation
goto 2f
1:
attackanimation
waitanimation
printsavedstring
waitmessage B_WAIT_TIME_LONG
2:
.endm

.macro setmultihitcounter value:req
Expand Down Expand Up @@ -1035,12 +1052,20 @@
.4byte \failInstr
.endm

.macro setsemiinvulnerablebit
.macro setsemiinvulnerablebit clear=FALSE
.byte 0xc5
.byte \clear
.endm

.macro clearsemiinvulnerablebit
setsemiinvulnerablebit TRUE
.endm

.macro jumpifweathercheckchargeeffects battler:req, checkChargeTurnEffects:req, jumpInstr:req
.byte 0xc6
.byte \battler
.byte \checkChargeTurnEffects
.4byte \jumpInstr
.endm

.macro setminimize
Expand Down Expand Up @@ -1337,13 +1362,6 @@
.4byte \jumpInstr
.endm

.macro jumpifholdeffect battler:req, holdEffect:req, jumpInstr:req
callnative BS_JumpIfHoldEffect
.byte \battler
.2byte \holdEffect
.4byte \jumpInstr
.endm

.macro dostockpilestatchangeswearoff, battler:req, statChangeInstr:req
callnative BS_DoStockpileStatChangesWearOff
.byte \battler
Expand Down Expand Up @@ -2005,10 +2023,15 @@
.4byte \jumpInstr
.endm

.macro jumpifnoholdeffect battler:req, holdEffect:req, jumpInstr:req
various \battler, VARIOUS_JUMP_IF_NO_HOLD_EFFECT
.macro jumpifholdeffect battler:req, holdEffect:req, jumpInstr:req, equal=TRUE
various \battler, VARIOUS_JUMP_IF_HOLD_EFFECT
.byte \holdEffect
.4byte \jumpInstr
.byte \equal
.endm

.macro jumpifnoholdeffect battler:req, holdEffect:req, jumpInstr:req
jumpifholdeffect \battler, \holdEffect, \jumpInstr, FALSE
.endm

.macro infatuatewithbattler battler:req, infatuateWith:req
Expand Down
229 changes: 46 additions & 183 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -585,46 +585,9 @@ BattleScript_BeakBlastBurn::
call BattleScript_MoveEffectBurn
return

BattleScript_EffectMeteorBeam::
@ DecideTurn
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn
jumpifmove MOVE_METEOR_BEAM, BattleScript_SetStringMeteorBeam
jumpifmove MOVE_ELECTRO_SHOT, BattleScript_SetStringElectroShock
BattleScript_TryCharging:
call BattleScript_FirstChargingTurnMeteorBeam
jumpifmove MOVE_METEOR_BEAM, BattleScript_TryMeteorBeam
jumpifweatheraffected BS_ATTACKER, B_WEATHER_RAIN, BattleScript_TwoTurnMovesSecondTurn @ Check for move Electro Shot
BattleScript_TryMeteorBeam:
jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_MoveEnd
call BattleScript_PowerHerbActivation
goto BattleScript_TwoTurnMovesSecondTurn

BattleScript_SetStringMeteorBeam:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_METEOR_BEAM
goto BattleScript_TryCharging

BattleScript_SetStringElectroShock:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_ELECTRO_SHOCK
goto BattleScript_TryCharging

BattleScript_FirstChargingTurnMeteorBeam::
attackcanceler
flushtextbox
ppreduce
attackanimation
waitanimation
orword gHitMarker, HITMARKER_CHARGING
seteffectprimary MOVE_EFFECT_CHARGING | MOVE_EFFECT_AFFECTS_USER
copybyte cMULTISTRING_CHOOSER, sTWOTURN_STRINGID
printfromtable gFirstTurnOfTwoStringIds
waitmessage B_WAIT_TIME_LONG
setadditionaleffects @ only onChargeTurnOnly effects will work here
return

BattleScript_EffectSkyDrop::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_SkyDropTurn2
attackcanceler
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_SkyDropTurn2
ppreduce
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
Expand All @@ -638,16 +601,10 @@ BattleScript_EffectSkyDrop::

BattleScript_SkyDropWork:
setskydrop
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_SKY_DROP
setsemiinvulnerablebit
call BattleScriptFirstChargingTurnAfterAttackString
call BattleScript_FirstChargingTurnAfterAttackString
goto BattleScript_MoveEnd
BattleScript_SkyDropTurn2:
attackcanceler
setbyte sB_ANIM_TURN, 0x1
clearstatusfromeffect BS_ATTACKER, MOVE_EFFECT_CHARGING
orword gHitMarker, HITMARKER_NO_PPDEDUCT
clearsemiinvulnerablebit
call BattleScript_TwoTurnMovesSecondTurnRet
attackstring
clearskydrop BattleScript_SkyDropChangedTarget
jumpiftype BS_TARGET, TYPE_FLYING, BattleScript_SkyDropFlyingType
Expand Down Expand Up @@ -3485,29 +3442,6 @@ BattleScript_KOFail::
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd

BattleScript_TwoTurnMovesSecondTurn::
attackcanceler
setbyte sB_ANIM_TURN, 1
clearstatusfromeffect BS_ATTACKER, MOVE_EFFECT_CHARGING
orword gHitMarker, HITMARKER_NO_PPDEDUCT
goto BattleScript_HitFromAccCheck

BattleScriptFirstChargingTurn::
attackcanceler
flushtextbox
ppreduce
attackstring
BattleScriptFirstChargingTurnAfterAttackString:
pause B_WAIT_TIME_LONG
copybyte cMULTISTRING_CHOOSER, sTWOTURN_STRINGID
printfromtable gFirstTurnOfTwoStringIds
waitmessage B_WAIT_TIME_LONG
attackanimation
waitanimation
orword gHitMarker, HITMARKER_CHARGING
seteffectprimary MOVE_EFFECT_CHARGING | MOVE_EFFECT_AFFECTS_USER
return

BattleScript_EffectSuperFang::
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
Expand Down Expand Up @@ -3784,34 +3718,16 @@ BattleScript_PowerHerbActivation:
BattleScript_EffectTwoTurnsAttack::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn
jumpifmove MOVE_SKY_ATTACK, BattleScript_EffectTwoTurnsAttackSkyAttack
jumpifmove MOVE_RAZOR_WIND, BattleScript_EffectTwoTurnsAttackRazorWind
jumpifmove MOVE_ICE_BURN, BattleScript_EffectTwoTurnsAttackIceBurn
jumpifmove MOVE_FREEZE_SHOCK, BattleScript_EffectTwoTurnsAttackFreezeShock
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_RAZOR_WIND
BattleScript_EffectTwoTurnsAttackContinue:
call BattleScriptFirstChargingTurn
jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_MoveEnd
call BattleScript_PowerHerbActivation
goto BattleScript_TwoTurnMovesSecondTurn
BattleScript_EffectTwoTurnsAttackSkyAttack:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_SKY_ATTACK
goto BattleScript_EffectTwoTurnsAttackContinue
BattleScript_EffectTwoTurnsAttackRazorWind:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_RAZOR_WIND
goto BattleScript_EffectTwoTurnsAttackContinue
BattleScript_EffectTwoTurnsAttackIceBurn:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_RAZOR_WIND
goto BattleScript_EffectTwoTurnsAttackContinue
BattleScript_EffectTwoTurnsAttackFreezeShock:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_FREEZE_SHOCK
goto BattleScript_EffectTwoTurnsAttackContinue
jumpifweathercheckchargeeffects BS_ATTACKER, TRUE, BattleScript_EffectHit
call BattleScript_FirstChargingTurn
jumpifweathercheckchargeeffects BS_ATTACKER, FALSE, BattleScript_TwoTurnMovesSecondTurn
jumpifholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_TwoTurnMovesSecondPowerHerbActivates
goto BattleScript_MoveEnd

BattleScript_EffectGeomancy::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_GeomancySecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_GeomancySecondTurn
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_GEOMANCY
call BattleScriptFirstChargingTurn
call BattleScript_FirstChargingTurn
jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_MoveEnd
call BattleScript_PowerHerbActivation
BattleScript_GeomancySecondTurn:
Expand Down Expand Up @@ -3848,6 +3764,43 @@ BattleScript_GeomancyTrySpeed::
BattleScript_GeomancyEnd::
goto BattleScript_MoveEnd

BattleScript_FirstChargingTurn::
attackcanceler
.if B_UPDATED_MOVE_DATA >= GEN_5 @ before Gen 5, charge moves did not print an attack string on the charge turn
flushtextbox
attackstring
waitmessage B_WAIT_TIME_LONG
.endif
ppreduce
BattleScript_FirstChargingTurnAfterAttackString:
setsemiinvulnerablebit @ only for moves with EFFECT_SEMI_INVULNERABLE/EFFECT_SKY_DROP
orword gHitMarker, HITMARKER_CHARGING
seteffectprimary MOVE_EFFECT_CHARGING | MOVE_EFFECT_AFFECTS_USER
twoturnmoveschargestringandanimation
setadditionaleffects @ only onChargeTurnOnly effects will work here
return

BattleScript_TwoTurnMovesSecondPowerHerbActivates:
call BattleScript_PowerHerbActivation
call BattleScript_TwoTurnMovesSecondTurnRet
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
.if B_UPDATED_MOVE_DATA < GEN_5 @ before Gen 5, charge moves did not print an attack string on the charge turn
attackstring
.endif
goto BattleScript_HitFromCritCalc

BattleScript_TwoTurnMovesSecondTurn::
attackcanceler
call BattleScript_TwoTurnMovesSecondTurnRet
orword gHitMarker, HITMARKER_NO_PPDEDUCT
goto BattleScript_HitFromAccCheck

BattleScript_TwoTurnMovesSecondTurnRet:
setbyte sB_ANIM_TURN, 1
clearstatusfromeffect BS_ATTACKER, MOVE_EFFECT_CHARGING
clearsemiinvulnerablebit @ only for moves with EFFECT_SEMI_INVULNERABLE/EFFECT_SKY_DROP
return

BattleScript_EffectSubstitute::
attackcanceler
ppreduce
Expand Down Expand Up @@ -4178,17 +4131,6 @@ BattleScript_PartyHealEnd::
waitstate
goto BattleScript_MoveEnd

BattleScript_EffectTripleKick::
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
jumpifmove MOVE_TRIPLE_AXEL BS_TripleAxel
addbyte sTRIPLE_KICK_POWER, 10 @ triple kick gets +10 power
goto BattleScript_HitFromAtkString

BS_TripleAxel:
addbyte sTRIPLE_KICK_POWER, 20 @ triple axel gets +20 power
goto BattleScript_HitFromAtkString

BattleScript_EffectMeanLook::
attackcanceler
attackstring
Expand Down Expand Up @@ -4654,23 +4596,6 @@ BattleScript_EffectMirrorCoat::
adjustdamage
goto BattleScript_HitFromAtkAnimation

BattleScript_EffectSkullBash::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_SKULL_BASH
call BattleScriptFirstChargingTurn
setstatchanger STAT_DEF, 1, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_SkullBashEnd
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_SkullBashEnd
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_SkullBashEnd::
jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_MoveEnd
call BattleScript_PowerHerbActivation
goto BattleScript_TwoTurnMovesSecondTurn

BattleScript_EffectFutureSight::
attackcanceler
attackstring
Expand All @@ -4682,25 +4607,6 @@ BattleScript_EffectFutureSight::
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd

BattleScript_EffectGust::
goto BattleScript_EffectHit

BattleScript_EffectSolarBeam::
jumpifweatheraffected BS_ATTACKER, B_WEATHER_SUN, BattleScript_SolarBeamOnFirstTurn
BattleScript_SolarBeamDecideTurn::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_SOLAR_BEAM
call BattleScriptFirstChargingTurn
jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_MoveEnd
call BattleScript_PowerHerbActivation
goto BattleScript_TwoTurnMovesSecondTurn
BattleScript_SolarBeamOnFirstTurn::
orword gHitMarker, HITMARKER_CHARGING
seteffectprimary MOVE_EFFECT_CHARGING | MOVE_EFFECT_AFFECTS_USER
ppreduce
goto BattleScript_TwoTurnMovesSecondTurn

BattleScript_EffectTeleport::
.if B_TELEPORT_BEHAVIOR >= GEN_7
jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_EffectBatonPass
Expand Down Expand Up @@ -4765,46 +4671,6 @@ BattleScript_BeatUpEnd::
end
.endif

BattleScript_EffectSemiInvulnerable::
jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_SecondTurnSemiInvulnerable
jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_SecondTurnSemiInvulnerable
jumpifmove MOVE_FLY, BattleScript_FirstTurnFly
jumpifmove MOVE_DIVE, BattleScript_FirstTurnDive
jumpifmove MOVE_BOUNCE, BattleScript_FirstTurnBounce
jumpifmove MOVE_PHANTOM_FORCE, BattleScript_FirstTurnPhantomForce
jumpifmove MOVE_SHADOW_FORCE, BattleScript_FirstTurnPhantomForce
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_DIG
goto BattleScript_FirstTurnSemiInvulnerable
BattleScript_FirstTurnBounce::
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_BOUNCE
goto BattleScript_FirstTurnSemiInvulnerable
BattleScript_FirstTurnDive::
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_DIVE
goto BattleScript_FirstTurnSemiInvulnerable
BattleScript_FirstTurnPhantomForce:
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_PHANTOM_FORCE
goto BattleScript_FirstTurnSemiInvulnerable
BattleScript_FirstTurnFly::
setbyte sTWOTURN_STRINGID, B_MSG_TURN1_FLY
BattleScript_FirstTurnSemiInvulnerable::
call BattleScriptFirstChargingTurn
setsemiinvulnerablebit
jumpifnoholdeffect BS_ATTACKER, HOLD_EFFECT_POWER_HERB, BattleScript_MoveEnd
call BattleScript_PowerHerbActivation
BattleScript_SecondTurnSemiInvulnerable::
attackcanceler
setbyte sB_ANIM_TURN, 1
clearstatusfromeffect BS_ATTACKER, MOVE_EFFECT_CHARGING
orword gHitMarker, HITMARKER_NO_PPDEDUCT
BattleScript_SemiInvulnerableTryHit::
accuracycheck BattleScript_SemiInvulnerableMiss, ACC_CURR_MOVE
clearsemiinvulnerablebit
goto BattleScript_HitFromAtkString

BattleScript_SemiInvulnerableMiss::
clearsemiinvulnerablebit
goto BattleScript_PrintMoveMissed

BattleScript_EffectDefenseCurl::
attackcanceler
attackstring
Expand Down Expand Up @@ -5544,9 +5410,6 @@ BattleScript_CosmicPowerTrySpDef::
BattleScript_CosmicPowerEnd::
goto BattleScript_MoveEnd

BattleScript_EffectSkyUppercut::
goto BattleScript_EffectHit

BattleScript_EffectBulkUp::
attackcanceler
attackstring
Expand Down
Loading

0 comments on commit 65c508d

Please sign in to comment.