Directly deals damage to the NPC, spawns combat text, plays hit sound, deals knockback based on the provided T:Terraria.NPC.HitInfo
Calls M:Terraria.NPC.HitEffect(Terraria.NPC.HitInfo) and associated hooks after dealing damage.
Calls M:Terraria.NPC.checkDead
Does not automatically send packets. Use M:Terraria.NetMessage.SendStrikeNPC(Terraria.NPC,Terraria.NPC.HitInfo@,System.Int32) to synchronize hits.
91815 {
91816
91817
91818
91819
91820
91821
91822
91823
91824
91825
91826
91827
91828
91829
91830
91831
91832 bool flag = Main.netMode == 0;
91835 {
91836 return 0;
91837 }
91838 double num =
hit.Damage;
91839 bool crit =
hit.Crit;
91841 if (
hit.InstantKill)
91842 {
91844 }
91846 {
91848 {
91849 Color
color = (crit ? CombatText.DamagedFriendlyCrit : CombatText.DamagedFriendly);
91851 }
91852 else
91853 {
91854 Color
color2 = (crit ? CombatText.DamagedHostileCrit : CombatText.DamagedHostile);
91856 {
91857 color2 = (crit ? CombatText.OthersDamagedHostileCrit : CombatText.OthersDamagedHostile);
91858 }
91860 }
91861 }
91863 {
91865 {
91867 }
91869 if ((
type == 438 ||
type == 379) && Main.netMode != 1)
91870 {
91871 int num2 = (int)(0
f -
ai[3] - 1
f);
91872 if (
num2 > -1 && Main.npc[
num2].localAI[0] == 0
f)
91873 {
91874 Main.npc[
num2].localAI[0] = 1
f;
91875 }
91876 }
91878 {
91880 {
91883 {
91885 nPC.ai[1] = 300 + Main.rand.Next(300);
91887 nPC.localAI[3] = 0
f;
91889 nPC.netUpdate = true;
91890 }
91891 }
91893 ai[1] = 300 + Main.rand.Next(300);
91898 }
91899 if (
aiStyle == 8 && Main.netMode != 1)
91900 {
91902 {
91904 }
91905 else if (
type == 283 ||
type == 284)
91906 {
91907 if (Main.rand.Next(2) == 0)
91908 {
91911 }
91912 }
91913 else if (
type == 533)
91914 {
91915 if (Main.rand.Next(3) != 0)
91916 {
91919 }
91920 }
91921 else
91922 {
91924 }
91926 }
91927 if (
aiStyle == 97 && Main.netMode != 1)
91928 {
91931 }
91933 {
91938 }
91940 {
91942 }
91944 {
91946 }
91948 {
91950 }
91952 {
91954 }
91956 {
91958 {
91962 }
91963 else
91964 {
91966 }
91967 }
91968 if (
hit.Knockback > 0
f)
91969 {
91972 {
91976 }
91978 {
91982 }
91984 {
91988 }
91990 {
91994 }
91996 {
91998 }
91999 if (crit)
92000 {
92002 }
92004 if (Main.expertMode)
92005 {
92007 }
92009 {
92011 {
92013 {
92014 velocity.X -=
num3;
92015 }
92016 velocity.X -=
num3;
92018 {
92019 velocity.X = 0
f -
num3;
92020 }
92021 }
92023 {
92025 {
92026 velocity.X +=
num3;
92027 }
92028 velocity.X +=
num3;
92030 {
92032 }
92033 }
92035 {
92037 }
92040 {
92041 velocity.Y +=
num3;
92043 {
92045 }
92046 }
92047 }
92048 else
92049 {
92051 {
92053 }
92054 else
92055 {
92057 }
92059 }
92060 }
92062 {
92063 for (int i = 0; i < 200; i++)
92064 {
92065 if (Main.npc[i].active && (Main.npc[i].type == 113 || Main.npc[i].type == 114))
92066 {
92068 }
92069 }
92070 }
92071 else
92072 {
92074 }
92076 {
92078 }
92080 {
92082 }
92083 else
92084 {
92086 }
92088 }
92089 return 0;
92090 }
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 ...
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Vector2 position
The position of this Entity in world coordinates.
int width
The width of this Entity's hitbox, in pixels.
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
int height
The height of this Entity's hitbox, in pixels.
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
int lifeMax
The maximum life of this NPC.
void TargetClosest(bool faceTarget=true)
int aiStyle
Selects which vanilla code to use for the AI method. Vanilla NPC AI styles are enumerated in the T:Te...
bool noGravity
If true, the npc will not be affected by gravity. Demon Eyes and other floating npc use this....
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
float knockBackResist
How much of the knockback it receives will actually apply. 1f: full knockback; 0f: no knockback....
bool friendly
Indicates that an NPC is friendly to players. If true, a player won't damage the NPC and the NPC won'...
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
SoundStyle? HitSound
The sound that plays when this npc is hit. Set this to an existing T:Terraria.ID.SoundID entry or ass...
bool HideStrikeDamage
If true, damage combat text will not be shown by M:Terraria.NPC.StrikeNPC(Terraria....
void PlayerInteraction(int player)
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
int realLife
Stores the index (the F:Terraria.Entity.whoAmI) of a single NPC. This NPC will then share a health po...
void HitEffect(int hitDirection=0, double dmg=10.0, bool? instantKill=null)