broken code...

ZJ

Skeletron
ok so basically I am trying to make a summon weapon. I know the name "crusty killer" isn't that cool but it's just supposed to be funny. Anyway, like many of the people on the AMA thread, I am new to C# and modding and I tried making this weapon and I am receiving many errors as you might expect.



Here is my code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
//using static Terraria.ModLoader.ModContent;
namespace Zjmod1.Items
{
public class Crustykiller : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Crusty Killer");
Tooltip.SetDefault("You made this staff out of gold bars and other seemingly UN-crusty items, but after forging the staff it became as crusty as whole wheat bread.");
}
public override void SetDefaults()
{
item.summon = true;
item.mana = 10;
item.damage = 30;
item.width = 48;
item.height = 48;
item.maxStack = 1;
item.value = 50000;
item.rare = 5;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 1;
item.noMelee = true;
item.knockBack = 4;
item.useTurn = true;
item.UseSound = SoundID.Item44;
item.shoot = mod.ProjectileType("crustyminion");
item.shootSpeed = 10f;
item.buffType("Spiritual Guidance");
item.buffTime = 3600;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.GoldBar, 38);
recipe.AddIngredient(ItemID.Silk, 20);
recipe.AddIngredient(ItemID.FallenStar, 10);
recipe.AddIngredient(ItemID.Sapphire, 5);
recipe.AddIngredient(ItemID.Ruby, 1);
recipe.AddIngredient(ItemID.Emerald, 3);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void UseStyle(Player MyPlayer)
{
if (player.whoAmI == Main.MyPlayer && player.itemTime == 0)
{
player.AddBuff(item.buffType, 3600, true);
}
}
public override bool AltFunctionUse(Player MyPlayer) => true;

public override bool shoot.ModContent.ProjectileType<MinionP>();

}
public override bool UseItem<Crustykiller>();
}
[NewStruct1] = 2;
{
object p = player.MinionNPCTargetAim();
}
internal struct NewStruct
{
public object Item1;
public object Item2;
public NewStruct(object item1, object item2)
{
Item1 = item1;
Item2 = item2;
}
public override bool Equals(object obj)
{
return obj is NewStruct other &&
EqualityComparer<object>.Default.Equals(Item1, other.Item1) &&
EqualityComparer<object>.Default.Equals(Item2, other.Item2);
}
public override int GetHashCode()
{
int hashCode = -1030903623;
hashCode = hashCode * -1521134295 + EqualityComparer<object>.Default.GetHashCode(Item1);
hashCode = hashCode * -1521134295 + EqualityComparer<object>.Default.GetHashCode(Item2);
return hashCode;
}
public void Deconstruct(out object item1, out object item2)
{
item1 = Item1;
item2 = Item2;
}
public static implicit operator (object, object)(NewStruct value)
{
return (value.Item1, value.Item2);
}
public static implicit operator NewStruct((object, object) value)
{
return new NewStruct(value.Item1, value.Item2);
}
}
internal struct NewStruct1
{
public player.altFunctionUse Item1;
public object Item2;
public NewStruct1(player.altFunctionUse item1, object item2)
{
Item1 = item1;
Item2 = item2;
}
public override bool Equals(object obj)
{
return obj is NewStruct1 other &&
EqualityComparer<player.altFunctionUse>.Default.Equals(Item1, other.Item1) &&
EqualityComparer<object>.Default.Equals(Item2, other.Item2);
}
public override int GetHashCode()
{
int hashCode = -1030903623;
hashCode = hashCode * -1521134295 + EqualityComparer<player.altFunctionUse>.Default.GetHashCode(Item1);
hashCode = hashCode * -1521134295 + EqualityComparer<object>.Default.GetHashCode(Item2);
return hashCode;
}
public void Deconstruct(out player.altFunctionUse item1, out object item2)
{
item1 = Item1;
item2 = Item2;
}
public static implicit operator (player.altFunctionUse, object)(NewStruct1 value)
{
return (value.Item1, value.Item2);
}
public static implicit operator NewStruct1((player.altFunctionUse, object) value)
{
return new NewStruct1(value.Item1, value.Item2);
}
}
}
return base.UseItem(player, player);
}
}
}




The current problems are:

