More abilities
All checks were successful
Build / Build (push) Successful in 49s

This commit is contained in:
2025-06-09 15:24:37 +02:00
parent 074f92bfc0
commit 1579d46671
23 changed files with 480 additions and 41 deletions

View File

@@ -41,6 +41,11 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// </summary>
IForm? DisplayForm { get; }
/// <summary>
/// Sets the display species and form of the Pokemon. This is used for abilities like Illusion.
/// </summary>
void SetDisplaySpecies(ISpecies? species, IForm? form);
/// <summary>
/// The current level of the Pokemon.
/// </summary>
@@ -90,14 +95,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// <summary>
/// The weight of the Pokemon in kilograms.
/// </summary>
float WeightInKg { get; set; }
/// <summary>
/// Sets the weight of the Pokémon in kilograms. Returns whether the weight was changed.
/// </summary>
/// <param name="weightInKg">The new weight in kilograms</param>
/// <returns></returns>
public bool ChangeWeightInKgBy(float weightInKg);
float WeightInKg { get; }
/// <summary>
/// The height of the Pokémon in meters.
@@ -511,7 +509,6 @@ public class PokemonImpl : ScriptSource, IPokemon
Types = form.Types.ToList();
Experience = library.StaticLibrary.GrowthRates.CalculateExperience(species.GrowthRate, level);
WeightInKg = form.Weight;
HeightInMeters = form.Height;
Happiness = species.BaseHappiness;
Volatile = new ScriptSet(this);
@@ -546,7 +543,6 @@ public class PokemonImpl : ScriptSource, IPokemon
}
CurrentHealth = serializedPokemon.CurrentHealth;
WeightInKg = form.Weight;
HeightInMeters = form.Height;
Happiness = serializedPokemon.Happiness;
IndividualValues = serializedPokemon.IndividualValues.ToIndividualValueStatisticSet();
@@ -599,6 +595,18 @@ public class PokemonImpl : ScriptSource, IPokemon
/// <inheritdoc />
public IForm? DisplayForm { get; set; }
/// <inheritdoc />
public void SetDisplaySpecies(ISpecies? species, IForm? form)
{
DisplaySpecies = species;
DisplayForm = form;
BattleData?.Battle.EventHook.Invoke(new DisplaySpeciesChangeEvent(this, species, form)
{
BatchId = new EventBatchId(),
});
}
/// <inheritdoc />
public LevelInt Level { get; private set; }
@@ -660,18 +668,18 @@ public class PokemonImpl : ScriptSource, IPokemon
public uint CurrentHealth { get; private set; }
/// <inheritdoc />
public float WeightInKg { get; set; }
/// <inheritdoc />
public bool ChangeWeightInKgBy(float weightInKg)
public float WeightInKg
{
if (WeightInKg <= 0.1f)
return false;
var newWeight = WeightInKg + weightInKg;
if (newWeight <= 0.1f)
newWeight = 0.1f;
WeightInKg = newWeight;
return true;
get
{
var weight = Form.Weight;
if (BattleData is not null)
// ReSharper disable once AccessToModifiedClosure
this.RunScriptHook(script => script.ModifyWeight(ref weight));
if (weight < 0.1f)
weight = 0.1f;
return weight;
}
}
/// <inheritdoc />
@@ -958,7 +966,6 @@ public class PokemonImpl : ScriptSource, IPokemon
Form = form;
Types = form.Types.ToList();
WeightInKg = form.Weight;
HeightInMeters = form.Height;
var newAbility = Form.GetAbility(AbilityIndex);
@@ -1216,7 +1223,6 @@ public class PokemonImpl : ScriptSource, IPokemon
if (!onBattleField)
{
Volatile.Clear();
WeightInKg = Form.Weight;
HeightInMeters = Form.Height;
Types = Form.Types;
OverrideAbility = null;
@@ -1241,7 +1247,6 @@ public class PokemonImpl : ScriptSource, IPokemon
var battleData = BattleData;
BattleData = null;
Volatile.Clear();
WeightInKg = Form.Weight;
HeightInMeters = Form.Height;
Types = Form.Types;
OverrideAbility = null;