F11 (suite) : regard de reference par tick serveur, une inondation de paquets ne le chasse plus

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
gastineltetClaude Opus 5.5 a révisé 2026-10-14 09:19:24 +02:00
1 Parent ec17ccae5d
révision 6329cd3d63
3 fichiers modifiés
+46 -13

Aucun fichier ne correspond à votre recherche

+27 -12
Voir le fichier
@@ -11,21 +11,28 @@ package com.gastinelgarde.core;
* honnête qui se tourne vers sa cible continue de la regarder, ou repart ailleurs, mais revient rarement pile
* en arrière en un ou deux ticks. Seuils à régler avec les traces [À VÉRIFIER] (combat PvP rapide).
*
* <p>Coût constant : 8 derniers regards.
* <p>Coût constant : le dernier regard reçu et le regard de fin des 4 derniers ticks serveur. L'historique avance
* par tick serveur, pas par paquet (revue de sécurité de F11 : huit paquets de rotation en deux ticks chassaient
* le regard de référence d'un historique par paquet).
*/
public final class RotationSilencieuse {
public static final double SNAP_DEGRES = 45.0;
public static final double RETOUR_DEGRES = 15.0;
public static final int DELAI_TICKS = 3;
private static final int HISTORIQUE = 8;
private static final int HISTORIQUE = 4;
/** Regard de fin de tick des derniers ticks serveur où un regard a été reçu. */
private final long[] ticks = new long[HISTORIQUE];
private final float[] yaws = new float[HISTORIQUE];
private final float[] pitchs = new float[HISTORIQUE];
private int taille;
private int tete; // prochaine case écrite
private boolean aRegard;
private long tickCourant;
private float yawCourant, pitchCourant;
private boolean enAttente;
private float avantYaw, avantPitch, coupYaw, coupPitch;
private long limite;
@@ -36,11 +43,18 @@ public final class RotationSilencieuse {
* @return points (1 si un aller-retour autour d'un coup vient de se terminer, 0 sinon)
*/
public double regard(long tick, float yaw, float pitch) {
ticks[tete] = tick;
yaws[tete] = yaw;
pitchs[tete] = pitch;
tete = (tete + 1) % HISTORIQUE;
if (taille < HISTORIQUE) taille++;
if (aRegard && tick > tickCourant) {
// Nouveau tick : le dernier regard du tick précédent devient son regard de fin.
ticks[tete] = tickCourant;
yaws[tete] = yawCourant;
pitchs[tete] = pitchCourant;
tete = (tete + 1) % HISTORIQUE;
if (taille < HISTORIQUE) taille++;
}
aRegard = true;
tickCourant = Math.max(tickCourant, tick);
yawCourant = yaw;
pitchCourant = pitch;
if (!enAttente) return 0;
if (tick > limite) {
@@ -57,8 +71,7 @@ public final class RotationSilencieuse {
/** Un coup est porté au tick donné, avec le dernier regard reçu. */
public void coup(long tick) {
if (taille == 0) return;
int dernier = Math.floorMod(tete - 1, HISTORIQUE);
if (!aRegard || taille == 0) return;
int reference = -1;
for (int k = 1; k <= taille; k++) {
int i = Math.floorMod(tete - k, HISTORIQUE);
@@ -68,12 +81,12 @@ public final class RotationSilencieuse {
}
}
if (reference < 0) return;
if (angle(yaws[reference], pitchs[reference], yaws[dernier], pitchs[dernier]) < SNAP_DEGRES) return;
if (angle(yaws[reference], pitchs[reference], yawCourant, pitchCourant) < SNAP_DEGRES) return;
enAttente = true;
avantYaw = yaws[reference];
avantPitch = pitchs[reference];
coupYaw = yaws[dernier];
coupPitch = pitchs[dernier];
coupYaw = yawCourant;
coupPitch = pitchCourant;
limite = tick + DELAI_TICKS;
}
@@ -90,6 +103,8 @@ public final class RotationSilencieuse {
public void vider() {
taille = 0;
tete = 0;
aRegard = false;
tickCourant = 0;
enAttente = false;
}
}