public ResponseStruct SpawnBoss(string BossName, string BossAmount, string TargetPlayer) { ResponseStruct Result; List<TShockAPI.TSPlayer> Players = TShockAPI.TShock.Utils.FindPlayer(TargetPlayer); int Amount = -1; if (!Int32.TryParse(BossAmount, out Amount)) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "Số lượng Boss không hợp lệ." }, Broadcast = new List<string>() { "Số lượng Boss phải là số nguyên dương và nên nhỏ hơn 200." } }; } else if (!(Amount >= 1 && Amount <= Terraria.Main.maxNPCs)) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "Số lượng Boss không hợp lệ." }, Broadcast = new List<string>() { "Số lượng Boss phải là số nguyên dương và nên nhỏ hơn 200." } }; } else if (Players.Count == 0) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "Không tìm thấy Player Name trong Server." }, Broadcast = new List<string>() { "Chỉ có thể summon Boss nếu Player có mặt trong Server." } }; } else if (Players.Count > 1) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { String.Format("Có {0} Player có tên phù hợp với tên Player được cung cấp.") }, Broadcast = new List<string>() { "Cung cấp Player Name đầy đủ." } }; } else { int CurrentNpcCount = CountNPC(); if (Amount > Terraria.Main.maxNPCs - CurrentNpcCount) Amount = Terraria.Main.maxNPCs - CurrentNpcCount; TShockAPI.TSPlayer Player = Players[0]; Terraria.NPC Npc = new Terraria.NPC(); switch (BossName) { case "Brain of Cthulhu": Npc.SetDefaults(266); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Brain of Cthulhu {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "The Destroyer": if (Terraria.Main.dayTime) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "The Destroyer phải được gọi vào ban đêm (trong game)." } }; } else { Npc.SetDefaults(134); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Destroyer {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; } break; case "Duke Fishron": Npc.SetDefaults(370); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned Duke Fishron {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Eater of Worlds": Npc.SetDefaults(13); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Eater of Worlds {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Eye of Cthulhu": Npc.SetDefaults(4); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Eye of Cthulhu {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Golem": Npc.SetDefaults(245); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned Golem {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "King Slime": Npc.SetDefaults(50); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned King Slime {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Plantera": Npc.SetDefaults(262); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned Plantera {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Skeletron Prime": Npc.SetDefaults(127); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned Skeletron Prime {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Queen Bee": Npc.SetDefaults(222); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned Queen Bee {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Skeletron": Npc.SetDefaults(35); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned Skeletron {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "The Twins": if (Terraria.Main.dayTime) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "The Twins phải gọi vào ban đêm (trong game)." } }; } else { Npc.SetDefaults(125); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); Npc.SetDefaults(126); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Twins {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; } break; case "Wall of Flesh": if (Terraria.Main.wof > 0) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "Wall of Flesh đang tồn tại trong World." } }; } else if (Player.Y / 16f < Terraria.Main.maxTilesY - 205) { Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "Nhân vật phải đứng tại \"hell\" để có thể gọi Wall of Flesh." } }; } else { Terraria.NPC.SpawnWOF(new Vector2(Player.X, Player.Y)); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Wall of Flesh.", Player.Name); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = "1" }; } break; case "Lunatic Cultist": Npc.SetDefaults(439); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Lunatic Cultist {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; case "Moon Lord": Npc.SetDefaults(398); TShockAPI.TSPlayer.Server.SpawnNPC(type: Npc.type, name: Npc.name, amount: Amount, startTileX: Player.TileX, startTileY: Player.TileY); TShockAPI.TSPlayer.All.SendSuccessMessage("{0} has spawned the Moon Lord {1} time(s).", Player.Name, Amount); Result = new ResponseStruct() { Status = ResponseStatusType.Done, Content = Convert.ToString(Amount) }; break; default: Result = new ResponseStruct() { Status = ResponseStatusType.Fail, Error = new List<string>() { "Tên Boss không hợp lệ." }, Broadcast = new List<string>() { "Cần đúng tên Boss hợp lệ để summon." } }; break; } } return Result; }
private void InitializeLookups() { Terraria.NPC npc = new Terraria.NPC(); for (var i = -17; i < Terraria.Main.maxNPCTypes; ++i) { npc.SetDefaults(i); _npcLookup[Terraria.Lang.GetNPCNameValue(i)] = (NpcId)i; } }
public void NpcSetDefaults_AbstractItem_EventTriggered(NpcId id) { var terrariaNpc = new Terraria.NPC(); var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); using var npcService = new OrionNpcService(events, log); Mock.Get(events) .Setup(em => em.Raise( It.Is <NpcDefaultsEvent>(evt => ((OrionNpc)evt.Npc).Wrapped == terrariaNpc && evt.Id == id), log)); terrariaNpc.SetDefaults((int)id); Assert.Equal(id, (NpcId)terrariaNpc.netID); Mock.Get(events).VerifyAll(); }