Recovery -> Dazed. Better cooldown logic handling

This commit is contained in:
Kam committed 2026-01-27 04:07:02 -05:00
1 parent 93486d306b
commit 747aae8337
30 files changed
+577 -435

No files matched your search

+32 -19
View File
@@ -170,8 +170,8 @@ public class DataAbilities {
currentAbility.onActiveTick(npc, target, npc.worldObj, currentAbility.getCurrentTick());
break;
case RECOVERY:
// Recovery phase - just wait
case DAZED:
// Dazed phase - NPC cannot attack, just wait for daze to end
break;
case IDLE:
@@ -222,12 +222,10 @@ public class DataAbilities {
releaseLockedRotation();
// Calculate cooldown: random(min, max) + ability offset
int baseCooldown = minCooldown;
if (maxCooldown > minCooldown) {
baseCooldown = minCooldown + random.nextInt(maxCooldown - minCooldown + 1);
}
int totalCooldown = baseCooldown + currentAbility.getCooldownTicks();
cooldownEndTime = npc.worldObj.getTotalWorldTime() + totalCooldown;
int abilityCooldownOffset = currentAbility.getCooldownTicks();
rollCooldown();
// Add ability-specific cooldown offset
cooldownEndTime += abilityCooldownOffset;
currentAbility = null;
lastTarget = null;
@@ -539,8 +537,8 @@ public class DataAbilities {
/**
* Interrupt the currently executing ability.
* The ability will transition to RECOVERY phase (dazed state) and continue ticking.
* When RECOVERY completes, the ability will move to IDLE and onAbilityComplete() is called.
* If interrupted during WINDUP, the ability will transition to DAZED phase.
* When DAZED completes, the ability will move to IDLE and onAbilityComplete() is called.
*/
public void interruptCurrentAbility(DamageSource source, float damage) {
if (currentAbility != null) {
@@ -559,10 +557,10 @@ public class DataAbilities {
NpcAPI.EVENT_BUS.post(interruptEvent);
currentAbility.onInterrupt(npc, source, damage);
currentAbility.interrupt(); // This now transitions to RECOVERY, not IDLE
currentAbility.interrupt(); // Transitions to DAZED if interrupted during WINDUP
// Don't clear currentAbility - let it tick through RECOVERY phase
// When RECOVERY ends and phase becomes IDLE, onAbilityComplete() will be called
// Don't clear currentAbility - let it tick through DAZED phase
// When DAZED ends and phase becomes IDLE, onAbilityComplete() will be called
}
}
@@ -631,10 +629,13 @@ public class DataAbilities {
/**
* Reset all runtime state (cooldowns, current ability).
* Called when NPC respawns or combat ends.
* Rolls cooldown so NPC doesn't immediately use an ability.
*/
public void reset() {
stopCurrentAbility();
resetCooldown();
// Roll cooldown so NPC doesn't immediately attack after reset
rollCooldown();
// Reset execution state on all abilities
for (Ability ability : abilities) {
@@ -642,6 +643,18 @@ public class DataAbilities {
}
}
/**
* Roll a new cooldown using the min/max range.
* Called after ability completes and on reset.
*/
private void rollCooldown() {
int baseCooldown = minCooldown;
if (maxCooldown > minCooldown) {
baseCooldown = minCooldown + random.nextInt(maxCooldown - minCooldown + 1);
}
cooldownEndTime = npc.worldObj.getTotalWorldTime() + baseCooldown;
}
// ═══════════════════════════════════════════════════════════════════
// ABILITY LIST MANAGEMENT
// ═══════════════════════════════════════════════════════════════════
@@ -706,7 +719,7 @@ public class DataAbilities {
* Rules:
* - WINDUP phase: Block AI if lockMovement is true
* - ACTIVE phase: Block AI if lockMovement OR hasAbilityMovement is true
* - RECOVERY phase: Block AI if lockMovement is true
* - DAZED phase: Always block AI (NPC is stunned)
*/
public boolean isAbilityControllingMovement() {
if (currentAbility == null || !currentAbility.isExecuting()) {
@@ -727,9 +740,9 @@ public class DataAbilities {
// - hasAbilityMovement is true (ability is moving the NPC itself)
return currentAbility.isLockMovement() || currentAbility.hasAbilityMovement();
case RECOVERY:
// During recovery, block if lockMovement is set
return currentAbility.isLockMovement();
case DAZED:
// During dazed phase, always block - NPC is stunned from interrupt
return true;
default:
return false;
@@ -739,7 +752,7 @@ public class DataAbilities {
/**
* Check if NPC's look direction should be locked to target.
* Only locks during ACTIVE phase when lockMovement is true.
* This allows the NPC to freely track target during WINDUP and RECOVERY.
* This allows the NPC to freely track target during WINDUP and DAZED.
*/
public boolean shouldLockLookDirection() {
if (currentAbility == null || !currentAbility.isExecuting()) {
@@ -61,8 +61,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Timing
protected int cooldownTicks;
protected int windUpTicks;
protected int activeTicks;
protected int recoveryTicks;
protected int dazedTicks;
// ═══════════════════════════════════════════════════════════════════════════
// CACHED VALUES - Target Tab
@@ -115,8 +114,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Timing
this.cooldownTicks = ability.getCooldownTicks();
this.windUpTicks = ability.getWindUpTicks();
this.activeTicks = ability.getActiveTicks();
this.recoveryTicks = ability.getRecoveryTicks();
this.dazedTicks = ability.getDazedTicks();
// Target
this.minRange = ability.getMinRange();
@@ -254,42 +252,36 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
y += 24;
// Row 3: Interruptible
// Row 3: Interruptible + Dazed Ticks (only if interruptible)
addLabel(new GuiNpcLabel(6, "ability.interruptible", col1LabelX, y + 5));
addButton(new GuiNpcButton(14, guiLeft + 85, y, 40, 20, new String[]{"gui.no", "gui.yes"}, interruptible ? 1 : 0));
// Only show dazed ticks if interruptible is enabled
if (interruptible) {
addLabel(new GuiNpcLabel(12, "ability.dazed", col2LabelX, y + 5));
GuiNpcTextField dazedField = new GuiNpcTextField(13, this, fontRendererObj, col2FieldX, y, 40, 20, String.valueOf(dazedTicks));
dazedField.setIntegersOnly();
dazedField.setMinMaxDefault(0, 1000, 80);
addTextField(dazedField);
}
y += 28;
// Separator - Timing section header
addLabel(new GuiNpcLabel(7, "ability.timing", col1LabelX, y));
y += 14;
// Row 4: Windup Ticks + Active Ticks
// Row 4: Windup Ticks + Cooldown Ticks
addLabel(new GuiNpcLabel(10, "ability.windup", col1LabelX, y + 5));
GuiNpcTextField windupField = new GuiNpcTextField(11, this, fontRendererObj, col1FieldX, y, 40, 20, String.valueOf(windUpTicks));
windupField.setIntegersOnly();
windupField.setMinMaxDefault(0, 1000, 20);
addTextField(windupField);
addLabel(new GuiNpcLabel(11, "ability.active", col2LabelX, y + 5));
GuiNpcTextField activeField = new GuiNpcTextField(12, this, fontRendererObj, col2FieldX, y, 40, 20, String.valueOf(activeTicks));
activeField.setIntegersOnly();
activeField.setMinMaxDefault(1, 1000, 10);
addTextField(activeField);
y += 24;
// Row 5: Recovery Ticks + Cooldown Ticks
addLabel(new GuiNpcLabel(12, "ability.recovery", col1LabelX, y + 5));
GuiNpcTextField recoveryField = new GuiNpcTextField(13, this, fontRendererObj, col1FieldX, y, 40, 20, String.valueOf(recoveryTicks));
recoveryField.setIntegersOnly();
recoveryField.setMinMaxDefault(0, 1000, 20);
addTextField(recoveryField);
addLabel(new GuiNpcLabel(13, "ability.cooldown", col2LabelX, y + 5));
GuiNpcTextField cooldownField = new GuiNpcTextField(10, this, fontRendererObj, col2FieldX, y, 40, 20, String.valueOf(cooldownTicks));
cooldownField.setIntegersOnly();
cooldownField.setMinMaxDefault(0, 10000, 100);
cooldownField.setMinMaxDefault(0, 10000, 0);
addTextField(cooldownField);
}
@@ -632,6 +624,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// General tab buttons
else if (id == 14) {
interruptible = ((GuiNpcButton) guibutton).getValue() == 1;
initGui(); // Refresh to show/hide dazed ticks field
} else if (id == 16) {
lockMovement = ((GuiNpcButton) guibutton).getValue() == 1;
}
@@ -764,10 +757,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
cooldownTicks = textField.getInteger();
} else if (id == 11) {
windUpTicks = textField.getInteger();
} else if (id == 12) {
activeTicks = textField.getInteger();
} else if (id == 13) {
recoveryTicks = textField.getInteger();
dazedTicks = textField.getInteger();
}
// Visual-specific fields (200+) - delegate to subclass
@@ -865,8 +856,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Timing
ability.setCooldownTicks(cooldownTicks);
ability.setWindUpTicks(windUpTicks);
ability.setActiveTicks(activeTicks);
ability.setRecoveryTicks(recoveryTicks);
ability.setDazedTicks(dazedTicks);
// Target
ability.setMinRange(minRange);
@@ -914,8 +904,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
this.cooldownTicks = ability.getCooldownTicks();
this.windUpTicks = ability.getWindUpTicks();
this.activeTicks = ability.getActiveTicks();
this.recoveryTicks = ability.getRecoveryTicks();
this.dazedTicks = ability.getDazedTicks();
this.minRange = ability.getMinRange();
this.maxRange = ability.getMaxRange();
@@ -68,8 +68,15 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
y += 24;
// Row 5: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
// Row 5: Spin Duration (only for SPIN mode) + Effects button
if (cutter.getSweepMode() == AbilityCutter.SweepMode.SPIN) {
addLabel(new GuiNpcLabel(108, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(108, fieldX, y, 50, cutter.getSpinDurationTicks());
durationField.setMinMaxDefault(1, 1000, 60);
addTextField(durationField);
}
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -78,6 +85,7 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
switch (id) {
case 106:
cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]);
initGui(); // Refresh to show/hide duration field
break;
case 107:
cutter.setPiercing(value == 1);
@@ -121,6 +129,9 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
case 105:
cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed()));
break;
case 108:
cutter.setSpinDurationTicks(field.getInteger());
break;
}
}
}
@@ -31,9 +31,14 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 165;
int col2FieldX = guiLeft + 225;
// Row 1: Damage Reduction
addLabel(new GuiNpcLabel(100, "ability.dmgReduce", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, guard.getDamageReduction()));
// Row 1: Duration + Damage Reduction
addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, guard.getDurationTicks());
durationField.setMinMaxDefault(1, 1000, 60);
addTextField(durationField);
addLabel(new GuiNpcLabel(100, "ability.dmgReduce", col2LabelX, y + 5));
addTextField(createFloatField(100, col2FieldX, y, 50, guard.getDamageReduction()));
y += 24;
@@ -112,6 +117,9 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
guard.setDurationTicks(field.getInteger());
break;
case 100:
guard.setDamageReduction(parseFloat(field, guard.getDamageReduction()));
break;
@@ -31,14 +31,22 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Shape + Placement
addLabel(new GuiNpcLabel(100, "ability.shape", labelX, y + 5));
String[] shapes = {"Circle", "Ring", "Cone"};
addButton(new GuiNpcButton(100, fieldX, y, 55, 20, shapes, hazard.getShape().ordinal()));
// Row 1: Duration + Shape
addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, hazard.getDurationTicks());
durationField.setMinMaxDefault(1, 2000, 100);
addTextField(durationField);
addLabel(new GuiNpcLabel(101, "ability.placement", col2LabelX, y + 5));
addLabel(new GuiNpcLabel(100, "ability.shape", col2LabelX, y + 5));
String[] shapes = {"Circle", "Ring", "Cone"};
addButton(new GuiNpcButton(100, col2FieldX, y, 55, 20, shapes, hazard.getShape().ordinal()));
y += 24;
// Row 2: Placement
addLabel(new GuiNpcLabel(101, "ability.placement", labelX, y + 5));
String[] placements = {"Caster", "Target", "FollowCast", "FollowTgt"};
addButton(new GuiNpcButton(101, col2FieldX, y, 60, 20, placements, hazard.getPlacement().ordinal()));
addButton(new GuiNpcButton(101, fieldX, y, 70, 20, placements, hazard.getPlacement().ordinal()));
y += 24;
@@ -116,6 +124,9 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
hazard.setDurationTicks(field.getInteger());
break;
case 102:
hazard.setRadius(parseFloat(field, hazard.getRadius()));
break;
@@ -27,7 +27,20 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Heal Amount + Heal Percent
// Row 1: Instant Heal + Duration (only shown if not instant)
addLabel(new GuiNpcLabel(103, "dialog.instant", labelX, y + 5));
addButton(new GuiNpcButton(103, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isInstantHeal() ? 1 : 0));
if (!heal.isInstantHeal()) {
addLabel(new GuiNpcLabel(99, "ability.duration", col2LabelX, y + 5));
GuiNpcTextField durationField = createIntField(99, col2FieldX, y, 50, heal.getDurationTicks());
durationField.setMinMaxDefault(1, 1000, 60);
addTextField(durationField);
}
y += 24;
// Row 2: Heal Amount + Heal Percent
addLabel(new GuiNpcLabel(100, "ability.healAmount", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, heal.getHealAmount()));
@@ -36,16 +49,13 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
y += 24;
// Row 2: Heal Radius + Instant Heal
// Row 3: Heal Radius
addLabel(new GuiNpcLabel(102, "ability.healRadius", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, heal.getHealRadius()));
addLabel(new GuiNpcLabel(103, "dialog.instant", col2LabelX, y + 5));
addButton(new GuiNpcButton(103, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isInstantHeal() ? 1 : 0));
y += 24;
// Row 3: Heal Self + Heal Allies
// Row 4: Heal Self + Heal Allies
addLabel(new GuiNpcLabel(104, "ability.healSelf", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealSelf() ? 1 : 0));
@@ -59,6 +69,7 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
switch (id) {
case 103:
heal.setInstantHeal(value == 1);
initGui(); // Refresh to show/hide duration field
break;
case 104:
heal.setHealSelf(value == 1);
@@ -72,6 +83,9 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
heal.setDurationTicks(field.getInteger());
break;
case 100:
heal.setHealAmount(parseFloat(field, heal.getHealAmount()));
break;
@@ -31,13 +31,21 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Placement + Trigger Radius
addLabel(new GuiNpcLabel(100, "ability.placement", labelX, y + 5));
String[] placements = {"Caster", "Target", "Ahead"};
addButton(new GuiNpcButton(100, fieldX, y, 55, 20, placements, trap.getPlacement().ordinal()));
// Row 1: Duration + Placement
addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, trap.getDurationTicks());
durationField.setMinMaxDefault(1, 2000, 200);
addTextField(durationField);
addLabel(new GuiNpcLabel(101, "ability.triggerRad", col2LabelX, y + 5));
addTextField(createFloatField(101, col2FieldX, y, 50, trap.getTriggerRadius()));
addLabel(new GuiNpcLabel(100, "ability.placement", col2LabelX, y + 5));
String[] placements = {"Caster", "Target", "Ahead"};
addButton(new GuiNpcButton(100, col2FieldX, y, 55, 20, placements, trap.getPlacement().ordinal()));
y += 24;
// Row 2: Trigger Radius
addLabel(new GuiNpcLabel(101, "ability.triggerRad", labelX, y + 5));
addTextField(createFloatField(101, fieldX, y, 50, trap.getTriggerRadius()));
y += 24;
@@ -90,6 +98,9 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
trap.setDurationTicks(field.getInteger());
break;
case 101:
trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius()));
break;