public override void NPCLoot(NPC npc) { for (var i = 0; i < modifiers.Count; i++) { modifiers[i].NPCLoot(npc); } if (npc.lifeMax < 10) { return; } if (npc.friendly) { return; } if (npc.townNPC) { return; } if (Main.rand.Next(2500) < GetLevel(npc.type)) { if (Main.rand.Next(8) == 0) { Item.NewItem(npc.position, mod.ItemType <BlacksmithCrown>()); } else { Item.NewItem(npc.position, mod.ItemType <PermanenceCrown>()); } } int level = GetLevel(npc.netID); Player player = Array.Find(Main.player, p => p.active); if (Main.netMode == 0) { player = Main.LocalPlayer; } else if (Main.player[npc.target].active) { player = Main.player[npc.target]; } else { PlayerCharacter c = player.GetModPlayer <PlayerCharacter>(); foreach (Player p in Main.player) { if (p != null) { if (p.active) { if (p.GetModPlayer <PlayerCharacter>() != null) { if (p.GetModPlayer <PlayerCharacter>().level > c.level) { player = p; } } } } } } PlayerCharacter character = player.GetModPlayer <PlayerCharacter>(); int life = npc.type == NPCID.SolarCrawltipedeTail || npc.type == NPCID.SolarCrawltipedeBody || npc.type == NPCID.SolarCrawltipedeHead ? npc.lifeMax / 8 : npc.lifeMax; int defFactor = (npc.defense < 0) ? 1 : npc.defense * life / (character.level + 10); int baseExp = Main.rand.Next((life + defFactor) / 5) + (life + defFactor) / 6; int scaled = Main.expertMode ? (int)(baseExp * 0.5) : baseExp; if (Main.netMode == 2) { ModPacket packet = mod.GetPacket(); packet.Write((byte)Message.AddXP); packet.Write(scaled); packet.Write(npc.target); packet.Send(); } else { character.AddXP(scaled); } if (level < Math.Min(character.level - 17, 70)) { return; } float dps = Math.Min((float)(Math.Pow(1.04, Math.Min(130, character.level)) * 9f), (float)(Math.Pow(1.023, level) * 15) + 14); int assumedDef = !Main.hardMode ? 5 : character.level / 3; if (npc.FullName.Contains("Green Slime")) { if (Main.rand.Next(22) == 0) { ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.GENERIC), SwordBlade.slimeGreen, Main.rand.Next(3) < 1 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, assumedDef); } } else if (npc.FullName.Contains("Blue Slime")) { if (Main.rand.Next(30) == 0) { ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.GENERIC), SwordBlade.slimeBlue, Main.rand.Next(2) < 1 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, assumedDef); } } else if (Main.rand.Next((character.level < 5 ? 5 : (character.level < 10 ? 8 : 20))) == 0) { if (Main.rand.Next(5) == 0) { Item.NewItem(npc.position, RangedWeapon.NewRangedWeapon(mod, npc.position, level, character.level, dps, assumedDef), Main.rand.Next(30, 90)); } else if (Main.rand.Next(9) < 5) { ProceduralSword.GenerateSword(mod, npc.position, GetTheme(player), dps, assumedDef); } else { ProceduralStaff.GenerateStaff(mod, npc.position, GetStaffTheme(player), dps * 1.2f, assumedDef); } } else if (Main.rand.Next(40) == 0) { Item item = Main.item[Item.NewItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), mod.ItemType(Glyph.GetRandom()))]; if (item.modItem is Glyph && Main.netMode == 0) { ((Glyph)item.modItem).Randomize(); } } else if (npc.FullName.EndsWith(" Eye") && level < 20) { if (Main.rand.Next(20) == 0) { ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.MONSTROUS), SwordBlade.demonEye, Main.rand.Next(5) < 2 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, assumedDef); } else if (Main.rand.Next(15) == 0) { ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.GENERIC), SwordBlade.demonEye, SwordAccent.none, dps, assumedDef); } } }
public static Item GenerateSword(Mod mod, Vector2 position, SWORDTHEME theme, float dps, int enemyDef) { ProceduralSword sword; sword = NewSword(mod, position, SwordHilt.RandomHilt(theme), SwordBlade.RandomBlade(theme), Main.rand.Next(5) < 3 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, enemyDef); return(sword.item); }