The Wild Boar
Red quare suqare purple on b all the code for boar and then i will remove
using hackerworld.Commmon.Systems;
using hackerworld.Content.Items;
using hackerworld.Content.Projectiles;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
using Terraria.Graphics.CameraModifiers;
using Terraria.Graphics.Renderers;
using Terraria.ID;
using Terraria.ModLoader;
namespace hackerworld.Content.NPCs.Boar
{
// The main part of the boss, usually referred to as "body"
[AutoloadBossHead] // This attribute looks for a texture called "ClassName_Head_Boss" and automatically registers it as the NPC boss head icon
public class Boar_Body : ModNPC
{
public override void SetStaticDefaults()
{
Main.npcFrameCount[Type] = 3;
NPCID.Sets.MPAllowedEnemies[Type] = true;
NPCID.Sets.BossBestiaryPriority.Add(Type);
NPCID.Sets.NPCBestiaryDrawModifiers DrawMods = new()
{
PortraitScale = 0.6f
};
}
public override void SetDefaults()
{
NPC.immortal = false;
NPC.damage = 50;
NPC.height = 110;
NPC.width = 110;
NPC.scale = 1.1f;
NPC.lifeMax = 666667;
NPC.knockBackResist = 0;
NPC.HitSound = SoundID.Shatter;
NPC.DeathSound = SoundID.ScaryScream;
NPC.noGravity = true;
NPC.noTileCollide = true;
NPC.SpawnWithHigherTime(30);
NPC.boss = true;
NPC.npcSlots = 10;
NPC.aiStyle = -1;
NPC.value = 66666666; // money dropped
if (!Main.dedServ)
{
Music = MusicLoader.GetMusicSlot(Mod, "Assets/Music/boarPhase2");
}
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
{
cooldownSlot = ImmunityCooldownID.Bosses; // player has iframes
return true;
}
public override void ModifyNPCLoot(NPCLoot npcLoot)
{
//drops 1-60spikess!!!
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<spike>(), 1, 1, 60));
}
public override void OnKill()
{
var random = new Random();
var random2 = new Random();
NPC.SetEventFlagCleared(ref youkilledtheboaryay.killedtheboar, -1); //makes the boar dead in saved in the world
for (int index = 1; index <= 55; index++)
{
// blood evry were
Main.NewText("Wild boar: you will regret this for the length of 2000 tombs", Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)), Convert.ToByte(random.Next(0, 255)));
Dust.NewDust(NPC.Center, 0, 0, DustID.Blood, random.Next(-50, 50) / 5, random.Next(-50, 50) / 5, 1, Color.DarkRed, random.Next(1, 50) / 2);
Dust.NewDust(NPC.Center, 0, 0, DustID.Blood, random.Next(-50, 50) / 5, random.Next(-50, 50) / 5, 1, Color.DarkRed, random.Next(1, 50) / 2);
Dust.NewDust(NPC.Center, 0, 0, DustID.Blood, random.Next(-50, 50) / 5, random.Next(-50, 50) / 5, 1, Color.DarkRed, random.Next(1, 50) / 2);
Dust.NewDust(NPC.Center, 0, 0, DustID.Blood, random.Next(-50, 50) / 5, random.Next(-50, 50) / 5, 1, Color.DarkRed, random.Next(1, 50) / 2);
Gore.NewGore(NPC.GetSource_FromThis(), NPC.Center, new Vector2(random.Next(-50, 50) / 2, random.Next(-50, 50) / 2), GoreID.DripplerChunk, random.Next(1, 10) / 2);
Gore.NewGore(NPC.GetSource_FromThis(), NPC.Center, new Vector2(random.Next(-50, 50) / 2, random.Next(-50, 50) / 2), GoreID.BloodSquid2, random.Next(1, 10) / 2);
Gore.NewGore(NPC.GetSource_FromThis(), NPC.Center, new Vector2(random.Next(-50, 50) / 2, random.Next(-50, 50) / 2), GoreID.BloodZombieChunk2, random.Next(1, 10) / 2);
Gore.NewGore(NPC.GetSource_FromThis(), NPC.Center, new Vector2(random.Next(-50, 50) / 2, random.Next(-50, 50) / 2), GoreID.BloodEel3, random.Next(1, 10) / 2);
}
}
public int count;
public int beamcount;
public float spin = 0;
public float spi2n = 0;
public float KILL = 0;
public float spi2ncounter = 0;
public bool bosscutscene = true;
public float cutscenid = 1;
public float sector = 0;
public float bosscounter = 0;
public float songider = 0;
public override void AI()
{
var random = new Random();
if (bosscutscene == true)
{
NPC.immortal = true;
NPC.position.X = Main.player[NPC.target].Center.X - 350;
NPC.position.Y = Main.player[NPC.target].Center.Y - 350;
bosscounter++;
switch(cutscenid)
{
case 1:
switch (bosscounter)
{
case 1:
if (youkilledtheboaryay.killedtheboar != true)
{ Main.NewText("Wild Boar: i diddnt want to have to do this", 150, 10, 10);
} else
{
Main.NewText("i will Destroy you..", 255, 25, 25);
for (KILL = 0; KILL < 100;)
{ Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(random.Next(-10, 10), random.Next(-10, 10)), ProjectileID.BouncyBoulder, 50, 77, -1, random.Next(-100, 100));
KILL++;
}
}
break;
case 200:
Main.NewText("Wild boar: but you lev me no choies this time", 150, 10, 10);
break;
case 350:
Main.NewText("wild boar : and now ......", 150, 10, 10);
break;
case 500:
Main.NewText("wild boar: i killer you", 150, 10, 10);
bosscounter = 0;
bosscutscene = false;
cutscenid = 2;
break;
}
break; // end of case 1 for id
case 2:
if (cutscenid == 2)
{ switch (bosscounter)
{
case 1:
Main.NewText("wild boar: how ist this possible", 150, 10, 10);
break;
case 200:
Main.NewText("Wild boar : i have to go all the way powerful mode", 150, 10, 10);
break;
case 350:
Main.NewText("wild boar : im sorry", 150, 10, 10);
break;
case 500:
Main.NewText("wild boar: Just kidding your evil.... I HATE YOU,,,... (in lore)", 255, 10, 10);
bosscounter = 0;
bosscutscene = false;
cutscenid = 3;
break;
}
}
break; // end of case 1 for id
case 3:
if (cutscenid == 3)
{
switch (bosscounter)
{
case 1:
Main.NewText("wild boar: im sorry for what im about to do.....", 255, 00, 00);
break;
case 200:
Main.NewText("Wild boar : as this may destroy the:", 255, 00, 0);
Main.NewText("unvierse", 25, 255, 255);
break;
case 350:
Main.NewText("wild boar : 3 , 2 , 1", 150, 10, 10);
break;
case 500:
Main.NewText("ion death!!!!!", 255, 255, 10);
songider = 1;
bosscounter = 0;
bosscutscene = false;
cutscenid = 4;
break;
}
}
break; // end of case 1 for id
}
}
else
{
if (youkilledtheboaryay.killedtheboar == true)
{
for (KILL = 0; KILL < 5;)
{
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(random.Next(-10, 10), random.Next(-10, 10)), ProjectileID.BouncyBoulder, 50, 77, -1, random.Next(-100, 100));
KILL++;
}
}
NPC.immortal = false;
count++;
var uporleft = random.Next(1, 3);
if (NPC.life <= NPC.lifeMax / 10)
{
if (!Main.dedServ)
{
if (songider == 1)
{ Music = MusicLoader.GetMusicSlot(Mod, "Assets/Music/boarDesperation");
songider = 2;
}
}
if (cutscenid == 3)
{
bosscutscene = true;
}
NPC.velocity.Y = 0;
NPC.velocity.X = 0;
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 0), ProjectileID.FairyQueenLance, 50, 77, -1, spin);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 0), ProjectileID.FairyQueenLance, 50, 77, -1, spin + 2f);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 0), ProjectileID.FairyQueenLance, 50, 77, -1, spin + 4f);
spin += 0.1111111f;
}
if (NPC.life <= NPC.lifeMax / 10)
{
//Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 0), ProjectileID.FairyQueenLance, 50, 77, -1, random.Next(1,100));
}
if (NPC.life >= NPC.lifeMax / 2) // check in second fase
{
if (beamcount >= 10) // how many times has it "dashed"(recalculated velocity)
{
if (uporleft >= 2) // is the player "up" or "left" aka should it do horizontal beam attack or verticle
{
// btw this is the horizontal dash so it uses x instead of y and boarprojectile instead of boarverticle
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-1, 5), ModContent.ProjectileType<boarprojectile>(), 50, 77);//this to
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(1, -5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(1, 5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-1, -5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, -5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, 5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, -5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, 5), ModContent.ProjectileType<boarprojectile>(), 50, 77);// this is just the x pattern when the boss does the beam
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(20, 0), ModContent.ProjectileType<boarprojectile>(), 50, 77); // lazers from dog
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-20, 0), ModContent.ProjectileType<boarprojectile>(), 50, 77);
if (NPC.position.X <= Main.player[NPC.target].Center.X) // is player to the right or left
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) + 100; // dash toward player
}
else
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) - 100;
}
beamcount = 0; // start counting until can beam again
}
else
{
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, 1), ModContent.ProjectileType<boarverticle>(), 50, 77);// read other section
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, -1), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, 1), ModContent.ProjectileType<boarverticle>(), 50, 77);// only difference is
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, -1), ModContent.ProjectileType<boarverticle>(), 50, 77);//the prev mentioned
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, -5), ModContent.ProjectileType<boarverticle>(), 50, 77);// x to y and boarpr
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, 5), ModContent.ProjectileType<boarverticle>(), 50, 77);// to boar vert
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, -5), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, 5), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 20), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, -20), ModContent.ProjectileType<boarverticle>(), 50, 77);
if (NPC.position.Y <= Main.player[NPC.target].Center.Y)
{
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) + 64;
}
else
{
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) - 64;
}
beamcount = 0;
}
}
}else
{
if (cutscenid == 2)
{
bosscutscene = true;
}
if (beamcount >= 10 & NPC.life >= NPC.lifeMax * 0.1)
{
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-1, 5), ModContent.ProjectileType<boarprojectile>(), 50, 77);// in phase two it does smaller x but grid instead of rows/columns
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(1, -5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(1, 5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-1, -5), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(20, 0), ModContent.ProjectileType<boarprojectile>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-20, 0), ModContent.ProjectileType<boarprojectile>(), 50, 77);
if (NPC.position.X <= Main.player[NPC.target].Center.X)
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) + 25;
}
else
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) - 25;
}
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, 1), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, -1), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(5, 1), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(-5, -1), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 20), ModContent.ProjectileType<boarverticle>(), 50, 77);
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, -20), ModContent.ProjectileType<boarverticle>(), 50, 77);
if (NPC.position.Y <= Main.player[NPC.target].Center.Y)
{
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) + 25;
}
else
{
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) - 25;
}
beamcount = 0;
}
}
if (NPC.target == 0 || NPC.target == 255 || Main.player[NPC.target].active || Main.player[NPC.target].dead) //attacker at player
{
NPC.TargetClosest();
}
if (Main.player[NPC.target].dead) // fly away and deaspawn
{
NPC.velocity.Y -= 5.6f;
NPC.EncourageDespawn(10);
}
if (count == 25)
{
if (Main.expertMode == false) // movment its pretty clear the harder it is the faster it goeas
{
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 8;
}
else
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 4;
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 18;
}
if (Main.masterMode == true)
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 20;
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 20;
beamcount++;
}
if (count == 50)
{
}
if (Main.expertMode == false)
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 8;
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 4;
beamcount++;
}
else
{
NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 18;
NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 10;
beamcount += 1;
}
if (NPC.life <= NPC.lifeMax / 10)
{
//NPC.velocity.X = (Main.player[NPC.target].Center.X - NPC.Center.X) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 18 * random.Next(-1, 3);
//NPC.velocity.Y = (Main.player[NPC.target].Center.Y - NPC.Center.Y) / Vector2.Distance(NPC.Center, Main.player[NPC.target].position) * 10 * random.Next(-1, 3);
spi2ncounter++;
if (spi2ncounter >= 3)
{
for (spi2n = 0; spi2n < 100;)
{
Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Microsoft.Xna.Framework.Vector2(0, 0), ProjectileID.FairyQueenLance, 1, 1, -1, spi2n);
spi2n++;
}
spi2ncounter = 0;
}
}
spi2n = 0;
count = 0;
KILL = 0;// no count
}
}
}
}
}