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

◆ Hurt() [1/4]

void Terraria.Player.Hurt ( HurtInfo info,
bool quiet = false )
inline

Definition at line 37317 of file Player.cs.

37318 {
37319 //IL_00ec: Unknown result type (might be due to invalid IL or missing references)
37320 //IL_00e5: Unknown result type (might be due to invalid IL or missing references)
37321 //IL_00f1: Unknown result type (might be due to invalid IL or missing references)
37322 //IL_0117: Unknown result type (might be due to invalid IL or missing references)
37323 //IL_011c: Unknown result type (might be due to invalid IL or missing references)
37324 //IL_0312: Unknown result type (might be due to invalid IL or missing references)
37325 //IL_0331: Unknown result type (might be due to invalid IL or missing references)
37326 //IL_06ec: Unknown result type (might be due to invalid IL or missing references)
37327 //IL_07f8: Unknown result type (might be due to invalid IL or missing references)
37328 //IL_0825: Unknown result type (might be due to invalid IL or missing references)
37329 //IL_082b: Unknown result type (might be due to invalid IL or missing references)
37330 //IL_0846: Unknown result type (might be due to invalid IL or missing references)
37331 //IL_0877: Unknown result type (might be due to invalid IL or missing references)
37332 //IL_087d: Unknown result type (might be due to invalid IL or missing references)
37333 //IL_091a: Unknown result type (might be due to invalid IL or missing references)
37334 //IL_0947: Unknown result type (might be due to invalid IL or missing references)
37335 //IL_094d: Unknown result type (might be due to invalid IL or missing references)
37336 //IL_08b7: Unknown result type (might be due to invalid IL or missing references)
37337 //IL_08e5: Unknown result type (might be due to invalid IL or missing references)
37338 //IL_08eb: Unknown result type (might be due to invalid IL or missing references)
37339 //IL_077e: Unknown result type (might be due to invalid IL or missing references)
37340 //IL_075d: Unknown result type (might be due to invalid IL or missing references)
37341 PlayerDeathReason damageSource = info.DamageSource;
37342 int hitDirection = info.HitDirection;
37343 int cooldownCounter = info.CooldownCounter;
37344 bool pvp = info.PvP;
37345 double num20 = info.Damage;
37346 bool Crit = false;
37347 bool flag2 = cooldownCounter == 2;
37348 if (Main.netMode == 1 && whoAmI == Main.myPlayer && !quiet)
37349 {
37350 if (info.Knockback != 0f && hitDirection != 0 && (!mount.Active || !mount.Cart))
37351 {
37352 NetMessage.SendData(13, -1, -1, null, whoAmI);
37353 }
37354 NetMessage.SendData(16, -1, -1, null, whoAmI);
37355 NetMessage.SendPlayerHurt(whoAmI, info);
37356 }
37357 PlayerLoader.OnHurt(this, info);
37361 Color color = (Crit ? CombatText.DamagedFriendlyCrit : CombatText.DamagedFriendly);
37362 CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, width, height), color, (int)num20, Crit);
37363 statLife -= (int)num20;
37364 switch (cooldownCounter)
37365 {
37366 case -1:
37367 {
37368 immune = true;
37369 int num14 = 0;
37370 num14 = (pvp ? 8 : ((num20 == 1.0) ? (longInvince ? 40 : 20) : (longInvince ? 80 : 40)));
37371 immuneTime = num14;
37372 break;
37373 }
37374 case 0:
37375 if (num20 == 1.0)
37376 {
37378 }
37379 else
37380 {
37382 }
37383 break;
37384 case 1:
37385 case 3:
37386 case 4:
37387 if (num20 == 1.0)
37388 {
37390 }
37391 else
37392 {
37394 }
37395 break;
37396 }
37397 lifeRegenTime = 0f;
37398 int? sourceProjectileType = damageSource.SourceProjectileType;
37400 {
37401 mount.Dismount(this);
37402 }
37403 if (whoAmI == Main.myPlayer)
37404 {
37405 if (starCloakItem != null && !starCloakItem.IsAir && (cooldownCounter == -1 || cooldownCounter == 1))
37406 {
37407 Vector2 vector = default(Vector2);
37408 for (int num15 = 0; num15 < 3; num15++)
37409 {
37410 float x = position.X + (float)Main.rand.Next(-400, 400);
37411 float y = position.Y - (float)Main.rand.Next(500, 800);
37412 ((Vector2)(ref vector))._002Ector(x, y);
37413 float num16 = position.X + (float)(width / 2) - vector.X;
37414 float num17 = position.Y + (float)(height / 2) - vector.Y;
37415 num16 += (float)Main.rand.Next(-100, 101);
37416 float num18 = (float)Math.Sqrt(num16 * num16 + num17 * num17);
37417 num18 = 23f / num18;
37418 num16 *= num18;
37419 num17 *= num18;
37420 int type = 726;
37421 Item item = starCloakItem;
37423 {
37425 type = 725;
37426 }
37428 {
37430 type = 724;
37431 }
37433 {
37435 type = 723;
37436 }
37437 int num19 = 75;
37438 if (Main.masterMode)
37439 {
37440 num19 *= 3;
37441 }
37442 else if (Main.expertMode)
37443 {
37444 num19 *= 2;
37445 }
37446 Projectile.NewProjectile(GetSource_Accessory_OnHurt(item, info.DamageSource), x, y, num16, num17, type, num19, 5f, whoAmI, 0f, position.Y);
37447 }
37448 }
37449 if (honeyCombItem != null && !honeyCombItem.IsAir)
37450 {
37451 int num21 = 1;
37452 if (Main.rand.Next(3) == 0)
37453 {
37454 num21++;
37455 }
37456 if (Main.rand.Next(3) == 0)
37457 {
37458 num21++;
37459 }
37460 if (strongBees && Main.rand.Next(3) == 0)
37461 {
37462 num21++;
37463 }
37464 float num22 = 13f;
37465 if (strongBees)
37466 {
37467 num22 = 18f;
37468 }
37469 if (Main.masterMode)
37470 {
37471 num22 *= 2f;
37472 }
37473 else if (Main.expertMode)
37474 {
37475 num22 *= 1.5f;
37476 }
37478 for (int num23 = 0; num23 < num21; num23++)
37479 {
37480 float speedX = (float)Main.rand.Next(-35, 36) * 0.02f;
37481 float speedY = (float)Main.rand.Next(-35, 36) * 0.02f;
37482 Projectile.NewProjectile(projectileSource_Accessory, position.X, position.Y, speedX, speedY, beeType(), beeDamage((int)num22), beeKB(0f), Main.myPlayer);
37483 }
37484 AddBuff(48, 300);
37485 }
37486 }
37488 if (info.Knockback != 0f && hitDirection != 0 && (!mount.Active || !mount.Cart))
37489 {
37490 velocity.X = info.Knockback * (float)hitDirection;
37491 velocity.Y = info.Knockback * -7f / 9f;
37492 fallStart = (int)(position.Y / 16f);
37493 }
37494 if (!info.SoundDisabled)
37495 {
37496 if (stoned)
37497 {
37498 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
37499 }
37500 else if (mount.Active && mount.Type == 52)
37501 {
37502 SoundEngine.PlaySound(3, (int)position.X, (int)position.Y, 6);
37503 }
37504 else if ((wereWolf || forceWerewolf) && !hideWolf)
37505 {
37506 SoundEngine.PlaySound(3, (int)position.X, (int)position.Y, 6);
37507 }
37508 else if (frostArmor)
37509 {
37511 }
37512 else if (boneArmor)
37513 {
37514 SoundEngine.PlaySound(3, (int)position.X, (int)position.Y, 2);
37515 }
37516 else if (Main.dontStarveWorld && !Main.remixWorld)
37517 {
37518 SoundStyle style = (Male ? SoundID.DSTMaleHurt : SoundID.DSTFemaleHurt);
37520 }
37521 else
37522 {
37524 }
37525 }
37527 if (statLife > 0)
37528 {
37529 if (!info.DustDisabled)
37530 {
37531 double num24 = num20 / (double)statLifeMax2 * 100.0;
37532 float num25 = 2 * hitDirection;
37533 float num26 = 0f;
37534 if (flag2)
37535 {
37536 num24 *= 12.0;
37537 num26 = 6f;
37538 }
37539 for (int num27 = 0; (double)num27 < num24; num27++)
37540 {
37541 if (stoned)
37542 {
37543 Dust.NewDust(position, width, height, 1, num25 + (float)hitDirection * num26 * Main.rand.NextFloat(), -2f);
37544 }
37545 else if (frostArmor)
37546 {
37547 int num28 = Dust.NewDust(position, width, height, 135, num25 + (float)hitDirection * num26 * Main.rand.NextFloat(), -2f);
37548 Main.dust[num28].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
37549 }
37550 else if (boneArmor)
37551 {
37552 int num29 = Dust.NewDust(position, width, height, 26, num25 + (float)hitDirection * num26 * Main.rand.NextFloat(), -2f);
37553 Main.dust[num29].shader = GameShaders.Armor.GetSecondaryShader(ArmorSetDye(), this);
37554 }
37555 else
37556 {
37557 Dust.NewDust(position, width, height, 5, num25 + (float)hitDirection * num26 * Main.rand.NextFloat(), -2f);
37558 }
37559 }
37560 }
37561 PlayerLoader.PostHurt(this, info);
37562 }
37563 else
37564 {
37565 statLife = 0;
37566 if (whoAmI == Main.myPlayer)
37567 {
37569 }
37570 }
37571 }
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....
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 ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static bool[] DismountsPlayersOnHit
If true for a given projectile type (F:Terraria.Projectile.type), then that projectile will forcibly ...
static readonly SoundStyle Item27
Definition SoundID.cs:731
static readonly SoundStyle DSTFemaleHurt
Definition SoundID.cs:259
bool IsAir
Definition Item.cs:965
static void OnHurt(Player player, Player.HurtInfo info)
static void PostHurt(Player player, Player.HurtInfo info)
This is where all ModPlayer hooks are gathered and called.
void Dismount(Player mountedPlayer)
Definition Mount.cs:6357
bool Active
Definition Mount.cs:348
int statLifeMax2
The maximum health this player can have, adjusted by buffs and equipment.
Definition Player.cs:2092
float lifeRegenTime
How effective this player's natural life regeneration should be. Resets whenever the player is hurt,...
Definition Player.cs:2146
bool strongBees
If true, then the bees created by F:Terraria.Player.honeyCombItem have a chance to be stronger.
Definition Player.cs:2193
bool forceWerewolf
Definition Player.cs:2535
int ArmorSetDye()
Definition Player.cs:7809
int statLife
The current health of this player. Capped at F:Terraria.Player.statLifeMax2. If you increase this v...
Definition Player.cs:2102
void OnHurt_Part1(HurtInfo info)
Definition Player.cs:37090
void KillMe(PlayerDeathReason damageSource, double dmg, int hitDirection, bool pvp=false)
Definition Player.cs:37626
Item starCloakItem_beeCloakOverrideItem
Definition Player.cs:2577
void OnHurt_Part3(HurtInfo info)
Definition Player.cs:37269
void OnHurt_Part2(HurtInfo info)
Definition Player.cs:37177
Mount mount
This player's T:Terraria.Mount. Do not overwrite this value. Instead, call M:Terraria....
Definition Player.cs:2323
Item honeyCombItem
If not null, this player will create damaging bee projectiles when taking damage.
Definition Player.cs:2964
float beeKB(float KB)
Definition Player.cs:10439
Item starCloakItem
Definition Player.cs:2571
void StopVanityActions(bool multiplayerBroadcast=true)
Definition Player.cs:31655
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
PlayerEyeHelper eyeHelper
Definition Player.cs:3013
int beeDamage(int dmg)
Definition Player.cs:10430
int[] hurtCooldowns
Definition Player.cs:3259
IEntitySource GetSource_Accessory_OnHurt(Item item, Entity? attacker, string? context=null)
Definition Player.cs:58754
Item starCloakItem_manaCloakOverrideItem
Definition Player.cs:2573
Item starCloakItem_starVeilOverrideItem
Definition Player.cs:2575
This object encapsulates context information about the source of a particular spawning event of an It...
This data type describes in detail how a sound should be played. Passable to the M:Terraria....
Definition SoundStyle.cs:19

