From baae9377eff4a4a860e24259530e37f89bd6f3e3 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 20 Nov 2021 14:43:13 +0100 Subject: [PATCH] Adds Arena Trap ability --- Scripts/Abilities/ArenaTrap.as | 15 +++++++++++++++ Scripts/Interfaces/Pokemon.astypedef | 3 ++- Scripts/Pokemon/RaisedUp.as | 5 +++++ Scripts/Utilities/SpecialStates.as | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Scripts/Abilities/ArenaTrap.as create mode 100644 Scripts/Pokemon/RaisedUp.as create mode 100644 Scripts/Utilities/SpecialStates.as diff --git a/Scripts/Abilities/ArenaTrap.as b/Scripts/Abilities/ArenaTrap.as new file mode 100644 index 0000000..16adbcb --- /dev/null +++ b/Scripts/Abilities/ArenaTrap.as @@ -0,0 +1,15 @@ +namespace Gen7 { + class ArenaTrap : PkmnScript { + void PreventOpponentRunAway(FleeTurnChoice@ choice, bool &inout block){ + if (block) return; + if (SpecialStates::IsRaised(choice.User)) return; + block = true; + } + + void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool &inout block){ + if (block) return; + if (SpecialStates::IsRaised(choice.User)) return; + block = true; + } + } +} \ No newline at end of file diff --git a/Scripts/Interfaces/Pokemon.astypedef b/Scripts/Interfaces/Pokemon.astypedef index 28fbc58..0a63ac7 100644 --- a/Scripts/Interfaces/Pokemon.astypedef +++ b/Scripts/Interfaces/Pokemon.astypedef @@ -26,6 +26,7 @@ type Pokemon { void SetHeldItem(const Item@ item); string Nickname { get const; }; bool HasType(uint8 type) const; + bool HasType(const constString &in type) const; void Damage(uint type, DamageSource source); void Heal(uint type); void OverrideActiveAbility(const string &in ability); @@ -34,7 +35,7 @@ type Pokemon { uint GetBoostedStat(Statistic stat) const; uint GetBaseStat(Statistic stat) const; int8 GetStatBoost(Statistic stat) const; - bool HasVolatile(const constString &in name); + bool HasVolatile(const constString &in name) const; ref@ AddVolatile(const constString &in name); void RemoveVolatile(const constString &in name) const; void ClearStatus() const; diff --git a/Scripts/Pokemon/RaisedUp.as b/Scripts/Pokemon/RaisedUp.as new file mode 100644 index 0000000..0183c2a --- /dev/null +++ b/Scripts/Pokemon/RaisedUp.as @@ -0,0 +1,5 @@ +namespace Gen7 { + // Empty class to tag the Pokemon as raised up. + [Pokemon effect=RaisedUp] + class RaisedUp : PkmnScript {} +} \ No newline at end of file diff --git a/Scripts/Utilities/SpecialStates.as b/Scripts/Utilities/SpecialStates.as new file mode 100644 index 0000000..980f4dd --- /dev/null +++ b/Scripts/Utilities/SpecialStates.as @@ -0,0 +1,14 @@ +namespace Gen7 { + namespace SpecialStates { + bool IsRaised(const Pokemon@ pokemon){ + if (pokemon.HasType("flying")){ + return true; + } + if (pokemon.HasVolatile("RaisedUp")){ + return true; + } + + return false; + } + } +} \ No newline at end of file