Loads of work on getting data ready.

This commit is contained in:
Deukhoofd 2021-03-28 20:22:46 +02:00
parent d3262e924d
commit 82ac1061fa
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
27 changed files with 19683 additions and 12390 deletions

View File

@ -3560,7 +3560,11 @@
"itemType": "medicine",
"flags": [],
"price": 200,
"flingPower": 30
"flingPower": 30,
"effect": {
"name": "heal",
"parameters": [20]
}
},
{
"name": "powder_jar",

18638
Moves.json

File diff suppressed because it is too large Load Diff

13176
Pokemon.json

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
shared interface BaseTurnChoice {
TurnChoiceKind Kind { get const; }
Pokemon@ User { get const; }
const Pokemon@ User { get const; }
MoveTurnChoice@ opCast();
SwitchTurnChoice@ opCast();
FleeTurnChoice@ opCast();
}

View File

@ -4,9 +4,10 @@ shared interface Battle {
bool CanFlee { get const; }
BattleRandom@ Random { get const; }
ChoiceQueue@ TurnQueue { get const; }
void AddVolatile(const constString &in name) const;
ref AddVolatile(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;
const constString& GetWeatherName() const;
BattleSide@ GetBattleSide(uint8 index);
}

View File

@ -0,0 +1,5 @@
shared interface BattleSide {
bool SwapPositions(uint8 a, uint8 b);
uint8 SideIndex { get const; }
uint8 GetPokemonIndex(const Pokemon@ pokemon) const;
}

View File

@ -0,0 +1,5 @@
shared interface FleeTurnChoice {
TurnChoiceKind Kind { get const; }
const Pokemon@ User { get const; }
BaseTurnChoice@ opImplCast();
}

View File

@ -4,4 +4,6 @@ shared interface HitData {
float Effectiveness { get const; }
uint Damage { get const; }
uint8 Type { get const; }
bool HasFailed { get const; }
void Fail();
}

View File

@ -0,0 +1,9 @@
shared abstract class ItemUseScript {
void OnInitialize(const EffectParameter@[] &in){};
bool IsItemUsable(){};
bool IsPokemonUseItem(){};
bool IsUseValidForPokemon(Pokemon@){};
bool IsHoldable(){};
void OnUse(){};
void OnPokemonUse(Pokemon@){};
}

View File

@ -1,6 +1,6 @@
shared interface MoveTurnChoice {
TurnChoiceKind Kind { get const; }
Pokemon@ User { get const; }
const Pokemon@ User { get const; }
LearnedMove@ Move { get const; }
int8 Priority { get const; }
BaseTurnChoice@ opImplCast();

View File

@ -4,6 +4,7 @@ shared abstract class PkmnScript {
void OnRemove(){};
void OnBeforeTurn(BaseTurnChoice@){};
void ChangeAttack(MoveTurnChoice@, constString &inout){};
void ModifyNumberOfHits(MoveTurnChoice@, uint8 &inout){};
void PreventAttack(ExecutingMove@, bool &inout){};
void FailAttack(ExecutingMove@, bool &inout){};
void StopBeforeAttack(ExecutingMove@, bool &inout){};
@ -26,6 +27,13 @@ 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 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 ModifyCriticalStage(ExecutingMove@, Pokemon@, uint8, uint8 &inout){};
void OverrideCriticalModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void OverrideSTABModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};

View File

@ -27,7 +27,8 @@ shared interface Pokemon {
uint GetBoostedStat(Statistic stat) const;
uint GetBaseStat(Statistic stat) const;
int8 GetStatBoost(Statistic stat) const;
void AddVolatile(const constString &in name) const;
ref AddVolatile(const constString &in name);
void RemoveVolatile(const constString &in name) const;
const Battle@ Battle { get const; }
Battle@ Battle { get const; }
BattleSide@ BattleSide { get const; }
}

View File

@ -1,7 +1,6 @@
shared interface SwitchTurnChoice {
TurnChoiceKind Kind { get const; }
Pokemon@ User { get const; }
const Pokemon@ User { get const; }
Pokemon@ NewPokemon { get const; }
MoveTurnChoice@ opCast();
BaseTurnChoice@ opImplCast();
}

View File

@ -0,0 +1,16 @@
shared interface dictionary {
void set(const string &in, const ?&in);
bool get(const string &in, ? &out) const;
void set(const string &in, const int64&in);
bool get(const string &in, int64 &out) const;
void set(const string &in, const double&in);
bool get(const string &in, double &out) const;
bool exists(const string &in) const;
bool isEmpty() const;
uint getSize() const;
bool delete(const string &in);
void deleteAll();
string[]@ getKeys() const;
dictionaryValue& opIndex(const string &in);
const dictionaryValue& opIndex(const string &in) const;
}

View File

@ -0,0 +1,8 @@
shared interface dictionaryValue {
dictionaryValue& opHndlAssign(const ? &in);
dictionaryValue& opHndlAssign(const dictionaryValue &in);
void opCast(? &out);
void opConv(? &out);
int64 opConv();
double opConv();
}

View File

@ -0,0 +1,26 @@
namespace Pokemon{
[ItemUse effect=heal]
class HealItem : ItemUseScript {
uint _amount;
void OnInitialize(const array<EffectParameter@> &in parameters) override {
_amount = uint(parameters[0].AsInt());
}
bool IsItemUsable() override {
return true;
}
bool IsPokemonUseItem() override {
return true;
}
bool IsUseValidForPokemon(Pokemon@ pokemon) override {
return pokemon.CurrentHealth < pokemon.MaxHealth;
}
void OnPokemonUse(Pokemon@ pkmn) override {
pkmn.Heal(_amount);
}
}
}

View File

@ -0,0 +1,26 @@
namespace Gen7 {
[Move effect=2_5HitMove]
class MultiHitMove : PkmnScript{
void ModifyNumberOfHits(MoveTurnChoice@ choice, uint8 &inout numberHits) override {
auto randValue = choice.User.Battle.Random.Get(6);
switch (randValue){
case 0:
case 1:
numberHits = 2;
break;
case 2:
case 3:
numberHits = 3;
break;
case 4:
numberHits = 4;
break;
case 5:
numberHits = 5;
break;
default:
throw("Invalid randValue");
}
}
}
}

View File

@ -0,0 +1,18 @@
namespace Gen7 {
[Move effect=ChangeAllTargetStats]
class ChangeAllTargetStats : PkmnScript{
int8 _amount;
void OnInitialize(const EffectParameter@[] &in parameters) override{
_amount = int8(parameters[0].AsInt());
}
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Attack, _amount);
target.ChangeStatBoost(Statistic::Defense, _amount);
target.ChangeStatBoost(Statistic::SpecialAttack, _amount);
target.ChangeStatBoost(Statistic::SpecialDefense, _amount);
target.ChangeStatBoost(Statistic::Speed, _amount);
}
}
}

View File

@ -0,0 +1,14 @@
namespace Gen7 {
[Move effect=ChangeTargetAtt]
class ChangeTargetAttack : PkmnScript{
int8 _amount;
void OnInitialize(const EffectParameter@[] &in parameters) override{
_amount = int8(parameters[0].AsInt());
}
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Attack, _amount);
}
}
}

