2026-11-08 12:57:20 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GladiatorIdle
|
|
|
|
|
|
{
|
|
|
|
|
|
public enum DuelState { Ready, Windup, Strike, Recover, Block, Dodge, Hit, Stunned, Down, Victory, Wall, Leap, Super }
|
2026-11-09 16:13:28 +01:00
|
|
|
|
public enum DuelEventType { Hit, Blocked, Parry, Dodged, GuardBreak, Special, Heal, Stun, Ko, Leap, Super, SuperReady, Charge }
|
2026-11-08 12:57:20 +01:00
|
|
|
|
|
|
|
|
|
|
/// Ereignis für Anzeige/Ton. ByPlayer: wer es ausgelöst hat (Treffer: der Angreifer).
|
|
|
|
|
|
internal readonly record struct DuelEvent(DuelEventType Type, bool ByPlayer, double Amount = 0, bool Crit = false);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Ein Kämpfer im Echtzeit-Duell (Seitenansicht, Design-Pixel auf der x-Achse).</summary>
|
|
|
|
|
|
internal sealed class DuelFighter
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsPlayer;
|
|
|
|
|
|
public double X, MaxHp, Hp, Stamina = 100;
|
|
|
|
|
|
public int Facing = 1; // +1 nach rechts, −1 nach links
|
|
|
|
|
|
public DuelState State = DuelState.Ready;
|
|
|
|
|
|
public double StateTime; // seit wann im Zustand
|
|
|
|
|
|
public double Reach = 290 * Duel.SCALE, Speed = 440 * Duel.SCALE;
|
|
|
|
|
|
public double HitFraction; // Schaden je Treffer als Anteil des gegnerischen Lebens
|
|
|
|
|
|
public double Crit;
|
|
|
|
|
|
public double Windup = 0.12, StrikeTime = 0.10, RecoverTime = 0.28;
|
|
|
|
|
|
public double SpecialCooldown;
|
|
|
|
|
|
public double Slow, SicaHits; // Netz (langsamer), Sica (nächste Treffer kritisch)
|
|
|
|
|
|
public double BlockSince = -1; // Zeitpunkt, seit dem geblockt wird (für die Parade)
|
|
|
|
|
|
public double StunLeft;
|
|
|
|
|
|
public bool StruckThisSwing;
|
|
|
|
|
|
public bool Heavy; // gerade ein Schwerer Schlag
|
|
|
|
|
|
public double HeavyCd, WallCd, WallTime;
|
|
|
|
|
|
public double Invulnerable; // Bollwerk: kein Schaden, aber frei beweglich
|
|
|
|
|
|
public bool SecondWindUsed;
|
|
|
|
|
|
public double Rage; // Wut 0..100: voll → Super-Angriff
|
|
|
|
|
|
public double LeapCd;
|
|
|
|
|
|
public int SuperHits; // Hiebe der Super-Serie bisher
|
|
|
|
|
|
public double DmgMult = 1; // für den nächsten Treffer (Sprung, Super)
|
|
|
|
|
|
public bool Unblockable; // nächster Treffer geht durch Block und Parade
|
|
|
|
|
|
|
|
|
|
|
|
public bool Busy => State is DuelState.Windup or DuelState.Strike or DuelState.Recover or DuelState.Dodge
|
|
|
|
|
|
or DuelState.Hit or DuelState.Stunned or DuelState.Down or DuelState.Victory or DuelState.Wall
|
|
|
|
|
|
or DuelState.Leap or DuelState.Super;
|
|
|
|
|
|
public bool Alive => Hp > 0;
|
|
|
|
|
|
|
|
|
|
|
|
public void Set(DuelState s) { State = s; StateTime = 0; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Echtzeit-Duell gegen einen Champion (oder ein Übungsduell): Bewegen, Schlag, Block (mit Parade
|
|
|
|
|
|
/// im letzten Moment), Ausweichen, Spezialschlag, Ausdauer. Schaden hängt vom Verhältnis der
|
|
|
|
|
|
/// Kampfkraft ab — Werte zählen, entschieden wird mit Geschick. Reine Logik, die Anzeige liest
|
|
|
|
|
|
/// Zustände und Ereignisse.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal sealed class Duel
|
|
|
|
|
|
{
|
|
|
|
|
|
public const double FLOOR_MIN = 160, FLOOR_MAX = 1760;
|
|
|
|
|
|
/// Maßstab der Kämpfer (0.6 = 60 % der früheren Größe): alle Abstände und Tempi wachsen mit,
|
|
|
|
|
|
/// damit Reichweite und Schwertlänge zusammenpassen und die Balance gleich bleibt.
|
|
|
|
|
|
public const double SCALE = 0.6;
|
|
|
|
|
|
const double GAP = 230 * SCALE;
|
|
|
|
|
|
const double ATTACK_COST = 14, DODGE_COST = 24, BLOCK_HIT_COST = 18, REGEN = 30, REGEN_BLOCKING = 8;
|
|
|
|
|
|
const double DODGE_TIME = 0.32, DODGE_DIST = 320 * SCALE, HIT_TIME = 0.25, PARRY_WINDOW = 0.18, PARRY_STUN = 1.1;
|
|
|
|
|
|
public const double SPECIAL_COOLDOWN = 15;
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
|
public const double HEAVY_COOLDOWN = 10, HEAVY_WINDUP = 0.5, HEAVY_COST = 30, HEAVY_MULT = 2.5;
|
2026-11-08 12:57:20 +01:00
|
|
|
|
public const double WALL_COOLDOWN = 12, WALL_TIME = 2.5;
|
|
|
|
|
|
// Sprungangriff (Leertaste): Satz nach vorn, in der Luft unverwundbar, Schlag von oben
|
|
|
|
|
|
public const double LEAP_COST = 26, LEAP_COOLDOWN = 3, LEAP_TIME = 0.8, LEAP_HIT = 0.52, LEAP_DIST = 300 * SCALE, LEAP_MULT = 1.4;
|
|
|
|
|
|
const double LEAP_AIR_FROM = 0.06, LEAP_AIR_TO = 0.46;
|
|
|
|
|
|
// Super-Angriff (R, volle Wut): Aufladen, dann drei Hiebe, die jeden Block durchbrechen
|
|
|
|
|
|
public const double SUPER_CHARGE = 0.6, SUPER_TIME = 2.0, SUPER_MULT = 1.25;
|
|
|
|
|
|
public static readonly double[] SUPER_HITS = { 0.85, 1.2, 1.6 };
|
|
|
|
|
|
const double RAGE_HIT = 9, RAGE_HURT = 8, RAGE_BLOCK = 6, RAGE_PARRY = 25;
|
|
|
|
|
|
|
|
|
|
|
|
public DuelFighter Player { get; }
|
|
|
|
|
|
public DuelFighter Enemy { get; }
|
|
|
|
|
|
public Special PlayerSpecial { get; }
|
|
|
|
|
|
public bool Over { get; private set; }
|
|
|
|
|
|
public bool PlayerWon { get; private set; }
|
|
|
|
|
|
public double Time { get; private set; }
|
|
|
|
|
|
public List<DuelEvent> Events { get; } = new();
|
|
|
|
|
|
|
|
|
|
|
|
// Eingaben des Spielers (von der Anzeige gesetzt)
|
|
|
|
|
|
public int MoveDir;
|
|
|
|
|
|
public bool BlockHeld;
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
|
|
|
|
|
|
|
// Einführung: Gegner wartet (EnemyPassive) oder greift nur an (EnemyAttacksOnly, blockt nicht),
|
|
|
|
|
|
// macht weniger Schaden, und niemand fällt, solange GuardHp gesetzt ist.
|
|
|
|
|
|
public bool EnemyPassive, EnemyAttacksOnly, GuardHp;
|
|
|
|
|
|
public double EnemyDamageMult = 1;
|
2026-11-08 12:57:20 +01:00
|
|
|
|
bool _attack, _dodge, _special, _heavy, _wall, _leap, _super;
|
|
|
|
|
|
public void PressLeap() => _leap = true;
|
|
|
|
|
|
public void PressSuper() => _super = true;
|
|
|
|
|
|
public void PressHeavy() => _heavy = true;
|
|
|
|
|
|
public void PressWall() => _wall = true;
|
|
|
|
|
|
public void PressAttack() => _attack = true;
|
|
|
|
|
|
public void PressDodge() => _dodge = true;
|
|
|
|
|
|
public void PressSpecial() => _special = true;
|
|
|
|
|
|
|
|
|
|
|
|
readonly Random _rng;
|
|
|
|
|
|
readonly bool _champion;
|
|
|
|
|
|
readonly SkillPerks _perks;
|
|
|
|
|
|
public SkillPerks Perks => _perks;
|
|
|
|
|
|
public double SpecialCooldownTotal => SPECIAL_COOLDOWN + _perks.SpecialCdAdd;
|
|
|
|
|
|
double _thinkIn, _aiMove;
|
|
|
|
|
|
|
2026-11-09 16:13:28 +01:00
|
|
|
|
// ── Kampfstil des Gegners ───────────────────────────────────
|
|
|
|
|
|
/// "clumsy" (Sklave, Rekrut), "brawler" (Serien), "spear" (Abstand), "dual" (Doppelschlag),
|
|
|
|
|
|
/// "champion" (Finten, Ansturm) oder "" (Grundverhalten).
|
|
|
|
|
|
public string Style { get; private set; } = "";
|
|
|
|
|
|
public const double CHARGE_WINDUP = 0.8;
|
|
|
|
|
|
const double CHARGE_MULT = 1.8 / HEAVY_MULT, CHARGE_EVERY = 8;
|
|
|
|
|
|
int _comboLeft; // Raufbold: noch so viele Schläge in der Serie
|
|
|
|
|
|
bool _charging, _secondDone;
|
|
|
|
|
|
double _chargeIn = CHARGE_EVERY * 0.6;
|
|
|
|
|
|
|
|
|
|
|
|
// für das Urteil des Publikums (Gnadenstoß)
|
|
|
|
|
|
public double DamageToPlayer { get; private set; }
|
|
|
|
|
|
public int PlayerParries { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// Kampfstil aus dem Bild des Gegners.
|
|
|
|
|
|
public static string StyleOf(string art, bool champion)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (champion || art.StartsWith("champ_") || art.StartsWith("fig_") || art.StartsWith("hero_")) return "champion";
|
|
|
|
|
|
if (art.Contains("slave") || art.Contains("recruit")) return "clumsy";
|
|
|
|
|
|
if (art.Contains("brawler")) return "brawler";
|
|
|
|
|
|
if (art.Contains("hoplomachus") || art.Contains("eques")) return "spear";
|
|
|
|
|
|
if (art.Contains("dimachaerus")) return "dual";
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Kampfstil setzen (nach dem Erzeugen): ändert Tempo, Reichweite und Verhalten des Gegners.
|
|
|
|
|
|
public void SetStyle(string style)
|
|
|
|
|
|
{
|
|
|
|
|
|
Style = style;
|
|
|
|
|
|
var e = Enemy;
|
|
|
|
|
|
switch (style)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "clumsy": e.Windup *= 1.25; e.RecoverTime *= 1.1; break;
|
|
|
|
|
|
case "brawler": e.RecoverTime *= 0.8; e.Speed *= 1.1; e.HitFraction *= 0.85; break;
|
|
|
|
|
|
case "spear": e.Reach *= 1.35; e.Windup *= 1.1; break;
|
|
|
|
|
|
case "dual": e.StrikeTime = 0.18; e.HitFraction *= 0.6; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-08 12:57:20 +01:00
|
|
|
|
/// <param name="ratio">Kampfkraft Spieler / Gegner (1 = ausgeglichen)</param>
|
|
|
|
|
|
public Duel(double playerHp, double playerCrit, Special special, double enemyHp, double ratio, bool champion,
|
|
|
|
|
|
bool trident, Random rng, SkillPerks? perks = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_rng = rng;
|
|
|
|
|
|
_perks = perks ?? new SkillPerks();
|
|
|
|
|
|
_champion = champion;
|
|
|
|
|
|
PlayerSpecial = special;
|
|
|
|
|
|
double r = Math.Clamp(ratio, 0.05, 20);
|
|
|
|
|
|
Player = new DuelFighter
|
|
|
|
|
|
{
|
|
|
|
|
|
IsPlayer = true, X = 960 - 400 * SCALE, Facing = 1, MaxHp = playerHp, Hp = playerHp, Crit = playerCrit,
|
|
|
|
|
|
HitFraction = Math.Clamp(0.05 * Math.Pow(r, 0.35), 0.012, 0.25), Reach = ((trident ? 345 : 300) + _perks.ReachAdd) * SCALE,
|
|
|
|
|
|
Windup = 0.12 * _perks.WindupMult, Speed = 440 * _perks.SpeedMult * SCALE
|
|
|
|
|
|
};
|
|
|
|
|
|
Enemy = new DuelFighter
|
|
|
|
|
|
{
|
|
|
|
|
|
IsPlayer = false, X = 960 + 400 * SCALE, Facing = -1, MaxHp = enemyHp, Hp = enemyHp, Crit = 0.08,
|
|
|
|
|
|
HitFraction = Math.Clamp(Balance.DUEL_ENEMY_HIT * Math.Pow(r, -0.35), 0.02, 0.4),
|
|
|
|
|
|
Speed = (champion ? 350 : 320) * SCALE, Windup = champion ? 0.38 : 0.46, RecoverTime = champion ? 0.40 : 0.50
|
|
|
|
|
|
};
|
|
|
|
|
|
_thinkIn = 0.6;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Step(double dt)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Over) { Time += dt; Tick(Player, dt); Tick(Enemy, dt); return; }
|
|
|
|
|
|
Time += dt;
|
|
|
|
|
|
PlayerInput(dt);
|
|
|
|
|
|
EnemyAi(dt);
|
|
|
|
|
|
Tick(Player, dt);
|
|
|
|
|
|
Tick(Enemy, dt);
|
|
|
|
|
|
// immer einander zugewandt (außer beim Ausweichen/Schlagen)
|
|
|
|
|
|
if (!Player.Busy) Player.Facing = Enemy.X >= Player.X ? 1 : -1;
|
|
|
|
|
|
if (!Enemy.Busy) Enemy.Facing = Player.X >= Enemy.X ? 1 : -1;
|
|
|
|
|
|
_attack = _dodge = _special = _heavy = _wall = _leap = _super = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ── Spieler ─────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
void PlayerInput(double dt)
|
|
|
|
|
|
{
|
|
|
|
|
|
var p = Player;
|
|
|
|
|
|
if (p.Busy && p.State != DuelState.Recover) return;
|
|
|
|
|
|
if (p.State == DuelState.Recover && p.StateTime < p.RecoverTime * 0.6) return; // Ende der Erholung: schon wieder handeln
|
|
|
|
|
|
|
|
|
|
|
|
if (_super && p.Rage >= 100)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Rage = 0; p.SuperHits = 0; p.Heavy = false;
|
|
|
|
|
|
p.Set(DuelState.Super);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Super, true));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_leap && p.LeapCd <= 0 && p.Stamina >= LEAP_COST)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Stamina -= LEAP_COST; p.LeapCd = LEAP_COOLDOWN;
|
|
|
|
|
|
p.StruckThisSwing = false; p.Heavy = false;
|
|
|
|
|
|
p.Set(DuelState.Leap);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Leap, true));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_special && p.SpecialCooldown <= 0) { DoSpecial(p, Enemy); return; }
|
|
|
|
|
|
if (_wall && _perks.ShieldWall && p.WallCd <= 0) { StartWall(p, WALL_TIME); p.WallCd = WALL_COOLDOWN; return; }
|
|
|
|
|
|
if (_heavy && _perks.HeavyStrike && p.HeavyCd <= 0 && p.Stamina >= HEAVY_COST)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Stamina -= HEAVY_COST;
|
|
|
|
|
|
p.HeavyCd = HEAVY_COOLDOWN;
|
|
|
|
|
|
p.StruckThisSwing = false;
|
|
|
|
|
|
p.Heavy = true;
|
|
|
|
|
|
p.Set(DuelState.Windup);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
double dodgeCost = DODGE_COST * _perks.DodgeCostMult;
|
|
|
|
|
|
if (_dodge && p.Stamina >= dodgeCost)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Stamina -= dodgeCost;
|
|
|
|
|
|
p.Set(DuelState.Dodge);
|
|
|
|
|
|
_dodgeDir = MoveDir != 0 ? MoveDir : -p.Facing;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_attack && p.Stamina >= ATTACK_COST)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Stamina -= ATTACK_COST;
|
|
|
|
|
|
p.StruckThisSwing = false;
|
|
|
|
|
|
p.Heavy = false;
|
|
|
|
|
|
p.Set(DuelState.Windup);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (BlockHeld)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (p.State != DuelState.Block) { p.Set(DuelState.Block); p.BlockSince = Time; }
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (p.State == DuelState.Block) { p.Set(DuelState.Ready); p.BlockSince = -1; }
|
|
|
|
|
|
if (MoveDir != 0) Move(p, MoveDir * p.Speed * dt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int _dodgeDir;
|
|
|
|
|
|
|
|
|
|
|
|
// ── Gegner-KI ───────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
void EnemyAi(double dt)
|
|
|
|
|
|
{
|
|
|
|
|
|
var e = Enemy; var p = Player;
|
|
|
|
|
|
double dist = Math.Abs(p.X - e.X);
|
|
|
|
|
|
double speed = e.Speed * (e.Slow > 0 ? 0.45 : 1);
|
2026-11-09 16:13:28 +01:00
|
|
|
|
// Ansturm: während des langen Ausholens auf den Spieler zu rennen
|
|
|
|
|
|
if (_charging && e.State == DuelState.Windup)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dist > e.Reach * 0.75) Move(e, (p.X >= e.X ? 1 : -1) * speed * 2.4 * dt);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// Raufbold: Serie – nach dem Schlag gleich der nächste, mit kurzem Ausholen
|
|
|
|
|
|
if (Style == "brawler" && _comboLeft > 0 && e.State == DuelState.Recover && e.StateTime > e.RecoverTime * 0.35)
|
|
|
|
|
|
{
|
|
|
|
|
|
_comboLeft--;
|
|
|
|
|
|
if (e.Stamina >= ATTACK_COST * 0.6 && dist < e.Reach * 1.1)
|
|
|
|
|
|
{
|
|
|
|
|
|
e.Stamina -= ATTACK_COST * 0.6;
|
|
|
|
|
|
e.StruckThisSwing = false;
|
|
|
|
|
|
e.Set(DuelState.Windup);
|
|
|
|
|
|
e.StateTime = e.Windup * 0.45; // kürzer angekündigt
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-11-08 12:57:20 +01:00
|
|
|
|
if (e.Busy && e.State != DuelState.Block) return;
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
|
if (EnemyPassive) return;
|
2026-11-09 16:13:28 +01:00
|
|
|
|
if (Style == "champion") _chargeIn -= dt;
|
2026-11-08 12:57:20 +01:00
|
|
|
|
|
2026-11-09 16:13:28 +01:00
|
|
|
|
// Spieler holt aus: manchmal blocken (je Stil öfter oder seltener)
|
|
|
|
|
|
double blockMul = Style switch { "clumsy" => 0.5, "brawler" => 0.4, "spear" => 1.4, _ => 1 };
|
|
|
|
|
|
if (!EnemyAttacksOnly && p.State == DuelState.Windup && dist < p.Reach + 40 * SCALE && e.State != DuelState.Block && _rng.NextDouble() < (_champion ? 0.45 : 0.3) * blockMul * dt * 12)
|
2026-11-08 12:57:20 +01:00
|
|
|
|
{
|
|
|
|
|
|
e.Set(DuelState.Block); e.BlockSince = Time;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.State == DuelState.Block)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.StateTime > 0.5 + _rng.NextDouble() * 0.4) { e.Set(DuelState.Ready); e.BlockSince = -1; }
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_thinkIn -= dt;
|
|
|
|
|
|
if (_thinkIn <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_thinkIn = 0.12 + _rng.NextDouble() * 0.18;
|
2026-11-09 16:13:28 +01:00
|
|
|
|
// Champion: Ansturm aus der Distanz (lange angekündigt, schwerer Schlag)
|
|
|
|
|
|
if (Style == "champion" && !EnemyAttacksOnly && _chargeIn <= 0 && dist > e.Reach * 1.2 && e.Stamina >= 30)
|
|
|
|
|
|
{
|
|
|
|
|
|
_chargeIn = CHARGE_EVERY * (0.8 + 0.4 * _rng.NextDouble());
|
|
|
|
|
|
e.Stamina -= 30;
|
|
|
|
|
|
e.StruckThisSwing = false;
|
|
|
|
|
|
e.Heavy = true; e.DmgMult = CHARGE_MULT; _charging = true; _feint = false;
|
|
|
|
|
|
e.Set(DuelState.Windup);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Charge, false));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.Stamina < (Style == "brawler" ? 10 : 25)) _aiMove = -1; // erschöpft: zurückweichen
|
|
|
|
|
|
else if (dist > e.Reach * 0.9) _aiMove = 1; // heran
|
|
|
|
|
|
else if (Style == "spear" && dist < e.Reach * 0.7) _aiMove = -1; // Speer: Abstand halten
|
|
|
|
|
|
else if (Style != "brawler" && dist < e.Reach * 0.45) _aiMove = -1; // zu nah (der Raufbold drängt)
|
|
|
|
|
|
else if (Style == "clumsy" && _rng.NextDouble() < 0.25) _aiMove = -1; // unsicher, weicht zurück
|
2026-11-08 12:57:20 +01:00
|
|
|
|
else _aiMove = _rng.NextDouble() < 0.2 ? (_rng.NextDouble() < 0.5 ? 1 : -1) : 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (dist < e.Reach && e.Stamina >= ATTACK_COST && _rng.NextDouble() < (_champion ? 0.65 : 0.5))
|
|
|
|
|
|
{
|
|
|
|
|
|
e.Stamina -= ATTACK_COST;
|
|
|
|
|
|
e.StruckThisSwing = false;
|
2026-11-09 16:13:28 +01:00
|
|
|
|
e.Heavy = false; e.DmgMult = 1; _secondDone = false;
|
2026-11-08 12:57:20 +01:00
|
|
|
|
e.Set(DuelState.Windup);
|
|
|
|
|
|
_feint = _champion && _rng.NextDouble() < 0.15; // Champions täuschen an
|
2026-11-09 16:13:28 +01:00
|
|
|
|
if (Style == "brawler" && _rng.NextDouble() < 0.6) _comboLeft = 1 + _rng.Next(2);
|
2026-11-08 12:57:20 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
int toward = p.X >= e.X ? 1 : -1;
|
|
|
|
|
|
if (_aiMove != 0) Move(e, _aiMove * toward * speed * dt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool _feint;
|
|
|
|
|
|
|
|
|
|
|
|
// ── Ablauf je Kämpfer ───────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
void Tick(DuelFighter f, double dt)
|
|
|
|
|
|
{
|
|
|
|
|
|
f.StateTime += dt;
|
|
|
|
|
|
f.SpecialCooldown = Math.Max(0, f.SpecialCooldown - dt);
|
|
|
|
|
|
f.HeavyCd = Math.Max(0, f.HeavyCd - dt);
|
|
|
|
|
|
f.WallCd = Math.Max(0, f.WallCd - dt);
|
|
|
|
|
|
f.LeapCd = Math.Max(0, f.LeapCd - dt);
|
|
|
|
|
|
f.Invulnerable = Math.Max(0, f.Invulnerable - dt);
|
|
|
|
|
|
f.Slow = Math.Max(0, f.Slow - dt);
|
|
|
|
|
|
double regen = (f.State == DuelState.Block ? REGEN_BLOCKING : REGEN) * (f.IsPlayer ? _perks.RegenMult : 1);
|
|
|
|
|
|
if (!f.Busy) f.Stamina = Math.Min(100, f.Stamina + regen * dt);
|
|
|
|
|
|
if (f.IsPlayer) f.Stamina = Math.Max(f.Stamina, _perks.StaminaFloor);
|
|
|
|
|
|
var other = f.IsPlayer ? Enemy : Player;
|
2026-11-09 16:13:28 +01:00
|
|
|
|
double windup = (f.Heavy ? (f.IsPlayer ? HEAVY_WINDUP * _perks.WindupMult : CHARGE_WINDUP) : f.Windup) * (f.Slow > 0 ? 1.6 : 1);
|
2026-11-08 12:57:20 +01:00
|
|
|
|
|
|
|
|
|
|
switch (f.State)
|
|
|
|
|
|
{
|
|
|
|
|
|
case DuelState.Windup:
|
|
|
|
|
|
if (!f.IsPlayer && _feint && f.StateTime > windup * 0.6) { _feint = false; f.Set(DuelState.Ready); break; }
|
|
|
|
|
|
if (f.StateTime >= windup) f.Set(DuelState.Strike);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Strike:
|
|
|
|
|
|
if (!f.StruckThisSwing) { f.StruckThisSwing = true; TryHit(f, other); }
|
2026-11-09 16:13:28 +01:00
|
|
|
|
// Doppelschlag (zwei Schwerter): zweiter Treffer kurz danach
|
|
|
|
|
|
if (!f.IsPlayer && Style == "dual" && !_secondDone && f.StateTime >= 0.09) { _secondDone = true; TryHit(f, other); }
|
2026-11-08 12:57:20 +01:00
|
|
|
|
if (f.StateTime >= f.StrikeTime) f.Set(DuelState.Recover);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Recover:
|
2026-11-09 16:13:28 +01:00
|
|
|
|
if (!f.IsPlayer && _charging) { _charging = false; f.DmgMult = 1; }
|
2026-11-08 12:57:20 +01:00
|
|
|
|
if (f.StateTime >= f.RecoverTime) { f.Heavy = false; f.Set(DuelState.Ready); }
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Dodge:
|
|
|
|
|
|
Move(f, _dodgeDir * DODGE_DIST / DODGE_TIME * dt);
|
|
|
|
|
|
if (f.StateTime >= DODGE_TIME) f.Set(DuelState.Ready);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Hit:
|
|
|
|
|
|
if (f.StateTime >= HIT_TIME) f.Set(DuelState.Ready);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Stunned:
|
|
|
|
|
|
if (f.StateTime >= f.StunLeft) f.Set(DuelState.Ready);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Wall:
|
|
|
|
|
|
if (f.StateTime >= f.WallTime) f.Set(DuelState.Ready);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Leap:
|
|
|
|
|
|
if (f.StateTime < LEAP_HIT) Move(f, f.Facing * LEAP_DIST / LEAP_HIT * dt);
|
|
|
|
|
|
else if (!f.StruckThisSwing)
|
|
|
|
|
|
{
|
|
|
|
|
|
f.StruckThisSwing = true;
|
|
|
|
|
|
f.DmgMult = LEAP_MULT;
|
|
|
|
|
|
TryHit(f, other);
|
|
|
|
|
|
f.DmgMult = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (f.StateTime >= LEAP_TIME) f.Set(DuelState.Recover);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case DuelState.Super:
|
|
|
|
|
|
if (f.SuperHits < SUPER_HITS.Length && f.StateTime >= SUPER_HITS[f.SuperHits])
|
|
|
|
|
|
{
|
|
|
|
|
|
// nachsetzen, falls der Gegner zurückgewichen ist
|
|
|
|
|
|
double gap = Math.Abs(other.X - f.X) - f.Reach * 0.75;
|
|
|
|
|
|
if (gap > 0) Move(f, f.Facing * Math.Min(gap, 160 * SCALE));
|
|
|
|
|
|
f.SuperHits++;
|
|
|
|
|
|
f.DmgMult = SUPER_MULT; f.Unblockable = true;
|
|
|
|
|
|
TryHit(f, other);
|
|
|
|
|
|
f.DmgMult = 1; f.Unblockable = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (f.StateTime >= SUPER_TIME) f.Set(DuelState.Recover);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Move(DuelFighter f, double dx)
|
|
|
|
|
|
{
|
|
|
|
|
|
var other = f.IsPlayer ? Enemy : Player;
|
|
|
|
|
|
double nx = Math.Clamp(f.X + dx, FLOOR_MIN, FLOOR_MAX);
|
|
|
|
|
|
// nicht durcheinander hindurch (Mindestabstand)
|
|
|
|
|
|
if (Math.Abs(nx - other.X) < GAP && Math.Abs(nx - other.X) < Math.Abs(f.X - other.X)) return;
|
|
|
|
|
|
f.X = nx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TryHit(DuelFighter a, DuelFighter d)
|
|
|
|
|
|
{
|
|
|
|
|
|
double dist = Math.Abs(d.X - a.X);
|
|
|
|
|
|
bool inFront = Math.Sign(d.X - a.X) == a.Facing || dist < 80 * SCALE;
|
|
|
|
|
|
if (dist > a.Reach || !inFront || Over) return;
|
|
|
|
|
|
if (d.State == DuelState.Dodge) { Events.Add(new DuelEvent(DuelEventType.Dodged, d.IsPlayer)); return; }
|
|
|
|
|
|
// in der Luft (Sprungangriff) trifft nichts
|
|
|
|
|
|
if (d.State == DuelState.Leap && d.StateTime >= LEAP_AIR_FROM && d.StateTime <= LEAP_AIR_TO)
|
|
|
|
|
|
{ Events.Add(new DuelEvent(DuelEventType.Dodged, d.IsPlayer)); return; }
|
|
|
|
|
|
// Super-Angriff: nicht zu unterbrechen
|
|
|
|
|
|
if (d.State == DuelState.Super) { Events.Add(new DuelEvent(DuelEventType.Blocked, d.IsPlayer)); return; }
|
|
|
|
|
|
|
|
|
|
|
|
if (d.State == DuelState.Wall || d.Invulnerable > 0) { Events.Add(new DuelEvent(DuelEventType.Blocked, d.IsPlayer)); return; }
|
|
|
|
|
|
bool crit = a.SicaHits > 0 || _rng.NextDouble() < a.Crit;
|
|
|
|
|
|
if (a.SicaHits > 0) a.SicaHits--;
|
|
|
|
|
|
double critMult = a.IsPlayer ? _perks.CritMult : Balance.CRIT_MULT;
|
|
|
|
|
|
double dmg = a.HitFraction * d.MaxHp * (0.9 + 0.2 * _rng.NextDouble()) * (crit ? critMult : 1) * a.DmgMult;
|
|
|
|
|
|
if (a.IsPlayer && d.Hp < d.MaxHp * 0.3) dmg *= 1 + _perks.Execute; // Gnadenstoß
|
|
|
|
|
|
if (a.Heavy)
|
|
|
|
|
|
{
|
|
|
|
|
|
dmg *= HEAVY_MULT;
|
2026-11-09 16:13:28 +01:00
|
|
|
|
bool parried = !a.IsPlayer && d.State == DuelState.Block && d.BlockSince >= 0
|
|
|
|
|
|
&& Time - d.BlockSince <= PARRY_WINDOW + _perks.ParryBonus + 0.1;
|
|
|
|
|
|
if (d.State == DuelState.Block && !parried && !a.IsPlayer)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Ansturm gegen den Block: Deckung hält, kostet aber viel Ausdauer
|
|
|
|
|
|
d.Stamina = Math.Max(0, d.Stamina - BLOCK_HIT_COST * 2);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Blocked, d.IsPlayer));
|
|
|
|
|
|
Damage(a, d, dmg * 0.15, false, silent: true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (d.State == DuelState.Block && a.IsPlayer)
|
2026-11-08 12:57:20 +01:00
|
|
|
|
{
|
|
|
|
|
|
// Schwerer Schlag durchbricht jeden Block
|
|
|
|
|
|
d.StunLeft = 0.6; d.Set(DuelState.Stunned);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.GuardBreak, a.IsPlayer));
|
|
|
|
|
|
Damage(a, d, dmg, crit);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double parryWindow = PARRY_WINDOW + (d.IsPlayer ? _perks.ParryBonus : 0);
|
|
|
|
|
|
if (a.Unblockable && d.State == DuelState.Block)
|
|
|
|
|
|
{
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.GuardBreak, a.IsPlayer));
|
|
|
|
|
|
d.BlockSince = -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (d.State == DuelState.Block && Math.Sign(a.X - d.X) == d.Facing)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Parade: Block erst kurz vor dem Treffer gehoben → Angreifer betäubt, kein Schaden
|
|
|
|
|
|
if (d.BlockSince >= 0 && Time - d.BlockSince <= parryWindow)
|
|
|
|
|
|
{
|
2026-11-09 16:13:28 +01:00
|
|
|
|
a.StunLeft = PARRY_STUN * (a.Heavy ? 1.6 : 1); a.Set(DuelState.Stunned);
|
|
|
|
|
|
if (a.Heavy) { a.Heavy = false; _charging = false; a.DmgMult = 1; }
|
|
|
|
|
|
if (d.IsPlayer) PlayerParries++;
|
2026-11-08 12:57:20 +01:00
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Parry, d.IsPlayer));
|
|
|
|
|
|
AddRage(d, RAGE_PARRY);
|
|
|
|
|
|
// Riposte: sofortiger kritischer Gegenschlag
|
|
|
|
|
|
Damage(d, a, d.HitFraction * a.MaxHp * Balance.CRIT_MULT, true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
d.Stamina -= BLOCK_HIT_COST * (d.IsPlayer ? _perks.BlockCostMult : 1);
|
|
|
|
|
|
if (d.Stamina <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
d.Stamina = 0; d.StunLeft = 0.6; d.Set(DuelState.Stunned);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.GuardBreak, a.IsPlayer));
|
|
|
|
|
|
Damage(a, d, dmg * 0.5, false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Blocked, d.IsPlayer));
|
|
|
|
|
|
AddRage(d, RAGE_BLOCK);
|
|
|
|
|
|
Damage(a, d, dmg * 0.05, false, silent: true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Damage(a, d, dmg, crit);
|
|
|
|
|
|
if (d.Alive) d.Set(DuelState.Hit);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Damage(DuelFighter a, DuelFighter d, double dmg, bool crit, bool silent = false)
|
|
|
|
|
|
{
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
|
if (!a.IsPlayer) dmg *= EnemyDamageMult;
|
2026-11-09 16:13:28 +01:00
|
|
|
|
if (d.IsPlayer) DamageToPlayer += Math.Min(d.Hp, dmg);
|
3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:24:20 +01:00
|
|
|
|
d.Hp = Math.Max(GuardHp ? d.MaxHp * 0.15 : 0, d.Hp - dmg);
|
2026-11-08 12:57:20 +01:00
|
|
|
|
if (!silent) Events.Add(new DuelEvent(DuelEventType.Hit, a.IsPlayer, dmg, crit));
|
|
|
|
|
|
if (!silent && a.State != DuelState.Super) { AddRage(a, RAGE_HIT); AddRage(d, RAGE_HURT); }
|
|
|
|
|
|
if (d.IsPlayer && d.Hp > 0 && _perks.SecondWind > 0 && !d.SecondWindUsed && d.Hp < d.MaxHp * 0.25)
|
|
|
|
|
|
{
|
|
|
|
|
|
d.SecondWindUsed = true;
|
|
|
|
|
|
double heal = d.MaxHp * _perks.SecondWind;
|
|
|
|
|
|
d.Hp += heal;
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Heal, true, heal));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (d.Hp <= 0 && !Over)
|
|
|
|
|
|
{
|
|
|
|
|
|
Over = true;
|
|
|
|
|
|
PlayerWon = a.IsPlayer;
|
|
|
|
|
|
d.Set(DuelState.Down);
|
|
|
|
|
|
a.Set(DuelState.Victory);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Ko, a.IsPlayer));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DoSpecial(DuelFighter f, DuelFighter other)
|
|
|
|
|
|
{
|
|
|
|
|
|
f.SpecialCooldown = SpecialCooldownTotal;
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Special, true));
|
|
|
|
|
|
double dist = Math.Abs(other.X - f.X);
|
|
|
|
|
|
switch (PlayerSpecial)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Special.ShieldBash:
|
|
|
|
|
|
if (dist <= f.Reach * 1.2)
|
|
|
|
|
|
{
|
|
|
|
|
|
other.StunLeft = 1.4 + _perks.StunAdd; other.Set(DuelState.Stunned);
|
|
|
|
|
|
Damage(f, other, f.HitFraction * other.MaxHp * 0.5, false);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Stun, true));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_perks.BulwarkTime > 0) f.Invulnerable = _perks.BulwarkTime; // Bollwerk
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Special.Net:
|
|
|
|
|
|
if (dist <= f.Reach * 1.8 * _perks.NetRangeMult)
|
|
|
|
|
|
{
|
|
|
|
|
|
other.Slow = 3.5 + _perks.NetSlowAdd;
|
|
|
|
|
|
if (_perks.NetStun > 0) { other.StunLeft = _perks.NetStun; other.Set(DuelState.Stunned); }
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Stun, true));
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Special.Sica:
|
|
|
|
|
|
f.SicaHits = 3 + _perks.SicaExtra;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Special.Endure:
|
|
|
|
|
|
double heal = Math.Min(f.MaxHp - f.Hp, f.MaxHp * (0.3 + _perks.HealAdd));
|
|
|
|
|
|
f.Hp += heal;
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Heal, true, heal));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Wut sammeln (nur der Spieler hat einen Super-Angriff); einmal melden, wenn sie voll ist.
|
|
|
|
|
|
void AddRage(DuelFighter f, double amount)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!f.IsPlayer || f.Rage >= 100) return;
|
|
|
|
|
|
f.Rage = Math.Min(100, f.Rage + amount);
|
|
|
|
|
|
if (f.Rage >= 100) Events.Add(new DuelEvent(DuelEventType.SuperReady, true));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void StartWall(DuelFighter f, double seconds)
|
|
|
|
|
|
{
|
|
|
|
|
|
f.WallTime = seconds;
|
|
|
|
|
|
f.Set(DuelState.Wall);
|
|
|
|
|
|
Events.Add(new DuelEvent(DuelEventType.Special, f.IsPlayer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Aufgeben (Pause → Aufgeben): zählt als Niederlage.
|
|
|
|
|
|
public void Surrender()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Over) return;
|
|
|
|
|
|
Over = true; PlayerWon = false;
|
|
|
|
|
|
Player.Set(DuelState.Down); Enemy.Set(DuelState.Victory);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|