• Labor of Love is here! Visit our Labor of Love thread for a special message from the team, a look at brand new Labor of Love merch, and the changelog (minus a few surprises 😉)

Standalone [1.3] tModLoader - A Modding API

NightmareSans

Terrarian
Hello guys! Can someone tell all the DustName's that is used in melee weapons (example the Excalibur's golden dust even its used) for the mod i making? Because im struggling with it! pls help
 

Dan Yami

Empress of Light
um, i still dont know the code how to make the sprite...
pls put it into my code...
(srry, this is the thing im not very good at, FINDING stuff ._.)

Code:
using Terraria;
using Terraria.ModLoader;
using SacredTools.NPCs;

namespace SacredTools.Buffs
{
    public class PandolarBuff : ModBuff
    {
        public override void SetDefaults()
        {
            Main.buffName[Type] = "Blessing of the Pandolars";
            Main.buffTip[Type] = "the almighty Pandolars gave you a blessing...";
            Main.debuff[Type] = false;
            Main.pvpBuff[Type] = true;
            Main.buffNoSave[Type] = true;
            longerExpertDebuff = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            player.lifeRegen += 2;
            player.statLifeMax2 += 50;
            player.magicDamage += 0.15f;
            player.meleeDamage += 0.15f;
            player.rangedDamage += 0.15f;
            player.thrownDamage += 0.15f;
            player.minionDamage += 0.15f;
       
            //Example:
            if (Main.rand.Next(2) == 0)
            {
                int idx= Dust.NewDust(player.position, player.width, player.height, mod.DustType("PandolarDust"));
                Main.dust[idx].noGravity = true;
            }
        }

       
    }
}

the file name for the Sprite is PandolarGod.png and its in the Buffs folder (or does it need to be somewhere else?)
 

Snrasha

Terrarian
um, i still dont know the code how to make the sprite...
pls put it into my code...
(srry, this is the thing im not very good at, FINDING stuff ._.)

Code:
using Terraria;
using Terraria.ModLoader;
using SacredTools.NPCs;

namespace SacredTools.Buffs
{
    public class PandolarBuff : ModBuff
    {
        public override void SetDefaults()
        {
            Main.buffName[Type] = "Blessing of the Pandolars";
            Main.buffTip[Type] = "the almighty Pandolars gave you a blessing...";
            Main.debuff[Type] = false;
            Main.pvpBuff[Type] = true;
            Main.buffNoSave[Type] = true;
            longerExpertDebuff = false;
        }

        public override void Update(Player player, ref int buffIndex)
        {
            player.lifeRegen += 2;
            player.statLifeMax2 += 50;
            player.magicDamage += 0.15f;
            player.meleeDamage += 0.15f;
            player.rangedDamage += 0.15f;
            player.thrownDamage += 0.15f;
            player.minionDamage += 0.15f;

            //Example:
            if (Main.rand.Next(2) == 0)
            {
                int idx= Dust.NewDust(player.position, player.width, player.height, mod.DustType("PandolarDust"));
                Main.dust[idx].noGravity = true;
            }
        }


    }
}

the file name for the Sprite is PandolarGod.png and its in the Buffs folder (or does it need to be somewhere else?)

You need add here a bool like buff Undead.
Then, you go in your modplayer for add this same bool everywhere you found Undead bool in ExamplePlayer
Then, you change MiscEffects where you add your sprite and also, change the position of your sprite.
This is simple, i do not need give the code because all code is in the examplemod.

edit: sorry for my word, i go very fast angry ><

............HELP I cant go to Terrarai it not letting me ???

It keep saying go to steam client but I do that and it still NOT working ;-; HELP!!!!
I do not understand your question.

Heyo, I have a question.
Do I have to create a new map every time I install a mod? ( Talking about the ores and so on )
Thanks
If the mod include ores when you generate the world, yes, you need.
 
Last edited:

Joost8910

Dungeon Spirit
How do I make a custom animation for an NPC? I've seen @bluemagic123 say to use FindFrame, but how do I use it?

EDIT: I found out how:
Code:
public override void FindFrame(int frameHeight)
{
npc.frameCounter++;
if (npc.frameCounter >= ##) // Height of frame in pixels
{
npc.frame.Y = (npc.frame.Y + 50);
npc.frameCounter = 0;
}
if (npc.frame.Y >= ###) // the pixel number from top of png of where to end the animation loop
{
npc.frame.Y = 0;
}
}
 
Last edited:

DoYouEvenCookie

Terrarian
I am trying to make a gun that turns any bullet into a custom shot, not just musket balls, and I tried
Code:
 public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref int knockback)
{
            if (type == ProjectileID.Bullet)
            {
                type = mod.ProjectileType("Blast");
            }
            return true;
}

but there was an error that said
'no suitable method found to override'
and referred to the first line of code above

help pls
 

pat1231

Spazmatism
can someone pls show/give me the codes needed to make my accesory like cobalt shield and medicated bandage? I dont know how to get the codes by myself
 

jopojelly

Retinazer
tModLoader
I am trying to make a gun that turns any bullet into a custom shot, not just musket balls, and I tried
Code:
 public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref int knockback)
{
            if (type == ProjectileID.Bullet)
            {
                type = mod.ProjectileType("Blast");
            }
            return true;
}

but there was an error that said
'no suitable method found to override'
and referred to the first line of code above

help pls
Knock back is a float
 

64BTX

Official Terrarian
To backup the "vanilla Terraria.exe," do you just only copy Terraria.exe to a backup folder? Or everything in Terraria's Steam folder?
 

Solo-Ion

Dungeon Spirit
In my experience, Main.NewText itself should be called on the server (same as when the server displays the chat input of every player).
So if this is never called on the server, my guess is that it never reaches the server(?).
Calling Main.NewText on a server only won't have any effect because the server has no chat to output to, only the console lines. There are ways to output to the chat from a server: use a NetMessage. I tried the following in the AI of a projectile:
NetMessage.SendData(25, -1, -1, "AI", 255, 175f, 75f, 199f, 0, 0, 0);
And the text "AI" was correctly output to the chat, but the same line in several item hooks had no effect whatsoever. I even downloaded an older version of my mod that I know was working, and now one item that is dependant on useItem being called on the server no longer works.

There may be a workaround for this, but it's annoying if this is just the way that tModLoader works now.

EDIT: Ok, after some rebuilding and connecting to my server from another PC, these hooks have inexplicably started working as normal again. No idea how, but I'm not complaining.
 
Last edited:

Snrasha

Terrarian
ExampleMod => NPCs => ExampleGlobalNPC => public override void NPCLoot(NPC npc) =>
Code:
            if (npc.type == NPCID.DukeFishron && !Main.expertMode)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Bubble"), Main.rand.Next(5, 8));
            }
 
Last edited:
Top Bottom