Standalone [1.3] tModLoader - A Modding API

You'll probably want to do:
Code:
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
    Player player = Main.player[projectile.owner];
    player.statLife += 2; //10 is the heal amount
    player.HealEffect(10);
}
It works! Thank you so much!
 
OK, now I have a new problem: I can access the Main.playerDrawInfo information for my armor, but changing it doesn't do anything. Where would I have to edit the information so that it occurs pre-draw?
 
I've been trying to achieve an "explosion" effect around the player, and I figured the best way to do this would be to spawn dust particles around them. However, (and I'm sure this is stupid of me) I can't for the life of me figure out how to spawn more than one particle using Dust.NewDust
Surely there's a way to do it without using tons of instances of Dust.NewDust, right?
 
I've been trying to achieve an "explosion" effect around the player, and I figured the best way to do this would be to spawn dust particles around them. However, (and I'm sure this is stupid of me) I can't for the life of me figure out how to spawn more than one particle using Dust.NewDust
Surely there's a way to do it without using tons of instances of Dust.NewDust, right?
You can use a for loop for this kind of stuff. Ex:
Code:
for(int i = 0; i < 5; ++i)
{
    // This will trigger 5 times in one update.
}
Think you can work with that?
 
How can I make an ore spawn when a boss is killed?
I would've searched for it but ore is too short
 
How can I make an ore spawn when a boss is killed?
I would've searched for it but ore is too short
I picked this code up somewhere along the way.
Call this method when your boss dies:
Code:
private void SpawnOre()
{
    int minX = 200;
    int maxX = Main.maxTilesX - 200;
    int minY = (int)Main.worldSurface;
    int maxY = Main.maxTilesY - 200;

    int x = WorldGen.genRand.Next(minX, maxX);
    int y = WorldGen.genRand.Next(minY, maxY);

    int minSpread = 2;
    int maxSpread = 8;

    int minFreq = 6;
    int maxFreq = 8;

    int s = WorldGen.genRand.Next(minSpread, maxSpread + 1);
    int f = WorldGen.genRand.Next(minFreq, maxFreq + 1);

    for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
    {
        WorldGen.OreRunner(x, y, s, f, (ushort)mod.TileType("MyModOre"));
    }
}
 
On Tmodloader's current state for multiplayer, is it normal for the server to lag a lot every 3 or 5 minutes for the other players?

The host connection is fine and on his end so is the server (other than blocks broken by the other players not being pickable for a while)

Is there anyway to fix this at all, as it seems connection is OK on all ends.

Edit: Also the "start-tModLoaderServer-steam-friends" file from the latest version doesn't open at all here, so I'm using the .11 version, simply because it works. (In case it is that)
 
Last edited:
I think something might be wrong with my game? When I started it up just now it said my game had crashed. I hit okay and it seemed fine. Then when I try to open the mod browser it locks up. Sometimes it'll go through but then downloading a mod takes AGES compared to how fast it should be going. Is this a bug or something?
 

Code:
public override void NPCLoot()
        {
            if (Main.rand.Next(4) == 3)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("irrelevant"));
            }
            if (Main.rand.Next(4) == 2)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("irrelevant"));
            }
            if (Main.rand.Next(4) == 1)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("irrelevant"));
            }
           
            if (Main.expertMode)
            {
                npc.DropBossBags();
            }
           
            private void SpawnOre()
            {
                int minX = 200;
                int maxX = Main.maxTilesX - 200;
                int minY = (int)Main.worldSurface;
                int maxY = Main.maxTilesY - 200;

                int x = WorldGen.genRand.Next(minX, maxX);
                int y = WorldGen.genRand.Next(minY, maxY);

                int minSpread = 2;
                int maxSpread = 8;

                int minFreq = 6;
                int maxFreq = 8;

                int s = WorldGen.genRand.Next(minSpread, maxSpread + 1);
                int f = WorldGen.genRand.Next(minFreq, maxFreq + 1);

                for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                {
                    WorldGen.OreRunner(x, y, s, f, (ushort)mod.TileType("OreName"));
                }
            }
        }
Probably missing something really obvious here, but it says (61,5) error CS1513: } expected, but there's a } on line 61 so I'm confused
 
