Finish the A moves
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-10-30 18:45:42 +02:00
parent cb2f53a239
commit afe091eefa
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
14 changed files with 213 additions and 10 deletions

View File

@ -619,7 +619,10 @@
"category": "status",
"flags": [
"snatch"
]
],
"effect": {
"name": "Automize"
}
},
{
"name": "avalanche",
@ -634,7 +637,10 @@
"contact",
"protect",
"mirror"
]
],
"effect": {
"name": "ModifyDamageIfHitByTarget"
}
},
{
"name": "baby_doll_eyes",

View File

@ -0,0 +1,35 @@
namespace Gen7 {
[Side effect=AuroraVeil]
class AuroraVeilEffect : PkmnScript {
uint8 _turnsRemaining;
void SetTurns(uint8 turns){
_turnsRemaining = turns;
};
void OverrideIncomingDamage(ExecutingMove@ move, Pokemon@ target, uint8 hit, uint &inout damage) override {
if (move.GetHitData(target, hit).IsCritical){
return;
}
auto side = cast<BattleSide@>(GetOwner());
if (side.HasVolatile("Reflect") && move.UseMove.Category == MoveCategory::Physical){
return;
}
if (side.HasVolatile("LightScreen") && move.UseMove.Category == MoveCategory::Special){
return;
}
auto modifier = 2.0f;
if (target.Battle.PokemonPerSide > 1){
modifier = 1.5f;
}
damage = uint(damage / modifier);
};
void OnEndTurn() override {
auto side = cast<BattleSide@>(GetOwner());
if (_turnsRemaining == 0 || --_turnsRemaining == 0){
side.RemoveVolatile("AuroraVeil");
}
};
}
}

View File

@ -2,6 +2,7 @@ type Battle {
const BattleLibrary@ Library { get const; };
bool CanFlee { get const; };
uint CurrentTurn { get const; };
uint8 PokemonPerSide { get const; };
BattleRandom@ Random { get const; };
ChoiceQueue@ TurnQueue { get const; };
narray<BattleSide>@ Sides { get const; };
@ -9,6 +10,7 @@ type Battle {
BattleHistory@ History { get const; };
bool CanUse(BaseTurnChoice@ choice);
ref@ AddVolatile(const constString &in name);
ref@ GetVolatile(const constString &in name);
void RemoveVolatile(const constString &in name) const;
void SetWeather(const constString &in name) const;
void ClearWeather(const constString &in name) const;
@ -16,4 +18,5 @@ type Battle {
BattleSide@ GetBattleSide(uint8 index);
BattleParty@ GetParty(uint8 index);
BattleParty@ FindPartyForPokemon(Pokemon@ pokemon);
bool HasVolatile(const constString &in name) const;
}

View File

@ -1,6 +1,13 @@
type BattleSide {
bool SwapPositions(uint8 a, uint8 b);
uint8 SideIndex { get const; };
bool IsDefeated { get const; };
bool HasFled { get const; };
Battle@ Battle { get const; };
uint8 GetPokemonIndex(const Pokemon@ pokemon) const;
Pokemon@ GetPokemon(uint8 index) const;
ref@ AddVolatile(const constString &in name);
ref@ GetVolatile(const constString &in name);
void RemoveVolatile(const constString &in name) const;
bool HasVolatile(const constString &in name) const;
}

View File

@ -1,4 +1,7 @@
type HistoryElement {
const HistoryElement@ Previous { get const; };
HistoryElementKind Kind { get const; };
uint TurnNumber { get const; };
const DamageHistory@ opCast() const;
const AttackUseHistory@ opCast() const;
}

View File

@ -1,4 +1,7 @@
shared abstract class PkmnScript {
ref@ __owner;
ref@& GetOwner(){ return __owner; };
void OnInitialize(const narray<EffectParameter@>@){};
void Stack(){};
void OnRemove(){};
@ -27,13 +30,14 @@ shared abstract class PkmnScript {
void ModifyStatModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void ModifyDamageModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void OverrideDamage(ExecutingMove@, Pokemon@, uint8, uint &inout){};
void OverrideIncomingDamage(ExecutingMove@, Pokemon@, uint8, uint &inout){};
void ChangePriority(MoveTurnChoice@, int8 &inout){};
void OnFail(Pokemon@){};
void OnOpponentFail(Pokemon@){};
void PreventRunAway(FleeTurnChoice@, bool &inout){};
void PreventOpponentRunAway(FleeTurnChoice@, bool &inout){};
void PreventOpponentSwitch(SwitchTurnChoice@, bool &inout){};
void OnEndTurn(Pokemon@){};
void OnEndTurn(){};
void ModifyCriticalStage(ExecutingMove@, Pokemon@, uint8, uint8 &inout){};
void OverrideCriticalModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void OverrideSTABModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};

View File

@ -17,6 +17,8 @@ type Pokemon {
BattleSide@ BattleSide { get const; };
const constString& Status { get const; };
const narray<LearnedMove@>@ Moves { get const; };
float Weight { get const; set; };
float Height { get const; set; };
bool HasHeldItem(const constString &in name) const;
void SetHeldItem(const constString &in name);
void SetHeldItem(const Item@ item);

View File

@ -1,5 +1,5 @@
type narray<T> {
uint64 Length { get const; };
const T@ At(uint64 index) const;
const T@ opIndex(uint64) const;
const T@ get_opIndex(uint64) const property;
}

View File

@ -0,0 +1,79 @@
namespace Gen7 {
[Move effect=AuroraVeil]
class AuroraVeil : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
if (target.Battle.GetWeatherName() != "hail"){
move.GetHitData(target, hit).Fail();
return;
}
auto effect = cast<AuroraVeilEffect>(target.BattleSide.AddVolatile("AuroraVeil"));
if (move.User.HasHeldItem("light_clay")){
effect.SetTurns(8);
}
else{
effect.SetTurns(5);
}
}
}
}
#if TESTS
[Test name="AuroraVeil: Fails without hail"]
void AuroraVeil_FailsWithoutHail(){
auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto script = cast<Gen7::AuroraVeil>(CreateMoveScript("AuroraVeil"));
auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1);
script.OnSecondaryEffect(executingMove, mon1, 0x0);
Require(executingMove.GetHitData(mon1, 0x0).HasFailed);
}
[Test name="AuroraVeil: Works with hail"]
void AuroraVeil_WorksWithHail(){
auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100);
battle.SetWeather("hail");
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto script = cast<Gen7::AuroraVeil>(CreateMoveScript("AuroraVeil"));
auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1);
script.OnSecondaryEffect(executingMove, mon1, 0x0);
Require(!executingMove.GetHitData(mon1, 0x0).HasFailed);
Require(battle.GetBattleSide(0).HasVolatile("AuroraVeil"));
}
[Test name="AuroraVeil: Sets to 5 turns by default"]
void AuroraVeil_FiveTurnsByDefault(){
auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100);
battle.SetWeather("hail");
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto script = cast<Gen7::AuroraVeil>(CreateMoveScript("AuroraVeil"));
auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1);
script.OnSecondaryEffect(executingMove, mon1, 0x0);
Require(!executingMove.GetHitData(mon1, 0x0).HasFailed);
Require(battle.GetBattleSide(0).HasVolatile("AuroraVeil"));
auto effect = cast<Gen7::AuroraVeilEffect>(battle.GetBattleSide(0).GetVolatile("AuroraVeil"));
RequireEquals(5, effect._turnsRemaining);
}
[Test name="AuroraVeil: Sets to 8 turns with light clay"]
void AuroraVeil_EightTurnsWithLightClay(){
auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100);
battle.SetWeather("hail");
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
mon1.SetHeldItem("light_clay");
auto script = cast<Gen7::AuroraVeil>(CreateMoveScript("AuroraVeil"));
auto executingMove = CreateExecutingMove("aurora_veil", mon1, mon1);
script.OnSecondaryEffect(executingMove, mon1, 0x0);
Require(!executingMove.GetHitData(mon1, 0x0).HasFailed);
Require(battle.GetBattleSide(0).HasVolatile("AuroraVeil"));
auto effect = cast<Gen7::AuroraVeilEffect>(battle.GetBattleSide(0).GetVolatile("AuroraVeil"));
RequireEquals(8, effect._turnsRemaining);
}
#endif