References Terraria.Mount.Active, Terraria.Player.AddBuff(), Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Player.ArmorSetDye(), Terraria.Player.beeDamage(), Terraria.Player.beeKB(), Terraria.Player.beeType(), Terraria.GameContent.PlayerEyeHelper.BlinkBecausePlayerGotHurt(), Terraria.Player.boneArmor, Terraria.Mount.Cart, Terraria.CombatText.DamagedFriendly, Terraria.Mount.Dismount(), Terraria.ID.ProjectileID.Sets.DismountsPlayersOnHit, Terraria.Main.dontStarveWorld, Terraria.ID.SoundID.DSTFemaleHurt, Terraria.Main.dust, Terraria.Main.expertMode, Terraria.Player.eyeHelper, Terraria.Player.fallStart, Terraria.Player.forceWerewolf, Terraria.Player.frostArmor, Terraria.Player.GetSource_Accessory_OnHurt(), Terraria.Entity.height, Terraria.Player.hideWolf, Terraria.Player.honeyCombItem, Terraria.Player.hurtCooldowns, Terraria.Player.immune, Terraria.Player.immuneTime, Terraria.Item.IsAir, Terraria.ID.SoundID.Item27, Terraria.Player.KillMe(), Terraria.Player.lifeRegenTime, Terraria.Player.longInvince, Terraria.Player.Male, Terraria.Main.masterMode, Terraria.Player.mount, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.Projectile.NewProjectile(), Terraria.CombatText.NewText(), Terraria.ModLoader.PlayerLoader.OnHurt(), Terraria.Player.OnHurt_Part1(), Terraria.Player.OnHurt_Part2(), Terraria.Player.OnHurt_Part3(), Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.ModLoader.PlayerLoader.PostHurt(), Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.NetMessage.SendData(), Terraria.NetMessage.SendPlayerHurt(), Terraria.Player.starCloakItem, Terraria.Player.starCloakItem_beeCloakOverrideItem, Terraria.Player.starCloakItem_manaCloakOverrideItem, Terraria.Player.starCloakItem_starVeilOverrideItem, Terraria.Player.statLife, Terraria.Player.statLifeMax2, Terraria.Player.stoned, Terraria.Player.StopVanityActions(), Terraria.Player.strongBees, Terraria.Mount.Type, Terraria.Player.wereWolf, Terraria.Entity.whoAmI, and Terraria.Entity.width.

+ Here is the call graph for this function: