Add Track Delay and Anchor Handling

This commit is contained in:
Kam committed 2026-03-02 20:09:32 -05:00
1 parent 36aab9e86e
commit dad49f1867
6 files changed
+119 -23

No files matched your search

@@ -91,6 +91,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
protected LockMode lockMovement = LockMode.WINDUP;
protected RotationMode rotationMode = RotationMode.FREE;
protected LockMode rotationPhase = LockMode.WINDUP_AND_ACTIVE;
protected float trackDelay = 0; // 0 = instant tracking (legacy). Higher = slower lerp toward target.
protected int windUpColor = 0x80FF4400; // Telegraph color during wind up
protected int activeColor = 0xC0FF0000; // Telegraph warning/active color
@@ -687,6 +688,11 @@ public abstract class Ability implements IAbility, IAbilityAction {
.hover("ability.hover.rotationPhase")
.visibleWhen(() -> this.rotationMode != RotationMode.FREE)
).tab("General"));
defs.add(FieldDef.floatField("ability.trackDelay", this::getTrackDelay, this::setTrackDelay)
.range(0.0f, 20.0f)
.hover("ability.hover.trackDelay")
.visibleWhen(() -> this.rotationMode == RotationMode.TRACK)
.tab("General"));
defs.add(FieldDef.row(
FieldDef.boolField("ability.interruptible", this::isInterruptible, this::setInterruptible)
.hover("ability.hover.interruptible")
@@ -1388,6 +1394,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
nbt.setInteger("lockMovement", lockMovement.ordinal());
nbt.setInteger("rotationMode", rotationMode.ordinal());
nbt.setInteger("rotationPhase", rotationPhase.ordinal());
nbt.setFloat("trackDelay", trackDelay);
nbt.setInteger("windUpColor", windUpColor);
nbt.setInteger("activeColor", activeColor);
nbt.setString("windUpSound", windUpSound);
@@ -1482,6 +1489,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
lockMovement = LockMode.fromOrdinal(nbt.getInteger("lockMovement"));
rotationMode = RotationMode.fromOrdinal(nbt.getInteger("rotationMode"));
rotationPhase = LockMode.fromOrdinal(nbt.getInteger("rotationPhase"));
trackDelay = nbt.hasKey("trackDelay") ? nbt.getFloat("trackDelay") : 0;
windUpColor = nbt.hasKey("windUpColor") ? nbt.getInteger("windUpColor") : 0x80FF4400;
activeColor = nbt.hasKey("activeColor") ? nbt.getInteger("activeColor") : 0xC0FF0000;
windUpSound = nbt.getString("windUpSound");
@@ -1817,6 +1825,14 @@ public abstract class Ability implements IAbility, IAbilityAction {
this.rotationPhase = rotationPhase;
}
public float getTrackDelay() {
return trackDelay;
}
public void setTrackDelay(float trackDelay) {
this.trackDelay = trackDelay;
}
/**
* API method: Get lock movement type as integer.
*
@@ -1877,6 +1893,25 @@ public abstract class Ability implements IAbility, IAbilityAction {
this.rotationPhase = LockMode.fromOrdinal(type);
}
/**
* API method: Get track delay for TRACK rotation mode.
* 0 = instant tracking (legacy). Higher = slower lerp toward target.
*/
@Override
public float getTrackDelayValue() {
return trackDelay;
}
/**
* API method: Set track delay for TRACK rotation mode.
*
* @param delay 0 = instant tracking. Higher = slower lerp toward target.
*/
@Override
public void setTrackDelayValue(float delay) {
this.trackDelay = Math.max(0, delay);
}
/**
* Check if movement (pathfinding/motion) should be locked during WINDUP phase.
*/
@@ -49,6 +49,7 @@ public class AbilityLaser extends AbilityEnergyProjectile<EntityAbilityLaser> im
this.lockMovement = LockMode.WINDUP_AND_ACTIVE;
this.rotationMode = RotationMode.TRACK;
this.rotationPhase = LockMode.WINDUP_AND_ACTIVE;
this.trackDelay = 3;
this.telegraphType = TelegraphType.LINE;
this.showTelegraph = true;
this.windUpAnimationName = "Ability_Laser_Windup";
@@ -6,6 +6,7 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyCombatData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
import kamkeel.npcs.util.AnchorPointHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
@@ -224,11 +225,16 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
dirZ = 0.0;
}
// Keep origin centered on look vector while active and clear owner bbox.
Vec3 direction = Vec3.createVectorHelper(dirX, dirY, dirZ);
setLookVectorLaunchPosition(livingOwner, direction, false);
// Lower beam origin slightly so it doesn't obscure the player's crosshair
posY -= 0.15;
// Position: use anchor if launchFromAnchor, otherwise use look vector position
if (anchorData.launchFromAnchor) {
Vec3 anchorPos = AnchorPointHelper.calculateAnchorPosition(livingOwner, anchorData);
setPosition(anchorPos.xCoord, anchorPos.yCoord, anchorPos.zCoord);
} else {
Vec3 direction = Vec3.createVectorHelper(dirX, dirY, dirZ);
setLookVectorLaunchPosition(livingOwner, direction, false);
// Lower beam origin slightly so it doesn't obscure the player's crosshair
posY -= 0.15;
}
syncStartPositionToCurrent();
syncPositionStateToCurrent(false);
}