16
Scripts/Moves/Automize.as Normal file
View File

@ -0,0 +1,16 @@
namespace Gen7 {
class Automize : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
auto originalSpeed = move.User.GetBoostedStat(Statistic::Speed);
auto originalWeight = move.User.Weight;
move.User.ChangeStatBoost(Statistic::Speed, 2);
if (move.User.GetBoostedStat(Statistic::Speed) != originalSpeed){
// This setter function protects against going below 0.1
move.User.Weight -= 100;
if (move.User.Weight != originalWeight){
// {Pokemon} became nimble text
}
}
}
}
}

View File

@ -0,0 +1,22 @@
namespace Gen7 {
// For moves such as Avalanche
[Move effect=ModifyDamageIfHitByTarget]
class ModifyDamageIfHitByTarget : PkmnScript {
void OverrideDamage(ExecutingMove@ move, Pokemon@ target, uint8 hit, uint &inout damage) override {
auto historyElement = move.User.Battle.History.TopElement;
auto turn = move.User.Battle.CurrentTurn;
while (historyElement !is null){
if (historyElement.TurnNumber < turn){
break;
}
if (historyElement.Kind == HistoryElementKind::AttackUse){
auto attackEvent = cast<const AttackUseHistory@>(historyElement);
if (attackEvent.Move.User is target && attackEvent.Move.IsPokemonTarget(move.User)){
damage *= 2;
break;
}
}
}
};
}
}

