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

◆ QuickGrapple()

void Terraria.Player.QuickGrapple ( )
inline

Definition at line 5170 of file Player.cs.

5171 {
5172 if (frozen || tongued || webbed || stoned || dead)
5173 {
5174 return;
5175 }
5177 {
5178 if (Main.HoveringOverAnNPC || Main.SmartInteractShowingGenuine || Main.SmartInteractShowingFake || (_quickGrappleCooldown > 0 && !Main.mapFullscreen) || (WiresUI.Settings.DrawToolModeUI && PlayerInput.UsingGamepad))
5179 {
5180 return;
5181 }
5182 bool num = controlUseTile;
5183 bool flag = releaseUseTile;
5184 if (!num && !flag)
5185 {
5186 return;
5187 }
5188 Tile tileSafely = Framing.GetTileSafely(tileTargetX, tileTargetY);
5189 if ((tileSafely.active() && (tileSafely.type == 4 || tileSafely.type == 33 || tileSafely.type == 372 || tileSafely.type == 174 || tileSafely.type == 646 || tileSafely.type == 49)) || (inventory[selectedItem].type == 3384 && PlayerInput.UsingGamepad))
5190 {
5191 return;
5192 }
5193 }
5194 if (noItems)
5195 {
5196 return;
5197 }
5198 if (mount.Active)
5199 {
5200 mount.Dismount(this);
5201 }
5203 if (item == null || !ItemCheck_CheckCanUse(item))
5204 {
5205 return;
5206 }
5207 if (item.shoot == 73)
5208 {
5209 int num2 = 0;
5210 for (int i = 0; i < 1000; i++)
5211 {
5212 if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && (Main.projectile[i].type == 73 || Main.projectile[i].type == 74))
5213 {
5214 num2++;
5215 }
5216 }
5217 if (num2 > 1)
5218 {
5219 item = null;
5220 }
5221 }
5222 else if (item.shoot == 165)
5223 {
5224 int num3 = 0;
5225 for (int j = 0; j < 1000; j++)
5226 {
5227 if (Main.projectile[j].active && Main.projectile[j].owner == Main.myPlayer && Main.projectile[j].type == 165)
5228 {
5229 num3++;
5230 }
5231 }
5232 if (num3 > 8)
5233 {
5234 item = null;
5235 }
5236 }
5237 else if (item.shoot == 372)
5238 {
5239 int num4 = 0;
5240 for (int k = 0; k < 1000; k++)
5241 {
5242 if (Main.projectile[k].active && Main.projectile[k].owner == Main.myPlayer && Main.projectile[k].type == 372)
5243 {
5244 num4++;
5245 }
5246 }
5247 if (num4 > 2)
5248 {
5249 item = null;
5250 }
5251 }
5252 else if (item.shoot == 652)
5253 {
5254 int num5 = 0;
5255 for (int l = 0; l < 1000; l++)
5256 {
5257 if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == 652)
5258 {
5259 num5++;
5260 }
5261 }
5262 if (num5 > 1)
5263 {
5264 item = null;
5265 }
5266 }
5267 else if (item.type == 3572)
5268 {
5269 int num6 = 0;
5270 bool flag2 = false;
5271 for (int m = 0; m < 1000; m++)
5272 {
5273 if (Main.projectile[m].active && Main.projectile[m].owner == Main.myPlayer && Main.projectile[m].type >= 646 && Main.projectile[m].type <= 649)
5274 {
5275 num6++;
5276 if (Main.projectile[m].ai[0] == 2f)
5277 {
5278 flag2 = true;
5279 }
5280 }
5281 }
5282 if (num6 > 4 || (!flag2 && num6 > 3))
5283 {
5284 item = null;
5285 }
5286 }
5287 else
5288 {
5289 for (int n = 0; n < 1000; n++)
5290 {
5291 if (Main.projectile[n].active && Main.projectile[n].owner == Main.myPlayer && Main.projectile[n].type == item.shoot && Main.projectile[n].ai[0] != 2f)
5292 {
5293 item = null;
5294 break;
5295 }
5296 }
5297 }
5298 if (item == null)
5299 {
5300 return;
5301 }
5304 if (Main.netMode == 1 && whoAmI == Main.myPlayer)
5305 {
5306 NetMessage.SendData(51, -1, -1, null, whoAmI, 2f);
5307 }
5308 int num7 = item.shoot;
5309 float shootSpeed = item.shootSpeed;
5310 int damage = item.damage;
5311 float knockBack = item.knockBack;
5312 if (num7 == 13 || num7 == 32 || num7 == 315 || (num7 >= 230 && num7 <= 235) || num7 == 331 || num7 == 753 || num7 == 865 || num7 == 935)
5313 {
5314 grappling[0] = -1;
5315 grapCount = 0;
5316 for (int num8 = 0; num8 < 1000; num8++)
5317 {
5318 if (Main.projectile[num8].active && Main.projectile[num8].owner == whoAmI)
5319 {
5320 switch (Main.projectile[num8].type)
5321 {
5322 case 13:
5323 case 230:
5324 case 231:
5325 case 232:
5326 case 233:
5327 case 234:
5328 case 235:
5329 case 315:
5330 case 331:
5331 case 753:
5332 case 865:
5333 case 935:
5334 Main.projectile[num8].Kill();
5335 break;
5336 }
5337 }
5338 }
5339 }
5340 if (num7 == 256)
5341 {
5342 int num9 = 0;
5343 int num10 = -1;
5344 int num11 = 100000;
5345 for (int num12 = 0; num12 < 1000; num12++)
5346 {
5347 if (Main.projectile[num12].active && Main.projectile[num12].owner == whoAmI && Main.projectile[num12].type == 256)
5348 {
5349 num9++;
5350 if (Main.projectile[num12].timeLeft < num11)
5351 {
5352 num10 = num12;
5353 num11 = Main.projectile[num12].timeLeft;
5354 }
5355 }
5356 }
5357 if (num9 > 1)
5358 {
5359 Main.projectile[num10].Kill();
5360 }
5361 }
5362 if (num7 == 652)
5363 {
5364 int num13 = 0;
5365 int num14 = -1;
5366 int num15 = 100000;
5367 for (int num16 = 0; num16 < 1000; num16++)
5368 {
5369 if (Main.projectile[num16].active && Main.projectile[num16].owner == whoAmI && Main.projectile[num16].type == 652)
5370 {
5371 num13++;
5372 if (Main.projectile[num16].timeLeft < num15)
5373 {
5374 num14 = num16;
5375 num15 = Main.projectile[num16].timeLeft;
5376 }
5377 }
5378 }
5379 if (num13 > 1)
5380 {
5381 Main.projectile[num14].Kill();
5382 }
5383 }
5384 if (num7 == 73)
5385 {
5386 for (int num17 = 0; num17 < 1000; num17++)
5387 {
5388 if (Main.projectile[num17].active && Main.projectile[num17].owner == whoAmI && Main.projectile[num17].type == 73)
5389 {
5390 num7 = 74;
5391 }
5392 }
5393 }
5394 if (item.type == 3572)
5395 {
5396 int num18 = -1;
5397 int num19 = -1;
5398 for (int num20 = 0; num20 < 1000; num20++)
5399 {
5400 Projectile projectile = Main.projectile[num20];
5401 if (projectile.active && projectile.owner == whoAmI && projectile.type >= 646 && projectile.type <= 649 && (num19 == -1 || num19 < projectile.timeLeft))
5402 {
5403 num18 = projectile.type;
5404 num19 = projectile.timeLeft;
5405 }
5406 }
5407 switch (num18)
5408 {
5409 case 646:
5410 num7 = 647;
5411 break;
5412 case 647:
5413 num7 = 648;
5414 break;
5415 case 648:
5416 num7 = 649;
5417 break;
5418 case -1:
5419 case 649:
5420 num7 = 646;
5421 break;
5422 }
5423 }
5424 Vector2 vector = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
5425 float num21 = (float)Main.mouseX + Main.screenPosition.X - vector.X;
5426 float num22 = (float)Main.mouseY + Main.screenPosition.Y - vector.Y;
5427 if (gravDir == -1f)
5428 {
5429 num22 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector.Y;
5430 }
5431 float num23 = (float)Math.Sqrt(num21 * num21 + num22 * num22);
5432 if ((float.IsNaN(num21) && float.IsNaN(num22)) || (num21 == 0f && num22 == 0f))
5433 {
5434 num21 = direction;
5435 num22 = 0f;
5436 num23 = shootSpeed;
5437 }
5438 else
5439 {
5440 num23 = shootSpeed / num23;
5441 }
5442 num21 *= num23;
5443 num22 *= num23;
5444 Projectile.NewProjectile(GetProjectileSource_Item(item), vector.X, vector.Y, num21, num22, num7, damage, knockBack, whoAmI);
5445 }
static double Sqrt(double d)
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 position
Definition Entity.cs:14
void Dismount(Player mountedPlayer)
Definition Mount.cs:5229
bool Active
Definition Mount.cs:345
int _quickGrappleCooldown
Definition Player.cs:2657
Item QuickGrapple_GetItemToUse()
Definition Player.cs:5447
bool releaseUseTile
Definition Player.cs:1415
bool ItemCheck_CheckCanUse(Item sItem)
Definition Player.cs:48702
static int tileTargetY
Definition Player.cs:2085
IEntitySource GetProjectileSource_Item(Item item)
Definition Player.cs:9272
int[] grappling
Definition Player.cs:2305
static int tileTargetX
Definition Player.cs:2083
void UpdateBlacklistedTilesForGrappling()
Definition Player.cs:5147
Item[] inventory
Definition Player.cs:1257
bool controlUseTile
Definition Player.cs:1393

