Change level effects to be scaled so we can allow arbitrarily high caster levels

This commit is contained in:
Sollace 2022-09-01 22:28:04 +02:00
parent bb09feca7e
commit 0bc9f447f6
15 changed files with 23 additions and 19 deletions

View file

@ -32,6 +32,10 @@ public interface Levelled {
void set(int level); void set(int level);
default float getScaled(float max) {
return (1 + ((float)get() / getMax())) * max;
}
default boolean canLevelUp() { default boolean canLevelUp() {
int max = getMax(); int max = getMax();
return max < 0 || get() < max; return max < 0 || get() < max;

View file

@ -88,7 +88,7 @@ public class RainboomAbilitySpell extends AbstractSpell {
((Pony)source).getMagicalReserves().getExhaustion().multiply(0.2F); ((Pony)source).getMagicalReserves().getExhaustion().multiply(0.2F);
} }
return !source.getEntity().isRemoved() && age++ < 90 + 7 * (source.getLevel().get() + 1); return !source.getEntity().isRemoved() && age++ < 90 + 7 * source.getLevel().getScaled(9);
} }
private boolean canBreak(BlockPos pos, LivingEntity entity) { private boolean canBreak(BlockPos pos, LivingEntity entity) {

View file

@ -36,7 +36,7 @@ public class AttractiveSpell extends ShieldSpell implements ProjectileSpell {
@Override @Override
public double getDrawDropOffRange(Caster<?> caster) { public double getDrawDropOffRange(Caster<?> caster) {
return 10 + (caster.getLevel().get() * 2); return 10 + (caster.getLevel().getScaled(8) * 2);
} }
@Override @Override

View file

@ -25,7 +25,7 @@ public class AwkwardSpell extends AbstractSpell {
@Override @Override
public boolean tick(Caster<?> source, Situation situation) { public boolean tick(Caster<?> source, Situation situation) {
if (source.isClient()) { if (source.isClient()) {
source.spawnParticles(new Sphere(false, (1 + source.getLevel().get()) * 8), 10, pos -> { source.spawnParticles(new Sphere(false, (1 + source.getLevel().getScaled(8)) * 8), 10, pos -> {
List<Identifier> names = new ArrayList<>(Registry.PARTICLE_TYPE.getIds()); List<Identifier> names = new ArrayList<>(Registry.PARTICLE_TYPE.getIds());

View file

@ -67,7 +67,7 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpel
} }
protected void generateParticles(Caster<?> source) { protected void generateParticles(Caster<?> source) {
source.spawnParticles(new Sphere(false, Math.max(0, 4 + getTraits().get(Trait.POWER))), (1 + source.getLevel().get()) * 6, pos -> { source.spawnParticles(new Sphere(false, Math.max(0, 4 + getTraits().get(Trait.POWER))), (int)(1 + source.getLevel().getScaled(8)) * 6, pos -> {
source.addParticle(ParticleTypes.LARGE_SMOKE, pos, Vec3d.ZERO); source.addParticle(ParticleTypes.LARGE_SMOKE, pos, Vec3d.ZERO);
}); });
} }

View file

@ -34,7 +34,7 @@ public class InfernoSpell extends FireSpell {
World w = source.getReferenceWorld(); World w = source.getReferenceWorld();
if (!w.isClient) { if (!w.isClient) {
int radius = 4 + (source.getLevel().get() * 4); float radius = 4 + (source.getLevel().getScaled(4) * 4);
Shape shape = new Sphere(false, radius); Shape shape = new Sphere(false, radius);
Vec3d origin = source.getOriginVector(); Vec3d origin = source.getOriginVector();

View file

@ -50,7 +50,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
@Override @Override
public boolean tick(Caster<?> source, Situation situation) { public boolean tick(Caster<?> source, Situation situation) {
float radius = (source.getLevel().get() + 1) * 4 + getTraits().get(Trait.POWER); float radius = source.getLevel().getScaled(4) * 4 + getTraits().get(Trait.POWER);
if (radius <= 0) { if (radius <= 0) {
return false; return false;

View file

@ -87,7 +87,7 @@ public class ShieldSpell extends AbstractSpell {
long costMultiplier = applyEntities(source); long costMultiplier = applyEntities(source);
if (costMultiplier > 0) { if (costMultiplier > 0) {
double cost = 2 + source.getLevel().get(); double cost = 2 - source.getLevel().getScaled(2);
cost *= costMultiplier / ((1 + source.getLevel().get()) * 3F); cost *= costMultiplier / ((1 + source.getLevel().get()) * 3F);
cost /= 2.725D; cost /= 2.725D;
@ -107,7 +107,7 @@ public class ShieldSpell extends AbstractSpell {
public double getDrawDropOffRange(Caster<?> source) { public double getDrawDropOffRange(Caster<?> source) {
float multiplier = source.getMaster() != null && source.getMaster().isSneaking() ? 1 : 2; float multiplier = source.getMaster() != null && source.getMaster().isSneaking() ? 1 : 2;
float min = 4 + getTraits().get(Trait.POWER); float min = 4 + getTraits().get(Trait.POWER);
return (min + (source.getLevel().get() * 2)) / multiplier; return (min + (source.getLevel().getScaled(8) * 2)) / multiplier;
} }
protected boolean isValidTarget(Caster<?> source, Entity entity) { protected boolean isValidTarget(Caster<?> source, Entity entity) {

View file

@ -52,7 +52,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
} }
if (source.isClient()) { if (source.isClient()) {
int radius = 4 + source.getLevel().get(); float radius = 4 + source.getLevel().getScaled(5);
int direction = isFriendlyTogether(source) ? 1 : -1; int direction = isFriendlyTogether(source) ? 1 : -1;
source.spawnParticles(new Sphere(true, radius, 1, 0, 1), 1, pos -> { source.spawnParticles(new Sphere(true, radius, 1, 0, 1), 1, pos -> {
@ -79,7 +79,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
} }
private Stream<LivingEntity> getTargets(Caster<?> source) { private Stream<LivingEntity> getTargets(Caster<?> source) {
return VecHelper.findInRange(null, source.getReferenceWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity)) return VecHelper.findInRange(null, source.getReferenceWorld(), source.getOriginVector(), 4 + source.getLevel().getScaled(6), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity))
.stream() .stream()
.map(e -> (LivingEntity)e); .map(e -> (LivingEntity)e);
} }
@ -101,7 +101,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
setDirty(); setDirty();
} }
} else { } else {
e.heal((float)Math.min(0.5F * (1 + source.getLevel().get()), maxHealthGain * 0.6)); e.heal((float)Math.min(source.getLevel().getScaled(e.getHealth()) / 2F, maxHealthGain * 0.6));
ParticleUtils.spawnParticle(e.world, new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.getPos(), Vec3d.ZERO); ParticleUtils.spawnParticle(e.world, new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.getPos(), Vec3d.ZERO);
} }
}); });

View file

@ -42,7 +42,7 @@ class ManaRingSlot extends Slot {
float max = mana.getMana().getMax(); float max = mana.getMana().getMax();
cost *= 10; cost *= 10;
cost /= 1 + pony.getLevel().get(); cost /= 1 + pony.getLevel().getScaled(3);
int color = cost / max > percent ? 0xFF000099 : 0xFFFF0099; int color = cost / max > percent ? 0xFF000099 : 0xFFFF0099;

View file

@ -31,7 +31,7 @@ public class GhastBehaviour extends MobBehaviour<GhastEntity> {
rot.getX(), rot.getX(),
rot.getY(), rot.getY(),
rot.getZ(), rot.getZ(),
entity.getFireballStrength() * (player.getLevel().get() + 1) (int)player.getLevel().getScaled(entity.getFireballStrength())
); );
proj.updatePosition( proj.updatePosition(
entity.getX() + rot.x * 4, entity.getX() + rot.x * 4,

View file

@ -85,9 +85,9 @@ public class ManaContainer implements MagicReserves, Tickable {
@Override @Override
public void set(float value) { public void set(float value) {
float diff = value - get(); float diff = value - get();
if (diff < 0) { if (diff > 0) {
if (pony.getLevel().canLevelUp()) { if (pony.getLevel().canLevelUp()) {
xp.add(-diff / (float)Math.pow(1000, 1 + pony.getLevel().get())); xp.add(diff / (float)Math.pow(1000, 1 + pony.getLevel().get()));
if (xp.getPercentFill() >= 1) { if (xp.getPercentFill() >= 1) {
pony.getLevel().add(1); pony.getLevel().add(1);
xp.set(0); xp.set(0);

View file

@ -32,7 +32,7 @@ class PlayerLevelStore implements Levelled.LevelStore {
@Override @Override
public int getMax() { public int getMax() {
return 3; return 900;
} }
@Override @Override

View file

@ -392,7 +392,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
} }
private void tickNaturalFlight(MutableVector velocity) { private void tickNaturalFlight(MutableVector velocity) {
int level = pony.getLevel().get() + 1; float level = pony.getLevel().getScaled(5) + 1;
if (ticksInAir > (level * 100)) { if (ticksInAir > (level * 100)) {
Bar mana = pony.getMagicalReserves().getMana(); Bar mana = pony.getMagicalReserves().getMana();
@ -482,7 +482,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
private void moveFlying(MutableVector velocity) { private void moveFlying(MutableVector velocity) {
double motion = getHorizontalMotion(); double motion = getHorizontalMotion();
float forward = 0.000015F * (1 + (pony.getLevel().get() / 10F)) * (float)Math.sqrt(motion); float forward = 0.000015F * (1 + (pony.getLevel().getScaled(10) / 10F)) * (float)Math.sqrt(motion);
// vertical drop due to gravity // vertical drop due to gravity
forward += 0.005F; forward += 0.005F;

View file

@ -411,7 +411,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
if (!entity.isCreative() && !entity.isSpectator()) { if (!entity.isCreative() && !entity.isSpectator()) {
if (extraProtection) { if (extraProtection) {
distance /= (getLevel().get() + 1); distance /= (getLevel().getScaled(3) + 1);
if (entity.isSneaking()) { if (entity.isSneaking()) {
distance /= 2; distance /= 2;
} }