From db44a7e25aa7a9bd6c65723a52a2c3ec1a09b1c8 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 22 Sep 2018 17:27:51 +0200 Subject: [PATCH] Techno Blast and Autotomize --- asm/macros/battle_script.inc | 5 ++++ data/battle_scripts_1.s | 30 ++++++++++++++++++++++ include/constants/battle_move_effects.h | 3 +++ include/constants/battle_script_commands.h | 1 + include/constants/hold_effects.h | 1 + src/battle_main.c | 10 ++++++++ src/battle_script_commands.c | 11 ++++++++ src/battle_util.c | 15 +++++++++-- src/data/battle_moves.h | 6 ++--- 9 files changed, 77 insertions(+), 5 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index a1b1d326c..fb34f4fc5 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1491,6 +1491,11 @@ .4byte \ptr .endm + .macro tryautonomize battler ptr + various \battler, VARIOUS_TRY_AUTONOMIZE + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat, stages, down setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 172bf9745..efd3e8e39 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -313,6 +313,34 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectClearSmog .4byte BattleScript_EffectHitSwitchTarget .4byte BattleScript_EffectFinalGambit + .4byte BattleScript_EffectTechnoBlast + .4byte BattleScript_EffectJudgment + .4byte BattleScript_EffectAutonomize + +BattleScript_EffectAutonomize: + setstatchanger STAT_SPEED, 2, FALSE + attackcanceler + attackstring + ppreduce + statbuffchange MOVE_EFFECT_AFFECTS_USER | 0x1, BattleScript_AutonomizeWeightLoss + jumpifbyte CMP_NOT_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_AutonomizeAttackAnim + pause 0x20 + goto BattleScript_AutonomizePrintString +BattleScript_AutonomizeAttackAnim:: + attackanimation + waitanimation +BattleScript_AutonomizeDoAnim:: + setgraphicalstatchangevalues + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 +BattleScript_AutonomizePrintString:: + printfromtable gStatUpStringIds + waitmessage 0x40 +BattleScript_AutonomizeWeightLoss:: + jumpifmovehadnoeffect BattleScript_MoveEnd + tryautonomize BS_ATTACKER, BattleScript_MoveEnd + printstring STRINGID_BECAMENIMBLE + waitmessage 0x40 + goto BattleScript_MoveEnd BattleScript_EffectFinalGambit: attackcanceler @@ -1267,6 +1295,8 @@ BattleScript_EffectWeatherBall: BattleScript_EffectHiddenPower: BattleScript_EffectFreezeDry: BattleScript_EffectTwoTypedMove: +BattleScript_EffectTechnoBlast: +BattleScript_EffectJudgment: jumpifnotmove MOVE_SURF, BattleScript_HitFromAtkCanceler jumpifnostatus3 BS_TARGET, STATUS3_UNDERWATER, BattleScript_HitFromAtkCanceler orword gHitMarker, HITMARKER_IGNORE_UNDERWATER diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index a93cb2a0e..93f4f727e 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -302,5 +302,8 @@ #define EFFECT_CLEAR_SMOG 296 #define EFFECT_HIT_SWITCH_TARGET 297 #define EFFECT_FINAL_GAMBIT 298 +#define EFFECT_TECHNO_BLAST 299 +#define EFFECT_JUDGMENT 300 +#define EFFECT_AUTONOMIZE 301 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 67d434964..062db7ccc 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -104,6 +104,7 @@ #define VARIOUS_TRY_LAST_RESORT 52 #define VARIOUS_ARGUMENT_STATUS_EFFECT 53 #define VARIOUS_TRY_HIT_SWITCH_TARGET 54 +#define VARIOUS_TRY_AUTONOMIZE 55 // atk80, dmg manipulation #define ATK80_DMG_CHANGE_SIGN 0 diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index dd8f907ac..1845c77f9 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -107,6 +107,7 @@ #define HOLD_EFFECT_EVIOLITE 117 #define HOLD_EFFECT_ASSAULT_VEST 118 #define HOLD_EFFECT_BINDING_BAND 119 +#define HOLD_EFFECT_DRIVE 120 // Gen6 hold effects #define HOLD_EFFECT_FAIRY_POWER 130 diff --git a/src/battle_main.c b/src/battle_main.c index 2f79ed9ca..cbd4945e7 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5376,6 +5376,15 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk) gBattleStruct->dynamicMoveType++; gBattleStruct->dynamicMoveType |= 0xC0; } + else if (gBattleMoves[move].effect == EFFECT_TECHNO_BLAST) + { + if (GetBattlerHoldEffect(battlerAtk, TRUE) == HOLD_EFFECT_DRIVE) + gBattleStruct->dynamicMoveType = ItemId_GetSecondaryId(gBattleMons[battlerAtk].item) | 0x80; + } + else if (gBattleMoves[move].effect == EFFECT_JUDGMENT) + { + // TODO: + } attackerAbility = GetBattlerAbility(battlerAtk); GET_MOVE_TYPE(move, moveType); @@ -5387,6 +5396,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk) else if (gBattleMoves[move].type == TYPE_NORMAL && gBattleMoves[move].effect != EFFECT_HIDDEN_POWER && gBattleMoves[move].effect != EFFECT_WEATHER_BALL + && gBattleMoves[move].effect != EFFECT_JUDGMENT && ((attackerAbility == ABILITY_PIXILATE && (ateType = TYPE_FAIRY)) || (attackerAbility == ABILITY_REFRIGERATE && (ateType = TYPE_ICE)) || (attackerAbility == ABILITY_AERILATE && (ateType = TYPE_FLYING)) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 47ac3cc9b..ec4d6bca7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6735,6 +6735,17 @@ static void atk76_various(void) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); } return; + case VARIOUS_TRY_AUTONOMIZE: + if (GetBattlerWeight(gActiveBattler) > 1) + { + gDisableStructs[gActiveBattler].autonomizeCount++; + gBattlescriptCurrInstr += 7; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + } + return; } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 239e904ce..178f9ae2c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4475,6 +4475,7 @@ u8 GetBattleMonMoveSlot(struct BattlePokemon *battleMon, u16 move) u32 GetBattlerWeight(u8 battlerId) { + u32 i; u32 weight = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[battlerId].species), 1); u32 ability = GetBattlerAbility(battlerId); u32 holdEffect = GetBattlerHoldEffect(battlerId, TRUE); @@ -4487,8 +4488,18 @@ u32 GetBattlerWeight(u8 battlerId) if (holdEffect == HOLD_EFFECT_FLOAT_STONE) weight /= 2; - if (gDisableStructs[battlerId].autonomizeCount) - weight -= 1000 * gDisableStructs[battlerId].autonomizeCount; + for (i = 0; i < gDisableStructs[battlerId].autonomizeCount; i++) + { + if (weight > 1000) + { + weight -= 1000; + } + else if (weight <= 1000) + { + weight = 1; + break; + } + } if (weight == 0) weight = 1; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index d335c49ea..93265a340 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -5397,7 +5397,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_SPECIAL, }, { // MOVE_JUDGMENT - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_JUDGMENT, .power = 100, .type = TYPE_NORMAL, .accuracy = 100, @@ -5709,7 +5709,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_SPECIAL, }, { // MOVE_AUTOTOMIZE - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect (raises the user's Speed stat by two stages BUT also decreases the user's weight by 100kg) + .effect = EFFECT_AUTONOMIZE, .power = 0, .type = TYPE_STEEL, .accuracy = 0, @@ -6561,7 +6561,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .split = SPLIT_SPECIAL, }, { // MOVE_TECHNO_BLAST - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_TECHNO_BLAST, .power = 120, .type = TYPE_NORMAL, .accuracy = 100,