From 59c95c32db40773008e6554544003a35a6a29fde Mon Sep 17 00:00:00 2001 From: Avara <31101124+Mother-Of-Dragons@users.noreply.github.com> Date: Wed, 21 Feb 2018 00:26:12 +0000 Subject: [PATCH 01/11] Fixed label names: battle_ai_scripts.s --- data/battle_ai_scripts.s | 2808 +++++++++++++++++++------------------- 1 file changed, 1404 insertions(+), 1404 deletions(-) diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 430f9f403..70cc48d9b 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -50,48 +50,48 @@ AI_CheckBadMove: if_move MOVE_FISSURE, BattleAIScript_82DBF92 if_move MOVE_HORN_DRILL, BattleAIScript_82DBF92 get_how_powerful_move_is - if_equal 0, BattleAIScript_82DBFFE + if_equal 0, AI_CheckBadMove_CheckSoundproof -BattleAIScript_82DBF92: +BattleAIScript_82DBF92: @ 82DBF92 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_ability AI_TARGET - if_equal ABILITY_VOLT_ABSORB, BattleAIScript_82DBFBD - if_equal ABILITY_WATER_ABSORB, BattleAIScript_82DBFCA - if_equal ABILITY_FLASH_FIRE, BattleAIScript_82DBFD7 - if_equal ABILITY_WONDER_GUARD, BattleAIScript_82DBFE4 - if_equal ABILITY_LEVITATE, BattleAIScript_82DBFEF + if_equal ABILITY_VOLT_ABSORB, CheckIfVoltAbsorbCancelsElectric + if_equal ABILITY_WATER_ABSORB, CheckIfWaterAbsorbCancelsWater + if_equal ABILITY_FLASH_FIRE, CheckIfFlashFireCancelsFire + if_equal ABILITY_WONDER_GUARD, CheckIfWonderGuardCancelsMove + if_equal ABILITY_LEVITATE, CheckIfLevitateCancelsGroundMove goto BattleAIScript_82DBFF7 -BattleAIScript_82DBFBD: +CheckIfVoltAbsorbCancelsElectric: @ 82DBFBD get_curr_move_type if_equal_ TYPE_ELECTRIC, Score_Minus12 goto BattleAIScript_82DBFF7 -BattleAIScript_82DBFCA: +CheckIfWaterAbsorbCancelsWater: @ 82DBFCA get_curr_move_type if_equal_ TYPE_WATER, Score_Minus12 goto BattleAIScript_82DBFF7 -BattleAIScript_82DBFD7: +CheckIfFlashFireCancelsFire: @ 82DBFD7 get_curr_move_type if_equal_ TYPE_FIRE, Score_Minus12 goto BattleAIScript_82DBFF7 -BattleAIScript_82DBFE4: +CheckIfWonderGuardCancelsMove: @ 82DBFE4 if_type_effectiveness AI_EFFECTIVENESS_x2, BattleAIScript_82DBFF7 goto Score_Minus10 -BattleAIScript_82DBFEF: +CheckIfLevitateCancelsGroundMove: @ 82DBFEF get_curr_move_type if_equal_ TYPE_GROUND, Score_Minus10 -BattleAIScript_82DBFF7: +BattleAIScript_82DBFF7: @ 82DBFF7 get_how_powerful_move_is - if_equal 0, BattleAIScript_82DBFFE + if_equal 0, AI_CheckBadMove_CheckSoundproof -BattleAIScript_82DBFFE: +AI_CheckBadMove_CheckSoundproof: @ 82DBFFE get_ability AI_TARGET - if_not_equal ABILITY_SOUNDPROOF, BattleAIScript_82DC045 + if_not_equal ABILITY_SOUNDPROOF, AI_CheckBadMove_CheckEffect if_move MOVE_GROWL, Score_Minus10 if_move MOVE_ROAR, Score_Minus10 if_move MOVE_SING, Score_Minus10 @@ -102,119 +102,119 @@ BattleAIScript_82DBFFE: if_move MOVE_METAL_SOUND, Score_Minus10 if_move MOVE_GRASS_WHISTLE, Score_Minus10 -BattleAIScript_82DC045: - if_effect EFFECT_SLEEP, BattleAIScript_82DC2D4 - if_effect EFFECT_EXPLOSION, BattleAIScript_82DC2F7 - if_effect EFFECT_DREAM_EATER, BattleAIScript_82DC330 - if_effect EFFECT_ATTACK_UP, BattleAIScript_82DC348 - if_effect EFFECT_DEFENSE_UP, BattleAIScript_82DC351 - if_effect EFFECT_SPEED_UP, BattleAIScript_82DC35A - if_effect EFFECT_SPECIAL_ATTACK_UP, BattleAIScript_82DC363 - if_effect EFFECT_SPECIAL_DEFENSE_UP, BattleAIScript_82DC36C - if_effect EFFECT_ACCURACY_UP, BattleAIScript_82DC375 - if_effect EFFECT_EVASION_UP, BattleAIScript_82DC37E - if_effect EFFECT_ATTACK_DOWN, BattleAIScript_82DC387 - if_effect EFFECT_DEFENSE_DOWN, BattleAIScript_82DC39C - if_effect EFFECT_SPEED_DOWN, BattleAIScript_82DC3A9 - if_effect EFFECT_SPECIAL_ATTACK_DOWN, BattleAIScript_82DC3BF - if_effect EFFECT_SPECIAL_DEFENSE_DOWN, BattleAIScript_82DC3CC - if_effect EFFECT_ACCURACY_DOWN, BattleAIScript_82DC3D9 - if_effect EFFECT_EVASION_DOWN, BattleAIScript_82DC3EE - if_effect EFFECT_HAZE, BattleAIScript_82DC405 - if_effect EFFECT_BIDE, BattleAIScript_82DC4ED - if_effect EFFECT_ROAR, BattleAIScript_82DC47B - if_effect EFFECT_TOXIC, BattleAIScript_82DC48C - if_effect EFFECT_LIGHT_SCREEN, BattleAIScript_82DC4C5 - if_effect EFFECT_OHKO, BattleAIScript_82DC4D0 - if_effect EFFECT_RAZOR_WIND, BattleAIScript_82DC4ED - if_effect EFFECT_SUPER_FANG, BattleAIScript_82DC4ED - if_effect EFFECT_MIST, BattleAIScript_82DC507 - if_effect EFFECT_FOCUS_ENERGY, BattleAIScript_82DC512 - if_effect EFFECT_CONFUSE, BattleAIScript_82DC51D - if_effect EFFECT_ATTACK_UP_2, BattleAIScript_82DC348 - if_effect EFFECT_DEFENSE_UP_2, BattleAIScript_82DC351 - if_effect EFFECT_SPEED_UP_2, BattleAIScript_82DC35A - if_effect EFFECT_SPECIAL_ATTACK_UP_2, BattleAIScript_82DC363 - if_effect EFFECT_SPECIAL_DEFENSE_UP_2, BattleAIScript_82DC36C - if_effect EFFECT_ACCURACY_UP_2, BattleAIScript_82DC375 - if_effect EFFECT_EVASION_UP_2, BattleAIScript_82DC37E - if_effect EFFECT_ATTACK_DOWN_2, BattleAIScript_82DC387 - if_effect EFFECT_DEFENSE_DOWN_2, BattleAIScript_82DC39C - if_effect EFFECT_SPEED_DOWN_2, BattleAIScript_82DC3A9 - if_effect EFFECT_SPECIAL_ATTACK_DOWN_2, BattleAIScript_82DC3BF - if_effect EFFECT_SPECIAL_DEFENSE_DOWN_2, BattleAIScript_82DC3CC - if_effect EFFECT_ACCURACY_DOWN_2, BattleAIScript_82DC3D9 - if_effect EFFECT_EVASION_DOWN_2, BattleAIScript_82DC3EE - if_effect EFFECT_REFLECT, BattleAIScript_82DC53A - if_effect EFFECT_POISON, BattleAIScript_82DC48C - if_effect EFFECT_PARALYZE, BattleAIScript_82DC545 - if_effect EFFECT_SUBSTITUTE, BattleAIScript_82DC568 - if_effect EFFECT_RECHARGE, BattleAIScript_82DC4ED - if_effect EFFECT_LEECH_SEED, BattleAIScript_82DC57A - if_effect EFFECT_DISABLE, BattleAIScript_82DC595 - if_effect EFFECT_LEVEL_DAMAGE, BattleAIScript_82DC4ED - if_effect EFFECT_PSYWAVE, BattleAIScript_82DC4ED - if_effect EFFECT_COUNTER, BattleAIScript_82DC4ED - if_effect EFFECT_ENCORE, BattleAIScript_82DC59D - if_effect EFFECT_SNORE, BattleAIScript_82DC5A5 - if_effect EFFECT_SLEEP_TALK, BattleAIScript_82DC5A5 - if_effect EFFECT_FLAIL, BattleAIScript_82DC4ED - if_effect EFFECT_MEAN_LOOK, BattleAIScript_82DC5B0 - if_effect EFFECT_NIGHTMARE, BattleAIScript_82DC31B - if_effect EFFECT_MINIMIZE, BattleAIScript_82DC37E - if_effect EFFECT_CURSE, BattleAIScript_82DC5BB - if_effect EFFECT_SPIKES, BattleAIScript_82DC5CC - if_effect EFFECT_FORESIGHT, BattleAIScript_82DC5D7 - if_effect EFFECT_PERISH_SONG, BattleAIScript_82DC5E2 - if_effect EFFECT_SANDSTORM, BattleAIScript_82DC5ED - if_effect EFFECT_SWAGGER, BattleAIScript_82DC51D - if_effect EFFECT_ATTRACT, BattleAIScript_82DC5F5 - if_effect EFFECT_RETURN, BattleAIScript_82DC4ED - if_effect EFFECT_PRESENT, BattleAIScript_82DC4ED - if_effect EFFECT_FRUSTRATION, BattleAIScript_82DC4ED - if_effect EFFECT_SAFEGUARD, BattleAIScript_82DC635 - if_effect EFFECT_MAGNITUDE, BattleAIScript_82DC4E5 - if_effect EFFECT_BATON_PASS, BattleAIScript_82DC650 - if_effect EFFECT_SONICBOOM, BattleAIScript_82DC4ED - if_effect EFFECT_RAIN_DANCE, BattleAIScript_82DC659 - if_effect EFFECT_SUNNY_DAY, BattleAIScript_82DC661 - if_effect EFFECT_BELLY_DRUM, BattleAIScript_82DC341 - if_effect EFFECT_PSYCH_UP, BattleAIScript_82DC405 - if_effect EFFECT_MIRROR_COAT, BattleAIScript_82DC4ED - if_effect EFFECT_SKULL_BASH, BattleAIScript_82DC4ED - if_effect EFFECT_FUTURE_SIGHT, BattleAIScript_82DC669 +AI_CheckBadMove_CheckEffect: @ 82DC045 + if_effect EFFECT_SLEEP, AI_CBM_Sleep + if_effect EFFECT_EXPLOSION, AI_CBM_Explosion + if_effect EFFECT_DREAM_EATER, AI_CBM_DreamEater + if_effect EFFECT_ATTACK_UP, AI_CBM_AttackUp + if_effect EFFECT_DEFENSE_UP, AI_CBM_DefenseUp + if_effect EFFECT_SPEED_UP, AI_CBM_SpeedUp + if_effect EFFECT_SPECIAL_ATTACK_UP, AI_CBM_SpAtkUp + if_effect EFFECT_SPECIAL_DEFENSE_UP, AI_CBM_SpDefUp + if_effect EFFECT_ACCURACY_UP, AI_CBM_AccUp + if_effect EFFECT_EVASION_UP, AI_CBM_EvasionUp + if_effect EFFECT_ATTACK_DOWN, AI_CBM_AttackDown + if_effect EFFECT_DEFENSE_DOWN, AI_CBM_DefenseDown + if_effect EFFECT_SPEED_DOWN, AI_CBM_SpeedDown + if_effect EFFECT_SPECIAL_ATTACK_DOWN, AI_CBM_SpAtkDown + if_effect EFFECT_SPECIAL_DEFENSE_DOWN, AI_CBM_SpDefDown + if_effect EFFECT_ACCURACY_DOWN, AI_CBM_AccDown + if_effect EFFECT_EVASION_DOWN, AI_CBM_EvasionDown + if_effect EFFECT_HAZE, AI_CBM_Haze + if_effect EFFECT_BIDE, AI_CBM_HighRiskForDamage + if_effect EFFECT_ROAR, AI_CBM_Roar + if_effect EFFECT_TOXIC, AI_CBM_Toxic + if_effect EFFECT_LIGHT_SCREEN, AI_CBM_LightScreen + if_effect EFFECT_OHKO, AI_CBM_OneHitKO + if_effect EFFECT_RAZOR_WIND, AI_CBM_HighRiskForDamage + if_effect EFFECT_SUPER_FANG, AI_CBM_HighRiskForDamage + if_effect EFFECT_MIST, AI_CBM_Mist + if_effect EFFECT_FOCUS_ENERGY, AI_CBM_FocusEnergy + if_effect EFFECT_CONFUSE, AI_CBM_Confuse + if_effect EFFECT_ATTACK_UP_2, AI_CBM_AttackUp + if_effect EFFECT_DEFENSE_UP_2, AI_CBM_DefenseUp + if_effect EFFECT_SPEED_UP_2, AI_CBM_SpeedUp + if_effect EFFECT_SPECIAL_ATTACK_UP_2, AI_CBM_SpAtkUp + if_effect EFFECT_SPECIAL_DEFENSE_UP_2, AI_CBM_SpDefUp + if_effect EFFECT_ACCURACY_UP_2, AI_CBM_AccUp + if_effect EFFECT_EVASION_UP_2, AI_CBM_EvasionUp + if_effect EFFECT_ATTACK_DOWN_2, AI_CBM_AttackDown + if_effect EFFECT_DEFENSE_DOWN_2, AI_CBM_DefenseDown + if_effect EFFECT_SPEED_DOWN_2, AI_CBM_SpeedDown + if_effect EFFECT_SPECIAL_ATTACK_DOWN_2, AI_CBM_SpAtkDown + if_effect EFFECT_SPECIAL_DEFENSE_DOWN_2, AI_CBM_SpDefDown + if_effect EFFECT_ACCURACY_DOWN_2, AI_CBM_AccDown + if_effect EFFECT_EVASION_DOWN_2, AI_CBM_EvasionDown + if_effect EFFECT_REFLECT, AI_CBM_Reflect + if_effect EFFECT_POISON, AI_CBM_Toxic + if_effect EFFECT_PARALYZE, AI_CBM_Paralyze + if_effect EFFECT_SUBSTITUTE, AI_CBM_Substitute + if_effect EFFECT_RECHARGE, AI_CBM_HighRiskForDamage + if_effect EFFECT_LEECH_SEED, AI_CBM_LeechSeed + if_effect EFFECT_DISABLE, AI_CBM_Disable + if_effect EFFECT_LEVEL_DAMAGE, AI_CBM_HighRiskForDamage + if_effect EFFECT_PSYWAVE, AI_CBM_HighRiskForDamage + if_effect EFFECT_COUNTER, AI_CBM_HighRiskForDamage + if_effect EFFECT_ENCORE, AI_CBM_Encore + if_effect EFFECT_SNORE, AI_CBM_DamageDuringSleep + if_effect EFFECT_SLEEP_TALK, AI_CBM_DamageDuringSleep + if_effect EFFECT_FLAIL, AI_CBM_HighRiskForDamage + if_effect EFFECT_MEAN_LOOK, AI_CBM_CantEscape + if_effect EFFECT_NIGHTMARE, AI_CBM_Nightmare + if_effect EFFECT_MINIMIZE, AI_CBM_EvasionUp + if_effect EFFECT_CURSE, AI_CBM_Curse + if_effect EFFECT_SPIKES, AI_CBM_Spikes + if_effect EFFECT_FORESIGHT, AI_CBM_Foresight + if_effect EFFECT_PERISH_SONG, AI_CBM_PerishSong + if_effect EFFECT_SANDSTORM, AI_CBM_Sandstorm + if_effect EFFECT_SWAGGER, AI_CBM_Confuse + if_effect EFFECT_ATTRACT, AI_CBM_Attract + if_effect EFFECT_RETURN, AI_CBM_HighRiskForDamage + if_effect EFFECT_PRESENT, AI_CBM_HighRiskForDamage + if_effect EFFECT_FRUSTRATION, AI_CBM_HighRiskForDamage + if_effect EFFECT_SAFEGUARD, AI_CBM_Safeguard + if_effect EFFECT_MAGNITUDE, AI_CBM_Magnitude + if_effect EFFECT_BATON_PASS, AI_CBM_BatonPass + if_effect EFFECT_SONICBOOM, AI_CBM_HighRiskForDamage + if_effect EFFECT_RAIN_DANCE, AI_CBM_RainDance + if_effect EFFECT_SUNNY_DAY, AI_CBM_SunnyDay + if_effect EFFECT_BELLY_DRUM, AI_CBM_BellyDrum + if_effect EFFECT_PSYCH_UP, AI_CBM_Haze + if_effect EFFECT_MIRROR_COAT, AI_CBM_HighRiskForDamage + if_effect EFFECT_SKULL_BASH, AI_CBM_HighRiskForDamage + if_effect EFFECT_FUTURE_SIGHT, AI_CBM_FutureSight if_effect EFFECT_TELEPORT, Score_Minus10 - if_effect EFFECT_DEFENSE_CURL, BattleAIScript_82DC351 - if_effect EFFECT_FAKE_OUT, BattleAIScript_82DC680 - if_effect EFFECT_STOCKPILE, BattleAIScript_82DC689 - if_effect EFFECT_SPIT_UP, BattleAIScript_82DC692 - if_effect EFFECT_SWALLOW, BattleAIScript_82DC692 - if_effect EFFECT_HAIL, BattleAIScript_82DC6A1 - if_effect EFFECT_TORMENT, BattleAIScript_82DC6A9 - if_effect EFFECT_FLATTER, BattleAIScript_82DC51D - if_effect EFFECT_WILL_O_WISP, BattleAIScript_82DC6B4 - if_effect EFFECT_MEMENTO, BattleAIScript_82DC640 - if_effect EFFECT_FOCUS_PUNCH, BattleAIScript_82DC4ED - if_effect EFFECT_HELPING_HAND, BattleAIScript_82DC6E3 - if_effect EFFECT_TRICK, BattleAIScript_82DC6EB - if_effect EFFECT_INGRAIN, BattleAIScript_82DC6F4 - if_effect EFFECT_SUPERPOWER, BattleAIScript_82DC4ED - if_effect EFFECT_RECYCLE, BattleAIScript_82DC6FF - if_effect EFFECT_KNOCK_OFF, BattleAIScript_82DC6EB - if_effect EFFECT_ENDEAVOR, BattleAIScript_82DC4ED - if_effect EFFECT_IMPRISON, BattleAIScript_82DC708 - if_effect EFFECT_REFRESH, BattleAIScript_82DC713 - if_effect EFFECT_LOW_KICK, BattleAIScript_82DC4ED - if_effect EFFECT_MUD_SPORT, BattleAIScript_82DC71E - if_effect EFFECT_TICKLE, BattleAIScript_82DC729 - if_effect EFFECT_COSMIC_POWER, BattleAIScript_82DC73A - if_effect EFFECT_BULK_UP, BattleAIScript_82DC74B - if_effect EFFECT_WATER_SPORT, BattleAIScript_82DC75C - if_effect EFFECT_CALM_MIND, BattleAIScript_82DC767 - if_effect EFFECT_DRAGON_DANCE, BattleAIScript_82DC778 + if_effect EFFECT_DEFENSE_CURL, AI_CBM_DefenseUp + if_effect EFFECT_FAKE_OUT, AI_CBM_FakeOut + if_effect EFFECT_STOCKPILE, AI_CBM_Stockpile + if_effect EFFECT_SPIT_UP, AI_CBM_SpitUpAndSwallow + if_effect EFFECT_SWALLOW, AI_CBM_SpitUpAndSwallow + if_effect EFFECT_HAIL, AI_CBM_Hail + if_effect EFFECT_TORMENT, AI_CBM_Torment + if_effect EFFECT_FLATTER, AI_CBM_Confuse + if_effect EFFECT_WILL_O_WISP, AI_CBM_WillOWisp + if_effect EFFECT_MEMENTO, AI_CBM_Memento + if_effect EFFECT_FOCUS_PUNCH, AI_CBM_HighRiskForDamage + if_effect EFFECT_HELPING_HAND, AI_CBM_HelpingHand + if_effect EFFECT_TRICK, AI_CBM_TrickAndKnockOff + if_effect EFFECT_INGRAIN, AI_CBM_Ingrain + if_effect EFFECT_SUPERPOWER, AI_CBM_HighRiskForDamage + if_effect EFFECT_RECYCLE, AI_CBM_Recycle + if_effect EFFECT_KNOCK_OFF, AI_CBM_TrickAndKnockOff + if_effect EFFECT_ENDEAVOR, AI_CBM_HighRiskForDamage + if_effect EFFECT_IMPRISON, AI_CBM_Imprison + if_effect EFFECT_REFRESH, AI_CBM_Refresh + if_effect EFFECT_LOW_KICK, AI_CBM_HighRiskForDamage + if_effect EFFECT_MUD_SPORT, AI_CBM_MudSport + if_effect EFFECT_TICKLE, AI_CBM_Tickle + if_effect EFFECT_COSMIC_POWER, AI_CBM_CosmicPower + if_effect EFFECT_BULK_UP, AI_CBM_BulkUp + if_effect EFFECT_WATER_SPORT, AI_CBM_WaterSport + if_effect EFFECT_CALM_MIND, AI_CBM_CalmMind + if_effect EFFECT_DRAGON_DANCE, AI_CBM_DragonDance end -BattleAIScript_82DC2D4: +AI_CBM_Sleep: @ 82DC2D4 get_ability AI_TARGET if_equal ABILITY_INSOMNIA, Score_Minus10 if_equal ABILITY_VITAL_SPIRIT, Score_Minus10 @@ -222,126 +222,126 @@ BattleAIScript_82DC2D4: if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end -BattleAIScript_82DC2F7: +AI_CBM_Explosion: @ 82DC2F7 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_DAMP, Score_Minus10 count_usable_party_mons AI_USER - if_not_equal 0, BattleAIScript_82DC31A + if_not_equal 0, AI_CBM_Explosion_End count_usable_party_mons AI_TARGET if_not_equal 0, Score_Minus10 goto Score_Minus1 -BattleAIScript_82DC31A: +AI_CBM_Explosion_End: @ 82DC31A end -BattleAIScript_82DC31B: +AI_CBM_Nightmare: @ 82DC31B if_status2 AI_TARGET, STATUS2_NIGHTMARE, Score_Minus10 if_not_status AI_TARGET, STATUS1_SLEEP, Score_Minus8 end -BattleAIScript_82DC330: +AI_CBM_DreamEater: @ 82DC330 if_not_status AI_TARGET, STATUS1_SLEEP, Score_Minus8 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 end -BattleAIScript_82DC341: +AI_CBM_BellyDrum: @ 82DC341 if_hp_less_than AI_USER, 51, Score_Minus10 -BattleAIScript_82DC348: +AI_CBM_AttackUp: @ 82DC348 if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 end -BattleAIScript_82DC351: +AI_CBM_DefenseUp: @ 82DC351 if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus10 end -BattleAIScript_82DC35A: +AI_CBM_SpeedUp: @ 82DC35A if_stat_level_equal AI_USER, STAT_SPEED, 12, Score_Minus10 end -BattleAIScript_82DC363: +AI_CBM_SpAtkUp: @ 82DC363 if_stat_level_equal AI_USER, STAT_SPATK, 12, Score_Minus10 end -BattleAIScript_82DC36C: +AI_CBM_SpDefUp: @ 82DC36C if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus10 end -BattleAIScript_82DC375: +AI_CBM_AccUp: @ 82DC375 if_stat_level_equal AI_USER, STAT_ACC, 12, Score_Minus10 end -BattleAIScript_82DC37E: +AI_CBM_EvasionUp: @ 82DC37E if_stat_level_equal AI_USER, STAT_EVASION, 12, Score_Minus10 end -BattleAIScript_82DC387: +AI_CBM_AttackDown: @ 82DC387 if_stat_level_equal AI_TARGET, STAT_ATK, 0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_HYPER_CUTTER, Score_Minus10 - goto BattleAIScript_82DC3F6 + goto CheckIfAbilityBlocksStatChange -BattleAIScript_82DC39C: +AI_CBM_DefenseDown: @ 82DC39C if_stat_level_equal AI_TARGET, STAT_DEF, 0, Score_Minus10 - goto BattleAIScript_82DC3F6 + goto CheckIfAbilityBlocksStatChange -BattleAIScript_82DC3A9: +AI_CBM_SpeedDown: @ 82DC3A9 if_stat_level_equal AI_TARGET, STAT_SPEED, 0, Score_Minus10 if_ability AI_TARGET, ABILITY_SPEED_BOOST, Score_Minus10 - goto BattleAIScript_82DC3F6 + goto CheckIfAbilityBlocksStatChange -BattleAIScript_82DC3BF: +AI_CBM_SpAtkDown: @ 82DC3BF if_stat_level_equal AI_TARGET, STAT_SPATK, 0, Score_Minus10 - goto BattleAIScript_82DC3F6 + goto CheckIfAbilityBlocksStatChange -BattleAIScript_82DC3CC: +AI_CBM_SpDefDown: @ 82DC3CC if_stat_level_equal AI_TARGET, STAT_SPDEF, 0, Score_Minus10 - goto BattleAIScript_82DC3F6 + goto CheckIfAbilityBlocksStatChange -BattleAIScript_82DC3D9: +AI_CBM_AccDown: @ 82DC3D9 if_stat_level_equal AI_TARGET, STAT_ACC, 0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_KEEN_EYE, Score_Minus10 - goto BattleAIScript_82DC3F6 + goto CheckIfAbilityBlocksStatChange -BattleAIScript_82DC3EE: +AI_CBM_EvasionDown: @ 82DC3EE if_stat_level_equal AI_TARGET, STAT_EVASION, 0, Score_Minus10 -BattleAIScript_82DC3F6: +CheckIfAbilityBlocksStatChange: @ 82DC3F6 get_ability AI_TARGET if_equal ABILITY_CLEAR_BODY, Score_Minus10 if_equal ABILITY_WHITE_SMOKE, Score_Minus10 end -BattleAIScript_82DC405: - if_stat_level_less_than AI_USER, STAT_ATK, 6, BattleAIScript_82DC47A - if_stat_level_less_than AI_USER, STAT_DEF, 6, BattleAIScript_82DC47A - if_stat_level_less_than AI_USER, STAT_SPEED, 6, BattleAIScript_82DC47A - if_stat_level_less_than AI_USER, STAT_SPATK, 6, BattleAIScript_82DC47A - if_stat_level_less_than AI_USER, STAT_SPDEF, 6, BattleAIScript_82DC47A - if_stat_level_less_than AI_USER, STAT_ACC, 6, BattleAIScript_82DC47A - if_stat_level_less_than AI_USER, STAT_EVASION, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_ATK, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_DEF, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_SPEED, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_SPATK, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_SPDEF, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_ACC, 6, BattleAIScript_82DC47A - if_stat_level_more_than AI_TARGET, STAT_EVASION, 6, BattleAIScript_82DC47A +AI_CBM_Haze: @ 82DC405 + if_stat_level_less_than AI_USER, STAT_ATK, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_DEF, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_SPEED, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_SPATK, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_SPDEF, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_ACC, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_EVASION, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_ATK, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_DEF, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_SPEED, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_SPATK, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_SPDEF, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_ACC, 6, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_EVASION, 6, AI_CBM_Haze_End goto Score_Minus10 -BattleAIScript_82DC47A: +AI_CBM_Haze_End: @ 82DC47A end -BattleAIScript_82DC47B: +AI_CBM_Roar: @ 82DC47B count_usable_party_mons AI_TARGET if_equal 0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_SUCTION_CUPS, Score_Minus10 end -BattleAIScript_82DC48C: +AI_CBM_Toxic: @ 82DC48C get_target_type1 if_equal TYPE_STEEL, Score_Minus10 if_equal TYPE_POISON, Score_Minus10 @@ -354,51 +354,51 @@ BattleAIScript_82DC48C: if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end -BattleAIScript_82DC4C5: +AI_CBM_LightScreen: @ 82DC4C5 if_side_affecting AI_USER, SIDE_STATUS_LIGHTSCREEN, Score_Minus8 end -BattleAIScript_82DC4D0: +AI_CBM_OneHitKO: @ 82DC4D0 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_STURDY, Score_Minus10 if_level_cond 1, Score_Minus10 end -BattleAIScript_82DC4E5: +AI_CBM_Magnitude: @ 82DC4E5 get_ability AI_TARGET if_equal ABILITY_LEVITATE, Score_Minus10 -BattleAIScript_82DC4ED: +AI_CBM_HighRiskForDamage: @ 82DC4ED if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_ability AI_TARGET - if_not_equal ABILITY_WONDER_GUARD, BattleAIScript_82DC506 - if_type_effectiveness AI_EFFECTIVENESS_x2, BattleAIScript_82DC506 + if_not_equal ABILITY_WONDER_GUARD, AI_CBM_HighRiskForDamage_End + if_type_effectiveness AI_EFFECTIVENESS_x2, AI_CBM_HighRiskForDamage_End goto Score_Minus10 -BattleAIScript_82DC506: +AI_CBM_HighRiskForDamage_End: @ 82DC506 end -BattleAIScript_82DC507: +AI_CBM_Mist: @ 82DC507 if_side_affecting AI_USER, SIDE_STATUS_MIST, Score_Minus8 end -BattleAIScript_82DC512: +AI_CBM_FocusEnergy: @ 82DC512 if_status2 AI_USER, STATUS2_FOCUS_ENERGY, Score_Minus10 end -BattleAIScript_82DC51D: +AI_CBM_Confuse: @ 82DC51D if_status2 AI_TARGET, STATUS2_CONFUSION, Score_Minus5 get_ability AI_TARGET if_equal ABILITY_OWN_TEMPO, Score_Minus10 if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end -BattleAIScript_82DC53A: +AI_CBM_Reflect: @ 82DC53A if_side_affecting AI_USER, SIDE_STATUS_REFLECT, Score_Minus8 end -BattleAIScript_82DC545: +AI_CBM_Paralyze: @ 82DC545 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_LIMBER, Score_Minus10 @@ -406,12 +406,12 @@ BattleAIScript_82DC545: if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end -BattleAIScript_82DC568: +AI_CBM_Substitute: @ 82DC568 if_status2 AI_USER, STATUS2_SUBSTITUTE, Score_Minus8 if_hp_less_than AI_USER, 26, Score_Minus10 end -BattleAIScript_82DC57A: +AI_CBM_LeechSeed: @ 82DC57A if_status3 AI_TARGET, STATUS3_LEECHSEED, Score_Minus10 get_target_type1 if_equal TYPE_GRASS, Score_Minus10 @@ -419,121 +419,121 @@ BattleAIScript_82DC57A: if_equal TYPE_GRASS, Score_Minus10 end -BattleAIScript_82DC595: +AI_CBM_Disable: @ 82DC595 if_any_move_disabled AI_TARGET, Score_Minus8 end -BattleAIScript_82DC59D: +AI_CBM_Encore: @ 82DC59D if_any_move_encored AI_TARGET, Score_Minus8 end -BattleAIScript_82DC5A5: +AI_CBM_DamageDuringSleep: @ 82DC5A5 if_not_status AI_USER, STATUS1_SLEEP, Score_Minus8 end -BattleAIScript_82DC5B0: +AI_CBM_CantEscape: @ 82DC5B0 if_status2 AI_TARGET, STATUS2_ESCAPE_PREVENTION, Score_Minus10 end -BattleAIScript_82DC5BB: +AI_CBM_Curse: @ 82DC5BB if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus8 end -BattleAIScript_82DC5CC: +AI_CBM_Spikes: @ 82DC5CC if_side_affecting AI_TARGET, SIDE_STATUS_SPIKES, Score_Minus10 end -BattleAIScript_82DC5D7: +AI_CBM_Foresight: @ 82DC5D7 if_status2 AI_TARGET, STATUS2_FORESIGHT, Score_Minus10 end -BattleAIScript_82DC5E2: +AI_CBM_PerishSong: @ 82DC5E2 if_status3 AI_TARGET, STATUS3_PERISH_SONG, Score_Minus10 end -BattleAIScript_82DC5ED: +AI_CBM_Sandstorm: @ 82DC5ED get_weather if_equal AI_WEATHER_SANDSTORM, Score_Minus8 end -BattleAIScript_82DC5F5: +AI_CBM_Attract: @ 82DC5F5 if_status2 AI_TARGET, STATUS2_INFATUATION, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_OBLIVIOUS, Score_Minus10 get_gender AI_USER - if_equal 0, BattleAIScript_82DC61A - if_equal 254, BattleAIScript_82DC627 + if_equal 0, AI_CBM_Attract_CheckIfTargetIsFemale + if_equal 254, AI_CBM_Attract_CheckIfTargetIsMale goto Score_Minus10 -BattleAIScript_82DC61A: +AI_CBM_Attract_CheckIfTargetIsFemale: @ 82DC61A get_gender AI_TARGET - if_equal 254, BattleAIScript_82DC634 + if_equal 254, AI_CBM_Attract_End goto Score_Minus10 -BattleAIScript_82DC627: +AI_CBM_Attract_CheckIfTargetIsMale: @ 82DC627 get_gender AI_TARGET - if_equal 0, BattleAIScript_82DC634 + if_equal 0, AI_CBM_Attract_End goto Score_Minus10 -BattleAIScript_82DC634: +AI_CBM_Attract_End: @ 82DC634 end -BattleAIScript_82DC635: +AI_CBM_Safeguard: @ 82DC635 if_side_affecting AI_USER, SIDE_STATUS_SAFEGUARD, Score_Minus8 end -BattleAIScript_82DC640: +AI_CBM_Memento: @ 82DC640 if_stat_level_equal AI_TARGET, STAT_ATK, 0, Score_Minus10 if_stat_level_equal AI_TARGET, STAT_SPATK, 0, Score_Minus8 -BattleAIScript_82DC650: +AI_CBM_BatonPass: @ 82DC650 count_usable_party_mons AI_USER if_equal 0, Score_Minus10 end -BattleAIScript_82DC659: +AI_CBM_RainDance: @ 82DC659 get_weather if_equal AI_WEATHER_RAIN, Score_Minus8 end -BattleAIScript_82DC661: +AI_CBM_SunnyDay: @ 82DC661 get_weather if_equal AI_WEATHER_SUN, Score_Minus8 end -BattleAIScript_82DC669: +AI_CBM_FutureSight: @ 82DC669 if_side_affecting AI_TARGET, SIDE_STATUS_FUTUREATTACK, Score_Minus12 if_side_affecting AI_USER, SIDE_STATUS_FUTUREATTACK, Score_Minus12 score +5 end -BattleAIScript_82DC680: +AI_CBM_FakeOut: @ 82DC680 is_first_turn_for AI_USER if_equal 0, Score_Minus10 end -BattleAIScript_82DC689: +AI_CBM_Stockpile: @ 82DC689 get_stockpile_count AI_USER if_equal 3, Score_Minus10 end -BattleAIScript_82DC692: +AI_CBM_SpitUpAndSwallow: @ 82DC692 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_stockpile_count AI_USER if_equal 0, Score_Minus10 end -BattleAIScript_82DC6A1: +AI_CBM_Hail: @ 82DC6A1 get_weather if_equal AI_WEATHER_HAIL, Score_Minus8 end -BattleAIScript_82DC6A9: +AI_CBM_Torment: @ 82DC6A9 if_status2 AI_TARGET, STATUS2_TORMENT, Score_Minus10 end -BattleAIScript_82DC6B4: +AI_CBM_WillOWisp: @ 82DC6B4 get_ability AI_TARGET if_equal ABILITY_WATER_VEIL, Score_Minus10 if_status AI_TARGET, STATUS1_ANY, Score_Minus10 @@ -543,61 +543,61 @@ BattleAIScript_82DC6B4: if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end -BattleAIScript_82DC6E3: +AI_CBM_HelpingHand: @ 82DC6E3 if_not_double_battle Score_Minus10 end -BattleAIScript_82DC6EB: +AI_CBM_TrickAndKnockOff: @ 82DC6EB get_ability AI_TARGET if_equal ABILITY_STICKY_HOLD, Score_Minus10 end -BattleAIScript_82DC6F4: +AI_CBM_Ingrain: @ 82DC6F4 if_status3 AI_USER, STATUS3_ROOTED, Score_Minus10 end -BattleAIScript_82DC6FF: +AI_CBM_Recycle: @ 82DC6FF get_used_held_item AI_USER if_equal 0, Score_Minus10 end -BattleAIScript_82DC708: +AI_CBM_Imprison: @ 82DC708 if_status3 AI_USER, STATUS3_IMPRISONED_OTHERS, Score_Minus10 end -BattleAIScript_82DC713: +AI_CBM_Refresh: @ 82DC713 if_not_status AI_USER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, Score_Minus10 end -BattleAIScript_82DC71E: +AI_CBM_MudSport: @ 82DC71E if_status3 AI_USER, STATUS3_MUDSPORT, Score_Minus10 end -BattleAIScript_82DC729: +AI_CBM_Tickle: @ 82DC729 if_stat_level_equal AI_TARGET, STAT_ATK, 0, Score_Minus10 if_stat_level_equal AI_TARGET, STAT_DEF, 0, Score_Minus8 end -BattleAIScript_82DC73A: +AI_CBM_CosmicPower: @ 82DC73A if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus10 if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus8 end -BattleAIScript_82DC74B: +AI_CBM_BulkUp: @ 82DC74B if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus8 end -BattleAIScript_82DC75C: +AI_CBM_WaterSport: @ 82DC75C if_status3 AI_USER, STATUS3_WATERSPORT, Score_Minus10 end -BattleAIScript_82DC767: +AI_CBM_CalmMind: @ 82DC767 if_stat_level_equal AI_USER, STAT_SPATK, 12, Score_Minus10 if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus8 end -BattleAIScript_82DC778: +AI_CBM_DragonDance: @ 82DC778 if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 if_stat_level_equal AI_USER, STAT_SPEED, 12, Score_Minus8 end @@ -656,214 +656,214 @@ Score_Plus10: AI_TryToFaint: if_target_is_ally AI_Ret - if_effect EFFECT_SLEEP, BattleAIScript_82DCA92 - if_effect EFFECT_ABSORB, BattleAIScript_82DCAAE - if_effect EFFECT_EXPLOSION, BattleAIScript_82DCAC8 - if_effect EFFECT_DREAM_EATER, BattleAIScript_82DCB26 - if_effect EFFECT_MIRROR_MOVE, BattleAIScript_82DCB3A - if_effect EFFECT_ATTACK_UP, BattleAIScript_82DCBBC - if_effect EFFECT_DEFENSE_UP, BattleAIScript_82DCBF7 - if_effect EFFECT_SPEED_UP, BattleAIScript_82DCC5D - if_effect EFFECT_SPECIAL_ATTACK_UP, BattleAIScript_82DCC73 - if_effect EFFECT_SPECIAL_DEFENSE_UP, BattleAIScript_82DCCAE - if_effect EFFECT_ACCURACY_UP, BattleAIScript_82DCD14 - if_effect EFFECT_EVASION_UP, BattleAIScript_82DCD2E - if_effect EFFECT_ALWAYS_HIT, BattleAIScript_82DCDC8 - if_effect EFFECT_ATTACK_DOWN, BattleAIScript_82DCDF8 - if_effect EFFECT_DEFENSE_DOWN, BattleAIScript_82DCE4A - if_effect EFFECT_SPEED_DOWN, BattleAIScript_82DCE81 - if_effect EFFECT_SPECIAL_ATTACK_DOWN, BattleAIScript_82DCE97 - if_effect EFFECT_SPECIAL_DEFENSE_DOWN, BattleAIScript_82DCEEB - if_effect EFFECT_ACCURACY_DOWN, BattleAIScript_82DCF0C - if_effect EFFECT_EVASION_DOWN, BattleAIScript_82DCFA0 - if_effect EFFECT_HAZE, BattleAIScript_82DCFC1 - if_effect EFFECT_BIDE, BattleAIScript_82DD084 - if_effect EFFECT_ROAR, BattleAIScript_82DD08E - if_effect EFFECT_CONVERSION, BattleAIScript_82DD0C6 - if_effect EFFECT_RESTORE_HP, BattleAIScript_82DD0F7 - if_effect EFFECT_TOXIC, BattleAIScript_82DD150 - if_effect EFFECT_LIGHT_SCREEN, BattleAIScript_82DD18F - if_effect EFFECT_REST, BattleAIScript_82DD1BE - if_effect EFFECT_OHKO, BattleAIScript_82DD21E - if_effect EFFECT_RAZOR_WIND, BattleAIScript_82DDA0B - if_effect EFFECT_SUPER_FANG, BattleAIScript_82DD21F - if_effect EFFECT_TRAP, BattleAIScript_82DD229 - if_effect EFFECT_HIGH_CRITICAL, BattleAIScript_82DD25F - if_effect EFFECT_CONFUSE, BattleAIScript_82DD296 - if_effect EFFECT_ATTACK_UP_2, BattleAIScript_82DCBBC - if_effect EFFECT_DEFENSE_UP_2, BattleAIScript_82DCBF7 - if_effect EFFECT_SPEED_UP_2, BattleAIScript_82DCC5D - if_effect EFFECT_SPECIAL_ATTACK_UP_2, BattleAIScript_82DCC73 - if_effect EFFECT_SPECIAL_DEFENSE_UP_2, BattleAIScript_82DCCAE - if_effect EFFECT_ACCURACY_UP_2, BattleAIScript_82DCD14 - if_effect EFFECT_EVASION_UP_2, BattleAIScript_82DCD2E - if_effect EFFECT_ATTACK_DOWN_2, BattleAIScript_82DCDF8 - if_effect EFFECT_DEFENSE_DOWN_2, BattleAIScript_82DCE4A - if_effect EFFECT_SPEED_DOWN_2, BattleAIScript_82DCE81 - if_effect EFFECT_SPECIAL_ATTACK_DOWN_2, BattleAIScript_82DCE97 - if_effect EFFECT_SPECIAL_DEFENSE_DOWN_2, BattleAIScript_82DCEEB - if_effect EFFECT_ACCURACY_DOWN_2, BattleAIScript_82DCF0C - if_effect EFFECT_EVASION_DOWN_2, BattleAIScript_82DCFA0 - if_effect EFFECT_REFLECT, BattleAIScript_82DD2D3 - if_effect EFFECT_POISON, BattleAIScript_82DD303 - if_effect EFFECT_PARALYZE, BattleAIScript_82DD314 + if_effect EFFECT_SLEEP, AI_CV_Sleep + if_effect EFFECT_ABSORB, AI_CV_Absorb + if_effect EFFECT_EXPLOSION, AI_CV_SelfKO + if_effect EFFECT_DREAM_EATER, AI_CV_DreamEater + if_effect EFFECT_MIRROR_MOVE, AI_CV_MirrorMove + if_effect EFFECT_ATTACK_UP, AI_CV_AttackUp + if_effect EFFECT_DEFENSE_UP, AI_CV_DefenseUp + if_effect EFFECT_SPEED_UP, AI_CV_SpeedUp + if_effect EFFECT_SPECIAL_ATTACK_UP, AI_CV_SpAtkUp + if_effect EFFECT_SPECIAL_DEFENSE_UP, AI_CV_SpDefUp + if_effect EFFECT_ACCURACY_UP, AI_CV_AccuracyUp + if_effect EFFECT_EVASION_UP, AI_CV_EvasionUp + if_effect EFFECT_ALWAYS_HIT, AI_CV_AlwaysHit + if_effect EFFECT_ATTACK_DOWN, AI_CV_AttackDown + if_effect EFFECT_DEFENSE_DOWN, AI_CV_DefenseDown + if_effect EFFECT_SPEED_DOWN, AI_CV_SpeedDown + if_effect EFFECT_SPECIAL_ATTACK_DOWN, AI_CV_SpAtkDown + if_effect EFFECT_SPECIAL_DEFENSE_DOWN, AI_CV_SpDefDown + if_effect EFFECT_ACCURACY_DOWN, AI_CV_AccuracyDown + if_effect EFFECT_EVASION_DOWN, AI_CV_EvasionDown + if_effect EFFECT_HAZE, AI_CV_Haze + if_effect EFFECT_BIDE, AI_CV_Bide + if_effect EFFECT_ROAR, AI_CV_Roar + if_effect EFFECT_CONVERSION, AI_CV_Conversion + if_effect EFFECT_RESTORE_HP, AI_CV_Heal + if_effect EFFECT_TOXIC, AI_CV_Toxic + if_effect EFFECT_LIGHT_SCREEN, AI_CV_LightScreen + if_effect EFFECT_REST, AI_CV_Rest + if_effect EFFECT_OHKO, AI_CV_OneHitKO + if_effect EFFECT_RAZOR_WIND, AI_CV_ChargeUpMove + if_effect EFFECT_SUPER_FANG, AI_CV_SuperFang + if_effect EFFECT_TRAP, AI_CV_Trap + if_effect EFFECT_HIGH_CRITICAL, AI_CV_HighCrit + if_effect EFFECT_CONFUSE, AI_CV_Confuse + if_effect EFFECT_ATTACK_UP_2, AI_CV_AttackUp + if_effect EFFECT_DEFENSE_UP_2, AI_CV_DefenseUp + if_effect EFFECT_SPEED_UP_2, AI_CV_SpeedUp + if_effect EFFECT_SPECIAL_ATTACK_UP_2, AI_CV_SpAtkUp + if_effect EFFECT_SPECIAL_DEFENSE_UP_2, AI_CV_SpDefUp + if_effect EFFECT_ACCURACY_UP_2, AI_CV_AccuracyUp + if_effect EFFECT_EVASION_UP_2, AI_CV_EvasionUp + if_effect EFFECT_ATTACK_DOWN_2, AI_CV_AttackDown + if_effect EFFECT_DEFENSE_DOWN_2, AI_CV_DefenseDown + if_effect EFFECT_SPEED_DOWN_2, AI_CV_SpeedDown + if_effect EFFECT_SPECIAL_ATTACK_DOWN_2, AI_CV_SpAtkDown + if_effect EFFECT_SPECIAL_DEFENSE_DOWN_2, AI_CV_SpDefDown + if_effect EFFECT_ACCURACY_DOWN_2, AI_CV_AccuracyDown + if_effect EFFECT_EVASION_DOWN_2, AI_CV_EvasionDown + if_effect EFFECT_REFLECT, AI_CV_Reflect + if_effect EFFECT_POISON, AI_CV_Poison + if_effect EFFECT_PARALYZE, AI_CV_Paralyze if_effect EFFECT_SWAGGER, BattleAIScript_82DD286 - if_effect EFFECT_SPEED_DOWN_HIT, BattleAIScript_82DCE6B - if_effect EFFECT_SKY_ATTACK, BattleAIScript_82DDA0B - if_effect EFFECT_VITAL_THROW, BattleAIScript_82DD331 - if_effect EFFECT_SUBSTITUTE, BattleAIScript_82DD354 - if_effect EFFECT_RECHARGE, BattleAIScript_82DD3EA - if_effect EFFECT_LEECH_SEED, BattleAIScript_82DD150 - if_effect EFFECT_DISABLE, BattleAIScript_82DD412 - if_effect EFFECT_COUNTER, BattleAIScript_82DD431 - if_effect EFFECT_ENCORE, BattleAIScript_82DD4E3 - if_effect EFFECT_PAIN_SPLIT, BattleAIScript_82DD54B - if_effect EFFECT_SNORE, BattleAIScript_82DD577 - if_effect EFFECT_LOCK_ON, BattleAIScript_82DD57A - if_effect EFFECT_SLEEP_TALK, BattleAIScript_82DD583 - if_effect EFFECT_DESTINY_BOND, BattleAIScript_82DD590 - if_effect EFFECT_FLAIL, BattleAIScript_82DD5C6 - if_effect EFFECT_HEAL_BELL, BattleAIScript_82DD60B - if_effect EFFECT_THIEF, BattleAIScript_82DD622 - if_effect EFFECT_MEAN_LOOK, BattleAIScript_82DD229 - if_effect EFFECT_MINIMIZE, BattleAIScript_82DCD2E - if_effect EFFECT_CURSE, BattleAIScript_82DD645 - if_effect EFFECT_PROTECT, BattleAIScript_82DD694 - if_effect EFFECT_FORESIGHT, BattleAIScript_82DD75D - if_effect EFFECT_ENDURE, BattleAIScript_82DD78B - if_effect EFFECT_BATON_PASS, BattleAIScript_82DD7A9 - if_effect EFFECT_PURSUIT, BattleAIScript_82DD845 - if_effect EFFECT_MORNING_SUN, BattleAIScript_82DD0DD - if_effect EFFECT_SYNTHESIS, BattleAIScript_82DD0DD - if_effect EFFECT_MOONLIGHT, BattleAIScript_82DD0DD - if_effect EFFECT_RAIN_DANCE, BattleAIScript_82DD87B - if_effect EFFECT_SUNNY_DAY, BattleAIScript_82DD8BA - if_effect EFFECT_BELLY_DRUM, BattleAIScript_82DD8E3 - if_effect EFFECT_PSYCH_UP, BattleAIScript_82DD8F2 - if_effect EFFECT_MIRROR_COAT, BattleAIScript_82DD95A - if_effect EFFECT_SKULL_BASH, BattleAIScript_82DDA0B - if_effect EFFECT_SOLARBEAM, BattleAIScript_82DDA0B - if_effect EFFECT_SEMI_INVULNERABLE, BattleAIScript_82DDA2F - if_effect EFFECT_SOFTBOILED, BattleAIScript_82DD0F7 - if_effect EFFECT_FAKE_OUT, BattleAIScript_82DDAB9 - if_effect EFFECT_SPIT_UP, BattleAIScript_82DDABC - if_effect EFFECT_SWALLOW, BattleAIScript_82DD0F7 - if_effect EFFECT_HAIL, BattleAIScript_82DDACD - if_effect EFFECT_FLATTER, BattleAIScript_82DD28E - if_effect EFFECT_MEMENTO, BattleAIScript_82DCAC8 - if_effect EFFECT_FACADE, BattleAIScript_82DDAF6 - if_effect EFFECT_FOCUS_PUNCH, BattleAIScript_82DDB03 - if_effect EFFECT_SMELLINGSALT, BattleAIScript_82DDB5C - if_effect EFFECT_TRICK, BattleAIScript_82DDB6E - if_effect EFFECT_ROLE_PLAY, BattleAIScript_82DDBB9 - if_effect EFFECT_SUPERPOWER, BattleAIScript_82DDBF0 - if_effect EFFECT_MAGIC_COAT, BattleAIScript_82DDC20 - if_effect EFFECT_RECYCLE, BattleAIScript_82DDC53 - if_effect EFFECT_REVENGE, BattleAIScript_82DDC72 - if_effect EFFECT_BRICK_BREAK, BattleAIScript_82DDCA0 - if_effect EFFECT_KNOCK_OFF, BattleAIScript_82DDCB2 - if_effect EFFECT_ENDEAVOR, BattleAIScript_82DDCCA - if_effect EFFECT_ERUPTION, BattleAIScript_82DDCF6 - if_effect EFFECT_SKILL_SWAP, BattleAIScript_82DDBB9 - if_effect EFFECT_IMPRISON, BattleAIScript_82DDD1E - if_effect EFFECT_REFRESH, BattleAIScript_82DDD2F - if_effect EFFECT_SNATCH, BattleAIScript_82DDD3E - if_effect EFFECT_BLAZE_KICK, BattleAIScript_82DD25F - if_effect EFFECT_MUD_SPORT, BattleAIScript_82DDDA8 - if_effect EFFECT_OVERHEAT, BattleAIScript_82DDDCE - if_effect EFFECT_TICKLE, BattleAIScript_82DCE4A - if_effect EFFECT_COSMIC_POWER, BattleAIScript_82DCCAE - if_effect EFFECT_BULK_UP, BattleAIScript_82DCBF7 - if_effect EFFECT_POISON_TAIL, BattleAIScript_82DD25F - if_effect EFFECT_WATER_SPORT, BattleAIScript_82DDDF6 - if_effect EFFECT_CALM_MIND, BattleAIScript_82DCCAE - if_effect EFFECT_DRAGON_DANCE, BattleAIScript_82DDE1C + if_effect EFFECT_SPEED_DOWN_HIT, AI_CV_SpeedDownFromChance + if_effect EFFECT_SKY_ATTACK, AI_CV_ChargeUpMove + if_effect EFFECT_VITAL_THROW, AI_CV_VitalThrow + if_effect EFFECT_SUBSTITUTE, AI_CV_Substitute + if_effect EFFECT_RECHARGE, AI_CV_Recharge + if_effect EFFECT_LEECH_SEED, AI_CV_Toxic + if_effect EFFECT_DISABLE, AI_CV_Disable + if_effect EFFECT_COUNTER, AI_CV_Counter + if_effect EFFECT_ENCORE, AI_CV_Encore + if_effect EFFECT_PAIN_SPLIT, AI_CV_PainSplit + if_effect EFFECT_SNORE, AI_CV_Snore + if_effect EFFECT_LOCK_ON, AI_CV_LockOn + if_effect EFFECT_SLEEP_TALK, AI_CV_SleepTalk + if_effect EFFECT_DESTINY_BOND, AI_CV_DestinyBond + if_effect EFFECT_FLAIL, AI_CV_Flail + if_effect EFFECT_HEAL_BELL, AI_CV_HealBell + if_effect EFFECT_THIEF, AI_CV_Thief + if_effect EFFECT_MEAN_LOOK, AI_CV_Trap + if_effect EFFECT_MINIMIZE, AI_CV_EvasionUp + if_effect EFFECT_CURSE, AI_CV_Curse + if_effect EFFECT_PROTECT, AI_CV_Protect + if_effect EFFECT_FORESIGHT, AI_CV_Foresight + if_effect EFFECT_ENDURE, AI_CV_Endure + if_effect EFFECT_BATON_PASS, AI_CV_BatonPass + if_effect EFFECT_PURSUIT, AI_CV_Pursuit + if_effect EFFECT_MORNING_SUN, AI_CV_HealWeather + if_effect EFFECT_SYNTHESIS, AI_CV_HealWeather + if_effect EFFECT_MOONLIGHT, AI_CV_HealWeather + if_effect EFFECT_RAIN_DANCE, AI_CV_RainDance + if_effect EFFECT_SUNNY_DAY, AI_CV_SunnyDay + if_effect EFFECT_BELLY_DRUM, AI_CV_BellyDrum + if_effect EFFECT_PSYCH_UP, AI_CV_PsychUp + if_effect EFFECT_MIRROR_COAT, AI_CV_MirrorCoat + if_effect EFFECT_SKULL_BASH, AI_CV_ChargeUpMove + if_effect EFFECT_SOLARBEAM, AI_CV_ChargeUpMove + if_effect EFFECT_SEMI_INVULNERABLE, AI_CV_Fly + if_effect EFFECT_SOFTBOILED, AI_CV_Heal + if_effect EFFECT_FAKE_OUT, AI_CV_FakeOut + if_effect EFFECT_SPIT_UP, AI_CV_SpitUp + if_effect EFFECT_SWALLOW, AI_CV_Heal + if_effect EFFECT_HAIL, AI_CV_Hail + if_effect EFFECT_FLATTER, AI_CV_Flatter + if_effect EFFECT_MEMENTO, AI_CV_SelfKO + if_effect EFFECT_FACADE, AI_CV_Facade + if_effect EFFECT_FOCUS_PUNCH, AI_CV_FocusPunch + if_effect EFFECT_SMELLINGSALT, AI_CV_SmellingSalt + if_effect EFFECT_TRICK, AI_CV_Trick + if_effect EFFECT_ROLE_PLAY, AI_CV_ChangeSelfAbility + if_effect EFFECT_SUPERPOWER, AI_CV_Superpower + if_effect EFFECT_MAGIC_COAT, AI_CV_MagicCoat + if_effect EFFECT_RECYCLE, AI_CV_Recycle + if_effect EFFECT_REVENGE, AI_CV_Revenge + if_effect EFFECT_BRICK_BREAK, AI_CV_BrickBreak + if_effect EFFECT_KNOCK_OFF, AI_CV_KnockOff + if_effect EFFECT_ENDEAVOR, AI_CV_Endeavor + if_effect EFFECT_ERUPTION, AI_CV_Eruption + if_effect EFFECT_SKILL_SWAP, AI_CV_ChangeSelfAbility + if_effect EFFECT_IMPRISON, AI_CV_Imprison + if_effect EFFECT_REFRESH, AI_CV_Refresh + if_effect EFFECT_SNATCH, AI_CV_Snatch + if_effect EFFECT_BLAZE_KICK, AI_CV_HighCrit + if_effect EFFECT_MUD_SPORT, AI_CV_MudSport + if_effect EFFECT_OVERHEAT, AI_CV_Overheat + if_effect EFFECT_TICKLE, AI_CV_DefenseDown + if_effect EFFECT_COSMIC_POWER, AI_CV_SpDefUp + if_effect EFFECT_BULK_UP, AI_CV_DefenseUp + if_effect EFFECT_POISON_TAIL, AI_CV_HighCrit + if_effect EFFECT_WATER_SPORT, AI_CV_WaterSport + if_effect EFFECT_CALM_MIND, AI_CV_SpDefUp + if_effect EFFECT_DRAGON_DANCE, AI_CV_DragonDance end -BattleAIScript_82DCA92: - if_has_move_with_effect AI_TARGET, EFFECT_DREAM_EATER, BattleAIScript_82DCAA5 - if_has_move_with_effect AI_TARGET, EFFECT_NIGHTMARE, BattleAIScript_82DCAA5 - goto BattleAIScript_82DCAAD +AI_CV_Sleep: @ 82DCA92 + if_has_move_with_effect AI_TARGET, EFFECT_DREAM_EATER, AI_CV_SleepEncourageSlpDamage + if_has_move_with_effect AI_TARGET, EFFECT_NIGHTMARE, AI_CV_SleepEncourageSlpDamage + goto AI_CV_Sleep_End -BattleAIScript_82DCAA5: - if_random_less_than 128, BattleAIScript_82DCAAD +AI_CV_SleepEncourageSlpDamage: @ 82DCAA5 + if_random_less_than 128, AI_CV_Sleep_End score +1 -BattleAIScript_82DCAAD: +AI_CV_Sleep_End: @ 82DCAAD end -BattleAIScript_82DCAAE: - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DCABF - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DCABF - goto BattleAIScript_82DCAC7 +AI_CV_Absorb: @ 82DCAAE + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_AbsorbEncourageMaybe + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_AbsorbEncourageMaybe + goto AI_CV_Absorb_End -BattleAIScript_82DCABF: - if_random_less_than 50, BattleAIScript_82DCAC7 +AI_CV_AbsorbEncourageMaybe: @ 82DCABF + if_random_less_than 50, AI_CV_Absorb_End score -3 -BattleAIScript_82DCAC7: +AI_CV_Absorb_End: @ 82DCAC7 end -BattleAIScript_82DCAC8: - if_stat_level_less_than AI_TARGET, STAT_EVASION, 7, BattleAIScript_82DCAE2 +AI_CV_SelfKO: @ 82DCAC8 + if_stat_level_less_than AI_TARGET, STAT_EVASION, 7, AI_CV_SelfKO_Encourage1 score -1 - if_stat_level_less_than AI_TARGET, STAT_EVASION, 10, BattleAIScript_82DCAE2 - if_random_less_than 128, BattleAIScript_82DCAE2 + if_stat_level_less_than AI_TARGET, STAT_EVASION, 10, AI_CV_SelfKO_Encourage1 + if_random_less_than 128, AI_CV_SelfKO_Encourage1 score -1 -BattleAIScript_82DCAE2: - if_hp_less_than AI_USER, 80, BattleAIScript_82DCAFA - if_target_faster BattleAIScript_82DCAFA - if_random_less_than 50, BattleAIScript_82DCB25 +AI_CV_SelfKO_Encourage1: @ 82DCAE2 + if_hp_less_than AI_USER, 80, AI_CV_SelfKO_Encourage2 + if_target_faster AI_CV_SelfKO_Encourage2 + if_random_less_than 50, AI_CV_SelfKO_End goto Score_Minus3 -BattleAIScript_82DCAFA: - if_hp_more_than AI_USER, 50, BattleAIScript_82DCB1D - if_random_less_than 128, BattleAIScript_82DCB09 +AI_CV_SelfKO_Encourage2: @ 82DCAFA + if_hp_more_than AI_USER, 50, AI_CV_SelfKO_Encourage4 + if_random_less_than 128, AI_CV_SelfKO_Encourage3 score +1 -BattleAIScript_82DCB09: - if_hp_more_than AI_USER, 30, BattleAIScript_82DCB25 - if_random_less_than 50, BattleAIScript_82DCB25 +AI_CV_SelfKO_Encourage3: @ 82DCB09 + if_hp_more_than AI_USER, 30, AI_CV_SelfKO_End + if_random_less_than 50, AI_CV_SelfKO_End score +1 - goto BattleAIScript_82DCB25 + goto AI_CV_SelfKO_End -BattleAIScript_82DCB1D: - if_random_less_than 50, BattleAIScript_82DCB25 +AI_CV_SelfKO_Encourage4: @ 82DCB1D + if_random_less_than 50, AI_CV_SelfKO_End score -1 -BattleAIScript_82DCB25: +AI_CV_SelfKO_End: @ 82DCB25 end -BattleAIScript_82DCB26: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DCB37 - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DCB37 - goto BattleAIScript_82DCB39 +AI_CV_DreamEater: @ 82DCB26 + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_DreamEater_ScoreDown1 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_DreamEater_ScoreDown1 + goto AI_CV_DreamEater_End -BattleAIScript_82DCB37: +AI_CV_DreamEater_ScoreDown1: @ 82DCB37 score -1 -BattleAIScript_82DCB39: +AI_CV_DreamEater_End: @ 82DCB39 end -BattleAIScript_82DCB3A: - if_target_faster BattleAIScript_82DCB58 +AI_CV_MirrorMove: @ 82DCB3A + if_target_faster AI_CV_MirrorMove2 get_last_used_bank_move AI_TARGET - if_not_in_hwords sMovesTable_82DCB6C, BattleAIScript_82DCB58 - if_random_less_than 128, BattleAIScript_82DCB6B + if_not_in_hwords AI_CV_MirrorMove_EncouragedMovesToMirror, AI_CV_MirrorMove2 + if_random_less_than 128, AI_CV_MirrorMove_End score +2 - goto BattleAIScript_82DCB6B + goto AI_CV_MirrorMove_End -BattleAIScript_82DCB58: +AI_CV_MirrorMove2: @ 82DCB58 get_last_used_bank_move AI_TARGET - if_in_hwords sMovesTable_82DCB6C, BattleAIScript_82DCB6B - if_random_less_than 80, BattleAIScript_82DCB6B + if_in_hwords AI_CV_MirrorMove_EncouragedMovesToMirror, AI_CV_MirrorMove_End + if_random_less_than 80, AI_CV_MirrorMove_End score -1 -BattleAIScript_82DCB6B: +AI_CV_MirrorMove_End: @ 82DCB6B end -sMovesTable_82DCB6C: +AI_CV_MirrorMove_EncouragedMovesToMirror: @ 82DCB6C .2byte MOVE_SLEEP_POWDER .2byte MOVE_LOVELY_KISS .2byte MOVE_SPORE @@ -905,63 +905,63 @@ sMovesTable_82DCB6C: .2byte MOVE_SKILL_SWAP .2byte -1 -BattleAIScript_82DCBBC: - if_stat_level_less_than AI_USER, STAT_ATK, 9, BattleAIScript_82DCBD1 - if_random_less_than 100, BattleAIScript_82DCBE0 +AI_CV_AttackUp: @ 82DCBBC + if_stat_level_less_than AI_USER, STAT_ATK, 9, AI_CV_AttackUp2 + if_random_less_than 100, AI_CV_AttackUp3 score -1 - goto BattleAIScript_82DCBE0 + goto AI_CV_AttackUp3 -BattleAIScript_82DCBD1: - if_hp_not_equal AI_USER, 100, BattleAIScript_82DCBE0 - if_random_less_than 128, BattleAIScript_82DCBE0 +AI_CV_AttackUp2: @ 82DCBD1 + if_hp_not_equal AI_USER, 100, AI_CV_AttackUp3 + if_random_less_than 128, AI_CV_AttackUp3 score +2 -BattleAIScript_82DCBE0: - if_hp_more_than AI_USER, 70, BattleAIScript_82DCBF6 - if_hp_less_than AI_USER, 40, BattleAIScript_82DCBF4 - if_random_less_than 40, BattleAIScript_82DCBF6 +AI_CV_AttackUp3: @ 82DCBE0 + if_hp_more_than AI_USER, 70, AI_CV_AttackUp_End + if_hp_less_than AI_USER, 40, AI_CV_AttackUp_ScoreDown2 + if_random_less_than 40, AI_CV_AttackUp_End -BattleAIScript_82DCBF4: +AI_CV_AttackUp_ScoreDown2: @ 82DCBF4 score -2 -BattleAIScript_82DCBF6: +AI_CV_AttackUp_End: @ 82DCBF6 end -BattleAIScript_82DCBF7: - if_stat_level_less_than AI_USER, STAT_DEF, 9, BattleAIScript_82DCC0C - if_random_less_than 100, BattleAIScript_82DCC1B +AI_CV_DefenseUp: @ 82DCBF7 + if_stat_level_less_than AI_USER, STAT_DEF, 9, AI_CV_DefenseUp2 + if_random_less_than 100, AI_CV_DefenseUp3 score -1 - goto BattleAIScript_82DCC1B + goto AI_CV_DefenseUp3 -BattleAIScript_82DCC0C: - if_hp_not_equal AI_USER, 100, BattleAIScript_82DCC1B - if_random_less_than 128, BattleAIScript_82DCC1B +AI_CV_DefenseUp2: @ 82DCC0C + if_hp_not_equal AI_USER, 100, AI_CV_DefenseUp3 + if_random_less_than 128, AI_CV_DefenseUp3 score +2 -BattleAIScript_82DCC1B: - if_hp_less_than AI_USER, 70, BattleAIScript_82DCC28 - if_random_less_than 200, BattleAIScript_82DCC52 +AI_CV_DefenseUp3: @ 82DCC1B + if_hp_less_than AI_USER, 70, AI_CV_DefenseUp4 + if_random_less_than 200, AI_CV_DefenseUp_End -BattleAIScript_82DCC28: - if_hp_less_than AI_USER, 40, BattleAIScript_82DCC50 +AI_CV_DefenseUp4: @ 82DCC28 + if_hp_less_than AI_USER, 40, AI_CV_DefenseUp_ScoreDown2 get_last_used_bank_move AI_TARGET get_move_power_from_result - if_equal 0, BattleAIScript_82DCC4A + if_equal 0, AI_CV_DefenseUp5 get_last_used_bank_move AI_TARGET get_move_type_from_result - if_not_in_bytes sTypesTable_82DCC53, BattleAIScript_82DCC50 - if_random_less_than 60, BattleAIScript_82DCC52 + if_not_in_bytes AI_CV_DefenseUp_PhysicalTypes, AI_CV_DefenseUp_ScoreDown2 + if_random_less_than 60, AI_CV_DefenseUp_End -BattleAIScript_82DCC4A: - if_random_less_than 60, BattleAIScript_82DCC52 +AI_CV_DefenseUp5: @ 82DCC4A + if_random_less_than 60, AI_CV_DefenseUp_End -BattleAIScript_82DCC50: +AI_CV_DefenseUp_ScoreDown2: @ 82DCC50 score -2 -BattleAIScript_82DCC52: +AI_CV_DefenseUp_End: @ 82DCC52 end -sTypesTable_82DCC53: +AI_CV_DefenseUp_PhysicalTypes: @ 82DCC53 .byte TYPE_NORMAL .byte TYPE_FIGHTING .byte TYPE_POISON @@ -973,75 +973,75 @@ sTypesTable_82DCC53: .byte TYPE_STEEL .byte -1 -BattleAIScript_82DCC5D: - if_target_faster BattleAIScript_82DCC6A +AI_CV_SpeedUp: @ 82DCC5D + if_target_faster AI_CV_SpeedUp2 score -3 - goto BattleAIScript_82DCC72 + goto AI_CV_SpeedUp_End -BattleAIScript_82DCC6A: - if_random_less_than 70, BattleAIScript_82DCC72 +AI_CV_SpeedUp2: @ 82DCC6A + if_random_less_than 70, AI_CV_SpeedUp_End score +3 -BattleAIScript_82DCC72: +AI_CV_SpeedUp_End: @ 82DCC72 end -BattleAIScript_82DCC73: - if_stat_level_less_than AI_USER, STAT_SPATK, 9, BattleAIScript_82DCC88 - if_random_less_than 100, BattleAIScript_82DCC97 +AI_CV_SpAtkUp: @ 82DCC73 + if_stat_level_less_than AI_USER, STAT_SPATK, 9, AI_CV_SpAtkUp2 + if_random_less_than 100, AI_CV_SpAtkUp3 score -1 - goto BattleAIScript_82DCC97 + goto AI_CV_SpAtkUp3 -BattleAIScript_82DCC88: - if_hp_not_equal AI_USER, 100, BattleAIScript_82DCC97 - if_random_less_than 128, BattleAIScript_82DCC97 +AI_CV_SpAtkUp2: @ 82DCC88 + if_hp_not_equal AI_USER, 100, AI_CV_SpAtkUp3 + if_random_less_than 128, AI_CV_SpAtkUp3 score +2 -BattleAIScript_82DCC97: - if_hp_more_than AI_USER, 70, BattleAIScript_82DCCAD - if_hp_less_than AI_USER, 40, BattleAIScript_82DCCAB - if_random_less_than 70, BattleAIScript_82DCCAD +AI_CV_SpAtkUp3: @ 82DCC97 + if_hp_more_than AI_USER, 70, AI_CV_SpAtkUp_End + if_hp_less_than AI_USER, 40, AI_CV_SpAtkUp_ScoreDown2 + if_random_less_than 70, AI_CV_SpAtkUp_End -BattleAIScript_82DCCAB: +AI_CV_SpAtkUp_ScoreDown2: @ 82DCCAB score -2 -BattleAIScript_82DCCAD: +AI_CV_SpAtkUp_End: @ 82DCCAD end -BattleAIScript_82DCCAE: - if_stat_level_less_than AI_USER, STAT_SPDEF, 9, BattleAIScript_82DCCC3 - if_random_less_than 100, BattleAIScript_82DCCD2 +AI_CV_SpDefUp: @ 82DCCAE + if_stat_level_less_than AI_USER, STAT_SPDEF, 9, AI_CV_SpDefUp2 + if_random_less_than 100, AI_CV_SpDefUp3 score -1 - goto BattleAIScript_82DCCD2 + goto AI_CV_SpDefUp3 -BattleAIScript_82DCCC3: - if_hp_not_equal AI_USER, 100, BattleAIScript_82DCCD2 - if_random_less_than 128, BattleAIScript_82DCCD2 +AI_CV_SpDefUp2: @ 82DCCC3 + if_hp_not_equal AI_USER, 100, AI_CV_SpDefUp3 + if_random_less_than 128, AI_CV_SpDefUp3 score +2 -BattleAIScript_82DCCD2: - if_hp_less_than AI_USER, 70, BattleAIScript_82DCCDF - if_random_less_than 200, BattleAIScript_82DCD09 +AI_CV_SpDefUp3: @ 82DCCD2 + if_hp_less_than AI_USER, 70, AI_CV_SpDefUp4 + if_random_less_than 200, AI_CV_SpDefUp_End -BattleAIScript_82DCCDF: - if_hp_less_than AI_USER, 40, BattleAIScript_82DCD07 +AI_CV_SpDefUp4: @ 82DCCDF + if_hp_less_than AI_USER, 40, AI_CV_SpDefUp_ScoreDown2 get_last_used_bank_move AI_TARGET get_move_power_from_result - if_equal 0, BattleAIScript_82DCD01 + if_equal 0, AI_CV_SpDefUp5 get_last_used_bank_move AI_TARGET get_move_type_from_result - if_in_bytes sTypesTable_82DCD0A, BattleAIScript_82DCD07 - if_random_less_than 60, BattleAIScript_82DCD09 + if_in_bytes AI_CV_SpDefUp_PhysicalTypes, AI_CV_SpDefUp_ScoreDown2 + if_random_less_than 60, AI_CV_SpDefUp_End -BattleAIScript_82DCD01: - if_random_less_than 60, BattleAIScript_82DCD09 +AI_CV_SpDefUp5: @ 82DCD01 + if_random_less_than 60, AI_CV_SpDefUp_End -BattleAIScript_82DCD07: +AI_CV_SpDefUp_ScoreDown2: @ 82DCD07 score -2 -BattleAIScript_82DCD09: +AI_CV_SpDefUp_End: @ 82DCD09 end -sTypesTable_82DCD0A: +AI_CV_SpDefUp_PhysicalTypes: @ 82DCD0A .byte TYPE_NORMAL .byte TYPE_FIGHTING .byte TYPE_POISON @@ -1053,109 +1053,109 @@ sTypesTable_82DCD0A: .byte TYPE_STEEL .byte -1 -BattleAIScript_82DCD14: - if_stat_level_less_than AI_USER, STAT_ACC, 9, BattleAIScript_82DCD24 - if_random_less_than 50, BattleAIScript_82DCD24 +AI_CV_AccuracyUp: + if_stat_level_less_than AI_USER, STAT_ACC, 9, AI_CV_AccuracyUp2 + if_random_less_than 50, AI_CV_AccuracyUp2 score -2 -BattleAIScript_82DCD24: - if_hp_more_than AI_USER, 70, BattleAIScript_82DCD2D +AI_CV_AccuracyUp2: + if_hp_more_than AI_USER, 70, AI_CV_AccuracyUp_End score -2 -BattleAIScript_82DCD2D: +AI_CV_AccuracyUp_End: end -BattleAIScript_82DCD2E: - if_hp_less_than AI_USER, 90, BattleAIScript_82DCD3D - if_random_less_than 100, BattleAIScript_82DCD3D +AI_CV_EvasionUp: + if_hp_less_than AI_USER, 90, AI_CV_EvasionUp2 + if_random_less_than 100, AI_CV_EvasionUp2 score +3 -BattleAIScript_82DCD3D: - if_stat_level_less_than AI_USER, STAT_EVASION, 9, BattleAIScript_82DCD4D - if_random_less_than 128, BattleAIScript_82DCD4D +AI_CV_EvasionUp2: + if_stat_level_less_than AI_USER, STAT_EVASION, 9, AI_CV_EvasionUp3 + if_random_less_than 128, AI_CV_EvasionUp3 score -1 -BattleAIScript_82DCD4D: - if_not_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DCD6C - if_hp_more_than AI_USER, 50, BattleAIScript_82DCD64 - if_random_less_than 80, BattleAIScript_82DCD6C +AI_CV_EvasionUp3: + if_not_status AI_TARGET, STATUS1_TOXIC_POISON, AI_CV_EvasionUp5 + if_hp_more_than AI_USER, 50, AI_CV_EvasionUp4 + if_random_less_than 80, AI_CV_EvasionUp5 -BattleAIScript_82DCD64: - if_random_less_than 50, BattleAIScript_82DCD6C +AI_CV_EvasionUp4: + if_random_less_than 50, AI_CV_EvasionUp5 score +3 -BattleAIScript_82DCD6C: - if_not_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DCD7E - if_random_less_than 70, BattleAIScript_82DCD7E +AI_CV_EvasionUp5: + if_not_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_EvasionUp6 + if_random_less_than 70, AI_CV_EvasionUp6 score +3 -BattleAIScript_82DCD7E: - if_not_status3 AI_USER, STATUS3_ROOTED, BattleAIScript_82DCD90 - if_random_less_than 128, BattleAIScript_82DCD90 +AI_CV_EvasionUp6: + if_not_status3 AI_USER, STATUS3_ROOTED, AI_CV_EvasionUp7 + if_random_less_than 128, AI_CV_EvasionUp7 score +2 -BattleAIScript_82DCD90: - if_not_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DCDA2 - if_random_less_than 70, BattleAIScript_82DCDA2 +AI_CV_EvasionUp7: + if_not_status2 AI_TARGET, STATUS2_CURSED, AI_CV_EvasionUp8 + if_random_less_than 70, AI_CV_EvasionUp8 score +3 -BattleAIScript_82DCDA2: - if_hp_more_than AI_USER, 70, BattleAIScript_82DCDC7 - if_stat_level_equal AI_USER, STAT_EVASION, 6, BattleAIScript_82DCDC7 - if_hp_less_than AI_USER, 40, BattleAIScript_82DCDC5 - if_hp_less_than AI_TARGET, 40, BattleAIScript_82DCDC5 - if_random_less_than 70, BattleAIScript_82DCDC7 +AI_CV_EvasionUp8: + if_hp_more_than AI_USER, 70, AI_CV_EvasionUp_End + if_stat_level_equal AI_USER, STAT_EVASION, 6, AI_CV_EvasionUp_End + if_hp_less_than AI_USER, 40, AI_CV_EvasionUp_ScoreDown2 + if_hp_less_than AI_TARGET, 40, AI_CV_EvasionUp_ScoreDown2 + if_random_less_than 70, AI_CV_EvasionUp_End -BattleAIScript_82DCDC5: +AI_CV_EvasionUp_ScoreDown2: score -2 -BattleAIScript_82DCDC7: +AI_CV_EvasionUp_End: end -BattleAIScript_82DCDC8: - if_stat_level_more_than AI_TARGET, STAT_EVASION, 10, BattleAIScript_82DCDED - if_stat_level_less_than AI_USER, STAT_ACC, 2, BattleAIScript_82DCDED - if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, BattleAIScript_82DCDEF - if_stat_level_less_than AI_USER, STAT_ACC, 4, BattleAIScript_82DCDEF - goto BattleAIScript_82DCDF7 +AI_CV_AlwaysHit: + if_stat_level_more_than AI_TARGET, STAT_EVASION, 10, AI_CV_AlwaysHit_ScoreUp1 + if_stat_level_less_than AI_USER, STAT_ACC, 2, AI_CV_AlwaysHit_ScoreUp1 + if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_AlwaysHit2 + if_stat_level_less_than AI_USER, STAT_ACC, 4, AI_CV_AlwaysHit2 + goto AI_CV_AlwaysHit_End -BattleAIScript_82DCDED: +AI_CV_AlwaysHit_ScoreUp1: score +1 -BattleAIScript_82DCDEF: - if_random_less_than 100, BattleAIScript_82DCDF7 +AI_CV_AlwaysHit2: + if_random_less_than 100, AI_CV_AlwaysHit_End score +1 -BattleAIScript_82DCDF7: +AI_CV_AlwaysHit_End: end -BattleAIScript_82DCDF8: - if_stat_level_equal AI_TARGET, STAT_ATK, 6, BattleAIScript_82DCE1B +AI_CV_AttackDown: @ 82DCDF8 + if_stat_level_equal AI_TARGET, STAT_ATK, 6, AI_CV_AttackDown3 score -1 - if_hp_more_than AI_USER, 90, BattleAIScript_82DCE0B + if_hp_more_than AI_USER, 90, AI_CV_AttackDown2 score -1 -BattleAIScript_82DCE0B: - if_stat_level_more_than AI_TARGET, STAT_ATK, 3, BattleAIScript_82DCE1B - if_random_less_than 50, BattleAIScript_82DCE1B +AI_CV_AttackDown2: @ 82DCE0B + if_stat_level_more_than AI_TARGET, STAT_ATK, 3, AI_CV_AttackDown3 + if_random_less_than 50, AI_CV_AttackDown3 score -2 -BattleAIScript_82DCE1B: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCE24 +AI_CV_AttackDown3: @ 82DCE1B + if_hp_more_than AI_TARGET, 70, AI_CV_AttackDown4 score -2 -BattleAIScript_82DCE24: +AI_CV_AttackDown4: @ 82DCE24 get_target_type1 - if_in_bytes sTypesTable_82DCE43, BattleAIScript_82DCE42 + if_in_bytes AI_CV_AttackDown_UnknownTypeList, AI_CV_AttackDown_End get_target_type2 - if_in_bytes sTypesTable_82DCE43, BattleAIScript_82DCE42 - if_random_less_than 50, BattleAIScript_82DCE42 + if_in_bytes AI_CV_AttackDown_UnknownTypeList, AI_CV_AttackDown_End + if_random_less_than 50, AI_CV_AttackDown_End score -2 -BattleAIScript_82DCE42: +AI_CV_AttackDown_End: @ 82DCE42 end -sTypesTable_82DCE43: +AI_CV_AttackDown_UnknownTypeList: .byte TYPE_NORMAL .byte TYPE_FIGHTING .byte TYPE_GROUND @@ -1164,66 +1164,66 @@ sTypesTable_82DCE43: .byte TYPE_STEEL .byte -1 -BattleAIScript_82DCE4A: - if_hp_less_than AI_USER, 70, BattleAIScript_82DCE59 - if_stat_level_more_than AI_TARGET, STAT_DEF, 3, BattleAIScript_82DCE61 +AI_CV_DefenseDown: + if_hp_less_than AI_USER, 70, AI_CV_DefenseDown2 + if_stat_level_more_than AI_TARGET, STAT_DEF, 3, AI_CV_DefenseDown3 -BattleAIScript_82DCE59: - if_random_less_than 50, BattleAIScript_82DCE61 +AI_CV_DefenseDown2: + if_random_less_than 50, AI_CV_DefenseDown3 score -2 -BattleAIScript_82DCE61: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCE6A +AI_CV_DefenseDown3: + if_hp_more_than AI_TARGET, 70, AI_CV_DefenseDown_End score -2 -BattleAIScript_82DCE6A: +AI_CV_DefenseDown_End: end -BattleAIScript_82DCE6B: - if_move MOVE_ICY_WIND, BattleAIScript_82DCE81 - if_move MOVE_ROCK_TOMB, BattleAIScript_82DCE81 - if_move MOVE_MUD_SHOT, BattleAIScript_82DCE81 +AI_CV_SpeedDownFromChance: @ 82DCE6B + if_move MOVE_ICY_WIND, AI_CV_SpeedDown + if_move MOVE_ROCK_TOMB, AI_CV_SpeedDown + if_move MOVE_MUD_SHOT, AI_CV_SpeedDown end -BattleAIScript_82DCE81: - if_target_faster BattleAIScript_82DCE8E +AI_CV_SpeedDown: @ 82DCE81 + if_target_faster AI_CV_SpeedDown2 score -3 - goto BattleAIScript_82DCE96 + goto AI_CV_SpeedDown_End -BattleAIScript_82DCE8E: - if_random_less_than 70, BattleAIScript_82DCE96 +AI_CV_SpeedDown2: @ 82DCE8E + if_random_less_than 70, AI_CV_SpeedDown_End score +2 -BattleAIScript_82DCE96: +AI_CV_SpeedDown_End: @ 82DCE96 end -BattleAIScript_82DCE97: - if_stat_level_equal AI_TARGET, STAT_ATK, 6, BattleAIScript_82DCEBA +AI_CV_SpAtkDown: + if_stat_level_equal AI_TARGET, STAT_ATK, 6, AI_CV_SpAtkDown3 score -1 - if_hp_more_than AI_USER, 90, BattleAIScript_82DCEAA + if_hp_more_than AI_USER, 90, AI_CV_SpAtkDown2 score -1 -BattleAIScript_82DCEAA: - if_stat_level_more_than AI_TARGET, STAT_SPATK, 3, BattleAIScript_82DCEBA - if_random_less_than 50, BattleAIScript_82DCEBA +AI_CV_SpAtkDown2: + if_stat_level_more_than AI_TARGET, STAT_SPATK, 3, AI_CV_SpAtkDown3 + if_random_less_than 50, AI_CV_SpAtkDown3 score -2 -BattleAIScript_82DCEBA: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCEC3 +AI_CV_SpAtkDown3: + if_hp_more_than AI_TARGET, 70, AI_CV_SpAtkDown4 score -2 -BattleAIScript_82DCEC3: +AI_CV_SpAtkDown4: get_target_type1 - if_in_bytes sTypesTable_82DCEE2, BattleAIScript_82DCEE1 + if_in_bytes AI_CV_SpAtkDown_SpecialTypeList, AI_CV_SpAtkDown_End get_target_type2 - if_in_bytes sTypesTable_82DCEE2, BattleAIScript_82DCEE1 - if_random_less_than 50, BattleAIScript_82DCEE1 + if_in_bytes AI_CV_SpAtkDown_SpecialTypeList, AI_CV_SpAtkDown_End + if_random_less_than 50, AI_CV_SpAtkDown_End score -2 -BattleAIScript_82DCEE1: +AI_CV_SpAtkDown_End: @ 82DCEE1 end -sTypesTable_82DCEE2: +AI_CV_SpAtkDown_SpecialTypeList: @ 82DCEE2 .byte TYPE_FIRE .byte TYPE_WATER .byte TYPE_GRASS @@ -1234,236 +1234,236 @@ sTypesTable_82DCEE2: .byte TYPE_DARK .byte -1 -BattleAIScript_82DCEEB: - if_hp_less_than AI_USER, 70, BattleAIScript_82DCEFA - if_stat_level_more_than AI_TARGET, STAT_SPDEF, 3, BattleAIScript_82DCF02 +AI_CV_SpDefDown: @ 82DCEEB + if_hp_less_than AI_USER, 70, AI_CV_SpDefDown2 + if_stat_level_more_than AI_TARGET, STAT_SPDEF, 3, AI_CV_SpDefDown3 -BattleAIScript_82DCEFA: - if_random_less_than 50, BattleAIScript_82DCF02 +AI_CV_SpDefDown2: @ 82DCEFA + if_random_less_than 50, AI_CV_SpDefDown3 score -2 -BattleAIScript_82DCF02: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCF0B +AI_CV_SpDefDown3: @ 82DCF02 + if_hp_more_than AI_TARGET, 70, AI_CV_SpDefDown_End score -2 -BattleAIScript_82DCF0B: +AI_CV_SpDefDown_End: @ 82DCF0B end -BattleAIScript_82DCF0C: - if_hp_less_than AI_USER, 70, BattleAIScript_82DCF1A - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCF22 +AI_CV_AccuracyDown: @ 82DCF0C + if_hp_less_than AI_USER, 70, AI_CV_AccuracyDown2 + if_hp_more_than AI_TARGET, 70, AI_CV_AccuracyDown3 -BattleAIScript_82DCF1A: - if_random_less_than 100, BattleAIScript_82DCF22 +AI_CV_AccuracyDown2: + if_random_less_than 100, AI_CV_AccuracyDown3 score -1 -BattleAIScript_82DCF22: - if_stat_level_more_than AI_USER, STAT_ACC, 4, BattleAIScript_82DCF32 - if_random_less_than 80, BattleAIScript_82DCF32 +AI_CV_AccuracyDown3: + if_stat_level_more_than AI_USER, STAT_ACC, 4, AI_CV_AccuracyDown4 + if_random_less_than 80, AI_CV_AccuracyDown4 score -2 -BattleAIScript_82DCF32: - if_not_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DCF44 - if_random_less_than 70, BattleAIScript_82DCF44 +AI_CV_AccuracyDown4: + if_not_status AI_TARGET, STATUS1_TOXIC_POISON, AI_CV_AccuracyDown5 + if_random_less_than 70, AI_CV_AccuracyDown5 score +2 -BattleAIScript_82DCF44: - if_not_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DCF56 - if_random_less_than 70, BattleAIScript_82DCF56 +AI_CV_AccuracyDown5: + if_not_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_AccuracyDown6 + if_random_less_than 70, AI_CV_AccuracyDown6 score +2 -BattleAIScript_82DCF56: - if_not_status3 AI_USER, STATUS3_ROOTED, BattleAIScript_82DCF68 - if_random_less_than 128, BattleAIScript_82DCF68 +AI_CV_AccuracyDown6: + if_not_status3 AI_USER, STATUS3_ROOTED, AI_CV_AccuracyDown7 + if_random_less_than 128, AI_CV_AccuracyDown7 score +1 -BattleAIScript_82DCF68: - if_not_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DCF7A - if_random_less_than 70, BattleAIScript_82DCF7A +AI_CV_AccuracyDown7: + if_not_status2 AI_TARGET, STATUS2_CURSED, AI_CV_AccuracyDown8 + if_random_less_than 70, AI_CV_AccuracyDown8 score +2 -BattleAIScript_82DCF7A: - if_hp_more_than AI_USER, 70, BattleAIScript_82DCF9F - if_stat_level_equal AI_TARGET, STAT_ACC, 6, BattleAIScript_82DCF9F - if_hp_less_than AI_USER, 40, BattleAIScript_82DCF9D - if_hp_less_than AI_TARGET, 40, BattleAIScript_82DCF9D - if_random_less_than 70, BattleAIScript_82DCF9F +AI_CV_AccuracyDown8: + if_hp_more_than AI_USER, 70, AI_CV_AccuracyDown_End + if_stat_level_equal AI_TARGET, STAT_ACC, 6, AI_CV_AccuracyDown_End + if_hp_less_than AI_USER, 40, AI_CV_AccuracyDown_ScoreDown2 + if_hp_less_than AI_TARGET, 40, AI_CV_AccuracyDown_ScoreDown2 + if_random_less_than 70, AI_CV_AccuracyDown_End -BattleAIScript_82DCF9D: +AI_CV_AccuracyDown_ScoreDown2: score -2 -BattleAIScript_82DCF9F: +AI_CV_AccuracyDown_End: end -BattleAIScript_82DCFA0: - if_hp_less_than AI_USER, 70, BattleAIScript_82DCFAF - if_stat_level_more_than AI_TARGET, STAT_EVASION, 3, BattleAIScript_82DCFB7 +AI_CV_EvasionDown: + if_hp_less_than AI_USER, 70, AI_CV_EvasionDown2 + if_stat_level_more_than AI_TARGET, STAT_EVASION, 3, AI_CV_EvasionDown3 -BattleAIScript_82DCFAF: - if_random_less_than 50, BattleAIScript_82DCFB7 +AI_CV_EvasionDown2: + if_random_less_than 50, AI_CV_EvasionDown3 score -2 -BattleAIScript_82DCFB7: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DCFC0 +AI_CV_EvasionDown3: + if_hp_more_than AI_TARGET, 70, AI_CV_EvasionDown_End score -2 -BattleAIScript_82DCFC0: +AI_CV_EvasionDown_End: end -BattleAIScript_82DCFC1: - if_stat_level_more_than AI_USER, STAT_ATK, 8, BattleAIScript_82DD016 - if_stat_level_more_than AI_USER, STAT_DEF, 8, BattleAIScript_82DD016 - if_stat_level_more_than AI_USER, STAT_SPATK, 8, BattleAIScript_82DD016 - if_stat_level_more_than AI_USER, STAT_SPDEF, 8, BattleAIScript_82DD016 - if_stat_level_more_than AI_USER, STAT_EVASION, 8, BattleAIScript_82DD016 - if_stat_level_less_than AI_TARGET, STAT_ATK, 4, BattleAIScript_82DD016 - if_stat_level_less_than AI_TARGET, STAT_DEF, 4, BattleAIScript_82DD016 - if_stat_level_less_than AI_TARGET, STAT_SPATK, 4, BattleAIScript_82DD016 - if_stat_level_less_than AI_TARGET, STAT_SPDEF, 4, BattleAIScript_82DD016 - if_stat_level_less_than AI_TARGET, STAT_ACC, 4, BattleAIScript_82DD016 - goto BattleAIScript_82DD01E +AI_CV_Haze: + if_stat_level_more_than AI_USER, STAT_ATK, 8, AI_CV_Haze2 + if_stat_level_more_than AI_USER, STAT_DEF, 8, AI_CV_Haze2 + if_stat_level_more_than AI_USER, STAT_SPATK, 8, AI_CV_Haze2 + if_stat_level_more_than AI_USER, STAT_SPDEF, 8, AI_CV_Haze2 + if_stat_level_more_than AI_USER, STAT_EVASION, 8, AI_CV_Haze2 + if_stat_level_less_than AI_TARGET, STAT_ATK, 4, AI_CV_Haze2 + if_stat_level_less_than AI_TARGET, STAT_DEF, 4, AI_CV_Haze2 + if_stat_level_less_than AI_TARGET, STAT_SPATK, 4, AI_CV_Haze2 + if_stat_level_less_than AI_TARGET, STAT_SPDEF, 4, AI_CV_Haze2 + if_stat_level_less_than AI_TARGET, STAT_ACC, 4, AI_CV_Haze2 + goto AI_CV_Haze3 -BattleAIScript_82DD016: - if_random_less_than 50, BattleAIScript_82DD01E +AI_CV_Haze2: + if_random_less_than 50, AI_CV_Haze3 score -3 -BattleAIScript_82DD01E: - if_stat_level_more_than AI_TARGET, STAT_ATK, 8, BattleAIScript_82DD07B - if_stat_level_more_than AI_TARGET, STAT_DEF, 8, BattleAIScript_82DD07B - if_stat_level_more_than AI_TARGET, STAT_SPATK, 8, BattleAIScript_82DD07B - if_stat_level_more_than AI_TARGET, STAT_SPDEF, 8, BattleAIScript_82DD07B - if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, BattleAIScript_82DD07B - if_stat_level_less_than AI_USER, STAT_ATK, 4, BattleAIScript_82DD07B - if_stat_level_less_than AI_USER, STAT_DEF, 4, BattleAIScript_82DD07B - if_stat_level_less_than AI_USER, STAT_SPATK, 4, BattleAIScript_82DD07B - if_stat_level_less_than AI_USER, STAT_SPDEF, 4, BattleAIScript_82DD07B - if_stat_level_less_than AI_USER, STAT_ACC, 4, BattleAIScript_82DD07B - if_random_less_than 50, BattleAIScript_82DD083 +AI_CV_Haze3: + if_stat_level_more_than AI_TARGET, STAT_ATK, 8, AI_CV_Haze4 + if_stat_level_more_than AI_TARGET, STAT_DEF, 8, AI_CV_Haze4 + if_stat_level_more_than AI_TARGET, STAT_SPATK, 8, AI_CV_Haze4 + if_stat_level_more_than AI_TARGET, STAT_SPDEF, 8, AI_CV_Haze4 + if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_Haze4 + if_stat_level_less_than AI_USER, STAT_ATK, 4, AI_CV_Haze4 + if_stat_level_less_than AI_USER, STAT_DEF, 4, AI_CV_Haze4 + if_stat_level_less_than AI_USER, STAT_SPATK, 4, AI_CV_Haze4 + if_stat_level_less_than AI_USER, STAT_SPDEF, 4, AI_CV_Haze4 + if_stat_level_less_than AI_USER, STAT_ACC, 4, AI_CV_Haze4 + if_random_less_than 50, AI_CV_Haze_End score -1 - goto BattleAIScript_82DD083 + goto AI_CV_Haze_End -BattleAIScript_82DD07B: - if_random_less_than 50, BattleAIScript_82DD083 +AI_CV_Haze4: + if_random_less_than 50, AI_CV_Haze_End score +3 -BattleAIScript_82DD083: +AI_CV_Haze_End: end -BattleAIScript_82DD084: - if_hp_more_than AI_USER, 90, BattleAIScript_82DD08D +AI_CV_Bide: + if_hp_more_than AI_USER, 90, AI_CV_Bide_End score -2 -BattleAIScript_82DD08D: +AI_CV_Bide_End: end -BattleAIScript_82DD08E: - if_stat_level_more_than AI_TARGET, STAT_ATK, 8, BattleAIScript_82DD0BD - if_stat_level_more_than AI_TARGET, STAT_DEF, 8, BattleAIScript_82DD0BD - if_stat_level_more_than AI_TARGET, STAT_SPATK, 8, BattleAIScript_82DD0BD - if_stat_level_more_than AI_TARGET, STAT_SPDEF, 8, BattleAIScript_82DD0BD - if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, BattleAIScript_82DD0BD +AI_CV_Roar: + if_stat_level_more_than AI_TARGET, STAT_ATK, 8, AI_CV_Roar2 + if_stat_level_more_than AI_TARGET, STAT_DEF, 8, AI_CV_Roar2 + if_stat_level_more_than AI_TARGET, STAT_SPATK, 8, AI_CV_Roar2 + if_stat_level_more_than AI_TARGET, STAT_SPDEF, 8, AI_CV_Roar2 + if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_Roar2 score -3 - goto BattleAIScript_82DD0C5 + goto AI_CV_Roar_End -BattleAIScript_82DD0BD: - if_random_less_than 128, BattleAIScript_82DD0C5 +AI_CV_Roar2: + if_random_less_than 128, AI_CV_Roar_End score +2 -BattleAIScript_82DD0C5: +AI_CV_Roar_End: end -BattleAIScript_82DD0C6: - if_hp_more_than AI_USER, 90, BattleAIScript_82DD0CF +AI_CV_Conversion: + if_hp_more_than AI_USER, 90, AI_CV_Conversion2 score -2 -BattleAIScript_82DD0CF: +AI_CV_Conversion2: get_turn_count - if_equal 0, BattleAIScript_82DD0DC + if_equal 0, AI_CV_Conversion_End if_random_less_than 200, Score_Minus2 -BattleAIScript_82DD0DC: +AI_CV_Conversion_End: end -BattleAIScript_82DD0DD: +AI_CV_HealWeather: get_weather - if_equal AI_WEATHER_HAIL, BattleAIScript_82DD0F5 - if_equal AI_WEATHER_RAIN, BattleAIScript_82DD0F5 - if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DD0F5 - goto BattleAIScript_82DD0F7 + if_equal AI_WEATHER_HAIL, AI_CV_HealWeather_ScoreDown2 + if_equal AI_WEATHER_RAIN, AI_CV_HealWeather_ScoreDown2 + if_equal AI_WEATHER_SANDSTORM, AI_CV_HealWeather_ScoreDown2 + goto AI_CV_Heal -BattleAIScript_82DD0F5: +AI_CV_HealWeather_ScoreDown2: score -2 -BattleAIScript_82DD0F7: - if_hp_equal AI_USER, 100, BattleAIScript_82DD11F - if_target_faster BattleAIScript_82DD126 +AI_CV_Heal: + if_hp_equal AI_USER, 100, AI_CV_Heal3 + if_target_faster AI_CV_Heal4 score -8 - goto BattleAIScript_82DD14F + goto AI_CV_Heal_End AI_CV_Heal2: - if_hp_less_than AI_USER, 50, BattleAIScript_82DD13A - if_hp_more_than AI_USER, 80, BattleAIScript_82DD11F - if_random_less_than 70, BattleAIScript_82DD13A + if_hp_less_than AI_USER, 50, AI_CV_Heal5 + if_hp_more_than AI_USER, 80, AI_CV_Heal3 + if_random_less_than 70, AI_CV_Heal5 -BattleAIScript_82DD11F: +AI_CV_Heal3: score -3 - goto BattleAIScript_82DD14F + goto AI_CV_Heal_End -BattleAIScript_82DD126: - if_hp_less_than AI_USER, 70, BattleAIScript_82DD13A - if_random_less_than 30, BattleAIScript_82DD13A +AI_CV_Heal4: + if_hp_less_than AI_USER, 70, AI_CV_Heal5 + if_random_less_than 30, AI_CV_Heal5 score -3 - goto BattleAIScript_82DD14F + goto AI_CV_Heal_End -BattleAIScript_82DD13A: - if_doesnt_have_move_with_effect AI_TARGET, EFFECT_SNATCH, BattleAIScript_82DD147 - if_random_less_than 100, BattleAIScript_82DD14F +AI_CV_Heal5: + if_doesnt_have_move_with_effect AI_TARGET, EFFECT_SNATCH, AI_CV_Heal6 + if_random_less_than 100, AI_CV_Heal_End -BattleAIScript_82DD147: - if_random_less_than 20, BattleAIScript_82DD14F +AI_CV_Heal6: + if_random_less_than 20, AI_CV_Heal_End score +2 -BattleAIScript_82DD14F: +AI_CV_Heal_End: end -BattleAIScript_82DD150: - if_user_has_no_attacking_moves BattleAIScript_82DD173 - if_hp_more_than AI_USER, 50, BattleAIScript_82DD164 - if_random_less_than 50, BattleAIScript_82DD164 +AI_CV_Toxic: + if_user_has_no_attacking_moves AI_CV_Toxic3 + if_hp_more_than AI_USER, 50, AI_CV_Toxic2 + if_random_less_than 50, AI_CV_Toxic2 score -3 -BattleAIScript_82DD164: - if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD173 - if_random_less_than 50, BattleAIScript_82DD173 +AI_CV_Toxic2: + if_hp_more_than AI_TARGET, 50, AI_CV_Toxic3 + if_random_less_than 50, AI_CV_Toxic3 score -3 -BattleAIScript_82DD173: - if_has_move_with_effect AI_USER, EFFECT_SPECIAL_DEFENSE_UP, BattleAIScript_82DD186 - if_has_move_with_effect AI_USER, EFFECT_PROTECT, BattleAIScript_82DD186 - goto BattleAIScript_82DD18E +AI_CV_Toxic3: + if_has_move_with_effect AI_USER, EFFECT_SPECIAL_DEFENSE_UP, AI_CV_Toxic4 + if_has_move_with_effect AI_USER, EFFECT_PROTECT, AI_CV_Toxic4 + goto AI_CV_Toxic_End -BattleAIScript_82DD186: - if_random_less_than 60, BattleAIScript_82DD18E +AI_CV_Toxic4: + if_random_less_than 60, AI_CV_Toxic_End score +2 -BattleAIScript_82DD18E: +AI_CV_Toxic_End: end -BattleAIScript_82DD18F: - if_hp_less_than AI_USER, 50, BattleAIScript_82DD1B2 +AI_CV_LightScreen: + if_hp_less_than AI_USER, 50, AI_CV_LightScreen_ScoreDown2 get_target_type1 - if_in_bytes sTypesTable_82DD1B5, BattleAIScript_82DD1B4 + if_in_bytes AI_CV_LightScreen_SpecialTypeList, AI_CV_LightScreen_End get_target_type2 - if_in_bytes sTypesTable_82DD1B5, BattleAIScript_82DD1B4 - if_random_less_than 50, BattleAIScript_82DD1B4 + if_in_bytes AI_CV_LightScreen_SpecialTypeList, AI_CV_LightScreen_End + if_random_less_than 50, AI_CV_LightScreen_End -BattleAIScript_82DD1B2: +AI_CV_LightScreen_ScoreDown2: score -2 -BattleAIScript_82DD1B4: +AI_CV_LightScreen_End: end -sTypesTable_82DD1B5: +AI_CV_LightScreen_SpecialTypeList: .byte TYPE_FIRE .byte TYPE_WATER .byte TYPE_GRASS @@ -1474,98 +1474,98 @@ sTypesTable_82DD1B5: .byte TYPE_DARK .byte -1 -BattleAIScript_82DD1BE: - if_target_faster BattleAIScript_82DD1ED - if_hp_not_equal AI_USER, 100, BattleAIScript_82DD1D2 +AI_CV_Rest: + if_target_faster AI_CV_Rest4 + if_hp_not_equal AI_USER, 100, AI_CV_Rest2 score -8 - goto BattleAIScript_82DD21D + goto AI_CV_Rest_End -BattleAIScript_82DD1D2: - if_hp_less_than AI_USER, 40, BattleAIScript_82DD208 - if_hp_more_than AI_USER, 50, BattleAIScript_82DD1E6 - if_random_less_than 70, BattleAIScript_82DD208 +AI_CV_Rest2: + if_hp_less_than AI_USER, 40, AI_CV_Rest6 + if_hp_more_than AI_USER, 50, AI_CV_Rest3 + if_random_less_than 70, AI_CV_Rest6 -BattleAIScript_82DD1E6: +AI_CV_Rest3: score -3 - goto BattleAIScript_82DD21D + goto AI_CV_Rest_End -BattleAIScript_82DD1ED: - if_hp_less_than AI_USER, 60, BattleAIScript_82DD208 - if_hp_more_than AI_USER, 70, BattleAIScript_82DD201 - if_random_less_than 50, BattleAIScript_82DD208 +AI_CV_Rest4: + if_hp_less_than AI_USER, 60, AI_CV_Rest6 + if_hp_more_than AI_USER, 70, AI_CV_Rest5 + if_random_less_than 50, AI_CV_Rest6 -BattleAIScript_82DD201: +AI_CV_Rest5: score -3 - goto BattleAIScript_82DD21D + goto AI_CV_Rest_End -BattleAIScript_82DD208: - if_doesnt_have_move_with_effect AI_TARGET, EFFECT_SNATCH, BattleAIScript_82DD215 - if_random_less_than 50, BattleAIScript_82DD21D +AI_CV_Rest6: + if_doesnt_have_move_with_effect AI_TARGET, EFFECT_SNATCH, AI_CV_Rest7 + if_random_less_than 50, AI_CV_Rest_End -BattleAIScript_82DD215: - if_random_less_than 10, BattleAIScript_82DD21D +AI_CV_Rest7: + if_random_less_than 10, AI_CV_Rest_End score +3 -BattleAIScript_82DD21D: +AI_CV_Rest_End: end -BattleAIScript_82DD21E: +AI_CV_OneHitKO: end -BattleAIScript_82DD21F: - if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD228 +AI_CV_SuperFang: + if_hp_more_than AI_TARGET, 50, AI_CV_SuperFang_End score -1 -BattleAIScript_82DD228: +AI_CV_SuperFang_End: end -BattleAIScript_82DD229: - if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DD256 - if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD256 - if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD256 - if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD256 - goto BattleAIScript_82DD25E +AI_CV_Trap: + if_status AI_TARGET, STATUS1_TOXIC_POISON, AI_CV_Trap2 + if_status2 AI_TARGET, STATUS2_CURSED, AI_CV_Trap2 + if_status3 AI_TARGET, STATUS3_PERISH_SONG, AI_CV_Trap2 + if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_Trap2 + goto AI_CV_Trap_End -BattleAIScript_82DD256: - if_random_less_than 128, BattleAIScript_82DD25E +AI_CV_Trap2: + if_random_less_than 128, AI_CV_Trap_End score +1 -BattleAIScript_82DD25E: +AI_CV_Trap_End: end -BattleAIScript_82DD25F: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DD285 - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DD285 - if_type_effectiveness AI_EFFECTIVENESS_x2, BattleAIScript_82DD27D - if_type_effectiveness AI_EFFECTIVENESS_x4, BattleAIScript_82DD27D - if_random_less_than 128, BattleAIScript_82DD285 +AI_CV_HighCrit: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_HighCrit_End + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_HighCrit_End + if_type_effectiveness AI_EFFECTIVENESS_x2, AI_CV_HighCrit2 + if_type_effectiveness AI_EFFECTIVENESS_x4, AI_CV_HighCrit2 + if_random_less_than 128, AI_CV_HighCrit_End -BattleAIScript_82DD27D: - if_random_less_than 128, BattleAIScript_82DD285 +AI_CV_HighCrit2: + if_random_less_than 128, AI_CV_HighCrit_End score +1 -BattleAIScript_82DD285: +AI_CV_HighCrit_End: end BattleAIScript_82DD286: if_has_move AI_USER, MOVE_PSYCH_UP, BattleAIScript_82DD2B8 -BattleAIScript_82DD28E: - if_random_less_than 128, BattleAIScript_82DD296 +AI_CV_Flatter: + if_random_less_than 128, AI_CV_Confuse score +1 -BattleAIScript_82DD296: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DD2B7 - if_random_less_than 128, BattleAIScript_82DD2A5 +AI_CV_Confuse: + if_hp_more_than AI_TARGET, 70, AI_CV_Confuse_End + if_random_less_than 128, AI_CV_Confuse2 score -1 -BattleAIScript_82DD2A5: - if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD2B7 +AI_CV_Confuse2: + if_hp_more_than AI_TARGET, 50, AI_CV_Confuse_End score -1 - if_hp_more_than AI_TARGET, 30, BattleAIScript_82DD2B7 + if_hp_more_than AI_TARGET, 30, AI_CV_Confuse_End score -1 -BattleAIScript_82DD2B7: +AI_CV_Confuse_End: end BattleAIScript_82DD2B8: @@ -1582,21 +1582,21 @@ BattleAIScript_82DD2D0: BattleAIScript_82DD2D2: end -BattleAIScript_82DD2D3: - if_hp_less_than AI_USER, 50, BattleAIScript_82DD2F6 +AI_CV_Reflect: + if_hp_less_than AI_USER, 50, AI_CV_Reflect_ScoreDown2 get_target_type1 - if_in_bytes sTypesTable_82DD2F9, BattleAIScript_82DD2F8 + if_in_bytes AI_CV_Reflect_PhysicalTypeList, AI_CV_Reflect_End get_target_type2 - if_in_bytes sTypesTable_82DD2F9, BattleAIScript_82DD2F8 - if_random_less_than 50, BattleAIScript_82DD2F8 + if_in_bytes AI_CV_Reflect_PhysicalTypeList, AI_CV_Reflect_End + if_random_less_than 50, AI_CV_Reflect_End -BattleAIScript_82DD2F6: +AI_CV_Reflect_ScoreDown2: score -2 -BattleAIScript_82DD2F8: +AI_CV_Reflect_End: end -sTypesTable_82DD2F9: +AI_CV_Reflect_PhysicalTypeList: .byte TYPE_NORMAL .byte TYPE_FIGHTING .byte TYPE_FLYING @@ -1608,160 +1608,160 @@ sTypesTable_82DD2F9: .byte TYPE_STEEL .byte -1 -BattleAIScript_82DD303: - if_hp_less_than AI_USER, 50, BattleAIScript_82DD311 - if_hp_more_than AI_TARGET, 50, BattleAIScript_82DD313 +AI_CV_Poison: + if_hp_less_than AI_USER, 50, AI_CV_Poison_ScoreDown1 + if_hp_more_than AI_TARGET, 50, AI_CV_Poison_End -BattleAIScript_82DD311: +AI_CV_Poison_ScoreDown1: score -1 -BattleAIScript_82DD313: +AI_CV_Poison_End: end -BattleAIScript_82DD314: - if_target_faster BattleAIScript_82DD328 - if_hp_more_than AI_USER, 70, BattleAIScript_82DD330 +AI_CV_Paralyze: + if_target_faster AI_CV_Paralyze2 + if_hp_more_than AI_USER, 70, AI_CV_Paralyze_End score -1 - goto BattleAIScript_82DD330 + goto AI_CV_Paralyze_End -BattleAIScript_82DD328: - if_random_less_than 20, BattleAIScript_82DD330 +AI_CV_Paralyze2: + if_random_less_than 20, AI_CV_Paralyze_End score +3 -BattleAIScript_82DD330: +AI_CV_Paralyze_End: end -BattleAIScript_82DD331: - if_target_faster BattleAIScript_82DD353 - if_hp_more_than AI_USER, 60, BattleAIScript_82DD353 - if_hp_less_than AI_USER, 40, BattleAIScript_82DD34B - if_random_less_than 180, BattleAIScript_82DD353 +AI_CV_VitalThrow: + if_target_faster AI_CV_VitalThrow_End + if_hp_more_than AI_USER, 60, AI_CV_VitalThrow_End + if_hp_less_than AI_USER, 40, AI_CV_VitalThrow2 + if_random_less_than 180, AI_CV_VitalThrow_End -BattleAIScript_82DD34B: - if_random_less_than 50, BattleAIScript_82DD353 +AI_CV_VitalThrow2: + if_random_less_than 50, AI_CV_VitalThrow_End score -1 -BattleAIScript_82DD353: +AI_CV_VitalThrow_End: end -BattleAIScript_82DD354: - if_hp_more_than AI_USER, 90, BattleAIScript_82DD381 - if_hp_more_than AI_USER, 70, BattleAIScript_82DD379 - if_hp_more_than AI_USER, 50, BattleAIScript_82DD371 - if_random_less_than 100, BattleAIScript_82DD371 +AI_CV_Substitute: + if_hp_more_than AI_USER, 90, AI_CV_Substitute4 + if_hp_more_than AI_USER, 70, AI_CV_Substitute3 + if_hp_more_than AI_USER, 50, AI_CV_Substitute2 + if_random_less_than 100, AI_CV_Substitute2 score -1 -BattleAIScript_82DD371: - if_random_less_than 100, BattleAIScript_82DD379 +AI_CV_Substitute2: + if_random_less_than 100, AI_CV_Substitute3 score -1 -BattleAIScript_82DD379: - if_random_less_than 100, BattleAIScript_82DD381 +AI_CV_Substitute3: + if_random_less_than 100, AI_CV_Substitute4 score -1 -BattleAIScript_82DD381: - if_target_faster BattleAIScript_82DD3E9 +AI_CV_Substitute4: + if_target_faster AI_CV_Substitute_End get_last_used_bank_move AI_TARGET get_move_effect_from_result - if_equal EFFECT_SLEEP, BattleAIScript_82DD3B9 - if_equal EFFECT_TOXIC, BattleAIScript_82DD3B9 - if_equal EFFECT_POISON, BattleAIScript_82DD3B9 - if_equal EFFECT_PARALYZE, BattleAIScript_82DD3B9 - if_equal EFFECT_WILL_O_WISP, BattleAIScript_82DD3B9 - if_equal EFFECT_CONFUSE, BattleAIScript_82DD3C8 - if_equal EFFECT_LEECH_SEED, BattleAIScript_82DD3D7 - goto BattleAIScript_82DD3E9 + if_equal EFFECT_SLEEP, AI_CV_Substitute5 + if_equal EFFECT_TOXIC, AI_CV_Substitute5 + if_equal EFFECT_POISON, AI_CV_Substitute5 + if_equal EFFECT_PARALYZE, AI_CV_Substitute5 + if_equal EFFECT_WILL_O_WISP, AI_CV_Substitute5 + if_equal EFFECT_CONFUSE, AI_CV_Substitute6 + if_equal EFFECT_LEECH_SEED, AI_CV_Substitute7 + goto AI_CV_Substitute_End -BattleAIScript_82DD3B9: - if_not_status AI_TARGET, STATUS1_ANY, BattleAIScript_82DD3E1 - goto BattleAIScript_82DD3E9 +AI_CV_Substitute5: + if_not_status AI_TARGET, STATUS1_ANY, AI_CV_Substitute8 + goto AI_CV_Substitute_End -BattleAIScript_82DD3C8: - if_not_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD3E1 - goto BattleAIScript_82DD3E9 +AI_CV_Substitute6: + if_not_status2 AI_TARGET, STATUS2_CONFUSION, AI_CV_Substitute8 + goto AI_CV_Substitute_End -BattleAIScript_82DD3D7: - if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DD3E9 +AI_CV_Substitute7: + if_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_Substitute_End -BattleAIScript_82DD3E1: - if_random_less_than 100, BattleAIScript_82DD3E9 +AI_CV_Substitute8: + if_random_less_than 100, AI_CV_Substitute_End score +1 -BattleAIScript_82DD3E9: +AI_CV_Substitute_End: end -BattleAIScript_82DD3EA: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DD40F - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DD40F - if_target_faster BattleAIScript_82DD408 - if_hp_more_than AI_USER, 40, BattleAIScript_82DD40F - goto BattleAIScript_82DD411 +AI_CV_Recharge: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_Recharge_ScoreDown1 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_Recharge_ScoreDown1 + if_target_faster AI_CV_Recharge2 + if_hp_more_than AI_USER, 40, AI_CV_Recharge_ScoreDown1 + goto AI_CV_Recharge_End -BattleAIScript_82DD408: - if_hp_less_than AI_USER, 60, BattleAIScript_82DD411 +AI_CV_Recharge2: + if_hp_less_than AI_USER, 60, AI_CV_Recharge_End -BattleAIScript_82DD40F: +AI_CV_Recharge_ScoreDown1: score -1 -BattleAIScript_82DD411: +AI_CV_Recharge_End: end -BattleAIScript_82DD412: - if_target_faster BattleAIScript_82DD430 +AI_CV_Disable: + if_target_faster AI_CV_Disable_End get_last_used_bank_move AI_TARGET get_move_power_from_result - if_equal 0, BattleAIScript_82DD428 + if_equal 0, AI_CV_Disable2 score +1 - goto BattleAIScript_82DD430 + goto AI_CV_Disable_End -BattleAIScript_82DD428: - if_random_less_than 100, BattleAIScript_82DD430 +AI_CV_Disable2: + if_random_less_than 100, AI_CV_Disable_End score -1 -BattleAIScript_82DD430: +AI_CV_Disable_End: end -BattleAIScript_82DD431: - if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DD4D6 - if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD4D6 - if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD4D6 - if_hp_more_than AI_USER, 30, BattleAIScript_82DD45E - if_random_less_than 10, BattleAIScript_82DD45E +AI_CV_Counter: + if_status AI_TARGET, STATUS1_SLEEP, AI_CV_Counter_ScoreDown1 + if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_Counter_ScoreDown1 + if_status2 AI_TARGET, STATUS2_CONFUSION, AI_CV_Counter_ScoreDown1 + if_hp_more_than AI_USER, 30, AI_CV_Counter2 + if_random_less_than 10, AI_CV_Counter2 score -1 -BattleAIScript_82DD45E: - if_hp_more_than AI_USER, 50, BattleAIScript_82DD46D - if_random_less_than 100, BattleAIScript_82DD46D +AI_CV_Counter2: + if_hp_more_than AI_USER, 50, AI_CV_Counter3 + if_random_less_than 100, AI_CV_Counter3 score -1 -BattleAIScript_82DD46D: +AI_CV_Counter3: if_has_move AI_USER, MOVE_MIRROR_COAT, BattleAIScript_82DD4CD get_last_used_bank_move AI_TARGET get_move_power_from_result - if_equal 0, BattleAIScript_82DD4A4 - if_target_not_taunted BattleAIScript_82DD48B - if_random_less_than 100, BattleAIScript_82DD48B + if_equal 0, AI_CV_Counter5 + if_target_not_taunted AI_CV_Counter4 + if_random_less_than 100, AI_CV_Counter4 score +1 -BattleAIScript_82DD48B: +AI_CV_Counter4: get_last_used_bank_move AI_TARGET get_move_type_from_result - if_not_in_bytes sTypesTable_82DD4D9, BattleAIScript_82DD4D6 - if_random_less_than 100, BattleAIScript_82DD4D8 + if_not_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter_ScoreDown1 + if_random_less_than 100, AI_CV_Counter_End score +1 - goto BattleAIScript_82DD4D8 + goto AI_CV_Counter_End -BattleAIScript_82DD4A4: - if_target_not_taunted BattleAIScript_82DD4B1 - if_random_less_than 100, BattleAIScript_82DD4B1 +AI_CV_Counter5: + if_target_not_taunted AI_CV_Counter6 + if_random_less_than 100, AI_CV_Counter6 score +1 -BattleAIScript_82DD4B1: +AI_CV_Counter6: get_target_type1 - if_in_bytes sTypesTable_82DD4D9, BattleAIScript_82DD4D8 + if_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter_End get_target_type2 - if_in_bytes sTypesTable_82DD4D9, BattleAIScript_82DD4D8 - if_random_less_than 50, BattleAIScript_82DD4D8 + if_in_bytes AI_CV_Counter_PhysicalTypeList, AI_CV_Counter_End + if_random_less_than 50, AI_CV_Counter_End BattleAIScript_82DD4CD: if_random_less_than 100, BattleAIScript_82DD4D5 @@ -1770,13 +1770,13 @@ BattleAIScript_82DD4CD: BattleAIScript_82DD4D5: end -BattleAIScript_82DD4D6: +AI_CV_Counter_ScoreDown1: score -1 -BattleAIScript_82DD4D8: +AI_CV_Counter_End: end -sTypesTable_82DD4D9: +AI_CV_Counter_PhysicalTypeList: .byte TYPE_NORMAL .byte TYPE_FIGHTING .byte TYPE_FLYING @@ -1788,25 +1788,25 @@ sTypesTable_82DD4D9: .byte TYPE_STEEL .byte -1 -BattleAIScript_82DD4E3: - if_any_move_disabled AI_TARGET, BattleAIScript_82DD4FC - if_target_faster BattleAIScript_82DD509 +AI_CV_Encore: + if_any_move_disabled AI_TARGET, AI_CV_Encore2 + if_target_faster AI_CV_Encore_ScoreDown2 get_last_used_bank_move AI_TARGET get_move_effect_from_result - if_not_in_bytes sMoveEffectsTable_82DD50C, BattleAIScript_82DD509 + if_not_in_bytes AI_CV_Encore_EncouragedMovesToEncore, AI_CV_Encore_ScoreDown2 -BattleAIScript_82DD4FC: - if_random_less_than 30, BattleAIScript_82DD50B +AI_CV_Encore2: + if_random_less_than 30, AI_CV_Encore_End score +3 - goto BattleAIScript_82DD50B + goto AI_CV_Encore_End -BattleAIScript_82DD509: +AI_CV_Encore_ScoreDown2: score -2 -BattleAIScript_82DD50B: +AI_CV_Encore_End: end -sMoveEffectsTable_82DD50C: +AI_CV_Encore_EncouragedMovesToEncore: .byte EFFECT_DREAM_EATER .byte EFFECT_ATTACK_UP .byte EFFECT_DEFENSE_UP @@ -1871,108 +1871,108 @@ sMoveEffectsTable_82DD50C: .byte EFFECT_CAMOUFLAGE .byte -1 -BattleAIScript_82DD54B: - if_hp_less_than AI_TARGET, 80, BattleAIScript_82DD574 - if_target_faster BattleAIScript_82DD566 - if_hp_more_than AI_USER, 40, BattleAIScript_82DD574 +AI_CV_PainSplit: + if_hp_less_than AI_TARGET, 80, AI_CV_PainSplit_ScoreDown1 + if_target_faster AI_CV_PainSplit2 + if_hp_more_than AI_USER, 40, AI_CV_PainSplit_ScoreDown1 score +1 - goto BattleAIScript_82DD576 + goto AI_CV_PainSplit_End -BattleAIScript_82DD566: - if_hp_more_than AI_USER, 60, BattleAIScript_82DD574 +AI_CV_PainSplit2: + if_hp_more_than AI_USER, 60, AI_CV_PainSplit_ScoreDown1 score +1 - goto BattleAIScript_82DD576 + goto AI_CV_PainSplit_End -BattleAIScript_82DD574: +AI_CV_PainSplit_ScoreDown1: score -1 -BattleAIScript_82DD576: +AI_CV_PainSplit_End: end -BattleAIScript_82DD577: +AI_CV_Snore: score +2 end -BattleAIScript_82DD57A: - if_random_less_than 128, BattleAIScript_82DD582 +AI_CV_LockOn: + if_random_less_than 128, AI_CV_LockOn_End score +2 -BattleAIScript_82DD582: +AI_CV_LockOn_End: end -BattleAIScript_82DD583: +AI_CV_SleepTalk: if_status AI_USER, STATUS1_SLEEP, Score_Plus10 score -5 end -BattleAIScript_82DD590: +AI_CV_DestinyBond: score -1 - if_target_faster BattleAIScript_82DD5C5 - if_hp_more_than AI_USER, 70, BattleAIScript_82DD5C5 - if_random_less_than 128, BattleAIScript_82DD5A7 + if_target_faster AI_CV_DestinyBond_End + if_hp_more_than AI_USER, 70, AI_CV_DestinyBond_End + if_random_less_than 128, AI_CV_DestinyBond2 score +1 -BattleAIScript_82DD5A7: - if_hp_more_than AI_USER, 50, BattleAIScript_82DD5C5 - if_random_less_than 128, BattleAIScript_82DD5B6 +AI_CV_DestinyBond2: + if_hp_more_than AI_USER, 50, AI_CV_DestinyBond_End + if_random_less_than 128, AI_CV_DestinyBond3 score +1 -BattleAIScript_82DD5B6: - if_hp_more_than AI_USER, 30, BattleAIScript_82DD5C5 - if_random_less_than 100, BattleAIScript_82DD5C5 +AI_CV_DestinyBond3: + if_hp_more_than AI_USER, 30, AI_CV_DestinyBond_End + if_random_less_than 100, AI_CV_DestinyBond_End score +2 -BattleAIScript_82DD5C5: +AI_CV_DestinyBond_End: end -BattleAIScript_82DD5C6: - if_target_faster BattleAIScript_82DD5E6 - if_hp_more_than AI_USER, 33, BattleAIScript_82DD608 - if_hp_more_than AI_USER, 20, BattleAIScript_82DD60A - if_hp_less_than AI_USER, 8, BattleAIScript_82DD5F9 - goto BattleAIScript_82DD5FB +AI_CV_Flail: + if_target_faster AI_CV_Flail2 + if_hp_more_than AI_USER, 33, AI_CV_Flail_ScoreDown1 + if_hp_more_than AI_USER, 20, AI_CV_Flail_End + if_hp_less_than AI_USER, 8, AI_CV_Flail_ScoreUp1 + goto AI_CV_Flail3 -BattleAIScript_82DD5E6: - if_hp_more_than AI_USER, 60, BattleAIScript_82DD608 - if_hp_more_than AI_USER, 40, BattleAIScript_82DD60A - goto BattleAIScript_82DD5FB +AI_CV_Flail2: + if_hp_more_than AI_USER, 60, AI_CV_Flail_ScoreDown1 + if_hp_more_than AI_USER, 40, AI_CV_Flail_End + goto AI_CV_Flail3 -BattleAIScript_82DD5F9: +AI_CV_Flail_ScoreUp1: score +1 -BattleAIScript_82DD5FB: - if_random_less_than 100, BattleAIScript_82DD60A +AI_CV_Flail3: + if_random_less_than 100, AI_CV_Flail_End score +1 - goto BattleAIScript_82DD60A + goto AI_CV_Flail_End -BattleAIScript_82DD608: +AI_CV_Flail_ScoreDown1: score -1 -BattleAIScript_82DD60A: +AI_CV_Flail_End: end -BattleAIScript_82DD60B: - if_status AI_TARGET, STATUS1_ANY, BattleAIScript_82DD621 - if_status_in_party AI_TARGET, STATUS1_ANY, BattleAIScript_82DD621 +AI_CV_HealBell: + if_status AI_TARGET, STATUS1_ANY, AI_CV_HealBell_End + if_status_in_party AI_TARGET, STATUS1_ANY, AI_CV_HealBell_End score -5 -BattleAIScript_82DD621: +AI_CV_HealBell_End: end -BattleAIScript_82DD622: +AI_CV_Thief: get_hold_effect AI_TARGET - if_not_in_bytes sHoldEffectsTable_82DD63D, BattleAIScript_82DD63A - if_random_less_than 50, BattleAIScript_82DD63C + if_not_in_bytes AI_CV_Thief_EncourageItemsToSteal, AI_CV_Thief_ScoreDown2 + if_random_less_than 50, AI_CV_Thief_End score +1 - goto BattleAIScript_82DD63C + goto AI_CV_Thief_End -BattleAIScript_82DD63A: +AI_CV_Thief_ScoreDown2: score -2 -BattleAIScript_82DD63C: +AI_CV_Thief_End: end -sHoldEffectsTable_82DD63D: +AI_CV_Thief_EncourageItemsToSteal: .byte HOLD_EFFECT_CURE_SLP .byte HOLD_EFFECT_CURE_STATUS .byte HOLD_EFFECT_RESTORE_HP @@ -1982,317 +1982,317 @@ sHoldEffectsTable_82DD63D: .byte HOLD_EFFECT_THICK_CLUB .byte -1 -BattleAIScript_82DD645: +AI_CV_Curse: get_user_type1 - if_equal TYPE_GHOST, BattleAIScript_82DD68A + if_equal TYPE_GHOST, AI_CV_Curse4 get_user_type2 - if_equal TYPE_GHOST, BattleAIScript_82DD68A - if_stat_level_more_than AI_USER, STAT_DEF, 9, BattleAIScript_82DD693 - if_random_less_than 128, BattleAIScript_82DD665 + if_equal TYPE_GHOST, AI_CV_Curse4 + if_stat_level_more_than AI_USER, STAT_DEF, 9, AI_CV_Curse_End + if_random_less_than 128, AI_CV_Curse2 score +1 -BattleAIScript_82DD665: - if_stat_level_more_than AI_USER, STAT_DEF, 7, BattleAIScript_82DD693 - if_random_less_than 128, BattleAIScript_82DD675 +AI_CV_Curse2: + if_stat_level_more_than AI_USER, STAT_DEF, 7, AI_CV_Curse_End + if_random_less_than 128, AI_CV_Curse3 score +1 -BattleAIScript_82DD675: - if_stat_level_more_than AI_USER, STAT_DEF, 6, BattleAIScript_82DD693 - if_random_less_than 128, BattleAIScript_82DD693 +AI_CV_Curse3: + if_stat_level_more_than AI_USER, STAT_DEF, 6, AI_CV_Curse_End + if_random_less_than 128, AI_CV_Curse_End score +1 - goto BattleAIScript_82DD693 + goto AI_CV_Curse_End -BattleAIScript_82DD68A: - if_hp_more_than AI_USER, 80, BattleAIScript_82DD693 +AI_CV_Curse4: + if_hp_more_than AI_USER, 80, AI_CV_Curse_End score -1 -BattleAIScript_82DD693: +AI_CV_Curse_End: end -BattleAIScript_82DD694: +AI_CV_Protect: get_protect_count AI_USER - if_more_than 1, BattleAIScript_82DD75A - if_status AI_USER, STATUS1_TOXIC_POISON, BattleAIScript_82DD751 - if_status2 AI_USER, STATUS2_CURSED, BattleAIScript_82DD751 - if_status3 AI_USER, STATUS3_PERISH_SONG, BattleAIScript_82DD751 - if_status2 AI_USER, STATUS2_INFATUATION, BattleAIScript_82DD751 - if_status3 AI_USER, STATUS3_LEECHSEED, BattleAIScript_82DD751 - if_status3 AI_USER, STATUS3_YAWN, BattleAIScript_82DD751 - if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, BattleAIScript_82DD751 - if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, BattleAIScript_82DD751 - if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DD730 - if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD730 - if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD730 - if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD730 - if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DD730 - if_status3 AI_TARGET, STATUS3_YAWN, BattleAIScript_82DD730 + if_more_than 1, AI_CV_Protect_ScoreDown2 + if_status AI_USER, STATUS1_TOXIC_POISON, AI_CV_Protect3 + if_status2 AI_USER, STATUS2_CURSED, AI_CV_Protect3 + if_status3 AI_USER, STATUS3_PERISH_SONG, AI_CV_Protect3 + if_status2 AI_USER, STATUS2_INFATUATION, AI_CV_Protect3 + if_status3 AI_USER, STATUS3_LEECHSEED, AI_CV_Protect3 + if_status3 AI_USER, STATUS3_YAWN, AI_CV_Protect3 + if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, AI_CV_Protect3 + if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, AI_CV_Protect3 + if_status AI_TARGET, STATUS1_TOXIC_POISON, AI_CV_Protect_ScoreUp2 + if_status2 AI_TARGET, STATUS2_CURSED, AI_CV_Protect_ScoreUp2 + if_status3 AI_TARGET, STATUS3_PERISH_SONG, AI_CV_Protect_ScoreUp2 + if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_Protect_ScoreUp2 + if_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_Protect_ScoreUp2 + if_status3 AI_TARGET, STATUS3_YAWN, AI_CV_Protect_ScoreUp2 get_last_used_bank_move AI_TARGET get_move_effect_from_result - if_not_equal EFFECT_LOCK_ON, BattleAIScript_82DD730 - goto BattleAIScript_82DD732 + if_not_equal EFFECT_LOCK_ON, AI_CV_Protect_ScoreUp2 + goto AI_CV_Protect2 -BattleAIScript_82DD730: +AI_CV_Protect_ScoreUp2: score +2 -BattleAIScript_82DD732: - if_random_less_than 128, BattleAIScript_82DD73A +AI_CV_Protect2: + if_random_less_than 128, AI_CV_Protect4 score -1 -BattleAIScript_82DD73A: - get_protect_count AI_USER - if_equal 0, BattleAIScript_82DD75C - score -1 - if_random_less_than 128, BattleAIScript_82DD75C - score -1 - goto BattleAIScript_82DD75C - -BattleAIScript_82DD751: +AI_CV_Protect3: get_last_used_bank_move AI_TARGET get_move_effect_from_result - if_not_equal EFFECT_LOCK_ON, BattleAIScript_82DD75C + if_not_equal EFFECT_LOCK_ON, AI_CV_Protect_End + +AI_CV_Protect4: + get_protect_count AI_USER + if_equal 0, AI_CV_Protect_End + score -1 + if_random_less_than 128, AI_CV_Protect_End + score -1 + goto AI_CV_Protect_End -BattleAIScript_82DD75A: +AI_CV_Protect_ScoreDown2: score -2 -BattleAIScript_82DD75C: +AI_CV_Protect_End: end -BattleAIScript_82DD75D: +AI_CV_Foresight: get_user_type1 - if_equal TYPE_GHOST, BattleAIScript_82DD77C + if_equal TYPE_GHOST, AI_CV_Foresight2 get_user_type2 - if_equal TYPE_GHOST, BattleAIScript_82DD77C - if_stat_level_more_than AI_USER, STAT_EVASION, 8, BattleAIScript_82DD782 + if_equal TYPE_GHOST, AI_CV_Foresight2 + if_stat_level_more_than AI_USER, STAT_EVASION, 8, AI_CV_Foresight3 score -2 - goto BattleAIScript_82DD78A + goto AI_CV_Foresight_End -BattleAIScript_82DD77C: - if_random_less_than 80, BattleAIScript_82DD78A +AI_CV_Foresight2: + if_random_less_than 80, AI_CV_Foresight_End -BattleAIScript_82DD782: - if_random_less_than 80, BattleAIScript_82DD78A +AI_CV_Foresight3: + if_random_less_than 80, AI_CV_Foresight_End score +2 -BattleAIScript_82DD78A: +AI_CV_Foresight_End: end -BattleAIScript_82DD78B: - if_hp_less_than AI_USER, 4, BattleAIScript_82DD799 - if_hp_less_than AI_USER, 35, BattleAIScript_82DD7A0 +AI_CV_Endure: + if_hp_less_than AI_USER, 4, AI_CV_Endure2 + if_hp_less_than AI_USER, 35, AI_CV_Endure3 -BattleAIScript_82DD799: +AI_CV_Endure2: score -1 - goto BattleAIScript_82DD7A8 + goto AI_CV_Endure_End -BattleAIScript_82DD7A0: - if_random_less_than 70, BattleAIScript_82DD7A8 +AI_CV_Endure3: + if_random_less_than 70, AI_CV_Endure_End score +1 -BattleAIScript_82DD7A8: +AI_CV_Endure_End: end -BattleAIScript_82DD7A9: - if_stat_level_more_than AI_USER, STAT_ATK, 8, BattleAIScript_82DD7D6 - if_stat_level_more_than AI_USER, STAT_DEF, 8, BattleAIScript_82DD7D6 - if_stat_level_more_than AI_USER, STAT_SPATK, 8, BattleAIScript_82DD7D6 - if_stat_level_more_than AI_USER, STAT_SPDEF, 8, BattleAIScript_82DD7D6 - if_stat_level_more_than AI_USER, STAT_EVASION, 8, BattleAIScript_82DD7D6 - goto BattleAIScript_82DD7FC +AI_CV_BatonPass: + if_stat_level_more_than AI_USER, STAT_ATK, 8, AI_CV_BatonPass2 + if_stat_level_more_than AI_USER, STAT_DEF, 8, AI_CV_BatonPass2 + if_stat_level_more_than AI_USER, STAT_SPATK, 8, AI_CV_BatonPass2 + if_stat_level_more_than AI_USER, STAT_SPDEF, 8, AI_CV_BatonPass2 + if_stat_level_more_than AI_USER, STAT_EVASION, 8, AI_CV_BatonPass2 + goto AI_CV_BatonPass5 -BattleAIScript_82DD7D6: - if_target_faster BattleAIScript_82DD7E8 - if_hp_more_than AI_USER, 60, BattleAIScript_82DD844 - goto BattleAIScript_82DD7EF +AI_CV_BatonPass2: + if_target_faster AI_CV_BatonPass3 + if_hp_more_than AI_USER, 60, AI_CV_BatonPass_End + goto AI_CV_BatonPass4 -BattleAIScript_82DD7E8: - if_hp_more_than AI_USER, 70, BattleAIScript_82DD844 +AI_CV_BatonPass3: + if_hp_more_than AI_USER, 70, AI_CV_BatonPass_End -BattleAIScript_82DD7EF: - if_random_less_than 80, BattleAIScript_82DD844 +AI_CV_BatonPass4: + if_random_less_than 80, AI_CV_BatonPass_End score +2 - goto BattleAIScript_82DD844 + goto AI_CV_BatonPass_End -BattleAIScript_82DD7FC: - if_stat_level_more_than AI_USER, STAT_ATK, 7, BattleAIScript_82DD829 - if_stat_level_more_than AI_USER, STAT_DEF, 7, BattleAIScript_82DD829 - if_stat_level_more_than AI_USER, STAT_SPATK, 7, BattleAIScript_82DD829 - if_stat_level_more_than AI_USER, STAT_SPDEF, 7, BattleAIScript_82DD829 - if_stat_level_more_than AI_USER, STAT_EVASION, 7, BattleAIScript_82DD829 - goto BattleAIScript_82DD842 +AI_CV_BatonPass5: + if_stat_level_more_than AI_USER, STAT_ATK, 7, AI_CV_BatonPass7 + if_stat_level_more_than AI_USER, STAT_DEF, 7, AI_CV_BatonPass7 + if_stat_level_more_than AI_USER, STAT_SPATK, 7, AI_CV_BatonPass7 + if_stat_level_more_than AI_USER, STAT_SPDEF, 7, AI_CV_BatonPass7 + if_stat_level_more_than AI_USER, STAT_EVASION, 7, AI_CV_BatonPass7 + goto AI_CV_BatonPass_ScoreDown2 -BattleAIScript_82DD829: - if_target_faster BattleAIScript_82DD83B - if_hp_more_than AI_USER, 60, BattleAIScript_82DD842 - goto BattleAIScript_82DD844 +AI_CV_BatonPass7: + if_target_faster AI_CV_BatonPass8 + if_hp_more_than AI_USER, 60, AI_CV_BatonPass_ScoreDown2 + goto AI_CV_BatonPass_End -BattleAIScript_82DD83B: - if_hp_less_than AI_USER, 70, BattleAIScript_82DD844 +AI_CV_BatonPass8: + if_hp_less_than AI_USER, 70, AI_CV_BatonPass_End -BattleAIScript_82DD842: +AI_CV_BatonPass_ScoreDown2: score -2 -BattleAIScript_82DD844: +AI_CV_BatonPass_End: end -BattleAIScript_82DD845: +AI_CV_Pursuit: is_first_turn_for AI_USER - if_not_equal 0, BattleAIScript_82DD87A + if_not_equal 0, AI_CV_Pursuit_End get_target_type1 - if_equal TYPE_GHOST, BattleAIScript_82DD872 + if_equal TYPE_GHOST, AI_CV_Pursuit2 get_target_type1 - if_equal TYPE_PSYCHIC, BattleAIScript_82DD872 + if_equal TYPE_PSYCHIC, AI_CV_Pursuit2 get_target_type2 - if_equal TYPE_GHOST, BattleAIScript_82DD872 + if_equal TYPE_GHOST, AI_CV_Pursuit2 get_target_type2 - if_equal TYPE_PSYCHIC, BattleAIScript_82DD872 - goto BattleAIScript_82DD87A + if_equal TYPE_PSYCHIC, AI_CV_Pursuit2 + goto AI_CV_Pursuit_End -BattleAIScript_82DD872: - if_random_less_than 128, BattleAIScript_82DD87A +AI_CV_Pursuit2: + if_random_less_than 128, AI_CV_Pursuit_End score +1 -BattleAIScript_82DD87A: +AI_CV_Pursuit_End: end -BattleAIScript_82DD87B: - if_user_faster BattleAIScript_82DD889 +AI_CV_RainDance: + if_user_faster AI_CV_RainDance2 get_ability AI_USER - if_equal ABILITY_SWIFT_SWIM, BattleAIScript_82DD8B0 + if_equal ABILITY_SWIFT_SWIM, AI_CV_RainDance3 -BattleAIScript_82DD889: - if_hp_less_than AI_USER, 40, BattleAIScript_82DD8B7 +AI_CV_RainDance2: + if_hp_less_than AI_USER, 40, AI_CV_RainDance_ScoreDown1 get_weather - if_equal AI_WEATHER_HAIL, BattleAIScript_82DD8B0 - if_equal AI_WEATHER_SUN, BattleAIScript_82DD8B0 - if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DD8B0 + if_equal AI_WEATHER_HAIL, AI_CV_RainDance3 + if_equal AI_WEATHER_SUN, AI_CV_RainDance3 + if_equal AI_WEATHER_SANDSTORM, AI_CV_RainDance3 get_ability AI_USER - if_equal ABILITY_RAIN_DISH, BattleAIScript_82DD8B0 - goto BattleAIScript_82DD8B9 + if_equal ABILITY_RAIN_DISH, AI_CV_RainDance3 + goto AI_CV_RainDance_End -BattleAIScript_82DD8B0: +AI_CV_RainDance3: score +1 - goto BattleAIScript_82DD8B9 + goto AI_CV_RainDance_End -BattleAIScript_82DD8B7: +AI_CV_RainDance_ScoreDown1: score -1 -BattleAIScript_82DD8B9: +AI_CV_RainDance_End: end -BattleAIScript_82DD8BA: - if_hp_less_than AI_USER, 40, BattleAIScript_82DD8E0 +AI_CV_SunnyDay: + if_hp_less_than AI_USER, 40, AI_CV_SunnyDay_ScoreDown1 get_weather - if_equal AI_WEATHER_HAIL, BattleAIScript_82DD8D9 - if_equal AI_WEATHER_RAIN, BattleAIScript_82DD8D9 - if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DD8D9 - goto BattleAIScript_82DD8E2 + if_equal AI_WEATHER_HAIL, AI_CV_SunnyDay2 + if_equal AI_WEATHER_RAIN, AI_CV_SunnyDay2 + if_equal AI_WEATHER_SANDSTORM, AI_CV_SunnyDay2 + goto AI_CV_SunnyDay_End -BattleAIScript_82DD8D9: +AI_CV_SunnyDay2: score +1 - goto BattleAIScript_82DD8E2 + goto AI_CV_SunnyDay_End -BattleAIScript_82DD8E0: +AI_CV_SunnyDay_ScoreDown1: score -1 -BattleAIScript_82DD8E2: +AI_CV_SunnyDay_End: end -BattleAIScript_82DD8E3: - if_hp_less_than AI_USER, 90, BattleAIScript_82DD8EF - goto BattleAIScript_82DD8F1 +AI_CV_BellyDrum: + if_hp_less_than AI_USER, 90, AI_CV_BellyDrum_ScoreDown2 + goto AI_CV_BellyDrum_End -BattleAIScript_82DD8EF: +AI_CV_BellyDrum_ScoreDown2: score -2 -BattleAIScript_82DD8F1: +AI_CV_BellyDrum_End: end -BattleAIScript_82DD8F2: - if_stat_level_more_than AI_TARGET, STAT_ATK, 8, BattleAIScript_82DD91F - if_stat_level_more_than AI_TARGET, STAT_DEF, 8, BattleAIScript_82DD91F - if_stat_level_more_than AI_TARGET, STAT_SPATK, 8, BattleAIScript_82DD91F - if_stat_level_more_than AI_TARGET, STAT_SPDEF, 8, BattleAIScript_82DD91F - if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, BattleAIScript_82DD91F - goto BattleAIScript_82DD957 +AI_CV_PsychUp: + if_stat_level_more_than AI_TARGET, STAT_ATK, 8, AI_CV_PsychUp2 + if_stat_level_more_than AI_TARGET, STAT_DEF, 8, AI_CV_PsychUp2 + if_stat_level_more_than AI_TARGET, STAT_SPATK, 8, AI_CV_PsychUp2 + if_stat_level_more_than AI_TARGET, STAT_SPDEF, 8, AI_CV_PsychUp2 + if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_PsychUp2 + goto AI_CV_PsychUp_ScoreDown2 -BattleAIScript_82DD91F: - if_stat_level_less_than AI_USER, STAT_ATK, 7, BattleAIScript_82DD954 - if_stat_level_less_than AI_USER, STAT_DEF, 7, BattleAIScript_82DD954 - if_stat_level_less_than AI_USER, STAT_SPATK, 7, BattleAIScript_82DD954 - if_stat_level_less_than AI_USER, STAT_SPDEF, 7, BattleAIScript_82DD954 - if_stat_level_less_than AI_USER, STAT_EVASION, 7, BattleAIScript_82DD952 - if_random_less_than 50, BattleAIScript_82DD959 - goto BattleAIScript_82DD957 +AI_CV_PsychUp2: + if_stat_level_less_than AI_USER, STAT_ATK, 7, AI_CV_PsychUp3 + if_stat_level_less_than AI_USER, STAT_DEF, 7, AI_CV_PsychUp3 + if_stat_level_less_than AI_USER, STAT_SPATK, 7, AI_CV_PsychUp3 + if_stat_level_less_than AI_USER, STAT_SPDEF, 7, AI_CV_PsychUp3 + if_stat_level_less_than AI_USER, STAT_EVASION, 7, AI_CV_PsychUp_ScoreUp1 + if_random_less_than 50, AI_CV_PsychUp_End + goto AI_CV_PsychUp_ScoreDown2 -BattleAIScript_82DD952: +AI_CV_PsychUp_ScoreUp1: score +1 -BattleAIScript_82DD954: +AI_CV_PsychUp3: score +1 end -BattleAIScript_82DD957: +AI_CV_PsychUp_ScoreDown2: score -2 -BattleAIScript_82DD959: +AI_CV_PsychUp_End: end -BattleAIScript_82DD95A: - if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DD9FF - if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD9FF - if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD9FF - if_hp_more_than AI_USER, 30, BattleAIScript_82DD987 - if_random_less_than 10, BattleAIScript_82DD987 +AI_CV_MirrorCoat: + if_status AI_TARGET, STATUS1_SLEEP, AI_CV_MirrorCoat_ScoreDown1 + if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_MirrorCoat_ScoreDown1 + if_status2 AI_TARGET, STATUS2_CONFUSION, AI_CV_MirrorCoat_ScoreDown1 + if_hp_more_than AI_USER, 30, AI_CV_MirrorCoat2 + if_random_less_than 10, AI_CV_MirrorCoat2 score -1 -BattleAIScript_82DD987: - if_hp_more_than AI_USER, 50, BattleAIScript_82DD996 - if_random_less_than 100, BattleAIScript_82DD996 +AI_CV_MirrorCoat2: + if_hp_more_than AI_USER, 50, AI_CV_MirrorCoat3 + if_random_less_than 100, AI_CV_MirrorCoat3 score -1 -BattleAIScript_82DD996: - if_has_move AI_USER, MOVE_COUNTER, BattleAIScript_82DD9F6 +AI_CV_MirrorCoat3: + if_has_move AI_USER, MOVE_COUNTER, AI_CV_MirrorCoat_ScoreUp4 get_last_used_bank_move AI_TARGET get_move_power_from_result - if_equal 0, BattleAIScript_82DD9CD - if_target_not_taunted BattleAIScript_82DD9B4 - if_random_less_than 100, BattleAIScript_82DD9B4 + if_equal 0, AI_CV_MirrorCoat5 + if_target_not_taunted AI_CV_MirrorCoat4 + if_random_less_than 100, AI_CV_MirrorCoat4 score +1 -BattleAIScript_82DD9B4: +AI_CV_MirrorCoat4: get_last_used_bank_move AI_TARGET get_move_type_from_result - if_not_in_bytes sTypesTable_82DDA02, BattleAIScript_82DD9FF - if_random_less_than 100, BattleAIScript_82DDA01 + if_not_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat_ScoreDown1 + if_random_less_than 100, AI_CV_MirrorCoat_End score +1 - goto BattleAIScript_82DDA01 + goto AI_CV_MirrorCoat_End -BattleAIScript_82DD9CD: - if_target_not_taunted BattleAIScript_82DD9DA - if_random_less_than 100, BattleAIScript_82DD9DA +AI_CV_MirrorCoat5: + if_target_not_taunted AI_CV_MirrorCoat6 + if_random_less_than 100, AI_CV_MirrorCoat6 score +1 -BattleAIScript_82DD9DA: +AI_CV_MirrorCoat6: get_target_type1 - if_in_bytes sTypesTable_82DDA02, BattleAIScript_82DDA01 + if_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat_End get_target_type2 - if_in_bytes sTypesTable_82DDA02, BattleAIScript_82DDA01 - if_random_less_than 50, BattleAIScript_82DDA01 + if_in_bytes AI_CV_MirrorCoat_SpecialTypeList, AI_CV_MirrorCoat_End + if_random_less_than 50, AI_CV_MirrorCoat_End -BattleAIScript_82DD9F6: - if_random_less_than 100, BattleAIScript_82DD9FE +AI_CV_MirrorCoat_ScoreUp4: + if_random_less_than 100, AI_CV_MirrorCoat_ScoreUp4_End score +4 -BattleAIScript_82DD9FE: +AI_CV_MirrorCoat_ScoreUp4_End: end -BattleAIScript_82DD9FF: +AI_CV_MirrorCoat_ScoreDown1: score -1 -BattleAIScript_82DDA01: +AI_CV_MirrorCoat_End: end -sTypesTable_82DDA02: +AI_CV_MirrorCoat_SpecialTypeList: .byte TYPE_FIRE .byte TYPE_WATER .byte TYPE_GRASS @@ -2303,166 +2303,166 @@ sTypesTable_82DDA02: .byte TYPE_DARK .byte -1 -BattleAIScript_82DDA0B: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDA2C - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDA2C - if_has_move_with_effect AI_TARGET, EFFECT_PROTECT, BattleAIScript_82DDA2C - if_hp_more_than AI_USER, 38, BattleAIScript_82DDA2E +AI_CV_ChargeUpMove: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_ChargeUpMove_ScoreDown2 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_ChargeUpMove_ScoreDown2 + if_has_move_with_effect AI_TARGET, EFFECT_PROTECT, AI_CV_ChargeUpMove_ScoreDown2 + if_hp_more_than AI_USER, 38, AI_CV_ChargeUpMove_End score -1 - goto BattleAIScript_82DDA2E + goto AI_CV_ChargeUpMove_End -BattleAIScript_82DDA2C: +AI_CV_ChargeUpMove_ScoreDown2: score -2 -BattleAIScript_82DDA2E: +AI_CV_ChargeUpMove_End: end -BattleAIScript_82DDA2F: - if_doesnt_have_move_with_effect AI_TARGET, EFFECT_PROTECT, BattleAIScript_82DDA3D +AI_CV_Fly: + if_doesnt_have_move_with_effect AI_TARGET, EFFECT_PROTECT, AI_CV_Fly2 score -1 - goto BattleAIScript_82DDAB4 + goto AI_CV_Fly_End -BattleAIScript_82DDA3D: - if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DDAAC - if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DDAAC - if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DDAAC +AI_CV_Fly2: + if_status AI_TARGET, STATUS1_TOXIC_POISON, AI_CV_Fly6 + if_status2 AI_TARGET, STATUS2_CURSED, AI_CV_Fly6 + if_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_Fly6 get_weather - if_equal AI_WEATHER_HAIL, BattleAIScript_82DDA6D - if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DDA88 - goto BattleAIScript_82DDA98 + if_equal AI_WEATHER_HAIL, AI_CV_Fly3 + if_equal AI_WEATHER_SANDSTORM, AI_CV_Fly4 + goto AI_CV_Fly5 -BattleAIScript_82DDA6D: +AI_CV_Fly3: get_user_type1 - if_in_bytes sTypesTable_82DDAB5, BattleAIScript_82DDAAC + if_in_bytes AI_CV_Fly_TypesToEncourage, AI_CV_Fly6 get_user_type2 - if_in_bytes sTypesTable_82DDAB5, BattleAIScript_82DDAAC - goto BattleAIScript_82DDA98 + if_in_bytes AI_CV_Fly_TypesToEncourage, AI_CV_Fly6 + goto AI_CV_Fly5 -BattleAIScript_82DDA88: +AI_CV_Fly4: get_user_type1 - if_equal TYPE_ICE, BattleAIScript_82DDAAC + if_equal TYPE_ICE, AI_CV_Fly6 get_user_type2 - if_equal TYPE_ICE, BattleAIScript_82DDAAC + if_equal TYPE_ICE, AI_CV_Fly6 -BattleAIScript_82DDA98: - if_target_faster BattleAIScript_82DDAB4 +AI_CV_Fly5: + if_target_faster AI_CV_Fly_End get_last_used_bank_move AI_TARGET get_move_effect_from_result - if_not_equal EFFECT_LOCK_ON, BattleAIScript_82DDAAC - goto BattleAIScript_82DDAB4 + if_not_equal EFFECT_LOCK_ON, AI_CV_Fly6 + goto AI_CV_Fly_End -BattleAIScript_82DDAAC: - if_random_less_than 80, BattleAIScript_82DDAB4 +AI_CV_Fly6: + if_random_less_than 80, AI_CV_Fly_End score +1 -BattleAIScript_82DDAB4: +AI_CV_Fly_End: end -sTypesTable_82DDAB5: +AI_CV_Fly_TypesToEncourage: .byte TYPE_GROUND .byte TYPE_ROCK .byte TYPE_STEEL .byte -1 -BattleAIScript_82DDAB9: +AI_CV_FakeOut: score +2 end -BattleAIScript_82DDABC: +AI_CV_SpitUp: get_stockpile_count AI_USER - if_less_than 2, BattleAIScript_82DDACC - if_random_less_than 80, BattleAIScript_82DDACC + if_less_than 2, AI_CV_SpitUp_End + if_random_less_than 80, AI_CV_SpitUp_End score +2 -BattleAIScript_82DDACC: +AI_CV_SpitUp_End: end -BattleAIScript_82DDACD: - if_hp_less_than AI_USER, 40, BattleAIScript_82DDAF3 +AI_CV_Hail: + if_hp_less_than AI_USER, 40, AI_CV_Hail_ScoreDown1 get_weather - if_equal AI_WEATHER_SUN, BattleAIScript_82DDAEC - if_equal AI_WEATHER_RAIN, BattleAIScript_82DDAEC - if_equal AI_WEATHER_SANDSTORM, BattleAIScript_82DDAEC - goto BattleAIScript_82DDAF5 + if_equal AI_WEATHER_SUN, AI_CV_Hail2 + if_equal AI_WEATHER_RAIN, AI_CV_Hail2 + if_equal AI_WEATHER_SANDSTORM, AI_CV_Hail2 + goto AI_CV_Hail_End -BattleAIScript_82DDAEC: +AI_CV_Hail2: score +1 - goto BattleAIScript_82DDAF5 + goto AI_CV_Hail_End -BattleAIScript_82DDAF3: +AI_CV_Hail_ScoreDown1: score -1 -BattleAIScript_82DDAF5: +AI_CV_Hail_End: end -BattleAIScript_82DDAF6: - if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, BattleAIScript_82DDB02 +AI_CV_Facade: + if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End score +1 -BattleAIScript_82DDB02: +AI_CV_Facade_End: end -BattleAIScript_82DDB03: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDB42 - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDB42 - if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DDB59 - if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDB49 - if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDB49 +AI_CV_FocusPunch: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_FocusPunch2 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_FocusPunch2 + if_status AI_TARGET, STATUS1_SLEEP, AI_CV_FocusPunch_ScoreUp1 + if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_FocusPunch3 + if_status2 AI_TARGET, STATUS2_CONFUSION, AI_CV_FocusPunch3 is_first_turn_for AI_USER - if_not_equal 0, BattleAIScript_82DDB5B - if_random_less_than 100, BattleAIScript_82DDB5B + if_not_equal 0, AI_CV_FocusPunch_End + if_random_less_than 100, AI_CV_FocusPunch_End score +1 - goto BattleAIScript_82DDB5B + goto AI_CV_FocusPunch_End -BattleAIScript_82DDB42: +AI_CV_FocusPunch2: score -1 - goto BattleAIScript_82DDB5B + goto AI_CV_FocusPunch_End -BattleAIScript_82DDB49: - if_random_less_than 100, BattleAIScript_82DDB5B +AI_CV_FocusPunch3: + if_random_less_than 100, AI_CV_FocusPunch_End if_status2 AI_USER, STATUS2_SUBSTITUTE, Score_Plus5 -BattleAIScript_82DDB59: +AI_CV_FocusPunch_ScoreUp1: score +1 -BattleAIScript_82DDB5B: +AI_CV_FocusPunch_End: end -BattleAIScript_82DDB5C: - if_status AI_TARGET, STATUS1_PARALYSIS, BattleAIScript_82DDB6B - goto BattleAIScript_82DDB6D +AI_CV_SmellingSalt: + if_status AI_TARGET, STATUS1_PARALYSIS, AI_CV_SmellingSalt_ScoreUp1 + goto AI_CV_SmellingSalt_End -BattleAIScript_82DDB6B: +AI_CV_SmellingSalt_ScoreUp1: score +1 -BattleAIScript_82DDB6D: +AI_CV_SmellingSalt_End: end -BattleAIScript_82DDB6E: +AI_CV_Trick: get_hold_effect AI_USER - if_in_bytes sHoldEffectsTable_82DDBB7, BattleAIScript_82DDB89 - if_in_bytes sHoldEffectsTable_82DDBAF, BattleAIScript_82DDB9B + if_in_bytes AI_CV_Trick_EffectsToEncourage2, AI_CV_Trick3 + if_in_bytes AI_CV_Trick_EffectsToEncourage, AI_CV_Trick4 -BattleAIScript_82DDB82: +AI_CV_Trick2: score -3 - goto BattleAIScript_82DDBAE + goto AI_CV_Trick_End -BattleAIScript_82DDB89: +AI_CV_Trick3: get_hold_effect AI_TARGET - if_in_bytes sHoldEffectsTable_82DDBB7, BattleAIScript_82DDB82 + if_in_bytes AI_CV_Trick_EffectsToEncourage2, AI_CV_Trick2 score +5 - goto BattleAIScript_82DDBAE + goto AI_CV_Trick_End -BattleAIScript_82DDB9B: +AI_CV_Trick4: get_hold_effect AI_TARGET - if_in_bytes sHoldEffectsTable_82DDBAF, BattleAIScript_82DDB82 - if_random_less_than 50, BattleAIScript_82DDBAE + if_in_bytes AI_CV_Trick_EffectsToEncourage, AI_CV_Trick2 + if_random_less_than 50, AI_CV_Trick_End score +2 -BattleAIScript_82DDBAE: +AI_CV_Trick_End: end -sHoldEffectsTable_82DDBAF: +AI_CV_Trick_EffectsToEncourage: .byte HOLD_EFFECT_CONFUSE_SPICY .byte HOLD_EFFECT_CONFUSE_DRY .byte HOLD_EFFECT_CONFUSE_SWEET @@ -2472,28 +2472,28 @@ sHoldEffectsTable_82DDBAF: .byte HOLD_EFFECT_CHOICE_BAND .byte -1 -sHoldEffectsTable_82DDBB7: +AI_CV_Trick_EffectsToEncourage2: .byte HOLD_EFFECT_CHOICE_BAND .byte -1 -BattleAIScript_82DDBB9: +AI_CV_ChangeSelfAbility: get_ability AI_USER - if_in_bytes sAbilitiesTable_82DDBDF, BattleAIScript_82DDBCF + if_in_bytes AI_CV_ChangeSelfAbility_AbilitiesToEncourage, AI_CV_ChangeSelfAbility2 get_ability AI_TARGET - if_in_bytes sAbilitiesTable_82DDBDF, BattleAIScript_82DDBD6 + if_in_bytes AI_CV_ChangeSelfAbility_AbilitiesToEncourage, AI_CV_ChangeSelfAbility3 -BattleAIScript_82DDBCF: +AI_CV_ChangeSelfAbility2: score -1 - goto BattleAIScript_82DDBDE + goto AI_CV_ChangeSelfAbility_End -BattleAIScript_82DDBD6: - if_random_less_than 50, BattleAIScript_82DDBDE +AI_CV_ChangeSelfAbility3: + if_random_less_than 50, AI_CV_ChangeSelfAbility_End score +2 -BattleAIScript_82DDBDE: +AI_CV_ChangeSelfAbility_End: end -sAbilitiesTable_82DDBDF: +AI_CV_ChangeSelfAbility_AbilitiesToEncourage: .byte ABILITY_SPEED_BOOST .byte ABILITY_BATTLE_ARMOR .byte ABILITY_SAND_VEIL @@ -2512,287 +2512,287 @@ sAbilitiesTable_82DDBDF: .byte ABILITY_SHIELD_DUST .byte -1 -BattleAIScript_82DDBF0: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDC1D - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDC1D - if_stat_level_less_than AI_USER, STAT_ATK, 6, BattleAIScript_82DDC1D - if_target_faster BattleAIScript_82DDC16 - if_hp_more_than AI_USER, 40, BattleAIScript_82DDC1D - goto BattleAIScript_82DDC1F +AI_CV_Superpower: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_Superpower_ScoreDown1 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_Superpower_ScoreDown1 + if_stat_level_less_than AI_USER, STAT_ATK, 6, AI_CV_Superpower_ScoreDown1 + if_target_faster AI_CV_Superpower2 + if_hp_more_than AI_USER, 40, AI_CV_Superpower_ScoreDown1 + goto AI_CV_Superpower_End -BattleAIScript_82DDC16: - if_hp_less_than AI_USER, 60, BattleAIScript_82DDC1F +AI_CV_Superpower2: + if_hp_less_than AI_USER, 60, AI_CV_Superpower_End -BattleAIScript_82DDC1D: +AI_CV_Superpower_ScoreDown1: score -1 -BattleAIScript_82DDC1F: +AI_CV_Superpower_End: end -BattleAIScript_82DDC20: - if_hp_more_than AI_TARGET, 30, BattleAIScript_82DDC2F - if_random_less_than 100, BattleAIScript_82DDC2F +AI_CV_MagicCoat: + if_hp_more_than AI_TARGET, 30, AI_CV_MagicCoat2 + if_random_less_than 100, AI_CV_MagicCoat2 score -1 -BattleAIScript_82DDC2F: +AI_CV_MagicCoat2: is_first_turn_for AI_USER - if_equal 0, BattleAIScript_82DDC4A - if_random_less_than 150, BattleAIScript_82DDC52 + if_equal 0, AI_CV_MagicCoat4 + if_random_less_than 150, AI_CV_MagicCoat_End score +1 - goto BattleAIScript_82DDC52 + goto AI_CV_MagicCoat_End AI_CV_MagicCoat3: - if_random_less_than 50, BattleAIScript_82DDC52 + if_random_less_than 50, AI_CV_MagicCoat_End -BattleAIScript_82DDC4A: - if_random_less_than 30, BattleAIScript_82DDC52 +AI_CV_MagicCoat4: + if_random_less_than 30, AI_CV_MagicCoat_End score -1 -BattleAIScript_82DDC52: +AI_CV_MagicCoat_End: end -BattleAIScript_82DDC53: +AI_CV_Recycle: get_used_held_item AI_USER - if_not_in_bytes sItemsTable_82DDC6E, BattleAIScript_82DDC6B - if_random_less_than 50, BattleAIScript_82DDC6D + if_not_in_bytes AI_CV_Recycle_ItemsToEncourage, AI_CV_Recycle_ScoreDown2 + if_random_less_than 50, AI_CV_Recycle_End score +1 - goto BattleAIScript_82DDC6D + goto AI_CV_Recycle_End -BattleAIScript_82DDC6B: +AI_CV_Recycle_ScoreDown2: score -2 -BattleAIScript_82DDC6D: +AI_CV_Recycle_End: end -sItemsTable_82DDC6E: +AI_CV_Recycle_ItemsToEncourage: .byte ITEM_CHESTO_BERRY .byte ITEM_LUM_BERRY .byte ITEM_STARF_BERRY .byte -1 -BattleAIScript_82DDC72: - if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DDC9D - if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDC9D - if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDC9D - if_random_less_than 180, BattleAIScript_82DDC9D +AI_CV_Revenge: + if_status AI_TARGET, STATUS1_SLEEP, AI_CV_Revenge_ScoreDown2 + if_status2 AI_TARGET, STATUS2_INFATUATION, AI_CV_Revenge_ScoreDown2 + if_status2 AI_TARGET, STATUS2_CONFUSION, AI_CV_Revenge_ScoreDown2 + if_random_less_than 180, AI_CV_Revenge_ScoreDown2 score +2 - goto BattleAIScript_82DDC9F + goto AI_CV_Revenge_End -BattleAIScript_82DDC9D: +AI_CV_Revenge_ScoreDown2: score -2 -BattleAIScript_82DDC9F: +AI_CV_Revenge_End: end -BattleAIScript_82DDCA0: - if_side_affecting AI_TARGET, SIDE_STATUS_REFLECT, BattleAIScript_82DDCAF - goto BattleAIScript_82DDCB1 +AI_CV_BrickBreak: + if_side_affecting AI_TARGET, SIDE_STATUS_REFLECT, AI_CV_BrickBreak_ScoreUp1 + goto AI_CV_BrickBreak_End -BattleAIScript_82DDCAF: +AI_CV_BrickBreak_ScoreUp1: score +1 -BattleAIScript_82DDCB1: +AI_CV_BrickBreak_End: end -BattleAIScript_82DDCB2: - if_hp_less_than AI_TARGET, 30, BattleAIScript_82DDCC9 +AI_CV_KnockOff: + if_hp_less_than AI_TARGET, 30, AI_CV_KnockOff_End is_first_turn_for AI_USER - if_more_than 0, BattleAIScript_82DDCC9 - if_random_less_than 180, BattleAIScript_82DDCC9 + if_more_than 0, AI_CV_KnockOff_End + if_random_less_than 180, AI_CV_KnockOff_End score +1 -BattleAIScript_82DDCC9: +AI_CV_KnockOff_End: end -BattleAIScript_82DDCCA: - if_hp_less_than AI_TARGET, 70, BattleAIScript_82DDCF3 - if_target_faster BattleAIScript_82DDCE5 - if_hp_more_than AI_USER, 40, BattleAIScript_82DDCF3 +AI_CV_Endeavor: + if_hp_less_than AI_TARGET, 70, AI_CV_Endeavor_ScoreDown1 + if_target_faster AI_CV_Endeavor2 + if_hp_more_than AI_USER, 40, AI_CV_Endeavor_ScoreDown1 score +1 - goto BattleAIScript_82DDCF5 + goto AI_CV_Endeavor_End -BattleAIScript_82DDCE5: - if_hp_more_than AI_USER, 50, BattleAIScript_82DDCF3 +AI_CV_Endeavor2: + if_hp_more_than AI_USER, 50, AI_CV_Endeavor_ScoreDown1 score +1 - goto BattleAIScript_82DDCF5 + goto AI_CV_Endeavor_End -BattleAIScript_82DDCF3: +AI_CV_Endeavor_ScoreDown1: score -1 -BattleAIScript_82DDCF5: +AI_CV_Endeavor_End: end -BattleAIScript_82DDCF6: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDD1B - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDD1B - if_target_faster BattleAIScript_82DDD14 - if_hp_more_than AI_TARGET, 50, BattleAIScript_82DDD1D - goto BattleAIScript_82DDD1B +AI_CV_Eruption: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_Eruption_ScoreDown1 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_Eruption_ScoreDown1 + if_target_faster AI_CV_Eruption2 + if_hp_more_than AI_TARGET, 50, AI_CV_Eruption_End + goto AI_CV_Eruption_ScoreDown1 -BattleAIScript_82DDD14: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DDD1D +AI_CV_Eruption2: + if_hp_more_than AI_TARGET, 70, AI_CV_Eruption_End -BattleAIScript_82DDD1B: +AI_CV_Eruption_ScoreDown1: score -1 -BattleAIScript_82DDD1D: +AI_CV_Eruption_End: end -BattleAIScript_82DDD1E: +AI_CV_Imprison: is_first_turn_for AI_USER - if_more_than 0, BattleAIScript_82DDD2E - if_random_less_than 100, BattleAIScript_82DDD2E + if_more_than 0, AI_CV_Imprison_End + if_random_less_than 100, AI_CV_Imprison_End score +2 -BattleAIScript_82DDD2E: +AI_CV_Imprison_End: end -BattleAIScript_82DDD2F: - if_hp_less_than AI_TARGET, 50, BattleAIScript_82DDD3B - goto BattleAIScript_82DDD3D +AI_CV_Refresh: + if_hp_less_than AI_TARGET, 50, AI_CV_Refresh_ScoreDown1 + goto AI_CV_Refresh_End -BattleAIScript_82DDD3B: +AI_CV_Refresh_ScoreDown1: score -1 -BattleAIScript_82DDD3D: +AI_CV_Refresh_End: end -BattleAIScript_82DDD3E: +AI_CV_Snatch: is_first_turn_for AI_USER - if_equal 1, BattleAIScript_82DDD85 - if_random_less_than 30, BattleAIScript_82DDDA7 - if_target_faster BattleAIScript_82DDD6B - if_hp_not_equal AI_USER, 100, BattleAIScript_82DDD9F - if_hp_less_than AI_TARGET, 70, BattleAIScript_82DDD9F - if_random_less_than 60, BattleAIScript_82DDDA7 - goto BattleAIScript_82DDD9F + if_equal 1, AI_CV_Snatch3 + if_random_less_than 30, AI_CV_Snatch_End + if_target_faster AI_CV_Snatch2 + if_hp_not_equal AI_USER, 100, AI_CV_Snatch5 + if_hp_less_than AI_TARGET, 70, AI_CV_Snatch5 + if_random_less_than 60, AI_CV_Snatch_End + goto AI_CV_Snatch5 -BattleAIScript_82DDD6B: - if_hp_more_than AI_TARGET, 25, BattleAIScript_82DDD9F - if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, BattleAIScript_82DDD85 - if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, BattleAIScript_82DDD85 - goto BattleAIScript_82DDD92 +AI_CV_Snatch2: + if_hp_more_than AI_TARGET, 25, AI_CV_Snatch5 + if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, AI_CV_Snatch3 + if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, AI_CV_Snatch3 + goto AI_CV_Snatch4 -BattleAIScript_82DDD85: - if_random_less_than 150, BattleAIScript_82DDDA7 +AI_CV_Snatch3: + if_random_less_than 150, AI_CV_Snatch_End score +2 - goto BattleAIScript_82DDDA7 + goto AI_CV_Snatch_End -BattleAIScript_82DDD92: - if_random_less_than 230, BattleAIScript_82DDD9F +AI_CV_Snatch4: + if_random_less_than 230, AI_CV_Snatch5 score +1 - goto BattleAIScript_82DDDA7 + goto AI_CV_Snatch_End -BattleAIScript_82DDD9F: - if_random_less_than 30, BattleAIScript_82DDDA7 +AI_CV_Snatch5: + if_random_less_than 30, AI_CV_Snatch_End score -2 -BattleAIScript_82DDDA7: +AI_CV_Snatch_End: end -BattleAIScript_82DDDA8: - if_hp_less_than AI_USER, 50, BattleAIScript_82DDDCB +AI_CV_MudSport: + if_hp_less_than AI_USER, 50, AI_CV_MudSport_ScoreDown1 get_target_type1 - if_equal TYPE_ELECTRIC, BattleAIScript_82DDDC4 + if_equal TYPE_ELECTRIC, AI_CV_MudSport2 get_target_type2 - if_equal TYPE_ELECTRIC, BattleAIScript_82DDDC4 - goto BattleAIScript_82DDDCB + if_equal TYPE_ELECTRIC, AI_CV_MudSport2 + goto AI_CV_MudSport_ScoreDown1 -BattleAIScript_82DDDC4: +AI_CV_MudSport2: score +1 - goto BattleAIScript_82DDDCD + goto AI_CV_MudSport_End -BattleAIScript_82DDDCB: +AI_CV_MudSport_ScoreDown1: score -1 -BattleAIScript_82DDDCD: +AI_CV_MudSport_End: end -BattleAIScript_82DDDCE: - if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDDF3 - if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDDF3 - if_target_faster BattleAIScript_82DDDEC - if_hp_more_than AI_USER, 60, BattleAIScript_82DDDF5 - goto BattleAIScript_82DDDF3 +AI_CV_Overheat: + if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_Overheat_ScoreDown1 + if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_Overheat_ScoreDown1 + if_target_faster AI_CV_Overheat2 + if_hp_more_than AI_USER, 60, AI_CV_Overheat_End + goto AI_CV_Overheat_ScoreDown1 -BattleAIScript_82DDDEC: - if_hp_more_than AI_USER, 80, BattleAIScript_82DDDF5 +AI_CV_Overheat2: + if_hp_more_than AI_USER, 80, AI_CV_Overheat_End -BattleAIScript_82DDDF3: +AI_CV_Overheat_ScoreDown1: score -1 -BattleAIScript_82DDDF5: +AI_CV_Overheat_End: end -BattleAIScript_82DDDF6: - if_hp_less_than AI_USER, 50, BattleAIScript_82DDE19 +AI_CV_WaterSport: + if_hp_less_than AI_USER, 50, AI_CV_WaterSport_ScoreDown1 get_target_type1 - if_equal TYPE_FIRE, BattleAIScript_82DDE12 + if_equal TYPE_FIRE, AI_CV_WaterSport2 get_target_type2 - if_equal TYPE_FIRE, BattleAIScript_82DDE12 - goto BattleAIScript_82DDE19 + if_equal TYPE_FIRE, AI_CV_WaterSport2 + goto AI_CV_WaterSport_ScoreDown1 -BattleAIScript_82DDE12: +AI_CV_WaterSport2: score +1 - goto BattleAIScript_82DDE1B + goto AI_CV_WaterSport_End -BattleAIScript_82DDE19: +AI_CV_WaterSport_ScoreDown1: score -1 -BattleAIScript_82DDE1B: +AI_CV_WaterSport_End: end -BattleAIScript_82DDE1C: - if_target_faster BattleAIScript_82DDE36 - if_hp_more_than AI_USER, 50, BattleAIScript_82DDE3E - if_random_less_than 70, BattleAIScript_82DDE3E +AI_CV_DragonDance: + if_target_faster AI_CV_DragonDance2 + if_hp_more_than AI_USER, 50, AI_CV_DragonDance_End + if_random_less_than 70, AI_CV_DragonDance_End score -1 - goto BattleAIScript_82DDE3E + goto AI_CV_DragonDance_End -BattleAIScript_82DDE36: - if_random_less_than 128, BattleAIScript_82DDE3E +AI_CV_DragonDance2: + if_random_less_than 128, AI_CV_DragonDance_End score +1 -BattleAIScript_82DDE3E: +AI_CV_DragonDance_End: end AI_CheckViability: if_target_is_ally AI_Ret - if_can_faint BattleAIScript_82DDE60 + if_can_faint AI_TryToFaint_TryToEncourageQuickAttack get_how_powerful_move_is if_equal 1, Score_Minus1 if_type_effectiveness AI_EFFECTIVENESS_x4, BattleAIScript_82DDE57 end BattleAIScript_82DDE57: - if_random_less_than 80, BattleAIScript_82DDE70 + if_random_less_than 80, AI_TryToFaint_End score +2 end -BattleAIScript_82DDE60: - if_effect EFFECT_EXPLOSION, BattleAIScript_82DDE70 - if_not_effect EFFECT_QUICK_ATTACK, BattleAIScript_82DDE6E +AI_TryToFaint_TryToEncourageQuickAttack: + if_effect EFFECT_EXPLOSION, AI_TryToFaint_End + if_not_effect EFFECT_QUICK_ATTACK, AI_TryToFaint_ScoreUp4 score +2 -BattleAIScript_82DDE6E: +AI_TryToFaint_ScoreUp4: score +4 -BattleAIScript_82DDE70: +AI_TryToFaint_End: end AI_SetupFirstTurn: if_target_is_ally AI_Ret get_turn_count - if_not_equal 0, BattleAIScript_82DDE8F + if_not_equal 0, AI_SetupFirstTurn_End get_considered_move_effect - if_not_in_bytes sMoveEffectsTable_82DDE90, BattleAIScript_82DDE8F - if_random_less_than 80, BattleAIScript_82DDE8F + if_not_in_bytes AI_SetupFirstTurn_SetupEffectsToEncourage, AI_SetupFirstTurn_End + if_random_less_than 80, AI_SetupFirstTurn_End score +2 -BattleAIScript_82DDE8F: +AI_SetupFirstTurn_End: end -sMoveEffectsTable_82DDE90: +AI_SetupFirstTurn_SetupEffectsToEncourage: .byte EFFECT_ATTACK_UP .byte EFFECT_DEFENSE_UP .byte EFFECT_SPEED_UP @@ -2853,24 +2853,24 @@ sMoveEffectsTable_82DDE90: AI_PreferStrongestMove: if_target_is_ally AI_Ret get_how_powerful_move_is - if_not_equal 0, BattleAIScript_82DDEDC - if_random_less_than 100, BattleAIScript_82DDEDC + if_not_equal 0, AI_PreferStrongestMove_End + if_random_less_than 100, AI_PreferStrongestMove_End score +2 -BattleAIScript_82DDEDC: +AI_PreferStrongestMove_End: end AI_Risky: if_target_is_ally AI_Ret get_considered_move_effect - if_not_in_bytes sMoveEffectsTable_82DDEF5, BattleAIScript_82DDEF4 - if_random_less_than 128, BattleAIScript_82DDEF4 + if_not_in_bytes AI_Risky_EffectsToEncourage, AI_Risky_End + if_random_less_than 128, AI_Risky_End score +2 -BattleAIScript_82DDEF4: +AI_Risky_End: end -sMoveEffectsTable_82DDEF5: +AI_Risky_EffectsToEncourage: .byte EFFECT_SLEEP .byte EFFECT_EXPLOSION .byte EFFECT_MIRROR_MOVE @@ -2898,25 +2898,25 @@ AI_PreferBatonPass: if_equal 0, BattleAIScript_82DDFB3 get_how_powerful_move_is if_not_equal 0, BattleAIScript_82DDFB3 - if_has_move_with_effect AI_USER, EFFECT_BATON_PASS, BattleAIScript_82DDF2A - if_random_less_than 80, BattleAIScript_82DDEF4 + if_has_move_with_effect AI_USER, EFFECT_BATON_PASS, AI_PreferBatonPass_GoForBatonPass + if_random_less_than 80, AI_Risky_End -BattleAIScript_82DDF2A: - if_move MOVE_SWORDS_DANCE, BattleAIScript_82DDF54 - if_move MOVE_DRAGON_DANCE, BattleAIScript_82DDF54 - if_move MOVE_CALM_MIND, BattleAIScript_82DDF54 - if_effect EFFECT_PROTECT, BattleAIScript_82DDF67 +AI_PreferBatonPass_GoForBatonPass: + if_move MOVE_SWORDS_DANCE, AI_PreferBatonPass2 + if_move MOVE_DRAGON_DANCE, AI_PreferBatonPass2 + if_move MOVE_CALM_MIND, AI_PreferBatonPass2 + if_effect EFFECT_PROTECT, AI_PreferBatonPass_End if_move MOVE_BATON_PASS, BattleAIScript_82DDF7B - if_random_less_than 20, BattleAIScript_82DDEF4 + if_random_less_than 20, AI_Risky_End score +3 -BattleAIScript_82DDF54: +AI_PreferBatonPass2: get_turn_count if_equal 0, Score_Plus5 if_hp_less_than AI_USER, 60, Score_Minus10 goto Score_Plus1 -BattleAIScript_82DDF67: +AI_PreferBatonPass_End: get_last_used_bank_move AI_USER if_in_hwords sMovesTable_82DDF75, Score_Minus2 score +2 @@ -3085,51 +3085,51 @@ Score_Minus30_: AI_HPAware: if_target_is_ally AI_TryOnAlly - if_hp_more_than AI_USER, 70, BattleAIScript_82DE1B5 - if_hp_more_than AI_USER, 30, BattleAIScript_82DE1C4 + if_hp_more_than AI_USER, 70, AI_HPAware_UserHasHighHP + if_hp_more_than AI_USER, 30, AI_HPAware_UserHasMediumHP get_considered_move_effect - if_in_bytes sMoveEffectsTable_82DE258, BattleAIScript_82DE1D3 - goto BattleAIScript_82DE1DB + if_in_bytes AI_HPAware_DiscouragedEffectsWhenLowHP, AI_HPAware_TryToDiscourage + goto AI_HPAware_ConsiderTarget -BattleAIScript_82DE1B5: +AI_HPAware_UserHasHighHP: get_considered_move_effect - if_in_bytes sMoveEffectsTable_82DE21F, BattleAIScript_82DE1D3 - goto BattleAIScript_82DE1DB + if_in_bytes AI_HPAware_DiscouragedEffectsWhenHighHP, AI_HPAware_TryToDiscourage + goto AI_HPAware_ConsiderTarget -BattleAIScript_82DE1C4: +AI_HPAware_UserHasMediumHP: get_considered_move_effect - if_in_bytes sMoveEffectsTable_82DE22D, BattleAIScript_82DE1D3 - goto BattleAIScript_82DE1DB + if_in_bytes AI_HPAware_DiscouragedEffectsWhenMediumHP, AI_HPAware_TryToDiscourage + goto AI_HPAware_ConsiderTarget -BattleAIScript_82DE1D3: - if_random_less_than 50, BattleAIScript_82DE1DB +AI_HPAware_TryToDiscourage: + if_random_less_than 50, AI_HPAware_ConsiderTarget score -2 -BattleAIScript_82DE1DB: - if_hp_more_than AI_TARGET, 70, BattleAIScript_82DE1F8 - if_hp_more_than AI_TARGET, 30, BattleAIScript_82DE207 +AI_HPAware_ConsiderTarget: + if_hp_more_than AI_TARGET, 70, AI_HPAware_TargetHasHighHP + if_hp_more_than AI_TARGET, 30, AI_HPAware_TargetHasMediumHP get_considered_move_effect - if_in_bytes sMoveEffectsTable_82DE2B1, BattleAIScript_82DE216 - goto BattleAIScript_82DE21E + if_in_bytes AI_HPAware_DiscouragedEffectsWhenTargetLowHP, AI_HPAware_TargetTryToDiscourage + goto AI_HPAware_End -BattleAIScript_82DE1F8: +AI_HPAware_TargetHasHighHP: get_considered_move_effect - if_in_bytes sMoveEffectsTable_82DE288, BattleAIScript_82DE216 - goto BattleAIScript_82DE21E + if_in_bytes AI_HPAware_DiscouragedEffectsWhenTargetHighHP, AI_HPAware_TargetTryToDiscourage + goto AI_HPAware_End -BattleAIScript_82DE207: +AI_HPAware_TargetHasMediumHP: get_considered_move_effect - if_in_bytes sMoveEffectsTable_82DE289, BattleAIScript_82DE216 - goto BattleAIScript_82DE21E + if_in_bytes AI_HPAware_DiscouragedEffectsWhenTargetMediumHP, AI_HPAware_TargetTryToDiscourage + goto AI_HPAware_End -BattleAIScript_82DE216: - if_random_less_than 50, BattleAIScript_82DE21E +AI_HPAware_TargetTryToDiscourage: + if_random_less_than 50, AI_HPAware_End score -2 -BattleAIScript_82DE21E: +AI_HPAware_End: end -sMoveEffectsTable_82DE21F: +AI_HPAware_DiscouragedEffectsWhenHighHP: @ 82DE21F .byte EFFECT_EXPLOSION .byte EFFECT_RESTORE_HP .byte EFFECT_REST @@ -3145,7 +3145,7 @@ sMoveEffectsTable_82DE21F: .byte EFFECT_OVERHEAT .byte -1 -sMoveEffectsTable_82DE22D: +AI_HPAware_DiscouragedEffectsWhenMediumHP: @ 82DE22D .byte EFFECT_EXPLOSION .byte EFFECT_ATTACK_UP .byte EFFECT_DEFENSE_UP @@ -3190,7 +3190,7 @@ sMoveEffectsTable_82DE22D: .byte EFFECT_DRAGON_DANCE .byte -1 -sMoveEffectsTable_82DE258: +AI_HPAware_DiscouragedEffectsWhenLowHP: @ 82DE258 .byte EFFECT_ATTACK_UP .byte EFFECT_DEFENSE_UP .byte EFFECT_SPEED_UP @@ -3240,10 +3240,10 @@ sMoveEffectsTable_82DE258: .byte EFFECT_DRAGON_DANCE .byte -1 -sMoveEffectsTable_82DE288: +AI_HPAware_DiscouragedEffectsWhenTargetHighHP: @ 82DE288 .byte -1 -sMoveEffectsTable_82DE289: +AI_HPAware_DiscouragedEffectsWhenTargetMediumHP: @ 82DE289 .byte EFFECT_ATTACK_UP .byte EFFECT_DEFENSE_UP .byte EFFECT_SPEED_UP @@ -3285,7 +3285,7 @@ sMoveEffectsTable_82DE289: .byte EFFECT_DRAGON_DANCE .byte -1 -sMoveEffectsTable_82DE2B1: +AI_HPAware_DiscouragedEffectsWhenTargetLowHP: @ 82DE2B1 .byte EFFECT_SLEEP .byte EFFECT_EXPLOSION .byte EFFECT_ATTACK_UP @@ -3349,36 +3349,36 @@ sMoveEffectsTable_82DE2B1: AI_Unknown: if_target_is_ally AI_TryOnAlly - if_not_effect EFFECT_SUNNY_DAY, BattleAIScript_82DE308 - if_equal 0, BattleAIScript_82DE308 + if_not_effect EFFECT_SUNNY_DAY, AI_Unknown_End + if_equal 0, AI_Unknown_End is_first_turn_for AI_USER - if_equal 0, BattleAIScript_82DE308 + if_equal 0, AI_Unknown_End score +5 -BattleAIScript_82DE308: +AI_Unknown_End: @ 82DE308 end AI_Roaming: - if_status2 AI_USER, STATUS2_WRAPPED, BattleAIScript_82DE336 - if_status2 AI_USER, STATUS2_ESCAPE_PREVENTION, BattleAIScript_82DE336 + if_status2 AI_USER, STATUS2_WRAPPED, AI_Roaming_End + if_status2 AI_USER, STATUS2_ESCAPE_PREVENTION, AI_Roaming_End get_ability AI_TARGET - if_equal ABILITY_SHADOW_TAG, BattleAIScript_82DE336 + if_equal ABILITY_SHADOW_TAG, AI_Roaming_End get_ability AI_USER - if_equal ABILITY_LEVITATE, BattleAIScript_82DE335 + if_equal ABILITY_LEVITATE, AI_Roaming_Flee get_ability AI_TARGET - if_equal ABILITY_ARENA_TRAP, BattleAIScript_82DE336 + if_equal ABILITY_ARENA_TRAP, AI_Roaming_End -BattleAIScript_82DE335: +AI_Roaming_Flee: @ 82DE335 flee -BattleAIScript_82DE336: +AI_Roaming_End: @ 82DE336 end AI_Safari: - if_random_safari_flee BattleAIScript_82DE33D + if_random_safari_flee AI_Safari_Flee watch -BattleAIScript_82DE33D: +AI_Safari_Flee: flee AI_FirstBattle: From ae29f35afdd7c79b08a729be689248359153f587 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 2 Mar 2018 16:34:31 +0100 Subject: [PATCH 02/11] start decompiling list menu --- asm/field_specials.s | 12 +- asm/learn_move.s | 4 +- asm/list_menu.s | 909 ----------------------------------- asm/player_pc.s | 20 +- asm/pokemon_summary_screen.s | 16 +- asm/rom_8011DC0.s | 20 +- asm/shop.s | 2 +- include/list_menu.h | 36 +- include/menu_indicators.h | 1 + ld_script.txt | 1 + src/daycare.c | 8 +- src/decoration.c | 8 +- src/item_menu.c | 28 +- src/list_menu.c | 378 +++++++++++++++ src/pokeblock.c | 24 +- src/secret_base.c | 10 +- 16 files changed, 476 insertions(+), 1001 deletions(-) create mode 100644 src/list_menu.c diff --git a/asm/field_specials.s b/asm/field_specials.s index 6200123ac..7e3185556 100644 --- a/asm/field_specials.s +++ b/asm/field_specials.s @@ -4894,7 +4894,7 @@ sub_813A46C: @ 813A46C lsrs r0, 24 mov r1, sp movs r2, 0 - bl sub_81AE860 + bl ListMenuGetScrollAndRow ldr r1, =gUnknown_0203AB68 mov r0, sp ldrh r0, [r0] @@ -4903,7 +4903,7 @@ sub_813A46C: @ 813A46C lsls r0, 24 lsrs r0, 24 mov r1, sp - bl sub_81AE838 + bl ListMenuGetCurrentItemArrayId ldrh r0, [r4, 0x1E] ldr r5, =gUnknown_0203AB6A ldrh r1, [r5] @@ -5007,7 +5007,7 @@ sub_813A570: @ 813A570 lsls r0, 24 lsrs r0, 24 mov r1, sp - bl sub_81AE838 + bl ListMenuGetCurrentItemArrayId ldrh r0, [r4, 0x1E] mov r1, sp ldrh r1, [r1] @@ -5019,7 +5019,7 @@ sub_813A570: @ 813A570 lsrs r0, 24 movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldr r0, =gUnknown_0203AB64 ldr r0, [r0] bl Free @@ -6012,7 +6012,7 @@ sub_813ADD4: @ 813ADD4 adds r4, 0x16 add r1, sp, 0x14 adds r2, r4, 0 - bl sub_81AE860 + bl ListMenuGetScrollAndRow ldrh r0, [r6, 0x22] lsls r0, 24 lsrs r0, 24 @@ -6173,7 +6173,7 @@ sub_813AF48: @ 813AF48 lsrs r0, 24 movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldr r0, =gUnknown_0203AB64 ldr r0, [r0] bl Free diff --git a/asm/learn_move.s b/asm/learn_move.s index 56f6f84c7..a33bd11b6 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -903,7 +903,7 @@ sub_8160EA0: @ 8160EA0 ldrb r0, [r0] ldr r1, =gUnknown_0203BC38 adds r2, r1, 0x2 - bl sub_81AE6C8 + bl DestroyListMenuTask bl FreeAllWindowBuffers ldr r0, [r4] bl Free @@ -988,7 +988,7 @@ sub_8160F50: @ 8160F50 ldr r4, =gUnknown_0203BC38 adds r2, r4, 0x2 adds r1, r4, 0 - bl sub_81AE860 + bl ListMenuGetScrollAndRow movs r0, 0x2 negs r0, r0 cmp r5, r0 diff --git a/asm/list_menu.s b/asm/list_menu.s index 58719093c..89309262f 100644 --- a/asm/list_menu.s +++ b/asm/list_menu.s @@ -5,917 +5,8 @@ .text - thumb_func_start ListMenuDummyTask -@ void ListMenuDummyTask(u8 taskId) -ListMenuDummyTask: @ 81AE458 - bx lr - thumb_func_end ListMenuDummyTask - thumb_func_start DoMysteryGiftListMenu -@ int DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, int a3, int a4, int a5) -DoMysteryGiftListMenu: @ 81AE45C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - mov r12, r0 - str r1, [sp] - ldr r0, [sp, 0x28] - lsls r2, 24 - lsrs r6, r2, 24 - mov r10, r6 - lsls r3, 16 - lsrs r7, r3, 16 - str r7, [sp, 0x4] - lsls r0, 16 - mov r8, r0 - lsrs r0, 16 - mov r9, r0 - ldr r5, =gUnknown_0203CE84 - ldrb r4, [r5, 0x4] - cmp r4, 0x1 - beq _081AE4F4 - cmp r4, 0x1 - ble _081AE492 - cmp r4, 0x2 - beq _081AE558 -_081AE492: - mov r0, r12 - bl AddWindow - strb r0, [r5, 0x5] - cmp r6, 0x1 - beq _081AE4B0 - cmp r6, 0x2 - bne _081AE4C0 - ldrb r0, [r5, 0x5] - mov r1, r9 - lsls r2, r1, 24 - lsrs r2, 24 - adds r1, r7, 0 - bl sub_809882C -_081AE4B0: - ldrb r0, [r5, 0x5] - mov r3, r8 - lsrs r2, r3, 20 - lsls r2, 24 - lsrs r2, 24 - ldr r1, [sp, 0x4] - bl sub_8098858 -_081AE4C0: - ldr r0, =gMultiuseListMenuTemplate - adds r2, r0, 0 - ldr r1, [sp] - ldm r1!, {r3-r5} - stm r2!, {r3-r5} - ldm r1!, {r3-r5} - stm r2!, {r3-r5} - ldr r4, =gUnknown_0203CE84 - ldrb r1, [r4, 0x5] - strb r1, [r0, 0x10] - movs r1, 0 - movs r2, 0 - bl ListMenuInit - strb r0, [r4, 0x6] - ldrb r0, [r4, 0x5] - movs r1, 0x1 - bl CopyWindowToVram - movs r0, 0x1 - strb r0, [r4, 0x4] - b _081AE570 - .pool -_081AE4F4: - ldrb r0, [r5, 0x6] - bl ListMenuHandleInputGetItemId - str r0, [r5] - ldr r1, =gMain - ldrh r0, [r1, 0x2E] - ands r4, r0 - cmp r4, 0 - beq _081AE50A - movs r0, 0x2 - strb r0, [r5, 0x4] -_081AE50A: - ldrh r1, [r1, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081AE51E - movs r0, 0x2 - negs r0, r0 - str r0, [r5] - movs r0, 0x2 - strb r0, [r5, 0x4] -_081AE51E: - ldrb r0, [r5, 0x4] - cmp r0, 0x2 - bne _081AE570 - cmp r6, 0 - bne _081AE534 - ldrb r0, [r5, 0x5] - bl ClearWindowTilemap - b _081AE546 - .pool -_081AE534: - mov r4, r10 - cmp r4, 0 - blt _081AE546 - cmp r4, 0x2 - bgt _081AE546 - ldrb r0, [r5, 0x5] - movs r1, 0 - bl sub_819746C -_081AE546: - ldr r0, =gUnknown_0203CE84 - ldrb r0, [r0, 0x5] - movs r1, 0x1 - bl CopyWindowToVram - b _081AE570 - .pool -_081AE558: - ldrb r0, [r5, 0x6] - movs r1, 0 - movs r2, 0 - bl sub_81AE6C8 - ldrb r0, [r5, 0x5] - bl RemoveWindow - movs r0, 0 - strb r0, [r5, 0x4] - ldr r0, [r5] - b _081AE574 -_081AE570: - movs r0, 0x1 - negs r0, r0 -_081AE574: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end DoMysteryGiftListMenu - thumb_func_start ListMenuInit -@ u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow) -ListMenuInit: @ 81AE584 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - bl ListMenuInitInternal - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldrb r0, [r5, 0x10] - bl PutWindowTilemap - ldrb r0, [r5, 0x10] - movs r1, 0x2 - bl CopyWindowToVram - adds r0, r4, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end ListMenuInit - - thumb_func_start Unused_ListMenuInit2 -@ u8 Unused_ListMenuInit2(struct ListMenuTemplate *listMenuTemplate, int a2, u16 scrollOffset, u16 selectedRow) -Unused_ListMenuInit2: @ 81AE5B0 - push {r4-r7,lr} - sub sp, 0x8 - adds r6, r0, 0 - adds r4, r1, 0 - adds r1, r2, 0 - adds r2, r3, 0 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - bl ListMenuInitInternal - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r4, 0x4] - cmp r0, 0xFF - beq _081AE5F0 - adds r5, r4, 0 -_081AE5D4: - ldrb r0, [r6, 0x10] - ldrb r1, [r5] - ldrb r2, [r5, 0x1] - ldrb r3, [r5, 0x2] - ldrb r4, [r5, 0x3] - str r4, [sp] - ldrb r4, [r5, 0x4] - str r4, [sp, 0x4] - bl PutWindowRectTilemapOverridePalette - adds r5, 0x8 - ldrb r0, [r5, 0x4] - cmp r0, 0xFF - bne _081AE5D4 -_081AE5F0: - ldrb r0, [r6, 0x10] - movs r1, 0x2 - bl CopyWindowToVram - adds r0, r7, 0 - add sp, 0x8 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end Unused_ListMenuInit2 - - thumb_func_start ListMenuHandleInputGetItemId -@ int ListMenuHandleInputGetItemId(u8 taskId) -ListMenuHandleInputGetItemId: @ 81AE604 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r3, r1, r0 - ldr r2, =gMain - ldrh r1, [r2, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081AE638 - ldrh r0, [r3, 0x18] - ldrh r1, [r3, 0x1A] - adds r0, r1 - ldr r1, [r3] - lsls r0, 3 - adds r0, r1 - ldr r0, [r0, 0x4] - b _081AE6C2 - .pool -_081AE638: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081AE646 - movs r0, 0x2 - negs r0, r0 - b _081AE6C2 -_081AE646: - ldrh r1, [r2, 0x30] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081AE65A - adds r0, r3, 0 - movs r1, 0x1 - movs r2, 0x1 - movs r3, 0 - b _081AE6BA -_081AE65A: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081AE66A - adds r0, r3, 0 - movs r1, 0x1 - movs r2, 0x1 - b _081AE6B8 -_081AE66A: - ldrb r0, [r3, 0x16] - lsrs r0, 6 - cmp r0, 0x1 - beq _081AE680 - cmp r0, 0x1 - ble _081AE67A - cmp r0, 0x2 - beq _081AE68C -_081AE67A: - movs r2, 0 - movs r0, 0 - b _081AE6A0 -_081AE680: - movs r0, 0x20 - ands r0, r1 - lsls r0, 16 - lsrs r2, r0, 16 - movs r0, 0x10 - b _081AE69A -_081AE68C: - movs r0, 0x80 - lsls r0, 2 - ands r0, r1 - lsls r0, 16 - lsrs r2, r0, 16 - movs r0, 0x80 - lsls r0, 1 -_081AE69A: - ands r0, r1 - lsls r0, 16 - lsrs r0, 16 -_081AE6A0: - cmp r2, 0 - beq _081AE6AE - ldrb r2, [r3, 0xE] - adds r0, r3, 0 - movs r1, 0x1 - movs r3, 0 - b _081AE6BA -_081AE6AE: - cmp r0, 0 - beq _081AE6BE - ldrb r2, [r3, 0xE] - adds r0, r3, 0 - movs r1, 0x1 -_081AE6B8: - movs r3, 0x1 -_081AE6BA: - bl ListMenuChangeSelection -_081AE6BE: - movs r0, 0x1 - negs r0, r0 -_081AE6C2: - pop {r1} - bx r1 - thumb_func_end ListMenuHandleInputGetItemId - - thumb_func_start sub_81AE6C8 -sub_81AE6C8: @ 81AE6C8 - push {r4,lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r1, r0, r1 - cmp r3, 0 - beq _081AE6E4 - ldrh r0, [r1, 0x18] - strh r0, [r3] -_081AE6E4: - cmp r2, 0 - beq _081AE6EC - ldrh r0, [r1, 0x1A] - strh r0, [r2] -_081AE6EC: - ldrb r0, [r1, 0x1E] - cmp r0, 0xFF - beq _081AE6FC - ldrb r1, [r1, 0x17] - lsrs r1, 6 - subs r1, 0x2 - bl ListMenuRemoveCursorObject -_081AE6FC: - adds r0, r4, 0 - bl DestroyTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AE6C8 - - thumb_func_start sub_81AE70C -sub_81AE70C: @ 81AE70C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldrb r0, [r4, 0x10] - ldrb r2, [r4, 0x15] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - bl FillWindowPixelBuffer - ldrh r1, [r4, 0x18] - ldrh r3, [r4, 0xE] - adds r0, r4, 0 - movs r2, 0 - bl ListMenuPrintEntries - adds r0, r4, 0 - bl ListMenuDrawCursor - ldrb r0, [r4, 0x10] - movs r1, 0x2 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AE70C - - thumb_func_start sub_81AE750 -sub_81AE750: @ 81AE750 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - lsrs r1, 20 - ldrb r6, [r4, 0x14] - movs r5, 0xF - adds r0, r5, 0 - ands r0, r6 - orrs r0, r1 - strb r0, [r4, 0x14] - ands r2, r5 - ldrb r1, [r4, 0x15] - movs r0, 0x10 - negs r0, r0 - ands r0, r1 - orrs r0, r2 - lsrs r3, 20 - ands r0, r5 - orrs r0, r3 - strb r0, [r4, 0x15] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AE750 - - thumb_func_start sub_81AE794 -sub_81AE794: @ 81AE794 - push {r4,r5,lr} - adds r3, r1, 0 - adds r5, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldrb r0, [r4, 0x10] - movs r1, 0x1 - adds r2, r3, 0 - bl SetWindowAttribute - ldrb r0, [r4, 0x10] - movs r1, 0x2 - adds r2, r5, 0 - bl SetWindowAttribute - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AE794 - - thumb_func_start sub_81AE7D0 -sub_81AE7D0: @ 81AE7D0 - push {r4-r7,lr} - sub sp, 0x20 - mov r12, r2 - ldr r5, [sp, 0x34] - lsls r3, 16 - lsrs r3, 16 - adds r4, r3, 0 - mov r3, sp - ldm r0!, {r2,r6,r7} - stm r3!, {r2,r6,r7} - ldm r0!, {r2,r6,r7} - stm r3!, {r2,r6,r7} - mov r0, sp - movs r3, 0 - strh r1, [r0, 0x18] - mov r1, r12 - strh r1, [r0, 0x1A] - strb r3, [r0, 0x1C] - strb r3, [r0, 0x1D] - cmp r4, 0x40 - bne _081AE804 - movs r1, 0 - movs r2, 0x1 - movs r3, 0 - bl ListMenuChangeSelection -_081AE804: - cmp r4, 0x80 - bne _081AE814 - mov r0, sp - movs r1, 0 - movs r2, 0x1 - movs r3, 0x1 - bl ListMenuChangeSelection -_081AE814: - cmp r5, 0 - beq _081AE81E - mov r0, sp - ldrh r0, [r0, 0x18] - strh r0, [r5] -_081AE81E: - ldr r2, [sp, 0x38] - cmp r2, 0 - beq _081AE82A - mov r0, sp - ldrh r0, [r0, 0x1A] - strh r0, [r2] -_081AE82A: - movs r0, 0x1 - negs r0, r0 - add sp, 0x20 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81AE7D0 - - thumb_func_start sub_81AE838 -sub_81AE838: @ 81AE838 - push {lr} - adds r2, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r1, r0 - cmp r2, 0 - beq _081AE856 - ldrh r0, [r1, 0x1A] - ldrh r1, [r1, 0x18] - adds r0, r1 - strh r0, [r2] -_081AE856: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AE838 - - thumb_func_start sub_81AE860 -sub_81AE860: @ 81AE860 - push {lr} - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r1, r0 - cmp r3, 0 - beq _081AE87A - ldrh r0, [r1, 0x18] - strh r0, [r3] -_081AE87A: - cmp r2, 0 - beq _081AE882 - ldrh r0, [r1, 0x1A] - strh r0, [r2] -_081AE882: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AE860 - - thumb_func_start ListMenuGetYCoordForPrintingArrowCursor -@ u8 ListMenuGetYCoordForPrintingArrowCursor(u8 taskId) -ListMenuGetYCoordForPrintingArrowCursor: @ 81AE88C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldrb r0, [r4, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetFontAttribute - ldrb r1, [r4, 0x16] - lsls r1, 26 - lsrs r1, 29 - adds r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x1A] - adds r2, r1, 0 - muls r2, r0 - adds r1, r2, 0 - ldrb r0, [r4, 0x14] - lsls r0, 28 - lsrs r0, 28 - adds r0, r1 - lsls r0, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end ListMenuGetYCoordForPrintingArrowCursor - - thumb_func_start ListMenuInitInternal -@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow) -ListMenuInitInternal: @ 81AE8D4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - ldr r0, =ListMenuDummyTask - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r0, 2 - add r0, r8 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r7, r0, r1 - adds r0, r7, 0 - ldm r4!, {r1-r3} - stm r0!, {r1-r3} - ldm r4!, {r1-r3} - stm r0!, {r1-r3} - movs r1, 0 - strh r5, [r7, 0x18] - strh r6, [r7, 0x1A] - strb r1, [r7, 0x1C] - strb r1, [r7, 0x1D] - movs r0, 0xFF - strb r0, [r7, 0x1E] - strb r1, [r7, 0x1F] - ldr r3, =gUnknown_03006300 - ldrb r1, [r7, 0x14] - movs r5, 0xF - lsrs r1, 4 - ldrb r4, [r3] - movs r2, 0x10 - negs r2, r2 - adds r0, r2, 0 - ands r0, r4 - orrs r0, r1 - strb r0, [r3] - ldrb r1, [r7, 0x15] - lsls r1, 28 - lsrs r1, 24 - ands r0, r5 - orrs r0, r1 - strb r0, [r3] - ldrb r0, [r7, 0x15] - lsrs r0, 4 - ands r5, r0 - ldrb r0, [r3, 0x1] - ands r2, r0 - orrs r2, r5 - strb r2, [r3, 0x1] - ldrb r1, [r7, 0x16] - lsls r1, 29 - lsrs r1, 17 - ldr r0, [r3] - ldr r2, =0xfffc0fff - ands r0, r2 - orrs r0, r1 - str r0, [r3] - ldrb r0, [r7, 0x17] - lsls r0, 26 - lsrs r0, 26 - strb r0, [r3, 0x3] - ldrh r0, [r7, 0xC] - ldrh r1, [r7, 0xE] - cmp r0, r1 - bcs _081AE96C - strh r0, [r7, 0xE] -_081AE96C: - ldrb r0, [r7, 0x10] - ldrb r2, [r7, 0x15] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - bl FillWindowPixelBuffer - ldrh r1, [r7, 0x18] - ldrh r3, [r7, 0xE] - adds r0, r7, 0 - movs r2, 0 - bl ListMenuPrintEntries - adds r0, r7, 0 - bl ListMenuDrawCursor - adds r0, r7, 0 - movs r1, 0x1 - bl ListMenuCallSelectionChangedCallback - mov r0, r8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end ListMenuInitInternal - - thumb_func_start ListMenuPrint -@ void ListMenuPrint(struct ListMenu *listMenu, u8 *str, u8 x, u8 y) -ListMenuPrint: @ 81AE9B4 - push {r4-r7,lr} - sub sp, 0x18 - adds r4, r0, 0 - adds r6, r1, 0 - lsls r2, 24 - lsrs r7, r2, 24 - lsls r3, 24 - lsrs r3, 24 - mov r12, r3 - ldr r5, =gUnknown_03006300 - ldrb r1, [r5, 0x3] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _081AEA20 - add r1, sp, 0x14 - ldr r2, [r5] - lsls r0, r2, 24 - lsrs r0, 28 - movs r3, 0 - strb r0, [r1] - lsls r0, r2, 28 - lsrs r0, 28 - strb r0, [r1, 0x1] - lsls r0, r2, 20 - lsrs r0, 28 - strb r0, [r1, 0x2] - ldrb r0, [r4, 0x10] - lsls r1, r2, 1 - lsrs r1, 25 - lsls r2, 14 - lsrs r2, 26 - str r2, [sp] - str r3, [sp, 0x4] - add r2, sp, 0x14 - str r2, [sp, 0x8] - movs r2, 0x1 - negs r2, r2 - str r2, [sp, 0xC] - str r6, [sp, 0x10] - adds r2, r7, 0 - mov r3, r12 - bl AddTextPrinterParameterized2 - ldrb r1, [r5, 0x3] - movs r0, 0x7F - ands r0, r1 - strb r0, [r5, 0x3] - b _081AEA5E - .pool -_081AEA20: - add r2, sp, 0x14 - ldrb r1, [r4, 0x15] - lsls r0, r1, 28 - lsrs r0, 28 - strb r0, [r2] - ldrb r0, [r4, 0x14] - lsrs r0, 4 - strb r0, [r2, 0x1] - adds r0, r2, 0 - lsls r1, 24 - lsrs r1, 28 - strb r1, [r0, 0x2] - ldrb r0, [r4, 0x10] - ldrb r1, [r4, 0x17] - lsls r1, 26 - lsrs r1, 26 - ldrb r2, [r4, 0x16] - lsls r2, 29 - lsrs r2, 29 - str r2, [sp] - str r3, [sp, 0x4] - add r2, sp, 0x14 - str r2, [sp, 0x8] - movs r2, 0x1 - negs r2, r2 - str r2, [sp, 0xC] - str r6, [sp, 0x10] - adds r2, r7, 0 - mov r3, r12 - bl AddTextPrinterParameterized2 -_081AEA5E: - add sp, 0x18 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end ListMenuPrint - - thumb_func_start ListMenuPrintEntries -@ void ListMenuPrintEntries(struct ListMenu *listMenu, u16 startIndex, u16 yOffset, u16 count) -ListMenuPrintEntries: @ 81AEA68 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r4, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - lsls r2, 16 - lsrs r2, 16 - str r2, [sp] - lsls r3, 16 - lsrs r3, 16 - mov r10, r3 - ldrb r0, [r4, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetFontAttribute - ldrb r1, [r4, 0x16] - lsls r1, 26 - lsrs r1, 29 - adds r0, r1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - movs r0, 0 - mov r8, r0 - cmp r8, r10 - bge _081AEB10 -_081AEAAA: - ldr r0, [r4] - mov r2, r9 - lsls r1, r2, 3 - adds r0, r1, r0 - ldr r2, [r0, 0x4] - movs r0, 0x3 - negs r0, r0 - adds r5, r1, 0 - cmp r2, r0 - beq _081AEAC2 - ldrb r6, [r4, 0x12] - b _081AEAC4 -_081AEAC2: - ldrb r6, [r4, 0x11] -_081AEAC4: - ldr r0, [sp] - add r0, r8 - ldr r2, [sp, 0x4] - adds r1, r0, 0 - muls r1, r2 - ldrb r0, [r4, 0x14] - lsls r0, 28 - lsrs r0, 28 - adds r0, r1 - lsls r0, 24 - lsrs r2, r0, 24 - adds r7, r2, 0 - ldr r3, [r4, 0x8] - cmp r3, 0 - beq _081AEAEE - ldrb r0, [r4, 0x10] - ldr r1, [r4] - adds r1, r5, r1 - ldr r1, [r1, 0x4] - bl _call_via_r3 -_081AEAEE: - ldr r0, [r4] - adds r0, r5, r0 - ldr r1, [r0] - adds r0, r4, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl ListMenuPrint - mov r0, r9 - adds r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - mov r9, r0 - movs r0, 0x1 - add r8, r0 - cmp r8, r10 - blt _081AEAAA -_081AEB10: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end ListMenuPrintEntries thumb_func_start ListMenuDrawCursor @ void ListMenuDrawCursor(struct ListMenu *listMenu) diff --git a/asm/player_pc.s b/asm/player_pc.s index 8a329a2fe..6fe4b3b85 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -1021,7 +1021,7 @@ sub_816B674: @ 816B674 mov r8, r1 adds r1, r7, 0 mov r2, r8 - bl sub_81AE860 + bl ListMenuGetScrollAndRow movs r0, 0x2 negs r0, r0 cmp r6, r0 @@ -1050,7 +1050,7 @@ _0816B6EA: ldrb r0, [r4, 0xA] adds r1, r7, 0 mov r2, r8 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0 bl schedule_bg_copy_tilemap_to_vram mov r1, r8 @@ -1129,7 +1129,7 @@ sub_816B798: @ 816B798 ldrb r0, [r4, 0xA] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0 bl schedule_bg_copy_tilemap_to_vram bl sub_81D1EC0 @@ -2476,7 +2476,7 @@ sub_816C30C: @ 816C30C ldr r1, =gUnknown_0203BCBA subs r4, r1, 0x2 adds r2, r4, 0 - bl sub_81AE860 + bl ListMenuGetScrollAndRow ldrh r1, [r4, 0x2] ldrh r0, [r4] adds r1, r0 @@ -2497,7 +2497,7 @@ _0816C35C: ldrb r0, [r4, 0xA] ldr r1, =gUnknown_0203BCBA subs r2, r1, 0x2 - bl sub_81AE860 + bl ListMenuGetScrollAndRow movs r0, 0x2 negs r0, r0 cmp r6, r0 @@ -2584,7 +2584,7 @@ sub_816C400: @ 816C400 ldrb r0, [r5, 0xA] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldr r0, =gUnknown_0203BCC4 ldr r0, [r0] movs r1, 0xCD @@ -2691,7 +2691,7 @@ sub_816C4FC: @ 816C4FC ldrb r0, [r4, 0xA] ldr r1, =gUnknown_0203BCBA subs r2, r1, 0x2 - bl sub_81AE860 + bl ListMenuGetScrollAndRow b _0816C57E .pool _0816C530: @@ -2702,7 +2702,7 @@ _0816C530: ldr r1, =gUnknown_0203BCBA subs r4, r1, 0x2 adds r2, r4, 0 - bl sub_81AE860 + bl ListMenuGetScrollAndRow ldr r0, =gUnknown_0203BCC4 ldr r0, [r0] movs r1, 0xCD @@ -2776,7 +2776,7 @@ sub_816C5A0: @ 816C5A0 ldrb r0, [r2, 0xA] adds r1, r4, 0x2 adds r2, r4, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask cmp r5, 0 bne _0816C60A ldr r1, =gUnknown_0203BCC4 @@ -3359,7 +3359,7 @@ sub_816CB04: @ 816CB04 ldrb r0, [r5, 0xA] adds r1, r4, 0x2 adds r2, r4, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask bl sub_816C110 bl sub_816C140 bl sub_816BD04 diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index 14dc569fe..3b41afb55 100644 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -3469,7 +3469,7 @@ sub_81C5B4C: @ 81C5B4C ldr r4, =gUnknown_0203CF38 subs r2, r4, 0x2 adds r1, r4, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldr r0, =gUnknown_0203CF2C ldr r0, [r0] ldr r0, [r0] @@ -3545,7 +3545,7 @@ _081C5C12: adds r1, r4, 0 adds r1, 0x8 adds r2, r4, 0x6 - bl sub_81AE860 + bl ListMenuGetScrollAndRow ldrh r1, [r4, 0x8] ldrh r0, [r4, 0x6] adds r1, r0 @@ -3572,7 +3572,7 @@ _081C5C5C: mov r8, r1 mov r2, r8 subs r2, 0x2 - bl sub_81AE860 + bl ListMenuGetScrollAndRow movs r0, 0x2 negs r0, r0 cmp r6, r0 @@ -4642,7 +4642,7 @@ sub_81C65CC: @ 81C65CC ldrb r0, [r4] adds r1, r6, 0 adds r2, r7, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask bl sub_81C5924 bl sub_81C59BC bl sub_81C5314 @@ -4953,7 +4953,7 @@ sub_81C68B0: @ 81C68B0 ldrb r0, [r4] ldr r1, =gUnknown_0203CF38 subs r2, r1, 0x2 - bl sub_81AE860 + bl ListMenuGetScrollAndRow b _081C6940 .pool _081C68F8: @@ -4964,7 +4964,7 @@ _081C68F8: ldr r4, =gUnknown_0203CF38 subs r2, r4, 0x2 adds r1, r4, 0 - bl sub_81AE860 + bl ListMenuGetScrollAndRow movs r0, 0 bl sub_81C7028 subs r4, 0x8 @@ -5054,7 +5054,7 @@ _081C69A8: ldrb r0, [r5] adds r1, r7, 0 mov r2, r8 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r3, 0x2 ldrsh r0, [r5, r3] cmp r0, r4 @@ -5109,7 +5109,7 @@ sub_81C6A14: @ 81C6A14 ldrb r0, [r4] adds r1, r5, 0 adds r2, r7, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0x2 ldrsh r2, [r4, r0] ldrh r0, [r5] diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s index b069ec58e..4d50a5271 100644 --- a/asm/rom_8011DC0.s +++ b/asm/rom_8011DC0.s @@ -1192,7 +1192,7 @@ sub_8012F64: @ 8012F64 ldrb r0, [r4, 0x12] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldrb r0, [r4, 0x10] bl ClearWindowTilemap ldrb r0, [r4, 0xF] @@ -2394,7 +2394,7 @@ _08013A8C: ldrb r0, [r6, 0xE] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldrb r0, [r6, 0xC] bl ClearWindowTilemap ldrb r0, [r6, 0xB] @@ -4511,7 +4511,7 @@ _08014E16: ldrb r0, [r5, 0x12] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0 bl CopyBgTilemapBufferToVram ldrb r0, [r5, 0xF] @@ -4567,7 +4567,7 @@ _08014EA8: ldrb r0, [r5, 0x12] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0 bl CopyBgTilemapBufferToVram ldrb r0, [r5, 0xF] @@ -4923,7 +4923,7 @@ _08015204: ldrb r0, [r7, 0xE] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0 bl CopyBgTilemapBufferToVram ldrb r0, [r7, 0xD] @@ -5292,7 +5292,7 @@ _08015564: ldrb r0, [r5, 0xE] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask movs r0, 0 bl CopyBgTilemapBufferToVram ldrb r0, [r5, 0xB] @@ -8545,7 +8545,7 @@ _08017228: ldrb r0, [r4] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldrb r0, [r5] movs r1, 0x1 bl sub_819746C @@ -8565,7 +8565,7 @@ _08017264: ldrb r0, [r6] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldrb r0, [r5] movs r1, 0x1 bl sub_819746C @@ -8669,7 +8669,7 @@ _0801733E: ldrb r0, [r4] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldrb r0, [r6] bl RemoveWindow mov r7, r9 @@ -8691,7 +8691,7 @@ _08017368: ldrb r0, [r1] movs r1, 0 movs r2, 0 - bl sub_81AE6C8 + bl DestroyListMenuTask ldrb r0, [r6] bl RemoveWindow mov r3, r9 diff --git a/asm/shop.s b/asm/shop.s index c42af8ef1..ae60eb364 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -1985,7 +1985,7 @@ _080E0AEA: adds r1, r2, r3 subs r3, 0x2 adds r2, r3 - bl sub_81AE860 + bl ListMenuGetScrollAndRow movs r0, 0x2 negs r0, r0 cmp r5, r0 diff --git a/include/list_menu.h b/include/list_menu.h index 77d00bf97..d25549845 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -4,6 +4,10 @@ #define LIST_NOTHING_CHOSEN -1 #define LIST_B_PRESSED -2 +#define LIST_NO_MULTIPLE_SCROLL 0 +#define LIST_MULTIPLE_SCROLL_DPAD 1 +#define LIST_MULTIPLE_SCROLL_L_R 2 + // Exported type declarations // Exported RAM declarations @@ -20,27 +24,27 @@ struct ListMenuTemplate { const struct ListMenuItem *items; void (* moveCursorFunc)(u32, bool8, struct ListMenu *); - void (* unk_08)(u8, s32, u8); + void (* unk_08)(u8 windowId, s32 itemId, u8 y); u16 totalItems; u16 maxShowed; - u8 unk_10; + u8 windowId; u8 unk_11; u8 unk_12; u8 cursor_Y; - u32 upText_Y:4; // x1, x2, x4, x8 = xF - u32 cursorColor:4; // x10, x20, x40, x80 = xF0 - u32 fillColor:4; // x100, x200, x400, x800 = xF00 - u32 cursorShadowColor:4; // x1000, x2000, x4000, x8000 = xF000 - u32 unk_16_0:1; // x10000 - u32 spaceBetweenItems:6; // x20000, x40000, x80000, x100000, x200000, x400000 = x7E0000 - u32 unk_16_7:1; // x800000 - u32 unk_17_0:6; // x1000000, x2000000, x4000000, x8000000, x10000000, x20000000 = x3F000000 - u32 cursorKind:2; // x40000000, x80000000 + u8 upText_Y:4; // x1, x2, x4, x8 = xF + u8 cursorPal:4; // x10, x20, x40, x80 = xF0 + u8 fillPal:4; // x1, x2, x4, x8 = xF + u8 cursorShadowPal:4; // x10, x20, x40, x80 = xF0 + u8 lettersSpacing:3; + u8 unk_16_3:3; + u8 scrollMultiple:2; // x40, x80 = xC0 + u8 fontId:6; // x1, x2, x4, x8, x10, x20 = x3F + u8 cursorKind:2; // x40, x80 }; struct ListMenu { - struct ListMenuTemplate _template; + struct ListMenuTemplate template; u16 scrollOffset; u16 selectedRow; u8 unk_1C; @@ -53,10 +57,10 @@ extern struct ListMenuTemplate gMultiuseListMenuTemplate; // Exported ROM declarations -u8 ListMenuInit(struct ListMenuTemplate *template, u16 cursorPage, u16 cursorPosition); +u8 ListMenuInit(struct ListMenuTemplate *template, u16 scrollOffset, u16 selectedRow); s32 ListMenuHandleInputGetItemId(u8 listTaskId); -void sub_81AE860(u8 listTaskId, u16 *a1, u16 *a2); -void sub_81AE6C8(u8 listTaskId, u16 *a1, u16 *a2); -u8 ListMenuGetYCoordForPrintingArrowCursor(u8); +void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); +void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); +u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId); #endif //GUARD_LIST_MENU_H diff --git a/include/menu_indicators.h b/include/menu_indicators.h index b82e48725..b4cea11c7 100644 --- a/include/menu_indicators.h +++ b/include/menu_indicators.h @@ -18,5 +18,6 @@ u8 AddScrollIndicatorArrowPairParametrized(u8, u8, u8, u8, s32, u16, u16, u16 *) void RemoveScrollIndicatorArrowPair(u8); u8 AddScrollIndicatorArrowPair(const struct ArrowStruct*, void*); void sub_81AF15C(u8, u8, u8); +void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind); #endif //GUARD_MENU_INDICATORS_H diff --git a/ld_script.txt b/ld_script.txt index 7dcf21569..88306e790 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -247,6 +247,7 @@ SECTIONS { src/menu.o(.text); asm/battle_frontier_2.o(.text); src/item_menu.o(.text); + src/list_menu.o(.text); asm/list_menu.o(.text); asm/menu_indicators.o(.text); src/unk_text_util.o(.text); diff --git a/src/daycare.c b/src/daycare.c index 36e8b208d..f4bd84af3 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -41,7 +41,7 @@ extern const u8 gDaycareText_PlayOther[]; extern u8 GetCursorSelectionMonId(void); extern u16 ItemIdToBattleMoveId(u16); extern s32 ListMenuHandleInputGetItemId(u8); -extern void sub_81AE6C8(u8, u16*, u16*); +extern void DestroyListMenuTask(u8, u16*, u16*); extern void sub_819746C(u8, bool8); extern void NewMenuHelpers_DrawStdWindowFrame(u8, bool8); extern void sub_81B9328(void); @@ -89,7 +89,7 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate = .cursorShadowColor = 3, .unk_16_0 = TRUE, .spaceBetweenItems = 0, - .unk_16_7 = FALSE, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, .unk_17_0 = 1, .cursorKind = 0 }; @@ -1271,7 +1271,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId) gSpecialVar_Result = 2; break; } - sub_81AE6C8(gTasks[taskId].tMenuListTaskId, NULL, NULL); + DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL); sub_819746C(gTasks[taskId].tWindowId, TRUE); RemoveWindow(gTasks[taskId].tWindowId); DestroyTask(taskId); @@ -1280,7 +1280,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId) else if (gMain.newKeys & B_BUTTON) { gSpecialVar_Result = 2; - sub_81AE6C8(gTasks[taskId].tMenuListTaskId, NULL, NULL); + DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL); sub_819746C(gTasks[taskId].tWindowId, TRUE); RemoveWindow(gTasks[taskId].tWindowId); DestroyTask(taskId); diff --git a/src/decoration.c b/src/decoration.c index e4d867a34..899851c6a 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -801,7 +801,7 @@ void sub_8127330(u8 taskId) sDecorPCBuffer->items[i].name = sDecorPCBuffer->names[i]; sDecorPCBuffer->items[i].id = -2; gMultiuseListMenuTemplate = gUnknown_085A6BD0; - gMultiuseListMenuTemplate.unk_10 = sDecorMenuWindowIndices[1]; + gMultiuseListMenuTemplate.windowId = sDecorMenuWindowIndices[1]; gMultiuseListMenuTemplate.totalItems = sDecorPCBuffer->unk_520; gMultiuseListMenuTemplate.items = sDecorPCBuffer->items; gMultiuseListMenuTemplate.maxShowed = sDecorPCBuffer->unk_521; @@ -892,7 +892,7 @@ void sub_812764C(u8 taskId) if (!gPaletteFade.active) { input = ListMenuHandleInputGetItemId(data[13]); - sub_81AE860(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo); + ListMenuGetScrollAndRow(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo); switch (input) { case -1: @@ -905,7 +905,7 @@ void sub_812764C(u8 taskId) PlaySE(SE_SELECT); gCurDecorationIndex = input; sub_8127554(); - sub_81AE6C8(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo); + DestroyListMenuTask(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo); sub_8126A58(1); sub_81277A8(); free(sDecorPCBuffer); @@ -1074,7 +1074,7 @@ void sub_8127A8C(u8 taskId) data = gTasks[taskId].data; sub_8127554(); sub_81277A8(); - sub_81AE6C8(data[13], NULL, NULL); + DestroyListMenuTask(data[13], NULL, NULL); free(sDecorPCBuffer); sub_8126E44(taskId); } diff --git a/src/item_menu.c b/src/item_menu.c index 9090a39c5..a51894ea1 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -830,7 +830,7 @@ void task_close_bag_menu_2(u8 taskId) s16* data = gTasks[taskId].data; if (!gPaletteFade.active) { - sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + DestroyListMenuTask(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); if (gUnknown_0203CE54->unk0 != 0) SetMainCallback2(gUnknown_0203CE54->unk0); else @@ -915,7 +915,7 @@ void bag_menu_inits_lists_menu(u8 taskId) u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; bag_menu_RemoveBagItem_message_window(4); - sub_81AE6C8(data[0], scrollPos, cursorPos); + DestroyListMenuTask(data[0], scrollPos, cursorPos); sub_81AB9A8(gUnknown_0203CE58.pocket); sub_81ABA88(gUnknown_0203CE58.pocket); load_bag_item_list_buffers(gUnknown_0203CE58.pocket); @@ -967,7 +967,7 @@ void Task_BagMenu(u8 taskId) { if (sub_81AC2C0() == 1) { - sub_81AE860(data[0], scrollPos, cursorPos); + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); if ((*scrollPos + *cursorPos) != gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - 1) { PlaySE(SE_SELECT); @@ -979,7 +979,7 @@ void Task_BagMenu(u8 taskId) else { int r4 = ListMenuHandleInputGetItemId(data[0]); - sub_81AE860(data[0], scrollPos, cursorPos); + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); switch (r4) { case -1: @@ -1063,7 +1063,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) { ClearWindowTilemap(0); ClearWindowTilemap(1); - sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + DestroyListMenuTask(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); schedule_bg_copy_tilemap_to_vram(0); gSprites[gUnknown_0203CE54->unk806[gUnknown_0203CE54->unk81B_1 ^ 1]].invisible = 1; sub_81AB824(); @@ -1125,7 +1125,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) adds r1, r2, r1\n\ adds r3, 0x8\n\ adds r2, r3\n\ - bl sub_81AE6C8\n\ + bl DestroyListMenuTask\n\ movs r0, 0\n\ bl schedule_bg_copy_tilemap_to_vram\n\ ldr r3, =gSprites\n\ @@ -1340,13 +1340,13 @@ void sub_81AC3C0(u8 taskId) if (gMain.newKeys & SELECT_BUTTON) { PlaySE(SE_SELECT); - sub_81AE860(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + ListMenuGetScrollAndRow(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); sub_81AC498(taskId); } else { r7 = ListMenuHandleInputGetItemId(data[0]); - sub_81AE860(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + ListMenuGetScrollAndRow(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); sub_80D4FC8(0); sub_80D4FEC(gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); switch (r7) @@ -1381,7 +1381,7 @@ void sub_81AC498(u8 taskId) { sub_80D702C(gBagPockets[gUnknown_0203CE58.pocket].itemSlots, data[1], realPos); gUnknown_0203CE54->unk81A = -1; - sub_81AE6C8(data[0], scrollPos, cursorPos); + DestroyListMenuTask(data[0], scrollPos, cursorPos); if (data[1] < realPos) gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]--; load_bag_item_list_buffers(gUnknown_0203CE58.pocket); @@ -1399,7 +1399,7 @@ void sub_81AC590(u8 taskId) u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; gUnknown_0203CE54->unk81A = -1; - sub_81AE6C8(data[0], scrollPos, cursorPos); + DestroyListMenuTask(data[0], scrollPos, cursorPos); if (data[1] < (*scrollPos + *cursorPos)) gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]--; load_bag_item_list_buffers(gUnknown_0203CE58.pocket); @@ -1771,7 +1771,7 @@ void Task_ActuallyToss(u8 taskId) { PlaySE(SE_SELECT); RemoveBagItem(gSpecialVar_ItemId, data[8]); - sub_81AE6C8(data[0], scrollPos, cursorPos); + DestroyListMenuTask(data[0], scrollPos, cursorPos); sub_81AB9A8(gUnknown_0203CE58.pocket); sub_81ABA88(gUnknown_0203CE58.pocket); load_bag_item_list_buffers(gUnknown_0203CE58.pocket); @@ -1791,7 +1791,7 @@ void ItemMenu_Register(u8 taskId) gSaveBlock1Ptr->registeredItem = 0; else gSaveBlock1Ptr->registeredItem = gSpecialVar_ItemId; - sub_81AE6C8(data[0], scrollPos, cursorPos); + DestroyListMenuTask(data[0], scrollPos, cursorPos); load_bag_item_list_buffers(gUnknown_0203CE58.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); schedule_bg_copy_tilemap_to_vram(0); @@ -2039,7 +2039,7 @@ void sub_81AD8C8(u8 taskId) PlaySE(SE_REGI); RemoveBagItem(gSpecialVar_ItemId, data[8]); AddMoney(&gSaveBlock1Ptr->money, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]); - sub_81AE6C8(data[0], scrollPos, cursorPos); + DestroyListMenuTask(data[0], scrollPos, cursorPos); sub_81AB9A8(gUnknown_0203CE58.pocket); sub_81ABA88(gUnknown_0203CE58.pocket); load_bag_item_list_buffers(gUnknown_0203CE58.pocket); @@ -2212,7 +2212,7 @@ void Task_WallyTutorialBagMenu(u8 taskId) case 0x132: PlaySE(SE_SELECT); bag_menu_remove_some_window(); - sub_81AE6C8(data[0], 0, 0); + DestroyListMenuTask(data[0], 0, 0); RestoreBagAfterWallyTutorial(); unknown_ItemMenu_Confirm(taskId); break; diff --git a/src/list_menu.c b/src/list_menu.c new file mode 100644 index 000000000..6df5d5d3a --- /dev/null +++ b/src/list_menu.c @@ -0,0 +1,378 @@ +#include "global.h" +#include "menu.h" +#include "list_menu.h" +#include "window.h" +#include "text_window.h" +#include "main.h" +#include "task.h" +#include "menu_indicators.h" + +struct ListMenuStruct +{ + s32 field_0; + u8 field_4; + u8 field_5; + u8 field_6; +}; + +struct UnknownListMenuStruct +{ + u8 x; + u8 y; + u8 width; + u8 height; + u8 palNum; +}; + +extern struct ListMenuStruct gUnknown_0203CE84; + +// this file's functions +u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); +bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown); +void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count); +void ListMenuDrawCursor(struct ListMenu *list); +void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2); + +// code +void ListMenuDummyTask(u8 taskId) +{ + +} + +s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum) +{ + switch (gUnknown_0203CE84.field_4) + { + case 0: + default: + gUnknown_0203CE84.field_5 = AddWindow(windowTemplate); + switch (arg2) + { + case 2: + sub_809882C(gUnknown_0203CE84.field_5, tileNum, palNum); + case 1: + sub_8098858(gUnknown_0203CE84.field_5, tileNum, palNum / 16); + break; + } + gMultiuseListMenuTemplate = *listMenuTemplate; + gMultiuseListMenuTemplate.windowId = gUnknown_0203CE84.field_5; + gUnknown_0203CE84.field_6 = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); + CopyWindowToVram(gUnknown_0203CE84.field_5, 1); + gUnknown_0203CE84.field_4 = 1; + break; + case 1: + gUnknown_0203CE84.field_0 = ListMenuHandleInputGetItemId(gUnknown_0203CE84.field_6); + if (gMain.newKeys & A_BUTTON) + gUnknown_0203CE84.field_4 = 2; + if (gMain.newKeys & B_BUTTON) + { + gUnknown_0203CE84.field_0 = LIST_B_PRESSED; + gUnknown_0203CE84.field_4 = 2; + } + if (gUnknown_0203CE84.field_4 == 2) + { + if (arg2 == 0) + ClearWindowTilemap(gUnknown_0203CE84.field_5); + else + { + switch (arg2) + { + case 0: // can never be reached, because of the if statement above + sub_819746C(gUnknown_0203CE84.field_5, FALSE); + break; + case 2: + case 1: + sub_819746C(gUnknown_0203CE84.field_5, FALSE); + break; + } + } + + CopyWindowToVram(gUnknown_0203CE84.field_5, 1); + } + break; + case 2: + DestroyListMenuTask(gUnknown_0203CE84.field_6, NULL, NULL); + RemoveWindow(gUnknown_0203CE84.field_5); + gUnknown_0203CE84.field_4 = 0; + return gUnknown_0203CE84.field_0; + } + + return -1; +} + +u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow) +{ + u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow); + PutWindowTilemap(listMenuTemplate->windowId); + CopyWindowToVram(listMenuTemplate->windowId, 2); + + return taskId; +} + +// unused +u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuStruct *arg1, u16 scrollOffset, u16 selectedRow) +{ + s32 i; + + u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow); + for (i = 0; arg1[i].palNum != 0xFF; i++) + { + PutWindowRectTilemapOverridePalette(listMenuTemplate->windowId, + arg1[i].x, + arg1[i].y, + arg1[i].width, + arg1[i].height, + arg1[i].palNum); + } + CopyWindowToVram(listMenuTemplate->windowId, 2); + + return taskId; +} + +s32 ListMenuHandleInputGetItemId(u8 listTaskId) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + if (gMain.newKeys & A_BUTTON) + { + return list->template.items[list->scrollOffset + list->selectedRow].id; + } + else if (gMain.newKeys & B_BUTTON) + { + return LIST_B_PRESSED; + } + else if (gMain.newAndRepeatedKeys & DPAD_UP) + { + ListMenuChangeSelection(list, TRUE, 1, FALSE); + return LIST_NOTHING_CHOSEN; + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + ListMenuChangeSelection(list, TRUE, 1, TRUE); + return LIST_NOTHING_CHOSEN; + } + else // try to move by one window scroll + { + bool16 rightButton, leftButton; + switch (list->template.scrollMultiple) + { + case LIST_NO_MULTIPLE_SCROLL: + default: + leftButton = FALSE; + rightButton = FALSE; + break; + case LIST_MULTIPLE_SCROLL_DPAD: + leftButton = gMain.newAndRepeatedKeys & DPAD_LEFT; + rightButton = gMain.newAndRepeatedKeys & DPAD_RIGHT; + break; + case LIST_MULTIPLE_SCROLL_L_R: + leftButton = gMain.newAndRepeatedKeys & L_BUTTON; + rightButton = gMain.newAndRepeatedKeys & R_BUTTON; + break; + } + + if (leftButton) + { + ListMenuChangeSelection(list, TRUE, list->template.maxShowed, FALSE); + return LIST_NOTHING_CHOSEN; + } + else if (rightButton) + { + ListMenuChangeSelection(list, TRUE, list->template.maxShowed, TRUE); + return LIST_NOTHING_CHOSEN; + } + else + { + return LIST_NOTHING_CHOSEN; + } + } +} + +void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + if (scrollOffset != NULL) + *scrollOffset = list->scrollOffset; + if (selectedRow != NULL) + *selectedRow = list->selectedRow; + + if (list->unk_1E != 0xFF) + ListMenuRemoveCursorObject(list->unk_1E, list->template.cursorKind - 2); + + DestroyTask(listTaskId); +} + +void sub_81AE70C(u8 listTaskId) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + FillWindowPixelBuffer(list->template.windowId, (list->template.fillPal << 4) | (list->template.fillPal)); + ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed); + ListMenuDrawCursor(list); + CopyWindowToVram(list->template.windowId, 2); +} + +// unused +void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillPal, u8 cursorShadowPal) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + list->template.cursorPal = cursorPal; + list->template.fillPal = fillPal; + list->template.cursorShadowPal = cursorShadowPal; +} + +// unused +void ChangeListMenuCoords(u8 listTaskId, u8 x, u8 y) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + SetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT, x); + SetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP, y); +} + +// unused +s32 ListMenuTestInput(struct ListMenuTemplate *template, u32 scrollOffset, u32 selectedRow, u16 keys, u16 *newScrollOffset, u16 *newSelectedRow) +{ + struct ListMenu list; + + list.template = *template; + list.scrollOffset = scrollOffset; + list.selectedRow = selectedRow; + list.unk_1C = 0; + list.unk_1D = 0; + + if (keys == DPAD_UP) + ListMenuChangeSelection(&list, FALSE, 1, FALSE); + if (keys == DPAD_DOWN) + ListMenuChangeSelection(&list, FALSE, 1, TRUE); + + if (newScrollOffset != NULL) + *newScrollOffset = list.scrollOffset; + if (newSelectedRow != NULL) + *newSelectedRow = list.selectedRow; + + return LIST_NOTHING_CHOSEN; +} + +void ListMenuGetCurrentItemArrayId(u8 listTaskId, u16 *arrayId) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + if (arrayId != NULL) + *arrayId = list->scrollOffset + list->selectedRow; +} + +void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + if (scrollOffset != NULL) + *scrollOffset = list->scrollOffset; + if (selectedRow != NULL) + *selectedRow = list->selectedRow; +} + +u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId) +{ + struct ListMenu *list = (void*) gTasks[listTaskId].data; + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3; + + return list->selectedRow * yMultiplier + list->template.upText_Y; +} + +struct ListMenuPals +{ + u8 field_0_0:4; + u8 field_0_4:4; + u8 field_1_0:4; + u8 lettersSpacing:6; + u8 field_2_2:6; + u8 fontId:7; + u8 field_3_7:1; +}; + +extern struct ListMenuPals gUnknown_03006300; + +u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow) +{ + u8 listTaskId = CreateTask(ListMenuDummyTask, 0); + struct ListMenu *list = (void*) gTasks[listTaskId].data; + + list->template = *listMenuTemplate; + list->scrollOffset = scrollOffset; + list->selectedRow = selectedRow; + list->unk_1C = 0; + list->unk_1D = 0; + list->unk_1E = 0xFF; + list->unk_1F = 0; + + gUnknown_03006300.field_0_0 = list->template.cursorPal; + gUnknown_03006300.field_0_4 = list->template.fillPal; + gUnknown_03006300.field_1_0 = list->template.cursorShadowPal; + gUnknown_03006300.lettersSpacing = list->template.lettersSpacing; + gUnknown_03006300.fontId = list->template.fontId; + gUnknown_03006300.field_3_7 = 0; + + if (list->template.totalItems < list->template.maxShowed) + list->template.maxShowed = list->template.totalItems; + + FillWindowPixelBuffer(list->template.windowId, (list->template.fillPal << 4) | (list->template.fillPal)); + ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed); + ListMenuDrawCursor(list); + ListMenuCallSelectionChangedCallback(list, 1); + + return listTaskId; +} + +void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) +{ + u8 colors[3]; + if (gUnknown_03006300.field_3_7) + { + colors[0] = gUnknown_03006300.field_0_4; + colors[1] = gUnknown_03006300.field_0_0; + colors[2] = gUnknown_03006300.field_1_0; + AddTextPrinterParameterized2(list->template.windowId, + gUnknown_03006300.fontId, + x, y, + gUnknown_03006300.lettersSpacing, + 0, colors, TEXT_SPEED_FF, str); + + gUnknown_03006300.field_3_7 = 0; + } + else + { + colors[0] = list->template.fillPal; + colors[1] = list->template.cursorPal; + colors[2] = list->template.cursorShadowPal; + AddTextPrinterParameterized2(list->template.windowId, + list->template.fontId, + x, y, + list->template.lettersSpacing, + 0, colors, TEXT_SPEED_FF, str); + } +} + +void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count) +{ + s32 i; + u8 x, y; + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3; + + for (i = 0; i < count; i++) + { + if (list->template.items[startIndex].id != -3) + x = list->template.unk_12; + else + x = list->template.unk_11; + + y = (yOffset + i) * yMultiplier + list->template.upText_Y; + if (list->template.unk_08 != NULL) + list->template.unk_08(list->template.windowId, list->template.items[startIndex].id, y); + + ListMenuPrint(list, list->template.items[startIndex].name, x, y); + startIndex++; + } +} diff --git a/src/pokeblock.c b/src/pokeblock.c index b9a1f6bf3..4c467017f 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -319,17 +319,17 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate = .unk_08 = NULL, .totalItems = 0, .maxShowed = 0, - .unk_10 = 1, + .windowId = 1, .unk_11 = 0, .unk_12 = 1, .cursor_Y = 0, .upText_Y = 1, - .cursorColor = 2, - .fillColor = 0, - .cursorShadowColor = 3, + .cursorPal = 2, + .fillPal = 0, + .cursorShadowPal = 3, .unk_16_0 = FALSE, .spaceBetweenItems = 32, - .unk_16_7 = FALSE, + .scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD, .unk_17_0 = 1, .cursorKind = 1 }; @@ -869,7 +869,7 @@ static void Task_FreeDataAndExitPokeblockCase(u8 taskId) if (sPokeblockMenu->caseId == PBLOCK_CASE_FEEDER || sPokeblockMenu->caseId == PBLOCK_CASE_GIVE) gFieldCallback = sub_80AF168; - sub_81AE6C8(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); + DestroyListMenuTask(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); sub_8136418(); ResetSpriteData(); FreeAllSpritePalettes(); @@ -893,7 +893,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId) { if (gMain.newKeys & SELECT_BUTTON) { - sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); + ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); if (sSavedPokeblockData.lastItemPage + sSavedPokeblockData.lastItemPos != sPokeblockMenu->itemsNo - 1) { PlaySE(SE_SELECT); @@ -908,7 +908,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId) u16 oldPosition = sSavedPokeblockData.lastItemPos; s32 itemId = ListMenuHandleInputGetItemId(data[0]); - sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); + ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); if (oldPosition != sSavedPokeblockData.lastItemPos) { HandlePokeblockMenuCursor(oldPosition, 5); @@ -945,7 +945,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId) if (gMain.newKeys & SELECT_BUTTON) { PlaySE(SE_SELECT); - sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); + ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); HandlePokeblocksSwap(taskId, FALSE); } else @@ -954,7 +954,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId) u16 var = sSavedPokeblockData.lastItemPos; s32 itemId = ListMenuHandleInputGetItemId(data[0]); - sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); + ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); if (i != sSavedPokeblockData.lastItemPage || var != sSavedPokeblockData.lastItemPos) { for (i = 0; i < 9; i++) @@ -996,7 +996,7 @@ static void HandlePokeblocksSwap(u8 taskId, bool8 noSwap) u16 swappedFromId = sSavedPokeblockData.lastItemPage + sSavedPokeblockData.lastItemPos; sPokeblockMenu->isSwapping = FALSE; - sub_81AE6C8(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); + DestroyListMenuTask(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); if (!noSwap && data[2] != swappedFromId && data[2] != swappedFromId - 1) { @@ -1112,7 +1112,7 @@ static void HandleErasePokeblock(u8 taskId) lastPos = &sSavedPokeblockData.lastItemPos; data = gTasks[taskId].data; - sub_81AE6C8(data[0], lastPage, lastPos); + DestroyListMenuTask(data[0], lastPage, lastPos); HandlePokeblockMenuCursor(*lastPos, 5); SetMenuItemsCountAndMaxShowed(); sub_81362E0(); diff --git a/src/secret_base.c b/src/secret_base.c index df754f2a0..29bbc4245 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -913,7 +913,7 @@ void game_continue(u8 taskId) data[3] = 8; } gMultiuseListMenuTemplate = gUnknown_0858D07C; - gMultiuseListMenuTemplate.unk_10 = data[6]; + gMultiuseListMenuTemplate.windowId = data[6]; gMultiuseListMenuTemplate.totalItems = data[0]; gMultiuseListMenuTemplate.items = gUnknown_0203A020->items; gMultiuseListMenuTemplate.maxShowed = data[3]; @@ -953,14 +953,14 @@ void sub_80E9E90(u8 taskId) data = gTasks[taskId].data; input = ListMenuHandleInputGetItemId(data[5]); - sub_81AE860(data[5], &data[2], &data[1]); + ListMenuGetScrollAndRow(data[5], &data[2], &data[1]); switch (input) { case -1: break; case -2: PlaySE(SE_SELECT); - sub_81AE6C8(data[5], NULL, NULL); + DestroyListMenuTask(data[5], NULL, NULL); RemoveScrollIndicatorArrowPair(data[8]); sub_819746C(data[6], 0); ClearWindowTilemap(data[6]); @@ -1042,7 +1042,7 @@ void sub_80EA08C(u8 taskId) data = gTasks[taskId].data; sub_8197434(0, 0); - sub_81AE6C8(data[5], &data[2], &data[1]); + DestroyListMenuTask(data[5], &data[2], &data[1]); gSaveBlock1Ptr->secretBases[data[4]].sbr_field_1_6 = 0; game_continue(taskId); sub_812225C(&data[2], &data[1], data[3], data[0]); @@ -1061,7 +1061,7 @@ void sub_80EA13C(u8 taskId) data = gTasks[taskId].data; sub_8197434(0, 0); - sub_81AE6C8(data[5], &data[2], &data[1]); + DestroyListMenuTask(data[5], &data[2], &data[1]); sub_80E9E00(taskId); gTasks[taskId].func = sub_80E9E90; } From 87274b9eedfcc1881a82b826dec1a6d63858ff33 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 3 Mar 2018 01:02:07 +0100 Subject: [PATCH 03/11] more list menu work --- asm/list_menu.s | 171 -------------------------------------- include/menu_indicators.h | 16 +++- src/list_menu.c | 47 +++++++++++ 3 files changed, 62 insertions(+), 172 deletions(-) diff --git a/asm/list_menu.s b/asm/list_menu.s index 89309262f..4eeb29fd4 100644 --- a/asm/list_menu.s +++ b/asm/list_menu.s @@ -6,177 +6,6 @@ .text - - - thumb_func_start ListMenuDrawCursor -@ void ListMenuDrawCursor(struct ListMenu *listMenu) -ListMenuDrawCursor: @ 81AEB20 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - ldrb r0, [r6, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetFontAttribute - ldrb r1, [r6, 0x16] - lsls r1, 26 - lsrs r1, 29 - adds r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r6, 0x13] - mov r8, r1 - ldrh r1, [r6, 0x1A] - muls r1, r0 - ldrb r0, [r6, 0x14] - lsls r0, 28 - lsrs r0, 28 - adds r0, r1 - lsls r0, 24 - lsrs r7, r0, 24 - ldrb r0, [r6, 0x17] - lsrs r0, 6 - cmp r0, 0x1 - beq _081AEC0C - cmp r0, 0x1 - bgt _081AEB66 - cmp r0, 0 - beq _081AEB70 - b _081AEC0C -_081AEB66: - cmp r0, 0x2 - beq _081AEB84 - cmp r0, 0x3 - beq _081AEBCC - b _081AEC0C -_081AEB70: - ldr r1, =gText_SelectorArrow2 - adds r0, r6, 0 - mov r2, r8 - adds r3, r7, 0 - bl ListMenuPrint - b _081AEC0C - .pool -_081AEB84: - ldrb r0, [r6, 0x1E] - cmp r0, 0xFF - bne _081AEB94 - adds r0, r6, 0 - movs r1, 0 - bl ListMenuAddCursorObject - strb r0, [r6, 0x1E] -_081AEB94: - ldrb r5, [r6, 0x1E] - ldrb r0, [r6, 0x10] - movs r1, 0x1 - bl GetWindowAttribute - adds r4, r0, 0 - lsls r4, 19 - ldr r0, =0xffff0000 - adds r4, r0 - lsrs r4, 16 - ldrb r0, [r6, 0x10] - movs r1, 0x2 - bl GetWindowAttribute - adds r2, r0, 0 - lsls r2, 3 - adds r2, r7 - subs r2, 0x1 - lsls r2, 16 - lsrs r2, 16 - adds r0, r5, 0 - adds r1, r4, 0 - movs r3, 0 - bl ListMenuUpdateCursorObject - b _081AEC0C - .pool -_081AEBCC: - ldrb r0, [r6, 0x1E] - cmp r0, 0xFF - bne _081AEBDC - adds r0, r6, 0 - movs r1, 0x1 - bl ListMenuAddCursorObject - strb r0, [r6, 0x1E] -_081AEBDC: - ldrb r5, [r6, 0x1E] - ldrb r0, [r6, 0x10] - movs r1, 0x1 - bl GetWindowAttribute - adds r4, r0, 0 - lsls r4, 3 - add r4, r8 - lsls r4, 16 - lsrs r4, 16 - ldrb r0, [r6, 0x10] - movs r1, 0x2 - bl GetWindowAttribute - adds r2, r0, 0 - lsls r2, 3 - adds r2, r7 - lsls r2, 16 - lsrs r2, 16 - adds r0, r5, 0 - adds r1, r4, 0 - movs r3, 0x1 - bl ListMenuUpdateCursorObject -_081AEC0C: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end ListMenuDrawCursor - - thumb_func_start ListMenuAddCursorObject -ListMenuAddCursorObject: @ 81AEC18 - push {r4,r5,lr} - sub sp, 0xC - adds r4, r0, 0 - adds r5, r1, 0 - mov r1, sp - movs r0, 0 - strb r0, [r1] - movs r0, 0xA0 - strb r0, [r1, 0x1] - ldrb r0, [r4, 0x10] - movs r1, 0x3 - bl GetWindowAttribute - mov r1, sp - lsls r0, 3 - adds r0, 0x2 - strh r0, [r1, 0x2] - ldrb r0, [r4, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetFontAttribute - mov r1, sp - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x2 - strh r0, [r1, 0x4] - movs r0, 0x80 - lsls r0, 7 - strh r0, [r1, 0x6] - ldr r0, =0x0000ffff - strh r0, [r1, 0x8] - movs r0, 0xF - strb r0, [r1, 0xA] - mov r0, sp - adds r1, r5, 0 - bl ListMenuAddCursorObjectInternal - lsls r0, 24 - lsrs r0, 24 - add sp, 0xC - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end ListMenuAddCursorObject - thumb_func_start ListMenuErasePrintedCursor ListMenuErasePrintedCursor: @ 81AEC78 push {r4-r7,lr} diff --git a/include/menu_indicators.h b/include/menu_indicators.h index b4cea11c7..a099cffab 100644 --- a/include/menu_indicators.h +++ b/include/menu_indicators.h @@ -7,17 +7,31 @@ // Exported ROM declarations -struct ArrowStruct { +struct ArrowStruct +{ u8 unk0[6]; u16 unk6[4]; u8 unkE; }; +struct CursorStruct +{ + u8 unk0; + u8 unk1; + u16 unk2; + u16 unk4; + u16 unk6; + u16 unk8; + u8 unkA; +}; + void Task_ScrollIndicatorArrowPairOnMainMenu(u8); u8 AddScrollIndicatorArrowPairParametrized(u8, u8, u8, u8, s32, u16, u16, u16 *); void RemoveScrollIndicatorArrowPair(u8); u8 AddScrollIndicatorArrowPair(const struct ArrowStruct*, void*); void sub_81AF15C(u8, u8, u8); void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind); +void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind); +u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind); #endif //GUARD_MENU_INDICATORS_H diff --git a/src/list_menu.c b/src/list_menu.c index 6df5d5d3a..91cc2532a 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -32,6 +32,7 @@ bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCa void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count); void ListMenuDrawCursor(struct ListMenu *list); void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2); +u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind); // code void ListMenuDummyTask(u8 taskId) @@ -376,3 +377,49 @@ void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u1 startIndex++; } } + +extern const u8 gText_SelectorArrow2[]; + +void ListMenuDrawCursor(struct ListMenu *list) +{ + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3; + u8 x = list->template.cursor_Y; + u8 y = list->selectedRow * yMultiplier + list->template.upText_Y; + switch (list->template.cursorKind) + { + case 0: + ListMenuPrint(list, gText_SelectorArrow2, x, y); + break; + case 1: + break; + case 2: + if (list->unk_1E == 0xFF) + list->unk_1E = ListMenuAddCursorObject(list, 0); + ListMenuUpdateCursorObject(list->unk_1E, + GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 - 1, + GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y - 1, 0); + break; + case 3: + if (list->unk_1E == 0xFF) + list->unk_1E = ListMenuAddCursorObject(list, 1); + ListMenuUpdateCursorObject(list->unk_1E, + GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 + x, + GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y, 1); + break; + } +} + +u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind) +{ + struct CursorStruct cursor; + + cursor.unk0 = 0; + cursor.unk1 = 0xA0; + cursor.unk2 = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8 + 2; + cursor.unk4 = GetFontAttribute(list->template.fontId, 1) + 2; + cursor.unk6 = 0x4000; + cursor.unk8 = 0xFFFF; + cursor.unkA = 0xF; + + return ListMenuAddCursorObjectInternal(&cursor, cursorKind); +} From 18a92fdcc05c9bf46c4ff11006043cccf5eefcff Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 3 Mar 2018 14:58:41 +0100 Subject: [PATCH 04/11] list menu is decompiled --- asm/list_menu.s | 563 -------------------------------------- common_syms/list_menu.txt | 2 + include/list_menu.h | 36 ++- ld_script.txt | 1 - src/daycare.c | 19 +- src/decoration.c | 4 +- src/item_menu.c | 4 +- src/list_menu.c | 300 ++++++++++++++++---- src/pokeblock.c | 16 +- src/secret_base.c | 6 +- sym_common.txt | 6 +- 11 files changed, 303 insertions(+), 654 deletions(-) delete mode 100644 asm/list_menu.s create mode 100644 common_syms/list_menu.txt diff --git a/asm/list_menu.s b/asm/list_menu.s deleted file mode 100644 index 4eeb29fd4..000000000 --- a/asm/list_menu.s +++ /dev/null @@ -1,563 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start ListMenuErasePrintedCursor -ListMenuErasePrintedCursor: @ 81AEC78 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - adds r7, r0, 0 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - ldrb r1, [r7, 0x17] - lsrs r0, r1, 6 - cmp r0, 0 - bne _081AECF4 - lsls r0, r1, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetFontAttribute - adds r4, r0, 0 - ldrb r0, [r7, 0x16] - lsls r0, 26 - lsrs r0, 29 - adds r4, r0 - lsls r4, 24 - lsrs r4, 24 - ldrb r0, [r7, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0 - bl GetMenuCursorDimensionByFont - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldrb r0, [r7, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetMenuCursorDimensionByFont - lsls r0, 24 - lsrs r0, 24 - ldrb r6, [r7, 0x10] - ldrb r2, [r7, 0x15] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - ldrb r2, [r7, 0x13] - mov r3, r8 - muls r3, r4 - adds r4, r3, 0 - ldrb r3, [r7, 0x14] - lsls r3, 28 - lsrs r3, 28 - adds r3, r4 - lsls r3, 16 - lsrs r3, 16 - str r5, [sp] - str r0, [sp, 0x4] - adds r0, r6, 0 - bl FillWindowPixelRect -_081AECF4: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end ListMenuErasePrintedCursor - - thumb_func_start ListMenuUpdateSelectedRowIndexAndScrollOffset -@ u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(int, bool8 movingDown) -ListMenuUpdateSelectedRowIndexAndScrollOffset: @ 81AED00 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 24 - ldrh r3, [r4, 0x1A] - ldrh r5, [r4, 0x18] - cmp r1, 0 - bne _081AED74 - ldrh r0, [r4, 0xE] - cmp r0, 0x1 - bne _081AED18 - movs r2, 0 - b _081AED2A -_081AED18: - ldrh r0, [r4, 0xE] - lsrs r2, r0, 1 - movs r1, 0x1 - ands r1, r0 - adds r2, r1 - subs r0, r2 - subs r0, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 -_081AED2A: - cmp r5, 0 - bne _081AED50 - cmp r3, 0 - beq _081AEDB6 - ldr r1, [r4] - movs r2, 0x3 - negs r2, r2 -_081AED38: - subs r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - adds r0, r5, r3 - lsls r0, 3 - adds r0, r1 - ldr r0, [r0, 0x4] - cmp r0, r2 - bne _081AEDBA - cmp r3, 0 - bne _081AED38 - b _081AEDB6 -_081AED50: - cmp r3, r2 - bls _081AED70 - ldr r1, [r4] - movs r6, 0x3 - negs r6, r6 -_081AED5A: - subs r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - adds r0, r5, r3 - lsls r0, 3 - adds r0, r1 - ldr r0, [r0, 0x4] - cmp r0, r6 - bne _081AEDBA - cmp r3, r2 - bhi _081AED5A -_081AED70: - subs r0, r5, 0x1 - b _081AEDE2 -_081AED74: - ldrh r0, [r4, 0xE] - cmp r0, 0x1 - bne _081AED7E - movs r2, 0 - b _081AED88 -_081AED7E: - ldrh r0, [r4, 0xE] - lsrs r2, r0, 1 - movs r1, 0x1 - ands r1, r0 - adds r2, r1 -_081AED88: - adds r1, r0, 0 - ldrh r0, [r4, 0xC] - subs r0, r1 - cmp r5, r0 - bne _081AEDC0 - subs r0, r1, 0x1 - cmp r3, r0 - bge _081AEDB6 - ldr r2, [r4] - movs r6, 0x3 - negs r6, r6 - adds r1, r0, 0 -_081AEDA0: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - adds r0, r5, r3 - lsls r0, 3 - adds r0, r2 - ldr r0, [r0, 0x4] - cmp r0, r6 - bne _081AEDBA - cmp r3, r1 - blt _081AEDA0 -_081AEDB6: - movs r0, 0 - b _081AEDE8 -_081AEDBA: - strh r3, [r4, 0x1A] - movs r0, 0x1 - b _081AEDE8 -_081AEDC0: - cmp r3, r2 - bcs _081AEDE0 - ldr r1, [r4] - movs r6, 0x3 - negs r6, r6 -_081AEDCA: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - adds r0, r5, r3 - lsls r0, 3 - adds r0, r1 - ldr r0, [r0, 0x4] - cmp r0, r6 - bne _081AEDBA - cmp r3, r2 - bcc _081AEDCA -_081AEDE0: - adds r0, r5, 0x1 -_081AEDE2: - strh r2, [r4, 0x1A] - strh r0, [r4, 0x18] - movs r0, 0x2 -_081AEDE8: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end ListMenuUpdateSelectedRowIndexAndScrollOffset - - thumb_func_start ListMenuScroll -@ void ListMenuScroll(struct ListMenu *listMenu, int a2, bool8 movingDown) -ListMenuScroll: @ 81AEDF0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - adds r6, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - adds r7, r5, 0 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldrh r0, [r6, 0xE] - cmp r5, r0 - bcc _081AEE2A - ldrb r0, [r6, 0x10] - ldrb r2, [r6, 0x15] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - bl FillWindowPixelBuffer - ldrh r1, [r6, 0x18] - ldrh r3, [r6, 0xE] - adds r0, r6, 0 - movs r2, 0 - bl ListMenuPrintEntries - b _081AEF1A -_081AEE2A: - ldrb r0, [r6, 0x17] - lsls r0, 26 - lsrs r0, 26 - movs r1, 0x1 - bl GetFontAttribute - ldrb r1, [r6, 0x16] - lsls r1, 26 - lsrs r1, 29 - adds r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - mov r1, r8 - cmp r1, 0 - bne _081AEEBC - ldrb r0, [r6, 0x10] - adds r2, r5, 0 - muls r2, r4 - lsls r2, 24 - lsrs r2, 24 - ldrb r1, [r6, 0x15] - lsls r1, 28 - lsrs r3, r1, 4 - orrs r3, r1 - lsrs r3, 24 - movs r1, 0x1 - bl ScrollWindow - ldrh r1, [r6, 0x18] - adds r0, r6, 0 - movs r2, 0 - adds r3, r5, 0 - bl ListMenuPrintEntries - ldrh r0, [r6, 0xE] - adds r1, r0, 0 - muls r1, r4 - adds r0, r1, 0 - ldrb r4, [r6, 0x14] - lsls r4, 28 - lsrs r4, 28 - adds r4, r0 - lsls r4, 16 - lsrs r4, 16 - ldrb r0, [r6, 0x10] - movs r1, 0x3 - bl GetWindowAttribute - adds r5, r0, 0 - lsls r5, 19 - lsrs r5, 16 - ldrb r0, [r6, 0x10] - movs r1, 0x4 - bl GetWindowAttribute - lsls r0, 3 - subs r0, r4 - lsls r0, 16 - lsrs r0, 16 - ldrb r3, [r6, 0x10] - ldrb r2, [r6, 0x15] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - str r5, [sp] - str r0, [sp, 0x4] - adds r0, r3, 0 - movs r2, 0 - adds r3, r4, 0 - bl FillWindowPixelRect - b _081AEF1A -_081AEEBC: - ldrb r0, [r6, 0x10] - adds r2, r7, 0 - muls r2, r4 - lsls r2, 24 - lsrs r2, 24 - ldrb r1, [r6, 0x15] - lsls r1, 28 - lsrs r3, r1, 4 - orrs r3, r1 - lsrs r3, 24 - movs r1, 0 - bl ScrollWindow - ldrh r2, [r6, 0xE] - subs r2, r7 - ldrh r1, [r6, 0x18] - adds r1, r2 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - adds r0, r6, 0 - adds r3, r7, 0 - bl ListMenuPrintEntries - ldrb r0, [r6, 0x10] - movs r1, 0x3 - bl GetWindowAttribute - lsls r0, 19 - lsrs r0, 16 - ldrb r3, [r6, 0x10] - ldrb r2, [r6, 0x15] - lsls r2, 28 - lsrs r1, r2, 4 - orrs r1, r2 - lsrs r1, 24 - str r0, [sp] - ldrb r0, [r6, 0x14] - lsls r0, 28 - lsrs r0, 28 - str r0, [sp, 0x4] - adds r0, r3, 0 - movs r2, 0 - movs r3, 0 - bl FillWindowPixelRect -_081AEF1A: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end ListMenuScroll - - thumb_func_start ListMenuChangeSelection -@ bool8 ListMenuChangeSelection(struct ListMenu *listMenu, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown) -ListMenuChangeSelection: @ 81AEF28 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - adds r4, r0, 0 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - lsls r3, 24 - lsrs r3, 24 - mov r9, r3 - ldrh r0, [r4, 0x1A] - mov r10, r0 - movs r7, 0 - movs r5, 0 - movs r0, 0 - cmp r7, r8 - bcs _081AEF90 -_081AEF56: - adds r6, r0, 0x1 - b _081AEF76 -_081AEF5A: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - ldrh r0, [r4, 0x18] - ldrh r1, [r4, 0x1A] - adds r0, r1 - ldr r1, [r4] - lsls r0, 3 - adds r0, r1 - ldr r1, [r0, 0x4] - movs r0, 0x3 - negs r0, r0 - cmp r1, r0 - bne _081AEF88 -_081AEF76: - adds r0, r4, 0 - mov r1, r9 - bl ListMenuUpdateSelectedRowIndexAndScrollOffset - lsls r0, 24 - lsrs r0, 24 - orrs r5, r0 - cmp r0, 0x2 - beq _081AEF5A -_081AEF88: - lsls r0, r6, 24 - lsrs r0, 24 - cmp r0, r8 - bcc _081AEF56 -_081AEF90: - ldr r0, [sp] - cmp r0, 0 - beq _081AEFEE - cmp r5, 0x1 - beq _081AEFA6 - cmp r5, 0x1 - ble _081AEFA2 - cmp r5, 0x3 - ble _081AEFC6 -_081AEFA2: - movs r0, 0x1 - b _081AEFF0 -_081AEFA6: - adds r0, r4, 0 - mov r1, r10 - bl ListMenuErasePrintedCursor - adds r0, r4, 0 - bl ListMenuDrawCursor - adds r0, r4, 0 - movs r1, 0 - bl ListMenuCallSelectionChangedCallback - ldrb r0, [r4, 0x10] - movs r1, 0x2 - bl CopyWindowToVram - b _081AEFEE -_081AEFC6: - adds r0, r4, 0 - mov r1, r10 - bl ListMenuErasePrintedCursor - adds r0, r4, 0 - adds r1, r7, 0 - mov r2, r9 - bl ListMenuScroll - adds r0, r4, 0 - bl ListMenuDrawCursor - adds r0, r4, 0 - movs r1, 0 - bl ListMenuCallSelectionChangedCallback - ldrb r0, [r4, 0x10] - movs r1, 0x2 - bl CopyWindowToVram -_081AEFEE: - movs r0, 0 -_081AEFF0: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end ListMenuChangeSelection - - thumb_func_start ListMenuCallSelectionChangedCallback -@ void ListMenuCallSelectionChangedCallback(struct ListMenu *listMenu, u8 a2) -ListMenuCallSelectionChangedCallback: @ 81AF000 - push {r4,lr} - adds r2, r0, 0 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r3, [r2, 0x4] - cmp r3, 0 - beq _081AF022 - ldrh r0, [r2, 0x18] - ldrh r1, [r2, 0x1A] - adds r0, r1 - ldr r1, [r2] - lsls r0, 3 - adds r0, r1 - ldr r0, [r0, 0x4] - adds r1, r4, 0 - bl _call_via_r3 -_081AF022: - pop {r4} - pop {r0} - bx r0 - thumb_func_end ListMenuCallSelectionChangedCallback - - thumb_func_start sub_81AF028 -sub_81AF028: @ 81AF028 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsls r2, 24 - lsrs r2, 24 - ldr r6, =gUnknown_03006300 - movs r5, 0xF - ands r0, r5 - ldrb r3, [r6] - mov r8, r3 - movs r4, 0x10 - negs r4, r4 - adds r3, r4, 0 - mov r7, r8 - ands r3, r7 - orrs r3, r0 - lsrs r1, 20 - ands r3, r5 - orrs r3, r1 - strb r3, [r6] - ands r2, r5 - ldrb r0, [r6, 0x1] - ands r4, r0 - orrs r4, r2 - strb r4, [r6, 0x1] - ldrb r0, [r6, 0x3] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r6, 0x3] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AF028 - - thumb_func_start sub_81AF078 -sub_81AF078: @ 81AF078 - push {lr} - lsls r1, 24 - cmp r1, 0 - bne _081AF086 - movs r0, 0x5 - bl PlaySE -_081AF086: - pop {r0} - bx r0 - thumb_func_end sub_81AF078 - - .align 2, 0 @ Don't pad with nop. diff --git a/common_syms/list_menu.txt b/common_syms/list_menu.txt new file mode 100644 index 000000000..a346edeef --- /dev/null +++ b/common_syms/list_menu.txt @@ -0,0 +1,2 @@ +gUnknown_03006300 +gMultiuseListMenuTemplate diff --git a/include/list_menu.h b/include/list_menu.h index d25549845..0aa66a524 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -8,9 +8,7 @@ #define LIST_MULTIPLE_SCROLL_DPAD 1 #define LIST_MULTIPLE_SCROLL_L_R 2 -// Exported type declarations - -// Exported RAM declarations +struct ListMenu; struct ListMenuItem { @@ -18,22 +16,20 @@ struct ListMenuItem s32 id; }; -struct ListMenu; - struct ListMenuTemplate { const struct ListMenuItem *items; - void (* moveCursorFunc)(u32, bool8, struct ListMenu *); + void (* moveCursorFunc)(s32, bool8, struct ListMenu *); void (* unk_08)(u8 windowId, s32 itemId, u8 y); u16 totalItems; u16 maxShowed; u8 windowId; u8 unk_11; u8 unk_12; - u8 cursor_Y; + u8 cursor_X; u8 upText_Y:4; // x1, x2, x4, x8 = xF u8 cursorPal:4; // x10, x20, x40, x80 = xF0 - u8 fillPal:4; // x1, x2, x4, x8 = xF + u8 fillValue:4; // x1, x2, x4, x8 = xF u8 cursorShadowPal:4; // x10, x20, x40, x80 = xF0 u8 lettersSpacing:3; u8 unk_16_3:3; @@ -53,14 +49,30 @@ struct ListMenu u8 unk_1F; }; +struct UnknownListMenuWindowStruct +{ + u8 x; + u8 y; + u8 width; + u8 height; + u8 palNum; +}; + extern struct ListMenuTemplate gMultiuseListMenuTemplate; -// Exported ROM declarations - -u8 ListMenuInit(struct ListMenuTemplate *template, u16 scrollOffset, u16 selectedRow); +s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum); +u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); +u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuWindowStruct *arg1, u16 scrollOffset, u16 selectedRow); s32 ListMenuHandleInputGetItemId(u8 listTaskId); -void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); +void sub_81AE70C(u8 listTaskId); +void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillValue, u8 cursorShadowPal); +void ChangeListMenuCoords(u8 listTaskId, u8 x, u8 y); +s32 ListMenuTestInput(struct ListMenuTemplate *template, u32 scrollOffset, u32 selectedRow, u16 keys, u16 *newScrollOffset, u16 *newSelectedRow); +void ListMenuGetCurrentItemArrayId(u8 listTaskId, u16 *arrayId); +void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow); u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId); +void sub_81AF028(u8 cursorPal, u8 fillValue, u8 cursorShadowPal); +void sub_81AF078(s32 arg0, u8 arg1, struct ListMenu *list); #endif //GUARD_LIST_MENU_H diff --git a/ld_script.txt b/ld_script.txt index 88306e790..8f104f391 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -248,7 +248,6 @@ SECTIONS { asm/battle_frontier_2.o(.text); src/item_menu.o(.text); src/list_menu.o(.text); - asm/list_menu.o(.text); asm/menu_indicators.o(.text); src/unk_text_util.o(.text); src/save_location.o(.text); diff --git a/src/daycare.c b/src/daycare.c index f4bd84af3..d567ff79a 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -45,7 +45,6 @@ extern void DestroyListMenuTask(u8, u16*, u16*); extern void sub_819746C(u8, bool8); extern void NewMenuHelpers_DrawStdWindowFrame(u8, bool8); extern void sub_81B9328(void); -extern void sub_81AF078(u32, bool8, struct ListMenu *); extern void CB2_ReturnToField(void); // this file's functions @@ -79,18 +78,18 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate = .unk_08 = DaycarePrintMonInfo, .totalItems = 3, .maxShowed = 3, - .unk_10 = 0, + .windowId = 0, .unk_11 = 0, .unk_12 = 8, - .cursor_Y = 0, + .cursor_X = 0, .upText_Y = 1, - .cursorColor = 2, - .fillColor = 1, - .cursorShadowColor = 3, - .unk_16_0 = TRUE, - .spaceBetweenItems = 0, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 1, + .unk_16_3 = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, - .unk_17_0 = 1, + .fontId = 1, .cursorKind = 0 }; @@ -1299,7 +1298,7 @@ void ShowDaycareLevelMenu(void) NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE); menuTemplate = sDaycareListMenuLevelTemplate; - menuTemplate.unk_10 = windowId; + menuTemplate.windowId = windowId; listMenuTaskId = ListMenuInit(&menuTemplate, 0, 0); CopyWindowToVram(windowId, 3); diff --git a/src/decoration.c b/src/decoration.c index 899851c6a..ffa1c3a68 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -113,7 +113,7 @@ void sub_812719C(u8 taskId); void sub_81271CC(u8 taskId); void sub_8127268(u8 taskId); void sub_8127454(u8 *dest, u16 decorId); -void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu); +void sub_8127480(s32 a0, bool8 flag, struct ListMenu *menu); void sub_81274A0(u8 a0, s32 a1, u8 a2); void sub_8127620(u8 taskId); void sub_812764C(u8 taskId); @@ -813,7 +813,7 @@ void sub_8127454(u8 *dest, u16 decorId) StringAppend(dest, gDecorations[decorId].name); } -void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu) +void sub_8127480(s32 a0, bool8 flag, struct ListMenu *menu) { if (flag != TRUE) { diff --git a/src/item_menu.c b/src/item_menu.c index a51894ea1..24dce79f6 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -128,7 +128,7 @@ void sub_81ABAC4(void); void sub_81ABAE0(void); u8 sub_81AB1F0(u8); void sub_81AC23C(u8); -void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu*); +void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu*); void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a); void ItemMenu_UseOutOfBattle(u8 taskId); void ItemMenu_Toss(u8 taskId); @@ -688,7 +688,7 @@ void get_name(s8 *dest, u16 itemId) } } -void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu *unused) +void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu *unused) { if (b != 1) { diff --git a/src/list_menu.c b/src/list_menu.c index 91cc2532a..9b9921c8f 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -6,8 +6,11 @@ #include "main.h" #include "task.h" #include "menu_indicators.h" +#include "strings.h" +#include "sound.h" +#include "constants/songs.h" -struct ListMenuStruct +struct UnknownMysteryGiftLinkMenuStruct { s32 field_0; u8 field_4; @@ -15,27 +18,33 @@ struct ListMenuStruct u8 field_6; }; -struct UnknownListMenuStruct +struct UnknownListMenuPals { - u8 x; - u8 y; - u8 width; - u8 height; - u8 palNum; + u8 cursorPal:4; + u8 fillValue:4; + u8 cursorShadowPal:4; + u8 lettersSpacing:6; + u8 field_2_2:6; // unused + u8 fontId:7; + u8 field_3_7:1; }; -extern struct ListMenuStruct gUnknown_0203CE84; +extern struct UnknownMysteryGiftLinkMenuStruct gUnknown_0203CE84; // this file's functions -u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); -bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown); -void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count); -void ListMenuDrawCursor(struct ListMenu *list); -void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2); -u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind); +static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); +static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown); +static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count); +static void ListMenuDrawCursor(struct ListMenu *list); +static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2); +static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind); + +// IWRAM common +struct UnknownListMenuPals gUnknown_03006300; +struct ListMenuTemplate gMultiuseListMenuTemplate; // code -void ListMenuDummyTask(u8 taskId) +static void ListMenuDummyTask(u8 taskId) { } @@ -111,7 +120,7 @@ u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 } // unused -u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuStruct *arg1, u16 scrollOffset, u16 selectedRow) +u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuWindowStruct *arg1, u16 scrollOffset, u16 selectedRow) { s32 i; @@ -208,19 +217,19 @@ void sub_81AE70C(u8 listTaskId) { struct ListMenu *list = (void*) gTasks[listTaskId].data; - FillWindowPixelBuffer(list->template.windowId, (list->template.fillPal << 4) | (list->template.fillPal)); + FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue)); ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed); ListMenuDrawCursor(list); CopyWindowToVram(list->template.windowId, 2); } // unused -void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillPal, u8 cursorShadowPal) +void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillValue, u8 cursorShadowPal) { struct ListMenu *list = (void*) gTasks[listTaskId].data; list->template.cursorPal = cursorPal; - list->template.fillPal = fillPal; + list->template.fillValue = fillValue; list->template.cursorShadowPal = cursorShadowPal; } @@ -283,20 +292,7 @@ u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId) return list->selectedRow * yMultiplier + list->template.upText_Y; } -struct ListMenuPals -{ - u8 field_0_0:4; - u8 field_0_4:4; - u8 field_1_0:4; - u8 lettersSpacing:6; - u8 field_2_2:6; - u8 fontId:7; - u8 field_3_7:1; -}; - -extern struct ListMenuPals gUnknown_03006300; - -u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow) +static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow) { u8 listTaskId = CreateTask(ListMenuDummyTask, 0); struct ListMenu *list = (void*) gTasks[listTaskId].data; @@ -309,9 +305,9 @@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOff list->unk_1E = 0xFF; list->unk_1F = 0; - gUnknown_03006300.field_0_0 = list->template.cursorPal; - gUnknown_03006300.field_0_4 = list->template.fillPal; - gUnknown_03006300.field_1_0 = list->template.cursorShadowPal; + gUnknown_03006300.cursorPal = list->template.cursorPal; + gUnknown_03006300.fillValue = list->template.fillValue; + gUnknown_03006300.cursorShadowPal = list->template.cursorShadowPal; gUnknown_03006300.lettersSpacing = list->template.lettersSpacing; gUnknown_03006300.fontId = list->template.fontId; gUnknown_03006300.field_3_7 = 0; @@ -319,7 +315,7 @@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOff if (list->template.totalItems < list->template.maxShowed) list->template.maxShowed = list->template.totalItems; - FillWindowPixelBuffer(list->template.windowId, (list->template.fillPal << 4) | (list->template.fillPal)); + FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue)); ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed); ListMenuDrawCursor(list); ListMenuCallSelectionChangedCallback(list, 1); @@ -327,14 +323,14 @@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOff return listTaskId; } -void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) +static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) { u8 colors[3]; if (gUnknown_03006300.field_3_7) { - colors[0] = gUnknown_03006300.field_0_4; - colors[1] = gUnknown_03006300.field_0_0; - colors[2] = gUnknown_03006300.field_1_0; + colors[0] = gUnknown_03006300.fillValue; + colors[1] = gUnknown_03006300.cursorPal; + colors[2] = gUnknown_03006300.cursorShadowPal; AddTextPrinterParameterized2(list->template.windowId, gUnknown_03006300.fontId, x, y, @@ -345,7 +341,7 @@ void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) } else { - colors[0] = list->template.fillPal; + colors[0] = list->template.fillValue; colors[1] = list->template.cursorPal; colors[2] = list->template.cursorShadowPal; AddTextPrinterParameterized2(list->template.windowId, @@ -356,7 +352,7 @@ void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) } } -void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count) +static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count) { s32 i; u8 x, y; @@ -378,12 +374,10 @@ void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u1 } } -extern const u8 gText_SelectorArrow2[]; - -void ListMenuDrawCursor(struct ListMenu *list) +static void ListMenuDrawCursor(struct ListMenu *list) { u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3; - u8 x = list->template.cursor_Y; + u8 x = list->template.cursor_X; u8 y = list->selectedRow * yMultiplier + list->template.upText_Y; switch (list->template.cursorKind) { @@ -409,7 +403,7 @@ void ListMenuDrawCursor(struct ListMenu *list) } } -u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind) +static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind) { struct CursorStruct cursor; @@ -423,3 +417,213 @@ u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind) return ListMenuAddCursorObjectInternal(&cursor, cursorKind); } + +static void ListMenuErasePrintedCursor(struct ListMenu *list, u16 selectedRow) +{ + u8 cursorKind = list->template.cursorKind; + if (cursorKind == 0) + { + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3; + u8 width = GetMenuCursorDimensionByFont(list->template.fontId, 0); + u8 height = GetMenuCursorDimensionByFont(list->template.fontId, 1); + FillWindowPixelRect(list->template.windowId, + (list->template.fillValue << 4) | (list->template.fillValue), + list->template.cursor_X, + selectedRow * yMultiplier + list->template.upText_Y, + width, + height); + } +} + +static u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, bool8 movingDown) +{ + u16 selectedRow = list->selectedRow; + u16 scrollOffset = list->scrollOffset; + u16 newRow; + u32 newScroll; + + if (!movingDown) + { + if (list->template.maxShowed == 1) + newRow = 0; + else + newRow = list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1; + + if (scrollOffset == 0) + { + while (selectedRow != 0) + { + selectedRow--; + if (list->template.items[scrollOffset + selectedRow].id != -3) + { + list->selectedRow = selectedRow; + return 1; + } + } + + return 0; + } + else + { + while (selectedRow > newRow) + { + selectedRow--; + if (list->template.items[scrollOffset + selectedRow].id != -3) + { + list->selectedRow = selectedRow; + return 1; + } + } + + newScroll = scrollOffset - 1; + } + } + else + { + if (list->template.maxShowed == 1) + newRow = 0; + else + newRow = ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)); + + if (scrollOffset == list->template.totalItems - list->template.maxShowed) + { + while (selectedRow < list->template.maxShowed - 1) + { + selectedRow++; + if (list->template.items[scrollOffset + selectedRow].id != -3) + { + list->selectedRow = selectedRow; + return 1; + } + } + + return 0; + } + else + { + while (selectedRow < newRow) + { + selectedRow++; + if (list->template.items[scrollOffset + selectedRow].id != -3) + { + list->selectedRow = selectedRow; + return 1; + } + } + + newScroll = scrollOffset + 1; + } + } + + list->selectedRow = newRow; + list->scrollOffset = newScroll; + return 2; +} + +static void ListMenuScroll(struct ListMenu *list, u8 count, bool8 movingDown) +{ + if (count >= list->template.maxShowed) + { + FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue)); + ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed); + } + else + { + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3; + + if (!movingDown) + { + u16 y, width, height; + + ScrollWindow(list->template.windowId, 1, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue)); + ListMenuPrintEntries(list, list->scrollOffset, 0, count); + + y = (list->template.maxShowed * yMultiplier) + list->template.upText_Y; + width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8; + height = (GetWindowAttribute(list->template.windowId, WINDOW_HEIGHT) * 8) - y; + FillWindowPixelRect(list->template.windowId, + (list->template.fillValue << 4) | (list->template.fillValue), + 0, y, width, height); + } + else + { + u16 width; + + ScrollWindow(list->template.windowId, 0, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue)); + ListMenuPrintEntries(list, list->scrollOffset + (list->template.maxShowed - count), list->template.maxShowed - count, count); + + width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8; + FillWindowPixelRect(list->template.windowId, + (list->template.fillValue << 4) | (list->template.fillValue), + 0, 0, width, list->template.upText_Y); + } + } +} + +static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown) +{ + u16 oldSelectedRow; + u8 selectionChange, i, cursorCount; + + oldSelectedRow = list->selectedRow; + cursorCount = 0; + selectionChange = 0; + for (i = 0; i < count; i++) + { + do + { + u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown); + selectionChange |= ret; + if (ret != 2) + break; + cursorCount++; + } while (list->template.items[list->scrollOffset + list->selectedRow].id == -3); + } + + if (updateCursorAndCallCallback) + { + switch (selectionChange) + { + case 0: + default: + return TRUE; + case 1: + ListMenuErasePrintedCursor(list, oldSelectedRow); + ListMenuDrawCursor(list); + ListMenuCallSelectionChangedCallback(list, 0); + CopyWindowToVram(list->template.windowId, 2); + break; + case 2: + case 3: + ListMenuErasePrintedCursor(list, oldSelectedRow); + ListMenuScroll(list, cursorCount, movingDown); + ListMenuDrawCursor(list); + ListMenuCallSelectionChangedCallback(list, 0); + CopyWindowToVram(list->template.windowId, 2); + break; + } + } + + return FALSE; +} + +static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2) +{ + if (list->template.moveCursorFunc != NULL) + list->template.moveCursorFunc(list->template.items[list->scrollOffset + list->selectedRow].id, a2, list); +} + +// unused +void sub_81AF028(u8 cursorPal, u8 fillValue, u8 cursorShadowPal) +{ + gUnknown_03006300.cursorPal = cursorPal; + gUnknown_03006300.fillValue = fillValue; + gUnknown_03006300.cursorShadowPal = cursorShadowPal; + gUnknown_03006300.field_3_7 = 1; +} + +void sub_81AF078(s32 arg0, u8 arg1, struct ListMenu *list) +{ + if (!arg1) + PlaySE(SE_SELECT); +} diff --git a/src/pokeblock.c b/src/pokeblock.c index 4c467017f..b244409c4 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -91,7 +91,7 @@ static void sub_81362E0(void); static void sub_8136344(void); static void HandlePokeblockListMenuItems(void); static void sub_81363BC(void); -static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2); +static void MovePokeblockMenuCursor(s32 pkblId, bool8 arg1, struct ListMenu *arg2); static void PutPokeblockInfoText(void); static void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1); static void PutPokeblockListMenuString(u8 *dst, u16 pkblId); @@ -322,15 +322,15 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate = .windowId = 1, .unk_11 = 0, .unk_12 = 1, - .cursor_Y = 0, + .cursor_X = 0, .upText_Y = 1, .cursorPal = 2, - .fillPal = 0, + .fillValue = 0, .cursorShadowPal = 3, - .unk_16_0 = FALSE, - .spaceBetweenItems = 32, + .lettersSpacing = 0, + .unk_16_3 = 0, .scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD, - .unk_17_0 = 1, + .fontId = 1, .cursorKind = 1 }; @@ -620,7 +620,7 @@ static void HandlePokeblockListMenuItems(void) sPokeblockMenu->items[i].id = LIST_B_PRESSED; gMultiuseListMenuTemplate = sPokeblockListMenuTemplate; - gMultiuseListMenuTemplate.unk_17_0 = 7; + gMultiuseListMenuTemplate.fontId = 7; gMultiuseListMenuTemplate.totalItems = sPokeblockMenu->itemsNo; gMultiuseListMenuTemplate.items = sPokeblockMenu->items; gMultiuseListMenuTemplate.maxShowed = sPokeblockMenu->maxShowed; @@ -639,7 +639,7 @@ static void PutPokeblockListMenuString(u8 *dst, u16 pkblId) StringExpandPlaceholders(txtPtr, gText_LvVar1); } -static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2) +static void MovePokeblockMenuCursor(s32 pkblId, bool8 arg1, struct ListMenu *arg2) { if (arg1 != TRUE) { diff --git a/src/secret_base.c b/src/secret_base.c index 29bbc4245..c886912f4 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -6,8 +6,8 @@ #include "main.h" #include "task.h" #include "palette.h" -#include "list_menu.h" #include "window.h" +#include "list_menu.h" #include "menu.h" #include "menu_helpers.h" #include "menu_indicators.h" @@ -66,7 +66,7 @@ EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL; void sub_80E9C9C(u8 taskId); void game_continue(u8 taskId); -void sub_80E9DEC(u32 a0, bool8 flag, struct ListMenu *menu); +void sub_80E9DEC(s32 a0, bool8 flag, struct ListMenu *menu); void sub_80E9E00(u8 taskId); void sub_80E9E44(u8 taskId); void sub_80E9E90(u8 taskId); @@ -919,7 +919,7 @@ void game_continue(u8 taskId) gMultiuseListMenuTemplate.maxShowed = data[3]; } -void sub_80E9DEC(u32 a0, bool8 flag, struct ListMenu *menu) +void sub_80E9DEC(s32 a0, bool8 flag, struct ListMenu *menu) { if (flag != TRUE) { diff --git a/sym_common.txt b/sym_common.txt index ce3540ad9..01772fa5a 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -178,11 +178,7 @@ gUnknown_030062F0: @ 30062F0 gUnknown_030062F4: @ 30062F4 .space 0xC -gUnknown_03006300: @ 3006300 - .space 0x10 - -gMultiuseListMenuTemplate: @ 3006310 - .space 0x18 + .include "list_menu.o" gUnknown_03006328: @ 3006328 .space 0x48 From 4c3f8ac6c6f15338f1cbad09605ed208044faf32 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 4 Mar 2018 18:41:07 +0100 Subject: [PATCH 05/11] start item menu icons decomp --- asm/item_menu_icons.s | 637 ---------------------- data/graphics/berries/berry_pic_table.inc | 45 -- data/item_menu_icons.s | 169 ------ include/graphics.h | 95 +++- include/item_menu.h | 41 +- include/item_menu_icons.h | 2 +- ld_script.txt | 3 +- src/item_menu.c | 67 +-- src/item_menu_icons.c | 570 +++++++++++++++++++ 9 files changed, 717 insertions(+), 912 deletions(-) delete mode 100644 asm/item_menu_icons.s delete mode 100644 data/graphics/berries/berry_pic_table.inc create mode 100644 src/item_menu_icons.c diff --git a/asm/item_menu_icons.s b/asm/item_menu_icons.s deleted file mode 100644 index 8068e37c2..000000000 --- a/asm/item_menu_icons.s +++ /dev/null @@ -1,637 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start RemoveBagObject -@ void RemoveBagObject(u8 a1) -RemoveBagObject: @ 80D4CA8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_0203CE54 - ldr r2, =0x00000804 - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - beq _080D4CEE - adds r4, 0x64 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl FreeSpriteOamMatrix - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - movs r0, 0xFF - strb r0, [r5] -_080D4CEE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end RemoveBagObject - - thumb_func_start AddBagVisualObject -@ void AddBagVisualObject(u8 bagPocketId) -AddBagVisualObject: @ 80D4D00 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gUnknown_0203CE54 - ldr r4, [r0] - ldr r0, =0x00000804 - adds r4, r0 - ldr r0, =gUnknown_0857FB4C - movs r1, 0x44 - movs r2, 0x42 - movs r3, 0 - bl CreateSprite - strb r0, [r4] - adds r0, r5, 0 - movs r1, 0 - bl SetBagVisualPocketId - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AddBagVisualObject - - thumb_func_start SetBagVisualPocketId -@ void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets) -SetBagVisualPocketId: @ 80D4D38 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r2, =0x00000804 - adds r0, r2 - ldrb r2, [r0] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - ldr r2, =gSprites - adds r2, r0, r2 - cmp r1, 0 - beq _080D4D84 - ldr r0, =0x0000fffb - strh r0, [r2, 0x26] - ldr r0, =ObjectCB_BagVisualSwitchingPockets - str r0, [r2, 0x1C] - adds r0, r3, 0x1 - strh r0, [r2, 0x2E] - adds r0, r2, 0 - movs r1, 0 - bl StartSpriteAnim - b _080D4D90 - .pool -_080D4D84: - adds r1, r3, 0x1 - lsls r1, 24 - lsrs r1, 24 - adds r0, r2, 0 - bl StartSpriteAnim -_080D4D90: - pop {r0} - bx r0 - thumb_func_end SetBagVisualPocketId - - thumb_func_start ObjectCB_BagVisualSwitchingPockets -@ void ObjectCB_BagVisualSwitchingPockets(struct obj *object) -ObjectCB_BagVisualSwitchingPockets: @ 80D4D94 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x26] - movs r2, 0x26 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _080D4DA8 - adds r0, r1, 0x1 - strh r0, [r4, 0x26] - b _080D4DB8 -_080D4DA8: - ldrh r1, [r4, 0x2E] - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_080D4DB8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_BagVisualSwitchingPockets - - thumb_func_start ShakeBagVisual -@ void ShakeBagVisual() -ShakeBagVisual: @ 80D4DC4 - push {r4,lr} - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000804 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080D4DF4 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldr r0, =ObjectCB_ShakeBagVisual - str r0, [r4, 0x1C] -_080D4DF4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ShakeBagVisual - - thumb_func_start ObjectCB_ShakeBagVisual -@ void ObjectCB_ShakeBagVisual(struct obj *object) -ObjectCB_ShakeBagVisual: @ 80D4E0C - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080D4E28 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnim - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_080D4E28: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_ShakeBagVisual - - thumb_func_start AddSwitchPocketRotatingBallObject -@ void AddSwitchPocketRotatingBallObject(u16 rotationDirection) -AddSwitchPocketRotatingBallObject: @ 80D4E34 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - ldr r0, =gUnknown_0203CE54 - ldr r4, [r0] - ldr r0, =0x00000805 - adds r4, r0 - ldr r0, =gUnknown_0857FBA0 - bl LoadSpriteSheet - ldr r0, =gUnknown_0857FBA8 - bl LoadSpritePalette - ldr r0, =gUnknown_0857FBB0 - movs r1, 0x10 - movs r2, 0x10 - movs r3, 0 - bl CreateSprite - strb r0, [r4] - ldr r2, =gSprites - ldrb r1, [r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r5, [r0, 0x2E] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AddSwitchPocketRotatingBallObject - - thumb_func_start update_switch_pocket_rotating_ball_coords -@ void update_switch_pocket_rotating_ball_coords(struct obj *object) -update_switch_pocket_rotating_ball_coords: @ 80D4E8C - ldrh r2, [r0, 0x30] - ldrh r1, [r0, 0x34] - adds r1, 0x1 - movs r3, 0x1 - ands r1, r3 - subs r2, r1 - adds r1, r0, 0 - adds r1, 0x28 - strb r2, [r1] - ldrh r2, [r0, 0x30] - ldrh r1, [r0, 0x34] - adds r1, 0x1 - ands r1, r3 - subs r2, r1 - adds r0, 0x29 - strb r2, [r0] - bx lr - thumb_func_end update_switch_pocket_rotating_ball_coords - - thumb_func_start ObjectCB_SwitchPocketRotatingBallInit -@ void ObjectCB_SwitchPocketRotatingBallInit(struct obj *object) -ObjectCB_SwitchPocketRotatingBallInit: @ 80D4EB0 - push {r4,lr} - adds r4, r0, 0 - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x2E - ldrsh r1, [r4, r0] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _080D4ED8 - ldr r0, =gUnknown_0857FB98 - b _080D4EDA - .pool -_080D4ED8: - ldr r0, =gUnknown_0857FB9C -_080D4EDA: - str r0, [r4, 0x10] - adds r0, r4, 0 - bl InitSpriteAffineAnim - adds r0, r4, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - strh r0, [r4, 0x30] - adds r0, r4, 0 - adds r0, 0x29 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - strh r0, [r4, 0x30] - adds r0, r4, 0 - bl update_switch_pocket_rotating_ball_coords - ldr r0, =ObjectCB_SwitchPocketRotatingBallContinue - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_SwitchPocketRotatingBallInit - - thumb_func_start ObjectCB_SwitchPocketRotatingBallContinue -@ void ObjectCB_SwitchPocketRotatingBallContinue(struct obj *object) -ObjectCB_SwitchPocketRotatingBallContinue: @ 80D4F14 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - adds r0, r4, 0 - bl update_switch_pocket_rotating_ball_coords - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0x10 - bne _080D4F32 - movs r0, 0x1 - bl RemoveBagObject -_080D4F32: - pop {r4} - pop {r0} - bx r0 - thumb_func_end ObjectCB_SwitchPocketRotatingBallContinue - - thumb_func_start AddBagItemIconObject -@ void AddBagItemIconObject(u16 itemId, u8 a2) -AddBagItemIconObject: @ 80D4F38 - push {r4-r6,lr} - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r0, =gUnknown_0203CE54 - ldr r2, =0x00000806 - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - bne _080D4F86 - adds r4, 0x66 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - adds r0, r4, 0 - adds r1, r4, 0 - adds r2, r6, 0 - bl AddItemIconSprite - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x40 - beq _080D4F86 - strb r2, [r5] - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - movs r1, 0x18 - strh r1, [r0, 0x24] - movs r1, 0x58 - strh r1, [r0, 0x26] -_080D4F86: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end AddBagItemIconObject - - thumb_func_start RemoveBagItemIconObject -@ void RemoveBagItemIconObject(u8 a1) -RemoveBagItemIconObject: @ 80D4F98 - push {lr} - lsls r0, 24 - movs r1, 0x80 - lsls r1, 18 - adds r0, r1 - lsrs r0, 24 - bl RemoveBagObject - pop {r0} - bx r0 - thumb_func_end RemoveBagItemIconObject - - thumb_func_start sub_80D4FAC -sub_80D4FAC: @ 80D4FAC - push {lr} - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000808 - adds r0, r1 - movs r1, 0x8 - bl sub_8122344 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D4FAC - - thumb_func_start sub_80D4FC8 -sub_80D4FC8: @ 80D4FC8 - push {lr} - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000808 - adds r0, r1 - movs r1, 0x8 - bl sub_81223FC - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D4FC8 - - thumb_func_start sub_80D4FEC -sub_80D4FEC: @ 80D4FEC - push {lr} - adds r3, r0, 0 - lsls r3, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000808 - adds r0, r1 - lsrs r3, 4 - movs r1, 0x80 - lsls r1, 13 - adds r3, r1 - lsrs r3, 16 - movs r1, 0x88 - movs r2, 0x78 - bl sub_8122448 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D4FEC - - thumb_func_start sub_80D5018 -sub_80D5018: @ 80D5018 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - adds r4, r1, 0 - movs r2, 0x80 - lsls r2, 4 - adds r0, r4, 0 - movs r1, 0 - bl memset - movs r0, 0x80 - lsls r0, 1 - adds r4, r0 - movs r7, 0 -_080D5036: - adds r4, 0x20 - movs r5, 0 - adds r1, r7, 0x1 - mov r8, r1 -_080D503E: - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0x20 - bl memcpy - adds r4, 0x20 - adds r6, 0x20 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _080D503E - cmp r7, 0x5 - beq _080D505C - adds r4, 0x20 -_080D505C: - mov r1, r8 - lsls r0, r1, 24 - lsrs r7, r0, 24 - cmp r7, 0x5 - bls _080D5036 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80D5018 - - thumb_func_start sub_80D5070 -sub_80D5070: @ 80D5070 - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - cmp r4, 0x2A - bne _080D5082 - bl IsEnigmaBerryValid -_080D5082: - ldr r5, =gBerryPicTable - lsls r4, 3 - adds r0, r5, 0x4 - adds r0, r4, r0 - ldr r0, [r0] - str r0, [sp] - ldr r1, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r1 - ldr r1, =0x00007544 - orrs r0, r1 - str r0, [sp, 0x4] - mov r0, sp - bl LoadCompressedObjectPalette - adds r4, r5 - ldr r0, [r4] - ldr r4, =0x0201d000 - adds r1, r4, 0 - bl LZDecompressWram - ldr r0, =0xfffff000 - adds r1, r4, r0 - adds r0, r4, 0 - bl sub_80D5018 - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D5070 - - thumb_func_start CreateBerryTagSprite -CreateBerryTagSprite: @ 80D50D4 - push {r4,r5,lr} - adds r4, r1, 0 - adds r5, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - bl sub_80D5070 - ldr r0, =gUnknown_0857FBEC - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end CreateBerryTagSprite - - thumb_func_start FreeBerryTagSpritePalette -FreeBerryTagSpritePalette: @ 80D510C - push {lr} - ldr r0, =0x00007544 - bl FreeSpritePaletteByTag - pop {r0} - bx r0 - .pool - thumb_func_end FreeBerryTagSpritePalette - - thumb_func_start sub_80D511C -sub_80D511C: @ 80D511C - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - mov r8, r3 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =0x00007544 - bl FreeSpritePaletteByTag - adds r0, r4, 0 - bl sub_80D5070 - ldr r0, =gUnknown_0857FC7C - adds r1, r5, 0 - adds r2, r6, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - adds r4, r1, 0 - mov r0, r8 - cmp r0, 0x1 - bne _080D5172 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - movs r1, 0x1 - bl StartSpriteAffineAnim -_080D5172: - adds r0, r4, 0 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80D511C - - thumb_func_start CreateBerryFlavorCircleSprite -CreateBerryFlavorCircleSprite: @ 80D518C - push {lr} - adds r1, r0, 0 - ldr r0, =gUnknown_0857FE10 - lsls r1, 16 - asrs r1, 16 - movs r2, 0x74 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end CreateBerryFlavorCircleSprite - - .align 2, 0 @ Don't pad with nop. diff --git a/data/graphics/berries/berry_pic_table.inc b/data/graphics/berries/berry_pic_table.inc deleted file mode 100644 index 12d4267a0..000000000 --- a/data/graphics/berries/berry_pic_table.inc +++ /dev/null @@ -1,45 +0,0 @@ - .align 2 -gBerryPicTable:: @ 857FC94 - .4byte gBerryPic_Cheri, gBerryPalette_Cheri - .4byte gBerryPic_Chesto, gBerryPalette_Chesto - .4byte gBerryPic_Pecha, gBerryPalette_Pecha - .4byte gBerryPic_Rawst, gBerryPalette_Rawst - .4byte gBerryPic_Aspear, gBerryPalette_Aspear - .4byte gBerryPic_Leppa, gBerryPalette_Leppa - .4byte gBerryPic_Oran, gBerryPalette_Oran - .4byte gBerryPic_Persim, gBerryPalette_Persim - .4byte gBerryPic_Lum, gBerryPalette_Lum - .4byte gBerryPic_Sitrus, gBerryPalette_Sitrus - .4byte gBerryPic_Figy, gBerryPalette_Figy - .4byte gBerryPic_Wiki, gBerryPalette_Wiki - .4byte gBerryPic_Mago, gBerryPalette_Mago - .4byte gBerryPic_Aguav, gBerryPalette_Aguav - .4byte gBerryPic_Iapapa, gBerryPalette_Iapapa - .4byte gBerryPic_Razz, gBerryPalette_Razz - .4byte gBerryPic_Bluk, gBerryPalette_Bluk - .4byte gBerryPic_Nanab, gBerryPalette_Nanab - .4byte gBerryPic_Wepear, gBerryPalette_Wepear - .4byte gBerryPic_Pinap, gBerryPalette_Pinap - .4byte gBerryPic_Pomeg, gBerryPalette_Pomeg - .4byte gBerryPic_Kelpsy, gBerryPalette_Kelpsy - .4byte gBerryPic_Qualot, gBerryPalette_Qualot - .4byte gBerryPic_Hondew, gBerryPalette_Hondew - .4byte gBerryPic_Grepa, gBerryPalette_Grepa - .4byte gBerryPic_Tamato, gBerryPalette_Tamato - .4byte gBerryPic_Cornn, gBerryPalette_Cornn - .4byte gBerryPic_Magost, gBerryPalette_Magost - .4byte gBerryPic_Rabuta, gBerryPalette_Rabuta - .4byte gBerryPic_Nomel, gBerryPalette_Nomel - .4byte gBerryPic_Spelon, gBerryPalette_Spelon - .4byte gBerryPic_Pamtre, gBerryPalette_Pamtre - .4byte gBerryPic_Watmel, gBerryPalette_Watmel - .4byte gBerryPic_Durin, gBerryPalette_Durin - .4byte gBerryPic_Belue, gBerryPalette_Belue - .4byte gBerryPic_Liechi, gBerryPalette_Liechi - .4byte gBerryPic_Ganlon, gBerryPalette_Ganlon - .4byte gBerryPic_Salac, gBerryPalette_Salac - .4byte gBerryPic_Petaya, gBerryPalette_Petaya - .4byte gBerryPic_Apicot, gBerryPalette_Apicot - .4byte gBerryPic_Lansat, gBerryPalette_Lansat - .4byte gBerryPic_Starf, gBerryPalette_Starf - .4byte gBerryPic_Enigma, gBerryPalette_Enigma diff --git a/data/item_menu_icons.s b/data/item_menu_icons.s index 36f339b09..aaf242dc2 100644 --- a/data/item_menu_icons.s +++ b/data/item_menu_icons.s @@ -4,175 +4,6 @@ .section .rodata - .align 2 -gUnknown_0857F564:: @ 857F564 - .incbin "graphics/interface/bag_spinner.gbapal" - - .align 2 -gUnknown_0857F584:: @ 857F584 - .incbin "graphics/interface/bag_spinner.4bpp" - - .align 2 -gUnknown_0857F604:: @ 857F604 - .incbin "graphics/unused/cherry.4bpp" - - .align 2 -gUnknown_0857FA84:: @ 857FA84 - .incbin "graphics/unused/cherry.gbapal" - - .align 2 -gOamData_857FAA4:: @ 857FAA4 - .2byte 0x0100, 0xc000, 0x0400, 0x0000 - - .align 2 -gSpriteAnim_857FAAC:: @ 857FAAC - .2byte 0x0000, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FAB4:: @ 857FAB4 - .2byte 0x0040, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FABC:: @ 857FABC - .2byte 0x0080, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FAC4:: @ 857FAC4 - .2byte 0x00c0, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FACC:: @ 857FACC - .2byte 0x0100, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FAD4:: @ 857FAD4 - .2byte 0x0140, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FADC:: @ 857FADC - .4byte gSpriteAnim_857FAAC - .4byte gSpriteAnim_857FAB4 - .4byte gSpriteAnim_857FAC4 - .4byte gSpriteAnim_857FACC - .4byte gSpriteAnim_857FAD4 - .4byte gSpriteAnim_857FABC - - .align 2 -gSpriteAffineAnim_857FAF4:: @ 857FAF4 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_857FB04:: @ 857FB04 - .2byte 0x0000, 0x0000, 0x02fe, 0x0000, 0x0000, 0x0000, 0x0402, 0x0000, 0x0000, 0x0000, 0x04fe, 0x0000, 0x0000, 0x0000, 0x0202, 0x0000 - .2byte 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnimTable_857FB2C:: @ 857FB2C - .4byte gSpriteAffineAnim_857FAF4 - .4byte gSpriteAffineAnim_857FB04 - - .align 2 -gUnknown_0857FB34:: @ 857FB34 - obj_tiles gBagMaleTiles, 0x3000, 0x0064 - - .align 2 -gUnknown_0857FB3C:: @ 857FB3C - obj_tiles gBagFemaleTiles, 0x3000, 0x0064 - - .align 2 -gUnknown_0857FB44:: @ 857FB44 - obj_pal gBagPalette, 0x0064 - - .align 2 -gUnknown_0857FB4C:: @ 857FB4C - spr_template 0x0064, 0x0064, gOamData_857FAA4, gSpriteAnimTable_857FADC, NULL, gSpriteAffineAnimTable_857FB2C, SpriteCallbackDummy - - .align 2 -gOamData_857FB64:: @ 857FB64 - .2byte 0x0000, 0x4800, 0x0800, 0x0000 - - .align 2 -gSpriteAnim_857FB6C:: @ 857FB6C - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FB74:: @ 857FB74 - .4byte gSpriteAnim_857FB6C - - .align 2 -gSpriteAffineAnim_857FB78:: @ 857FB78 - .2byte 0x0000, 0x0000, 0x1008, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_857FB88:: @ 857FB88 - .2byte 0x0000, 0x0000, 0x10f8, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gUnknown_0857FB98:: @ 857FB98 - .4byte gSpriteAffineAnim_857FB78 - - .align 2 -gUnknown_0857FB9C:: @ 857FB9C - .4byte gSpriteAffineAnim_857FB88 - - .align 2 -gUnknown_0857FBA0:: @ 857FBA0 - obj_tiles gUnknown_0857F584, 0x0080, 0x0065 - - .align 2 -gUnknown_0857FBA8:: @ 857FBA8 - obj_pal gUnknown_0857F564, 0x0065 - - .align 2 -gUnknown_0857FBB0:: @ 857FBB0 - spr_template 0x0065, 0x0065, gOamData_857FB64, gSpriteAnimTable_857FB74, NULL, gUnknown_0857FB98, ObjectCB_SwitchPocketRotatingBallInit - - .align 2 -gOamData_857FBC8:: @ 857FBC8 - .2byte 0x0000, 0xc000, 0x7400, 0x0000 - - .align 2 -gOamData_857FBD0:: @ 857FBD0 - .2byte 0x0300, 0xc000, 0x7000, 0x0000 - - .align 2 -gSpriteAnim_857FBD8:: @ 857FBD8 - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FBE0:: @ 857FBE0 - .4byte gSpriteAnim_857FBD8 - - .align 2 -gOamData_857FBE4:: @ 857FBE4 - .2byte 0xc000, 0x0201, 0x0800, 0x0000 - - .align 2 -gUnknown_0857FBEC:: @ 857FBEC - spr_template 0xffff, 0x7544, gOamData_857FBC8, gSpriteAnimTable_857FBE0, gOamData_857FBE4, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gSpriteAffineAnim_857FC04:: @ 857FC04 - .2byte 0xffff, 0xffff, 0x60fd, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0xfffe, 0xfffe, 0x40ff, 0x0000, 0xfff8, 0x0000, 0x1000, 0x0000 - .2byte 0x0000, 0xfff8, 0x1000, 0x0000, 0x0100, 0x0100, 0x0000, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_857FC3C:: @ 857FC3C - .2byte 0xffff, 0xffff, 0x6003, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0xfffe, 0xfffe, 0x4001, 0x0000, 0xfff8, 0x0000, 0x1000, 0x0000 - .2byte 0x0000, 0xfff8, 0x1000, 0x0000, 0x0100, 0x0100, 0x0000, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnimTable_857FC74:: @ 857FC74 - .4byte gSpriteAffineAnim_857FC04 - .4byte gSpriteAffineAnim_857FC3C - - .align 2 -gUnknown_0857FC7C:: @ 857FC7C - spr_template 0xffff, 0x7544, gOamData_857FBD0, gSpriteAnimTable_857FBE0, gOamData_857FBE4, gSpriteAffineAnimTable_857FC74, SpriteCallbackDummy - -@ 857FC94 - .include "data/graphics/berries/berry_pic_table.inc" - .align 2 gUnknown_0857FDEC:: @ 857FDEC obj_tiles gBerryCheckCircle_Gfx, 0x0800, 0x2710 diff --git a/include/graphics.h b/include/graphics.h index e0c9431ac..88d19ceb4 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2719,12 +2719,17 @@ extern const u16 gFireRedMenuElements2_Pal[16]; extern const u16 gFireRedMenuElements3_Pal[16]; extern const u8 gFireRedMenuElements_Gfx[]; -//item menu graphics +// item menu graphics extern const u8 gBagScreen_Gfx[]; extern const u16 gBagScreenFemale_Pal[]; extern const u16 gBagScreenMale_Pal[]; extern const u8 gBagMenuHMIcon_Gfx[]; +// item menu icons graphics +extern const u8 gBagMaleTiles[]; +extern const u8 gBagFemaleTiles[]; +extern const u8 gBagPalette[]; + //intro graphics extern const u8 gIntro1SparkleGfx[]; extern const u8 gIntro1FlygonGfx[]; @@ -2767,6 +2772,94 @@ extern const u16 gIntro2BrendanNoTurnPal[]; extern const u16 gIntro2FlygonPal[]; extern const u8 gIntro2FlygonGfx[]; +// berry pics +extern const u8 gBerryPic_Cheri[]; +extern const u8 gBerryPalette_Cheri[]; +extern const u8 gBerryPic_Chesto[]; +extern const u8 gBerryPalette_Chesto[]; +extern const u8 gBerryPic_Pecha[]; +extern const u8 gBerryPalette_Pecha[]; +extern const u8 gBerryPic_Rawst[]; +extern const u8 gBerryPalette_Rawst[]; +extern const u8 gBerryPic_Aspear[]; +extern const u8 gBerryPalette_Aspear[]; +extern const u8 gBerryPic_Leppa[]; +extern const u8 gBerryPalette_Leppa[]; +extern const u8 gBerryPic_Oran[]; +extern const u8 gBerryPalette_Oran[]; +extern const u8 gBerryPic_Persim[]; +extern const u8 gBerryPalette_Persim[]; +extern const u8 gBerryPic_Lum[]; +extern const u8 gBerryPalette_Lum[]; +extern const u8 gBerryPic_Sitrus[]; +extern const u8 gBerryPalette_Sitrus[]; +extern const u8 gBerryPic_Figy[]; +extern const u8 gBerryPalette_Figy[]; +extern const u8 gBerryPic_Wiki[]; +extern const u8 gBerryPalette_Wiki[]; +extern const u8 gBerryPic_Mago[]; +extern const u8 gBerryPalette_Mago[]; +extern const u8 gBerryPic_Aguav[]; +extern const u8 gBerryPalette_Aguav[]; +extern const u8 gBerryPic_Iapapa[]; +extern const u8 gBerryPalette_Iapapa[]; +extern const u8 gBerryPic_Razz[]; +extern const u8 gBerryPalette_Razz[]; +extern const u8 gBerryPic_Bluk[]; +extern const u8 gBerryPalette_Bluk[]; +extern const u8 gBerryPic_Nanab[]; +extern const u8 gBerryPalette_Nanab[]; +extern const u8 gBerryPic_Wepear[]; +extern const u8 gBerryPalette_Wepear[]; +extern const u8 gBerryPic_Pinap[]; +extern const u8 gBerryPalette_Pinap[]; +extern const u8 gBerryPic_Pomeg[]; +extern const u8 gBerryPalette_Pomeg[]; +extern const u8 gBerryPic_Kelpsy[]; +extern const u8 gBerryPalette_Kelpsy[]; +extern const u8 gBerryPic_Qualot[]; +extern const u8 gBerryPalette_Qualot[]; +extern const u8 gBerryPic_Hondew[]; +extern const u8 gBerryPalette_Hondew[]; +extern const u8 gBerryPic_Grepa[]; +extern const u8 gBerryPalette_Grepa[]; +extern const u8 gBerryPic_Tamato[]; +extern const u8 gBerryPalette_Tamato[]; +extern const u8 gBerryPic_Cornn[]; +extern const u8 gBerryPalette_Cornn[]; +extern const u8 gBerryPic_Magost[]; +extern const u8 gBerryPalette_Magost[]; +extern const u8 gBerryPic_Rabuta[]; +extern const u8 gBerryPalette_Rabuta[]; +extern const u8 gBerryPic_Nomel[]; +extern const u8 gBerryPalette_Nomel[]; +extern const u8 gBerryPic_Spelon[]; +extern const u8 gBerryPalette_Spelon[]; +extern const u8 gBerryPic_Pamtre[]; +extern const u8 gBerryPalette_Pamtre[]; +extern const u8 gBerryPic_Watmel[]; +extern const u8 gBerryPalette_Watmel[]; +extern const u8 gBerryPic_Durin[]; +extern const u8 gBerryPalette_Durin[]; +extern const u8 gBerryPic_Belue[]; +extern const u8 gBerryPalette_Belue[]; +extern const u8 gBerryPic_Liechi[]; +extern const u8 gBerryPalette_Liechi[]; +extern const u8 gBerryPic_Ganlon[]; +extern const u8 gBerryPalette_Ganlon[]; +extern const u8 gBerryPic_Salac[]; +extern const u8 gBerryPalette_Salac[]; +extern const u8 gBerryPic_Petaya[]; +extern const u8 gBerryPalette_Petaya[]; +extern const u8 gBerryPic_Apicot[]; +extern const u8 gBerryPalette_Apicot[]; +extern const u8 gBerryPic_Lansat[]; +extern const u8 gBerryPalette_Lansat[]; +extern const u8 gBerryPic_Starf[]; +extern const u8 gBerryPalette_Starf[]; +extern const u8 gBerryPic_Enigma[]; +extern const u8 gBerryPalette_Enigma[]; + //credits extern const u8 gCreditsCopyrightEnd_Gfx[]; diff --git a/include/item_menu.h b/include/item_menu.h index 5c1b26faa..9cffaa6c7 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -4,17 +4,48 @@ // Exported type declarations struct BagStruct { - void *func; - u8 unk4; + void (*bagCallback)(void); + u8 location; u8 pocket; u8 unk6[2]; - u16 unk8[5]; - u16 unk12[5]; - void *unk1C; + u16 cursorPosition[5]; + u16 scrollPosition[5]; }; extern struct BagStruct gUnknown_0203CE58; +struct UnkBagStruct +{ + void (*unk0)(void); + u8 unk4[0x800]; + u8 unk804[12]; + u8 unk810[7]; + u8 unk817; + u8 unk818; + u8 unk819; + u8 unk81A; + u8 unk81B:4; + u8 unk81B_1:2; + u8 unk81B_3:1; + u8 unk81B_2:1; + u8 filler3[2]; + u8 unk81E; + u8 unk81F; + const u8* unk820; + u8 unk824; + u8 unk825; + u8 filler[2]; + u8 unk828; + u8 unk829[5]; + u8 unk82E[6]; + s16 unk834; + u8 filler4[0xE]; + u8 unk844[32][32]; + u8 filler2[4]; +}; + +extern struct UnkBagStruct *gUnknown_0203CE54; + // Exported RAM declarations extern u16 gSpecialVar_ItemId; diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index 56e012421..0347e8f94 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -9,7 +9,7 @@ u8 CreateBerryTagSprite(u8 id, s16 x, s16 y); void FreeBerryTagSpritePalette(void); u8 CreateBerryFlavorCircleSprite(s16 x); void sub_80D4FAC(void); -void RemoveBagItemIconObject(u8); +void RemoveBagItemIconSprite(u8); void sub_80D4FEC(u8); void sub_80D4FC8(u8); diff --git a/ld_script.txt b/ld_script.txt index 7dcf21569..ceb12540c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -136,7 +136,7 @@ SECTIONS { asm/fldeff_cut.o(.text); src/mail_data.o(.text); asm/map_name_popup.o(.text); - asm/item_menu_icons.o(.text); + src/item_menu_icons.o(.text); asm/battle_anim_80D51AC.o(.text); src/item.o(.text); asm/item.o(.text); @@ -433,6 +433,7 @@ SECTIONS { src/pokemon_icon.o(.rodata); data/fldeff_cut.o(.rodata); data/map_name_popup.o(.rodata); + src/item_menu_icons.o(.rodata); data/item_menu_icons.o(.rodata); data/contest.o(.rodata); data/shop.o(.rodata); diff --git a/src/item_menu.c b/src/item_menu.c index 9090a39c5..fe756c2bb 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1,4 +1,5 @@ #include "global.h" +#include "item_menu.h" #include "battle.h" #include "battle_controllers.h" #include "battle_frontier_2.h" @@ -58,7 +59,7 @@ void load_bag_item_list_buffers(u8); void bag_menu_print_pocket_names(u8*, u8*); void bag_menu_copy_pocket_name_to_window(u32); void bag_menu_draw_pocket_indicator_square(u8, u8); -void AddBagVisualObject(u8); +void AddBagVisualSprite(u8); void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); void bag_menu_add_list_scroll_arrow_indicators_maybe(void); void bag_menu_prepare_tmhm_move_window(void); @@ -69,7 +70,7 @@ void get_name(s8*, u16); u16 ItemIdToBattleMoveId(u16); void ShakeBagVisual(void); u16 BagGetItemIdByPocketPosition(u8, u16); -void AddBagItemIconObject(u16, u8); +void AddBagItemIconSprite(u16, u8); void bag_menu_print_description_box_text(int); void bag_menu_print_cursor(u8, u8); void bag_menu_print(u8, u8, const u8*, u8, u8, u8, u8, u8, u8); @@ -87,8 +88,8 @@ void SwitchBagPocket(u8, s16, u16); bool8 sub_81AC2C0(void); void bag_menu_swap_items(u8); void SetBagVisualPocketId(u8, u8); -void RemoveBagObject(u8); -void AddSwitchPocketRotatingBallObject(s16); +void RemoveBagSprite(u8); +void AddSwitchPocketRotatingBallSprite(s16); void sub_81AC10C(u8); void sub_81AC3C0(u8); void sub_81AC498(u8); @@ -251,46 +252,6 @@ const struct WindowTemplate gUnknown_086141AC[] = { // .text -struct BagStruct { - void (*bagCallback)(void); - u8 location; - u8 pocket; - u8 unk6[2]; - u16 cursorPosition[5]; - u16 scrollPosition[5]; -}; - -struct UnkBagStruct { - MainCallback unk0; - u8 unk4[0x800]; - u8 unk804; - u8 unk805; - u8 unk806[10]; - u8 unk810[7]; - u8 unk817; - u8 unk818; - u8 unk819; - u8 unk81A; - u8 unk81B:4; - u8 unk81B_1:2; - u8 unk81B_3:1; - u8 unk81B_2:1; - u8 filler3[2]; - u8 unk81E; - u8 unk81F; - const u8* unk820; - u8 unk824; - u8 unk825; - u8 filler[2]; - u8 unk828; - u8 unk829[5]; - u8 unk82E[6]; - s16 unk834; - u8 filler4[0xE]; - u8 unk844[32][32]; - u8 filler2[4]; -}; - struct ListBuffer1 { struct ListMenuItem subBuffers[65]; }; @@ -411,7 +372,7 @@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2) gUnknown_0203CE54->unk81A = 0xFF; gUnknown_0203CE54->unk81E = -1; gUnknown_0203CE54->unk81F = -1; - memset(&gUnknown_0203CE54->unk804, 0xFF, 12); + memset(gUnknown_0203CE54->unk804, 0xFF, sizeof(gUnknown_0203CE54->unk804)); memset(gUnknown_0203CE54->unk810, 0xFF, 10); SetMainCallback2(CB2_Bag); } @@ -517,7 +478,7 @@ bool8 setup_bag_menu(void) gMain.state++; break; case 15: - AddBagVisualObject(gUnknown_0203CE58.pocket); + AddBagVisualSprite(gUnknown_0203CE58.pocket); gMain.state++; break; case 16: @@ -697,11 +658,11 @@ void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu *unused) } if (gUnknown_0203CE54->unk81A == 0xFF) { - RemoveBagItemIconObject(1 ^ gUnknown_0203CE54->unk81B_1); + RemoveBagItemIconSprite(1 ^ gUnknown_0203CE54->unk81B_1); if (a != -2) - AddBagItemIconObject(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a), gUnknown_0203CE54->unk81B_1); + AddBagItemIconSprite(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a), gUnknown_0203CE54->unk81B_1); else - AddBagItemIconObject(-1, gUnknown_0203CE54->unk81B_1); + AddBagItemIconSprite(-1, gUnknown_0203CE54->unk81B_1); gUnknown_0203CE54->unk81B_1 ^= 1; if (!gUnknown_0203CE54->unk81B_3) bag_menu_print_description_box_text(a); @@ -1085,8 +1046,8 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16); schedule_bg_copy_tilemap_to_vram(2); SetBagVisualPocketId(pocketId, 1); - RemoveBagObject(1); - AddSwitchPocketRotatingBallObject(deltaBagPocketId); + RemoveBagSprite(1); + AddSwitchPocketRotatingBallSprite(deltaBagPocketId); SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func); } #else @@ -1219,9 +1180,9 @@ _081AC09A:\n\ movs r1, 0x1\n\ bl SetBagVisualPocketId\n\ movs r0, 0x1\n\ - bl RemoveBagObject\n\ + bl RemoveBagSprite\n\ asrs r0, r5, 16\n\ - bl AddSwitchPocketRotatingBallObject\n\ + bl AddSwitchPocketRotatingBallSprite\n\ ldr r1, =sub_81AC10C\n\ ldr r2, =gTasks\n\ lsls r0, r6, 2\n\ diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c new file mode 100644 index 000000000..001731727 --- /dev/null +++ b/src/item_menu_icons.c @@ -0,0 +1,570 @@ +#include "global.h" +#include "sprite.h" +#include "decompress.h" +#include "item_menu.h" +#include "item_icon.h" +#include "item_menu_icons.h" +#include "window.h" +#include "menu_helpers.h" +#include "berry.h" +#include "graphics.h" +#include "constants/items.h" + +struct CompressedTilesPal +{ + const u8 *tiles; + const u8 *pal; +}; + +// this file's functions +void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); +void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); +void SpriteCB_ShakeBagVisual(struct Sprite *sprite); +void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); +void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); + +// const rom data +const u16 gUnknown_0857F564[] = INCBIN_U16("graphics/interface/bag_spinner.gbapal"); +const u8 gUnknown_0857F584[] = INCBIN_U8("graphics/interface/bag_spinner.4bpp"); +const u8 gUnknown_0857F604[] = INCBIN_U8("graphics/unused/cherry.4bpp"); +const u16 gUnknown_0857FA84[] = INCBIN_U16("graphics/unused/cherry.gbapal"); + +static const struct OamData sOamData_857FAA4 = +{ + .y = 0, + .affineMode = 1, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FAAC[] = +{ + ANIMCMD_FRAME(0, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FAB4[] = +{ + ANIMCMD_FRAME(64, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FABC[] = +{ + ANIMCMD_FRAME(128, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FAC4[] = +{ + ANIMCMD_FRAME(192, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FACC[] = +{ + ANIMCMD_FRAME(256, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FAD4[] = +{ + ANIMCMD_FRAME(320, 4), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FADC[] = +{ + sSpriteAnim_857FAAC, + sSpriteAnim_857FAB4, + sSpriteAnim_857FAC4, + sSpriteAnim_857FACC, + sSpriteAnim_857FAD4, + sSpriteAnim_857FABC +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FAF4[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FB04[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 254, 2), + AFFINEANIMCMD_FRAME(0, 0, 2, 4), + AFFINEANIMCMD_FRAME(0, 0, 254, 4), + AFFINEANIMCMD_FRAME(0, 0, 2, 2), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB2C[] = +{ + sSpriteAffineAnim_857FAF4, + sSpriteAffineAnim_857FB04 +}; + +const struct CompressedSpriteSheet gUnknown_0857FB34 = +{ + gBagMaleTiles, 0x3000, 100 +}; + +const struct CompressedSpriteSheet gUnknown_0857FB3C = +{ + gBagFemaleTiles, 0x3000, 100 +}; + +const struct CompressedSpritePalette gUnknown_0857FB44 = +{ + gBagPalette, 100 +}; + +const struct SpriteTemplate gUnknown_0857FB4C = +{ + .tileTag = 100, + .paletteTag = 100, + .oam = &sOamData_857FAA4, + .anims = sSpriteAnimTable_857FADC, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_857FB2C, + .callback = SpriteCallbackDummy, +}; + +static const struct OamData sOamData_857FB64 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 4, + .size = 1, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FB6C[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FB74[] = +{ + sSpriteAnim_857FB6C +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FB78[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 8, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FB88[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 248, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB98[] = +{ + sSpriteAffineAnim_857FB78, +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB9C[] = +{ + sSpriteAffineAnim_857FB88, +}; + +const struct SpriteSheet gUnknown_0857FBA0 = +{ + gUnknown_0857F584, 0x80, 101 +}; + +const struct SpritePalette gUnknown_0857FBA8 = +{ + gUnknown_0857F564, 101 +}; + +const struct SpriteTemplate gUnknown_0857FBB0 = +{ + .tileTag = 101, + .paletteTag = 101, + .oam = &sOamData_857FB64, + .anims = sSpriteAnimTable_857FB74, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_857FB98, + .callback = SpriteCB_SwitchPocketRotatingBallInit, +}; + +static const struct OamData sOamData_857FBC8 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 7, + .affineParam = 0 +}; + +static const struct OamData sOamData_857FBD0 = +{ + .y = 0, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 7, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FBD8[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FBE0[] = +{ + sSpriteAnim_857FBD8 +}; + +static const struct SpriteFrameImage sSpriteImageTable_857FBE4[] = +{ + {&gDecompressionBuffer[0], 0x800}, +}; + +const struct SpriteTemplate gUnknown_0857FBEC = +{ + .tileTag = 65535, + .paletteTag = 30020, + .oam = &sOamData_857FBC8, + .anims = sSpriteAnimTable_857FBE0, + .images = sSpriteImageTable_857FBE4, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FC04[] = +{ + AFFINEANIMCMD_FRAME(-1, -1, 253, 96), + AFFINEANIMCMD_FRAME(0, 0, 0, 16), + AFFINEANIMCMD_FRAME(-2, -2, 255, 64), + AFFINEANIMCMD_FRAME(-8, 0, 0, 16), + AFFINEANIMCMD_FRAME(0, -8, 0, 16), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_JUMP(0) +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FC3C[] = +{ + AFFINEANIMCMD_FRAME(-1, -1, 3, 96), + AFFINEANIMCMD_FRAME(0, 0, 0, 16), + AFFINEANIMCMD_FRAME(-2, -2, 1, 64), + AFFINEANIMCMD_FRAME(-8, 0, 0, 16), + AFFINEANIMCMD_FRAME(0, -8, 0, 16), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_JUMP(0) +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FC74[] = +{ + sSpriteAffineAnim_857FC04, + sSpriteAffineAnim_857FC3C +}; + +const struct SpriteTemplate gUnknown_0857FC7C = +{ + .tileTag = 0xFFFF, + .paletteTag = 0x7544, + .oam = &sOamData_857FBD0, + .anims = sSpriteAnimTable_857FBE0, + .images = sSpriteImageTable_857FBE4, + .affineAnims = sSpriteAffineAnimTable_857FC74, + .callback = SpriteCallbackDummy, +}; + +static const struct CompressedTilesPal gBerryPicTable[] = +{ + {gBerryPic_Cheri, gBerryPalette_Cheri}, + {gBerryPic_Chesto, gBerryPalette_Chesto}, + {gBerryPic_Pecha, gBerryPalette_Pecha}, + {gBerryPic_Rawst, gBerryPalette_Rawst}, + {gBerryPic_Aspear, gBerryPalette_Aspear}, + {gBerryPic_Leppa, gBerryPalette_Leppa}, + {gBerryPic_Oran, gBerryPalette_Oran}, + {gBerryPic_Persim, gBerryPalette_Persim}, + {gBerryPic_Lum, gBerryPalette_Lum}, + {gBerryPic_Sitrus, gBerryPalette_Sitrus}, + {gBerryPic_Figy, gBerryPalette_Figy}, + {gBerryPic_Wiki, gBerryPalette_Wiki}, + {gBerryPic_Mago, gBerryPalette_Mago}, + {gBerryPic_Aguav, gBerryPalette_Aguav}, + {gBerryPic_Iapapa, gBerryPalette_Iapapa}, + {gBerryPic_Razz, gBerryPalette_Razz}, + {gBerryPic_Bluk, gBerryPalette_Bluk}, + {gBerryPic_Nanab, gBerryPalette_Nanab}, + {gBerryPic_Wepear, gBerryPalette_Wepear}, + {gBerryPic_Pinap, gBerryPalette_Pinap}, + {gBerryPic_Pomeg, gBerryPalette_Pomeg}, + {gBerryPic_Kelpsy, gBerryPalette_Kelpsy}, + {gBerryPic_Qualot, gBerryPalette_Qualot}, + {gBerryPic_Hondew, gBerryPalette_Hondew}, + {gBerryPic_Grepa, gBerryPalette_Grepa}, + {gBerryPic_Tamato, gBerryPalette_Tamato}, + {gBerryPic_Cornn, gBerryPalette_Cornn}, + {gBerryPic_Magost, gBerryPalette_Magost}, + {gBerryPic_Rabuta, gBerryPalette_Rabuta}, + {gBerryPic_Nomel, gBerryPalette_Nomel}, + {gBerryPic_Spelon, gBerryPalette_Spelon}, + {gBerryPic_Pamtre, gBerryPalette_Pamtre}, + {gBerryPic_Watmel, gBerryPalette_Watmel}, + {gBerryPic_Durin, gBerryPalette_Durin}, + {gBerryPic_Belue, gBerryPalette_Belue}, + {gBerryPic_Liechi, gBerryPalette_Liechi}, + {gBerryPic_Ganlon, gBerryPalette_Ganlon}, + {gBerryPic_Salac, gBerryPalette_Salac}, + {gBerryPic_Petaya, gBerryPalette_Petaya}, + {gBerryPic_Apicot, gBerryPalette_Apicot}, + {gBerryPic_Lansat, gBerryPalette_Lansat}, + {gBerryPic_Starf, gBerryPalette_Starf}, + {gBerryPic_Enigma, gBerryPalette_Enigma}, +}; + +extern const struct SpriteTemplate gUnknown_0857FBEC; +extern const struct SpriteTemplate gUnknown_0857FE10; + +// code +void RemoveBagSprite(u8 id) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[id]; + if (*spriteId != 0xFF) + { + FreeSpriteTilesByTag(id + 100); + FreeSpritePaletteByTag(id + 100); + FreeSpriteOamMatrix(&gSprites[*spriteId]); + DestroySprite(&gSprites[*spriteId]); + *spriteId = 0xFF; + } +} + +void AddBagVisualSprite(u8 bagPocketId) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[0]; + *spriteId = CreateSprite(&gUnknown_0857FB4C, 68, 66, 0); + SetBagVisualPocketId(bagPocketId, FALSE); +} + +void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets) +{ + struct Sprite *sprite = &gSprites[gUnknown_0203CE54->unk804[0]]; + if (isSwitchingPockets) + { + sprite->pos2.y = -5; + sprite->callback = SpriteCB_BagVisualSwitchingPockets; + sprite->data[0] = bagPocketId + 1; + StartSpriteAnim(sprite, 0); + } + else + { + StartSpriteAnim(sprite, bagPocketId + 1); + } +} + +void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) +{ + if (sprite->pos2.y != 0) + { + sprite->pos2.y++; + } + else + { + StartSpriteAnim(sprite, sprite->data[0]); + sprite->callback = SpriteCallbackDummy; + } +} + +void ShakeBagVisual(void) +{ + struct Sprite *sprite = &gSprites[gUnknown_0203CE54->unk804[0]]; + if (sprite->affineAnimEnded) + { + StartSpriteAffineAnim(sprite, 1); + sprite->callback = SpriteCB_ShakeBagVisual; + } +} + +void SpriteCB_ShakeBagVisual(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + StartSpriteAffineAnim(sprite, 0); + sprite->callback = SpriteCallbackDummy; + } +} + +void AddSwitchPocketRotatingBallSprite(u16 rotationDirection) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[1]; + LoadSpriteSheet(&gUnknown_0857FBA0); + LoadSpritePalette(&gUnknown_0857FBA8); + *spriteId = CreateSprite(&gUnknown_0857FBB0, 16, 16, 0); + gSprites[*spriteId].data[0] = rotationDirection; +} + +void update_switch_pocket_rotating_ball_coords(struct Sprite *sprite) +{ + sprite->centerToCornerVecX = sprite->data[1] - ((sprite->data[3] + 1) & 1); + sprite->centerToCornerVecY = sprite->data[1] - ((sprite->data[3] + 1) & 1); +} + +void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) +{ + sprite->oam.affineMode = 1; + if (sprite->data[0] == -1) + sprite->affineAnims = sSpriteAffineAnimTable_857FB98; + else + sprite->affineAnims = sSpriteAffineAnimTable_857FB9C; + + InitSpriteAffineAnim(sprite); + sprite->data[1] = sprite->centerToCornerVecX; + sprite->data[1] = sprite->centerToCornerVecY; + update_switch_pocket_rotating_ball_coords(sprite); + sprite->callback = SpriteCB_SwitchPocketRotatingBallContinue; +} + +void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite) +{ + sprite->data[3]++; + update_switch_pocket_rotating_ball_coords(sprite); + if (sprite->data[3] == 16) + RemoveBagSprite(1); +} + +void AddBagItemIconSprite(u16 itemId, u8 id) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[id + 2]; + if (*spriteId == 0xFF) + { + u8 iconSpriteId; + + FreeSpriteTilesByTag(id + 102); + FreeSpritePaletteByTag(id + 102); + iconSpriteId = AddItemIconSprite(id + 102, id + 102, itemId); + if (iconSpriteId != MAX_SPRITES) + { + *spriteId = iconSpriteId; + gSprites[iconSpriteId].pos2.x = 24; + gSprites[iconSpriteId].pos2.y = 88; + } + } +} + +void RemoveBagItemIconSprite(u8 id) +{ + RemoveBagSprite(id + 2); +} + +void sub_80D4FAC(void) +{ + sub_8122344(&gUnknown_0203CE54->unk804[4], 8); +} + +void sub_80D4FC8(u8 arg0) +{ + sub_81223FC(&gUnknown_0203CE54->unk804[4], 8, arg0); +} + +void sub_80D4FEC(u8 arg0) +{ + sub_8122448(&gUnknown_0203CE54->unk804[4], 136, 120, (arg0 + 1) * 16); +} + +void sub_80D5018(void *mem0, void *mem1) +{ + u8 i, j; + + memset(mem1, 0, 0x800); + mem1 += 0x100; + for (i = 0; i < 6; i++) + { + mem1 += 0x20; + for (j = 0; j < 6; j++) + { + memcpy(mem1, mem0, 0x20); + mem1 += 0x20; + mem0 += 0x20; + } + if (i != 5) + mem1 += 0x20; + } +} + +void sub_80D5070(u8 berryId) +{ + struct CompressedSpritePalette pal; + + if (berryId == ITEM_TO_BERRY(ITEM_ENIGMA_BERRY) - 1) + IsEnigmaBerryValid(); // what's the point of calling it if the return value is ignored? + + pal.data = gBerryPicTable[berryId].pal; + pal.tag = 0x7544; + LoadCompressedObjectPalette(&pal); + LZDecompressWram(gBerryPicTable[berryId].tiles, &gDecompressionBuffer[0x1000]); + sub_80D5018(&gDecompressionBuffer[0x1000], &gDecompressionBuffer[0]); +} + +u8 CreateBerryTagSprite(u8 id, s16 x, s16 y) +{ + sub_80D5070(id); + return CreateSprite(&gUnknown_0857FBEC, x, y, 0); +} + +void FreeBerryTagSpritePalette(void) +{ + FreeSpritePaletteByTag(0x7544); +} + +u8 sub_80D511C(u8 berryId, u8 x, u8 y, bool8 startAffine) +{ + u8 spriteId; + + FreeSpritePaletteByTag(0x7544); + sub_80D5070(berryId); + spriteId = CreateSprite(&gUnknown_0857FC7C, x, y, 0); + if (startAffine == TRUE) + StartSpriteAffineAnim(&gSprites[spriteId], 1); + + return spriteId; +} + +u8 CreateBerryFlavorCircleSprite(s16 x) +{ + return CreateSprite(&gUnknown_0857FE10, x, 116, 0); +} From 62e849a5df791e92f0648827081f2c6247f09c5f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 4 Mar 2018 20:03:11 +0100 Subject: [PATCH 06/11] item menu is done --- data/item_menu_icons.s | 44 ---------- include/graphics.h | 1 + include/item_menu_icons.h | 19 +++-- src/item_menu.c | 166 +------------------------------------- src/item_menu_icons.c | 160 +++++++++++++++++++++++++++++------- 5 files changed, 151 insertions(+), 239 deletions(-) diff --git a/data/item_menu_icons.s b/data/item_menu_icons.s index aaf242dc2..30cb7e66b 100644 --- a/data/item_menu_icons.s +++ b/data/item_menu_icons.s @@ -4,50 +4,6 @@ .section .rodata - .align 2 -gUnknown_0857FDEC:: @ 857FDEC - obj_tiles gBerryCheckCircle_Gfx, 0x0800, 0x2710 - - .align 2 -gUnknown_0857FDF4:: @ 857FDF4 - obj_pal gUnknown_08D9BEF0, 0x2710 - - .align 2 -gOamData_857FDFC:: @ 857FDFC - .2byte 0x0000, 0xc000, 0x0400, 0x0000 - - .align 2 -gSpriteAnim_857FE04:: @ 857FE04 - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FE0C:: @ 857FE0C - .4byte gSpriteAnim_857FE04 - - .align 2 -gUnknown_0857FE10:: @ 857FE10 - spr_template 0x2710, 0x2710, gOamData_857FDFC, gSpriteAnimTable_857FE0C, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_0857FE28:: @ 857FE28 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5860 - - .align 2 -gUnknown_0857FE40:: @ 857FE40 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D58F8 - - .align 2 -gUnknown_0857FE58:: @ 857FE58 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5968 - - .align 2 -gUnknown_0857FE70:: @ 857FE70 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5A94 - - .align 2 -gUnknown_0857FE88:: @ 857FE88 - spr_template 0x0000, 0x0000, gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80D5B48 - @ 857FEA0 .include "data/text/item_descriptions.inc" diff --git a/include/graphics.h b/include/graphics.h index 88d19ceb4..9afcb75ad 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2729,6 +2729,7 @@ extern const u8 gBagMenuHMIcon_Gfx[]; extern const u8 gBagMaleTiles[]; extern const u8 gBagFemaleTiles[]; extern const u8 gBagPalette[]; +extern const u8 gBerryCheckCircle_Gfx[]; //intro graphics extern const u8 gIntro1SparkleGfx[]; diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index 0347e8f94..aee7599df 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -1,16 +1,25 @@ #ifndef GUARD_ITEM_MENU_ICONS #define GUARD_ITEM_MENU_ICONS +extern const struct CompressedSpriteSheet gUnknown_0857FB34; +extern const struct CompressedSpriteSheet gUnknown_0857FB3C; +extern const struct CompressedSpritePalette gUnknown_0857FB44; extern const struct CompressedSpriteSheet gUnknown_0857FDEC; extern const struct CompressedSpritePalette gUnknown_0857FDF4; -u8 sub_80D511C(u8 a0, u8 a1, u8 a2, u8 a3); +void RemoveBagSprite(u8 id); +void AddBagVisualSprite(u8 bagPocketId); +void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); +void ShakeBagVisual(void); +void AddSwitchPocketRotatingBallSprite(s16 rotationDirection); +void AddBagItemIconSprite(u16 itemId, u8 id); +void RemoveBagItemIconSprite(u8 id); +void sub_80D4FAC(void); +void sub_80D4FC8(u8 arg0); +void sub_80D4FEC(u8 arg0); u8 CreateBerryTagSprite(u8 id, s16 x, s16 y); void FreeBerryTagSpritePalette(void); +u8 sub_80D511C(u8 berryId, u8 x, u8 y, bool8 startAffine); u8 CreateBerryFlavorCircleSprite(s16 x); -void sub_80D4FAC(void); -void RemoveBagItemIconSprite(u8); -void sub_80D4FEC(u8); -void sub_80D4FC8(u8); #endif // GUARD_ITEM_MENU_ICONS diff --git a/src/item_menu.c b/src/item_menu.c index fe756c2bb..270e79a47 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -59,7 +59,6 @@ void load_bag_item_list_buffers(u8); void bag_menu_print_pocket_names(u8*, u8*); void bag_menu_copy_pocket_name_to_window(u32); void bag_menu_draw_pocket_indicator_square(u8, u8); -void AddBagVisualSprite(u8); void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); void bag_menu_add_list_scroll_arrow_indicators_maybe(void); void bag_menu_prepare_tmhm_move_window(void); @@ -68,7 +67,6 @@ void Task_WallyTutorialBagMenu(u8); void Task_BagMenu(u8); void get_name(s8*, u16); u16 ItemIdToBattleMoveId(u16); -void ShakeBagVisual(void); u16 BagGetItemIdByPocketPosition(u8, u16); void AddBagItemIconSprite(u16, u8); void bag_menu_print_description_box_text(int); @@ -87,9 +85,6 @@ u8 GetSwitchBagPocketDirection(void); void SwitchBagPocket(u8, s16, u16); bool8 sub_81AC2C0(void); void bag_menu_swap_items(u8); -void SetBagVisualPocketId(u8, u8); -void RemoveBagSprite(u8); -void AddSwitchPocketRotatingBallSprite(s16); void sub_81AC10C(u8); void sub_81AC3C0(u8); void sub_81AC498(u8); @@ -280,14 +275,11 @@ void (*gFieldCallback)(void); extern u8 *gPocketNamesStringsTable[]; extern u8 gUnknown_08D9A88C[]; -extern struct CompressedSpriteSheet gUnknown_0857FB34; -extern struct CompressedSpriteSheet gUnknown_0857FB3C; -extern struct CompressedSpritePalette gUnknown_0857FB44; extern struct ListMenuTemplate gUnknown_08613F9C; -extern u8 gMoveNames[][0xD]; +extern const u8 gMoveNames[][0xD]; extern u8* gReturnToXStringsTable[]; extern u32 gUnknown_0203CE5E[]; -extern u8 EventScript_2736B3[]; +extern const u8 EventScript_2736B3[]; extern const u16 gUnknown_0860F074[]; void ResetBagScrollPositions(void) @@ -1010,13 +1002,11 @@ void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) *bagPocketId += deltaBagPocketId; } -#ifdef NONMATCHING void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) { s16* data = gTasks[taskId].data; u8 pocketId; - data[13] = 0; data[12] = 0; data[11] = deltaBagPocketId; @@ -1026,7 +1016,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) ClearWindowTilemap(1); sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); schedule_bg_copy_tilemap_to_vram(0); - gSprites[gUnknown_0203CE54->unk806[gUnknown_0203CE54->unk81B_1 ^ 1]].invisible = 1; + gSprites[gUnknown_0203CE54->unk804[2 + (gUnknown_0203CE54->unk81B_1 ^ 1)]].invisible = 1; sub_81AB824(); } pocketId = gUnknown_0203CE58.pocket; @@ -1050,156 +1040,6 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) AddSwitchPocketRotatingBallSprite(deltaBagPocketId); SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func); } -#else -__attribute__((naked)) -void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) -{ - asm(".syntax unified\n\ - push {r4-r6,lr}\n\ - sub sp, 0xC\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - lsls r1, 16\n\ - lsrs r5, r1, 16\n\ - lsls r2, 16\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r0, 3\n\ - ldr r1, =gTasks + 0x8\n\ - adds r4, r0, r1\n\ - movs r0, 0\n\ - strh r0, [r4, 0x1A]\n\ - strh r0, [r4, 0x18]\n\ - strh r5, [r4, 0x16]\n\ - cmp r2, 0\n\ - bne _081AC026\n\ - movs r0, 0\n\ - bl ClearWindowTilemap\n\ - movs r0, 0x1\n\ - bl ClearWindowTilemap\n\ - ldrb r0, [r4]\n\ - ldr r3, =gUnknown_0203CE58\n\ - ldrb r2, [r3, 0x5]\n\ - lsls r2, 1\n\ - adds r1, r3, 0\n\ - adds r1, 0x12\n\ - adds r1, r2, r1\n\ - adds r3, 0x8\n\ - adds r2, r3\n\ - bl sub_81AE6C8\n\ - movs r0, 0\n\ - bl schedule_bg_copy_tilemap_to_vram\n\ - ldr r3, =gSprites\n\ - ldr r0, =gUnknown_0203CE54\n\ - ldr r2, [r0]\n\ - ldr r1, =0x0000081b\n\ - adds r0, r2, r1\n\ - ldrb r1, [r0]\n\ - lsls r1, 26\n\ - lsrs r1, 30\n\ - movs r0, 0x1\n\ - eors r0, r1\n\ - adds r2, r0\n\ - ldr r0, =0x00000806\n\ - adds r2, r0\n\ - ldrb r1, [r2]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r0, r3\n\ - adds r0, 0x3E\n\ - ldrb r1, [r0]\n\ - movs r2, 0x4\n\ - orrs r1, r2\n\ - strb r1, [r0]\n\ - bl sub_81AB824\n\ -_081AC026:\n\ - ldr r4, =gUnknown_0203CE58\n\ - ldrb r1, [r4, 0x5]\n\ - add r0, sp, 0x8\n\ - strb r1, [r0]\n\ - lsls r1, r5, 24\n\ - asrs r1, 24\n\ - bl ChangeBagPocketId\n\ - lsls r0, r5, 16\n\ - asrs r1, r0, 16\n\ - adds r5, r0, 0\n\ - cmp r1, 0x1\n\ - bne _081AC07C\n\ - ldr r2, =gPocketNamesStringsTable\n\ - ldrb r0, [r4, 0x5]\n\ - lsls r0, 2\n\ - adds r0, r2\n\ - ldr r0, [r0]\n\ - add r1, sp, 0x8\n\ - ldrb r1, [r1]\n\ - lsls r1, 2\n\ - adds r1, r2\n\ - ldr r1, [r1]\n\ - bl bag_menu_print_pocket_names\n\ - movs r0, 0\n\ - bl bag_menu_copy_pocket_name_to_window\n\ - b _081AC09A\n\ - .pool\n\ -_081AC07C:\n\ - ldr r2, =gPocketNamesStringsTable\n\ - add r0, sp, 0x8\n\ - ldrb r0, [r0]\n\ - lsls r0, 2\n\ - adds r0, r2\n\ - ldr r0, [r0]\n\ - ldrb r1, [r4, 0x5]\n\ - lsls r1, 2\n\ - adds r1, r2\n\ - ldr r1, [r1]\n\ - bl bag_menu_print_pocket_names\n\ - movs r0, 0x8\n\ - bl bag_menu_copy_pocket_name_to_window\n\ -_081AC09A:\n\ - ldr r0, =gUnknown_0203CE58\n\ - ldrb r0, [r0, 0x5]\n\ - movs r1, 0\n\ - bl bag_menu_draw_pocket_indicator_square\n\ - add r0, sp, 0x8\n\ - ldrb r0, [r0]\n\ - movs r1, 0x1\n\ - bl bag_menu_draw_pocket_indicator_square\n\ - movs r0, 0xF\n\ - str r0, [sp]\n\ - movs r0, 0x10\n\ - str r0, [sp, 0x4]\n\ - movs r0, 0x2\n\ - movs r1, 0xB\n\ - movs r2, 0xE\n\ - movs r3, 0x2\n\ - bl FillBgTilemapBufferRect_Palette0\n\ - movs r0, 0x2\n\ - bl schedule_bg_copy_tilemap_to_vram\n\ - add r0, sp, 0x8\n\ - ldrb r0, [r0]\n\ - movs r1, 0x1\n\ - bl SetBagVisualPocketId\n\ - movs r0, 0x1\n\ - bl RemoveBagSprite\n\ - asrs r0, r5, 16\n\ - bl AddSwitchPocketRotatingBallSprite\n\ - ldr r1, =sub_81AC10C\n\ - ldr r2, =gTasks\n\ - lsls r0, r6, 2\n\ - adds r0, r6\n\ - lsls r0, 3\n\ - adds r0, r2\n\ - ldr r2, [r0]\n\ - adds r0, r6, 0\n\ - bl SetTaskFuncWithFollowupFunc\n\ - add sp, 0xC\n\ - pop {r4-r6}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_81AC10C(u8 taskId) { diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index 001731727..843c9eec3 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -16,18 +16,23 @@ struct CompressedTilesPal const u8 *pal; }; -// this file's functions -void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); -void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); -void SpriteCB_ShakeBagVisual(struct Sprite *sprite); -void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); -void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); +extern void sub_80D5860(struct Sprite *sprite); +extern void sub_80D58F8(struct Sprite *sprite); +extern void sub_80D5968(struct Sprite *sprite); +extern void sub_80D5A94(struct Sprite *sprite); +extern void sub_80D5B48(struct Sprite *sprite); -// const rom data -const u16 gUnknown_0857F564[] = INCBIN_U16("graphics/interface/bag_spinner.gbapal"); -const u8 gUnknown_0857F584[] = INCBIN_U8("graphics/interface/bag_spinner.4bpp"); -const u8 gUnknown_0857F604[] = INCBIN_U8("graphics/unused/cherry.4bpp"); -const u16 gUnknown_0857FA84[] = INCBIN_U16("graphics/unused/cherry.gbapal"); +// this file's functions +static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); +static void SpriteCB_ShakeBagVisual(struct Sprite *sprite); +static void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); +static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); + +// static const rom data +static const u16 gUnknown_0857F564[] = INCBIN_U16("graphics/interface/bag_spinner.gbapal"); +static const u8 gUnknown_0857F584[] = INCBIN_U8("graphics/interface/bag_spinner.4bpp"); +static const u8 gUnknown_0857F604[] = INCBIN_U8("graphics/unused/cherry.4bpp"); +static const u16 gUnknown_0857FA84[] = INCBIN_U16("graphics/unused/cherry.gbapal"); static const struct OamData sOamData_857FAA4 = { @@ -128,7 +133,7 @@ const struct CompressedSpritePalette gUnknown_0857FB44 = gBagPalette, 100 }; -const struct SpriteTemplate gUnknown_0857FB4C = +static const struct SpriteTemplate gUnknown_0857FB4C = { .tileTag = 100, .paletteTag = 100, @@ -189,17 +194,17 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB9C[] = sSpriteAffineAnim_857FB88, }; -const struct SpriteSheet gUnknown_0857FBA0 = +static const struct SpriteSheet gUnknown_0857FBA0 = { gUnknown_0857F584, 0x80, 101 }; -const struct SpritePalette gUnknown_0857FBA8 = +static const struct SpritePalette gUnknown_0857FBA8 = { gUnknown_0857F564, 101 }; -const struct SpriteTemplate gUnknown_0857FBB0 = +static const struct SpriteTemplate gUnknown_0857FBB0 = { .tileTag = 101, .paletteTag = 101, @@ -260,7 +265,7 @@ static const struct SpriteFrameImage sSpriteImageTable_857FBE4[] = {&gDecompressionBuffer[0], 0x800}, }; -const struct SpriteTemplate gUnknown_0857FBEC = +static const struct SpriteTemplate gUnknown_0857FBEC = { .tileTag = 65535, .paletteTag = 30020, @@ -299,7 +304,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FC74[] = sSpriteAffineAnim_857FC3C }; -const struct SpriteTemplate gUnknown_0857FC7C = +static const struct SpriteTemplate gUnknown_0857FC7C = { .tileTag = 0xFFFF, .paletteTag = 0x7544, @@ -357,8 +362,109 @@ static const struct CompressedTilesPal gBerryPicTable[] = {gBerryPic_Enigma, gBerryPalette_Enigma}, }; -extern const struct SpriteTemplate gUnknown_0857FBEC; -extern const struct SpriteTemplate gUnknown_0857FE10; +const struct CompressedSpriteSheet gUnknown_0857FDEC = +{ + gBerryCheckCircle_Gfx, 0x800, 10000 +}; + +const struct CompressedSpritePalette gUnknown_0857FDF4 = +{ + gUnknown_08D9BEF0, 10000 +}; + +static const struct OamData sOamData_857FDFC = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FE04[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FE0C[] = +{ + sSpriteAnim_857FE04 +}; + +static const struct SpriteTemplate gUnknown_0857FE10 = +{ + .tileTag = 10000, + .paletteTag = 10000, + .oam = &sOamData_857FDFC, + .anims = sSpriteAnimTable_857FE0C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +const struct SpriteTemplate gUnknown_0857FE28 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5860, +}; + +const struct SpriteTemplate gUnknown_0857FE40 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D58F8, +}; + +const struct SpriteTemplate gUnknown_0857FE58 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5968, +}; + +const struct SpriteTemplate gUnknown_0857FE70 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5A94, +}; + +const struct SpriteTemplate gUnknown_0857FE88 = +{ + .tileTag = 0, + .paletteTag = 0, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80D5B48, +}; // code void RemoveBagSprite(u8 id) @@ -397,7 +503,7 @@ void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets) } } -void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) +static void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) { if (sprite->pos2.y != 0) { @@ -420,7 +526,7 @@ void ShakeBagVisual(void) } } -void SpriteCB_ShakeBagVisual(struct Sprite *sprite) +static void SpriteCB_ShakeBagVisual(struct Sprite *sprite) { if (sprite->affineAnimEnded) { @@ -429,7 +535,7 @@ void SpriteCB_ShakeBagVisual(struct Sprite *sprite) } } -void AddSwitchPocketRotatingBallSprite(u16 rotationDirection) +void AddSwitchPocketRotatingBallSprite(s16 rotationDirection) { u8 *spriteId = &gUnknown_0203CE54->unk804[1]; LoadSpriteSheet(&gUnknown_0857FBA0); @@ -438,13 +544,13 @@ void AddSwitchPocketRotatingBallSprite(u16 rotationDirection) gSprites[*spriteId].data[0] = rotationDirection; } -void update_switch_pocket_rotating_ball_coords(struct Sprite *sprite) +static void update_switch_pocket_rotating_ball_coords(struct Sprite *sprite) { sprite->centerToCornerVecX = sprite->data[1] - ((sprite->data[3] + 1) & 1); sprite->centerToCornerVecY = sprite->data[1] - ((sprite->data[3] + 1) & 1); } -void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) +static void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) { sprite->oam.affineMode = 1; if (sprite->data[0] == -1) @@ -459,7 +565,7 @@ void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) sprite->callback = SpriteCB_SwitchPocketRotatingBallContinue; } -void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite) +static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite) { sprite->data[3]++; update_switch_pocket_rotating_ball_coords(sprite); @@ -506,7 +612,7 @@ void sub_80D4FEC(u8 arg0) sub_8122448(&gUnknown_0203CE54->unk804[4], 136, 120, (arg0 + 1) * 16); } -void sub_80D5018(void *mem0, void *mem1) +static void sub_80D5018(void *mem0, void *mem1) { u8 i, j; @@ -526,7 +632,7 @@ void sub_80D5018(void *mem0, void *mem1) } } -void sub_80D5070(u8 berryId) +static void sub_80D5070(u8 berryId) { struct CompressedSpritePalette pal; From 1771e8b458c76a52f6d475bcc3f10124382c3ca9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 4 Mar 2018 20:12:45 +0100 Subject: [PATCH 07/11] make it compile --- src/berry_tag_screen.c | 6 +++--- src/item_menu.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index f86f350bf..1a0d1bce0 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -515,7 +515,7 @@ static void Task_HandleInput(u8 taskId) static void TryChangeDisplayedBerry(u8 taskId, s8 toMove) { s16 *data = gTasks[taskId].data; - s16 currPocketPosition = gUnknown_0203CE58.unk12[3] + gUnknown_0203CE58.unk8[3]; + s16 currPocketPosition = gUnknown_0203CE58.scrollPosition[3] + gUnknown_0203CE58.cursorPosition[3]; u32 newPocketPosition = currPocketPosition + toMove; if (newPocketPosition < 46 && BagGetItemIdByPocketPosition(BAG_BERRIES, newPocketPosition) != 0) { @@ -533,8 +533,8 @@ static void TryChangeDisplayedBerry(u8 taskId, s8 toMove) static void HandleBagCursorPositionChange(s8 toMove) { - u16 *scrollPos = &gUnknown_0203CE58.unk12[3]; - u16 *cursorPos = &gUnknown_0203CE58.unk8[3]; + u16 *scrollPos = &gUnknown_0203CE58.scrollPosition[3]; + u16 *cursorPos = &gUnknown_0203CE58.cursorPosition[3]; if (toMove > 0) { if (*cursorPos < 4 || BagGetItemIdByPocketPosition(BAG_BERRIES, *scrollPos + 8) == 0) diff --git a/src/item_menu.c b/src/item_menu.c index 270e79a47..d9acf0430 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -991,7 +991,6 @@ u8 GetSwitchBagPocketDirection(void) return 0; } - void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) { if (deltaBagPocketId == 1 && *bagPocketId == 4) From 18d8c9382a542e8672488bb6c9d1dcb1582ed792 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 6 Mar 2018 13:29:10 +0100 Subject: [PATCH 08/11] Use EGG_HATCH_LEVEL define --- src/pokemon_summary_screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 3ebdc3d6d..834ca6f7d 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -26,6 +26,7 @@ #include "international_string_util.h" #include "scanline_effect.h" #include "menu_helpers.h" +#include "daycare.h" struct ContestMove { @@ -3024,7 +3025,7 @@ void sub_81C31F0(u8 *a) { u8 level = gUnknown_0203CF1C->summary.metLevel; if (level == 0) - level = 5; + level = EGG_HATCH_LEVEL; ConvertIntToDecimalStringN(a, level, 0, 3); UnkTextUtil_SetPtrI(3, a); } From db2839bd5b771106a1578c20d067c21fab3f68cc Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 9 Mar 2018 22:18:58 +0100 Subject: [PATCH 09/11] curly brace --- src/list_menu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/list_menu.c b/src/list_menu.c index 9b9921c8f..c78d32bb3 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -73,7 +73,9 @@ s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenu case 1: gUnknown_0203CE84.field_0 = ListMenuHandleInputGetItemId(gUnknown_0203CE84.field_6); if (gMain.newKeys & A_BUTTON) + { gUnknown_0203CE84.field_4 = 2; + } if (gMain.newKeys & B_BUTTON) { gUnknown_0203CE84.field_0 = LIST_B_PRESSED; @@ -82,7 +84,9 @@ s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenu if (gUnknown_0203CE84.field_4 == 2) { if (arg2 == 0) + { ClearWindowTilemap(gUnknown_0203CE84.field_5); + } else { switch (arg2) From 70ec55386ce640b6844f7c0bf93a7a447888cb66 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 9 Mar 2018 22:22:00 +0100 Subject: [PATCH 10/11] if --- src/item_menu_icons.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index 843c9eec3..1d9dbb106 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -636,8 +636,10 @@ static void sub_80D5070(u8 berryId) { struct CompressedSpritePalette pal; - if (berryId == ITEM_TO_BERRY(ITEM_ENIGMA_BERRY) - 1) - IsEnigmaBerryValid(); // what's the point of calling it if the return value is ignored? + if (berryId == ITEM_TO_BERRY(ITEM_ENIGMA_BERRY) - 1 && IsEnigmaBerryValid()) + { + // unknown empty if statement + } pal.data = gBerryPicTable[berryId].pal; pal.tag = 0x7544; From e03004b4b6fed2aea46ac87a429bfa2db2f28af1 Mon Sep 17 00:00:00 2001 From: Avara <31101124+Mother-Of-Dragons@users.noreply.github.com> Date: Tue, 13 Mar 2018 11:55:18 +0000 Subject: [PATCH 11/11] Fixed label names: battle_ai_scripts.s --- data/battle_ai_scripts.s | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 70cc48d9b..1b4863046 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -2037,11 +2037,6 @@ AI_CV_Protect_ScoreUp2: AI_CV_Protect2: if_random_less_than 128, AI_CV_Protect4 score -1 - -AI_CV_Protect3: - get_last_used_bank_move AI_TARGET - get_move_effect_from_result - if_not_equal EFFECT_LOCK_ON, AI_CV_Protect_End AI_CV_Protect4: get_protect_count AI_USER @@ -2050,6 +2045,11 @@ AI_CV_Protect4: if_random_less_than 128, AI_CV_Protect_End score -1 goto AI_CV_Protect_End + +AI_CV_Protect3: + get_last_used_bank_move AI_TARGET + get_move_effect_from_result + if_not_equal EFFECT_LOCK_ON, AI_CV_Protect_End AI_CV_Protect_ScoreDown2: score -2