diff --git a/Abilities.json b/Abilities.json index 29171f2..a0fe8ff 100644 --- a/Abilities.json +++ b/Abilities.json @@ -68,8 +68,12 @@ "clear_body": { "effect": "PreventStatLowering" }, - "cloud_nine": {}, - "color_change": {}, + "cloud_nine": { + "effect": "SuppressWeather" + }, + "color_change": { + "effect": "ColorChange" + }, "comatose": {}, "competitive": {}, "compound_eyes": {}, diff --git a/Scripts/Abilities/ColorChange.as b/Scripts/Abilities/ColorChange.as new file mode 100644 index 0000000..b54cb79 --- /dev/null +++ b/Scripts/Abilities/ColorChange.as @@ -0,0 +1,15 @@ +namespace Gen7 { + [Ability effect=ColorChange] + class ColorChange : PkmnScript { + void OnIncomingHit(ExecutingMove@ move, Pokemon@ target, uint8 hit) override{ + // Color Change now activates after the last hit of a multi-strike move. + if (move.NumberOfHits - 1 != hit) + return; + // Color Change does not activate if the Pokémon is hit by a move of the same type as itself, even if the Pokémon is dual-typed + if (!target.HasType(move.UseMove.Type)){ + // Color Change will change the Pokémon's own type to the type of the move that it was hit by + target.SetType(0, move.UseMove.Type); + } + } + } +} \ No newline at end of file diff --git a/Scripts/Interfaces/ExecutingMove.astypedef b/Scripts/Interfaces/ExecutingMove.astypedef index 470e47f..56ae98e 100644 --- a/Scripts/Interfaces/ExecutingMove.astypedef +++ b/Scripts/Interfaces/ExecutingMove.astypedef @@ -2,6 +2,7 @@ type ExecutingMove { Pokemon@ User { get const; }; LearnedMove@ Move { get const; }; MoveData@ UseMove { get const; }; + uint8 NumberOfHits { get const; }; HitData@ GetHitData(Pokemon@ target, uint8 hit) const; bool IsPokemonTarget(Pokemon@ pkmn) const; } diff --git a/Scripts/Interfaces/Pokemon.astypedef b/Scripts/Interfaces/Pokemon.astypedef index 2a390d3..d4b4dda 100644 --- a/Scripts/Interfaces/Pokemon.astypedef +++ b/Scripts/Interfaces/Pokemon.astypedef @@ -21,6 +21,7 @@ type Pokemon { const constString& ActiveAbility { get const; }; uint64 TypesLength { get const; }; uint8 GetType(uint64 index) const; + void SetType(uint8 index, uint8 type); bool HasHeldItem(const constString &in name) const; void SetHeldItem(const constString &in name); void SetHeldItem(const Item@ item);