2D_Emerald
The Destroyer
Anyone know what the heck this is? It does this every time I click single player. I don't know how to fix it.
for (int i = Main.player.Length; i>=0; i--){
if (Distance(Main.players[i].Center, NPC.Center) < distance)
{
distance = Vector2.Distance(Main.player[i].Center, NPC.Center);
target = Main.player[i];
}
}
If you want to use the vanilla texture,Hey, I'm trying to make a mod that adds an NPC. It's supposed to shoot bullets from a sniper rifle. The bullets work but the sniper rifle won't show up when the NPC fires. heres the code snippet.
public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = ModContent.Request<Texture2D>("Terraria/tModLoader/ModSources/MeNPC/Content/Items/Weapons" + ItemID.SniperRifle).Value;
itemSize = 40;
}
If anyone could help me I would appreciate it, thank you![]()
TextureAssets.Item[ItemID.SniperRifle].Value
should work.TextureAssets
, you need using Terraria.GameContent;
in your file.I tried it. I didn't get an error code (like last time) But the sniper rifle still doesn't appear when the npc attacks. Heres the new code, maybe I just put it in wrong?If you want to use the vanilla texture,TextureAssets.Item[ItemID.SniperRifle].Value
should work.
If you get an error aboutTextureAssets
, you needusing Terraria.GameContent;
in your file.
You need to override `DrawTownAttackGun` instead of `DrawTownAttackSwing`. Apologies for not catching that earlier.I tried it. I didn't get an error code (like last time) But the sniper rifle still doesn't appear when the npc attacks. Heres the new code, maybe I just put it in wrong?
public override void DrawTownAttackSwing(ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
{
item = TextureAssets.Item[ItemID.SniperRifle].Value;
itemSize = 40;
}
Also I'm including a video of the attack incase that helps.
You need to override `DrawTownAttackGun` instead of `DrawTownAttackSwing`. Apologies for not catching that earlier.
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Creative;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System;
namespace DealerClass.Content.Items.Weapons
{
internal class WoodDeck : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Wood Deck");
Tooltip.SetDefault("4% wild card chance");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void SetDefaults()
{
Item.width = 28;
Item.height = 36;
Item.DamageType = DamageClass.Generic;
Item.damage = 4;
Item.knockBack = 0.05f;
Item.useTime = 5;
Item.useAnimation = 20;
Item.autoReuse = true;
Item.useStyle = ItemUseStyleID.Thrust;
Item.useTurn = true;
Item.UseSound = SoundID.Item1;
// VVV im trying to get these projectiles to do the randomizer thingy VVV
/*
Item.shoot = ModContent.ProjectileType<WoodNormalCard>();
Item.shootSpeed = 1f;
Item.shoot = ModContent.ProjectileType<WoodWildCard>();
Item.shootSpeed = 1f;
*/
Item.value = Item.buyPrice(copper : 20);
Item.rare = ItemRarityID.White;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
{
var lineToChange = tooltips.FirstOrDefault(x => x.Name=="Damage" && x.Mod == "Terraria");
if (lineToChange != null)
{
string[] split = lineToChange.Text.Split(" ");
lineToChange.Text = split.First() + " dealer " + split.Last();
}
}
public override void ModifyWeaponDamage(Player player, ref StatModifier damage)
{
damage += player.GetModPlayer<GlobalPlayer>().dealerDamage;
}
public override void AddRecipes()
{
CreateRecipe()
.AddTile(TileID.WorkBenches)
.AddIngredient(ItemID.Wood, 8)
.Register();
}
}
}