mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-14 15:43:43 +01:00
Captivate and new accuracy calc
This commit is contained in:
parent
4ec43cbed1
commit
51dc76c7e8
@ -1233,6 +1233,11 @@
|
||||
.byte \stat
|
||||
.endm
|
||||
|
||||
.macro jumpifoppositegenders ptr
|
||||
.byte 0xfc
|
||||
.4byte \ptr
|
||||
.endm
|
||||
|
||||
@ various command changed to more readable macros
|
||||
.macro cancelmultiturnmoves bank
|
||||
various \bank, VARIOUS_CANCEL_MULTI_TURN_MOVES
|
||||
|
@ -145,7 +145,7 @@ gBattleScriptsForMoveEffects:: @ 82D86A8
|
||||
.4byte BattleScript_EffectPursuit
|
||||
.4byte BattleScript_EffectRapidSpin
|
||||
.4byte BattleScript_EffectSonicboom
|
||||
.4byte BattleScript_EffectUnused83
|
||||
.4byte BattleScript_EffectCaptivate
|
||||
.4byte BattleScript_EffectMorningSun
|
||||
.4byte BattleScript_EffectSynthesis
|
||||
.4byte BattleScript_EffectMoonlight
|
||||
@ -471,6 +471,16 @@ BattleScript_EffectRoost:
|
||||
tryhealhalfhealth BattleScript_AlreadyAtFullHp, BS_TARGET
|
||||
setroost
|
||||
goto BattleScript_PresentHealTarget
|
||||
|
||||
BattleScript_EffectCaptivate:
|
||||
setstatchanger STAT_SPATK, 2, TRUE
|
||||
attackcanceler
|
||||
jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailedAtkStringPpReduce
|
||||
jumpifoppositegenders BattleScript_CaptivateCheckAcc
|
||||
goto BattleScript_ButItFailedAtkStringPpReduce
|
||||
BattleScript_CaptivateCheckAcc:
|
||||
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
|
||||
goto BattleScript_StatDownFromAttackString
|
||||
|
||||
BattleScript_EffectAlwaysHit:
|
||||
BattleScript_EffectPlaceholder43:
|
||||
@ -481,7 +491,6 @@ BattleScript_EffectFalseSwipe:
|
||||
BattleScript_EffectPlaceholder103:
|
||||
BattleScript_EffectUnused6e:
|
||||
BattleScript_EffectPursuit:
|
||||
BattleScript_EffectUnused83:
|
||||
BattleScript_EffectUnused8d:
|
||||
BattleScript_EffectUnusedA3:
|
||||
BattleScript_EffectPlaceholder200:
|
||||
@ -836,6 +845,7 @@ BattleScript_EffectStatDown:
|
||||
attackcanceler
|
||||
jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailedAtkStringPpReduce
|
||||
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
|
||||
BattleScript_StatDownFromAttackString:
|
||||
attackstring
|
||||
ppreduce
|
||||
statbuffchange 0x1, BattleScript_StatDownEnd
|
||||
|
@ -77,6 +77,7 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating);
|
||||
u32 GetBattlerHoldEffectParam(u8 battlerId);
|
||||
bool32 IsMoveMakingContact(u16 move, u8 battlerAtk);
|
||||
bool32 IsBattlerGrounded(u8 battlerId);
|
||||
bool32 IsBattlerAlive(u8 battlerId);
|
||||
u8 GetBattleMonMoveSlot(struct BattlePokemon *battleMon, u16 move);
|
||||
u32 GetBattlerWeight(u8 battlerId);
|
||||
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor);
|
||||
|
@ -132,7 +132,7 @@
|
||||
#define EFFECT_PURSUIT 128
|
||||
#define EFFECT_RAPID_SPIN 129
|
||||
#define EFFECT_SONICBOOM 130
|
||||
#define EFFECT_UNUSED_83 131
|
||||
#define EFFECT_CAPTIVATE 131
|
||||
#define EFFECT_MORNING_SUN 132
|
||||
#define EFFECT_SYNTHESIS 133
|
||||
#define EFFECT_MOONLIGHT 134
|
||||
|
@ -343,6 +343,7 @@ static void atkF8_trainerslideout(void);
|
||||
static void atkF9_settelekinesis(void);
|
||||
static void atkFA_swapstatstages(void);
|
||||
static void atkFB_averagestats(void);
|
||||
static void atkFC_jumpifoppositegenders(void);
|
||||
|
||||
void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
{
|
||||
@ -598,6 +599,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atkF9_settelekinesis,
|
||||
atkFA_swapstatstages,
|
||||
atkFB_averagestats,
|
||||
atkFC_jumpifoppositegenders,
|
||||
};
|
||||
|
||||
struct StatFractions
|
||||
@ -1063,6 +1065,11 @@ static bool8 AccuracyCalcHelper(u16 move)
|
||||
JumpIfMoveFailed(7, move);
|
||||
return TRUE;
|
||||
}
|
||||
else if (gBattleMoves[move].effect == EFFECT_TOXIC && IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_POISON))
|
||||
{
|
||||
JumpIfMoveFailed(7, move);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR)
|
||||
{
|
||||
@ -1116,9 +1123,9 @@ static void atk01_accuracycheck(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 type, moveAcc, holdEffect, param;
|
||||
s8 buff;
|
||||
u16 calc;
|
||||
u8 type, moveAcc, atkHoldEffect, atkParam, defHoldEffect, defParam, atkAbility, defAbility;
|
||||
s8 buff, accStage, evasionStage;
|
||||
u32 calc;
|
||||
|
||||
if (move == 0)
|
||||
move = gCurrentMove;
|
||||
@ -1130,16 +1137,22 @@ static void atk01_accuracycheck(void)
|
||||
if (AccuracyCalcHelper(move))
|
||||
return;
|
||||
|
||||
if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT)
|
||||
{
|
||||
u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_ACC];
|
||||
buff = acc;
|
||||
}
|
||||
atkAbility = GetBattlerAbility(gBattlerAttacker);
|
||||
defAbility = GetBattlerAbility(gBattlerTarget);
|
||||
|
||||
accStage = gBattleMons[gBattlerAttacker].statStages[STAT_ACC];
|
||||
evasionStage = gBattleMons[gBattlerTarget].statStages[STAT_EVASION];
|
||||
if (atkAbility == ABILITY_UNAWARE)
|
||||
evasionStage = 6;
|
||||
if (gBattleMoves[move].flags & FLAG_STAT_STAGES_IGNORED)
|
||||
evasionStage = 6;
|
||||
if (defAbility == ABILITY_UNAWARE)
|
||||
accStage = 6;
|
||||
|
||||
if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT || gStatuses3[gBattlerTarget] & STATUS3_MIRACLE_EYED)
|
||||
buff = accStage;
|
||||
else
|
||||
{
|
||||
u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_ACC];
|
||||
buff = acc + 6 - gBattleMons[gBattlerTarget].statStages[STAT_EVASION];
|
||||
}
|
||||
buff = accStage + 6 - evasionStage;
|
||||
|
||||
if (buff < 0)
|
||||
buff = 0;
|
||||
@ -1154,29 +1167,37 @@ static void atk01_accuracycheck(void)
|
||||
calc = sAccuracyStageRatios[buff].dividend * moveAcc;
|
||||
calc /= sAccuracyStageRatios[buff].divisor;
|
||||
|
||||
if (gBattleMons[gBattlerAttacker].ability == ABILITY_COMPOUND_EYES)
|
||||
if (atkAbility == ABILITY_COMPOUND_EYES)
|
||||
calc = (calc * 130) / 100; // 1.3 compound eyes boost
|
||||
if (WEATHER_HAS_EFFECT && gBattleMons[gBattlerTarget].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY)
|
||||
calc = (calc * 80) / 100; // 1.2 sand veil loss
|
||||
else if (atkAbility == ABILITY_VICTORY_STAR)
|
||||
calc = (calc * 110) / 100; // 1.1 victory star boost
|
||||
if (IsBattlerAlive(BATTLE_PARTNER(gBattlerAttacker)) && GetBattlerAbility(BATTLE_PARTNER(gBattlerAttacker)) == ABILITY_VICTORY_STAR)
|
||||
calc = (calc * 110) / 100; // 1.1 ally's victory star boost
|
||||
|
||||
if (gBattleMons[gBattlerAttacker].ability == ABILITY_HUSTLE && IS_MOVE_PHYSICAL(move))
|
||||
if (defAbility == ABILITY_SAND_VEIL && WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SANDSTORM_ANY)
|
||||
calc = (calc * 80) / 100; // 1.2 sand veil loss
|
||||
else if (defAbility == ABILITY_SNOW_CLOAK && WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_HAIL_ANY)
|
||||
calc = (calc * 80) / 100; // 1.2 snow cloak loss
|
||||
else if (defAbility == ABILITY_TANGLED_FEET && gBattleMons[gBattlerTarget].status2 & STATUS2_CONFUSION)
|
||||
calc = (calc * 50) / 100; // 1.5 tangled feet loss
|
||||
|
||||
if (atkAbility == ABILITY_HUSTLE && IS_MOVE_PHYSICAL(move))
|
||||
calc = (calc * 80) / 100; // 1.2 hustle loss
|
||||
|
||||
if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect;
|
||||
param = gEnigmaBerries[gBattlerTarget].holdEffectParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item);
|
||||
param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item);
|
||||
}
|
||||
|
||||
defHoldEffect = GetBattlerHoldEffect(gBattlerTarget, TRUE);
|
||||
defParam = GetBattlerHoldEffectParam(gBattlerTarget);
|
||||
gPotentialItemEffectBattler = gBattlerTarget;
|
||||
|
||||
if (holdEffect == HOLD_EFFECT_EVASION_UP)
|
||||
calc = (calc * (100 - param)) / 100;
|
||||
atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE);
|
||||
atkParam = GetBattlerHoldEffectParam(gBattlerAttacker);
|
||||
|
||||
if (defHoldEffect == HOLD_EFFECT_EVASION_UP)
|
||||
calc = (calc * (100 - defParam)) / 100;
|
||||
|
||||
if (atkHoldEffect == HOLD_EFFECT_WIDE_LENS)
|
||||
calc = (calc * (100 + atkParam)) / 100;
|
||||
else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget));
|
||||
calc = (calc * (100 + atkParam)) / 100;
|
||||
|
||||
// final calculation
|
||||
if ((Random() % 100 + 1) > calc)
|
||||
@ -10276,3 +10297,14 @@ static void atkFB_averagestats(void)
|
||||
|
||||
gBattlescriptCurrInstr += 2;
|
||||
}
|
||||
|
||||
static void atkFC_jumpifoppositegenders(void)
|
||||
{
|
||||
u32 atkGender = GetGenderFromSpeciesAndPersonality(gBattleMons[gBattlerAttacker].species, gBattleMons[gBattlerAttacker].personality);
|
||||
u32 defGender = GetGenderFromSpeciesAndPersonality(gBattleMons[gBattlerTarget].species, gBattleMons[gBattlerTarget].personality);
|
||||
|
||||
if ((atkGender == MON_MALE && defGender == MON_FEMALE) || (atkGender == MON_FEMALE && defGender == MON_MALE))
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
else
|
||||
gBattlescriptCurrInstr += 5;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user