Feldzugkarte, Reise in 3D, Kampfstile der Gegner, Missio, inszenierte Heimkehr
Stand von main 8c62f0dd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
109
Game/Duel.cs
109
Game/Duel.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
namespace GladiatorIdle
|
||||
{
|
||||
public enum DuelState { Ready, Windup, Strike, Recover, Block, Dodge, Hit, Stunned, Down, Victory, Wall, Leap, Super }
|
||||
public enum DuelEventType { Hit, Blocked, Parry, Dodged, GuardBreak, Special, Heal, Stun, Ko, Leap, Super, SuperReady }
|
||||
public enum DuelEventType { Hit, Blocked, Parry, Dodged, GuardBreak, Special, Heal, Stun, Ko, Leap, Super, SuperReady, Charge }
|
||||
|
||||
/// 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);
|
||||
@@ -102,6 +102,45 @@ namespace GladiatorIdle
|
||||
public double SpecialCooldownTotal => SPECIAL_COOLDOWN + _perks.SpecialCdAdd;
|
||||
double _thinkIn, _aiMove;
|
||||
|
||||
// ── 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
@@ -208,11 +247,32 @@ namespace GladiatorIdle
|
||||
var e = Enemy; var p = Player;
|
||||
double dist = Math.Abs(p.X - e.X);
|
||||
double speed = e.Speed * (e.Slow > 0 ? 0.45 : 1);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
if (e.Busy && e.State != DuelState.Block) return;
|
||||
if (EnemyPassive) return;
|
||||
if (Style == "champion") _chargeIn -= dt;
|
||||
|
||||
// Spieler holt aus: manchmal blocken
|
||||
if (!EnemyAttacksOnly && p.State == DuelState.Windup && dist < p.Reach + 40 * SCALE && e.State != DuelState.Block && _rng.NextDouble() < (_champion ? 0.45 : 0.3) * dt * 12)
|
||||
// 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)
|
||||
{
|
||||
e.Set(DuelState.Block); e.BlockSince = Time;
|
||||
return;
|
||||
@@ -227,17 +287,32 @@ namespace GladiatorIdle
|
||||
if (_thinkIn <= 0)
|
||||
{
|
||||
_thinkIn = 0.12 + _rng.NextDouble() * 0.18;
|
||||
if (e.Stamina < 25) _aiMove = -1; // erschöpft: zurückweichen
|
||||
else if (dist > e.Reach * 0.9) _aiMove = 1; // heran
|
||||
else if (dist < e.Reach * 0.45) _aiMove = -1; // zu nah
|
||||
// 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
|
||||
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;
|
||||
e.Heavy = false; e.DmgMult = 1; _secondDone = false;
|
||||
e.Set(DuelState.Windup);
|
||||
_feint = _champion && _rng.NextDouble() < 0.15; // Champions täuschen an
|
||||
if (Style == "brawler" && _rng.NextDouble() < 0.6) _comboLeft = 1 + _rng.Next(2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +337,7 @@ namespace GladiatorIdle
|
||||
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;
|
||||
double windup = (f.Heavy ? HEAVY_WINDUP * _perks.WindupMult : f.Windup) * (f.Slow > 0 ? 1.6 : 1);
|
||||
double windup = (f.Heavy ? (f.IsPlayer ? HEAVY_WINDUP * _perks.WindupMult : CHARGE_WINDUP) : f.Windup) * (f.Slow > 0 ? 1.6 : 1);
|
||||
|
||||
switch (f.State)
|
||||
{
|
||||
@@ -272,9 +347,12 @@ namespace GladiatorIdle
|
||||
break;
|
||||
case DuelState.Strike:
|
||||
if (!f.StruckThisSwing) { f.StruckThisSwing = true; TryHit(f, other); }
|
||||
// Doppelschlag (zwei Schwerter): zweiter Treffer kurz danach
|
||||
if (!f.IsPlayer && Style == "dual" && !_secondDone && f.StateTime >= 0.09) { _secondDone = true; TryHit(f, other); }
|
||||
if (f.StateTime >= f.StrikeTime) f.Set(DuelState.Recover);
|
||||
break;
|
||||
case DuelState.Recover:
|
||||
if (!f.IsPlayer && _charging) { _charging = false; f.DmgMult = 1; }
|
||||
if (f.StateTime >= f.RecoverTime) { f.Heavy = false; f.Set(DuelState.Ready); }
|
||||
break;
|
||||
case DuelState.Dodge:
|
||||
@@ -347,7 +425,17 @@ namespace GladiatorIdle
|
||||
if (a.Heavy)
|
||||
{
|
||||
dmg *= HEAVY_MULT;
|
||||
if (d.State == DuelState.Block)
|
||||
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)
|
||||
{
|
||||
// Schwerer Schlag durchbricht jeden Block
|
||||
d.StunLeft = 0.6; d.Set(DuelState.Stunned);
|
||||
@@ -368,7 +456,9 @@ namespace GladiatorIdle
|
||||
// Parade: Block erst kurz vor dem Treffer gehoben → Angreifer betäubt, kein Schaden
|
||||
if (d.BlockSince >= 0 && Time - d.BlockSince <= parryWindow)
|
||||
{
|
||||
a.StunLeft = PARRY_STUN; a.Set(DuelState.Stunned);
|
||||
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++;
|
||||
Events.Add(new DuelEvent(DuelEventType.Parry, d.IsPlayer));
|
||||
AddRage(d, RAGE_PARRY);
|
||||
// Riposte: sofortiger kritischer Gegenschlag
|
||||
@@ -395,6 +485,7 @@ namespace GladiatorIdle
|
||||
void Damage(DuelFighter a, DuelFighter d, double dmg, bool crit, bool silent = false)
|
||||
{
|
||||
if (!a.IsPlayer) dmg *= EnemyDamageMult;
|
||||
if (d.IsPlayer) DamageToPlayer += Math.Min(d.Hp, dmg);
|
||||
d.Hp = Math.Max(GuardHp ? d.MaxHp * 0.15 : 0, d.Hp - dmg);
|
||||
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); }
|
||||
|
||||
Reference in New Issue
Block a user