Terraria ModLoader  0.11.7.5
A mod to make and play Terraria mods
NPCSpawnHelper.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using Terraria.GameContent.Events;
4 using Terraria.ID;
5 
6 namespace Terraria.ModLoader
7 {
8  //todo: further documentation
12  public static class NPCSpawnHelper
13  {
14  internal static List<SpawnCondition> conditions = new List<SpawnCondition>();
15 
16  internal static void Reset() {
17  foreach (SpawnCondition cond in conditions) {
18  cond.Reset();
19  }
20  }
21 
22  internal static void DoChecks(NPCSpawnInfo info) {
23  float weight = 1f;
24  foreach (SpawnCondition cond in conditions) {
25  cond.Check(info, ref weight);
26  if (Math.Abs(weight) < 5E-6) {
27  break;
28  }
29  }
30  }
31  }
32 
33  //todo: further documentation
34  public class SpawnCondition
35  {
36  private Func<NPCSpawnInfo, bool> condition;
37  private List<SpawnCondition> children;
38  private float blockWeight;
39  internal Func<float> WeightFunc;
40 
41  private float chance;
42  private bool active;
43 
44  internal IEnumerable<SpawnCondition> Children => children;
45  internal float BlockWeight => blockWeight;
46 
47  public float Chance => chance;
48  public bool Active => active;
49 
50  internal SpawnCondition(Func<NPCSpawnInfo, bool> condition, float blockWeight = 1f) {
51  this.condition = condition;
52  this.children = new List<SpawnCondition>();
53  this.blockWeight = blockWeight;
54  NPCSpawnHelper.conditions.Add(this);
55  }
56 
57  internal SpawnCondition(SpawnCondition parent, Func<NPCSpawnInfo, bool> condition, float blockWeight = 1f) {
58  this.condition = condition;
59  this.children = new List<SpawnCondition>();
60  this.blockWeight = blockWeight;
61  parent.children.Add(this);
62  }
63 
64  internal void Reset() {
65  chance = 0f;
66  active = false;
67  foreach (SpawnCondition child in children) {
68  child.Reset();
69  }
70  }
71 
72  internal void Check(NPCSpawnInfo info, ref float remainingWeight) {
73  if (WeightFunc != null) {
74  blockWeight = WeightFunc();
75  }
76  active = true;
77  if (condition(info)) {
78  chance = remainingWeight * blockWeight;
79  float childWeight = chance;
80  foreach (SpawnCondition child in children) {
81  child.Check(info, ref childWeight);
82  if (Math.Abs(childWeight) < 5E-6) {
83  break;
84  }
85  }
86  remainingWeight -= chance;
87  }
88  }
89 
90  public static readonly SpawnCondition NebulaTower;
91  public static readonly SpawnCondition VortexTower;
92  public static readonly SpawnCondition StardustTower;
93  public static readonly SpawnCondition SolarTower;
94  public static readonly SpawnCondition Sky;
95  public static readonly SpawnCondition Invasion;
96  public static readonly SpawnCondition GoblinArmy;
97  public static readonly SpawnCondition FrostLegion;
98  public static readonly SpawnCondition Pirates;
99  public static readonly SpawnCondition MartianMadness;
100  public static readonly SpawnCondition Bartender;
101  public static readonly SpawnCondition SpiderCave;
102  public static readonly SpawnCondition DesertCave;
103  public static readonly SpawnCondition HardmodeJungleWater;
104  public static readonly SpawnCondition HardmodeCrimsonWater;
105  public static readonly SpawnCondition Ocean;
106  public static readonly SpawnCondition OceanAngler;
107  public static readonly SpawnCondition OceanMonster;
108  public static readonly SpawnCondition BeachAngler;
109  public static readonly SpawnCondition JungleWater;
110  public static readonly SpawnCondition CavePiranha;
111  public static readonly SpawnCondition CaveJellyfish;
112  public static readonly SpawnCondition WaterCritter;
113  public static readonly SpawnCondition CorruptWaterCritter;
114  public static readonly SpawnCondition OverworldWaterCritter;
117  public static readonly SpawnCondition DefaultWaterCritter;
118  public static readonly SpawnCondition BoundCaveNPC;
119  public static readonly SpawnCondition TownCritter;
120  public static readonly SpawnCondition TownWaterCritter;
124  public static readonly SpawnCondition TownDefaultWaterCritter;
125  public static readonly SpawnCondition TownSnowCritter;
126  public static readonly SpawnCondition TownJungleCritter;
127  public static readonly SpawnCondition TownGeneralCritter;
128  public static readonly SpawnCondition Dungeon;
129  public static readonly SpawnCondition DungeonGuardian;
130  public static readonly SpawnCondition DungeonNormal;
131  public static readonly SpawnCondition Meteor;
132  public static readonly SpawnCondition OldOnesArmy;
133  public static readonly SpawnCondition FrostMoon;
134  public static readonly SpawnCondition PumpkinMoon;
135  public static readonly SpawnCondition SolarEclipse;
136  public static readonly SpawnCondition HardmodeMushroomWater;
137  public static readonly SpawnCondition OverworldMushroom;
138  public static readonly SpawnCondition UndergroundMushroom;
139  public static readonly SpawnCondition CorruptWorm;
140  public static readonly SpawnCondition UndergroundMimic;
141  public static readonly SpawnCondition OverworldMimic;
142  public static readonly SpawnCondition Wraith;
143  public static readonly SpawnCondition HoppinJack;
144  public static readonly SpawnCondition DoctorBones;
145  public static readonly SpawnCondition LacBeetle;
146  public static readonly SpawnCondition WormCritter;
147  public static readonly SpawnCondition MouseCritter;
148  public static readonly SpawnCondition SnailCritter;
149  public static readonly SpawnCondition FrogCritter;
150  public static readonly SpawnCondition HardmodeJungle;
151  public static readonly SpawnCondition JungleTemple;
152  public static readonly SpawnCondition UndergroundJungle;
153  public static readonly SpawnCondition SurfaceJungle;
154  public static readonly SpawnCondition SandstormEvent;
155  public static readonly SpawnCondition Mummy;
156  public static readonly SpawnCondition DarkMummy;
157  public static readonly SpawnCondition LightMummy;
158  public static readonly SpawnCondition OverworldHallow;
159  public static readonly SpawnCondition EnchantedSword;
160  public static readonly SpawnCondition Crimson;
161  public static readonly SpawnCondition Corruption;
162  public static readonly SpawnCondition Overworld;
163  public static readonly SpawnCondition IceGolem;
164  public static readonly SpawnCondition RainbowSlime;
165  public static readonly SpawnCondition AngryNimbus;
166  public static readonly SpawnCondition MartianProbe;
167  public static readonly SpawnCondition OverworldDay;
168  public static readonly SpawnCondition OverworldDaySnowCritter;
169  public static readonly SpawnCondition OverworldDayGrassCritter;
170  public static readonly SpawnCondition OverworldDaySandCritter;
172  public static readonly SpawnCondition OverworldDayBirdCritter;
173  public static readonly SpawnCondition KingSlime;
174  public static readonly SpawnCondition OverworldDayDesert;
175  public static readonly SpawnCondition GoblinScout;
176  public static readonly SpawnCondition OverworldDayRain;
177  public static readonly SpawnCondition OverworldDaySlime;
178  public static readonly SpawnCondition OverworldNight;
179  public static readonly SpawnCondition OverworldFirefly;
180  public static readonly SpawnCondition OverworldNightMonster;
181  public static readonly SpawnCondition Underground;
182  public static readonly SpawnCondition Underworld;
183  public static readonly SpawnCondition Cavern;
184 
185  static SpawnCondition() {
186  NebulaTower = new SpawnCondition((info) => info.player.ZoneTowerNebula);
187  VortexTower = new SpawnCondition((info) => info.player.ZoneTowerVortex);
188  StardustTower = new SpawnCondition((info) => info.player.ZoneTowerStardust);
189  SolarTower = new SpawnCondition((info) => info.player.ZoneTowerSolar);
190  Sky = new SpawnCondition((info) => info.sky);
191  Invasion = new SpawnCondition((info) => info.invasion);
192  GoblinArmy = new SpawnCondition(Invasion, (info) => Main.invasionType == 1);
193  FrostLegion = new SpawnCondition(Invasion, (info) => Main.invasionType == 2);
194  Pirates = new SpawnCondition(Invasion, (info) => Main.invasionType == 3);
195  MartianMadness = new SpawnCondition(Invasion, (info) => Main.invasionType == 4);
196  Bartender = new SpawnCondition((info) => !NPC.savedBartender && DD2Event.ReadyToFindBartender
197  && !NPC.AnyNPCs(NPCID.BartenderUnconscious) && !info.water, 1f / 80f);
198  SpiderCave = new SpawnCondition((info) => GetTile(info).wall == WallID.SpiderUnsafe || info.spiderCave);
199  DesertCave = new SpawnCondition((info) => (WallID.Sets.Conversion.HardenedSand[GetTile(info).wall]
200  || WallID.Sets.Conversion.Sandstone[GetTile(info).wall] || info.desertCave)
201  && WorldGen.checkUnderground(info.spawnTileX, info.spawnTileY));
202  HardmodeJungleWater = new SpawnCondition((info) => Main.hardMode && info.water && info.player.ZoneJungle, 2f / 3f);
203  HardmodeCrimsonWater = new SpawnCondition((info) => Main.hardMode && info.water && info.player.ZoneCrimson, 8f / 9f);
204  Ocean = new SpawnCondition((info) => info.water && (info.spawnTileX < 250 || info.spawnTileX > Main.maxTilesX - 250)
205  && Main.tileSand[info.spawnTileType] && info.spawnTileY < Main.rockLayer);
206  OceanAngler = new SpawnCondition(Ocean, (info) => !NPC.savedAngler && !NPC.AnyNPCs(NPCID.SleepingAngler)
207  && WaterSurface(info));
208  OceanMonster = new SpawnCondition(Ocean, (info) => true);
209  BeachAngler = new SpawnCondition((info) => !info.water && !NPC.savedAngler && !NPC.AnyNPCs(NPCID.SleepingAngler)
210  && (info.spawnTileX < 340 || info.spawnTileX > Main.maxTilesX - 340) && Main.tileSand[info.spawnTileType]
211  && info.spawnTileY < Main.worldSurface);
212  JungleWater = new SpawnCondition((info) => info.water && info.spawnTileType == TileID.JungleGrass);
213  CavePiranha = new SpawnCondition((info) => info.water && info.spawnTileY > Main.rockLayer, 0.5f);
214  CaveJellyfish = new SpawnCondition((info) => info.water && info.spawnTileY > Main.worldSurface, 1f / 3f);
215  WaterCritter = new SpawnCondition((info) => info.water, 0.25f);
216  CorruptWaterCritter = new SpawnCondition(WaterCritter, (info) => info.player.ZoneCorrupt);
217  OverworldWaterCritter = new SpawnCondition(WaterCritter, (info) => info.spawnTileY < Main.worldSurface
218  && info.spawnTileY > 50 && Main.dayTime, 2f / 3f);
219  OverworldWaterSurfaceCritter = new SpawnCondition(OverworldWaterCritter, WaterSurface);
220  OverworldUnderwaterCritter = new SpawnCondition(OverworldWaterCritter, (info) => true);
221  DefaultWaterCritter = new SpawnCondition(WaterCritter, (info) => true);
222  BoundCaveNPC = new SpawnCondition((info) => !info.water && info.spawnTileY >= Main.rockLayer
223  && info.spawnTileY < Main.maxTilesY - 210, 1f / 20f);
224  TownCritter = new SpawnCondition((info) => info.playerInTown);
225  TownWaterCritter = new SpawnCondition(TownCritter, (info) => info.water);
226  TownOverworldWaterCritter = new SpawnCondition(TownWaterCritter, (info) => info.spawnTileY < Main.worldSurface
227  && info.spawnTileY > 50 && Main.dayTime, 2f / 3f);
228  TownOverworldWaterSurfaceCritter = new SpawnCondition(TownOverworldWaterCritter, WaterSurface);
229  TownOverworldUnderwaterCritter = new SpawnCondition(TownOverworldWaterCritter, (info) => true);
230  TownDefaultWaterCritter = new SpawnCondition(TownWaterCritter, (info) => true);
231  TownSnowCritter = new SpawnCondition(TownCritter, (info) => info.spawnTileType == TileID.SnowBlock
232  || info.spawnTileType == TileID.IceBlock);
233  TownJungleCritter = new SpawnCondition(TownCritter, (info) => info.spawnTileType == TileID.JungleGrass);
234  TownGeneralCritter = new SpawnCondition(TownCritter, (info) => info.spawnTileType == TileID.Grass
235  || info.spawnTileType == TileID.HallowedGrass || info.spawnTileY > Main.worldSurface);
236  Dungeon = new SpawnCondition((info) => info.player.ZoneDungeon);
237  DungeonGuardian = new SpawnCondition(Dungeon, (info) => !NPC.downedBoss3);
238  DungeonNormal = new SpawnCondition(Dungeon, (info) => true);
239  Meteor = new SpawnCondition((info) => info.player.ZoneMeteor);
240  OldOnesArmy = new SpawnCondition((info) => DD2Event.Ongoing && info.player.ZoneOldOneArmy);
241  FrostMoon = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface && !Main.dayTime && Main.snowMoon);
242  PumpkinMoon = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface
243  && !Main.dayTime && Main.pumpkinMoon);
244  SolarEclipse = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface && Main.dayTime && Main.eclipse);
245  HardmodeMushroomWater = new SpawnCondition((info) => Main.hardMode && info.spawnTileType == TileID.MushroomGrass
246  && info.water);
247  OverworldMushroom = new SpawnCondition((info) => info.spawnTileType == TileID.MushroomGrass
248  && info.spawnTileY <= Main.worldSurface, 2f / 3f);
249  UndergroundMushroom = new SpawnCondition((info) => info.spawnTileType == TileID.MushroomGrass
250  && Main.hardMode && info.spawnTileY >= Main.worldSurface, 2f / 3f);
251  CorruptWorm = new SpawnCondition((info) => info.player.ZoneCorrupt && !info.playerSafe, 1f / 65f);
252  UndergroundMimic = new SpawnCondition((info) => Main.hardMode && info.spawnTileY > Main.worldSurface, 1f / 70f);
253  OverworldMimic = new SpawnCondition((info) => Main.hardMode && GetTile(info).wall == WallID.DirtUnsafe, 0.05f);
254  Wraith = new SpawnCondition((info) => Main.hardMode && info.spawnTileY <= Main.worldSurface
255  && !Main.dayTime, 0.05f);
256  Wraith.WeightFunc = () => {
257  float inverseChance = 0.95f;
258  if (Main.moonPhase == 4) {
259  inverseChance *= 0.8f;
260  }
261  return 1f - inverseChance;
262  };
263  HoppinJack = new SpawnCondition((info) => Main.hardMode && Main.halloween
264  && info.spawnTileY <= Main.worldSurface && !Main.dayTime, 0.1f);
265  DoctorBones = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass && !Main.dayTime, 0.002f);
266  LacBeetle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass
267  && info.spawnTileY > Main.worldSurface, 1f / 60f);
268  WormCritter = new SpawnCondition((info) => info.spawnTileY > Main.worldSurface
269  && info.spawnTileY < Main.maxTilesY - 210 && !info.player.ZoneSnow && !info.player.ZoneCrimson
270  && !info.player.ZoneCorrupt && !info.player.ZoneJungle && !info.player.ZoneHoly, 1f / 8f);
271  MouseCritter = new SpawnCondition((info) => info.spawnTileY > Main.worldSurface
272  && info.spawnTileY < Main.maxTilesY - 210 && !info.player.ZoneSnow && !info.player.ZoneCrimson
273  && !info.player.ZoneCorrupt && !info.player.ZoneJungle && !info.player.ZoneHoly, 1f / 13f);
274  SnailCritter = new SpawnCondition((info) => info.spawnTileY > Main.worldSurface
275  && info.spawnTileY < (Main.rockLayer + Main.maxTilesY) / 2 && !info.player.ZoneSnow
276  && !info.player.ZoneCrimson && !info.player.ZoneCorrupt && !info.player.ZoneHoly, 1f / 13f);
277  FrogCritter = new SpawnCondition((info) => info.spawnTileY < Main.worldSurface && info.player.ZoneJungle, 1f / 9f);
278  HardmodeJungle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass && Main.hardMode, 2f / 3f);
279  JungleTemple = new SpawnCondition((info) => info.spawnTileType == TileID.LihzahrdBrick && info.lihzahrd);
280  UndergroundJungle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass
281  && info.spawnTileY > (Main.worldSurface + Main.rockLayer) / 2);
282  SurfaceJungle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass, 11f / 32f);
283  SandstormEvent = new SpawnCondition((info) => Sandstorm.Happening && info.player.ZoneSandstorm
284  && TileID.Sets.Conversion.Sand[info.spawnTileType]
285  && NPC.Spawning_SandstoneCheck(info.spawnTileX, info.spawnTileY));
286  Mummy = new SpawnCondition((info) => Main.hardMode && info.spawnTileType == TileID.Sand, 1f / 3f);
287  DarkMummy = new SpawnCondition((info) => Main.hardMode && (info.spawnTileType == TileID.Ebonsand
288  || info.spawnTileType == TileID.Crimsand), 0.5f);
289  LightMummy = new SpawnCondition((info) => Main.hardMode && info.spawnTileType == TileID.Pearlsand, 0.5f);
290  OverworldHallow = new SpawnCondition((info) => Main.hardMode && !info.water && info.spawnTileY < Main.rockLayer
291  && (info.spawnTileType == TileID.Pearlsand || info.spawnTileType == TileID.Pearlstone
292  || info.spawnTileType == TileID.HallowedGrass || info.spawnTileType == TileID.HallowedIce));
293  EnchantedSword = new SpawnCondition((info) => !info.playerSafe && Main.hardMode && !info.water
294  && info.spawnTileY >= Main.rockLayer && (info.spawnTileType == TileID.Pearlsand
295  || info.spawnTileType == TileID.Pearlstone || info.spawnTileType == TileID.HallowedGrass
296  || info.spawnTileType == TileID.HallowedIce), 0.02f);
297  Crimson = new SpawnCondition((info) => (info.spawnTileType == TileID.Crimtane && info.player.ZoneCrimson)
298  || info.spawnTileType == TileID.FleshGrass || info.spawnTileType == TileID.FleshIce
299  || info.spawnTileType == TileID.Crimstone || info.spawnTileType == TileID.Crimsand);
300  Corruption = new SpawnCondition((info) => (info.spawnTileType == TileID.Demonite && info.player.ZoneCorrupt)
301  || info.spawnTileType == TileID.CorruptGrass || info.spawnTileType == TileID.Ebonstone
302  || info.spawnTileType == TileID.Ebonsand || info.spawnTileType == TileID.CorruptIce);
303  Overworld = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface);
304  IceGolem = new SpawnCondition(Overworld, (info) => info.player.ZoneSnow && Main.hardMode
305  && Main.cloudAlpha > 0f && !NPC.AnyNPCs(NPCID.IceGolem), 0.05f);
306  RainbowSlime = new SpawnCondition(Overworld, (info) => info.player.ZoneHoly && Main.hardMode
307  && Main.cloudAlpha > 0f && !NPC.AnyNPCs(NPCID.RainbowSlime), 0.05f);
308  AngryNimbus = new SpawnCondition(Overworld, (info) => !info.player.ZoneSnow && Main.hardMode
309  && Main.cloudAlpha > 0f && NPC.CountNPCS(NPCID.AngryNimbus) < 2, 0.1f);
310  MartianProbe = new SpawnCondition(Overworld, (info) => MartianProbeHelper(info) && Main.hardMode
311  && NPC.downedGolemBoss && !NPC.AnyNPCs(NPCID.MartianProbe), 1f / 400f);
312  MartianProbe.WeightFunc = () => {
313  float inverseChance = 399f / 400f;
314  if (!NPC.downedMartians) {
315  inverseChance *= 0.99f;
316  }
317  return 1f - inverseChance;
318  };
319  OverworldDay = new SpawnCondition(Overworld, (info) => Main.dayTime);
320  OverworldDaySnowCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info)
321  && (GetTile(info).type == TileID.SnowBlock || GetTile(info).type == TileID.IceBlock), 1f / 15f);
322  OverworldDayGrassCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info)
323  && (GetTile(info).type == TileID.Grass || GetTile(info).type == TileID.HallowedGrass), 1f / 15f);
324  OverworldDaySandCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info)
325  && GetTile(info).type == TileID.Sand, 1f / 15f);
326  OverworldMorningBirdCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info) && Main.time < 18000.0
327  && (GetTile(info).type == TileID.Grass || GetTile(info).type == TileID.HallowedGrass), 0.25f);
328  OverworldDayBirdCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info)
329  && (GetTile(info).type == TileID.Grass || GetTile(info).type == TileID.HallowedGrass
330  || GetTile(info).type == TileID.SnowBlock), 1f / 15f);
331  KingSlime = new SpawnCondition(OverworldDay, (info) => OuterThird(info) && GetTile(info).type == TileID.Grass
332  && !NPC.AnyNPCs(NPCID.KingSlime), 1f / 300f);
333  OverworldDayDesert = new SpawnCondition(OverworldDay, (info) => GetTile(info).type == TileID.Sand
334  && !info.water, 0.2f);
335  GoblinScout = new SpawnCondition(OverworldDay, (info) => OuterThird(info), 1f / 15f);
336  GoblinScout.WeightFunc = () => {
337  float inverseChance = 14f / 15f;
338  if (!NPC.downedGoblins && WorldGen.shadowOrbSmashed) {
339  return inverseChance *= (6f / 7f);
340  }
341  return 1f - inverseChance;
342  };
343  OverworldDayRain = new SpawnCondition(OverworldDay, (info) => Main.raining, 2f / 3f);
344  OverworldDaySlime = new SpawnCondition(OverworldDay, (info) => true);
345  OverworldNight = new SpawnCondition(Overworld, (info) => true);
346  OverworldFirefly = new SpawnCondition(OverworldNight, (info) => GetTile(info).type == TileID.Grass
347  || GetTile(info).type == TileID.HallowedGrass, 0.1f);
348  OverworldFirefly.WeightFunc = () => 1f / (float)NPC.fireFlyChance;
349  OverworldNightMonster = new SpawnCondition(OverworldNight, (info) => true);
350  Underground = new SpawnCondition((info) => info.spawnTileY <= Main.rockLayer);
351  Underworld = new SpawnCondition((info) => info.spawnTileY > Main.maxTilesY - 190);
352  Cavern = new SpawnCondition((info) => true);
353  }
354 
355  private static Tile GetTile(NPCSpawnInfo info) {
356  return Main.tile[info.spawnTileX, info.spawnTileY];
357  }
358 
359  private static bool WaterSurface(NPCSpawnInfo info) {
360  if (info.safeRangeX) {
361  return false;
362  }
363  for (int k = info.spawnTileY - 1; k > info.spawnTileY - 50; k--) {
364  if (Main.tile[info.spawnTileX, k].liquid == 0 && !WorldGen.SolidTile(info.spawnTileX, k)
365  && !WorldGen.SolidTile(info.spawnTileX, k + 1) && !WorldGen.SolidTile(info.spawnTileX, k + 2)) {
366  return true;
367  }
368  }
369  return false;
370  }
371 
372  private static bool MartianProbeHelper(NPCSpawnInfo info) {
373  return (float)Math.Abs(info.spawnTileX - Main.maxTilesX / 2) / (float)(Main.maxTilesX / 2) > 0.33f
374  && !NPC.AnyDanger();
375  }
376 
377  private static bool InnerThird(NPCSpawnInfo info) {
378  return Math.Abs(info.spawnTileX - Main.spawnTileX) < Main.maxTilesX / 3;
379  }
380 
381  private static bool OuterThird(NPCSpawnInfo info) {
382  return Math.Abs(info.spawnTileX - Main.spawnTileX) > Main.maxTilesX / 3;
383  }
384  }
385 }
bool lihzahrd
Whether or not the player is inside the jungle temple, where Lihzahrds spawn.
Definition: NPCSpawnInfo.cs:70
static readonly SpawnCondition Crimson
static readonly SpawnCondition IceGolem
int spawnTileX
The x-coordinate of the tile the NPC will spawn above.
Definition: NPCSpawnInfo.cs:11
static readonly SpawnCondition SandstormEvent
static bool MartianProbeHelper(NPCSpawnInfo info)
This server as a central class to help modders spawn their npcs. It&#39;s basically the vanilla spawn cod...
bool invasion
Whether or not there is an invasion going on and the player is near it.
Definition: NPCSpawnInfo.cs:80
static readonly SpawnCondition Overworld
static readonly SpawnCondition Dungeon
static readonly SpawnCondition KingSlime
static readonly SpawnCondition Wraith
static readonly SpawnCondition UndergroundMushroom
static readonly SpawnCondition TownCritter
static bool InnerThird(NPCSpawnInfo info)
int spawnTileY
The y-coordinate of the tile the NPC will spawn above.
Definition: NPCSpawnInfo.cs:16
static readonly SpawnCondition SurfaceJungle
static readonly SpawnCondition MartianProbe
Func< NPCSpawnInfo, bool > condition
static readonly SpawnCondition DefaultWaterCritter
static readonly SpawnCondition TownWaterCritter
bool spiderCave
Whether or not the player is in a spider cave or the NPC will spawn near one.
static readonly SpawnCondition Sky
static readonly SpawnCondition CaveJellyfish
static readonly SpawnCondition VortexTower
static readonly SpawnCondition OverworldDayRain
static readonly SpawnCondition DoctorBones
static readonly SpawnCondition JungleTemple
static readonly SpawnCondition SolarTower
A struct that stores information regarding where an NPC is naturally spawning and the player it is sp...
Definition: NPCSpawnInfo.cs:6
static readonly SpawnCondition Pirates
static readonly SpawnCondition MouseCritter
static readonly SpawnCondition LacBeetle
static readonly SpawnCondition OceanAngler
static readonly SpawnCondition Underground
List< SpawnCondition > children
static bool WaterSurface(NPCSpawnInfo info)
static readonly SpawnCondition PumpkinMoon
static readonly SpawnCondition OverworldMushroom
static readonly SpawnCondition GoblinArmy
static readonly SpawnCondition Corruption
static readonly SpawnCondition OverworldDaySlime
static readonly SpawnCondition OverworldNight
static readonly SpawnCondition Cavern
static readonly SpawnCondition TownGeneralCritter
static readonly SpawnCondition TownOverworldUnderwaterCritter
static readonly SpawnCondition UndergroundJungle
static readonly SpawnCondition AngryNimbus
bool water
Whether or not the tile the NPC will spawn in contains water.
Definition: NPCSpawnInfo.cs:85
static readonly SpawnCondition OverworldMimic
static readonly SpawnCondition OverworldNightMonster
static readonly SpawnCondition OverworldDayGrassCritter
static readonly SpawnCondition EnchantedSword
static Tile GetTile(NPCSpawnInfo info)
static readonly SpawnCondition TownOverworldWaterCritter
static readonly SpawnCondition OverworldWaterSurfaceCritter
static readonly SpawnCondition Ocean
static readonly SpawnCondition BeachAngler
static readonly SpawnCondition TownDefaultWaterCritter
Player player
The player that this NPC is spawning around. For convenience, here are the player zones...
Definition: NPCSpawnInfo.cs:50
static readonly SpawnCondition Mummy
static readonly SpawnCondition TownSnowCritter
static readonly SpawnCondition OverworldDaySandCritter
static readonly SpawnCondition FrostMoon
static readonly SpawnCondition CavePiranha
static readonly SpawnCondition NebulaTower
static readonly SpawnCondition DungeonGuardian
static readonly SpawnCondition HoppinJack
static readonly SpawnCondition WormCritter
static readonly SpawnCondition OverworldWaterCritter
static readonly SpawnCondition OverworldHallow
static readonly SpawnCondition SnailCritter
bool playerSafe
Whether or not the player is in front of a player-placed wall or in a large town. If this is true...
Definition: NPCSpawnInfo.cs:75
static readonly SpawnCondition OverworldMorningBirdCritter
static readonly SpawnCondition SolarEclipse
static readonly SpawnCondition BoundCaveNPC
static readonly SpawnCondition DarkMummy
static readonly SpawnCondition Bartender
bool safeRangeX
Whether or not the NPC is horizontally within the range near the player in which NPCs cannot spawn...
static readonly SpawnCondition WaterCritter
static readonly SpawnCondition JungleWater
static readonly SpawnCondition DungeonNormal
static readonly SpawnCondition SpiderCave
static readonly SpawnCondition UndergroundMimic
bool desertCave
Whether or not the player is in front of a desert wall or the NPC will spawn near one...
static readonly SpawnCondition Underworld
static bool OuterThird(NPCSpawnInfo info)
static readonly SpawnCondition OverworldDayDesert
static readonly SpawnCondition DesertCave
static readonly SpawnCondition LightMummy
static readonly SpawnCondition HardmodeMushroomWater
bool sky
Whether or not the player is in the sky biome, where harpies and wyverns spawn.
Definition: NPCSpawnInfo.cs:65
static readonly SpawnCondition RainbowSlime
static readonly SpawnCondition Meteor
static readonly SpawnCondition MartianMadness
static readonly SpawnCondition FrogCritter
static readonly SpawnCondition OverworldDay
static readonly SpawnCondition HardmodeJungle
static readonly SpawnCondition GoblinScout
static readonly SpawnCondition OverworldFirefly
static readonly SpawnCondition TownJungleCritter
static readonly SpawnCondition FrostLegion
static readonly SpawnCondition OverworldDayBirdCritter
static readonly SpawnCondition CorruptWorm
static readonly SpawnCondition OverworldDaySnowCritter
static readonly SpawnCondition CorruptWaterCritter
static readonly SpawnCondition OldOnesArmy
static readonly SpawnCondition StardustTower
static readonly SpawnCondition OverworldUnderwaterCritter
static readonly SpawnCondition Invasion
static readonly SpawnCondition HardmodeCrimsonWater
static readonly SpawnCondition OceanMonster
static readonly SpawnCondition TownOverworldWaterSurfaceCritter
bool playerInTown
Whether or not the player is in a town. This is used for spawning critters instead of monsters...
static readonly SpawnCondition HardmodeJungleWater