Added Wasp Necklace

This commit is contained in:
FyloZ 2020-06-10 19:34:39 -04:00
parent cd01d40d54
commit 0510b2f3c9
5 changed files with 84 additions and 5 deletions

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Decimation.Content.Buffs.Buffs; using Decimation.Content.Buffs.Buffs;
using Decimation.Content.Items.Accessories;
using Decimation.Content.Items.Amulets; using Decimation.Content.Items.Amulets;
using Decimation.Content.Items.Misc; using Decimation.Content.Items.Misc;
using Decimation.Lib;
using Decimation.Lib.Amulets; using Decimation.Lib.Amulets;
using Decimation.Lib.Collections; using Decimation.Lib.Collections;
using Decimation.Lib.Util; using Decimation.Lib.Util;
@ -345,6 +345,29 @@ namespace Decimation.Content
if (AmuletSlotItem.type == ModContent.ItemType<CrystalAmulet>() && Main.rand.NextBool(25)) if (AmuletSlotItem.type == ModContent.ItemType<CrystalAmulet>() && Main.rand.NextBool(25))
CrystalAmuletEffect(); CrystalAmuletEffect();
if (this.HasEquippedAccessory(ModContent.ItemType<WaspNecklace>()))
{
player.AddBuff(BuffID.Panic, 300);
// Wasps
int waspsCount = 1;
for (int i = 0; i < 3; i++)
{
if (Main.rand.NextBool(3))
waspsCount++;
}
Vector2 position = player.position;
Vector2 speed = new Vector2(Main.rand.Next(-35, 36) * 0.02f, Main.rand.Next(-35, 36) * 0.02f);
int damages = 10 + Main.rand.Next(1, 4);
const float kb = 0.5f;
for (int i = 0; i < waspsCount; i++)
{
Projectile.NewProjectile(position, speed, ProjectileID.Wasp, damages, kb, player.whoAmI);
}
}
} }
public override void OnHitByProjectile(Projectile proj, int damage, bool crit) public override void OnHitByProjectile(Projectile proj, int damage, bool crit)

View File

@ -0,0 +1,47 @@
using Decimation.Lib.Items;
using Decimation.Lib.Util;
using Decimation.Lib.Util.Builder;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Decimation.Content.Items.Accessories
{
public class WaspNecklace : DecimationAccessory
{
protected override string ItemName => "Wasp Necklace";
protected override string ItemTooltip => "Releases wasps after taking damage\n" +
"Increases movement speed after taking damage\n" +
"Attackers have 20% chances to be poisoned";
protected override void InitAccessory()
{
item.width = 30;
item.height = 32;
item.value = Item.buyPrice(gold: 1, silver: 70);
item.rare = Rarity.Green.GetRarityValue();
}
protected override ModRecipe GetRecipe()
{
return new RecipeBuilder(this)
.WithIngredient(ItemID.SweetheartNecklace)
.WithIngredient(ModContent.ItemType<WaspNest>())
.WithStation(TileID.TinkerersWorkbench)
.Build();
}
}
internal class WaspNecklacePoisonEffect : GlobalNPC
{
public override void OnHitPlayer(NPC npc, Player target, int damage, bool crit)
{
if (target.HasEquippedAccessory(ModContent.ItemType<WaspNecklace>()) && Main.rand.NextBool(5))
npc.AddBuff(BuffID.Poisoned, 300);
base.OnHitPlayer(npc, target, damage, crit);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

View File

@ -10,6 +10,8 @@ namespace Decimation.Content.Items.Accessories
public class WaspNest : DecimationAccessory public class WaspNest : DecimationAccessory
{ {
protected override string ItemName => "Wasp Nest"; protected override string ItemName => "Wasp Nest";
protected override string ItemTooltip => "Attackers also take damage\n" +
"Attackers have 50% chances to be poisoned";
protected override void InitAccessory() protected override void InitAccessory()
{ {
@ -45,4 +47,5 @@ namespace Decimation.Content.Items.Accessories
npc.AddBuff(BuffID.Poisoned, 600); npc.AddBuff(BuffID.Poisoned, 600);
} }
} }
} }

View File

@ -1,6 +1,7 @@
using Decimation.Content; using Decimation.Content;
using Decimation.Lib.Items; using Decimation.Lib.Items;
using Terraria; using Terraria;
using Terraria.ModLoader;
namespace Decimation.Lib.Util namespace Decimation.Lib.Util
{ {
@ -21,6 +22,11 @@ namespace Decimation.Lib.Util
return player.GetModPlayer().EquippedAccessories.Contains(accessoryType); return player.GetModPlayer().EquippedAccessories.Contains(accessoryType);
} }
public static bool HasEquippedAccessory(this ModPlayer modPlayer, int accessoryType)
{
return modPlayer.player.GetModPlayer().EquippedAccessories.Contains(accessoryType);
}
public static bool HasEquippedAmulet(this Player player, int amuletType) public static bool HasEquippedAmulet(this Player player, int amuletType)
{ {
return player.GetModPlayer().AmuletSlotItem.type == amuletType; return player.GetModPlayer().AmuletSlotItem.type == amuletType;