This commit is contained in:
@@ -1840,6 +1840,9 @@
|
||||
"price": 3000,
|
||||
"additionalData": {
|
||||
"flingPower": 30
|
||||
},
|
||||
"effect": {
|
||||
"name": "evolution_use"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -4591,6 +4594,12 @@
|
||||
"parameters": {
|
||||
"heal_amount": 20
|
||||
}
|
||||
},
|
||||
"battleEffect": {
|
||||
"name": "healing_item",
|
||||
"parameters": {
|
||||
"healAmount": 20
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
54
Plugins/PkmnLib.Plugin.Gen7/Scripts/Items/EvolutionItem.cs
Normal file
54
Plugins/PkmnLib.Plugin.Gen7/Scripts/Items/EvolutionItem.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using PkmnLib.Static.Species;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Items;
|
||||
|
||||
[ItemScript("evolution_use")]
|
||||
public class EvolutionItem : ItemScript
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public EvolutionItem(IItem item) : base(item)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsItemUsable => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool RequiresTarget => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTargetValid(IPokemon target)
|
||||
{
|
||||
foreach (var x in target.Species.EvolutionData)
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case ItemUseEvolution itemUseEvolution when itemUseEvolution.Item == Item.Name:
|
||||
return true;
|
||||
case ItemGenderEvolution itemGenderEvolution when itemGenderEvolution.Item == Item.Name:
|
||||
return itemGenderEvolution.Gender == target.Gender;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
{
|
||||
var evolutionData = target.Species.EvolutionData.FirstOrDefault(x =>
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case ItemUseEvolution itemUseEvolution when itemUseEvolution.Item == Item.Name:
|
||||
case ItemGenderEvolution itemGenderEvolution when itemGenderEvolution.Item == Item.Name:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (evolutionData == null)
|
||||
return;
|
||||
|
||||
target.EvolveTo(evolutionData, eventHook);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class HealingItem : ItemScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTargetValid(IPokemon target) => !target.IsFainted;
|
||||
public override bool IsTargetValid(IPokemon target) => !target.IsFainted && target.CurrentHealth < target.MaxHealth;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
|
||||
Reference in New Issue
Block a user