View File

@ -3,12 +3,16 @@ namespace Gen7 {
shared class HealEachEndOfTurnEffect : PkmnScript {
float _factor;
void OnEndTurn(Pokemon@ pokemon) override {
auto healAmount = pokemon.MaxHealth * _factor;
if (pokemon.HasHeldItem("big_root")){
void OnEndTurn() override {
auto target = cast<Pokemon@>(GetOwner());
if (target is null){
throw("target was null");
}
auto healAmount = target.MaxHealth * _factor;
if (target.HasHeldItem("big_root")){
healAmount *= 1.3;
}
pokemon.Heal(uint(healAmount));
target.Heal(uint(healAmount));
}
void SetBaseHealAmount(float factor){
@ -16,3 +20,19 @@ namespace Gen7 {
}
}
}
#if TESTS
[Test name="Heal Each End Of Turn effect: Heals on end of turn"]
void HealEachEndOfTurn_HealsOnEndOfTurn(){
auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100);
auto mon = battle.GetParty(0).Party.GetAtIndex(0);
mon.Damage(100, DamageSource::AttackDamage);
auto effect = cast<Gen7::HealEachEndOfTurnEffect@>(mon.AddVolatile("HealEachEndOfTurn"));
effect.SetBaseHealAmount(0.0625);
effect.OnEndTurn();
RequireEquals(215, mon.CurrentHealth);
}
#endif

6
Scripts/Weather/Hail.as Normal file
View File

@ -0,0 +1,6 @@
namespace Gen7 {
[Weather effect=Hail]
class Hail : PkmnScript {
// TODO
}
}

View File

@ -1,6 +1,6 @@
#!/bin/sh
TESTERVERSION=0.0.8
TESTERVERSION=0.0.10
# Get the release information from the api for the specified version
curl -X GET "https://git.p-epsilon.com/api/v1/repos/Deukhoofd/PokemonScriptTester/releases/tags/$TESTERVERSION" -H "accept: application/json" |