166 lines
6.0 KiB
C#
166 lines
6.0 KiB
C#
using Decimation.Content.Buffs.Buffs;
|
|
using Decimation.Lib.Tiles;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.ObjectData;
|
|
|
|
namespace Decimation.Content.Tiles
|
|
{
|
|
public class EnchantedAnvil : DecimationMultiTile
|
|
{
|
|
public override Color MapColor => new Color(108, 239, 64);
|
|
public override int TileItem => ModContent.ItemType<Items.Placeable.EnchantedAnvil>();
|
|
public override TileObjectData Style => TileObjectData.Style3x2;
|
|
public override string Name => "Enchanted Anvil";
|
|
public override int DustType => DustID.Iron;
|
|
public override bool HasLight => true;
|
|
public override Point16 Origin => new Point16(1, 1);
|
|
public override bool Table => true;
|
|
|
|
protected override void InitMultiTile()
|
|
{
|
|
adjTiles = new int[] { TileID.Anvils, TileID.MythrilAnvil };
|
|
}
|
|
|
|
public override void NearbyEffects(int i, int j, bool closer)
|
|
{
|
|
if (closer)
|
|
{
|
|
Main.LocalPlayer.AddBuff(ModContent.BuffType<FatesSmile>(), 60);
|
|
Main.LocalPlayer.GetModPlayer<DecimationPlayer>().closeToEnchantedAnvil = true;
|
|
}
|
|
else
|
|
{
|
|
Main.LocalPlayer.GetModPlayer<DecimationPlayer>().closeToEnchantedAnvil = false;
|
|
}
|
|
}
|
|
|
|
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
|
|
{
|
|
r = 1f;
|
|
g = 1f;
|
|
b = 1f;
|
|
}
|
|
|
|
public class EnchantedAnvilGlobalItem : GlobalItem
|
|
{
|
|
public override void OnCraft(Item item, Recipe recipe)
|
|
{
|
|
//Work only on prefix, not on effects
|
|
if (Main.LocalPlayer.GetModPlayer<DecimationPlayer>().closeToEnchantedAnvil)
|
|
{
|
|
// Damages
|
|
if (item.melee && item.useStyle != 1 && item.pick == 0 && item.axe == 0 && item.hammer == 0)
|
|
{
|
|
if (Main.rand.Next(0, 21) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Godly);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.melee && (item.pick != 0 || item.axe != 0 || item.hammer != 0))
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Light);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.melee)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Legendary);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.summon)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Ruthless);
|
|
return;
|
|
}
|
|
}
|
|
else if ((item.magic || item.ranged) && item.knockBack == 0)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Demonic);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.ranged)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Unreal);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.summon)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Mythical);
|
|
return;
|
|
}
|
|
// Accessories
|
|
}
|
|
else if (item.accessory && item.defense != 0)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Warding);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.accessory && item.mana != 0)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Arcane);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.accessory && item.crit != 0)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Lucky);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.accessory && item.damage != 0)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Menacing);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.accessory && (item.velocity.X != 0 || item.velocity.Y != 0))
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Quick2);
|
|
return;
|
|
}
|
|
}
|
|
else if (item.accessory && item.shootSpeed != 0)
|
|
{
|
|
if (Main.rand.Next(0, 11) == 5)
|
|
{
|
|
item.Prefix(PrefixID.Violent);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|