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

◆ TorchAttack()

void Terraria.Player.TorchAttack ( )
inlineprivate

Definition at line 16277 of file Player.cs.

16278 {
16279 //IL_0063: Unknown result type (might be due to invalid IL or missing references)
16280 //IL_0074: Unknown result type (might be due to invalid IL or missing references)
16281 //IL_0086: Unknown result type (might be due to invalid IL or missing references)
16282 //IL_0098: Unknown result type (might be due to invalid IL or missing references)
16283 //IL_0350: Unknown result type (might be due to invalid IL or missing references)
16284 //IL_0355: Unknown result type (might be due to invalid IL or missing references)
16285 //IL_0357: Unknown result type (might be due to invalid IL or missing references)
16286 //IL_035c: Unknown result type (might be due to invalid IL or missing references)
16287 //IL_036e: Unknown result type (might be due to invalid IL or missing references)
16288 //IL_0372: Unknown result type (might be due to invalid IL or missing references)
16289 //IL_0377: Unknown result type (might be due to invalid IL or missing references)
16290 //IL_0381: Unknown result type (might be due to invalid IL or missing references)
16291 //IL_0383: Unknown result type (might be due to invalid IL or missing references)
16292 if (whoAmI != Main.myPlayer)
16293 {
16294 return;
16295 }
16296 if ((double)position.Y < Main.worldSurface * 16.0)
16297 {
16299 return;
16300 }
16301 AddBuff(80, 2);
16302 torchFunTimer++;
16303 if (torchFunTimer <= 20)
16304 {
16305 return;
16306 }
16307 torchFunTimer = 0;
16308 int num = 0;
16309 int num4 = 100;
16310 int value5 = (int)base.Center.X / 16 - num4;
16311 int value2 = (int)base.Center.X / 16 + num4;
16312 int value3 = (int)base.Center.Y / 16 - num4;
16313 int value4 = (int)base.Center.Y / 16 + num4;
16314 int num11 = Utils.Clamp(value5, 10, Main.maxTilesX - 10);
16315 value2 = Utils.Clamp(value2, 10, Main.maxTilesX - 10);
16316 value3 = Utils.Clamp(value3, 10, Main.maxTilesY - 10);
16317 value4 = Utils.Clamp(value4, 10, Main.maxTilesY - 10);
16318 for (int i = num11; i <= value2; i++)
16319 {
16320 for (int j = value3; j <= value4; j++)
16321 {
16322 Tile tile = Main.tile[i, j];
16323 if (tile != null && (tile.active() & (tile.type == 4)) && tile.frameX < 66)
16324 {
16325 _torchAttackPosX[num] = i;
16327 num++;
16328 if (num >= _torchAttackPosX.Length)
16329 {
16330 break;
16331 }
16332 }
16333 }
16334 if (num >= _torchAttackPosX.Length)
16335 {
16336 break;
16337 }
16338 }
16340 {
16342 happyFunTorchTime = false;
16343 if (Main.netMode == 1)
16344 {
16345 NetMessage.SendData(4, -1, -1, null, whoAmI);
16346 }
16347 if (numberOfTorchAttacksMade >= 95)
16348 {
16349 int number = Item.NewItem(GetItemSource_Misc(6), (int)position.X, (int)position.Y, width, height, 5043);
16350 if (Main.netMode == 1)
16351 {
16352 NetMessage.SendData(21, -1, -1, null, number, 1f);
16353 }
16354 }
16355 }
16356 else
16357 {
16358 if (num <= 0)
16359 {
16360 return;
16361 }
16362 int num5 = Main.rand.Next(num);
16363 int num6 = _torchAttackPosX[num5];
16364 int num7 = _torchAttackPosY[num5];
16365 Tile tile2 = Main.tile[num6, num7];
16366 if (tile2.type != 4)
16367 {
16368 return;
16369 }
16370 tile2 = Main.tile[num6, num7];
16371 if (tile2.frameX < 66)
16372 {
16373 float num8 = 8f;
16374 int num9 = 20;
16375 if (num9 < 10)
16376 {
16377 num9 = 10;
16378 }
16379 tile2 = Main.tile[num6, num7];
16380 int num10 = (int)MathHelper.Clamp((float)(tile2.frameY / 22), 0f, (float)(TorchID.Count - 1));
16382 tile2 = Main.tile[num6, num7];
16383 tile2.frameX += 66;
16387 NetMessage.SendTileSquare(-1, num6, num7);
16388 Vector2 vector = default(Vector2);
16389 ((Vector2)(ref vector))._002Ector((float)(num6 * 16 + 8), (float)(num7 * 16));
16390 Vector2 vector2 = base.Center - vector;
16391 float num2 = ((Vector2)(ref vector2)).Length();
16392 ((Vector2)(ref vector2)).Normalize();
16393 vector2 *= num8;
16394 int num3 = Projectile.NewProjectile(GetProjectileSource_Misc(10), vector, vector2, 949, num9, 1f, whoAmI, num10, num2);
16395 Main.projectile[num3].ai[0] = num10;
16396 Main.projectile[num3].ai[1] = num2;
16397 Main.projectile[num3].netUpdate = true;
16399 {
16400 torchFunTimer = -180;
16401 }
16402 }
16403 }
16404 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static int[] Dust
Definition TorchID.cs:75
int[] unlitTorchY
Definition Player.cs:3197
static int[] _torchAttackPosX
Definition Player.cs:3199
static int[] _torchAttackPosY
Definition Player.cs:3201
int[] unlitTorchX
Definition Player.cs:3195
bool happyFunTorchTime
Definition Player.cs:3185
void RelightTorches()
Definition Player.cs:16256
void EndOngoingTorchGodEvent()
Definition Player.cs:16160
IEntitySource GetProjectileSource_Misc(int projectileSourceId)
Definition Player.cs:7871
int numberOfTorchAttacksMade
Definition Player.cs:3191
IEntitySource GetItemSource_Misc(int itemSourceId)
Definition Player.cs:7846
void AddBuff(int type, int timeToAdd, bool quiet=true, bool foodHack=false)
Gives the player the provided buff. This accounts for if the player is immune to the buff....
Definition Player.cs:5700
static int maxTorchAttacks
Definition Player.cs:3193

References Terraria.Player._torchAttackPosX, Terraria.Player._torchAttackPosY, Terraria.Tile.active(), Terraria.Player.AddBuff(), Terraria.ID.TorchID.Dust, Terraria.Player.EndOngoingTorchGodEvent(), Terraria.Tile.frameX, Terraria.Player.GetItemSource_Misc(), Terraria.Player.GetProjectileSource_Misc(), Terraria.Player.happyFunTorchTime, Terraria.Entity.height, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Player.maxTorchAttacks, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.Projectile.NewProjectile(), Terraria.Player.numberOfTorchAttacksMade, Terraria.Entity.position, Terraria.Main.projectile, Terraria.Main.rand, Terraria.Player.RelightTorches(), Terraria.NetMessage.SendData(), Terraria.NetMessage.SendTileSquare(), Terraria.Main.tile, Terraria.Player.torchFunTimer, Terraria.Tile.type, Terraria.Player.unlitTorchX, Terraria.Player.unlitTorchY, Terraria.Entity.whoAmI, Terraria.Entity.width, and Terraria.Main.worldSurface.

Referenced by Terraria.Player.TryRecalculatingTorchLuck().

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