Add casting abilities for kirins

This commit is contained in:
Sollace 2023-10-09 23:43:59 +01:00
parent 1b0505375a
commit 8961cc2cff
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
9 changed files with 42 additions and 5 deletions

View file

@ -54,7 +54,7 @@ public record Race (Supplier<Composite> compositeSupplier, boolean canCast, Flig
public static final Race BAT = register("bat", false, FlightType.AVIAN, false, true, true);
public static final Race ALICORN = register("alicorn", true, FlightType.AVIAN, true, false, false);
public static final Race CHANGELING = register("changeling", false, FlightType.INSECTOID, false, false, true);
public static final Race KIRIN = register("kirin", false, FlightType.NONE, false, false, false);
public static final Race KIRIN = register("kirin", true, FlightType.NONE, false, false, false);
public static void bootstrap() {}

View file

@ -55,6 +55,7 @@ public interface Abilities {
// kirin
Ability<?> RAGE = register(new KirinRageAbility(), "rage", AbilitySlot.PRIMARY);
Ability<?> KIRIN_CAST = register(new KirinCastingAbility(), "kirin_cast", AbilitySlot.SECONDARY);
static <T extends Ability<?>> T register(T power, String name, AbilitySlot slot) {
Identifier id = Unicopia.id(name);

View file

@ -19,7 +19,7 @@ abstract class AbstractSpellCastingAbility implements Ability<Hit> {
@Override
public boolean canUse(Race race) {
return race.canCast();
return race.canCast() && race != Race.KIRIN;
}
@Override

View file

@ -0,0 +1,23 @@
package com.minelittlepony.unicopia.ability;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.particle.ParticleTypes;
public class KirinCastingAbility extends UnicornCastingAbility {
@Override
public boolean canUse(Race race) {
return race == Race.KIRIN;
}
@Override
public void coolDown(Pony player, AbilitySlot slot) {
player.spawnParticles(ParticleTypes.FLAME, 5);
}
@Override
protected boolean canCast(SpellType<?> type) {
return type == SpellType.FIRE_BOLT || type == SpellType.FLAME || type == SpellType.INFERNAL;
}
}

View file

@ -42,7 +42,11 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
@Override
public Optional<Hit> prepare(Pony player) {
return Hit.of(player.canCast() && player.getMagicalReserves().getMana().get() >= getCostEstimate(player));
TypedActionResult<CustomisedSpellType<?>> spell = player.getCharms().getSpellInHand(false);
return Hit.of(player.canCast()
&& player.getMagicalReserves().getMana().get() >= getCostEstimate(player)
&& (!spell.getResult().isAccepted() || canCast(spell.getValue().type()))
);
}
@Override
@ -94,7 +98,7 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
} else {
TypedActionResult<CustomisedSpellType<?>> newSpell = player.getCharms().getSpellInHand(true);
if (newSpell.getResult() != ActionResult.FAIL) {
if (newSpell.getResult() != ActionResult.FAIL && canCast(newSpell.getValue().type())) {
CustomisedSpellType<?> spell = newSpell.getValue();
boolean removed = player.getSpellSlot().removeWhere(s -> {
@ -122,6 +126,10 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
return true;
}
protected boolean canCast(SpellType<?> type) {
return true;
}
private TypedActionResult<ItemStack> getAmulet(Pony player) {
ItemStack stack = player.asEntity().getStackInHand(Hand.MAIN_HAND);

View file

@ -57,7 +57,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
@Override
public boolean canUse(Race race) {
return race.canCast();
return race.canCast() && race != Race.KIRIN;
}
@Override

View file

@ -380,6 +380,11 @@
"ability.unicopia.cast.with_spell.active": "Casting %s",
"ability.unicopia.cast.with_spell.hand": "Casting %s from hand",
"ability.unicopia.cast.with_spell.replacing": "Replace %s with %s",
"ability.unicopia.kirin_cast": "Cast Spell",
"ability.unicopia.kirin_cast.with_spell": "Cast %s",
"ability.unicopia.kirin_cast.with_spell.active": "Casting %s",
"ability.unicopia.kirin_cast.with_spell.hand": "Casting %s from hand",
"ability.unicopia.kirin_cast.with_spell.replacing": "Replace %s with %s",
"ability.unicopia.dispell": "Dispell Magic",
"ability.unicopia.teleport": "Teleport",
"ability.unicopia.teleport.far": "Teleport (Far)",

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB