mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-26 21:33:53 +01:00
Modify the stat changer, so it supports raise/lower by 12
This commit is contained in:
parent
94cd547e9a
commit
08892d19f2
@ -1591,7 +1591,7 @@
|
||||
|
||||
@ helpful macros
|
||||
.macro setstatchanger stat:req, stages:req, down:req
|
||||
setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7
|
||||
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7
|
||||
.endm
|
||||
|
||||
.macro setmoveeffect effect:req
|
||||
|
@ -597,14 +597,14 @@ struct BattleStruct
|
||||
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
|
||||
}
|
||||
|
||||
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
|
||||
#define GET_STAT_BUFF_VALUE2(n)((n & 0xF0))
|
||||
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
|
||||
#define GET_STAT_BUFF_ID(n)((n & 7)) // first three bits 0x1, 0x2, 0x4
|
||||
#define GET_STAT_BUFF_VALUE_WITH_SIGN(n)((n & 0xF8))
|
||||
#define GET_STAT_BUFF_VALUE(n)(((n >> 3) & 0xF)) // 0x8, 0x10, 0x20, 0x40
|
||||
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
|
||||
|
||||
#define SET_STAT_BUFF_VALUE(n)((((n) << 4) & 0xF0))
|
||||
#define SET_STAT_BUFF_VALUE(n)((((n) << 3) & 0xF8))
|
||||
|
||||
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7))
|
||||
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 3) + (goesDown << 7))
|
||||
|
||||
struct BattleScripting
|
||||
{
|
||||
|
@ -4011,7 +4011,7 @@ static void atk46_playanimation2(void) // animation Id is stored in the first po
|
||||
static void atk47_setgraphicalstatchangevalues(void)
|
||||
{
|
||||
u8 value = 0;
|
||||
switch (GET_STAT_BUFF_VALUE2(gBattleScripting.statChanger))
|
||||
switch (GET_STAT_BUFF_VALUE_WITH_SIGN(gBattleScripting.statChanger))
|
||||
{
|
||||
case SET_STAT_BUFF_VALUE(1): // +1
|
||||
value = STAT_ANIM_PLUS1;
|
||||
@ -6379,7 +6379,7 @@ static void atk76_various(void)
|
||||
{
|
||||
gBattleStruct->stolenStats[0] &= ~(gBitTable[i]);
|
||||
SET_STATCHANGER(i, gBattleStruct->stolenStats[i], FALSE);
|
||||
if (ChangeStatBuffs(gBattleScripting.statChanger & 0xF0, i, MOVE_EFFECT_CERTAIN | MOVE_EFFECT_AFFECTS_USER, NULL) == STAT_CHANGE_WORKED)
|
||||
if (ChangeStatBuffs(GET_STAT_BUFF_VALUE_WITH_SIGN(gBattleScripting.statChanger), i, MOVE_EFFECT_CERTAIN | MOVE_EFFECT_AFFECTS_USER, NULL) == STAT_CHANGE_WORKED)
|
||||
{
|
||||
BattleScriptPushCursor();
|
||||
gBattlescriptCurrInstr = BattleScript_StatUpMsg;
|
||||
@ -7772,6 +7772,10 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
statValue ^= STAT_BUFF_NEGATIVE;
|
||||
gBattleScripting.statChanger ^= STAT_BUFF_NEGATIVE;
|
||||
}
|
||||
else if (GetBattlerAbility(gActiveBattler) == ABILITY_SIMPLE)
|
||||
{
|
||||
statValue = (SET_STAT_BUFF_VALUE(GET_STAT_BUFF_VALUE(statValue) * 2)) | ((statValue <= -1) ? STAT_BUFF_NEGATIVE : 0);
|
||||
}
|
||||
|
||||
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
|
||||
|
||||
@ -7939,7 +7943,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
static void atk89_statbuffchange(void)
|
||||
{
|
||||
const u8 *jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
if (ChangeStatBuffs(gBattleScripting.statChanger & 0xF0, GET_STAT_BUFF_ID(gBattleScripting.statChanger), T1_READ_16(gBattlescriptCurrInstr + 1), jumpPtr) == STAT_CHANGE_WORKED)
|
||||
if (ChangeStatBuffs(GET_STAT_BUFF_VALUE_WITH_SIGN(gBattleScripting.statChanger), GET_STAT_BUFF_ID(gBattleScripting.statChanger), T1_READ_16(gBattlescriptCurrInstr + 1), jumpPtr) == STAT_CHANGE_WORKED)
|
||||
gBattlescriptCurrInstr += 7;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user