tModLoader Official tModLoader Help Thread

Well .... I am using my mage/ranger character for that and now I accidentally hit NPC with pickaxe and it is working ... only with melee weapons is there anything I can switch it for all kind of weapons ? It wont work with magic/ranged weapons or even with projectiles which are releasing from melee weapons. My bad that I didnt check this before but I didnt expect that it is gona be locked just for melee weapons.
Next to the OnHitNPC method, you'll want to do the same with the OnHitNPCWithProj method.
 
Hello , i want to make item that will be consumed and give player permament effect and the effect can be disabled by using another item but i dont know how can i make it ... :rolleyes:
 
Hello , i want to make item that will be consumed and give player permament effect and the effect can be disabled by using another item but i dont know how can i make it ... :rolleyes:
I'm assuming you mean like a permanent buff? If so, in one of your ModPlayers' update methods, check if that buff is active and if it is, extend its time.
Then when using the other item you can just remove the buff using the ClearBuff method.
 
I'm assuming you mean like a permanent buff? If so, in one of your ModPlayers' update methods, check if that buff is active and if it is, extend its time.
Then when using the other item you can just remove the buff using the ClearBuff method.
hi i want it to make it like in weapon out when u consumed the *insert any item here* it give you permament effect and the effect can be disabled at any time by using *insert any item here* , i dont understand that how to do it, if it will be possible could u send me Example code of this
 
hi i want it to make it like in weapon out when u consumed the *insert any item here* it give you permament effect and the effect can be disabled at any time by using *insert any item here* , i dont understand that how to do it, if it will be possible could u send me Example code of this
On your item, specify the buff it gives.
Code:
item.buffType = mod.BuffType("MyModBuff");
item.buffTime = 60;
Then in the buff code do the following:
Code:
public override void Update(Player player, ref int buffIndex)
{
    player.buffTime[buffIndex] = 60; // Will make sure the buff doesn't go away.
    player.GetModPlayer<MyModPlayer>().myBuffActive = true;
}
As you can see, we're accessing a ModPlayer there, so in your ModPlayer class:
Code:
public bool myBuffActive;
public override void ResetEffects()
{
    myBuffActive = false; // If we don't do this, the buff effects will persist after the buff is gone.
}
And then you can do anything just by checking against
Code:
if (myBuffActive == true)
{
    // Blablabla
}

Hope that helps.
 
On your item, specify the buff it gives.
Code:
item.buffType = mod.BuffType("MyModBuff");
item.buffTime = 60;
Then in the buff code do the following:
Code:
public override void Update(Player player, ref int buffIndex)
{
    player.buffTime[buffIndex] = 60; // Will make sure the buff doesn't go away.
    player.GetModPlayer<MyModPlayer>().myBuffActive = true;
}
As you can see, we're accessing a ModPlayer there, so in your ModPlayer class:
Code:
public bool myBuffActive;
public override void ResetEffects()
{
    myBuffActive = false; // If we don't do this, the buff effects will persist after the buff is gone.
}
And then you can do anything just by checking against
Code:
if (myBuffActive == true)
{
    // Blablabla
}

Hope that helps.
thanks alot i understand now :)
 
Hi, i need help i get an error CS1002, im new to mods and sorry for bad english.

using Terraria.ID;
using Terraria.ModLoader;

