Skip to content

Commit

Permalink
balance mother fight
Browse files Browse the repository at this point in the history
- spawn more ghosts in shorter intervals if more players are involved
- remove freeze effect from ghost
- increased ghost speed when not in blocks
- increase remains defender damage
  • Loading branch information
Cheaterpaul committed Oct 29, 2023
1 parent a7939b8 commit 7def14b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@ public static void serverTick(Level level, BlockPos blockPos, BlockState blockSt
player.addEffect(new MobEffectInstance(MobEffects.HUNGER, 5 * 20, 2));
ModParticles.spawnParticlesServer(player.level(), new FlyingBloodParticleOptions(100, false, p.getX() + 0.5, p.getY() + 0.5, p.getZ() + 0.5, 0.5f), player.getX(), player.getY() + player.getEyeHeight() / 2, player.getZ(), 5, 0.1f, 0.1f, 0.1f, 0);
}

if (e.level.getRandom().nextInt(3) == 0) {
if (e.level.getEntitiesOfClass(GhostEntity.class, e.getArea().inflate(10)).size() < Math.min(e.activePlayers.size(), 5)) {
BlockPos left = vuls.get(e.level.getRandom().nextInt(vuls.size())).getLeft();
e.spawnGhost(level, left);
}
}
}
}
}
if (e.level.getRandom().nextFloat() < Math.max(0.02f, Math.min(0.1f, e.activePlayers.size() * 0.002f))) {
var blocks = e.getTreeStructure(false).getCachedBlocks();
if (e.level.getEntitiesOfClass(GhostEntity.class, e.getArea().inflate(10)).size() < Math.min(e.activePlayers.size() * 1.6, 10)) {
blocks.stream().skip(e.level.getRandom().nextInt(blocks.size())).findFirst().ifPresent(pos -> e.spawnGhost(level, pos));
}
}
}
//Handle destruction --------------------------------
if (e.level != null && e.destructionTimer > 0) {
Expand Down Expand Up @@ -313,7 +312,7 @@ private AABB getArea() {
private void spawnGhosts() {
Set<BlockPos> vuls = this.getTreeStructure(false).getCachedBlocks();
int size = this.level.getEntitiesOfClass(GhostEntity.class, this.getArea()).size();
for(int i = size; i < 3; i++) {
for(int i = size; i < Math.max(3, Math.min(this.activePlayers.size() * 1.6, 10)); i++) {
vuls.stream().skip(level.getRandom().nextInt(vuls.size())).findFirst().ifPresent(pos -> this.spawnGhost(level, pos));
}
}
Expand Down
31 changes: 22 additions & 9 deletions src/main/java/de/teamlapen/vampirism/entity/GhostEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl;
Expand All @@ -28,14 +30,18 @@
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.ForgeMod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.UUID;

public class GhostEntity extends VampirismEntity implements IRemainsEntity, IEntityFollower {

private static final UUID SPEED_MODIFIER = UUID.fromString("e8c3b0b0-3d6c-11eb-b378-0242ac130002");
private IEntityLeader leader;

public GhostEntity(@NotNull EntityType<? extends VampirismEntity> type, @NotNull Level world) {
Expand All @@ -61,15 +67,6 @@ public boolean isInvulnerableTo(DamageSource pSource) {
return pSource.is(DamageTypeTags.IS_PROJECTILE) || pSource.is(ModTags.DamageTypes.MOTHER_RESISTANT_TO) && super.isInvulnerableTo(pSource);
}

@Override
public void playerTouch(Player pPlayer) {
if (pPlayer.canFreeze()) {
pPlayer.setTicksFrozen(Math.min(pPlayer.getTicksFrozen() + 2, pPlayer.getTicksRequiredToFreeze() + 10));
}
}



@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new GhostMeleeAttackGoal(1, true));
Expand All @@ -96,11 +93,27 @@ protected double getFollowDistance() {
public void tick() {
this.setNoGravity(true);
this.noPhysics = true;
checkInsideBlocks();
super.tick();
this.noPhysics = false;
this.setNoGravity(true);
}

@Override
protected void onInsideBlock(BlockState pState) {
if (pState.isAir()) {
AttributeInstance attribute = getAttribute(Attributes.FLYING_SPEED);
if (attribute != null && attribute.getModifier(SPEED_MODIFIER) == null) {
attribute.addTransientModifier(new AttributeModifier(SPEED_MODIFIER, "free movement", 0.2, AttributeModifier.Operation.ADDITION));
}
} else {
AttributeInstance attribute = getAttribute(Attributes.FLYING_SPEED);
if (attribute != null) {
attribute.removeModifier(SPEED_MODIFIER);
}
}
}

@Override
public boolean isFollowing() {
return this.leader != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class RemainsDefenderEntity extends Mob implements IRemainsEntity {


public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.ARMOR, 15).add(Attributes.ATTACK_DAMAGE, 5).add(Attributes.ARMOR_TOUGHNESS, 6);
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20.0D).add(Attributes.ARMOR, 15).add(Attributes.ATTACK_DAMAGE, 10).add(Attributes.ARMOR_TOUGHNESS, 6);
}

public RemainsDefenderEntity(EntityType<RemainsDefenderEntity> type, Level pLevel) {
Expand Down

0 comments on commit 7def14b

Please sign in to comment.