本文整理匯總了C#中Terraria.NPC.SetDefaults方法的典型用法代碼示例。如果您正苦於以下問題:C# NPC.SetDefaults方法的具體用法?C# NPC.SetDefaults怎麽用?C# NPC.SetDefaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terraria.NPC
的用法示例。
在下文中一共展示了NPC.SetDefaults方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ChooseNPC
public static void ChooseNPC()
{
var npc = new NPC();
Random r = new Random();
int type = r.Next(ApocalypseMonsters.Monsters.Count);
npc.SetDefaults(ApocalypseMonsters.Monsters[type]);
CurMonster = npc;
}
示例2: DedServ
public void DedServ()
{
ServerApi.Hooks.InvokeGameInitialize();
string str;
Main.rand = new Random();
Console.Title = string.Concat("Terraria Server ", Main.versionNumber2);
Main.dedServ = true;
Main.showSplash = false;
if (Main.autoGen)
{
Main.ActiveWorldFileData = new WorldFileData();
Main.ActiveWorldFileData.Path = Main.WorldPathClassic;
}
this.Initialize();
Lang.setLang(false);
for (int i = 0; i < 540; i++)
{
NPC nPC = new NPC();
nPC.SetDefaults(i, -1f);
Main.npcName[i] = nPC.name;
}
if (Console.IsInputRedirected == true && string.IsNullOrEmpty(Main.WorldPathClassic) == true && !Main.autoGen)
{
throw new Exception("When running in the background, the world must be specified with -world <path>");
}
while (string.IsNullOrEmpty(Main.worldPathName))
{
bool flag = true;
while (flag)
{
Main.LoadWorlds();
Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
Console.WriteLine("");
for (int j = 0; j < Main.WorldList.Count; j++)
{
object[] name = new object[]
{
j + 1,
'\t',
'\t', Main.WorldList[j].Name
};
Console.WriteLine("{0,-4}{1,-22}{2}, {3}, {4,-6}{5}",
j + 1,
Main.WorldList[j].Name,
Main.WorldList[j].IsHardMode ? "hard" : "norm",
Main.WorldList[j].HasCrimson ? "crim" : "corr",
Main.WorldList[j].IsExpertMode ? "exp" : "norm",
String.Format("Last used: {0}",
File.GetLastWriteTime(Main.WorldList[j].Path).ToString("g")));
}
Console.WriteLine();
Console.WriteLine("n \tNew World");
Console.WriteLine("d <number>\tDelete World");
Console.WriteLine("");
Console.Write("Choose World: ");
string str2 = Console.ReadLine() ?? "";
try
{
Console.Clear();
}
catch (Exception ex)
{
#if DEBUG
Console.WriteLine(ex);
System.Diagnostics.Debugger.Break();
#endif
}
if (str2.Length >= 2 && str2.Substring(0, 2).ToLower() == "d ")
{
try
{
int num = Convert.ToInt32(str2.Substring(2)) - 1;
if (num < Main.WorldList.Count)
{
Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
Console.WriteLine("");
Console.WriteLine(string.Concat("Really delete ", Main.WorldList[num].Name, "?"));
Console.Write("(y/n): ");
if (Console.ReadLine().ToLower() == "y")
{
Main.EraseWorld(num);
}
}
}
catch (Exception ex)
{
#if DEBUG
Console.WriteLine(ex);
System.Diagnostics.Debugger.Break();
#endif
}
try
{
Console.Clear();
}
catch (Exception ex)
//.........這裏部分代碼省略.........
示例3: OnSetDefaults
internal static void OnSetDefaults(NPC n, int type, float scaleOverride)
{
NpcBHandler h = null;
n.SetDefaults(0, scaleOverride);
if (DefFromType.ContainsKey(type))
{
var d = DefFromType[type];
n.type = n.netID = type;
n.width = n.height = 16;
CopyDefToNpc(n, d);
if (scaleOverride > -1f)
n.scale = scaleOverride;
h = new NpcBHandler();
if (d.CreateBehaviour != null)
{
var b = d.CreateBehaviour();
if (b != null)
h.behaviours.Add(b);
}
n.BHandler = h;
}
//TODO: add global hooks here (and check for null)
if (h != null)
{
h.Create();
n.BHandler = h;
foreach (var b in h.Behaviours)
b.Entity = n;
h.OnInit();
}
}
示例4: HandleSpawnBoss
private static bool HandleSpawnBoss(GetDataHandlerArgs args)
{
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
{
return true;
}
var spawnboss = false;
var invasion = false;
var plr = args.Data.ReadInt16();
var Type = args.Data.ReadInt16();
NPC npc = new NPC();
npc.SetDefaults(Type);
spawnboss = npc.boss;
if (!spawnboss)
{
switch (Type)
{
case -1:
case -2:
case -3:
case -4:
case -5:
case -6:
case -7:
invasion = true;
break;
case 4:
case 13:
case 50:
case 126:
case 125:
case 134:
case 127:
case 128:
case 131:
case 129:
case 130:
case 222:
case 245:
case 266:
case 370:
case 75:
case 398:
case 439:
case 493:
case 507:
case 422:
case 517:
spawnboss = true;
break;
}
}
if (spawnboss && !args.Player.Group.HasPermission(Permissions.summonboss))
{
args.Player.SendErrorMessage("You don't have permission to summon a boss.");
return true;
}
if (invasion && !args.Player.Group.HasPermission(Permissions.startinvasion))
{
args.Player.SendErrorMessage("You don't have permission to start an invasion.");
return true;
}
if (!spawnboss && !invasion)
return true;
if (plr != args.Player.Index)
return true;
string boss;
switch (Type)
{
case -5:
boss = "a frost moon";
break;
case -4:
boss = "a pumpkin moon";
break;
case -3:
boss = "the Pirates";
break;
case -2:
boss = "the Snow Legion";
break;
case -1:
boss = "a Goblin Invasion";
break;
default:
boss = String.Format("the {0}", npc.name);
break;
}
if (TShock.Config.AnonymousBossInvasions)
TShock.Utils.SendLogs(string.Format("{0} summoned {1}!", args.Player.Name, boss), Color.PaleVioletRed, args.Player);
else
TShock.Utils.Broadcast(String.Format("{0} summoned {1}!", args.Player.Name, boss), 175, 75, 255);
return false;
}
示例5: SpawnBosses
private void SpawnBosses(Dictionary<string, int> bosses, ScPlayer sPly)
{
var bossList = new List<string>();
foreach (var pair in bosses)
{
var npc = new NPC();
switch (pair.Key.ToLower())
{
case "*":
case "all":
int[] npcIds = {4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370};
TSPlayer.Server.SetTime(false, 0.0);
foreach (var i in npcIds)
{
npc.SetDefaults(i);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
}
bossList.Add("all bosses (" + pair.Value + ")");
break;
case "brain":
case "brain of cthulhu":
npc.SetDefaults(266);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "destroyer":
npc.SetDefaults(134);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "duke":
case "duke fishron":
case "fishron":
npc.SetDefaults(370);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "eater":
case "eater of worlds":
npc.SetDefaults(13);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "eye":
case "eye of cthulhu":
npc.SetDefaults(4);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "golem":
npc.SetDefaults(245);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "king":
case "king slime":
npc.SetDefaults(50);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "plantera":
npc.SetDefaults(262);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "prime":
case "skeletron prime":
npc.SetDefaults(127);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "queen":
case "queen bee":
npc.SetDefaults(222);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "skeletron":
npc.SetDefaults(35);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add(npc.name + " (" + pair.Value + ")");
break;
case "twins":
TSPlayer.Server.SetTime(false, 0.0);
npc.SetDefaults(125);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
npc.SetDefaults(126);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
bossList.Add("the Twins (" + pair.Value + ")");
break;
case "wof":
case "wall of flesh":
if (Main.wof >= 0)
//.........這裏部分代碼省略.........
示例6: DedServ
public void DedServ()
{
rand = new Random();
if (autoShutdown)
{
string lpWindowName = "terraria" + rand.Next(0x7fffffff);
Console.Title = lpWindowName;
IntPtr hWnd = FindWindow(null, lpWindowName);
if (hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 0);
}
}
else
{
Console.Title = "Terraria Server " + versionNumber2;
}
dedServ = true;
showSplash = false;
this.Initialize();
for (int i = 0; i < 0x93; i++)
{
NPC npc = new NPC();
npc.SetDefaults(i, -1f);
npcName[i] = npc.name;
}
while ((worldPathName == null) || (worldPathName == ""))
{
LoadWorlds();
bool flag = true;
while (flag)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
for (int j = 0; j < numLoadWorlds; j++)
{
Console.WriteLine(string.Concat(new object[] { j + 1, '\t', '\t', loadWorld[j] }));
}
Console.WriteLine(string.Concat(new object[] { "n", '\t', '\t', "New World" }));
Console.WriteLine("d <number>" + '\t' + "Delete World");
Console.WriteLine("");
Console.Write("Choose World: ");
string str2 = Console.ReadLine();
try
{
Console.Clear();
}
catch
{
}
if ((str2.Length >= 2) && (str2.Substring(0, 2).ToLower() == "d "))
{
try
{
int index = Convert.ToInt32(str2.Substring(2)) - 1;
if (index < numLoadWorlds)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.WriteLine("Really delete " + loadWorld[index] + "?");
Console.Write("(y/n): ");
if (Console.ReadLine().ToLower() == "y")
{
EraseWorld(index);
}
}
}
catch
{
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
if ((str2 == "n") || (str2 == "N"))
{
bool flag2 = true;
while (flag2)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.WriteLine("1" + '\t' + "Small");
Console.WriteLine("2" + '\t' + "Medium");
Console.WriteLine("3" + '\t' + "Large");
Console.WriteLine("");
Console.Write("Choose size: ");
string str4 = Console.ReadLine();
try
{
switch (Convert.ToInt32(str4))
{
case 1:
maxTilesX = 0x1068;
maxTilesY = 0x4b0;
//.........這裏部分代碼省略.........
示例7: DedServ
public void DedServ()
{
Main.rand = new Random();
if (Main.autoShutdown)
{
string text = "terraria" + Main.rand.Next(2147483647);
Console.Title = text;
IntPtr intPtr = Main.FindWindow(null, text);
if (intPtr != IntPtr.Zero)
{
Main.ShowWindow(intPtr, 0);
}
}
else
{
Console.Title = "Terraria Server " + Main.versionNumber2;
}
Main.dedServ = true;
Main.showSplash = false;
this.Initialize();
Lang.setLang(false);
for (int i = 0; i < 301; i++)
{
NPC nPC = new NPC();
nPC.SetDefaults(i, -1f);
Main.npcName[i] = nPC.name;
}
while (Main.worldPathName == null || Main.worldPathName == "")
{
Main.LoadWorlds();
bool flag = true;
while (flag)
{
Console.WriteLine("Terraria Server " + Main.versionNumber2);
Console.WriteLine("");
for (int j = 0; j < Main.numLoadWorlds; j++)
{
Console.WriteLine(string.Concat(new object[]
{
j + 1,
'\t',
'\t',
Main.loadWorld[j]
}));
}
Console.WriteLine(string.Concat(new object[]
{
"n",
'\t',
'\t',
"New World"
}));
Console.WriteLine("d <number>" + '\t' + "Delete World");
Console.WriteLine("");
Console.Write("Choose World: ");
string text2 = Console.ReadLine();
try
{
Console.Clear();
}
catch
{
}
if (text2.Length >= 2 && text2.Substring(0, 2).ToLower() == "d ")
{
try
{
int num = Convert.ToInt32(text2.Substring(2)) - 1;
if (num < Main.numLoadWorlds)
{
Console.WriteLine("Terraria Server " + Main.versionNumber2);
Console.WriteLine("");
Console.WriteLine("Really delete " + Main.loadWorld[num] + "?");
Console.Write("(y/n): ");
string text3 = Console.ReadLine();
if (text3.ToLower() == "y")
{
Main.EraseWorld(num);
}
}
}
catch
{
}
try
{
Console.Clear();
continue;
}
catch
{
continue;
}
}
if (text2 == "n" || text2 == "N")
{
bool flag2 = true;
while (flag2)
{
Console.WriteLine("Terraria Server " + Main.versionNumber2);
//.........這裏部分代碼省略.........
示例8: HandleSpawnBoss
private static bool HandleSpawnBoss(GetDataHandlerArgs args)
{
if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
{
return true;
}
var spawnboss = false;
var invasion = false;
var plr = args.Data.ReadInt32();
var Type = args.Data.ReadInt32();
NPC npc = new NPC();
npc.SetDefaults(Type);
spawnboss = npc.boss;
if (!spawnboss)
{
switch (Type)
{
case -1:
case -2:
case -3:
case -4:
case -5:
invasion = true;
break;
case 4:
case 13:
case 35:
case 50:
case 113:
case 125:
case 126:
case 127:
case 128:
case 134:
case 222:
case 245:
case 262:
case 266:
spawnboss = true;
break;
}
}
if (spawnboss && !args.Player.Group.HasPermission(Permissions.summonboss))
{
args.Player.SendMessage("You don't have permission to summon a boss.", Color.Red);
return true;
}
if (invasion && !args.Player.Group.HasPermission(Permissions.startinvasion))
{
args.Player.SendMessage("You don't have permission to start an invasion.", Color.Red);
return true;
}
if (!spawnboss && !invasion)
return true;
if (plr != args.Player.Index)
return true;
string boss;
switch (Type)
{
case -5:
boss = "a snow invasion";
break;
case -4:
boss = "a pumpkin invasion";
break;
case -3:
boss = "the pirates";
break;
case -2:
boss = "the Snow Legion";
break;
case -1:
boss = "a Goblin Invasion";
break;
default:
boss = String.Format("the {0}", npc.name);
break;
}
TShock.Utils.SendLogs(string.Format("{0} summoned {1}.", args.Player.Name, boss), Color.PaleVioletRed, args.Player);
return false;
}
示例9: SpawnBoss
private static void SpawnBoss(CommandArgs args)
{
if (args.Parameters.Count < 1 || args.Parameters.Count > 2)
{
args.Player.SendErrorMessage("指令錯誤 使用{0}刷Boss BOSS名 數量 來召喚BOSS", Specifier);
args.Player.SendErrorMessage("例如{0}刷Boss 克魯蘇之腦 1 表示召喚了1隻克魯蘇之腦", Specifier);
args.Player.SendErrorMessage("BOSS名如下 克魯蘇之腦 機械毀滅者 豬鯊公爵 世界吞噬者 克魯蘇之眼 石頭人 史萊姆國王", Specifier);
args.Player.SendErrorMessage("世紀之花 機械骷髏王 蜂後 骷髏王 魔眼雙子 肉山大魔牆 月之領主", Specifier);
return;
}
int amount = 1;
if (args.Parameters.Count == 2 && (!int.TryParse(args.Parameters[1], out amount) || amount <= 0))
{
args.Player.SendErrorMessage("數量錯誤。");
return;
}
NPC npc = new NPC();
switch (args.Parameters[0].ToLower())
{
case "*":
case "all":
case "所有":
int[] npcIds = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370, 398 };
TSPlayer.Server.SetTime(false, 0.0);
foreach (int i in npcIds)
{
npc.SetDefaults(i);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
}
TSPlayer.All.SendSuccessMessage("{0} 召喚了所有Boss{1}次。", args.Player.Name, amount);
return;
case "brain":
case "brain of cthulhu":
case "克魯蘇之腦":
npc.SetDefaults(266);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻克魯蘇之腦", args.Player.Name, amount);
return;
case "destroyer":
case "機械毀滅者":
npc.SetDefaults(134);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻機械毀滅者", args.Player.Name, amount);
return;
case "duke":
case "duke fishron":
case "fishron":
case "豬鯊公爵":
case "豬鯊":
npc.SetDefaults(370);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻豬鯊公爵", args.Player.Name, amount);
return;
case "eater":
case "eater of worlds":
case "世界吞噬者":
npc.SetDefaults(13);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻世界吞噬者", args.Player.Name, amount);
return;
case "eye":
case "eye of cthulhu":
case "克魯蘇之眼":
npc.SetDefaults(4);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0} 召喚了{1}個克蘇魯之眼。", args.Player.Name, amount);
return;
case "golem":
case "石頭人":
npc.SetDefaults(245);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻石頭人", args.Player.Name, amount);
return;
case "king":
case "king slime":
case "史萊姆國王":
case "史萊姆王":
npc.SetDefaults(50);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻史萊姆國王", args.Player.Name, amount);
return;
case "plantera":
case "世紀之花":
npc.SetDefaults(262);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻世紀之花", args.Player.Name, amount);
return;
case "prime":
case "skeletron prime":
case "機械骷髏王":
npc.SetDefaults(127);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY);
TSPlayer.All.SendSuccessMessage("{0}召喚了{1}隻機械骷髏王", args.Player.Name, amount);
return;
case "queen":
//.........這裏部分代碼省略.........
示例10: SpawnBoss
public static void SpawnBoss(CommandArgs args)
{
if (args.Parameters.Count == 1 && args.Parameters[0] == "list")
{
args.Player.SendInfoMessage("Available bosses: {0}", string.Join(", ", bosses));
return;
}
if (args.Parameters.Count < 1 || args.Parameters.Count > 4)
{
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}spawnboss <boss type> [amount] [XPos] [YPos]", TShock.Config.CommandSpecifier);
return;
}
if (!args.Player.RealPlayer && args.Parameters.Count != 4)
{
args.Player.SendErrorMessage("You are required to set coordinates from console! ");
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}spawnmob <mob type> [amount] [XPos] [YPos]", TShock.Config.CommandSpecifier);
return;
}
int amount = 1;
if (args.Parameters.Count >= 2 && (!int.TryParse(args.Parameters[1], out amount) || amount <= 0))
{
args.Player.SendErrorMessage("Invalid boss amount!");
return;
}
int x = -1;
int y = -1;
if (args.Parameters.Count >= 3 && !int.TryParse(args.Parameters[2], out x))
{
args.Player.SendErrorMessage("Invalid X coordinates!");
return;
}
if (args.Parameters.Count == 3)
{
args.Player.SendErrorMessage("You must set both X and Y coordinates!");
return;
}
if (args.Parameters.Count == 4)
{
if (args.Parameters.Count >= 4 && !int.TryParse(args.Parameters[3], out y))
{
args.Player.SendErrorMessage("Invalid Y coordinates!");
return;
}
if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
{
args.Player.SendErrorMessage("Given coordinates are invalid!");
return;
}
}
int TileX = -1;
int TileY = -1;
if (args.Parameters.Count == 4)
{
TileX = x;
TileY = y;
}
else
{
TileX = args.Player.TileX;
TileY = args.Player.TileY;
}
NPC npc = new NPC();
switch (args.Parameters[0].ToLower())
{
case "*":
case "all":
int[] npcIds = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370 };
TSPlayer.Server.SetTime(false, 0.0);
foreach (int i in npcIds)
{
npc.SetDefaults(i);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, TileX, TileY);
}
if (!args.Silent)
TSPlayer.All.SendSuccessMessage("{0} has spawned all bosses {1} time(s).", args.Player.Name, amount);
else
args.Player.SendSuccessMessage("Spawned all bosses {0} time(s).", amount);
return;
case "brain":
case "brain of cthulhu":
npc.SetDefaults(266);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, TileX, TileY);
if (!args.Silent)
TSPlayer.All.SendSuccessMessage("{0} has spawned the Brain of Cthulhu {1} time(s).", args.Player.Name, amount);
else
args.Player.SendSuccessMessage("Spawned the Brain of Cthulhu {0} time(s).", amount);
return;
case "destroyer":
npc.SetDefaults(134);
TSPlayer.Server.SetTime(false, 0.0);
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, TileX, TileY);
if (!args.Silent)
TSPlayer.All.SendSuccessMessage("{0} has spawned the Destroyer {1} time(s).", args.Player.Name, amount);
else
args.Player.SendSuccessMessage("Spawned the Destroyer {0} time(s).", amount);
return;
//.........這裏部分代碼省略.........
示例11: GetNpcs
public IEnumerable<Terraria.NPC> GetNpcs()
{
int[] friends = new int[]
{
17,
18,
19,
20,
22,
54,
38,
107,
108,
124,
160,
178,
207,
208,
209,
227,
228,
229
};
foreach (int id in friends)
{
var npc = new NPC();
npc.SetDefaults(id);
yield return npc;
}
}
示例12: OpenBossBag
//.........這裏部分代碼省略.........
}
if (type == 3322)
{
num14 = 222;
}
if (type == 3323)
{
num14 = 35;
}
if (type == 3324)
{
num14 = 113;
}
if (type == 3325)
{
num14 = 134;
}
if (type == 3326)
{
num14 = 125;
}
if (type == 3327)
{
num14 = 127;
}
if (type == 3328)
{
num14 = 262;
}
if (type == 3329)
{
num14 = 245;
}
if (type == 3330)
{
num14 = 370;
}
if (type == 3331)
{
num14 = 439;
}
if (type == 3332)
{
num14 = 398;
}
if (num14 > 0)
{
NPC nPC = new NPC();
nPC.SetDefaults(num14, -1f);
float num15 = nPC.value;
num15 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
if (Main.rand.Next(5) == 0)
{
num15 *= 1f + (float)Main.rand.Next(5, 11) * 0.01f;
}
if (Main.rand.Next(10) == 0)
{
num15 *= 1f + (float)Main.rand.Next(10, 21) * 0.01f;
}
if (Main.rand.Next(15) == 0)
{
num15 *= 1f + (float)Main.rand.Next(15, 31) * 0.01f;
}
if (Main.rand.Next(20) == 0)
{
num15 *= 1f + (float)Main.rand.Next(20, 41) * 0.01f;
}
while ((int)num15 > 0)
{
if (num15 > 1000000f)
{
int num16 = (int)(num15 / 1000000f);
num15 -= (float)(1000000 * num16);
this.QuickSpawnItem(74, num16);
}
else if (num15 > 10000f)
{
int num17 = (int)(num15 / 10000f);
num15 -= (float)(10000 * num17);
this.QuickSpawnItem(73, num17);
}
else if (num15 > 100f)
{
int num18 = (int)(num15 / 100f);
num15 -= (float)(100 * num18);
this.QuickSpawnItem(72, num18);
}
else
{
int num19 = (int)num15;
if (num19 < 1)
{
num19 = 1;
}
num15 -= (float)num19;
this.QuickSpawnItem(71, num19);
}
}
}
}
示例13: DedServ
public void DedServ()
{
GameHooks.OnInitialize(true);
Main.rand = new Random();
if (Main.autoShutdown)
{
string text = "terraria" + Main.rand.Next(2147483647);
Console.Title = text;
IntPtr intPtr = Main.FindWindow(null, text);
if (intPtr != IntPtr.Zero)
{
Main.ShowWindow(intPtr, 0);
}
}
else
{
Console.Title = "Terraria Server " + Main.versionNumber2;
}
Main.dedServ = true;
Main.showSplash = false;
this.Initialize();
/*var npcstring = "";
for (int i = -17; i < Terraria.Main.maxNPCTypes; i++)
{
var Npc = new Terraria.NPC();
Npc.netDefaults(i);
npcstring += string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\n",
Npc.type, Npc.netID, Npc.name, Npc.life, Npc.damage, Npc.defense, Npc.knockBackResist, Npc.noGravity, Npc.value,
Npc.friendly, Npc.noTileCollide, Npc.aiStyle, Npc.scale, Npc.boss, Npc.lavaImmune, Npc.townNPC,
Npc.height, Npc.width);
}
File.WriteAllText("npc.txt", npcstring);
var itemstring = "";
for (int i = -24; i < Terraria.Main.maxItemTypes; i++)
{
var item = new Terraria.Item();
item.netDefaults(i);
itemstring += item.type + "\t" + item.name + "\n";
}
File.WriteAllText("item.txt", itemstring);
var prefixstring = "";
for (int i = 1; i < 84; i++)
{
Item item = new Item();
item.SetDefaults(0);
item.prefix = (byte)i;
prefixstring += i + "\t" + item.AffixName() + "\n";
}
File.WriteAllText("prefix.txt", prefixstring);*/
for (int i = 0; i < 142; i++)
{
NPC nPC = new NPC();
nPC.SetDefaults(i, -1f);
Main.npcName[i] = nPC.name;
}
while (Main.worldPathName == null || Main.worldPathName == "")
{
Main.LoadWorlds();
bool flag = true;
while (flag)
{
Console.WriteLine("Terraria Server " + Main.versionNumber2);
Console.WriteLine("");
for (int j = 0; j < Main.numLoadWorlds; j++)
{
Console.WriteLine(string.Concat(new object[]
{
j + 1,
'\t',
'\t',
Main.loadWorld[j]
}));
}
Console.WriteLine(string.Concat(new object[]
{
"n",
'\t',
'\t',
"New World"
}));
Console.WriteLine("d <number>" + '\t' + "Delete World");
Console.WriteLine("");
Console.Write("Choose World: ");
string text2 = Console.ReadLine();
try
{
Console.Clear();
}
catch
{
}
if (text2.Length >= 2 && text2.Substring(0, 2).ToLower() == "d ")
{
try
{
int num = Convert.ToInt32(text2.Substring(2)) - 1;
if (num < Main.numLoadWorlds)
{
Console.WriteLine("Terraria Server " + Main.versionNumber2);
Console.WriteLine("");
//.........這裏部分代碼省略.........
示例14: ReadV1
//.........這裏部分代碼省略.........
}
#endregion
#region signs
for (int i = 0; i < ret.signs.Length; i++)
{
if (!bb.ReadBool())
continue;
ret.signs[i] = new Sign()
{
text = PlayerPorter.ReadString(bb),
position = new Point(bb.ReadInt(), bb.ReadInt())
};
}
#endregion
#region town npcs
while (bb.ReadBool())
{
TownNPC n = new TownNPC()
{
occupation = PlayerPorter.ReadString(bb)
};
if (ver >= 83)
n.name = PlayerPorter.ReadString(bb);
n.position = new Vector2(bb.ReadFloat(), bb.ReadFloat());
n.homeless = bb.ReadBool();
n.homeTile = new Point(bb.ReadInt(), bb.ReadInt());
NPC npc = new NPC();
npc.SetDefaults(n.occupation);
n.type = npc.type;
ret.townNPCs.Add(n);
}
if (ver >= 31 && ver <= 83)
{
string
merchantName = PlayerPorter.ReadString(bb),
nurseName = PlayerPorter.ReadString(bb),
armsDealerName = PlayerPorter.ReadString(bb),
dryadName = PlayerPorter.ReadString(bb),
guideName = PlayerPorter.ReadString(bb),
clothierName = PlayerPorter.ReadString(bb),
demolitionistName = PlayerPorter.ReadString(bb),
goblinName = PlayerPorter.ReadString(bb),
wizardName = PlayerPorter.ReadString(bb),
mechanicName = String.Empty,
truffleName = String.Empty,
steampunkerName = String.Empty,
dyeTraderName = String.Empty,
partyGirlName = String.Empty,
cyborgName = String.Empty,
painterName = String.Empty,
witchDoctorName = String.Empty,
pirateName = String.Empty,
anglerName = String.Empty;
if (ver >= 35)
{
mechanicName = PlayerPorter.ReadString(bb);
示例15: GetNpcByName
public NPC GetNpcByName(string name)
{
if (name == null)
{
Console.WriteLine(MessageType.Warning, "API: getNpcByName() failed (name was null");
return null;
}
NPC n = new NPC();
for (int i = 100; i > 0; i--)
{
try
{
n.SetDefaults(i);
if (n.name == "") continue;
if (n.name == null) continue;
}
catch
{
continue;
}
if (Input.CommandMatch(name, n.name))
{
return n;
}
}
n = null;
return n;
}