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

◆ Update_NPCCollision()

void Terraria.Player.Update_NPCCollision ( )
inline

Definition at line 29011 of file Player.cs.

29012 {
29013 //IL_013d: Unknown result type (might be due to invalid IL or missing references)
29014 //IL_0149: Unknown result type (might be due to invalid IL or missing references)
29015 //IL_014e: Unknown result type (might be due to invalid IL or missing references)
29016 //IL_0153: Unknown result type (might be due to invalid IL or missing references)
29017 //IL_019b: Unknown result type (might be due to invalid IL or missing references)
29018 //IL_01aa: Unknown result type (might be due to invalid IL or missing references)
29019 //IL_03d3: Unknown result type (might be due to invalid IL or missing references)
29020 //IL_03df: Unknown result type (might be due to invalid IL or missing references)
29021 //IL_03e4: Unknown result type (might be due to invalid IL or missing references)
29022 //IL_03e9: Unknown result type (might be due to invalid IL or missing references)
29023 //IL_01d5: Unknown result type (might be due to invalid IL or missing references)
29024 //IL_01d6: Unknown result type (might be due to invalid IL or missing references)
29025 //IL_01df: Unknown result type (might be due to invalid IL or missing references)
29026 if (creativeGodMode)
29027 {
29028 return;
29029 }
29030 Rectangle rectangle = default(Rectangle);
29031 ((Rectangle)(ref rectangle))._002Ector((int)position.X, (int)position.Y, width, height);
29032 Rectangle npcRect = default(Rectangle);
29033 for (int i = 0; i < 200; i++)
29034 {
29035 if (!Main.npc[i].active || Main.npc[i].friendly || Main.npc[i].damage <= 0)
29036 {
29037 continue;
29038 }
29039 int specialHitSetter = -1;
29040 switch (Main.npc[i].type)
29041 {
29042 case 396:
29043 case 397:
29044 case 398:
29045 case 400:
29046 case 401:
29047 specialHitSetter = 1;
29048 break;
29049 case 636:
29050 specialHitSetter = 1;
29051 if (Main.npc[i].ai[0] == 0f || Main.npc[i].ai[0] == 10f)
29052 {
29053 continue;
29054 }
29055 break;
29056 }
29057 if (!CombinedHooks.CanNPCHitPlayer(Main.npc[i], this, ref specialHitSetter) || (specialHitSetter == -1 && immune) || (dash == 2 && i == eocHit && eocDash > 0) || npcTypeNoAggro[Main.npc[i].type])
29058 {
29059 continue;
29060 }
29061 float damageMultiplier = 1f;
29062 NPC obj = Main.npc[i];
29063 obj.position += Main.npc[i].netOffset;
29064 ((Rectangle)(ref npcRect))._002Ector((int)Main.npc[i].position.X, (int)Main.npc[i].position.Y, Main.npc[i].width, Main.npc[i].height);
29065 NPC.GetMeleeCollisionData(rectangle, i, ref specialHitSetter, ref damageMultiplier, ref npcRect);
29066 if (((Rectangle)(ref rectangle)).Intersects(npcRect))
29067 {
29068 if (npcTypeNoAggro[Main.npc[i].type])
29069 {
29070 continue;
29071 }
29072 bool flag = true;
29073 bool flag2 = false;
29074 bool num6 = CanParryAgainst(rectangle, npcRect, Main.npc[i].velocity);
29075 float num2 = thorns;
29076 float knockback = 10f;
29077 if (turtleThorns)
29078 {
29079 num2 = 2f;
29080 }
29081 if (num6)
29082 {
29083 num2 = 2f;
29084 knockback = 5f;
29085 flag = false;
29086 flag2 = true;
29087 }
29088 int num3 = -1;
29089 if (Main.npc[i].position.X + (float)(Main.npc[i].width / 2) < position.X + (float)(width / 2))
29090 {
29091 num3 = 1;
29092 }
29093 int num4 = Main.DamageVar((float)Main.npc[i].damage * damageMultiplier, 0f - luck);
29094 bool flag3 = !immune;
29095 if (specialHitSetter >= 0)
29096 {
29098 }
29099 if (whoAmI == Main.myPlayer && num2 > 0f && flag3 && !Main.npc[i].dontTakeDamage)
29100 {
29101 int num5 = (int)((float)num4 * num2);
29102 if (num5 > 1000)
29103 {
29104 num5 = 1000;
29105 }
29106 ApplyDamageToNPC(Main.npc[i], num5, knockback, -num3);
29107 }
29108 if (whoAmI == Main.myPlayer && cactusThorns && flag3 && !Main.npc[i].dontTakeDamage)
29109 {
29110 int damage = 15;
29111 if (Main.masterMode)
29112 {
29113 damage = 45;
29114 }
29115 else if (Main.expertMode)
29116 {
29117 damage = 30;
29118 }
29119 ApplyDamageToNPC(Main.npc[i], damage, knockback, -num3);
29120 }
29121 if (flag && Hurt(dodgeable: Main.npc[i].IsDamageDodgeable(), damageSource: PlayerDeathReason.ByNPC(i), Damage: num4, hitDirection: num3, pvp: false, quiet: false, Crit: false, cooldownCounter: specialHitSetter) > 0.0 && !dead && !flag2)
29122 {
29123 StatusFromNPC(Main.npc[i]);
29124 }
29125 if (num6)
29126 {
29128 AddBuff(198, 300, quiet: false);
29129 }
29130 }
29131 NPC obj2 = Main.npc[i];
29132 obj2.position -= Main.npc[i].netOffset;
29133 }
29134 }
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 bool CanNPCHitPlayer(NPC nPC, Player player, ref int specialHitSetter)
bool cactusThorns
Definition Player.cs:2907
bool[] npcTypeNoAggro
Definition Player.cs:3107
bool creativeGodMode
Definition Player.cs:2046
bool turtleThorns
Definition Player.cs:2905
int dash
The current vanilla dash that the player is VISIBLY using. Unlike F:Terraria.Player....
Definition Player.cs:1234
double Hurt(PlayerDeathReason damageSource, int Damage, int hitDirection, bool pvp, bool quiet, bool Crit, int cooldownCounter, bool dodgeable=true, float armorPenetration=0f)
Definition Player.cs:36998
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
bool CanParryAgainst(Rectangle blockingPlayerRect, Rectangle enemyRect, Vector2 enemyVelocity)
Definition Player.cs:29136
void ApplyDamageToNPC(NPC npc, int damage, float knockback, int direction, bool crit=false, DamageClass? damageType=null, bool damageVariation=false)
Deals damage to an NPC (and syncs the hit in multiplayer). The damage will be affected by modifiers...
Definition Player.cs:18941
int[] hurtCooldowns
Definition Player.cs:3259
void StatusFromNPC(NPC npc)
Definition Player.cs:20238
void GiveImmuneTimeForCollisionAttack(int time)
Definition Player.cs:18994

References Terraria.Player.AddBuff(), Terraria.Player.ApplyDamageToNPC(), Terraria.DataStructures.PlayerDeathReason.ByNPC(), Terraria.Player.cactusThorns, Terraria.ModLoader.CombinedHooks.CanNPCHitPlayer(), Terraria.Player.CanParryAgainst(), Terraria.Player.creativeGodMode, Terraria.GameContent.Damage, Terraria.Main.DamageVar(), Terraria.Player.dash, Terraria.Player.dead, Terraria.Player.eocDash, Terraria.Player.eocHit, Terraria.Main.expertMode, Terraria.NPC.GetMeleeCollisionData(), Terraria.Player.GiveImmuneTimeForCollisionAttack(), Terraria.Entity.height, Terraria.Player.Hurt(), Terraria.Player.hurtCooldowns, Terraria.Player.immune, Terraria.Player.longInvince, Terraria.Player.luck, Terraria.Main.masterMode, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Player.npcTypeNoAggro, Terraria.Entity.position, Terraria.Player.StatusFromNPC(), Terraria.Player.thorns, Terraria.Player.turtleThorns, Terraria.Entity.whoAmI, and Terraria.Entity.width.

Referenced by Terraria.Player.Update().

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