Rework Skadi combat costs, fix dead melee, add cooldown icons
Dragon melee never dealt damage at all: the damage block sat behind !isMelee, so bite, claw and spin played an animation, charged eitr and did nothing. Melee now sweeps for targets the way Fenrir's claws do, and costs nothing - it is the baseline attack that has to work at every tier. Everything Skadi casts now runs on stamina rather than eitr. Eitr food only exists from the Mistlands on, while the Cold Spell unlocks at Eikthyr and the drake at the Elder, so the old costs were either unpayable or, in the drake's case, silently ignored because UseEitr never checked affordability. Ranged volleys are charged per projectile so the sixty shard breath no longer costs the same as a three shard spit, capped so the widest one stays castable. The Cold Spell also stopped borrowing the Staff of Frost's damage, which handed out Mistlands numbers from Eikthyr and multiplied them by every shard. It now scales with progression, and the improved cast spreads one budget across its shards: wider, not stronger. The kick that played over every cast was Valheim's own SecondaryAttack, bound to the same Middle Mouse button - suppressed for a Skadi holding the spell. Moder now keeps its ranged attack on Middle Mouse in the air as on the ground, with no left hand attack aloft, and Fader's airborne branch is gone since its form cannot fly. Ability cooldowns finally show on the HUD, each with its own icon and a live countdown.
This commit is contained in:
parent
a8a14f0416
commit
fc7fd54404
4 changed files with 251 additions and 56 deletions
|
|
@ -49,9 +49,25 @@ namespace RacesOfValheim
|
|||
return live != null && live.Form == formRules.Form && live.CanAttackInForm;
|
||||
}
|
||||
|
||||
private const float ATTACK_COST = 20f;
|
||||
private const float ATTACK_COOLDOWN = 3f;
|
||||
|
||||
// Ranged volleys charge per projectile rather than a flat fee, so the 20- and 60-shard
|
||||
// breaths cost what they are worth instead of the same as a three-shard drake spit.
|
||||
// Stamina rather than eitr, for the same reason the Cold Spell uses it: eitr food only
|
||||
// exists from the Mistlands on, while the drake form arrives at the Elder, so an eitr
|
||||
// cost left the earliest dragon tiers with no attack they could actually pay for.
|
||||
private const float STAMINA_PER_PROJECTILE = 1.5f;
|
||||
// Ceiling so the widest breath stays castable: 60 shards would otherwise ask 90 stamina.
|
||||
private const float MAX_VOLLEY_STAMINA = 85f;
|
||||
|
||||
// Melee costs nothing at all - it is the baseline attack that has to work at every tier,
|
||||
// including the long stretch where the player has no eitr whatsoever.
|
||||
private const float MELEE_RADIUS = 3f;
|
||||
private const float MODER_MELEE_DAMAGE = 90f;
|
||||
private const float FADER_MELEE_DAMAGE = 120f;
|
||||
private const float FADER_SPIN_DAMAGE = 100f;
|
||||
private const float FADER_SPIN_RADIUS = 5f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Active = this;
|
||||
|
|
@ -126,7 +142,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
|
||||
if (HasAttackForButton(0) && Time.time - lastAttackTime >= ATTACK_COOLDOWN)
|
||||
{
|
||||
StartCoroutine(PerformAttackCoroutine(0));
|
||||
}
|
||||
|
|
@ -148,15 +164,44 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// Airborne Moder keeps the same hand as the ground: the ranged breath is Middle Mouse, and
|
||||
// Left Mouse has no attack in the air (its ground bite and claws cannot reach from up
|
||||
// there). Checked before the cooldown so a stray left click does not eat the next volley.
|
||||
private bool HasAttackForButton(int button)
|
||||
{
|
||||
if (formRules == null) return false;
|
||||
|
||||
bool airborne = isFlying || isLanding;
|
||||
if (airborne && formRules.Form == SkadiProgression.FormType.Moder && button != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TrySpendVolleyStamina(int projCount)
|
||||
{
|
||||
float cost = Mathf.Min(STAMINA_PER_PROJECTILE * projCount, MAX_VOLLEY_STAMINA);
|
||||
if (!Player.m_localPlayer.HaveStamina(cost))
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough stamina");
|
||||
return false;
|
||||
}
|
||||
Player.m_localPlayer.UseStamina(cost);
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerator PerformAttackCoroutine(int button)
|
||||
{
|
||||
lastAttackTime = Time.time;
|
||||
SkadiRace.ApplyCooldownIcon(SkadiRace.ATTACK_COOLDOWN_SE, ATTACK_COOLDOWN);
|
||||
|
||||
if (formRules.Form == SkadiProgression.FormType.Drake)
|
||||
{
|
||||
if (button == 2) yield break; // Drake only uses LMB
|
||||
|
||||
Player.m_localPlayer.UseEitr(ATTACK_COST);
|
||||
|
||||
if (!TrySpendVolleyStamina(3)) yield break;
|
||||
if (anim != null) anim.SetTrigger("attack");
|
||||
|
||||
// Delay to match animation spit timing
|
||||
|
|
@ -229,12 +274,17 @@ namespace RacesOfValheim
|
|||
projDelay = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
Player.m_localPlayer.UseEitr(ATTACK_COST);
|
||||
|
||||
if (!isMelee && !TrySpendVolleyStamina(projCount)) yield break;
|
||||
if (anim != null) anim.SetTrigger(attackTrigger);
|
||||
|
||||
|
||||
yield return new WaitForSeconds(projDelay);
|
||||
|
||||
if (isMelee)
|
||||
{
|
||||
ExecuteMeleeDamage(MODER_MELEE_DAMAGE, MELEE_RADIUS);
|
||||
}
|
||||
|
||||
if (!isMelee && projName != null)
|
||||
{
|
||||
GameObject projPrefab = PrefabManager.Cache.GetPrefab<GameObject>(projName);
|
||||
|
|
@ -277,51 +327,50 @@ namespace RacesOfValheim
|
|||
int projCount = 1;
|
||||
float projDelay = 0.5f;
|
||||
bool isMelee = true;
|
||||
float meleeDamage = FADER_MELEE_DAMAGE;
|
||||
float meleeRadius = MELEE_RADIUS;
|
||||
|
||||
if (isFlying || isLanding)
|
||||
// No airborne branch here: the flight toggle in Update excludes SkeletonDragon,
|
||||
// so this form never leaves the ground and any air attack would be unreachable.
|
||||
if (button == 2)
|
||||
{
|
||||
// Air attack (Meteors replacement -> Ice Barrage)
|
||||
attackTrigger = "attack_roar"; // taunt animation has issues in air
|
||||
projName = "dragon_ice_projectile"; // spawn_fader_meteors is buggy without Fader boss script
|
||||
projCount = 16;
|
||||
projDelay = 1.0f;
|
||||
// Ground MMB (Frost Breath stream)
|
||||
attackTrigger = "attack_flamebreath";
|
||||
projName = "hatchling_cold_projectile";
|
||||
projCount = 60; // Tripled!
|
||||
projDelay = 0.5f;
|
||||
isMelee = false;
|
||||
}
|
||||
else if (button == 1)
|
||||
{
|
||||
// Ground RMB (Spin) - hits all around rather than in a forward arc
|
||||
attackTrigger = "attack_Spin";
|
||||
isMelee = true;
|
||||
projDelay = 0.5f;
|
||||
meleeDamage = FADER_SPIN_DAMAGE;
|
||||
meleeRadius = FADER_SPIN_RADIUS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button == 2)
|
||||
{
|
||||
// Ground MMB (Frost Breath stream)
|
||||
attackTrigger = "attack_flamebreath";
|
||||
projName = "hatchling_cold_projectile";
|
||||
projCount = 60; // Tripled!
|
||||
projDelay = 0.5f;
|
||||
isMelee = false;
|
||||
}
|
||||
else if (button == 1)
|
||||
{
|
||||
// Ground RMB (Spin)
|
||||
attackTrigger = "attack_Spin";
|
||||
isMelee = true;
|
||||
projDelay = 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ground LMB (Melee mix - bite/claws)
|
||||
float rand = UnityEngine.Random.value;
|
||||
if (rand < 0.33f) attackTrigger = "attack_bite";
|
||||
else if (rand < 0.66f) attackTrigger = "attack_ClawL";
|
||||
else attackTrigger = "attack_ClawR";
|
||||
isMelee = true;
|
||||
projDelay = 0.5f;
|
||||
}
|
||||
// Ground LMB (Melee mix - bite/claws)
|
||||
float rand = UnityEngine.Random.value;
|
||||
if (rand < 0.33f) attackTrigger = "attack_bite";
|
||||
else if (rand < 0.66f) attackTrigger = "attack_ClawL";
|
||||
else attackTrigger = "attack_ClawR";
|
||||
isMelee = true;
|
||||
projDelay = 0.5f;
|
||||
}
|
||||
|
||||
Player.m_localPlayer.UseEitr(ATTACK_COST);
|
||||
if (!isMelee && !TrySpendVolleyStamina(projCount)) yield break;
|
||||
if (anim != null) anim.SetTrigger(attackTrigger);
|
||||
|
||||
|
||||
yield return new WaitForSeconds(projDelay);
|
||||
|
||||
if (isMelee)
|
||||
{
|
||||
ExecuteMeleeDamage(meleeDamage, meleeRadius);
|
||||
}
|
||||
|
||||
if (!isMelee && projName != null)
|
||||
{
|
||||
GameObject projPrefab = PrefabManager.Cache.GetPrefab<GameObject>(projName);
|
||||
|
|
@ -377,6 +426,69 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// The dragon forms never go through Humanoid.StartAttack - SkadiAttackPatch blocks it, and
|
||||
// they carry no weapon - so the bite, claw and spin animations landed no damage at all and
|
||||
// simply burned eitr. Sweep for targets the way FenrirBehaviors does for its claws.
|
||||
private void ExecuteMeleeDamage(float baseDamage, float radius)
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
|
||||
Vector3 playerPos = Player.m_localPlayer.transform.position;
|
||||
Vector3 forward = Player.m_localPlayer.transform.forward;
|
||||
Vector3 attackPoint = playerPos + forward * 2f + Vector3.up * 1f;
|
||||
|
||||
// Spin sweeps all around; the directional attacks stay in a forward arc.
|
||||
bool fullCircle = radius >= FADER_SPIN_RADIUS;
|
||||
float totalDamage = baseDamage + Player.m_localPlayer.GetSkillLevel(Skills.SkillType.Unarmed);
|
||||
if (fullCircle) attackPoint = playerPos + Vector3.up * 1f;
|
||||
|
||||
int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle");
|
||||
Collider[] hits = Physics.OverlapSphere(attackPoint, radius, layerMask);
|
||||
System.Collections.Generic.HashSet<GameObject> hitObjects = new System.Collections.Generic.HashSet<GameObject>();
|
||||
|
||||
foreach (Collider hit in hits)
|
||||
{
|
||||
if (hit.gameObject == Player.m_localPlayer.gameObject) continue;
|
||||
if (hit.attachedRigidbody != null && hit.attachedRigidbody.gameObject == Player.m_localPlayer.gameObject) continue;
|
||||
|
||||
IDestructible target = hit.GetComponentInParent<IDestructible>();
|
||||
if (target == null) continue;
|
||||
|
||||
Character characterTarget = target as Character;
|
||||
if (characterTarget != null && characterTarget == Player.m_localPlayer) continue;
|
||||
|
||||
GameObject targetObj = (target as MonoBehaviour)?.gameObject;
|
||||
if (targetObj != null)
|
||||
{
|
||||
if (hitObjects.Contains(targetObj)) continue;
|
||||
hitObjects.Add(targetObj);
|
||||
}
|
||||
|
||||
Vector3 targetCenter = hit.bounds.center;
|
||||
Vector3 dirToTarget = (targetCenter - playerPos).normalized;
|
||||
if (!fullCircle && Vector3.Angle(forward, dirToTarget) >= 70f) continue;
|
||||
|
||||
Vector3 eyePos = playerPos + Vector3.up * 1.5f;
|
||||
if (Physics.Linecast(eyePos, targetCenter, out RaycastHit rayHit, LayerMask.GetMask("Default", "static_solid", "terrain", "piece"))) continue;
|
||||
|
||||
HitData hitData = new HitData();
|
||||
// Frost-flavoured maul; SkadiDamagePatch tops this up with the per-tier frost bonus.
|
||||
hitData.m_damage.m_blunt = totalDamage * 0.6f;
|
||||
hitData.m_damage.m_frost = totalDamage * 0.4f;
|
||||
hitData.m_pushForce = 40f;
|
||||
hitData.m_point = targetCenter;
|
||||
hitData.m_dir = dirToTarget;
|
||||
hitData.m_skill = Skills.SkillType.Unarmed;
|
||||
hitData.m_dodgeable = true;
|
||||
hitData.m_blockable = true;
|
||||
hitData.m_hitType = HitData.HitType.PlayerHit;
|
||||
hitData.m_toolTier = 0;
|
||||
hitData.SetAttacker(Player.m_localPlayer);
|
||||
|
||||
target.Damage(hitData);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (Active == this) Active = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue