Fledgling Wings is now primary sky island loot
Removed its recipe (Yes this is a port-over from recipe-changes)
This commit is contained in:
1 parent
98d4b82e24
commit
091f6f501f
4 files changed
+105
-8
No files matched your search
@@ -142,6 +142,8 @@ namespace CalamityMod.ILEditing
|
||||
IL_UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey;
|
||||
On_WorldGen.MakeDungeon += LimitDungeonEntranceXPosition;
|
||||
IL_WorldGen.DungeonHalls += LimitDungeonHallsXPosition;
|
||||
IL_WorldGen.IslandHouse += MakeFledgingWingsMoreCommon;
|
||||
IL_WorldGen.AddBuriedChest_int_int_int_bool_int_bool_ushort += DisableFledglingWingsSecondary;
|
||||
|
||||
// Removal of vanilla stupidity
|
||||
IL_Player.StatusFromNPC += RemoveExpertBrainRandomDebuffs;
|
||||
|
||||
@@ -208,5 +208,72 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
|
||||
#endregion Prevent Abyss/Dungeon Interactions
|
||||
|
||||
#region Fledgling Wings Loot Changes
|
||||
/// <summary>
|
||||
/// Changes the primary loot of Floating Island chests to include Fledging Wings
|
||||
/// </summary>
|
||||
private static void MakeFledgingWingsMoreCommon(ILContext il)
|
||||
{
|
||||
var cursor = new ILCursor(il);
|
||||
|
||||
// How the code we are moving to works:
|
||||
// Set num13 equal to the number of islands generated. If greater than 3, set to a random number between 0-3 inclusive. Then use that value in a 4-branch switch statement.
|
||||
// This makes num13 always be a value between 0-3, for the 4 primary items in island loot.
|
||||
// To accomodate for Fledgling Wings, we must change this to check for being greater than 4, then to set to a random number between 0-4 inclusive, then make the switch have 5 branches.
|
||||
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(13)))
|
||||
{
|
||||
LogFailure("Fledgling Wings", "Could not move to the location of determining Floating Island primary loot 1.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit a delegate which reimplements the logic for choosing the primary loot of floating islands with Fledgling Wings, then return the ID of the item.
|
||||
var label = il.DefineLabel();
|
||||
cursor.EmitDelegate<Func<int>>(() =>
|
||||
{
|
||||
int island = GenVars.skyIslandHouseCount;
|
||||
if (island > 4)
|
||||
island = Main.rand.Next(5);
|
||||
|
||||
return island switch
|
||||
{
|
||||
1 => 65, // Starfury
|
||||
2 => 158, // Lucky Horseshoe
|
||||
3 => 2219, // Celestial Magnet
|
||||
4 => 4978, // Fledgling Wings
|
||||
_ => 159, // Shiny Red Balloon
|
||||
};
|
||||
});
|
||||
|
||||
// Store this value in the variable which holds the ID of the item, then branch past the original logic.
|
||||
cursor.Emit(OpCodes.Stloc, 13);
|
||||
cursor.Emit(OpCodes.Br, label);
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdsfld<WorldGen>("getGoodWorldGen")))
|
||||
{
|
||||
LogFailure("Fledgling Wings", "Could not move after the switch statement.");
|
||||
return;
|
||||
}
|
||||
cursor.MarkLabel(label);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables Fledgling Wings being added as secondary loot in floating island chests
|
||||
/// </summary>
|
||||
private static void DisableFledglingWingsSecondary(ILContext il)
|
||||
{
|
||||
var cursor = new ILCursor(il);
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdloc(9)))
|
||||
{
|
||||
LogFailure("Fledgling Wings", "Could not move to the code adding Fledgling Wings as secondary loot.");
|
||||
return;
|
||||
}
|
||||
|
||||
// AND with 0 (false) so that the code to add Fledgling Wings as secondary loot never runs.
|
||||
cursor.Emit(OpCodes.Ldc_I4_0);
|
||||
cursor.Emit(OpCodes.And);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -301,9 +301,17 @@ namespace CalamityMod.Items
|
||||
loot.Add(ModContent.ItemType<EssenceofEleum>(), 2, 2, 5);
|
||||
break;
|
||||
|
||||
// Reimplement primary loot rule to include Fledgling Wings
|
||||
case ItemID.FloatingIslandFishingCrate:
|
||||
RemoveLootRuleFromSkyCrates(loot);
|
||||
loot.Add(ItemDropRule.OneFromOptionsNotScalingWithLuck(1, ItemID.ShinyRedBalloon, ItemID.LuckyHorseshoe, ItemID.Starfury, ItemID.CelestialMagnet, ItemID.CreativeWings));
|
||||
break;
|
||||
|
||||
// 2-5 Essences of Sunlight @ 50%
|
||||
// This is our equivalent to Souls of Light/Night
|
||||
case ItemID.FloatingIslandFishingCrateHard:
|
||||
RemoveLootRuleFromSkyCrates(loot);
|
||||
loot.Add(ItemDropRule.OneFromOptionsNotScalingWithLuck(1, ItemID.ShinyRedBalloon, ItemID.LuckyHorseshoe, ItemID.Starfury, ItemID.CelestialMagnet, ItemID.CreativeWings));
|
||||
RemoveHardmodeOresFromBiomeCrates(loot);
|
||||
loot.AddHardmodeOresToCrates(HardmodeCrateType.Biome);
|
||||
loot.Add(ModContent.ItemType<EssenceofSunlight>(), 2, 2, 5);
|
||||
@@ -584,6 +592,34 @@ namespace CalamityMod.Items
|
||||
ItemID.BandofRegeneration,
|
||||
ItemID.ShoeSpikes,
|
||||
ModContent.ItemType<EnchantedKnifeStaff>()); // Climbing Claws is in Wooden/Pearlwood (vanilla) in case you're curious
|
||||
|
||||
private static void RemoveLootRuleFromSkyCrates(ItemLoot loot)
|
||||
{
|
||||
List<IItemDropRule> rules = loot.Get(false);
|
||||
AlwaysAtleastOneSuccessDropRule main = null;
|
||||
foreach (IItemDropRule rule in rules)
|
||||
{
|
||||
if (rule is AlwaysAtleastOneSuccessDropRule a)
|
||||
main = a;
|
||||
}
|
||||
if (main is null)
|
||||
return;
|
||||
|
||||
// Remove the primary loot rule and the rule for Fledgling Wings
|
||||
foreach (IItemDropRule rule in main.rules)
|
||||
{
|
||||
if (rule is OneFromOptionsNotScaledWithLuckDropRule one && one.chanceDenominator == 1)
|
||||
{
|
||||
one.chanceNumerator = 0;
|
||||
continue;
|
||||
}
|
||||
if (rule is CommonDrop c && c.itemId == ItemID.CreativeWings)
|
||||
{
|
||||
c.chanceNumerator = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Goodie Bag Bat Hook
|
||||
|
||||
@@ -1541,14 +1541,6 @@ namespace CalamityMod.Systems
|
||||
r.Register();
|
||||
r.DisableDecraft();
|
||||
|
||||
// Fledgling Wings
|
||||
r = Recipe.Create(ItemID.CreativeWings);
|
||||
r.AddIngredient<AncientBoneDust>(2);
|
||||
r.AddIngredient(ItemID.Cloud, 5);
|
||||
r.AddIngredient(ItemID.Feather, 10);
|
||||
r.AddTile(TileID.Anvils);
|
||||
r.Register();
|
||||
|
||||
// Flying Carpet
|
||||
r = Recipe.Create(ItemID.FlyingCarpet);
|
||||
r.AddIngredient(ItemID.Silk, 10);
|
||||
|
||||
Reference in new issue
Block a user