View File

@ -1,14 +1,14 @@
namespace Gen7{
namespace Gen7 {
[Move effect=drain]
shared class DrainMove : PkmnScript{
private float _healModifier = 0;
void OnInitialize(const array<EffectParameter@> &in parameters) override{
void OnInitialize(const array<EffectParameter@> &in parameters) override {
_healModifier = parameters[0].AsFloat();
}
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
auto hitData = attack.GetAttackDataForTarget(target).GetHit(hit);
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
auto hitData = attack.GetHitData(target, hit);
auto damage = hitData.Damage;
float mod = _healModifier;
if (attack.User.HasHeldItem("big_root")){
@ -17,4 +17,4 @@ namespace Gen7{
attack.User.Heal(uint(damage * mod));
}
}
}
}

View File

@ -0,0 +1,15 @@
namespace Gen7 {
[Move effect=HealEachEndOfTurn]
shared class HealEachEndOfTurn : PkmnScript {
float _amount;
void OnInitialize(const EffectParameter@[] &in parameters) override{
_amount = float(parameters[0].AsFloat()) / 100;
}
void OnSecondaryEffect(ExecutingMove@, Pokemon@ pokemon, uint8) override {
auto script = cast<HealEachEndOfTurnEffect>(pokemon.AddVolatile("HealEachEndOfTurn"));
script.SetBaseHealAmount(_amount);
}
}
}

View File

@ -0,0 +1,9 @@
namespace Gen7 {
[Move effect=PreventFoeRunning]
shared class PreventFoeRunning : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
auto script = cast<PreventFoeRunningEffect>(move.User.AddVolatile("PreventFoeRunning"));
script.SetLockedOpponent(target);
}
}
}

View File

@ -0,0 +1,8 @@
namespace Gen7 {
[Move effect=Struggle]
shared class Struggle : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
attack.User.Damage(uint(attack.User.MaxHealth / 4), DamageSource::Struggle);
}
}
}

View File

@ -0,0 +1,18 @@
namespace Gen7 {
[Move effect=SwapWithTarget]
shared class SwapWithTarget : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
auto userSide = move.User.BattleSide;
auto targetSide = target.BattleSide;
if (userSide !is targetSide){
move.GetHitData(target, hit).Fail();
return;
}
auto userIndex = userSide.GetPokemonIndex(move.User);
auto targetIndex = userSide.GetPokemonIndex(target);
if (!userSide.SwapPositions(userIndex, targetIndex)){
move.GetHitData(target, hit).Fail();
}
}
}
}

View File

@ -3,6 +3,7 @@ namespace Pokemon{
class Flinch : PkmnScript{
void PreventAttack(ExecutingMove@ attack, bool& result) override {
result = true;
attack.User.RemoveVolatile("flinch");
}
}
}

View File

@ -0,0 +1,18 @@
namespace Gen7 {
[Pokemon effect=HealEachEndOfTurn]
shared class HealEachEndOfTurnEffect : PkmnScript {
float _factor;
void OnEndTurn(Pokemon@ pokemon) override {
auto healAmount = pokemon.MaxHealth * _factor;
if (pokemon.HasHeldItem("big_root")){
healAmount *= 1.3;
}
pokemon.Heal(uint(healAmount));
}
void SetBaseHealAmount(float factor){
_factor = factor;
}
}
}

View File

@ -0,0 +1,20 @@
namespace Gen7 {
[Pokemon effect=PreventFoeRunning]
shared class PreventFoeRunningEffect : PkmnScript {
Pokemon@[] _trappedOpponents;
void PreventOpponentRunAway(FleeTurnChoice@ choice, bool &inout o) override {
for(uint i = 0; i < _trappedOpponents.length; i++)
{
if (_trappedOpponents[i] is choice.User){
o = true;
break;
}
}
}
void SetLockedOpponent(Pokemon@ opponent){
_trappedOpponents.insertLast(opponent);
}
}
}