diff options
author | garak <garakmon@gmail.com> | 2018-11-27 13:31:07 -0500 |
---|---|---|
committer | garak <garakmon@gmail.com> | 2018-11-27 13:31:07 -0500 |
commit | 50f00b0827a4952a12f90009bd992f23c80a56af (patch) | |
tree | 6a5f78b04b42c162ed95cfc66c91a8b24f4051b2 /src/battle_script_commands.c | |
parent | f02cb667bbddf4f4a1152c86cbf9616468e7f0d2 (diff) | |
parent | c909aa92dee0a8d202d9195d80d0cc96b0d1ebc8 (diff) |
Merge remote-tracking branch 'upstream/master' into fldeff
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r-- | src/battle_script_commands.c | 128 |
1 files changed, 61 insertions, 67 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 665ee3750..5bd7de072 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -45,12 +45,8 @@ #include "party_menu.h" #include "battle_arena.h" #include "battle_pike.h" +#include "battle_pyramid.h" -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern const u8* const gBattleScriptsForMoveEffects[]; @@ -62,11 +58,8 @@ extern void sub_81D388C(struct Pokemon* mon, void* statStoreLocation); // pokena extern void sub_81D3640(u8 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); // pokenav.s extern void sub_81D3784(u8 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); // pokenav.s extern u8* GetMonNickname(struct Pokemon* mon, u8* dst); // party_menu -extern u8 BattleArena_ShowJudgmentWindow(u8* arg0); // battle frontier 2 extern void sub_81B8E80(u8 battlerId, u8, u8); // party menu extern bool8 sub_81B1250(void); // ? -extern bool8 InBattlePyramid(void); -extern u16 GetBattlePyramidPickupItemId(void); extern u8 sub_813B21C(void); extern u16 get_unknown_box_id(void); @@ -3285,7 +3278,7 @@ static void atk23_getexp(void) u16 calculatedExp; s32 viaSentIn; - for (viaSentIn = 0, i = 0; i < 6; i++) + for (viaSentIn = 0, i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) continue; @@ -3543,7 +3536,7 @@ static void atk24(void) } else { - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i]))) @@ -3556,7 +3549,7 @@ static void atk24(void) if (HP_count == 0) gBattleOutcome |= B_OUTCOME_LOST; - for (HP_count = 0, i = 0; i < 6; i++) + for (HP_count = 0, i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostOpponentMons & gBitTable[i]))) @@ -4952,7 +4945,7 @@ static void atk4D_switchindataupdate(void) if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { gBattleMons[gActiveBattler].statStages[i] = oldData.statStages[i]; } @@ -7406,7 +7399,7 @@ static void atk8A_normalisebuffs(void) // haze for (i = 0; i < gBattlersCount; i++) { - for (j = 0; j < BATTLE_STATS_NO; j++) + for (j = 0; j < NUM_BATTLE_STATS; j++) gBattleMons[i].statStages[j] = 6; } @@ -9034,7 +9027,7 @@ static void atkBD_copyfoestats(void) // psych up { s32 i; - for (i = 0; i < BATTLE_STATS_NO; i++) + for (i = 0; i < NUM_BATTLE_STATS; i++) { gBattleMons[gBattlerAttacker].statStages[i] = gBattleMons[gBattlerTarget].statStages[i]; } @@ -9860,71 +9853,72 @@ static void atkE4_getsecretpowereffect(void) static void atkE5_pickup(void) { - if (!InBattlePike()) + s32 i; + u16 species, heldItem; + u8 ability; + + if (InBattlePike()) { - s32 i; - u16 species, heldItem; - u8 ability; - if (InBattlePyramid()) + } + else if (InBattlePyramid()) + { + for (i = 0; i < PARTY_SIZE; i++) { - for (i = 0; i < 6; i++) - { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - if (GetMonData(&gPlayerParty[i], MON_DATA_ALT_ABILITY)) - ability = gBaseStats[species].ability2; - else - ability = gBaseStats[species].ability1; + if (GetMonData(&gPlayerParty[i], MON_DATA_ALT_ABILITY)) + ability = gBaseStats[species].ability2; + else + ability = gBaseStats[species].ability1; - if (ability == ABILITY_PICKUP - && species != 0 - && species != SPECIES_EGG - && heldItem == ITEM_NONE - && (Random() % 10) == 0) - { - heldItem = GetBattlePyramidPickupItemId(); - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); - } + if (ability == ABILITY_PICKUP + && species != 0 + && species != SPECIES_EGG + && heldItem == ITEM_NONE + && (Random() % 10) == 0) + { + heldItem = GetBattlePyramidPickupItemId(); + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); } } - else + } + else + { + for (i = 0; i < PARTY_SIZE; i++) { - for (i = 0; i < 6; i++) - { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); - if (GetMonData(&gPlayerParty[i], MON_DATA_ALT_ABILITY)) - ability = gBaseStats[species].ability2; - else - ability = gBaseStats[species].ability1; + if (GetMonData(&gPlayerParty[i], MON_DATA_ALT_ABILITY)) + ability = gBaseStats[species].ability2; + else + ability = gBaseStats[species].ability1; - if (ability == ABILITY_PICKUP - && species != 0 - && species != SPECIES_EGG - && heldItem == ITEM_NONE - && (Random() % 10) == 0) - { - s32 j; - s32 rand = Random() % 100; - u8 lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) - 1) / 10; - if (lvlDivBy10 > 9) - lvlDivBy10 = 9; + if (ability == ABILITY_PICKUP + && species != 0 + && species != SPECIES_EGG + && heldItem == ITEM_NONE + && (Random() % 10) == 0) + { + s32 j; + s32 rand = Random() % 100; + u8 lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) - 1) / 10; + if (lvlDivBy10 > 9) + lvlDivBy10 = 9; - for (j = 0; j < 9; j++) + for (j = 0; j < 9; j++) + { + if (sPickupProbabilities[j] > rand) { - if (sPickupProbabilities[j] > rand) - { - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sPickupItems[lvlDivBy10 + j]); - break; - } - else if (rand == 99 || rand == 98) - { - SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sRarePickupItems[lvlDivBy10 + (99 - rand)]); - break; - } + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sPickupItems[lvlDivBy10 + j]); + break; + } + else if (rand == 99 || rand == 98) + { + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &sRarePickupItems[lvlDivBy10 + (99 - rand)]); + break; } } } |