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

◆ ApplyNPCOnHitEffects()

void Terraria.Player.ApplyNPCOnHitEffects ( Item sItem,
Rectangle itemRectangle,
int damage,
float knockBack,
int npcIndex,
int dmgRandomized,
int dmgDone )
inlineprivate

Definition at line 42241 of file Player.cs.

42242 {
42243 bool flag = !Main.npc[npcIndex].immortal;
42244 if (sItem.type == 3211)
42245 {
42246 Vector2 vector = new Vector2(direction * 100 + Main.rand.Next(-25, 26), Main.rand.Next(-75, 76));
42247 vector.Normalize();
42248 vector *= (float)Main.rand.Next(30, 41) * 0.1f;
42249 Vector2 vector2 = new Vector2(itemRectangle.X + Main.rand.Next(itemRectangle.Width), itemRectangle.Y + Main.rand.Next(itemRectangle.Height));
42250 vector2 = (vector2 + Main.npc[npcIndex].Center * 2f) / 3f;
42251 Projectile.NewProjectile(GetProjectileSource_Item(sItem), vector2.X, vector2.Y, vector.X, vector.Y, 524, (int)((double)damage * 0.5), knockBack * 0.7f, whoAmI);
42252 }
42253 if (beetleOffense && flag)
42254 {
42256 beetleCountdown = 0;
42257 }
42258 if (meleeEnchant == 7)
42259 {
42260 Projectile.NewProjectile(GetProjectileSource_Misc(8), Main.npc[npcIndex].Center.X, Main.npc[npcIndex].Center.Y, Main.npc[npcIndex].velocity.X, Main.npc[npcIndex].velocity.Y, 289, 0, 0f, whoAmI);
42261 }
42262 if (sItem.type == 3106)
42263 {
42264 stealth = 1f;
42265 if (Main.netMode == 1)
42266 {
42267 NetMessage.SendData(84, -1, -1, null, whoAmI);
42268 }
42269 }
42270 if (sItem.type == 5094)
42271 {
42272 TentacleSpike_TrySpiking(Main.npc[npcIndex], sItem, damage, knockBack);
42273 }
42274 if (sItem.type == 795)
42275 {
42276 BloodButcherer_TryButchering(Main.npc[npcIndex], sItem, damage, knockBack);
42277 }
42278 if (sItem.type == 121)
42279 {
42280 Volcano_TrySpawningVolcano(Main.npc[npcIndex], sItem, (int)((float)damage * 0.75f), knockBack, itemRectangle);
42281 }
42282 if (sItem.type == 5097)
42283 {
42285 }
42286 if (sItem.type == 1123 && flag)
42287 {
42288 int num = Main.rand.Next(1, 4);
42289 if (strongBees && Main.rand.Next(3) == 0)
42290 {
42291 num++;
42292 }
42293 for (int i = 0; i < num; i++)
42294 {
42295 float num2 = (float)(direction * 2) + (float)Main.rand.Next(-35, 36) * 0.02f;
42296 float num3 = (float)Main.rand.Next(-35, 36) * 0.02f;
42297 num2 *= 0.2f;
42298 num3 *= 0.2f;
42299 int num4 = Projectile.NewProjectile(GetProjectileSource_Item(sItem), itemRectangle.X + itemRectangle.Width / 2, itemRectangle.Y + itemRectangle.Height / 2, num2, num3, beeType(), beeDamage(dmgRandomized / 3), beeKB(0f), whoAmI);
42300 Main.projectile[num4].melee = true;
42301 }
42302 }
42303 if (sItem.type == 155 && flag && _spawnMuramasaCut)
42304 {
42305 _spawnMuramasaCut = false;
42306 int num5 = Main.rand.Next(1, 4);
42307 num5 = 1;
42308 for (int j = 0; j < num5; j++)
42309 {
42310 NPC nPC = Main.npc[npcIndex];
42311 Rectangle hitbox = nPC.Hitbox;
42312 hitbox.Inflate(30, 16);
42313 hitbox.Y -= 8;
42314 Vector2 vector3 = Main.rand.NextVector2FromRectangle(hitbox);
42315 Vector2 vector4 = hitbox.Center.ToVector2();
42316 Vector2 spinningpoint = (vector4 - vector3).SafeNormalize(new Vector2(direction, gravDir)) * 8f;
42317 Main.rand.NextFloat();
42318 float num6 = (float)(Main.rand.Next(2) * 2 - 1) * ((float)Math.PI / 5f + (float)Math.PI * 4f / 5f * Main.rand.NextFloat());
42319 num6 *= 0.5f;
42320 spinningpoint = spinningpoint.RotatedBy(0.7853981852531433);
42321 int num7 = 3;
42322 int num8 = 10 * num7;
42323 int num9 = 5;
42324 int num10 = num9 * num7;
42325 vector3 = vector4;
42326 for (int k = 0; k < num10; k++)
42327 {
42329 spinningpoint = spinningpoint.RotatedBy((0f - num6) / (float)num8);
42330 }
42331 vector3 += nPC.velocity * num9;
42332 Projectile.NewProjectile(GetProjectileSource_Item(sItem), vector3, spinningpoint, 977, (int)((float)dmgRandomized * 0.5f), 0f, whoAmI, num6);
42333 }
42334 }
42335 if (Main.npc[npcIndex].value > 0f && hasLuckyCoin && Main.rand.Next(5) == 0)
42336 {
42337 int type = 71;
42338 if (Main.rand.Next(10) == 0)
42339 {
42340 type = 72;
42341 }
42342 if (Main.rand.Next(100) == 0)
42343 {
42344 type = 73;
42345 }
42346 int num11 = Item.NewItem(GetItemSource_OnHit(Main.npc[npcIndex], 2), (int)Main.npc[npcIndex].position.X, (int)Main.npc[npcIndex].position.Y, Main.npc[npcIndex].width, Main.npc[npcIndex].height, type);
42347 Main.item[num11].stack = Main.rand.Next(1, 11);
42348 Main.item[num11].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
42349 Main.item[num11].velocity.X = (float)Main.rand.Next(10, 31) * 0.2f * (float)direction;
42350 Main.item[num11].timeLeftInWhichTheItemCannotBeTakenByEnemies = 60;
42351 if (Main.netMode == 1)
42352 {
42353 NetMessage.SendData(148, -1, -1, null, num11);
42354 }
42355 }
42356 }
const double PI
Definition Math.cs:16
void TentacleSpike_TrySpiking(NPC npc, Item sItem, float damage, float knockBack)
Definition Player.cs:41977
float beetleCounter
Definition Player.cs:677
bool beetleOffense
Definition Player.cs:683
bool hasLuckyCoin
Definition Player.cs:2215
IEntitySource GetProjectileSource_Misc(int projectileSourceId)
Definition Player.cs:9317
IEntitySource GetProjectileSource_Item(Item item)
Definition Player.cs:9272
byte meleeEnchant
Definition Player.cs:831
void BatBat_TryLifeLeeching(Entity entity)
Definition Player.cs:42008
float beeKB(float KB)
Definition Player.cs:11853
void BloodButcherer_TryButchering(NPC npc, Item sItem, float damage, float knockBack)
Definition Player.cs:41992
bool _spawnMuramasaCut
Definition Player.cs:2457
int beeDamage(int dmg)
Definition Player.cs:11844
void Volcano_TrySpawningVolcano(NPC npc, Item sItem, float damage, float knockBack, Rectangle itemRectangle)
Definition Player.cs:41966
IEntitySource GetItemSource_OnHit(Entity victim, int itemSourceId)
Definition Player.cs:9337
int beetleCountdown
Definition Player.cs:679

References Terraria.Main.item, Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, System.Math.PI, Terraria.Main.projectile, Terraria.Main.rand, Terraria.NetMessage.SendData(), and System.type.