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

◆ AI_067_TigerSpecialAttack()

bool Terraria.Projectile.AI_067_TigerSpecialAttack ( )
inlineprivate

Definition at line 40340 of file Projectile.cs.

40341 {
40342 List<NPC> list = new List<NPC>();
40343 Vector2 center = Main.player[owner].Center;
40344 Rectangle value = Utils.CenteredRectangle(center, new Vector2(1600f, 800f));
40345 int num = Main.player[owner].ownedProjectileCounts[831] + 1;
40346 for (int i = 0; i < 200; i++)
40347 {
40348 NPC nPC = Main.npc[i];
40349 if (nPC.CanBeChasedBy(this) && nPC.Hitbox.Intersects(value))
40350 {
40351 list.Add(nPC);
40352 }
40353 }
40354 if (list.Count == 0)
40355 {
40356 return false;
40357 }
40358 NPC nPC2 = list[0];
40359 for (int j = 1; j < list.Count; j++)
40360 {
40361 if (Vector2.Distance(nPC2.Center, center) > Vector2.Distance(list[j].Center, center))
40362 {
40363 nPC2 = list[j];
40364 }
40365 }
40366 list.Remove(nPC2);
40367 NPC nPC3 = null;
40368 if (list.Count > 0)
40369 {
40370 nPC3 = list[0];
40371 for (int k = 1; k < list.Count; k++)
40372 {
40373 if (Distance(nPC3.Center) > Distance(list[k].Center))
40374 {
40375 nPC3 = list[k];
40376 }
40377 }
40378 list.Remove(nPC3);
40379 }
40381 if (nPC3 != null)
40382 {
40383 list2.Add(nPC3.Center);
40384 }
40385 int num2 = 0;
40386 while (list.Count > 0 && list2.Count < num - 1)
40387 {
40388 int index = Main.rand.Next(list.Count);
40389 Vector2 vector = list[index].velocity * 4f * (num2 + 1);
40391 list.RemoveAt(index);
40392 num2++;
40393 }
40394 if (nPC2 != null)
40395 {
40396 list2.Add(nPC2.Center);
40397 }
40398 if (list2.Count > 0 && Collision.SolidCollision(list2[list2.Count - 1] - base.Size / 2f, width, height))
40399 {
40400 list2.Add(center);
40401 }
40402 Vector2 vector2 = base.Center;
40403 float num3 = Math.Min(20, 30 / list2.Count);
40404 float num4 = 0f;
40405 for (int l = 0; l < list2.Count; l++)
40406 {
40407 float num5 = 20f;
40409 vector3.X += ((vector2.X < vector3.X) ? num5 : (0f - num5));
40411 int num6 = (int)Math.Min(num3, 4.0 + Math.Ceiling(vector4.Length() / 50f));
40412 if (num6 < 5)
40413 {
40414 num6 = 5;
40415 }
40417 vector2 = vector3;
40418 num4 += (float)num6;
40419 }
40420 base.Center = vector2;
40421 ai[0] = 4f;
40422 ai[1] = num4;
40423 netUpdate = true;
40424 return true;
40425 }
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Ceiling(double a)
Vector2 Center
Definition Entity.cs:43
float Distance(Vector2 Other)
Definition Entity.cs:187
IEntitySource GetProjectileSource_FromThis()
static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Math.Ceiling(), Terraria.Utils.CenteredRectangle(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, Microsoft.Xna.Framework.Vector2.Distance(), System.index, System.list, System.Math.Min(), Terraria.Main.npc, Terraria.Main.player, Terraria.Main.rand, System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), Terraria.Collision.SolidCollision(), and System.value.