Surfpup's tConfig Mod Wiki
Advertisement

I was trying to spawn my boss in-game and it didn't work for some reason.


Boss spawner item .ini:

[Stats]

width=10

height=10

consumable=True

useTurn=True

type=-1

maxStack=5

toolTip=Summons the Storm Dragon

scale=1

value=00

[Recipe]

Amount=5

needWater=False

Items=1 Wood (this is temporary for testing)

Tiles=Work Bench



Boss spawner item .cs File:

public void UseItem(Player player, int playerID) {

 NPC.SpawnOnPlayer(playerID, "Storm Dragon");

}



Boss .cs File:

public void AI()

{

npc.netUpdate = true;

npc.ai[2]++;

npc.ai[1]++;


if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)

{

npc.TargetClosest(true);

}

if (npc.ai[2] < 600)

{

if (Main.player[npc.target].position.X < npc.position.X)

{

if (npc.velocity.X > -8) {npc.velocity.X -= 0.22f;}

}

if (Main.player[npc.target].position.X > npc.position.X)

{

if (npc.velocity.X < 8) {npc.velocity.X += 0.22f;}

}


if (Main.player[npc.target].position.Y < npc.position.Y+300)

{

if (npc.velocity.Y > 0f) npc.velocity.Y -= 0.8f;

else npc.velocity.Y -= 0.07f;

}

if (Main.player[npc.target].position.Y > npc.position.Y+300)

{

if (npc.velocity.Y < 0f) npc.velocity.Y += 0.8f;

else npc.velocity.Y += 0.07f;

}


if (npc.ai[1] >= 0 && npc.ai[2] > 120 && npc.ai[2] < 600)

{

if ((Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) && Main.netMode != 2)

{

float num48 = 12f;

Vector2 vector8 = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height / 2));

int damage = 30;

int type = Config.projectileID["Flamelash"];

         Main.PlaySound(2, (int) npc.position.X, (int) npc.position.Y, 17);

float rotation = (float) Math.Atan2(vector8.Y-(Main.player[npc.target].position.Y+(Main.player[npc.target].height * 0.5f)), vector8.X-(Main.player[npc.target].position.X+(Main.player[npc.target].width * 0.5f)));

int num54 = Projectile.NewProjectile(vector8.X, vector8.Y,(float)((Math.Cos(rotation) * num48)*-1),(float)((Math.Sin(rotation) * num48)*-1), type, damage, 0f, 0);

Main.projectile[num54].timeLeft = 300;

Main.projectile[num54].tileCollide=false;

num54 = Projectile.NewProjectile(vector8.X, vector8.Y,(float)((Math.Cos(rotation+0.4) * num48)*-1),(float)((Math.Sin(rotation+0.4) * num48)*-1), type, damage, 0f, 0);

Main.projectile[num54].timeLeft = 300;

Main.projectile[num54].tileCollide=false;

num54 = Projectile.NewProjectile(vector8.X, vector8.Y,(float)((Math.Cos(rotation-0.4) * num48)*-1),(float)((Math.Sin(rotation-0.4) * num48)*-1), type, damage, 0f, 0);

Main.projectile[num54].timeLeft = 300;

Main.projectile[num54].tileCollide=false;

npc.ai[1] = -90;

}

}

}

else if (npc.ai[2] >= 600 && npc.ai[2] < 1200)

{

npc.velocity.X *= 0.98f;

npc.velocity.Y *= 0.98f;

if ((npc.velocity.X < 2f) && (npc.velocity.X > -2f) && (npc.velocity.Y < 2f) && (npc.velocity.Y > -2f))

{

float rotation = (float) Math.Atan2((npc.position.Y)-(Main.player[npc.target].position.Y+(Main.player[npc.target].height * 0.5f)), (npc.position.X)-(Main.player[npc.target].position.X+(Main.player[npc.target].width * 0.5f)));

npc.velocity.X = (float) (Math.Cos(rotation) * 25)*-1;

npc.velocity.Y = (float) (Math.Sin(rotation) * 25)*-1;

}

}

else npc.ai[2] = 0;


if (Main.player[npc.target].dead)

{

npc.velocity.Y -= 0.04f;

if (npc.timeLeft > 15)

{

npc.timeLeft = 15;

return;

}

}

}




I'm fairly sure that there is something wrong with the ini file.


Thanks~

EnDleSS

Advertisement