//////////////// private void UpdateStyleSlider(int sndType) { switch (sndType) { case 2: this.StyleSliderElem.SetRange(0f, (float)SoundLoader.SoundCount(SoundType.Item)); //125f break; case 3: this.StyleSliderElem.SetRange(1f, (float)SoundLoader.SoundCount(SoundType.NPCHit)); //57f break; case 4: this.StyleSliderElem.SetRange(0f, (float)SoundLoader.SoundCount(SoundType.NPCKilled)); //62f break; case 14: this.StyleSliderElem.SetRange(0f, 0f); //Main.soundInstanceZombie break; case 15: this.StyleSliderElem.SetRange(0f, (float)Main.soundInstanceRoar.Length - 1f); //2f break; case 19: this.StyleSliderElem.SetRange(0f, (float)Main.soundInstanceSplash.Length - 1f); //1f break; case 28: this.StyleSliderElem.SetRange(0f, (float)Main.soundInstanceMech.Length - 1f); //0f break; case 29: case 32: this.StyleSliderElem.SetRange(0f, (float)Main.soundInstanceZombie.Length - 1f); //105f break; case 34: case 35: this.StyleSliderElem.SetRange(0f, 50f); break; case 36: case 39: this.StyleSliderElem.SetRange(0f, (float)Main.soundInstanceDrip.Length - 1f); //2f break; case 50: this.StyleSliderElem.SetRange(0f, (float)SoundLoader.SoundCount(SoundType.Custom)); break; default: this.StyleSliderElem.SetRange(-1f, -1f); break; } }
public SoundLooper(Mod mod, string name, SoundType type = SoundType.Custom) { _mod = mod; int style = _mod.GetSoundSlot(type, name); _mod.Logger.Debug($"Sound looper {name} being created. Style: {style}"); if (style < 0 || style >= SoundLoader.SoundCount(type)) { _mod.Logger.Warn($"Couldn't create SoundLooper object properly! style: {style} name: {name} type: {type}"); return; } try { _instance = (SoundEffectInstance)((Array)typeof(SoundLoader).GetField("customSoundInstances", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)).GetValue(style); } catch (Exception e) { _mod.Logger.Error($"Couldn't create SoundLooper object properly! Exception: {e}"); return; } }
public override void SetDefaults(Item item) { if (!Main.dedServ && !Main.gameMenu) { base.SetDefaults(item); if (ModContent.GetInstance <RandomizerModConfig>().ItemNameRandomization) { string name1 = Lang.GetItemNameValue(Main.rand.Next(ItemLoader.ItemCount)); if (name1.Contains(' ')) { string[] splitName = name1.Split(' '); if (Main.rand.Next(2) == 0) { name1 = splitName.First(); } else { name1 = splitName.Last(); } } string name2 = Lang.GetItemNameValue(Main.rand.Next(ItemLoader.ItemCount)); if (name2.Contains(' ')) { string[] splitName = name2.Split(' '); if (Main.rand.Next(2) == 0) { name2 = splitName.First(); } else { name2 = splitName.Last(); } } if (Main.rand.Next(2) == 0) { item.SetNameOverride(name1 + " " + name2); } else { string name3 = Lang.GetItemNameValue(Main.rand.Next(ItemLoader.ItemCount)); if (name3.Contains(' ')) { string[] splitName = name3.Split(' '); if (Main.rand.Next(2) == 0) { name3 = splitName.First(); } else { name3 = splitName.Last(); } } item.SetNameOverride(name1 + " " + name2 + " " + name3); } } if (ModContent.GetInstance <RandomizerModConfig>().StatsRandomization) { if (item.damage > 1 && item.pick == 0 && item.axe == 0 && item.hammer == 0) { item.damage = Main.rand.Next(10, 60) + (Main.rand.Next(2) == 0 ? (Main.rand.Next(20, 100) + (Main.rand.Next(2) == 0 ? Main.rand.Next(40, 200) : 0)) : 0); item.knockBack = Main.rand.Next(10, 60) + (Main.rand.Next(2) == 0 ? (Main.rand.Next(20, 100) + (Main.rand.Next(2) == 0 ? Main.rand.Next(40, 200) : 0)) : 0); item.useTime = Main.rand.Next(10, 20) + (Main.rand.Next(2) == 0 ? (Main.rand.Next(10, 40) + (Main.rand.Next(2) == 0 ? Main.rand.Next(10, 40) : 0)) : 0); item.crit = Main.rand.Next(0, 100); } } if (ModContent.GetInstance <RandomizerModConfig>().RandomProjRandomization) { if (item.damage > 1 && item.pick == 0 && item.axe == 0 && item.hammer == 0) { item.shoot = Main.rand.Next(ProjectileLoader.ProjectileCount); item.shootSpeed = Main.rand.NextFloat(5f, 30f); } } if (ModContent.GetInstance <RandomizerModConfig>().ItemSpritesRandomization) { Main.itemTexture[item.type] = Main.itemTexture[Main.rand.Next(ItemLoader.ItemCount)]; } if (ModContent.GetInstance <RandomizerModConfig>().SoundsRandomization) { item.UseSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Item, "Item" + Main.rand.Next(SoundLoader.SoundCount(Terraria.ModLoader.SoundType.Item))); } } }
public override void SetDefaults(NPC npc) { base.SetDefaults(npc); if (ModContent.GetInstance <RandomizerModConfig>().NPCNameRandomization) { string name1 = Lang.GetNPCNameValue(Main.rand.Next(NPCLoader.NPCCount)); if (name1.Contains(' ')) { string[] splitName = name1.Split(' '); if (Main.rand.Next(2) == 0) { name1 = splitName.First(); } else { name1 = splitName.Last(); } } string name2 = Lang.GetNPCNameValue(Main.rand.Next(NPCLoader.NPCCount)); if (name2.Contains(' ')) { string[] splitName = name2.Split(' '); if (Main.rand.Next(2) == 0) { name2 = splitName.First(); } else { name2 = splitName.Last(); } } if (Main.rand.Next(2) == 0) { npc.GivenName = name1 + " " + name2; } else { string name3 = Lang.GetNPCNameValue(Main.rand.Next(NPCLoader.NPCCount)); if (name3.Contains(' ')) { string[] splitName = name3.Split(' '); if (Main.rand.Next(2) == 0) { name3 = splitName.First(); } else { name3 = splitName.Last(); } } npc.GivenName = name1 + " " + name2 + " " + name3; } } if (ImportantNPCs.Contains(npc.type)) { if (ModContent.GetInstance <RandomizerModConfig>().AIRandomizationSettings.affectsImportants) { npc.aiStyle = Main.rand.Next(Main.npc.Length); } } if (npc.boss) { if (ModContent.GetInstance <RandomizerModConfig>().AIRandomizationSettings.affectsBosses) { npc.aiStyle = Main.rand.Next(Main.npc.Length); } } if (ModContent.GetInstance <RandomizerModConfig>().AIRandomizationSettings.enabled) { //gross code incoming string forcedAI = ModContent.GetInstance <RandomizerModConfig>().AIRandomizationSettings.MemeAIRandomizationSettings.ForcedAI; if (forcedAI != "None") { if (forcedAI == "Goldfish") { npc.aiStyle = 16; } else if (forcedAI == "Spiky Ball") { npc.aiStyle = 20; } //else if (forcedAI == "Pumpking") //npc.aiStyle = 59; else if (forcedAI == "Fishron") { npc.aiStyle = 69; } else if (forcedAI == "Bird") { npc.aiStyle = 24; } } else if (!npc.boss && !ImportantNPCs.Contains(npc.type)) { npc.aiStyle = Main.rand.Next(Main.npc.Length); } } if (ModContent.GetInstance <RandomizerModConfig>().SoundsRandomization) { npc.HitSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.NPCHit, "NPCHit" + Main.rand.Next(SoundLoader.SoundCount(Terraria.ModLoader.SoundType.NPCHit))); npc.DeathSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.NPCKilled, "NPCDeath" + Main.rand.Next(SoundLoader.SoundCount(Terraria.ModLoader.SoundType.NPCKilled))); } if (ModContent.GetInstance <RandomizerModConfig>().AIRandomizationSettings.MemeAIRandomizationSettings.RandomSize) { npc.scale = Main.rand.NextFloat(0.1f, 3f); } }