mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-07 22:16:44 +01:00
Bat pony screech strength now scales to however long you hold the key down
This commit is contained in:
parent
554bca3831
commit
56e3807770
6 changed files with 80 additions and 19 deletions
|
@ -24,6 +24,7 @@ public interface UTags {
|
|||
|
||||
TagKey<Item> SHADES = item("shades");
|
||||
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> APPLE_SEEDS = item("apple_seeds");
|
||||
|
|
|
@ -201,6 +201,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
|
||||
if (player.isClientPlayer()) {
|
||||
Optional<T> data = ability.prepare(player);
|
||||
warmup = 0;
|
||||
|
||||
if (data.isPresent()) {
|
||||
Channel.CLIENT_PLAYER_ABILITY.sendToServer(new MsgPlayerAbility<>(ability, data, ActivationType.NONE));
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.AwaitTickQueue;
|
|||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.UTags;
|
||||
import com.minelittlepony.unicopia.ability.data.Numeric;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
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.damage.UDamageTypes;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.RegistryUtils;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
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.random.Random;
|
||||
|
||||
|
@ -26,15 +29,17 @@ import net.minecraft.util.math.random.Random;
|
|||
* (only shields for now)
|
||||
*/
|
||||
public class BatEeeeAbility implements Ability<Numeric> {
|
||||
public static final int SELF_SPOOK_PROBABILITY = 20000;
|
||||
public static final int MOB_SPOOK_PROBABILITY = 1000;
|
||||
|
||||
@Override
|
||||
public int getWarmupTime(Pony player) {
|
||||
return 1;
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldownTime(Pony player) {
|
||||
return 1;
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,6 +47,11 @@ public class BatEeeeAbility implements Ability<Numeric> {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activateOnEarlyRelease() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(Race race) {
|
||||
return race == Race.BAT;
|
||||
|
@ -49,7 +59,10 @@ public class BatEeeeAbility implements Ability<Numeric> {
|
|||
|
||||
@Override
|
||||
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
|
||||
|
@ -59,23 +72,26 @@ public class BatEeeeAbility implements Ability<Numeric> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Pony player, Numeric data) {
|
||||
float strength = 1 - MathHelper.clamp(data.type() / (float)getWarmupTime(player), 0, 1);
|
||||
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++) {
|
||||
player.asWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
|
||||
0.9F + (rng.nextFloat() - 0.5F) / 2F,
|
||||
player.playSound(USounds.ENTITY_PLAYER_BATPONY_SCREECH,
|
||||
(0.9F + (rng.nextFloat() - 0.5F) / 2F) * strength,
|
||||
1.6F + (rng.nextFloat() - 0.5F)
|
||||
);
|
||||
}
|
||||
AwaitTickQueue.scheduleTask(player.asWorld(), w -> {
|
||||
for (int i = 0; i < count; i++) {
|
||||
player.asWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
|
||||
0.9F + (rng.nextFloat() - 0.5F) / 2F,
|
||||
1.6F + (rng.nextFloat() - 0.5F)
|
||||
);
|
||||
for (int j = 0; j < (int)(strength * 2); j++) {
|
||||
for (int k = 0; k < count; k++) {
|
||||
AwaitTickQueue.scheduleTask(player.asWorld(), w -> {
|
||||
player.playSound(USounds.ENTITY_PLAYER_BATPONY_SCREECH,
|
||||
(0.9F + (rng.nextFloat() - 0.5F) / 2F) * strength,
|
||||
1.6F + (rng.nextFloat() - 0.5F)
|
||||
);
|
||||
}, rng.nextInt(3));
|
||||
}
|
||||
}, rng.nextInt(10));
|
||||
}
|
||||
|
||||
if (!player.getPhysics().isFlying()) {
|
||||
player.setAnimation(Animation.SPREAD_WINGS, Animation.Recipient.ANYONE);
|
||||
|
@ -83,20 +99,27 @@ public class BatEeeeAbility implements Ability<Numeric> {
|
|||
|
||||
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);
|
||||
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)) {
|
||||
boolean isEarthPony = EquinePredicates.PLAYER_EARTH.test(e);
|
||||
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());
|
||||
living.takeKnockback(isEarthPony ? 0.3F : 0.5F, knockVec.getX(), knockVec.getZ());
|
||||
Vec3d knockVec = origin.subtract(e.getPos()).multiply(strength);
|
||||
living.takeKnockback((isEarthPony ? 0.3F : 0.5F) * strength, knockVec.getX(), knockVec.getZ());
|
||||
if (!isEarthPony) {
|
||||
e.addVelocity(0, 0.1, 0);
|
||||
e.addVelocity(0, 0.1 * strength, 0);
|
||||
}
|
||||
Living.updateVelocity(e);
|
||||
return 1;
|
||||
|
|
|
@ -13,6 +13,7 @@ public interface UCriteria {
|
|||
CustomEventCriterion.Trigger FEED_TRICK_APPLE = CUSTOM_EVENT.createTrigger("feed_trick_apple");
|
||||
CustomEventCriterion.Trigger SCREECH_SELF = CUSTOM_EVENT.createTrigger("screech_self");
|
||||
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 THROW_MUFFIN = CUSTOM_EVENT.createTrigger("throw_muffin");
|
||||
CustomEventCriterion.Trigger SEND_OATS = CUSTOM_EVENT.createTrigger("send_oats");
|
||||
|
|
|
@ -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" ]
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:brick"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue