TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ UpdateNPC_CritterSounds()

void Terraria.NPC.UpdateNPC_CritterSounds ( )
inlineprivate

Definition at line 109285 of file NPC.cs.

109286 {
109287 if (Main.netMode == 2)
109288 {
109289 return;
109290 }
109291 if (type == 611 && !Main.dayTime && Main.rand.Next(700) == 0)
109292 {
109293 SoundEngine.PlaySound(46, (int)position.X, (int)position.Y);
109294 }
109295 if (type >= 602 && type <= 603 && Main.dayTime && Main.rand.Next(1200) == 0)
109296 {
109297 SoundEngine.PlaySound(44, (int)position.X, (int)position.Y);
109298 }
109299 if (type >= 362 && type <= 365)
109300 {
109301 if (Main.dayTime && Main.rand.Next(200) == 0)
109302 {
109303 SoundEngine.PlaySound(30, (int)position.X, (int)position.Y);
109304 }
109305 }
109306 else if (type == 361 || type == 445 || type == 687)
109307 {
109308 if ((double)Math.Abs(velocity.X) < 0.5 && (!Main.dayTime || (double)position.Y > Main.worldSurface * 16.0) && Main.rand.Next(200) == 0)
109309 {
109310 SoundEngine.PlaySound(31, (int)position.X, (int)position.Y);
109311 }
109312 }
109313 else if (type == 74 || type == 297 || type == 298 || type == 442 || type == 671 || type == 672 || type == 673 || type == 674 || type == 675)
109314 {
109315 if (!Main.dayTime || !(Main.time < 18000.0))
109316 {
109317 return;
109318 }
109319 int maxValue = 400;
109320 if (Main.rand.Next(maxValue) != 0)
109321 {
109322 return;
109323 }
109324 if (type == 74)
109325 {
109326 if (Main.rand.Next(3) != 0)
109327 {
109328 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 14);
109329 }
109330 else
109331 {
109332 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 18);
109333 }
109334 }
109335 if (type == 297)
109336 {
109337 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 16);
109338 }
109339 if (type == 298)
109340 {
109341 if (Main.rand.Next(3) != 0)
109342 {
109343 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 17);
109344 }
109345 else
109346 {
109347 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 19);
109348 }
109349 }
109350 if (type == 674 || type == 675)
109351 {
109352 SoundEngine.PlaySound(67, (int)position.X, (int)position.Y);
109353 }
109354 if (type == 671 || type == 672)
109355 {
109356 SoundEngine.PlaySound(68, (int)position.X, (int)position.Y);
109357 }
109358 if (type == 673)
109359 {
109360 SoundEngine.PlaySound(69, (int)position.X, (int)position.Y);
109361 }
109362 if (type == 442)
109363 {
109364 switch (Main.rand.Next(5))
109365 {
109366 case 0:
109367 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 16);
109368 break;
109369 case 1:
109370 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 17);
109371 break;
109372 case 2:
109373 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 19);
109374 break;
109375 case 3:
109376 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 14);
109377 break;
109378 default:
109379 SoundEngine.PlaySound(32, (int)position.X, (int)position.Y, 18);
109380 break;
109381 }
109382 }
109383 }
109384 else if ((type == 300 || type == 447 || type == 610) && Main.rand.Next(1800) == 0)
109385 {
109386 SoundEngine.PlaySound(33, (int)position.X, (int)position.Y);
109387 }
109388 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990

References Terraria.Main.dayTime, Terraria.Main.netMode, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.rand, Terraria.Main.time, and Terraria.Main.worldSurface.

+ Here is the call graph for this function: