Bat pony screech strength now scales to however long you hold the key down

This commit is contained in:
Sollace 2023-08-16 20:55:38 +01:00
parent 554bca3831
commit 56e3807770
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
6 changed files with 80 additions and 19 deletions

View file

@ -24,6 +24,7 @@ public interface UTags {
TagKey<Item> SHADES = item("shades"); TagKey<Item> SHADES = item("shades");
TagKey<Item> CHANGELING_EDIBLE = item("food_types/changeling_edible"); TagKey<Item> CHANGELING_EDIBLE = item("food_types/changeling_edible");
TagKey<Item> SPOOKED_MOB_DROPS = item("spooked_mob_drops");
TagKey<Item> POLEARMS = item("polearms"); TagKey<Item> POLEARMS = item("polearms");
TagKey<Item> APPLE_SEEDS = item("apple_seeds"); TagKey<Item> APPLE_SEEDS = item("apple_seeds");

View file

@ -201,6 +201,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
if (player.isClientPlayer()) { if (player.isClientPlayer()) {
Optional<T> data = ability.prepare(player); Optional<T> data = ability.prepare(player);
warmup = 0;
if (data.isPresent()) { if (data.isPresent()) {
Channel.CLIENT_PLAYER_ABILITY.sendToServer(new MsgPlayerAbility<>(ability, data, ActivationType.NONE)); Channel.CLIENT_PLAYER_ABILITY.sendToServer(new MsgPlayerAbility<>(ability, data, ActivationType.NONE));

View file

@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.data.Numeric; import com.minelittlepony.unicopia.ability.data.Numeric;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.advancement.UCriteria; import com.minelittlepony.unicopia.advancement.UCriteria;
@ -13,11 +14,13 @@ import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.damage.UDamageTypes; import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.util.RegistryUtils;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random; import net.minecraft.util.math.random.Random;
@ -26,15 +29,17 @@ import net.minecraft.util.math.random.Random;
* (only shields for now) * (only shields for now)
*/ */
public class BatEeeeAbility implements Ability<Numeric> { public class BatEeeeAbility implements Ability<Numeric> {
public static final int SELF_SPOOK_PROBABILITY = 20000;
public static final int MOB_SPOOK_PROBABILITY = 1000;
@Override @Override
public int getWarmupTime(Pony player) { public int getWarmupTime(Pony player) {
return 1; return 30;
} }
@Override @Override
public int getCooldownTime(Pony player) { public int getCooldownTime(Pony player) {
return 1; return 5;
} }
@Override @Override
@ -42,6 +47,11 @@ public class BatEeeeAbility implements Ability<Numeric> {
return 0; return 0;
} }
@Override
public boolean activateOnEarlyRelease() {
return true;
}
@Override @Override
public boolean canUse(Race race) { public boolean canUse(Race race) {
return race == Race.BAT; return race == Race.BAT;
@ -49,7 +59,10 @@ public class BatEeeeAbility implements Ability<Numeric> {
@Override @Override
public Optional<Numeric> prepare(Pony player) { public Optional<Numeric> prepare(Pony player) {
return Numeric.of(1); return player.getAbilities().getActiveStat()
.map(stat -> (int)(stat.getWarmup() * getWarmupTime(player)))
.filter(i -> i >= 0)
.map(Numeric::new);
} }
@Override @Override
@ -59,23 +72,26 @@ public class BatEeeeAbility implements Ability<Numeric> {
@Override @Override
public boolean apply(Pony player, Numeric data) { public boolean apply(Pony player, Numeric data) {
float strength = 1 - MathHelper.clamp(data.type() / (float)getWarmupTime(player), 0, 1);
Random rng = player.asWorld().random; Random rng = player.asWorld().random;
int count = 1 + rng.nextInt(10); int count = 1 + rng.nextInt(10) + (int)(strength * 10);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
player.asWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS, player.playSound(USounds.ENTITY_PLAYER_BATPONY_SCREECH,
0.9F + (rng.nextFloat() - 0.5F) / 2F, (0.9F + (rng.nextFloat() - 0.5F) / 2F) * strength,
1.6F + (rng.nextFloat() - 0.5F) 1.6F + (rng.nextFloat() - 0.5F)
); );
} }
AwaitTickQueue.scheduleTask(player.asWorld(), w -> { for (int j = 0; j < (int)(strength * 2); j++) {
for (int i = 0; i < count; i++) { for (int k = 0; k < count; k++) {
player.asWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS, AwaitTickQueue.scheduleTask(player.asWorld(), w -> {
0.9F + (rng.nextFloat() - 0.5F) / 2F, player.playSound(USounds.ENTITY_PLAYER_BATPONY_SCREECH,
1.6F + (rng.nextFloat() - 0.5F) (0.9F + (rng.nextFloat() - 0.5F) / 2F) * strength,
); 1.6F + (rng.nextFloat() - 0.5F)
);
}, rng.nextInt(3));
} }
}, rng.nextInt(10)); }
if (!player.getPhysics().isFlying()) { if (!player.getPhysics().isFlying()) {
player.setAnimation(Animation.SPREAD_WINGS, Animation.Recipient.ANYONE); player.setAnimation(Animation.SPREAD_WINGS, Animation.Recipient.ANYONE);
@ -83,20 +99,27 @@ public class BatEeeeAbility implements Ability<Numeric> {
Vec3d origin = player.getOriginVector(); Vec3d origin = player.getOriginVector();
if (rng.nextInt(20000) == 0) { if (strength > 0.5F && rng.nextInt(SELF_SPOOK_PROBABILITY) == 0) {
player.asEntity().damage(player.damageOf(UDamageTypes.BAT_SCREECH, player), 0.1F); player.asEntity().damage(player.damageOf(UDamageTypes.BAT_SCREECH, player), 0.1F);
UCriteria.SCREECH_SELF.trigger(player.asEntity()); UCriteria.SCREECH_SELF.trigger(player.asEntity());
} }
int total = player.findAllEntitiesInRange(5).mapToInt(e -> { int total = player.findAllEntitiesInRange((int)Math.max(1, 8 * strength)).mapToInt(e -> {
if (e instanceof LivingEntity living && !SpellType.SHIELD.isOn(e)) { if (e instanceof LivingEntity living && !SpellType.SHIELD.isOn(e)) {
boolean isEarthPony = EquinePredicates.PLAYER_EARTH.test(e); boolean isEarthPony = EquinePredicates.PLAYER_EARTH.test(e);
e.damage(player.damageOf(UDamageTypes.BAT_SCREECH, player), isEarthPony ? 0.1F : 0.3F); e.damage(player.damageOf(UDamageTypes.BAT_SCREECH, player), isEarthPony ? 0.1F : 0.3F);
if (e.getWorld().random.nextInt(MOB_SPOOK_PROBABILITY) == 0) {
RegistryUtils.pickRandom(e.getWorld(), UTags.SPOOKED_MOB_DROPS).ifPresent(drop -> {
e.dropStack(drop.getDefaultStack());
e.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1, 0.1F);
UCriteria.SPOOK_MOB.trigger(player.asEntity());
});
}
Vec3d knockVec = origin.subtract(e.getPos()); Vec3d knockVec = origin.subtract(e.getPos()).multiply(strength);
living.takeKnockback(isEarthPony ? 0.3F : 0.5F, knockVec.getX(), knockVec.getZ()); living.takeKnockback((isEarthPony ? 0.3F : 0.5F) * strength, knockVec.getX(), knockVec.getZ());
if (!isEarthPony) { if (!isEarthPony) {
e.addVelocity(0, 0.1, 0); e.addVelocity(0, 0.1 * strength, 0);
} }
Living.updateVelocity(e); Living.updateVelocity(e);
return 1; return 1;

View file

@ -13,6 +13,7 @@ public interface UCriteria {
CustomEventCriterion.Trigger FEED_TRICK_APPLE = CUSTOM_EVENT.createTrigger("feed_trick_apple"); CustomEventCriterion.Trigger FEED_TRICK_APPLE = CUSTOM_EVENT.createTrigger("feed_trick_apple");
CustomEventCriterion.Trigger SCREECH_SELF = CUSTOM_EVENT.createTrigger("screech_self"); CustomEventCriterion.Trigger SCREECH_SELF = CUSTOM_EVENT.createTrigger("screech_self");
CustomEventCriterion.Trigger SCREECH_TWENTY_MOBS = CUSTOM_EVENT.createTrigger("screech_twenty_mobs"); CustomEventCriterion.Trigger SCREECH_TWENTY_MOBS = CUSTOM_EVENT.createTrigger("screech_twenty_mobs");
CustomEventCriterion.Trigger SPOOK_MOB = CUSTOM_EVENT.createTrigger("spook_mob");
CustomEventCriterion.Trigger SHED_FEATHER = CUSTOM_EVENT.createTrigger("shed_feather"); CustomEventCriterion.Trigger SHED_FEATHER = CUSTOM_EVENT.createTrigger("shed_feather");
CustomEventCriterion.Trigger THROW_MUFFIN = CUSTOM_EVENT.createTrigger("throw_muffin"); CustomEventCriterion.Trigger THROW_MUFFIN = CUSTOM_EVENT.createTrigger("throw_muffin");
CustomEventCriterion.Trigger SEND_OATS = CUSTOM_EVENT.createTrigger("send_oats"); CustomEventCriterion.Trigger SEND_OATS = CUSTOM_EVENT.createTrigger("send_oats");

View file

@ -0,0 +1,29 @@
{
"parent": "unicopia:unicopia/bat/night_route",
"display": {
"icon": {
"item": "unicopia:sunglasses"
},
"title": {
"translate": "advancements.unicopia.extra_spooky.title"
},
"description": {
"translate": "advancements.unicopia.extra_spooky.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": true
},
"criteria": {
"spook_extra_hard": {
"trigger": "unicopia:custom",
"conditions": {
"event": "super_scare_entity"
}
}
},
"requirements": [
[ "spook_extra_hard" ]
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:brick"
]
}