namespace RivenBlade.Items
{
public class RivenBlade : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Riven Blade");
Tooltip.SetDefault("The time for talk is over.");
}
public override void SetDefaults()
{
item.name = "Riven Blade";
item.damage = 25000;
item.melee = true;
item.width = 100;
item.height = 100;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 10;
item.value = 10, 0, 0, 0;
item.rare = 11;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.useTurn = true;
item.crit = 50;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
Hi, i need help i get an error CS1002, im new to mods and sorry for bad english.

using Terraria.ID;
using Terraria.ModLoader;

namespace RivenBlade.Items
{
public class RivenBlade : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Riven Blade");
Tooltip.SetDefault("The time for talk is over.");
}
public override void SetDefaults()
{
item.name = "Riven Blade";
item.damage = 25000;
item.melee = true;
item.width = 100;
item.height = 100;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 10;
item.value = 10, 0, 0, 0;
item.rare = 11;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.useTurn = true;
item.crit = 50;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
You've got the following line in your code:
Code:
item.value = 10, 0, 0, 0;
This is not how you want to set this variable. If you want it to be worth one silver coin, set it to 100 (100 copper coins = 1 silver). If you want it to be worth 1 platinum coin, set it to 1000000 (one platinum in bronze coins).
 
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ItemsBuffs
{
    internal sealed class ItemsBuffsGlobalTile : GlobalTile
    {
        public override bool Drop(int i, int j, int type)
        {
            if (type == 31)
            {
                Item.NewItem(i * 16, j * 16, 32, 32, mod.ItemType("ModItemName"));
            }
            return true;
        }
    }
}
i want to make a shadow orb/crimson heart what i break to only drop one item at time but i dont know how :( it drops instead 5
 
Hello, can someone just write out lines of code for me? I'm trying to do "if" statements...
So if a player were to have "BuffA" active, npcs would have "BuffB" applied... if possible only hostile(to the player) npcs.
 
Hello, I get this error when loading mod loader https://i.imgur.com/mgbNCw0.png I have installed/repaired/removed/reinstalled the xna frame work 4.0 a few times. Terraria works just fine. If I deleted everything in my ModLoader folder and run everything again for the first time it works, but when I quit and retry it crashes with this message every time.
 
I got this error after i installed the mod, i tried everything: reinstall the game, reinstall the mod. Anothing thing i noticed is that even when i updated my game to 1.3.5.3, when i installed the mod and play it, it said at the bottom left of the screen was version 1.5.3.2.
Untitled.png
 
I have the error as quoted:

c:\Users\mchad\OneDrive\Documents\My Games\ModLoader\Mod Sources\CythersBanes\Items|Rithus.cs(6,15) :error CS0101: The namespace 'Cytherbanes.Items' already contains a definition for 'Replace'

This is my code:

1 using Terraria.ID;
2 using Terraria.ModLoader;
3
4 Namespace cyhtersbanes.Items
5 {
6 public class replace : Moditem
7 {


if anyone could reply asap that would be helpfull
 
I have the error as quoted:

c:\Users\mchad\OneDrive\Documents\My Games\ModLoader\Mod Sources\CythersBanes\Items|Rithus.cs(6,15) :error CS0101: The namespace 'Cytherbanes.Items' already contains a definition for 'Replace'

This is my code:

1 using Terraria.ID;
2 using Terraria.ModLoader;
3
4 Namespace cyhtersbanes.Items
5 {
6 public class replace : Moditem
7 {


if anyone could reply asap that would be helpfull
I don't see why you would find that error there. One thing you'll want to change for sure is change `Moditem` to `ModItem`.
 
I have the error as quoted:

c:\Users\mchad\OneDrive\Documents\My Games\ModLoader\Mod Sources\CythersBanes\Items|Rithus.cs(6,15) :error CS0101: The namespace 'Cytherbanes.Items' already contains a definition for 'Replace'

This is my code:

1 using Terraria.ID;
2 using Terraria.ModLoader;
3
4 Namespace cyhtersbanes.Items
5 {
6 public class replace : Moditem
7 {


if anyone could reply asap that would be helpfull
Somewhere else in your mod’s files, there’s another file containing this line:
Code:
public class replace : ModItem
Change ‘replace’ to something else (like Rithus) and that should fix it.
 
Hiya Folks, is there a way to adjust max frames of animation for a default npc? Say, the wraith's standard 4 frames of animation into 26 frames if you were to custom make extra for it?

I've tried "NPCID.Sets.ExtraFramesCount[NPCID.Wraith] = 12;"
not sure what it did, but I assume this line isn't for animation frames

As for this line, "Main.npcFrameCount[npc.type] = 12;"
I can adjust fine. However, I have it set as 12 as it's the amount of frames I currently have, and going any lower than 12 duplicates the npc (Having a floating version above it), while having this number at 6 has all of the frames I've made being used. I've tried adjusting the sprite sheets many times, so I do believe it has nothing to do with that.

Summary: My goal is to have all 12 frames play correctly, (I already have them looping) and not have a duplicate of the npc showing up above the base.
Thanks for any suggestions :)
 
Hiya Folks, is there a way to adjust max frames of animation for a default npc? Say, the wraith's standard 4 frames of animation into 26 frames if you were to custom make extra for it?

I've tried "NPCID.Sets.ExtraFramesCount[NPCID.Wraith] = 12;"
not sure what it did, but I assume this line isn't for animation frames

As for this line, "Main.npcFrameCount[npc.type] = 12;"
I can adjust fine. However, I have it set as 12 as it's the amount of frames I currently have, and going any lower than 12 duplicates the npc (Having a floating version above it), while having this number at 6 has all of the frames I've made being used. I've tried adjusting the sprite sheets many times, so I do believe it has nothing to do with that.

Summary: My goal is to have all 12 frames play correctly, (I already have them looping) and not have a duplicate of the npc showing up above the base.
Thanks for any suggestions :)
What is the problem? You said that setting it to 12 works and loops correctly with no floating version.
[doublepost=1540597296,1540596995][/doublepost]As a reminder to everyone asking code questions here, you'll find the most help if you ask in our Discord chat as very few experienced modders visit this forum/thread to help with programming questions: discord.me/tModloader
 
What is the problem? You said that setting it to 12 works and loops correctly with no floating version.
[doublepost=1540597296,1540596995][/doublepost]As a reminder to everyone asking code questions here, you'll find the most help if you ask in our Discord chat as very few experienced modders visit this forum/thread to help with programming questions: discord.me/tModloader

What worked with 12 was it having no duplicate copy; When I set it to 6 is when the full animation ran. That version was the one with the duplicate
No numbers in between worked correctly, as 12 was the one I said is the first without a duplicate. Going any higher makes the sprite shrink into itself

Edit: What I'm starting to think may be the case (In terms of fixing the sprite itself) is adding more static layers as to smooth out the transition between frames. As for code, I would try any suggestions
 
It should still loop with 12, not sure what is up.

With changing vanilla npc animation, you need to make sure FindFrame is correct. If not, you'd need to adjust the animation logic in GlobalNPC.FindFrame.

Luckily for you, the logic seems to just loop using the npcFrameCount, so I don't think you actually need to change anything.

Here is that code just for your information:
Code:
            else if (this.type == 48 || this.type == 49 || this.type == 51 || this.type == 60 || this.type == 82 || this.type == 93 || this.type == 137 || this.type == 182 || this.type == 210 || this.type == 211 || this.type == 253 || this.type == 316)
            {
                if (this.velocity.X > 0f)
                {
                    this.spriteDirection = 1;
                }
                if (this.velocity.X < 0f)
                {
                    this.spriteDirection = -1;
                }
                this.rotation = this.velocity.X * 0.1f;
                if (this.type == 210 || this.type == 211)
                {
                    this.frameCounter += 1.0;
                    this.rotation = this.velocity.X * 0.2f;
                }
                this.frameCounter += 1.0;
                if (this.frameCounter >= 6.0)
                {
                    this.frame.Y = this.frame.Y + num;
                    this.frameCounter = 0.0;
                }
                if (this.frame.Y >= num * Main.npcFrameCount[this.type])
                {
                    this.frame.Y = 0;
                }
            }
 
So what do I do if I haven't backed up vanilla? is it too late to do anything or is there a way I can get it back (just in case)?
 
Back
Top Bottom