1 - Removed Voodoo Demon IL edit.
2 - Reduced Calamity's Voodoo Demon PHM spawn chance boost by 5x. 3 - Added an OnSpawn effect which changes Voodoo Demons into normal Demons if they are within 2000 pixels of someone using the doll.
This commit is contained in:
1 parent
045b56b4df
commit
6e079dd706
3 files changed
+28
-44
No files matched your search
@@ -119,9 +119,6 @@ namespace CalamityMod.ILEditing
|
||||
IL_Item.TryGetPrefixStatMultipliersForItem += RelaxPrefixRequirements;
|
||||
On_NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns;
|
||||
|
||||
// ERROR
|
||||
//Terraria.IL_NPC.SpawnNPC += MakeVoodooDemonDollWork;
|
||||
|
||||
// TODO -- Beat Lava Slimes once and for all
|
||||
// IL.Terraria.NPC.VanillaHitEffect += RemoveLavaDropsFromExpertLavaSlimes;
|
||||
IL_Projectile.CanExplodeTile += MakeMeteoriteExplodable;
|
||||
|
||||
@@ -117,33 +117,6 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
#endregion Prevention of Slime Rain Spawns When Near Bosses
|
||||
|
||||
#region Voodoo Demon Doll Spawn Manipulations
|
||||
// This may seem absolutely obscene, but vanilla spawn behavior does not occur within the spawn pool that TML provides, only modded
|
||||
// spawns do. Pretty much everything else is simply a fuckton of manual conditional NPC.NewNPC calls. As such, the only way to bypass
|
||||
// vanilla spawn behaviors is the IL edit them out of existence. Here, simply replacing the voodoo demon ID with an empty one is performed.
|
||||
// Something cleaner could probably be done, such as getting rid of the entire NPC.NewNPC call, but this is the easiest solution I can come up with.
|
||||
private static void MakeVoodooDemonDollWork(ILContext il)
|
||||
{
|
||||
var cursor = new ILCursor(il);
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(NPCID.VoodooDemon)))
|
||||
{
|
||||
LogFailure("Voodoo Demon Doll Mechanic", "Could not locate the Voodoo Demon ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
cursor.Remove();
|
||||
cursor.Emit(OpCodes.Ldloc, 10);
|
||||
cursor.EmitDelegate<Func<int, int>>(spawnPlayerIndex =>
|
||||
{
|
||||
if (Main.player[spawnPlayerIndex].active && Main.player[spawnPlayerIndex].Calamity().disableVoodooSpawns)
|
||||
return NPCID.None;
|
||||
|
||||
return NPCID.VoodooDemon;
|
||||
});
|
||||
}
|
||||
#endregion Voodoo Demon Doll Spawn Manipulations
|
||||
|
||||
#region Remove Feral Bite Random Debuffs
|
||||
private static void RemoveFeralBiteRandomDebuffs(ILContext il)
|
||||
{
|
||||
|
||||
+28
-14
@@ -5128,33 +5128,47 @@ namespace CalamityMod.NPCs
|
||||
if (spawnInfo.PlayerSafe)
|
||||
return;
|
||||
|
||||
// Voodoo Demon changes (including Voodoo Demon Voodoo Doll implementation)
|
||||
// Voodoo Demon changes (including partial Voodoo Demon Voodoo Doll implementation)
|
||||
bool voodooDemonDollActive = spawnInfo.Player.Calamity().disableVoodooSpawns;
|
||||
if (!voodooDemonDollActive)
|
||||
|
||||
// If the doll is active, Voodoo Demons cannot spawn (via modded means).
|
||||
if (voodooDemonDollActive)
|
||||
pool.Remove(NPCID.VoodooDemon);
|
||||
// Otherwise, if it's pre-Hardmode, provide a modded spawn entry that makes them much more common.
|
||||
else if (!Main.hardMode && spawnInfo.Player.ZoneUnderworldHeight && !calamityBiomeZone)
|
||||
{
|
||||
// Nearby players with the doll apply it to anyone within 500 pixels
|
||||
pool[NPCID.VoodooDemon] = SpawnCondition.Underworld.Chance * 0.15f;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region On Spawn
|
||||
public override void OnSpawn(NPC npc, IEntitySource source)
|
||||
{
|
||||
if (npc.type != NPCID.VoodooDemon)
|
||||
return;
|
||||
|
||||
// This entity source does not provide a player. So we have to find out if anyone close enough has a doll.
|
||||
if (source is EntitySource_SpawnNPC)
|
||||
{
|
||||
bool voodooDemonDollActive = false;
|
||||
Vector2 v = npc.Center;
|
||||
for (int i = 0; i < Main.maxPlayers; ++i)
|
||||
{
|
||||
Player p = Main.player[i];
|
||||
if (p is null || !p.active)
|
||||
continue;
|
||||
float distsq = p.Center.DistanceSQ(spawnInfo.Player.Center);
|
||||
if (distsq < 25000f)
|
||||
if (p.DistanceSQ(v) < 4000000f && p.Calamity().disableVoodooSpawns) // 2000 pixel radius
|
||||
{
|
||||
voodooDemonDollActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!voodooDemonDollActive)
|
||||
return;
|
||||
|
||||
// If the doll is active, Voodoo Demons cannot spawn.
|
||||
// NOTE: This doesn't fully work! There is an IL edit to truly force them to stop spawning.
|
||||
if (voodooDemonDollActive)
|
||||
pool.Remove(NPCID.VoodooDemon);
|
||||
// Otherwise, if it's pre-Hardmode, boost their spawn rate by 1.25x.
|
||||
else if (!Main.hardMode && spawnInfo.Player.ZoneUnderworldHeight && !calamityBiomeZone)
|
||||
{
|
||||
pool[NPCID.VoodooDemon] *= 1.25f;
|
||||
npc.Transform(NPCID.Demon);
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user