52584 {
52585
52586
52587
52588
52589
52590
52591
52592
52593
52594
52595
52596
52597
52598
52599
52600
52601
52602
52603
52604
52605
52606
52607
52608
52609
52610
52611
52612
52613
52614
52615
52616
52617
52618
52619
52620
52621
52622
52623
52624
52625
52626
52627
52628
52629
52633 {
52636 {
52637 if (Main.npc[
num23].active && Main.npc[
num23].type >= 134 && Main.npc[
num23].type <= 136)
52638 {
52640 if (Main.npc[
num23].type == 134)
52641 {
52642 break;
52643 }
52645 {
52647 break;
52648 }
52650 continue;
52651 }
52653 break;
52654 }
52655 }
52657 {
52659 }
52661 {
52663 }
52665 {
52667 if (
type == 134 || (
type != 134 && Main.npc[(
int)
ai[1]].alpha < 128))
52668 {
52670 {
52671 for (int i = 0; i < 2; i++)
52672 {
52674 Main.dust[
num25].noGravity =
true;
52675 Main.dust[
num25].noLight =
true;
52676 }
52677 }
52680 {
52682 }
52683 }
52684 }
52686 {
52689 {
52691 }
52692 else if (Main.npc[(
int)
ai[1]].life <= 0)
52693 {
52695 }
52697 {
52701 }
52702 }
52703 if (Main.netMode != 1)
52704 {
52705 if (
ai[0] == 0
f &&
type == 134)
52706 {
52713 {
52716 {
52718 }
52724 NetMessage.SendData(23, -1, -1,
null,
num26);
52726 }
52727 }
52729 {
52730 localAI[0] += Main.rand.Next(4);
52731 if (
localAI[0] >= (
float)Main.rand.Next(1400, 26000))
52732 {
52736 {
52737 Vector2
vector =
default(Vector2);
52739 float num29 = Main.player[
target].position.X + (float)Main.player[
target].width * 0.5f -
vector.X + (
float)Main.rand.Next(-20, 21);
52740 float num30 = Main.player[
target].position.Y + (float)Main.player[
target].height * 0.5f -
vector.Y + (
float)Main.rand.Next(-20, 21);
52745 num29 += (float)Main.rand.Next(-20, 21) * 0.05f;
52746 num30 += (float)Main.rand.Next(-20, 21) * 0.05f;
52752 Main.projectile[
num4].timeLeft = 300;
52754 }
52755 }
52756 }
52757 }
52763 {
52765 }
52766 if (
num6 > Main.maxTilesX)
52767 {
52768 num6 = Main.maxTilesX;
52769 }
52771 {
52773 }
52774 if (
num8 > Main.maxTilesY)
52775 {
52776 num8 = Main.maxTilesY;
52777 }
52778 bool flag2 =
false;
52780 {
52781 Vector2
vector2 =
default(Vector2);
52783 {
52785 {
52786 if (Main.tile[
k,
l] !=
null && ((Main.tile[
k,
l].nactive() && (Main.tileSolid[Main.tile[
k,
l].type] || (Main.tileSolidTop[Main.tile[
k,
l].type] && Main.tile[
k,
l].frameY == 0))) || Main.tile[
k,
l].liquid > 64))
52787 {
52788 vector2.X =
k * 16;
52789 vector2.Y =
l * 16;
52791 {
52793 break;
52794 }
52795 }
52796 }
52797 }
52798 }
52800 {
52801 if (
type != 135 ||
ai[2] != 1
f)
52802 {
52803 Lighting.AddLight((
int)((position.X + (float)(
width / 2)) / 16
f), (int)((
position.Y + (
float)(
height / 2)) / 16
f), 0.3
f, 0.1
f, 0.05
f);
52804 }
52807 {
52808 Rectangle
rectangle =
default(Rectangle);
52813 {
52815 for (
int m = 0;
m < 255;
m++)
52816 {
52817 if (Main.player[
m].active)
52818 {
52821 {
52823 break;
52824 }
52825 }
52826 }
52828 {
52830 }
52831 }
52832 }
52833 }
52834 else
52835 {
52837 }
52839 if (Main.IsItDay() || Main.player[
target].dead)
52840 {
52843 if ((double)position.Y > Main.worldSurface * 16.0)
52844 {
52847 }
52848 if ((double)position.Y > Main.rockLayer * 16.0)
52849 {
52850 for (
int n = 0;
n < 200;
n++)
52851 {
52852 if (Main.npc[
n].aiStyle ==
aiStyle)
52853 {
52854 Main.npc[
n].active =
false;
52855 }
52856 }
52857 }
52858 }
52859 float num11 = 0.1f;
52860 float num13 = 0.15f;
52861 if (Main.getGoodWorld)
52862 {
52865 }
52866 Vector2
vector3 =
default(Vector2);
52868 float num14 = Main.player[
target].position.X + (float)(Main.player[
target].width / 2);
52869 float num15 = Main.player[
target].position.Y + (float)(Main.player[
target].height / 2);
52872 vector3.X = (int)(
vector3.X / 16
f) * 16;
52873 vector3.Y = (int)(
vector3.Y / 16
f) * 16;
52877 if (
ai[1] > 0
f &&
ai[1] < (
float)Main.npc.Length)
52878 {
52880 try
52881 {
52885 }
52886 catch
52887 {
52888 }
52890 {
52893 {
52895 }
52897 {
52899 }
52901 }
52905 {
52907 }
52912 position.X +=
num14;
52913 position.Y +=
num15;
52917 }
52918 else
52919 {
52921 {
52923 velocity.Y += 0.15f;
52925 {
52926 velocity.Y =
num10;
52927 }
52929 {
52931 {
52932 velocity.X -=
num11 * 1.1f;
52933 }
52934 else
52935 {
52936 velocity.X +=
num11 * 1.1f;
52937 }
52938 }
52940 {
52942 {
52943 velocity.X +=
num11;
52944 }
52946 {
52947 velocity.X -=
num11;
52948 }
52949 }
52951 {
52953 {
52954 velocity.X +=
num11 * 0.9f;
52955 }
52956 else
52957 {
52958 velocity.X -=
num11 * 0.9f;
52959 }
52960 }
52961 }
52962 else
52963 {
52965 {
52968 {
52970 }
52972 {
52974 }
52977 }
52985 {
52987 {
52988 velocity.X +=
num13;
52989 }
52991 {
52992 velocity.X -=
num13;
52993 }
52995 {
52996 velocity.Y +=
num13;
52997 }
52999 {
53000 velocity.Y -=
num13;
53001 }
53002 }
53004 {
53006 {
53007 velocity.X +=
num11;
53008 }
53010 {
53011 velocity.X -=
num11;
53012 }
53014 {
53015 velocity.Y +=
num11;
53016 }
53018 {
53019 velocity.Y -=
num11;
53020 }
53022 {
53024 {
53025 velocity.Y +=
num11 * 2
f;
53026 }
53027 else
53028 {
53029 velocity.Y -=
num11 * 2
f;
53030 }
53031 }
53033 {
53035 {
53036 velocity.X +=
num11 * 2
f;
53037 }
53038 else
53039 {
53040 velocity.X -=
num11 * 2
f;
53041 }
53042 }
53043 }
53045 {
53047 {
53048 velocity.X +=
num11 * 1.1f;
53049 }
53051 {
53052 velocity.X -=
num11 * 1.1f;
53053 }
53055 {
53057 {
53058 velocity.Y +=
num11;
53059 }
53060 else
53061 {
53062 velocity.Y -=
num11;
53063 }
53064 }
53065 }
53066 else
53067 {
53069 {
53070 velocity.Y +=
num11 * 1.1f;
53071 }
53073 {
53074 velocity.Y -=
num11 * 1.1f;
53075 }
53077 {
53079 {
53080 velocity.X +=
num11;
53081 }
53082 else
53083 {
53084 velocity.X -=
num11;
53085 }
53086 }
53087 }
53088 }
53091 {
53093 {
53095 {
53097 }
53099 }
53100 else
53101 {
53103 {
53105 }
53107 }
53109 {
53111 }
53112 }
53113 }
53115 {
53118 Vector2
vector4 =
default(Vector2);
53121 float num24 = nPC.velocity.X * 0.025f;
53127 }
53128 }
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 ...
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Vector2 position
The position of this Entity in world coordinates.
int width
The width of this Entity's hitbox, in pixels.
int height
The height of this Entity's hitbox, in pixels.
static int GetDestroyerSegmentsCount()
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
void TargetClosest(bool faceTarget=true)
int aiStyle
Selects which vanilla code to use for the AI method. Vanilla NPC AI styles are enumerated in the T:Te...
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
static bool IsMechQueenUp
float scale
Makes the NPC bigger or smaller. Bigger than 1f is bigger. Defaults to 1f.
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
int alpha
0 is opaque, and 255 is transparent. Note that this is the opposite of how alpha is typically express...
IEntitySource GetSpawnSourceForNPCFromNPCAI()
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
IEntitySource GetSpawnSource_ForProjectile()
int realLife
Stores the index (the F:Terraria.Entity.whoAmI) of a single NPC. This NPC will then share a health po...
void HitEffect(int hitDirection=0, double dmg=10.0, bool? instantKill=null)