Skip to content

Commit

Permalink
Fix infighting infecting player with diseases and poisons
Browse files Browse the repository at this point in the history
With enemy infighting enabled, a vampire fighting some other monster could infect player directly with vampirism on a successful roll. Same with lycanthropy or any generic disease and poison. This happens because assignment of these infections used player effect manager directly without checking target is player entity or properly use target effect manager.
Fix this by check that target monster is fighting is actually player before assigning disease or special infection. Monsters can't catch diseases and are unlikely to persist for the several days required anyway.
Fixed poison assignment to always use target effect manager rather than player effect manager. Monsters can be poisoned, and these are fast-acting enough to have a visible outcome during infighting.
This will prevent future instances of player being mysteriously infected without actually being hit by a monster.
  • Loading branch information
Interkarma committed Aug 10, 2019
1 parent cab81e8 commit ccd5c72
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Assets/Scripts/Game/Formulas/FormulaHelper.cs
Expand Up @@ -834,7 +834,7 @@ public static void OnMonsterHit(EnemyEntity attacker, DaggerfallEntity target, i
break;
case (int)MonsterCareers.Werewolf:
random = UnityEngine.Random.Range(0f, 100f);
if (random <= specialInfectionChance)
if (random <= specialInfectionChance && target.EntityBehaviour.EntityType == EntityTypes.Player)
{
// Werewolf
EntityEffectBundle bundle = GameManager.Instance.PlayerEffectManager.CreateLycanthropyDisease(LycanthropyTypes.Werewolf);
Expand All @@ -847,7 +847,7 @@ public static void OnMonsterHit(EnemyEntity attacker, DaggerfallEntity target, i
break;
case (int)MonsterCareers.Wereboar:
random = UnityEngine.Random.Range(0f, 100f);
if (random <= specialInfectionChance)
if (random <= specialInfectionChance && target.EntityBehaviour.EntityType == EntityTypes.Player)
{
// Wereboar
EntityEffectBundle bundle = GameManager.Instance.PlayerEffectManager.CreateLycanthropyDisease(LycanthropyTypes.Wereboar);
Expand All @@ -868,7 +868,7 @@ public static void OnMonsterHit(EnemyEntity attacker, DaggerfallEntity target, i
case (int)MonsterCareers.Vampire:
case (int)MonsterCareers.VampireAncient:
random = UnityEngine.Random.Range(0f, 100f);
if (random <= specialInfectionChance)
if (random <= specialInfectionChance && target.EntityBehaviour.EntityType == EntityTypes.Player)
{
// Inflict stage one vampirism disease
EntityEffectBundle bundle = GameManager.Instance.PlayerEffectManager.CreateVampirismDisease();
Expand Down Expand Up @@ -1057,7 +1057,7 @@ public static void InflictPoison(DaggerfallEntity target, Poisons poisonType, bo
if (target.Level != 1)
{
// Infect target
EntityEffectBundle bundle = GameManager.Instance.PlayerEffectManager.CreatePoison(poisonType);
EntityEffectBundle bundle = effectManager.CreatePoison(poisonType);
effectManager.AssignBundle(bundle, AssignBundleFlags.BypassSavingThrows);
}
}
Expand Down Expand Up @@ -1285,7 +1285,7 @@ public static int GetResistanceModifier(DFCareer.EffectFlags effectFlags, Dagger
public static void InflictDisease(DaggerfallEntity target, byte[] diseaseList)
{
// Must have a valid disease list
if (diseaseList == null || diseaseList.Length == 0)
if (diseaseList == null || diseaseList.Length == 0 || target.EntityBehaviour.EntityType != EntityTypes.Player)
return;

// Only allow player to catch a disease this way
Expand Down

0 comments on commit ccd5c72

Please sign in to comment.