Skip to content

Commit

Permalink
Hydra adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Jan 12, 2025
1 parent 13afa9f commit 1ab5e35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 50 deletions.
54 changes: 8 additions & 46 deletions src/main/java/twilightforest/entity/boss/EntityTFHydra.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ public class EntityTFHydra extends EntityLiving implements IEntityMultiPart, IMo

public static final ResourceLocation LOOT_TABLE = TwilightForestMod.prefix("entities/hydra");

private static final int TICKS_BEFORE_HEALING = 1000;
private static final int HEAD_RESPAWN_TICKS = 100;
private static final int HEAD_MAX_DAMAGE = 120;
private static final int TICKS_BEFORE_HEALING = 600;
private static final int HEAD_RESPAWN_TICKS = 50;
private static final int HEAD_MAX_DAMAGE = 100;
private static final float ARMOR_MULTIPLIER = 8.0F;
private static final int MAX_HEALTH = 360;
private static float HEADS_ACTIVITY_FACTOR = 0.3F;

private static final int SECONDARY_FLAME_CHANCE = 10;
private static final int SECONDARY_MORTAR_CHANCE = 16;
private static final int SECONDARY_FLAME_CHANCE = 50;
private static final int SECONDARY_MORTAR_CHANCE = 50;

private static final DataParameter<Boolean> DATA_SPAWNHEADS = EntityDataManager.createKey(EntityTFHydra.class, DataSerializers.BOOLEAN);

Expand Down Expand Up @@ -204,9 +203,6 @@ public void onLivingUpdate() {
this.heal(1);
}

// update fight variables for difficulty setting
setDifficultyVariables();

super.onLivingUpdate();

body.width = body.height = 6.0F;
Expand Down Expand Up @@ -369,14 +365,6 @@ protected void updateAITasks() {
this.secondaryAttacks();
}

private void setDifficultyVariables() {
if (world.getDifficulty() != EnumDifficulty.HARD) {
EntityTFHydra.HEADS_ACTIVITY_FACTOR = 0.3F;
} else {
EntityTFHydra.HEADS_ACTIVITY_FACTOR = 0.5F; // higher is harder
}
}

// TODO: make random
private int getRandomDeadHead() {
for (int i = 0; i < numHeads; i++) {
Expand Down Expand Up @@ -416,8 +404,8 @@ private void attackEntity(Entity target, float distance) {

// three main heads can do these kinds of attacks
for (int i = 0; i < 3; i++) {
if (hc[i].isIdle() && !areTooManyHeadsAttacking(i)) {
if (distance > 4 && distance < 10 && rand.nextInt(BITE_CHANCE) == 0 && this.countActiveHeads() > 2 && !areOtherHeadsBiting(i)) {
if (hc[i].isIdle()) {
if (distance > 4 && distance < 10 && rand.nextInt(BITE_CHANCE) == 0 && this.countActiveHeads() > 2) {
hc[i].setNextState(HydraHeadContainer.State.BITE_BEGINNING);
} else if (distance > 0 && distance < 20 && rand.nextInt(FLAME_CHANCE) == 0) {
hc[i].setNextState(HydraHeadContainer.State.FLAME_BEGINNING);
Expand All @@ -429,7 +417,7 @@ private void attackEntity(Entity target, float distance) {

// heads 4-7 can do everything but bite
for (int i = 3; i < numHeads; i++) {
if (hc[i].isIdle() && !areTooManyHeadsAttacking(i)) {
if (hc[i].isIdle()) {
if (distance > 0 && distance < 20 && rand.nextInt(FLAME_CHANCE) == 0) {
hc[i].setNextState(HydraHeadContainer.State.FLAME_BEGINNING);
} else if (distance > 8 && distance < 32 && !targetAbove && rand.nextInt(MORTAR_CHANCE) == 0) {
Expand All @@ -439,23 +427,6 @@ private void attackEntity(Entity target, float distance) {
}
}

private boolean areTooManyHeadsAttacking(int testHead) {
int otherAttacks = 0;

for (int i = 0; i < numHeads; i++) {
if (i != testHead && hc[i].isAttacking()) {
otherAttacks++;

// biting heads count triple
if (hc[i].isBiting()) {
otherAttacks += 2;
}
}
}

return otherAttacks >= 1 + (countActiveHeads() * HEADS_ACTIVITY_FACTOR);
}

private int countActiveHeads() {
int count = 0;

Expand All @@ -468,15 +439,6 @@ private int countActiveHeads() {
return count;
}

private boolean areOtherHeadsBiting(int testHead) {
for (int i = 0; i < numHeads; i++) {
if (i != testHead && hc[i].isBiting()) {
return true;
}
}
return false;
}

/**
* Called sometime after the main attackEntity routine. Finds a valid secondary target and has an unoccupied head start an attack against it.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class HydraHeadContainer {
enum State {
IDLE(10),

BITE_BEGINNING(40),
BITE_READY(80),
BITING(7),
BITE_ENDING(40),
BITE_BEGINNING(20),
BITE_READY(20),
BITING(4),
BITE_ENDING(20),

FLAME_BEGINNING(40),
FLAMING(100),
Expand Down

0 comments on commit 1ab5e35

Please sign in to comment.