From 5d40b7af7f92ecdc7652e9eabca18a859a15671a Mon Sep 17 00:00:00 2001 From: beholderface <13290805+beholderface@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:21:31 -0400 Subject: [PATCH] make impulse cost calculation respect max magnitude --- .../common/casting/actions/spells/OpAddMotion.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt index 7f45168f85..292f404eba 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpAddMotion.kt @@ -29,14 +29,15 @@ object OpAddMotion : SpellAction { val motion = args.getVec3(1, argc) env.assertEntityInRange(target) - var motionForCost = motion.lengthSqr() - if (CastingImage.checkAndMarkGivenMotion(userData, target)) - motionForCost++ - val shrunkMotion = if (motion.lengthSqr() > MAX_MOTION * MAX_MOTION) motion.normalize().scale(MAX_MOTION) else motion + + var motionForCost = shrunkMotion.lengthSqr() + if (CastingImage.checkAndMarkGivenMotion(userData, target)) + motionForCost++ + return SpellAction.Result( Spell(target, shrunkMotion), (motionForCost * MediaConstants.DUST_UNIT).toLong(),