Skip to content

Commit

Permalink
Fixed rolling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jofairden committed Sep 16, 2018
1 parent ae9c5e9 commit 6404a93
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion EMMItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal ModifierPool RollNewPool(ModifierContext ctx, ItemRollProperties itemRo
{
// GetWeightedPool already checks _CanRoll
ModifierPool = EMMLoader.GetWeightedPool(ctx);
noForce = ModifierPool == null;
noForce = ModifierPool == null || !ModifierPool._CanRoll(ctx);
}

// Roll from all modifiers
Expand Down Expand Up @@ -138,6 +138,7 @@ internal bool RollNewModifiers(ModifierContext ctx, ItemRollProperties itemRollP
// that are rollable in this context
WeightedRandom<Modifier> wr = new WeightedRandom<Modifier>();
List<Modifier> list = new List<Modifier>();

foreach (var e in ModifierPool.RollableModifiers(ctx))
{
wr.Add(e, e.Properties.RollChance);
Expand Down
Binary file removed Loot.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Modifiers/WeaponModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static bool HasVanillaDamage(Item item)
=> item.magic || item.melee || item.ranged || item.summon || item.thrown;

public override bool CanRoll(ModifierContext ctx)
=> ctx.Item.damage > 0;
=> ctx.Item.IsWeapon();

public void UpdateShootSpeed(Item item, Player player, float speedXBefore, float speedYBefore, ref float speedX, ref float speedY, float percentModifier)
{
Expand Down
4 changes: 4 additions & 0 deletions Pools/AccessoryModifierPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ namespace Loot.Pools
[PopulatePoolFrom("Loot.Modifiers.EquipModifiers")]
internal class AccessoryModifierPool : ModifierPool
{
public override bool CanRoll(ModifierContext ctx)
{
return ctx.Item.IsAccessory() || ctx.Item.IsArmor();
}
}
}
3 changes: 2 additions & 1 deletion Pools/WeaponModifierPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Loot.Pools
[PopulatePoolFrom("Loot.Modifiers.WeaponModifiers")]
internal class WeaponModifierPool : ModifierPool
{

public override bool CanRoll(ModifierContext ctx)
=> ctx.Item.IsWeapon();
}
}
4 changes: 2 additions & 2 deletions build.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
author = Jofairden
version = 0.1.0.9
version = 0.1.1.0
displayName = Even More Modifiers
homepage = https://forums.terraria.org/index.php?threads/even-more-modifiers-relaunch-beta.68438/
hideCode = false
hideResources = false
includeSource = true
languageVersion = 6
buildIgnore = *.csproj, *.user, *.config, tmp.txt, packages\*, UnitTests.cs, TestResults\*, LootTests\*
buildIgnore = *.csproj, *.user, .vs\*, .idea\*, *.git*, *.config, tmp.txt, packages\*, UnitTests.cs, TestResults\*, LootTests\*, docs\*, bin\*, obj\*
includePDB = false
weakReferences = CheatSheet, WingSlot

0 comments on commit 6404a93

Please sign in to comment.