References Terraria.Player._quickGrappleCooldown, Terraria.Entity.active, Terraria.Mount.Active, Terraria.Player.controlUseTile, Terraria.Player.dead, Terraria.Entity.direction, Terraria.Mount.Dismount(), Terraria.GameContent.UI.WiresUI.Settings.DrawToolModeUI, Terraria.Player.frozen, Terraria.Player.GetProjectileSource_Item(), Terraria.Framing.GetTileSafely(), Terraria.Player.grapCount, Terraria.GameInput.PlayerInput.GrappleAndInteractAreShared, Terraria.Player.grappling, Terraria.Player.gravDir, Terraria.Entity.height, Terraria.Main.HoveringOverAnNPC, Terraria.Player.inventory, System.item, Terraria.Player.ItemCheck_CheckCanUse(), Terraria.Main.mapFullscreen, Terraria.Player.mount, Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Projectile.NewProjectile(), Terraria.Player.noItems, Terraria.Projectile.owner, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.projectile, Terraria.Player.QuickGrapple_GetItemToUse(), Terraria.Player.releaseUseTile, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Player.selectedItem, Terraria.NetMessage.SendData(), Terraria.Main.SmartInteractShowingFake, Terraria.Main.SmartInteractShowingGenuine, System.Math.Sqrt(), Terraria.Player.stoned, Terraria.Player.tileTargetX, Terraria.Player.tileTargetY, Terraria.Projectile.timeLeft, Terraria.Player.tongued, Terraria.Item.type, Terraria.Projectile.type, Terraria.Player.UpdateBlacklistedTilesForGrappling(), Terraria.GameInput.PlayerInput.UsingGamepad, Terraria.Player.webbed, Terraria.Entity.whoAmI, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.