tModLoader How do I code a Yoyo for a mod?

I guess I might as well teach.
Code:
public class TheYoyo : ModItem
{
        public override void SetDefaults()
        {
            item.CloneDefaults(ItemID.WoodYoyo);
            item.damage = 40;
            item.width = 32;
            item.height = 26;
            item.knockBack = 6;
            item.name = "The Yo-Yo";
            item.shoot = mod.ProjectileType("Yoyo");
        }
}
That is the item. Put that in whatever file, obviously, with the correct namespace.
Code:
public class Yoyo : ModProjectile
{
    public override void SetDefaults()
    {
            projectile.CloneDefaults(ProjectileID.TheEyeOfCthulhu);
    }
}
That is the projectile, the thing it shoots. It simply copies another yo-yo :p
Boss Drop Code:
Code:
public class MyGlobalNPC : GlobalNPC

{
      public override void NPCLoot(NPC npc)
      {
            if (npc.type == NPCID.EyeOfCthulhu)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ExampleItem"), Main.rand.Next(5, 8));
            }
      }
}
That (should) make the Eye of Cthulhu drop 5-8 ExampleItems.
 
Last edited:
Back
Top Bottom