tModLoader king slime code?

Magi∆

Skeletron Prime
hello! i currently am working on a boss named the emerald king, and i want him to jump around like the king slime. can someone edit my current boss code to make it do so?
here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace NewAdventure.NPCs
{
[AutoloadBossHead]
public class EmeraldKing : ModNPC
{
private Player player;
private float speed;

public override void SetStaticDefaults()
{
DisplayName.SetDefault("The Emerald King");
Main.npcFrameCount[npc.type] = 1;
}

public override void SetDefaults()
{
npc.aiStyle = 30; // Will not have any AI from any existing AI styles.
npc.lifeMax = 900000; // The Max HP the boss has on Normal
npc.damage = 127; // The base damage value the boss has on Normal
npc.defense = 27; // The base defense on Normal
npc.knockBackResist = 0f; // No knockback
npc.width = 157;
npc.height = 157;
npc.value = 10000;
npc.npcSlots = 1f; // The higher the number, the more NPC slots this NPC takes.
npc.boss = true; // Is a boss
npc.lavaImmune = true; // Not hurt by lava
npc.noGravity = true; // Not affected by gravity
npc.noTileCollide = true; // Will not collide with the tiles.
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
music = MusicID.Boss1;
bossBag = mod.ItemType("Egg"); // Needed for the NPC to drop loot bag.
}

public override float
SpawnChance(NPCSpawnInfo spawnInfo)
{
return
SpawnCondition.OverworldNightMonster.Chance * 0.00f;
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
{
npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.6f);
npc.defense = (int)(npc.defense + numPlayers);
}

public override void AI()
{
npc.ai[0]++;
Player P = Main.player[npc.target];
if (npc.target < 0 || npc.target == 137 || Main.player[npc.target].dead || !Main.player[npc.target].active)
{
npc.TargetClosest(true);
}
npc.netUpdate = true;

npc.ai[1]++;
if (npc.ai[1] >= 190) // 230 is projectile fire rate
{
float Speed = 44f; //projectile speed
Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
int damage = 230; //projectile damage
int type = (mod.ProjectileType("ReaperCthuluProjectile")); //put your projectile
Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, 17);
float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
npc.ai[1] = 0;
}
}

private void Target()
{
player = Main.player[npc.target]; // This will get the player target.
}

private void Move(Vector2 offset)
{
speed = 0.6f; // Sets the max speed of the npc.
Vector2 moveTo = player.Center + offset; // Gets the point that the npc will be moving to.
Vector2 move = moveTo - npc.Center;
float magnitude = Magnitude(move);
if(magnitude > speed)
{
move *= speed / magnitude;
}
float turnResistance = 10f; // The larget the number the slower the npc will turn.
move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
magnitude = Magnitude(move);
if(magnitude > speed)
{
move *= speed / magnitude;
}
npc.velocity = move;
}

private void DespawnHandler()
{
if(!player.active || player.dead)
{
npc.TargetClosest(false);
player = Main.player[npc.target];
if(!player.active || player.dead)
{
npc.velocity = new Vector2(0f, -10f);
if(npc.timeLeft > 10)
{
npc.timeLeft = 10;
}
return;
}
}
}

private float Magnitude(Vector2 mag)
{
return (float)Math.Sqrt(mag.X * mag.X + mag.Y * mag.Y);
}

public override void FindFrame(int frameHeight)
{
npc.frameCounter += 1;
npc.frameCounter %= 20;
int frame = (int)(npc.frameCounter / 2.0);
if (frame >= Main.npcFrameCount[npc.type]) frame = 0;
npc.frame.Y = frame * frameHeight;

RotateNPCToTarget();
}

private void RotateNPCToTarget()
{
if (player == null) return;
Vector2 direction = npc.Center - player.Center;
float rotation = (float)Math.Atan2(direction.Y, direction.X);
npc.rotation = rotation + ((float)Math.PI * 0.5f);
}

public override void NPCLoot()
{
{
Item.NewItem((int)npc.position.X,(int)npc.position.Y,npc.width, npc.width, mod.ItemType("EmeraldSword"),Main.rand.Next(17));
}
if (Main.expertMode)
{
npc.DropBossBags();
} else
{
if (Main.rand.Next(10) == 0) // For items that you want to have a chance to drop
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MetalStaff"));;
}
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("EmeraldBar")); // For Items that you want to always drop
}

}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
{
scale = 1.5f;
return null;
}

}
}
 
Back
Top Bottom