Code:
public override void NPCLoot()
        {
            if (Main.rand.Next(4) == 3)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("irrelevant"));
            }
            if (Main.rand.Next(4) == 2)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("irrelevant"));
            }
            if (Main.rand.Next(4) == 1)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("irrelevant"));
            }
          
            if (Main.expertMode)
            {
                npc.DropBossBags();
            }
          
            private void SpawnOre()
            {
                int minX = 200;
                int maxX = Main.maxTilesX - 200;
                int minY = (int)Main.worldSurface;
                int maxY = Main.maxTilesY - 200;

                int x = WorldGen.genRand.Next(minX, maxX);
                int y = WorldGen.genRand.Next(minY, maxY);

                int minSpread = 2;
                int maxSpread = 8;

                int minFreq = 6;
                int maxFreq = 8;

                int s = WorldGen.genRand.Next(minSpread, maxSpread + 1);
                int f = WorldGen.genRand.Next(minFreq, maxFreq + 1);

                for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                {
                    WorldGen.OreRunner(x, y, s, f, (ushort)mod.TileType("OreName"));
                }
            }
        }
Probably missing something really obvious here, but it says (61,5) error CS1513: } expected, but there's a } on line 61 so I'm confused
SpawnOre is a method and should be treated as such, meaning that you do not want to put the whole method itself in the NPCLoot function, just a call to it.
Move the SpawnOre outside the NPCLoot method, but inside your NPC class and call 'SpawnOre();' in the NPCLoot method instead.
 
SpawnOre is a method and should be treated as such, meaning that you do not want to put the whole method itself in the NPCLoot function, just a call to it.
Move the SpawnOre outside the NPCLoot method, but inside your NPC class and call 'SpawnOre();' in the NPCLoot method instead.
Alright, thanks, it spawns now, but at a ridiculous rarity. After shredding up a small world with the drill mount, I found one vein of ore. I killed the boss about 20+ times, but my guess would be it is only spawning one vein per kill, judging from the rarity.
 
Alright, thanks, it spawns now, but at a ridiculous rarity. After shredding up a small world with the drill mount, I found one vein of ore. I killed the boss about 20+ times, but my guess would be it is only spawning one vein per kill, judging from the rarity.
Hmmm, instead of OreRunner, you could also try using TileRunner:
Code:
WorldGen.TileRunner(x, y, s, f, mod.TileType("MyOre"), false, 0f, 0f, false, true);
 
Hmmm, instead of OreRunner, you could also try using TileRunner:
Code:
WorldGen.TileRunner(x, y, s, f, mod.TileType("MyOre"), false, 0f, 0f, false, true);
That appears to be the same, but quick question, does the max/min stuff at the top confine it between certain X and Y values?

On a side note, how do I get custom boss music to work?
 
That appears to be the same, but quick question, does the max/min stuff at the top confine it between certain X and Y values?

On a side note, how do I get custom boss music to work?
Yes, it does. The X coordinate makes sure the ore vein is not spawned in the Ocean biome and the Y makes sure it's no spawned in hell.
 
That appears to be the same, but quick question, does the max/min stuff at the top confine it between certain X and Y values?

On a side note, how do I get custom boss music to work?
hey Iriazul, new question, how do you edit the drops of an existing boss, i want to add in the "OneRing" item as a drop from Golem(vanilla boss id 249), an ideas?
 
hey Iriazul, new question, how do you edit the drops of an existing boss, i want to add in the "OneRing" item as a drop from Golem(vanilla boss id 249), an ideas?
You'll want to use the GlobalNPC class for that. Ex:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MyMod.NPCs
{
    public class MyGlobalNPC : GlobalNPC
    {
        public override void NPCLoot(NPC npc)
        {
            if(npc.type == NPCID.Golem)
            {
                 // Drop your item here.
            }
        }
    }
}
 
IT DIDNT WORK!!!!!
:'(
[doublepost=1465779018,1465778948][/doublepost]
Everytime i have to download Tmodloader again and again because i can only play it once then when i try to play a second time it says:


System.DllNotFoundException: Unable to load DLL 'CSteamworks': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Steamworks.NativeMethods.SteamAPI_RestartAppIfNecessary(AppId_t unOwnAppID)
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args)



WHAT SHOULD I DO!!!!!!

IT DIDNT WORK :'(
 
so i want to add it into Golems Drop table, he has 8 items, each with a 12.5% chance of dropping, how do i make all those items,Stynger,Possessed Hatchet,Sun Stone,Eye of the Golem,Picksaw, Heat Ray,Staff of Earth, Golem Fist, and my item OneRing, all have an 11% drop rate
For that you'll want to override all vanilla dropping and use PreNPCLoot instead. Ex:
Code:
public override bool PreNPCLoot(NPC npc)
{
    int rand = Main.rand.Next(0, 9);

    if(rand == 0)
        // Drop item 1
    else if (rand == 1)
        // Drop item 2
    // Etc etc, untill you reach 8, where you drop your own item.

    return false;
}
 
Back
Top Bottom