Adds anticipation ability
This commit is contained in:
parent
7857f5c35a
commit
f19c60c4c1
|
@ -0,0 +1,51 @@
|
||||||
|
namespace Gen7 {
|
||||||
|
[Ability effect=Anticipation]
|
||||||
|
class Anticipation : PkmnScript {
|
||||||
|
void OnSwitchIn(Pokemon@ pokemon){
|
||||||
|
if (DoesOpponentHaveSuperEffectiveMove(pokemon.Battle, pokemon)){
|
||||||
|
// TODO: Shudder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DoesOpponentHaveSuperEffectiveMove(Battle@ battle, Pokemon@ pokemon){
|
||||||
|
bool hasSuperEffectiveMove = false;
|
||||||
|
auto typeLib = battle.Library.StaticLibrary.TypeLibrary;
|
||||||
|
for (uint64 i = 0; i < battle.Sides.Length; i++){
|
||||||
|
if (hasSuperEffectiveMove){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto side = battle.Sides[i];
|
||||||
|
if (side is pokemon.BattleSide){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (uint64 j = 0; j < side.Pokemon.Length; j++){
|
||||||
|
if (hasSuperEffectiveMove){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto opponent = side.Pokemon[j];
|
||||||
|
if (opponent is null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (opponent.IsFainted){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (uint64 k = 0; k < opponent.Moves.Length; k++){
|
||||||
|
if (hasSuperEffectiveMove){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto move = opponent.Moves[k];
|
||||||
|
if (move is null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (typeLib.GetEffectiveness(move.MoveData.Type, pokemon) > 1){
|
||||||
|
hasSuperEffectiveMove = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasSuperEffectiveMove;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ type BattleSide {
|
||||||
bool IsDefeated { get const; };
|
bool IsDefeated { get const; };
|
||||||
bool HasFled { get const; };
|
bool HasFled { get const; };
|
||||||
Battle@ Battle { get const; };
|
Battle@ Battle { get const; };
|
||||||
|
narray<Pokemon>@ Pokemon { get const; };
|
||||||
uint8 GetPokemonIndex(const Pokemon@ pokemon) const;
|
uint8 GetPokemonIndex(const Pokemon@ pokemon) const;
|
||||||
Pokemon@ GetPokemon(uint8 index) const;
|
Pokemon@ GetPokemon(uint8 index) const;
|
||||||
ref@ AddVolatile(const constString &in name);
|
ref@ AddVolatile(const constString &in name);
|
||||||
|
|
|
@ -19,6 +19,8 @@ type Pokemon {
|
||||||
float Weight { get const; set; };
|
float Weight { get const; set; };
|
||||||
float Height { get const; set; };
|
float Height { get const; set; };
|
||||||
const constString& ActiveAbility { get const; };
|
const constString& ActiveAbility { get const; };
|
||||||
|
uint64 TypesLength { get const; };
|
||||||
|
uint8 GetType(uint64 index) const;
|
||||||
bool HasHeldItem(const constString &in name) const;
|
bool HasHeldItem(const constString &in name) const;
|
||||||
void SetHeldItem(const constString &in name);
|
void SetHeldItem(const constString &in name);
|
||||||
void SetHeldItem(const Item@ item);
|
void SetHeldItem(const Item@ item);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
type TypeLibrary {
|
type TypeLibrary {
|
||||||
uint8 GetTypeId(const constString &in name) const;
|
uint8 GetTypeId(const constString &in name) const;
|
||||||
float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const;
|
float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const;
|
||||||
|
float GetEffectiveness(uint8 attackingType, Pokemon@ defender) const;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue