mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-27 00:22:55 +00:00
Various Fixes 🐶
This commit is contained in:
1 parent
12c50d5f6a
commit
3e58013ad6
12 files changed
+268
-10
No files matched your search
@@ -1034,6 +1034,62 @@ public abstract class AbstractDataAbilities {
|
||||
protected void onInterruptComplete() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the currently executing ability (voluntary player action).
|
||||
* Unlike interrupt, this always goes directly to IDLE (never DAZED),
|
||||
* immediately rolls cooldown, and clears state.
|
||||
* Also handles cancellation during chain delay (between chain entries).
|
||||
*/
|
||||
public void cancelCurrentAbility() {
|
||||
boolean hasExecutingAbility = currentAbility != null && currentAbility.isExecuting();
|
||||
boolean isInChainDelay = currentChain != null && chainDelayRemaining > 0;
|
||||
|
||||
if (!hasExecutingAbility && !isInChainDelay) return;
|
||||
|
||||
if (hasExecutingAbility) {
|
||||
AbilityPhase phase = currentAbility.getPhase();
|
||||
// Cannot cancel during DAZED (already interrupted)
|
||||
if (phase == AbilityPhase.DAZED) return;
|
||||
// Only allow cancel during active phases
|
||||
if (phase != AbilityPhase.WINDUP && phase != AbilityPhase.ACTIVE
|
||||
&& phase != AbilityPhase.BURST_DELAY) return;
|
||||
|
||||
// Remove telegraph
|
||||
removeTelegraph(currentAbility);
|
||||
|
||||
// Fire extender complete hook (cancelled = interrupted)
|
||||
AbilityController.Instance.fireOnAbilityComplete(currentAbility, getEntity(), getTarget(), true);
|
||||
|
||||
// Fire interrupt event (source=null, damage=0 for voluntary cancel)
|
||||
fireInterruptEvent(currentAbility, getTarget(), null, 0);
|
||||
|
||||
// Cancel the ability (cleanup + go directly to IDLE, no DAZED)
|
||||
currentAbility.onInterrupt(getEntity(), null, 0);
|
||||
currentAbility.cancel();
|
||||
|
||||
// Release locks and stop animation
|
||||
stopAbilityAnimation();
|
||||
releaseRotationControl();
|
||||
releaseLockedPosition();
|
||||
}
|
||||
|
||||
// Roll cooldown
|
||||
if (currentChain != null) {
|
||||
rollChainCooldown(currentChain);
|
||||
currentChain = null;
|
||||
chainEntryIndex = -1;
|
||||
chainDelayRemaining = -1;
|
||||
} else if (currentAbility != null) {
|
||||
rollCooldown(currentAbility);
|
||||
}
|
||||
|
||||
// Interrupt all concurrent slots
|
||||
interruptConcurrentSlots();
|
||||
|
||||
// Clear state via the normal completion path
|
||||
onAbilityComplete();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// CHAINED ABILITY EXECUTION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -91,6 +91,16 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
*/
|
||||
private transient byte lastSyncedFlags = 0;
|
||||
|
||||
/**
|
||||
* World time when the last ability was activated (for double-press cancel detection).
|
||||
*/
|
||||
private transient long lastAbilityActivationTime = -1;
|
||||
|
||||
/**
|
||||
* Ticks after activation during which a second key press will cancel the ability.
|
||||
*/
|
||||
private static final int CANCEL_WINDOW_TICKS = 10;
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// CONSTRUCTOR
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -258,6 +268,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
currentAbility = null;
|
||||
currentAbilityKey = null;
|
||||
currentTarget = null;
|
||||
lastAbilityActivationTime = -1;
|
||||
syncAbilityStateClear(playerData.player);
|
||||
}
|
||||
|
||||
@@ -273,6 +284,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
currentAbility = null;
|
||||
currentAbilityKey = null;
|
||||
currentTarget = null;
|
||||
lastAbilityActivationTime = -1;
|
||||
syncAbilityStateClear(playerData.player);
|
||||
}
|
||||
|
||||
@@ -378,6 +390,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
|
||||
currentAbilityKey = key;
|
||||
currentTarget = null;
|
||||
lastAbilityActivationTime = getWorldTime();
|
||||
return startChain((ChainedAbility) action, null);
|
||||
}
|
||||
|
||||
@@ -413,6 +426,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
currentAbility = ability;
|
||||
currentAbilityKey = key;
|
||||
currentTarget = null; // Players don't have auto-targets
|
||||
lastAbilityActivationTime = getWorldTime();
|
||||
ability.start(null);
|
||||
|
||||
if (ability.getPhase() == AbilityPhase.ACTIVE) {
|
||||
@@ -662,6 +676,38 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
interruptCurrentAbility(null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to cancel the current ability via double-press.
|
||||
* Only succeeds if within the cancel window and not in DAZED phase.
|
||||
* Also handles cancellation during chain delay (between chain entries).
|
||||
*
|
||||
* @return true if the ability was cancelled
|
||||
*/
|
||||
public boolean tryCancelAbility() {
|
||||
boolean hasExecutingAbility = currentAbility != null && currentAbility.isExecuting();
|
||||
boolean isInChainDelay = currentChain != null && chainDelayRemaining > 0;
|
||||
|
||||
if (!hasExecutingAbility && !isInChainDelay) return false;
|
||||
|
||||
// Don't allow cancel during DAZED
|
||||
if (hasExecutingAbility) {
|
||||
AbilityPhase phase = currentAbility.getPhase();
|
||||
if (phase == AbilityPhase.DAZED) return false;
|
||||
if (phase != AbilityPhase.WINDUP && phase != AbilityPhase.ACTIVE
|
||||
&& phase != AbilityPhase.BURST_DELAY) return false;
|
||||
}
|
||||
|
||||
long worldTime = getWorldTime();
|
||||
if (lastAbilityActivationTime < 0 || (worldTime - lastAbilityActivationTime) > CANCEL_WINDOW_TICKS) {
|
||||
// Outside cancel window — update time so a quick follow-up press can cancel
|
||||
lastAbilityActivationTime = worldTime;
|
||||
return false;
|
||||
}
|
||||
|
||||
cancelCurrentAbility();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// ENTITY RECONSTRUCTION RESET
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -701,6 +747,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
currentAbility = null;
|
||||
currentAbilityKey = null;
|
||||
currentTarget = null;
|
||||
lastAbilityActivationTime = -1;
|
||||
|
||||
if (clearCooldowns) {
|
||||
cooldownEndTime = 0;
|
||||
|
||||
Reference in new issue
Block a user