[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,23) : error CS0115: 'Crustykiller.shoot(Player, ref Vector2, ref float, ref float, ref int, ref int, ref float)': no suitable method found to override
[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(44,8) : error CS1955: Non-invocable member 'Item.buffType' cannot be used like a method.
[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(64,7) : error CS0103: The name 'player' does not exist in the current context
[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(64,29) : error CS0117: 'Main' does not contain a definition for 'MyPlayer'
[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(64,41) : error CS0103: The name 'player' does not exist in the current context
[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(66,4) : error CS0103: The name 'player' does not exist in the current context
[08:51:53] [21/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(86,15) : error CS1501: No overload for method 'UseItem' takes 2 arguments
Error: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,23) : error CS0115: 'Crustykiller.shoot(Player, ref Vector2, ref float, ref float, ref int, ref int, ref float)': no suitable method found to override
Terraria.ModLoader.Exceptions.BuildException: Compiling Zjmod1.XNA.dll failed with 13 errors and 0 warnings
Error: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,23) : error CS0115: 'Crustykiller.shoot(Player, ref Vector2, ref float, ref float, ref int, ref int, ref float)': no suitable method found to override
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(76,2) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(77,32) : error CS1519: Invalid token '!=' in class, struct, or interface member declaration
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(77,32) : error CS1519: Invalid token '!=' in class, struct, or interface member declaration
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(89,0) : error CS1022: Type or namespace definition, or end-of-file expected
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(80,23) : error CS0116: A namespace cannot directly contain members such as fields or methods
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(80,23) : error CS0115: '<invalid-global-code>.UseItem(Player)': no suitable method found to override
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,23) : error CS0246: The type or namespace name 'shoot' could not be found (are you missing a using directive or an assembly reference?)
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,40) : error CS0106: The modifier 'public' is not valid for this item
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,40) : error CS0106: The modifier 'override' is not valid for this item
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,23) : error CS0538: 'shoot.ModContent' in explicit interface declaration is not an interface
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(75,40) : error CS0501: 'Crustykiller.ProjectileType<MinionP>()' must declare a body because it is not marked abstract, extern, or partial
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(86,15) : error CS0117: 'object' does not contain a definition for 'UseItem'
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(44,8) : error CS1955: Non-invocable member 'Item.buffType' cannot be used like a method.
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(64,7) : error CS0103: The name 'player' does not exist in the current context
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(64,29) : error CS0117: 'Main' does not contain a definition for 'MyPlayer'
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(64,41) : error CS0103: The name 'player' does not exist in the current context
[08:58:49] [56/ERROR] [tML]: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(66,4) : error CS0103: The name 'player' does not exist in the current context
Error: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(76,2) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
Terraria.ModLoader.Exceptions.BuildException: Compiling Zjmod1.XNA.dll failed with 23 errors and 0 warnings
Error: C:\Users\ZJ44d\Documents\My Games\Terraria\ModLoader\Mod Sources\Zjmod1\Items\Crustykiller.cs(76,2) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
at Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, IDictionary`2 refs, Boolean xna)
at Terraria.ModLoader.Core.ModCompile.BuildModForPlatform(BuildingMod mod, Boolean xna)
at Terraria.ModLoader.Core.ModCompile.Build(BuildingMod mod)
at Terraria.ModLoader.UI.UIBuildMod.<>c__DisplayClass5_0.<Build>b__0(ModCompile mc)
at Terraria.ModLoader.UI.UIBuildMod.BuildMod(Action`1 buildAction, Boolean reload)


So uh... yeah. lots and lots of crap. I think there are probably more errors but I can't tell if they are just repeating or not.

If anyone can help me with any of these problems, (even just ONE will help!) I would greatly appreciate it. I doubt anyone would waste precious time on me considering how screwed up my code is, but I am thankful to anyone who does.

please tell me if anyone needs the minion projectile code.
 
It seems you have a lot of syntax errors. If you have an IDE, look around for red underlines, and if you don't, download Visual Studio. Then go through each error message and try to fix whatever it is, and if you can't, ask here.
 
Thanks. I actually use visual studio, but some of the errors I am having trouble fixing.
 
Look at the most basic beginner C# tutorials. This is just completely wrong, and don't randomly copy paste code, and I suggest don't pressing every code suggestion from vs/intellicode
 
Ok thanks geez... it wasn't copy and paste as much as it was learning off of a redundant outdated manuscript of github and other C# tutorials.
 
Back
Top Bottom