@@ -157,28 +157,29 @@ public WeaponTypes getWeapon(LivingEntity en) {
157157 }
158158
159159 public final void onCastingTick (SpellCastContext ctx ) {
160- int timesToCast = (int ) ctx .spell .getConfig ().times_to_cast ;
161- if (timesToCast > 1 ) {
162- int castTimeTicks = (int ) getCastTimeTicks (ctx );
160+
161+ int timesToCast = ctx .spell .getConfig ().times_to_cast ;
162+ if (timesToCast > 1 ){
163+ SpellCastInfo castInfo = getCastInfo (ctx );
164+
163165 // if i didnt do this then cast time reduction would reduce amount of spell hits.
164- int castEveryXTicks = castTimeTicks / timesToCast ;
165- if (timesToCast > 1 ) {
166- if (castEveryXTicks < 1 ) {
167- castEveryXTicks = 1 ;
168- }
169- }
170- if (ctx .ticksInUse > 0 && ctx .ticksInUse % castEveryXTicks == 0 ) {
166+
167+
168+ if (ctx .ticksInUse > 0 && castInfo .castInThisTick (ctx .ticksInUse )) {
171169 this .cast (ctx );
172170 }
171+
173172 } else if (timesToCast < 1 ) {
174173 ExileLog .get ().warn ("Times to cast spell is: " + timesToCast + " . this seems like a bug." );
175174 }
175+
176+ ctx .castedThisTick = true ;
176177 }
177178
178179 public void cast (SpellCastContext ctx ) {
179180 LivingEntity caster = ctx .caster ;
180- ctx . castedThisTick = true ;
181- /*
181+
182+ /*
182183 if (MMORPG.RUN_DEV_TOOLS_REMOVE_WHEN_DONE && this.config.swing_arm) {
183184 // caster.swingTime = -1; // this makes sure hand swings
184185 // caster.swing(InteractionHand.MAIN_HAND);
@@ -195,9 +196,32 @@ public final int getChargeCooldownTicks(SpellCastContext ctx) {
195196 return (int ) ctx .event .data .getNumber (EventData .CHARGE_COOLDOWN_TICKS ).number ;
196197 }
197198
198- public final int getCastTimeTicks (SpellCastContext ctx ) {
199+ public SpellCastInfo getCastInfo (SpellCastContext ctx ) {
199200 // if it casts 5 times a cast, it should take at least 5 ticks to cast it
200- return MathHelper .clamp ((int ) ctx .event .data .getNumber (EventData .CAST_TICKS ).number , config .times_to_cast , 10000 );
201+ // since Robert don't want spell can be cast multiple times in a single tick, then we have to handle the decimal cast tick carefully
202+ float clamp = MathHelper .clamp (ctx .event .data .getNumber (EventData .CAST_TICKS ).number , config .times_to_cast * 1f , 10000f );
203+ int timesToCast = ctx .spell .getConfig ().times_to_cast ;
204+ float singleTimeCost = clamp / timesToCast ;
205+ int [] points = new int [timesToCast ];
206+ //means a single cast cost decimal tick
207+ if (singleTimeCost % 1 != 0 ) {
208+ for (int i = 0 ; i < timesToCast ; i ++) {
209+ float v = singleTimeCost * (i + 1 );
210+ //means the result time is integer at some situation, like 2.5 * 4 ticks.
211+ if (v % 1 == 0 ){
212+ points [i ] = ((int ) v );
213+ } else {
214+ points [i ] = ((int ) Math .ceil (singleTimeCost * (i + 1 )));
215+ }
216+
217+ }
218+ } else {
219+ for (int i = 0 ; i < timesToCast ; i ++) {
220+ points [i ] = ((int ) singleTimeCost ) * (i + 1 );
221+ }
222+
223+ }
224+ return new SpellCastInfo (points [points .length - 1 ], points );
201225 }
202226
203227 @ Override
@@ -272,12 +296,12 @@ public final List<Component> GetTooltipString(StatRangeInfo info) {
272296 list .add (Words .COOLDOWN .locName (getCooldownTicks (ctx ) / 20 ).withStyle (ChatFormatting .YELLOW ));
273297 }
274298
275- int casttime = getCastTimeTicks (ctx );
299+ int casttime = getCastInfo (ctx ). castTime ( );
276300
277301 if (casttime == 0 ) {
278302 list .add (Words .INSTANT_CAST .locName ().withStyle (ChatFormatting .GREEN ));
279303 } else {
280- list .add (Words .CAST_TIME .locName (casttime / 20 ).withStyle (ChatFormatting .GREEN ));
304+ list .add (Words .CAST_TIME .locName (Math . round ( casttime / 20.0f * 100f ) / 100f ).withStyle (ChatFormatting .GREEN ));
281305 }
282306
283307 Set <String > radiuses = new LinkedHashSet <>();
0 commit comments