Skip to content

Commit 1b41242

Browse files
committed
Fix crash during ballistic when serpent and target y values differ by more than ArcHeight
Now `ArcHeight` is relative to the target instead of the serpent, so the serpent can jump as high as it needs
1 parent f32fdd7 commit 1b41242

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/me/nullicorn/hytale/stormserpent/npc/movement/BodyMotionSerpentBallistic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void activate(
6464
this.startPosition = new Vector3d(selfTransform.getPosition());
6565
this.targetPosition = new Vector3d(targetTransform.getPosition());
6666
this.targetHorizontalDistance = Vector2d.distance(this.startPosition.x, this.startPosition.z, this.targetPosition.x, this.targetPosition.z);
67-
this.peakHorizontalDistance = this.targetHorizontalDistance * Math.sqrt(Math.abs(this.arcHeight)) / (Math.sqrt(Math.abs(this.arcHeight)) + Math.sqrt(Math.abs(this.startPosition.y + this.arcHeight - this.targetPosition.y)));
67+
this.peakHorizontalDistance = this.targetHorizontalDistance * Math.sqrt(Math.abs(this.arcHeight)) / (Math.sqrt(Math.abs(this.arcHeight)) + Math.sqrt(Math.abs((this.targetPosition.y + this.arcHeight) - this.startPosition.y)));
6868
this.horizontalDirection = new Vector3d(this.targetPosition.x, 0, this.targetPosition.z).sub(this.startPosition.x, 0, this.startPosition.z).normalize();
6969
this.t = 0;
7070

src/main/java/me/nullicorn/hytale/stormserpent/npc/movement/builder/BuilderBodyMotionSerpentBallistic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public String getLongDescription() {
4242
@Override
4343
public Builder<BodyMotion> readConfig(final JsonElement data) {
4444
this.requireString(data, "TargetSlot", this.targetSlot, StringNotEmptyValidator.get(), BuilderDescriptorState.WorkInProgress, "Target to aim for", null);
45-
this.requireDouble(data, "ArcHeight", this.arcHeight, null, BuilderDescriptorState.WorkInProgress, "Peak height of the arc relative to the starting position", null);
45+
this.requireDouble(data, "ArcHeight", this.arcHeight, null, BuilderDescriptorState.WorkInProgress, "Peak height of the arc relative to the target position", null);
4646
this.requireDouble(data, "ArcPathSpeed", this.arcPathSpeed, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.WorkInProgress, "Horizontal speed that the arc is followed at", null);
4747
this.getDouble(data, "RelativeSpeed", this.relativeSpeed, 1.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.WorkInProgress, "Relative movement speed", null);
4848
this.getDouble(data, "RelativeTurnSpeed", this.relativeTurnSpeed, 1.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.WorkInProgress, "Relative turning speed", null);

0 commit comments

Comments
 (0)