summaryrefslogtreecommitdiff
path: root/src/battle_script_commands.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2019-05-11 21:22:09 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2019-05-11 21:22:09 -0400
commit539d47279625a3d7a274726a02468bb5c1c56514 (patch)
tree08f68b473f37d1a74396ef2e28e1a0cecc60a9f1 /src/battle_script_commands.c
parenta58d9a16dd7e4f263ebccda50e70103e7490886b (diff)
parentfc72b74e6ca6626dbaffa353eabf49429ff5e75f (diff)
Merge branch 'master' into dodrio_berry_picking
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r--src/battle_script_commands.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 2e78e1ca0..837fb5bac 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -50,6 +50,8 @@
#include "pokemon_summary_screen.h"
#include "pokenav.h"
#include "menu_specialized.h"
+#include "constants/rgb.h"
+#include "data.h"
extern struct MusicPlayerInfo gMPlayInfo_BGM;
@@ -66,8 +68,8 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr);
static bool32 IsMonGettingExpSentOut(void);
static void sub_804F17C(void);
static bool8 sub_804F1CC(void);
-static void sub_804F100(void);
-static void sub_804F144(void);
+static void DrawLevelUpWindow1(void);
+static void DrawLevelUpWindow2(void);
static bool8 sub_804F344(void);
static void PutMonIconOnLvlUpBox(void);
static void PutLevelAndGenderOnLvlUpBox(void);
@@ -1274,8 +1276,8 @@ static void atk04_critcalc(void)
+ 2 * (holdEffect == HOLD_EFFECT_LUCKY_PUNCH && gBattleMons[gBattlerAttacker].species == SPECIES_CHANSEY)
+ 2 * (holdEffect == HOLD_EFFECT_STICK && gBattleMons[gBattlerAttacker].species == SPECIES_FARFETCHD);
- if (critChance > 4)
- critChance = 4;
+ if (critChance >= ARRAY_COUNT(sCriticalHitChance))
+ critChance = ARRAY_COUNT(sCriticalHitChance) - 1;
if ((gBattleMons[gBattlerTarget].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBattlerTarget].ability != ABILITY_SHELL_ARMOR)
&& !(gStatuses3[gBattlerAttacker] & STATUS3_CANT_SCORE_A_CRIT)
@@ -3238,9 +3240,8 @@ static void atk23_getexp(void)
s32 i; // also used as stringId
u8 holdEffect;
s32 sentIn;
-
s32 viaExpShare = 0;
- u16* exp = &gBattleStruct->expValue;
+ u16 *exp = &gBattleStruct->expValue;
gBattlerFainted = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
sentIn = gSentPokesToOpponent[(gBattlerFainted & 2) >> 1];
@@ -3391,14 +3392,14 @@ static void atk23_getexp(void)
}
}
else
+ {
gBattleStruct->expGetterBattlerId = 0;
+ }
- PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleStruct->expGetterBattlerId, gBattleStruct->expGetterMonId)
-
+ PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleStruct->expGetterBattlerId, gBattleStruct->expGetterMonId);
// buffer 'gained' or 'gained a boosted'
- PREPARE_STRING_BUFFER(gBattleTextBuff2, i)
-
- PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff3, 5, gBattleMoveDamage)
+ PREPARE_STRING_BUFFER(gBattleTextBuff2, i);
+ PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff3, 5, gBattleMoveDamage);
PrepareStringBattle(STRINGID_PKMNGAINEDEXP, gBattleStruct->expGetterBattlerId);
MonGainEVs(&gPlayerParty[gBattleStruct->expGetterMonId], gBattleMons[gBattlerFainted].species);
@@ -3414,12 +3415,12 @@ static void atk23_getexp(void)
gBattleBufferB[gBattleStruct->expGetterBattlerId][0] = 0;
if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_LEVEL)
{
- gBattleResources->statsBeforeLvlUp->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
- gBattleResources->statsBeforeLvlUp->atk = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);
- gBattleResources->statsBeforeLvlUp->def = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF);
- gBattleResources->statsBeforeLvlUp->spd = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
- gBattleResources->statsBeforeLvlUp->spAtk = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK);
- gBattleResources->statsBeforeLvlUp->spDef = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF);
+ gBattleResources->beforeLvlUp->stats[STAT_HP] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
+ gBattleResources->beforeLvlUp->stats[STAT_ATK] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);
+ gBattleResources->beforeLvlUp->stats[STAT_DEF] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF);
+ gBattleResources->beforeLvlUp->stats[STAT_SPEED] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
+ gBattleResources->beforeLvlUp->stats[STAT_SPATK] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK);
+ gBattleResources->beforeLvlUp->stats[STAT_SPDEF] = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF);
gActiveBattler = gBattleStruct->expGetterBattlerId;
BtlController_EmitExpUpdate(0, gBattleStruct->expGetterMonId, gBattleMoveDamage);
@@ -3437,9 +3438,8 @@ static void atk23_getexp(void)
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlerPartyIndexes[gActiveBattler] == gBattleStruct->expGetterMonId)
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
- PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattleStruct->expGetterMonId)
-
- PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 3, GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL))
+ PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattleStruct->expGetterMonId);
+ PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 3, GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL));
BattleScriptPushCursor();
gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterMonId];
@@ -3487,7 +3487,9 @@ static void atk23_getexp(void)
break;
case 5: // looper increment
if (gBattleMoveDamage) // there is exp to give, goto case 3 that gives exp
+ {
gBattleScripting.atk23_state = 3;
+ }
else
{
gBattleStruct->expGetterMonId++;
@@ -5695,7 +5697,7 @@ static void atk5A_yesnoboxlearnmove(void)
if (gBattleCommunication[1] == 0)
{
HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR);
- BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gBattleScripting.learnMoveState++;
}
else
@@ -5911,8 +5913,7 @@ static void atk5D_getmoneyreward(void)
moneyReward += GetTrainerMoneyToGive(gTrainerBattleOpponent_B);
AddMoney(&gSaveBlock1Ptr->money, moneyReward);
-
- PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff1, 5, moneyReward)
+ PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff1, 5, moneyReward);
gBattlescriptCurrInstr++;
}
@@ -6233,7 +6234,7 @@ static void atk6C_drawlvlupbox(void)
gBattleScripting.atk6C_state = 4;
break;
case 4:
- sub_804F100();
+ DrawLevelUpWindow1();
PutWindowTilemap(13);
CopyWindowToVram(13, 3);
gBattleScripting.atk6C_state++;
@@ -6250,7 +6251,7 @@ static void atk6C_drawlvlupbox(void)
if (gMain.newKeys != 0)
{
PlaySE(SE_SELECT);
- sub_804F144();
+ DrawLevelUpWindow2();
CopyWindowToVram(13, 2);
gBattleScripting.atk6C_state++;
}
@@ -6291,20 +6292,20 @@ static void atk6C_drawlvlupbox(void)
}
}
-static void sub_804F100(void)
+static void DrawLevelUpWindow1(void)
{
- struct StatsArray currentStats;
+ u16 currStats[NUM_STATS];
- GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], (u16*) &currentStats);
- DrawLevelUpWindowPg1(0xD, (u16*) gBattleResources->statsBeforeLvlUp,(u16*) &currentStats, 0xE, 0xD, 0xF);
+ GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], currStats);
+ DrawLevelUpWindowPg1(0xD, gBattleResources->beforeLvlUp->stats, currStats, 0xE, 0xD, 0xF);
}
-static void sub_804F144(void)
+static void DrawLevelUpWindow2(void)
{
- struct StatsArray currentStats;
+ u16 currStats[NUM_STATS];
- GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], (u16*) &currentStats);
- DrawLevelUpWindowPg2(0xD, (u16*) &currentStats, 0xE, 0xD, 0xF);
+ GetMonLevelUpWindowStats(&gPlayerParty[gBattleStruct->expGetterMonId], currStats);
+ DrawLevelUpWindowPg2(0xD, currStats, 0xE, 0xD, 0xF);
}
static void sub_804F17C(void)
@@ -10274,7 +10275,7 @@ static void atkF2_displaydexinfo(void)
switch (gBattleCommunication[0])
{
case 0:
- BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gBattleCommunication[0]++;
break;
case 1:
@@ -10305,7 +10306,7 @@ static void atkF2_displaydexinfo(void)
case 4:
if (!IsDma3ManagerBusyWithBgCopy())
{
- BeginNormalPaletteFade(0xFFFF, 0, 0x10, 0, 0);
+ BeginNormalPaletteFade(0xFFFF, 0, 0x10, 0, RGB_BLACK);
ShowBg(0);
ShowBg(3);
gBattleCommunication[0]++;