using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using ModName.Projectiles;
namespace ModName.Projectiles
{
public class ProjName : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Projectile Name";
projectile.width = 10;
projectile.height = 10;
projectile.aiStyle = 2;
projectile.alpha = 100;
projectile.friendly = true;
projectile.thrown = true;
projectile.penetrate = 2;
projectile.timeLeft = 600;
aiType = ProjectileID.ThrowingKnife;
}
// The following code allows the thrown item to have a 1/3 chance to be retrievable
public override bool OnTileCollide(Vector2 oldVelocity)
{
if (Main.rand.Next(3) == 0)
{
int itemID = Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, mod.ItemType("ItemName"), 1, false, 0, false, false);
}
projectile.Kill();
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 10);
return false;
}
}
}