Project Elements
Terrarian
How do you make an item that changes the stats of all enemies in a world when used?
It's hard to say exactly what's gone wrong, but it looks like the number of animation frames in the .cs file doesn't match the actual number of frames in the .png file.Hey all, I'm making a town NPC and I have some animation bugs. I adapted animations of my NPC to the guide's animations but something weird happens when the NPC is walking or doing emotes.
Video
animation frames:
I don't have alt textures, maybe that causes the problem?
I'm new to modding, here is my code hastebinIt's hard to say exactly what's gone wrong, but it looks like the number of animation frames in the .cs file doesn't match the actual number of frames in the .png file.
What do you have in Main.npcFrameCount[npc.type] = ??; and how many are in the image?
Edit: huh, the image didn't load until after I replied. I can see that you have 27 frames. What does it say in the .cs file?
Edit 2: I've had a closer look at your image, and it looks like you've duplicated the last frame of his walk. Removing that frame may work, as long as you also set Main.npcFrameCount[npc.type] to 26.
Yeah, you've got 26 as your number of frames, when your image has 27. I can also see that for ExtraFramesCount you have 9. I haven't played around with that number on NPCs, but I think that that is the number of frames after the walk cycle, and both the Guide and your image has 10. You could try changing that if you still have issues after removing that frame.
I think it fully fixed it, it still has some problems but I think it has something to do with my drawing. I probably drew some of the frames bigger than others. Also, I accidentally drew the whole thing smaller than it should (my image was 24x900, and I think it should be 40x1456) so I just amplified it in photoshop. That's why it looks blurry lol. I'll try to fix my drawing. Thank you so muchYeah, you've got 26 as your number of frames, when your image has 27. I can also see that for ExtraFramesCount you have 9. I haven't played around with that number on NPCs, but I think that that is the number of frames after the walk cycle, and both the Guide and your image has 10. You could try changing that if you still have issues after removing that frame.
In the code for when the bomb explodes, loop through Main.player and see if any of the players are within some radius of the centre of the projectile, if they are thenHey all, I want to make a bomb that will heal players if they are in the explosion zone, I'm new to modding & c# so I don't know how can I do it. Can anyone help me? (If there is a tutorial for this, I'd gladly check it out too)
hastebin here is my code
player.statLife += healAmount; // Gives Health
player.HealEffect(healAmount, true); // Healing effect
Value cannot be null.
Parameter name: document
System.ArgumentNullException: Value cannot be null.
Parameter name: document
at Mono.Cecil.Cil.SequencePoint..ctor (Int32 offset, Document document) [0x00009] in data-0x7fc992019010
at Mono.Cecil.SignatureReader.ReadSequencePoints (Document document) [0x000f9] in data-0x7fc992019010
at Mono.Cecil.MetadataReader.ReadSequencePoints (MethodDefinition method) [0x0004e] in data-0x7fc992019010
at Mono.Cecil.Cil.PortablePdbReader.ReadSequencePoints (MethodDebugInformation method_info) [0x00000] in data-0x7fc992019010
at Mono.Cecil.Cil.PortablePdbReader.Read (MethodDefinition method) [0x00007] in data-0x7fc992019010
at Mono.Cecil.ImmediateModuleReader.ReadMethodsSymbols (TypeDefinition type, ISymbolReader symbol_reader) [0x0003d] in data-0x7fc992019010
at Mono.Cecil.ImmediateModuleReader.ReadTypesSymbols (Collection[T] types, ISymbolReader symbol_reader) [0x00029] in data-0x7fc992019010
at Mono.Cecil.ImmediateModuleReader.ReadTypesSymbols (Collection[T] types, ISymbolReader symbol_reader) [0x0001b] in data-0x7fc992019010
at Mono.Cecil.ImmediateModuleReader.ReadSymbols (ModuleDefinition module) [0x00010] in data-0x7fc992019010
at Mono.Cecil.ModuleWriter.Write (ModuleDefinition module, Disposable[T] stream, WriterParameters parameters) [0x00039] in data-0x7fc992019010
at Mono.Cecil.ModuleWriter.WriteModule (ModuleDefinition module, Disposable[T] stream, WriterParameters parameters) [0x00002] in data-0x7fc992019010
at Mono.Cecil.ModuleDefinition.Write (String fileName, WriterParameters parameters) [0x00017] in data-0x7fc992019010
at Mono.Cecil.AssemblyDefinition.Write (String fileName, WriterParameters parameters) [0x00000] in data-0x7fc992019010
at Terraria.ModLoader.Core.ModCompile.BuildModForPlatform (BuildingMod mod, Boolean xna) [0x0025d] in tModLoader.exe
at Terraria.ModLoader.Core.ModCompile.Build (BuildingMod mod) [0x000d0] in tModLoader.exe
at Terraria.ModLoader.Core.ModCompile.Build (String modFolder) [0x00008] in tModLoader.exe
at Terraria.ModLoader.UI.UIBuildMod+<>c__DisplayClass5_0.<Build>b__0 (ModCompile mc) [0x00000] in tModLoader.exe
at Terraria.ModLoader.UI.UIBuildMod.BuildMod (Action[T] buildAction, Boolean reload) [0x0003a] in tModLoader.exe
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace TestMod.Items
{
public class DemonSword : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("DemonSword"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Sword made from the core of hell.");
}
public override void SetDefaults()
{
item.damage = 5000;
item.melee = true;
item.width = 400;
item.height = 400;
item.useTime = 2;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 600;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = 187;
item.shoot = 188;
item.shoot = 15;
item.shootSpeed = 20f;
}
virtual void Terraria.ModLoader.ModItem.HoldItem(Player player)
{
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
well I used virtual void Terraria.ModLoader.ModItem.HoldItem(Player player) because it was listed on so how else would I make things happen when a player is holding my sword?its only public or private void in c#
In the documentation, HoldItem is in the public member functions list.well I used virtual void Terraria.ModLoader.ModItem.HoldItem(Player player) because it was listed on so how else would I make things happen when a player is holding my sword?
public virtual void HoldItem(Player p) {
// Do stuff here
}