Implements struggle.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
82e0774b40
commit
94980ef7ab
|
@ -1,5 +1,6 @@
|
|||
#include "MiscLibrary.hpp"
|
||||
#include <CreatureLib/Battling/Models/Battle.hpp>
|
||||
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
|
||||
#include "../PkmnScriptHook.hpp"
|
||||
|
||||
bool PkmnLib::Battling::MiscLibrary::IsCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
|
@ -7,7 +8,7 @@ bool PkmnLib::Battling::MiscLibrary::IsCritical(CreatureLib::Battling::Executing
|
|||
uint8_t critStage = 0;
|
||||
PKMN_HOOK(ModifyCriticalStage, attack, attack, target, hit, &critStage);
|
||||
auto rand = target->GetBattle()->GetRandom();
|
||||
switch (critStage){
|
||||
switch (critStage) {
|
||||
case 0: return rand->Get(24) == 0;
|
||||
case 1: return rand->Get(8) == 0;
|
||||
case 2: return rand->Get(2) == 0;
|
||||
|
@ -18,3 +19,30 @@ bool PkmnLib::Battling::MiscLibrary::IsCritical(CreatureLib::Battling::Executing
|
|||
bool PkmnLib::Battling::MiscLibrary::CanFlee(CreatureLib::Battling::FleeTurnChoice* switchChoice) const {
|
||||
return CreatureLib::Battling::MiscLibrary::CanFlee(switchChoice);
|
||||
}
|
||||
|
||||
static CreatureLib::Battling::LearnedAttack* _replacementAttack = nullptr;
|
||||
static PkmnLib::Library::MoveData* _replacementMove = nullptr;
|
||||
|
||||
static CreatureLib::Library::AttackData* GetReplacementAttackData() {
|
||||
if (_replacementMove == nullptr) {
|
||||
_replacementMove =
|
||||
new PkmnLib::Library::MoveData("struggle"_cnc, 0, PkmnLib::Library::MoveCategory::Physical, 50, 255, 255,
|
||||
CreatureLib::Library::AttackTarget::Any, 0,
|
||||
new CreatureLib::Library::SecondaryEffect(-1, "struggle"_cnc, {}), {});
|
||||
}
|
||||
return _replacementMove;
|
||||
}
|
||||
|
||||
static CreatureLib::Battling::LearnedAttack* GetReplacementAttack() {
|
||||
if (_replacementAttack == nullptr) {
|
||||
_replacementAttack = new CreatureLib::Battling::LearnedAttack(
|
||||
GetReplacementAttackData(), CreatureLib::Battling::AttackLearnMethod::Unknown);
|
||||
}
|
||||
return _replacementAttack;
|
||||
}
|
||||
|
||||
CreatureLib::Battling::BaseTurnChoice*
|
||||
PkmnLib::Battling::MiscLibrary::ReplacementAttack(CreatureLib::Battling::Creature* user,
|
||||
CreatureLib::Battling::CreatureIndex target) const {
|
||||
return new CreatureLib::Battling::AttackTurnChoice(user, GetReplacementAttack(), target);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ namespace PkmnLib::Battling{
|
|||
bool IsCritical(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
|
||||
uint8_t hit) const override;
|
||||
bool CanFlee(CreatureLib::Battling::FleeTurnChoice* switchChoice) const override;
|
||||
CreatureLib::Battling::BaseTurnChoice*
|
||||
ReplacementAttack(CreatureLib::Battling::Creature* user,
|
||||
CreatureLib::Battling::CreatureIndex target) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue