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

◆ AI_113_WindyBalloon()

void Terraria.NPC.AI_113_WindyBalloon ( )
inlineprivate

Definition at line 50061 of file NPC.cs.

50062 {
50063 //IL_0142: Unknown result type (might be due to invalid IL or missing references)
50064 //IL_0147: Unknown result type (might be due to invalid IL or missing references)
50065 //IL_0157: Unknown result type (might be due to invalid IL or missing references)
50066 //IL_0164: Unknown result type (might be due to invalid IL or missing references)
50067 //IL_017e: Unknown result type (might be due to invalid IL or missing references)
50068 //IL_01be: Unknown result type (might be due to invalid IL or missing references)
50069 //IL_01c3: Unknown result type (might be due to invalid IL or missing references)
50070 //IL_087b: Unknown result type (might be due to invalid IL or missing references)
50071 //IL_01d0: Unknown result type (might be due to invalid IL or missing references)
50072 //IL_01d6: Unknown result type (might be due to invalid IL or missing references)
50073 //IL_01db: Unknown result type (might be due to invalid IL or missing references)
50074 //IL_01e0: Unknown result type (might be due to invalid IL or missing references)
50075 //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
50076 //IL_02ed: Unknown result type (might be due to invalid IL or missing references)
50077 //IL_020c: Unknown result type (might be due to invalid IL or missing references)
50078 //IL_01f0: Unknown result type (might be due to invalid IL or missing references)
50079 //IL_052f: Unknown result type (might be due to invalid IL or missing references)
50080 //IL_054c: Unknown result type (might be due to invalid IL or missing references)
50081 //IL_058c: Unknown result type (might be due to invalid IL or missing references)
50082 //IL_061f: Unknown result type (might be due to invalid IL or missing references)
50083 //IL_073d: Unknown result type (might be due to invalid IL or missing references)
50084 //IL_074c: Unknown result type (might be due to invalid IL or missing references)
50085 //IL_0751: Unknown result type (might be due to invalid IL or missing references)
50086 //IL_0769: Unknown result type (might be due to invalid IL or missing references)
50087 //IL_076e: Unknown result type (might be due to invalid IL or missing references)
50088 //IL_077a: Unknown result type (might be due to invalid IL or missing references)
50089 //IL_077f: Unknown result type (might be due to invalid IL or missing references)
50090 if (localAI[0] == 0f && Main.netMode != 1)
50091 {
50092 TargetClosest();
50093 localAI[0] = 1f;
50094 ai[2] = Main.rand.Next(7) + 1;
50095 int num = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)position.X, (int)position.Y, 1);
50096 if (Main.rand.Next(180) == 0)
50097 {
50098 Main.npc[num].SetDefaults(-4);
50099 }
50100 else if (Main.rand.Next(10) == 0)
50101 {
50102 Main.npc[num].SetDefaults(-7);
50103 }
50104 else if (Main.rand.Next(3) == 0)
50105 {
50106 Main.npc[num].SetDefaults(-3);
50107 }
50108 Main.npc[num].ai[0] = -999f;
50109 Main.npc[num].netUpdate = true;
50110 ai[3] = num;
50111 netUpdate = true;
50112 ai[1] = Main.npc[num].scale;
50113 }
50114 position = base.Center;
50115 base.Size = new Vector2(20f, 20f) * ai[1];
50116 scale = ai[1];
50117 base.Center = position;
50119 rotation = velocity.X * 0.05f;
50120 if (nPC != null)
50121 {
50123 float num4 = float.PositiveInfinity;
50124 int num5 = 0;
50125 Vector2 zero = Vector2.Zero;
50126 if (!targetData.Invalid)
50127 {
50128 zero = targetData.Center - base.Bottom;
50129 if (zero.Y < 0f)
50130 {
50131 num5 = (int)zero.Y / -16;
50132 }
50133 num4 = ((Vector2)(ref zero)).Length();
50134 if (direction != Math.Sign(zero.X))
50135 {
50136 num5 = 0;
50137 }
50138 }
50139 if (wet || nPC.wet || collideX || (collideY && oldVelocity.Y < 0f))
50140 {
50141 float num6 = oldVelocity.X + (float)(direction * 8);
50142 position.X -= num6;
50143 nPC.position.X -= num6;
50145 direction *= -1;
50146 velocity.X = direction * 2;
50147 life = -1;
50148 HitEffect();
50149 active = false;
50150 netUpdate = true;
50152 return;
50153 }
50154 if (collideY)
50155 {
50156 velocity.Y = ((oldVelocity.Y > 0f) ? 1 : (-1));
50158 }
50159 float num7 = 2f + Math.Abs(Main.windSpeedTarget) * 2f;
50160 if (Math.Sign(velocity.X) != direction || Math.Abs(velocity.X) < num7)
50161 {
50162 velocity.X += (float)direction * 0.01f;
50163 if (velocity.X * (float)direction < 0f)
50164 {
50165 if (Math.Abs(velocity.X) > num7)
50166 {
50167 velocity.X += (float)direction * 0.1f;
50168 }
50169 else
50170 {
50171 velocity.X += (float)direction * 0.05f;
50172 }
50173 }
50174 else if (Math.Abs(velocity.X) > num7)
50175 {
50176 velocity.X = (float)direction * num7;
50177 }
50178 }
50179 int num8 = (int)((position.X + (float)(width / 2)) / 16f) + direction;
50180 int num9 = (int)((position.Y + (float)height) / 16f);
50181 bool flag = true;
50182 int num10 = 8 + num5;
50183 bool flag2 = false;
50184 for (int i = num9; i < num9 + num10; i++)
50185 {
50186 if (Main.tile[num8, i] == null)
50187 {
50188 Main.tile[num8, i] = default(Tile);
50189 }
50190 if ((Main.tile[num8, i].nactive() && Main.tileSolid[Main.tile[num8, i].type]) || Main.tile[num8, i].liquid > 0)
50191 {
50192 if (i < num9 + 5 + num5)
50193 {
50194 flag2 = true;
50195 }
50196 flag = false;
50197 break;
50198 }
50199 }
50200 if (num4 < 400f && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
50201 {
50202 float num11 = 2f;
50203 float num2 = 0.035f;
50204 if (base.Center.Y + (float)(height / 4) > Main.player[target].position.Y + (float)(Main.player[target].height / 4) && velocity.Y > 0f - num11)
50205 {
50206 velocity.Y -= num2;
50207 if (velocity.Y > 0f)
50208 {
50209 velocity.Y -= num2;
50210 }
50211 }
50212 else if (base.Center.Y + (float)(height / 4) < Main.player[target].position.Y + (float)(Main.player[target].height / 4) && velocity.Y < num11)
50213 {
50214 velocity.Y += num2;
50215 if (velocity.Y < 0f)
50216 {
50217 velocity.Y += num2;
50218 }
50219 }
50220 }
50221 else
50222 {
50223 if (flag)
50224 {
50225 velocity.Y += 0.05f;
50226 }
50227 else
50228 {
50229 velocity.Y -= 0.1f;
50230 }
50231 if (flag2)
50232 {
50233 velocity.Y -= 0.2f;
50234 }
50235 if (velocity.Y > 2f)
50236 {
50237 velocity.Y = 2f;
50238 }
50239 if (velocity.Y < -4f)
50240 {
50241 velocity.Y = -4f;
50242 }
50243 }
50244 nPC.Center = base.Bottom + new Vector2(0f, -8f) + new Vector2(0f, 56f * ai[1]);
50245 nPC.velocity = velocity;
50246 }
50247 else
50248 {
50249 velocity.Y = MathHelper.Clamp(velocity.Y - 0.2f, -8f, 8f);
50250 velocity.X = MathHelper.Clamp(velocity.X + Main.windSpeedTarget * 0.3f, -4f, 4f);
50251 if (collideX || collideY)
50252 {
50253 float num3 = oldVelocity.X + (float)(direction * 8);
50254 position.X -= num3;
50256 direction *= -1;
50257 velocity.X = direction * 2;
50258 life = -1;
50259 HitEffect();
50260 active = false;
50261 netUpdate = true;
50263 }
50264 }
50265 }
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 ...
bool wet
The Entity is currently in water. Projectile: Affects movement speed and some projectiles die when ...
Definition Entity.cs:57
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
Vector2 oldVelocity
Definition Entity.cs:37
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
Definition NPC.cs:1003
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:83247
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:1668
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
float scale
Makes the NPC bigger or smaller. Bigger than 1f is bigger. Defaults to 1f.
Definition NPC.cs:1104
bool collideX
Definition NPC.cs:1134
bool collideY
Definition NPC.cs:1136
float rotation
Definition NPC.cs:1116
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:107568
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...
Definition NPC.cs:91239
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
Definition NPC.cs:1072
SoundStyle? DeathSound
The sound that plays when this npc dies. Set this to an existing T:Terraria.ID.SoundID entry or assig...
Definition NPC.cs:1067
NPC AI_113_WindyBalloon_GetSlaveNPC()
Definition NPC.cs:50267
bool netUpdate
Definition NPC.cs:1130
int target
Definition NPC.cs:1019
void HitEffect(int hitDirection=0, double dmg=10.0, bool? instantKill=null)
Definition NPC.cs:92191

References Terraria.Entity.active, Terraria.NPC.ai, Terraria.NPC.AI_113_WindyBalloon_GetSlaveNPC(), Terraria.Collision.CanHit(), Terraria.NPC.collideX, Terraria.NPC.collideY, Terraria.NPC.DeathSound, Terraria.Entity.direction, Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.NPC.HitEffect(), Terraria.NPC.life, Terraria.NPC.localAI, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.NPC.NewNPC(), Terraria.Main.npc, Terraria.Entity.oldVelocity, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.NPC.rotation, Terraria.NPC.scale, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Entity.width, and Terraria.Main.windSpeedTarget.

Referenced by Terraria.NPC.VanillaAI_Inner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: