Add Bad Dreams

This commit is contained in:
DizzyEggg 2018-07-22 21:05:12 +02:00
parent fdd8765256
commit 6a7d58003b
8 changed files with 64 additions and 1 deletions

View file

@ -1238,6 +1238,11 @@
.4byte \ptr
.endm
.macro trygetbaddreamstarget ptr
.byte 0xfd
.4byte \ptr
.endm
@ various command changed to more readable macros
.macro cancelmultiturnmoves bank
various \bank, VARIOUS_CANCEL_MULTI_TURN_MOVES
@ -1431,3 +1436,7 @@
.macro jumpifnotbattletype flags, jumpptr
jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
.endm
.macro dmg_1_8_targethp
manipulatedamage ATK80_1_8_TARGET_HP
.endm

View file

@ -4461,6 +4461,24 @@ BattleScript_DroughtActivates::
playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES, NULL
call BattleScript_WeatherFormChanges
end3
BattleScript_BadDreamsActivates::
setbyte gBattlerTarget, 0
BattleScript_BadDreamsLoop:
trygetbaddreamstarget BattleScript_BadDreamsEnd
dmg_1_8_targethp
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
printstring STRINGID_BADDREAMSDMG
waitmessage 0x40
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
tryfaintmon BS_TARGET, FALSE, NULL
atk24 BattleScript_BadDreamsIncrement
BattleScript_BadDreamsIncrement:
addbyte gBattlerTarget, 1
goto BattleScript_BadDreamsLoop
BattleScript_BadDreamsEnd:
end3
BattleScript_TookAttack::
attackstring

View file

@ -312,5 +312,6 @@ extern const u8 BattleScript_AngryPointActivates[];
extern const u8 BattleScript_AttackerAbilityStatRaise[];
extern const u8 BattleScript_AttackerAbilityStatRaiseEnd3[];
extern const u8 BattleScript_PoisonHealActivates[];
extern const u8 BattleScript_BadDreamsActivates[];
#endif // GUARD_BATTLE_SCRIPTS_H

View file

@ -79,6 +79,7 @@
#define ATK80_DMG_CHANGE_SIGN 0
#define ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP 1
#define ATK80_DMG_DOUBLED 2
#define ATK80_1_8_TARGET_HP 3
// atk4F, a flag used for the jumpifcantswitch command
#define ATK4F_DONT_CHECK_STATUSES 0x80

View file

@ -454,7 +454,8 @@
#define STRINGID_ANGRYPOINTACTIVATES 451
#define STRINGID_ATTACKERABILITYSTATRAISE 452
#define STRINGID_POISONHEALHPUP 453
#define STRINGID_BADDREAMSDMG 454
#define BATTLESTRINGS_COUNT 442
#define BATTLESTRINGS_COUNT 443
#endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H

View file

@ -597,6 +597,7 @@ static const u8 sText_PsychicTerrainEnds[] = _("");
static const u8 sText_GrassyTerrainEnds[] = _("");
static const u8 sText_AngryPointActivates[] = _("");
static const u8 sText_PoisonHealHpUp[] = _("");
static const u8 sText_BadDreamsDmg[] = _("");
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
{
@ -1043,6 +1044,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
sText_AngryPointActivates, // 451
sText_AttackerAbilityRaisedStat, // 452
sText_PoisonHealHpUp, // 453
sText_BadDreamsDmg, // 454
};
const u16 gMissStringIds[] =

View file

@ -344,6 +344,7 @@ static void atkF9_settelekinesis(void);
static void atkFA_swapstatstages(void);
static void atkFB_averagestats(void);
static void atkFC_jumpifoppositegenders(void);
static void atkFD_trygetbaddreamstarget(void);
void (* const gBattleScriptingCommandsTable[])(void) =
{
@ -600,6 +601,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
atkFA_swapstatstages,
atkFB_averagestats,
atkFC_jumpifoppositegenders,
atkFD_trygetbaddreamstarget,
};
struct StatFractions
@ -6787,6 +6789,11 @@ static void atk80_manipulatedamage(void)
case ATK80_DMG_DOUBLED:
gBattleMoveDamage *= 2;
break;
case ATK80_1_8_TARGET_HP:
gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 8;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
break;
}
gBattlescriptCurrInstr += 2;
@ -10339,3 +10346,20 @@ static void atkFC_jumpifoppositegenders(void)
else
gBattlescriptCurrInstr += 5;
}
static void atkFD_trygetbaddreamstarget(void)
{
u8 badDreamsMonSide = GetBattlerSide(gBattlerAttacker);
for (;gBattlerTarget < gBattlersCount; gBattlerTarget++)
{
if (GetBattlerSide(gBattlerTarget) == badDreamsMonSide)
continue;
if (gBattleMons[gBattlerTarget].status1 & STATUS1_SLEEP && IsBattlerAlive(gBattlerTarget))
break;
}
if (gBattlerTarget >= gBattlersCount)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
else
gBattlescriptCurrInstr += 5;
}

View file

@ -2551,6 +2551,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
case ABILITY_TRUANT:
gDisableStructs[gBattlerAttacker].truantCounter ^= 1;
break;
case ABILITY_BAD_DREAMS:
if (gBattleMons[BATTLE_OPPOSITE(battler)].status1 & STATUS1_SLEEP || gBattleMons[BATTLE_OPPOSITE(battler)].status1 & STATUS1_SLEEP)
{
BattleScriptPushCursorAndCallback(BattleScript_BadDreamsActivates);
effect++;
}
break;
}
}
break;