Skip to content

Commit

Permalink
Merge pull request #72 from Vapok/vapok/r1.6.7
Browse files Browse the repository at this point in the history
Fixing Status Effects being mirrored on Spawn Mobs
  • Loading branch information
Vapok authored Feb 21, 2023
2 parents 547546c + cbb2d51 commit 9b9a08d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion AdventureBackpacks/AdventureBackpacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo
//Module Constants
private const string _pluginId = "vapok.mods.adventurebackpacks";
private const string _displayName = "Adventure Backpacks";
private const string _version = "1.6.6";
private const string _version = "1.6.7";

//Interface Properties
public string PluginId => _pluginId;
Expand Down
28 changes: 12 additions & 16 deletions AdventureBackpacks/Features/EquipmentEffectCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,29 @@ public static class EquipmentEffectCache
{
public static HashSet<StatusEffect> ActiveEffects = new();

public static HashSet<StatusEffect> AddActiveBackpackEffects(HashSet<StatusEffect> other)
public static HashSet<StatusEffect> AddActiveBackpackEffects(HashSet<StatusEffect> other, Humanoid instance)
{
if (other == null)
{
AdventureBackpacks.Log.Debug($"other HashSet argument is null. Expecting initialized object.");
other = new();
}

if (Player.m_localPlayer == null)
if (instance is Player player && player == Player.m_localPlayer)
{
AdventureBackpacks.Log.Debug($"Add Active Effects Started... Player null");
return other;
}

var player = Player.m_localPlayer;

ActiveEffects = new HashSet<StatusEffect>();
ActiveEffects = new HashSet<StatusEffect>();

foreach (var effectKeyValuePair in EffectsFactory.EffectList)
{
if (effectKeyValuePair.Value.HasActiveStatusEffect(player, out var statusEffect))
ActiveEffects.Add(statusEffect);
}
foreach (var effectKeyValuePair in EffectsFactory.EffectList)
{
if (effectKeyValuePair.Value.HasActiveStatusEffect(player, out var statusEffect))
ActiveEffects.Add(statusEffect);
}

other.UnionWith(ActiveEffects);
other.UnionWith(ActiveEffects);

AdventureBackpacks.Log.Debug($"Adding {other.Count} Active Backpack Effects.");
AdventureBackpacks.Log.Debug($"Adding {other.Count} Active Backpack Effects.");
}

return other;
}
}
4 changes: 4 additions & 0 deletions AdventureBackpacks/Patches/Humanoid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ CodeInstruction LogMessage(CodeInstruction instruction)
//Patch the ldloc_0 which is the argument of my method using local variable 0.
yield return LogMessage(ldlocInstruction);
counter++;

//Need to bring in the Humanoid Instance too to filter for players versus creatures.
yield return LogMessage(new CodeInstruction(OpCodes.Ldarg_0));
counter++;

//Patch Calling Method
yield return LogMessage(new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(EquipmentEffectCache), nameof(EquipmentEffectCache.AddActiveBackpackEffects))));
Expand Down
4 changes: 2 additions & 2 deletions AdventureBackpacks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.6.0")]
[assembly: AssemblyFileVersion("1.6.6.0")]
[assembly: AssemblyVersion("1.6.7.0")]
[assembly: AssemblyFileVersion("1.6.7.0")]
4 changes: 4 additions & 0 deletions PATCHNOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Adventure Backpacks Patchnotes

# 1.6.7.0 - Hotfix - Holy Status Effects Batman!
* Bug was identified that all status effects applied to Player were being replicated to all creatures spawned in.
* While this is quite magical for the Wisplight effect, in giving every creature in the Mistlands Demister, (which in and of itself is pretty spectacular to see), this is indeed a bug that needs to be patched quickly.

# 1.6.6.0 - Hotfix - Sneaky Bug Is Sneaky
* The Troll Armor status effect was being applied even without wearing the full set when a backpack was equipped with that effect.
* This ensures that the full troll armor set is worn.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AdventureBackpacks",
"version_number": "1.6.6",
"version_number": "1.6.7",
"website_url": "https://github.com/Vapok/AdventureBackpacks",
"description": "A Valheim Mod to add a catalogue of Adventuring Backpacks to the Game. These packs will grow and become more useful as the game progresses.",
"dependencies": [
Expand Down

0 comments on commit 9b9a08d

Please sign in to comment.