feat: Fenrir forms sense nearby creatures like the Aswid
Every Fenrir form (Wolf, Ulv, Fenring, Cultist) now lights each untamed creature within 100 m with the Aswid's green glow; the human does not. The glow moved out of AswidRace into a shared HunterSenses, which the Aswid now calls too, unchanged. New setting Fenrir - Superhuman Senses / Detection Radius; the light follows the Aswid's Marker Light settings. Compendium line in English, Italian and Russian. Asked for by a friend of MrBiffty.
This commit is contained in:
parent
1c4d1c7b6a
commit
fc5d6b8abc
8 changed files with 111 additions and 70 deletions
|
|
@ -329,9 +329,6 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
private float m_tintCheckTimer = 0f;
|
||||
private float sensesCheckTimer = 0f;
|
||||
|
||||
private Dictionary<Character, GameObject> activeSensesLight = new Dictionary<Character, GameObject>();
|
||||
|
||||
public static float GetEnslaveCooldown()
|
||||
{
|
||||
|
|
@ -373,6 +370,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
seman.RemoveStatusEffect(myHash);
|
||||
}
|
||||
HunterSenses.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -381,64 +379,8 @@ namespace RacesOfValheim
|
|||
seman.AddStatusEffect(myHash, true);
|
||||
}
|
||||
|
||||
sensesCheckTimer -= Time.deltaTime;
|
||||
if (sensesCheckTimer <= 0f)
|
||||
{
|
||||
sensesCheckTimer = AswidConfig.SensesRefreshInterval.Value; // TTL is 2s
|
||||
|
||||
List<Character> allChars = Character.GetAllCharacters();
|
||||
Vector3 myPos = Player.m_localPlayer.transform.position;
|
||||
|
||||
int markHash = "SE_AswidSensesMark".GetStableHashCode();
|
||||
HashSet<Character> inRangeChars = new HashSet<Character>();
|
||||
|
||||
foreach (var c in allChars)
|
||||
{
|
||||
if (c == null || c == Player.m_localPlayer || c.IsDead() || c.IsTamed()) continue;
|
||||
|
||||
float dist = Vector3.Distance(c.transform.position, myPos);
|
||||
if (dist <= AswidConfig.SensesRadius.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
inRangeChars.Add(c);
|
||||
c.GetSEMan().AddStatusEffect(markHash, true); // Keep the malus as requested
|
||||
|
||||
// Locally generate the visual
|
||||
if (!activeSensesLight.ContainsKey(c))
|
||||
{
|
||||
GameObject lightObj = new GameObject("AswidSensesLight");
|
||||
lightObj.transform.SetParent(c.transform);
|
||||
lightObj.transform.position = c.GetCenterPoint();
|
||||
|
||||
Light pLight = lightObj.AddComponent<Light>();
|
||||
pLight.type = LightType.Point;
|
||||
pLight.color = Color.green;
|
||||
pLight.range = AswidConfig.SensesLightRange.Value;
|
||||
pLight.intensity = AswidConfig.SensesLightIntensity.Value;
|
||||
pLight.shadows = LightShadows.None;
|
||||
|
||||
activeSensesLight[c] = lightObj;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Jotunn.Logger.LogError($"[Aswid] Error processing mob {c.name}: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Character> keysToRemove = new List<Character>();
|
||||
foreach (var kvp in activeSensesLight)
|
||||
{
|
||||
if (kvp.Key == null || kvp.Key.IsDead() || !inRangeChars.Contains(kvp.Key))
|
||||
{
|
||||
if (kvp.Value != null) Destroy(kvp.Value);
|
||||
keysToRemove.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
foreach (var k in keysToRemove) activeSensesLight.Remove(k);
|
||||
}
|
||||
int markHash = "SE_AswidSensesMark".GetStableHashCode();
|
||||
HunterSenses.Tick(AswidConfig.SensesRadius.Value, c => c.GetSEMan().AddStatusEffect(markHash, true));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -446,15 +388,6 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
private void ClearSuperhumanSenses()
|
||||
{
|
||||
foreach (var kvp in activeSensesLight)
|
||||
{
|
||||
if (kvp.Value != null) Destroy(kvp.Value);
|
||||
}
|
||||
activeSensesLight.Clear();
|
||||
}
|
||||
|
||||
private bool? wasNight = null;
|
||||
|
||||
private void Update()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue