Implements clearbody, update changestatboost interface
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2022-03-12 11:45:18 +01:00
parent 1fdca38b29
commit 262152b81d
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
15 changed files with 33 additions and 20 deletions

View File

@ -65,7 +65,9 @@
"effect": "DoubleSpeedInWeather", "effect": "DoubleSpeedInWeather",
"parameters": ["HarshSunlight"] "parameters": ["HarshSunlight"]
}, },
"clear_body": {}, "clear_body": {
"effect": "PreventStatLowering"
},
"cloud_nine": {}, "cloud_nine": {},
"color_change": {}, "color_change": {},
"comatose": {}, "comatose": {},

View File

@ -2,7 +2,7 @@ namespace Gen7 {
class AngerPoint : PkmnScript { class AngerPoint : PkmnScript {
void OnIncomingHit(ExecutingMove@ move, Pokemon@ target, uint8 hit) override { void OnIncomingHit(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
if (move.GetHitData(target, hit).IsCritical){ if (move.GetHitData(target, hit).IsCritical){
target.ChangeStatBoost(Statistic::Attack, 12); target.ChangeStatBoost(Statistic::Attack, 12, true);
} }
} }
} }

View File

@ -29,7 +29,7 @@ namespace Gen7 {
if (user.GetFlatStat(Statistic::Speed) > user.GetFlatStat(Statistic::HP)) { if (user.GetFlatStat(Statistic::Speed) > user.GetFlatStat(Statistic::HP)) {
increaseStat = Statistic::Speed; increaseStat = Statistic::Speed;
} }
user.ChangeStatBoost(increaseStat, 1); user.ChangeStatBoost(increaseStat, 1, true);
} }
} }
} }

View File

@ -3,7 +3,7 @@ namespace Gen7 {
class Berserk : PkmnScript { class Berserk : PkmnScript {
void OnDamage(Pokemon@ pokemon, DamageSource, uint old, uint new) override { void OnDamage(Pokemon@ pokemon, DamageSource, uint old, uint new) override {
if (float(old) / pokemon.MaxHealth >= 0.5f && float(new) / pokemon.MaxHealth < 0.5f) { if (float(old) / pokemon.MaxHealth >= 0.5f && float(new) / pokemon.MaxHealth < 0.5f) {
pokemon.ChangeStatBoost(Statistic::SpecialDefense, 1); pokemon.ChangeStatBoost(Statistic::SpecialDefense, 1, true);
} }
} }
} }

View File

@ -1,8 +1,8 @@
namespace Gen7 { namespace Gen7 {
[Ability effect=PreventDefLowering] [Ability effect=PreventDefLowering]
class PreventDefLowering : PkmnScript { class PreventDefLowering : PkmnScript {
void PreventStatBoostChange(Pokemon@, Statistic stat, int8 amount, bool &inout prevent) override { void PreventStatBoostChange(Pokemon@, Statistic stat, int8 amount, bool selfInflicted, bool &inout prevent) override {
if (stat == Statistic::Defense && amount < 0) { if (stat == Statistic::Defense && amount < 0 && !selfInflicted) {
prevent = true; prevent = true;
} }
} }

View File

@ -0,0 +1,10 @@
namespace Gen7 {
[Ability effect=PreventStatLowering]
class PreventStatLowering : PkmnScript {
void PreventStatBoostChange(Pokemon@, Statistic stat, int8 amount, bool selfInflicted, bool &inout prevent) override {
if (amount < 0 && !selfInflicted) {
prevent = true;
}
}
}
}

View File

@ -1,7 +1,8 @@
shared abstract class PkmnScript { shared abstract class PkmnScript {
ref@ __owner; ref@ __owner;
ref@& GetOwner(){ return __owner; }; const ref@& GetOwner(){ return __owner; };
void SetOwner(ref@){};
void OnInitialize(const BattleLibrary@, const narray<EffectParameter@>@){}; void OnInitialize(const BattleLibrary@, const narray<EffectParameter@>@){};
void Stack(){}; void Stack(){};
void OnRemove(){}; void OnRemove(){};
@ -20,7 +21,7 @@ shared abstract class PkmnScript {
void BlockCritical(ExecutingMove@, Pokemon@, uint8, bool &inout){}; void BlockCritical(ExecutingMove@, Pokemon@, uint8, bool &inout){};
void OnIncomingHit(ExecutingMove@, Pokemon@, uint8){}; void OnIncomingHit(ExecutingMove@, Pokemon@, uint8){};
void OnFaintingOpponent(ExecutingMove@, Pokemon@, uint8){}; void OnFaintingOpponent(ExecutingMove@, Pokemon@, uint8){};
void PreventStatBoostChange(Pokemon@, Statistic, int8, bool &inout){}; void PreventStatBoostChange(Pokemon@, Statistic, int8, bool, bool &inout){};
void ModifyStatBoostChange(Pokemon@, Statistic, int8 &inout){}; void ModifyStatBoostChange(Pokemon@, Statistic, int8 &inout){};
void PreventSecondaryEffects(ExecutingMove@, Pokemon@, uint8, bool &inout){}; void PreventSecondaryEffects(ExecutingMove@, Pokemon@, uint8, bool &inout){};
void OnSecondaryEffect(ExecutingMove@, Pokemon@, uint8){}; void OnSecondaryEffect(ExecutingMove@, Pokemon@, uint8){};

View File

@ -30,7 +30,7 @@ type Pokemon {
void Damage(uint type, DamageSource source); void Damage(uint type, DamageSource source);
void Heal(uint type); void Heal(uint type);
void OverrideActiveAbility(const string &in ability); void OverrideActiveAbility(const string &in ability);
void ChangeStatBoost(Statistic stat, int8 amount); void ChangeStatBoost(Statistic stat, int8 amount, bool selfInflicted);
uint GetFlatStat(Statistic stat) const; uint GetFlatStat(Statistic stat) const;
uint GetBoostedStat(Statistic stat) const; uint GetBoostedStat(Statistic stat) const;
uint GetBaseStat(Statistic stat) const; uint GetBaseStat(Statistic stat) const;

View File

@ -7,7 +7,7 @@ namespace Gen7{
return; return;
} }
auto randStat = Statistic(target.Battle.Random.Get(1, 6)); auto randStat = Statistic(target.Battle.Random.Get(1, 6));
target.ChangeStatBoost(randStat, 2); target.ChangeStatBoost(randStat, 2, false);
}; };
} }
} }

View File

@ -3,7 +3,7 @@ namespace Gen7 {
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override { void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
auto originalSpeed = move.User.GetBoostedStat(Statistic::Speed); auto originalSpeed = move.User.GetBoostedStat(Statistic::Speed);
auto originalWeight = move.User.Weight; auto originalWeight = move.User.Weight;
move.User.ChangeStatBoost(Statistic::Speed, 2); move.User.ChangeStatBoost(Statistic::Speed, 2, true);
if (move.User.GetBoostedStat(Statistic::Speed) != originalSpeed){ if (move.User.GetBoostedStat(Statistic::Speed) != originalSpeed){
// This setter function protects against going below 0.1 // This setter function protects against going below 0.1
move.User.Weight -= 100; move.User.Weight -= 100;

View File

@ -8,11 +8,11 @@ namespace Gen7 {
} }
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{ void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Attack, _amount); target.ChangeStatBoost(Statistic::Attack, _amount, attack.User is target);
target.ChangeStatBoost(Statistic::Defense, _amount); target.ChangeStatBoost(Statistic::Defense, _amount, attack.User is target);
target.ChangeStatBoost(Statistic::SpecialAttack, _amount); target.ChangeStatBoost(Statistic::SpecialAttack, _amount, attack.User is target);
target.ChangeStatBoost(Statistic::SpecialDefense, _amount); target.ChangeStatBoost(Statistic::SpecialDefense, _amount, attack.User is target);
target.ChangeStatBoost(Statistic::Speed, _amount); target.ChangeStatBoost(Statistic::Speed, _amount, attack.User is target);
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace Gen7 {
} }
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{ void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Attack, _amount); target.ChangeStatBoost(Statistic::Attack, _amount, attack.User is target);
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace Gen7 {
} }
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{ void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Defense, _amount); target.ChangeStatBoost(Statistic::Defense, _amount, attack.User is target);
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace Gen7 {
} }
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{ void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::SpecialDefense, _amount); target.ChangeStatBoost(Statistic::SpecialDefense, _amount, attack.User is target);
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace Gen7 {
} }
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{ void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Speed, _amount); target.ChangeStatBoost(Statistic::Speed, _amount, attack.User is target);
} }
} }
} }