This commit is contained in:
DizzyEggg 2018-09-30 12:27:51 +02:00
parent 65a48e16ee
commit 162c83fcff
10 changed files with 74 additions and 5 deletions

View File

@ -1445,6 +1445,11 @@
.4byte \ptr
.endm
.macro trybestow ptr
various BS_ATTACKER, VARIOUS_BESTOW
.4byte \ptr
.endm
.macro invertstatstages battler
various \battler, VARIOUS_INVERT_STAT_STAGES
.endm

View File

@ -325,6 +325,20 @@ gBattleScriptsForMoveEffects:: @ 82D86A8
.4byte BattleScript_EffectPowerTrick
.4byte BattleScript_EffectFlameBurst
.4byte BattleScript_EffectAfterYou
.4byte BattleScript_EffectBestow
BattleScript_EffectBestow:
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON
attackstring
ppreduce
jumpifsubstituteblocks BattleScript_ButItFailed
trybestow BattleScript_ButItFailed
attackanimation
waitanimation
printstring STRINGID_BESTOWITEMGIVING
waitmessage 0x40
goto BattleScript_MoveEnd
BattleScript_EffectAfterYou:
attackcanceler

View File

@ -92,5 +92,6 @@ u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId);
bool32 CanMegaEvolve(u8 battlerId);
void UndoMegaEvolution(u8 monId);
bool32 DoBattlersShareType(u32 battler1, u32 battler2);
bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId);
#endif // GUARD_BATTLE_UTIL_H

View File

@ -314,5 +314,6 @@
#define EFFECT_POWER_TRICK 308
#define EFFECT_FLAME_BURST 309
#define EFFECT_AFTER_YOU 310
#define EFFECT_BESTOW 311
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View File

@ -116,6 +116,7 @@
#define VARIOUS_CURE_STATUS 62
#define VARIOUS_POWER_TRICK 63
#define VARIOUS_AFTER_YOU 64
#define VARIOUS_BESTOW 65
// atk80, dmg manipulation
#define ATK80_DMG_CHANGE_SIGN 0

View File

@ -509,6 +509,7 @@
#define STRINGID_INFESTATION 506
#define STRINGID_NOEFFECTONTARGET 507
#define STRINGID_BURSTINGFLAMESHIT 508
#define STRINGID_BESTOWITEMGIVING 509
#define BATTLESTRINGS_COUNT 521

View File

@ -650,6 +650,7 @@ static const u8 sText_severely[] = _("severely ");
static const u8 sText_Infestation[] = _("{B_DEF_NAME_WITH_PREFIX} has been afflicted\nwith an infestation by {B_ATK_NAME_WITH_PREFIX}!");
static const u8 sText_NoEffectOnTarget[] = _("It had no effect\non {B_DEF_NAME_WITH_PREFIX}!");
static const u8 sText_BurstingFlames[] = _("The bursting flames\nhit {B_SCR_ACTIVE_NAME_WITH_PREFIX}!");
static const u8 sText_BestowItemGiving[] = _("{B_DEF_NAME_WITH_PREFIX} received {B_LAST_ITEM}\nfrom {B_ATK_NAME_WITH_PREFIX}!");
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
{
@ -1151,6 +1152,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
sText_Infestation,
sText_NoEffectOnTarget,
sText_BurstingFlames,
sText_BestowItemGiving,
};
const u16 gTerrainStringIds[] =

View File

@ -7010,6 +7010,31 @@ static void atk76_various(void)
gBattlescriptCurrInstr += 7;
}
return;
case VARIOUS_BESTOW:
if (gBattleMons[gBattlerAttacker].item == ITEM_NONE
|| gBattleMons[gBattlerTarget].item != ITEM_NONE
|| !CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerAttacker].item)
|| !CanBattlerGetOrLoseItem(gBattlerTarget, gBattleMons[gBattlerAttacker].item))
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
}
else
{
gLastUsedItem = gBattleMons[gBattlerAttacker].item;
gActiveBattler = gBattlerAttacker;
gBattleMons[gActiveBattler].item = ITEM_NONE;
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item);
MarkBattlerForControllerExec(gActiveBattler);
gActiveBattler = gBattlerTarget;
gBattleMons[gActiveBattler].item = gLastUsedItem;
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item);
MarkBattlerForControllerExec(gActiveBattler);
gBattlescriptCurrInstr += 7;
}
return;
}
gBattlescriptCurrInstr += 3;
@ -9687,10 +9712,10 @@ static void atkD2_tryswapitems(void) // trick
// can't swap if two pokemon don't have an item
// or if either of them is an enigma berry or a mail
else if ((gBattleMons[gBattlerAttacker].item == 0 && gBattleMons[gBattlerTarget].item == 0)
|| gBattleMons[gBattlerAttacker].item == ITEM_ENIGMA_BERRY
|| gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY
|| IS_ITEM_MAIL(gBattleMons[gBattlerAttacker].item)
|| IS_ITEM_MAIL(gBattleMons[gBattlerTarget].item))
|| !CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerAttacker].item)
|| !CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerTarget].item)
|| !CanBattlerGetOrLoseItem(gBattlerTarget, gBattleMons[gBattlerTarget].item)
|| !CanBattlerGetOrLoseItem(gBattlerTarget, gBattleMons[gBattlerAttacker].item))
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}

View File

@ -24,6 +24,7 @@
#include "link.h"
#include "berry.h"
#include "pokedex.h"
#include "mail.h"
#include "constants/battle_config.h"
extern u8 weather_get_current(void);
@ -5680,3 +5681,21 @@ bool32 DoBattlersShareType(u32 battler1, u32 battler2)
else
return FALSE;
}
bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId)
{
u16 species = gBattleMons[battlerId].species;
if (IS_ITEM_MAIL(itemId))
return FALSE;
else if (itemId == ITEM_ENIGMA_BERRY)
return FALSE;
else if (species == SPECIES_KYOGRE && itemId == ITEM_BLUE_ORB)
return FALSE;
else if (species == SPECIES_GROUDON && itemId == ITEM_RED_ORB)
return FALSE;
else if (ItemId_GetHoldEffect(itemId) == HOLD_EFFECT_MEGA_STONE && GetMegaEvolutionSpecies(species, itemId) != SPECIES_NONE)
return FALSE;
else
return TRUE;
}

View File

@ -6201,7 +6201,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.split = SPLIT_SPECIAL,
},
{ // MOVE_BESTOW
.effect = EFFECT_PLACEHOLDER, // Needs a custom move effect
.effect = EFFECT_BESTOW,
.power = 0,
.type = TYPE_NORMAL,
.accuracy = 0,