tModLoader Official tModLoader Help Thread

Thank you so much, that seemed to fix it. Now all I need to worry about is the sprite offset because that is heckin wonky at the moment.
 
hi, does anyone know an open source mod with different weapons
I can't find up-to-date guides for creating various projectiles
most mod authors block access and it is very difficult to find a good reference
 
hi, does anyone know an open source mod with different weapons
I can't find up-to-date guides for creating various projectiles
most mod authors block access and it is very difficult to find a good reference

the " Projectile Guide and Implementation " thread is very helpful for projectiles, there will be a lot of reading but its really helpfull

and the tModLoader ExampleMod on git hub has things like enemies and weapons and its showes all code
 
I'm trying to figure out how to add crit chance increases to an armor set I've tried player.Crit += x% however I don't know if it will exactly work
 
I'm having an issue with my code for armor more so with the line that says that when you equip it you gain stat bonuses
this is my code
public override void UpdateEquip(Player player) {
player.buffImmune[BuffID.Bleeding] = true;
player.thrownDamage += 2f;
}
and when I start to build my mod in the mod sources section it states that my mod failed to build with the term of 'Player" not being able to be found
any help at all would be nice
 
I'm having an issue with my code for armor more so with the line that says that when you equip it you gain stat bonuses
this is my code
public override void UpdateEquip(Player player) {
player.buffImmune[BuffID.Bleeding] = true;
player.thrownDamage += 2f;
}
and when I start to build my mod in the mod sources section it states that my mod failed to build with the term of 'Player" not being able to be found
any help at all would be nice

could you post the full code of the armor? it may be a problem somewhere else
 
I'm having an issue with my code for armor more so with the line that says that when you equip it you gain stat bonuses
this is my code
public override void UpdateEquip(Player player) {
player.buffImmune[BuffID.Bleeding] = true;
player.thrownDamage += 2f;
}
and when I start to build my mod in the mod sources section it states that my mod failed to build with the term of 'Player" not being able to be found
any help at all would be nice

use this



public override void SetStaticDefaults() {
Tooltip.SetDefault(" adds throwing damage ");

you can change what it says. i dont know how to make it only show up when you have all the armor set equipted. so it will show up on the piece you put the code on
 
use this



public override void SetStaticDefaults() {
Tooltip.SetDefault(" adds throwing damage ");

you can change what it says. i dont know how to make it only show up when you have all the armor set equipted. so it will show up on the piece you put the code on
I realised it was because I forgot to put using Terraria at the top
 
i'm trying to make a consumable waffle item that gives you the well fed buff, please provide me with the holy waffle code
 
i'm trying to make a consumable waffle item that gives you the well fed buff, please provide me with the holy waffle code

using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Modding2.Items.Buffs
{
public class Waffle : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("holy Waffle");
Tooltip.SetDefault("Grants WellFed Buff");
}
public override void SetDefaults()
{

item.width = 12;
item.height = 26;
item.maxStack = 99;

item.value = 500;
item.rare = 3;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}

public override bool UseItem(Player player)
{
player.AddBuff(BuffID.WellFed, 7200); // this about 1 minute

return true;

}
}
}


you will have to change some stuff around to fit your mod
 
How would I go about increasing the swing style by 1 with every swing, then resetting it after the style = 3? This is the code I have so far, with no luck, any help would be greatly appreciated

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace testMod.Items
{
public class whyNot : ModItem
{
public int swing;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("chonkSword"); // 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("This is a basic modded sword.");
}

public override void SetDefaults()
{
item.damage = 2140;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 30;
item.useAnimation = 20;
item.useStyle = swing;
item.knockBack = 90;
item.value = 10000;
item.rare = ItemRarityID.Cyan;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override bool UseItem(Player player)
{
swing = swing + 1;
if (swing > 3)
{
swing = 0;
}
return true;
}
}
}
 
How would I go about increasing the swing style by 1 with every swing, then resetting it after the style = 3? This is the code I have so far, with no luck, any help would be greatly appreciated

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace testMod.Items
{
public class whyNot : ModItem
{
public int swing;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("chonkSword"); // 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("This is a basic modded sword.");
}

public override void SetDefaults()
{
item.damage = 2140;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 30;
item.useAnimation = 20;
item.useStyle = swing;
item.knockBack = 90;
item.value = 10000;
item.rare = ItemRarityID.Cyan;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override bool UseItem(Player player)
{
swing = swing + 1;
if (swing > 3)
{
swing = 0;
}
return true;
}
}
}
I'm not certain, but I think you would need to update item.useStyle directly. The SetDefault hook is only called once, so changing swing has no impact during gameplay.
 
I'm not certain, but I think you would need to update item.useStyle directly. The SetDefault hook is only called once, so changing swing has no impact during gameplay.
So how would I go about that? I'd assume I would want to change that using the UseItem bool, but I can't figure out how I'd go about doing this
 
IDK if be real, but here is the first way:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace testMod.Items
{
    public class whyNot : ModItem
    {
        public int swing = 0;
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("chonkSword");
            Tooltip.SetDefault("This is not basic modded sword.");
        }

        public override void SetDefaults()
        {
            item.damage = 2140;
            item.melee = true;
            item.width = 40;
            item.height = 40;
            item.useTime = 30;
            item.useAnimation = 20;
            item.useStyle = swing;
            item.knockBack = 90;
            item.value = 10000;
            item.rare = ItemRarityID.Cyan;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
        public override bool UseItem(Player player)
        {
            swing += 1;
            if (swing > 3) swing = 0;
            return true; //using weapon after setting
        }
    }
}
And the second way:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace testMod.Items
{
    public class whyNot : ModItem
    {
        public int swing = 0;
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("chonkSword");
            Tooltip.SetDefault("This is not basic modded sword.");
        }

        public override void SetDefaults()
        {
            item.damage = 2140;
            item.melee = true;
            item.width = 40;
            item.height = 40;
            item.useTime = 30;
            item.useAnimation = 20;
            item.useStyle = 0; //that's standard swing (on start)
            item.knockBack = 90;
            item.value = 10000;
            item.rare = ItemRarityID.Cyan;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
        public override bool UseItem(Player player)
        {
            swing += 1;
            if (swing > 3) swing = 0;
            item.useStyle = swing; //changing swing right from there
            return true; //using weapon
        }
    }
}
Quote this post if you will have compile (send screen of error, but try to fix it yourself if possible) / in-game error (describe it and send video if possible).
 
Back
Top Bottom