Standalone [1.3] tModLoader - A Modding API

I have 7777 port-fowarded, but it still isn't working. Help?
 
Hey guys!
So I'm trying to make a projectile spawn more projectiles on death, but when the projectile is "killed" nothing happens. Here is my script so far, and as you can probably tell I'm a massive C# scrub.
public override void Kill(int timeLeft)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("EtherealFlame"), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
}
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 25);
Projectile.NewProjectile((int)projectile.position.X + 1, (int)projectile.position.Y, 5, 5, mod.ItemType("DeathOrb"), 10, 0.5f);
Projectile.NewProjectile((int)projectile.position.X - 1, (int)projectile.position.Y, -5, 5, mod.ItemType("DeathOrb"), 10, 0.5f);
}

Any help is appreciated!
Thanks, Tulra
 
Last edited:
I tested a lot my mod and I thought I had done something wrong but I found a bug in tmodloader while doing my tests.

public override void NPCLoot(NPC npc) is not called when an npc die in a server in multiplayer game.

So what I tried to be sure: My mod give xp. But on multiplayer it does not. But leech worked since it's on hit. So I tried calling the npcloot on each hit and it worked. So by the mean the hook is not called on a multiplayer game. But it is in single player.
 
Hey guys!
So I'm trying to make a projectile spawn more projectiles on death, but when the projectile is "killed" nothing happens. Here is my script so far, and as you can probably tell I'm a massive C# scrub.
public override void Kill(int timeLeft)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("EtherealFlame"), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
}
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 25);
Projectile.NewProjectile((int)projectile.position.X + 1, (int)projectile.position.Y, 5, 5, mod.ItemType("DeathOrb"), 10, 0.5f);
Projectile.NewProjectile((int)projectile.position.X - 1, (int)projectile.position.Y, -5, 5, mod.ItemType("DeathOrb"), 10, 0.5f);
}

Any help is appreciated!
Thanks, Tulra
You should probably do mod.ProjectileType() instead of mod.ItemType(). You don't really need the int for projectile.position. And that's pretty much all.
 
You should probably do mod.ProjectileType() instead of mod.ItemType(). You don't really need the int for projectile.position. And that's pretty much all.

Oops, I thought I changed it from mod.ItemType(). Thanks though!
 
Port-fowarding isn't working for my server? Any ideas/suggestions?
 
You should probably do mod.ProjectileType() instead of mod.ItemType(). You don't really need the int for projectile.position. And that's pretty much all.

Thanks so much for the help before, I have another probably scrub issue.
The projectile now splits into the new projectiles which behave as normal, except they deal no damage, apply no knockback and generally act as if they aren't colliding with NPCs.

Code:
        public override void Kill(int timeLeft)
        {
            for (int k = 0; k < 5; k++)
            {
                Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("EtherealFlame"), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
            }
            Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 25);
            Projectile.NewProjectile(projectile.position.X + 1, projectile.position.Y, projectile.velocity.X * 1.25f, projectile.velocity.Y, mod.ProjectileType("DeathOrb"), 10, 0.5f);
            Projectile.NewProjectile(projectile.position.X - 1, projectile.position.Y, projectile.velocity.X * 0.75f, projectile.velocity.Y, mod.ProjectileType("DeathOrb"), 10, 0.5f);
        }

Sorry for noobing it up once again, but I would really like to learn how to mod Terraria as an introduction to coding. Thanks!
 
For some reason TmodLoader doesn't support mod browser for my OS X computer, Any advice
 
For some reason TmodLoader doesn't support mod browser for my OS X computer, Any advice
I am also having this problem. I am really sad and disappointed as most Tmodloader mods use the ModBrowser which mac users cannot use.
 
Thanks so much for the help before, I have another probably scrub issue.
The projectile now splits into the new projectiles which behave as normal, except they deal no damage, apply no knockback and generally act as if they aren't colliding with NPCs.

Code:
        public override void Kill(int timeLeft)
        {
            for (int k = 0; k < 5; k++)
            {
                Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("EtherealFlame"), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
            }
            Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 25);
            Projectile.NewProjectile(projectile.position.X + 1, projectile.position.Y, projectile.velocity.X * 1.25f, projectile.velocity.Y, mod.ProjectileType("DeathOrb"), 10, 0.5f);
            Projectile.NewProjectile(projectile.position.X - 1, projectile.position.Y, projectile.velocity.X * 0.75f, projectile.velocity.Y, mod.ProjectileType("DeathOrb"), 10, 0.5f);
        }

Sorry for noobing it up once again, but I would really like to learn how to mod Terraria as an introduction to coding. Thanks!
In the Projectile.NewProjectile function, you want to insert one more parameter:
Code:
Projectile.NewProjectile(projectile.position.X + 1, projectile.position.Y, projectile.velocity.X * 1.25f, projectile.velocity.Y, mod.ProjectileType("DeathOrb"), 10, 0.5f, Main.player[Main.myPlayer]);
That should probably work.
 
In the Projectile.NewProjectile function, you want to insert one more parameter:
Code:
Projectile.NewProjectile(projectile.position.X + 1, projectile.position.Y, projectile.velocity.X * 1.25f, projectile.velocity.Y, mod.ProjectileType("DeathOrb"), 10, 0.5f, Main.player[Main.myPlayer]);
That should probably work.
That exact code didn't work, but if you take away the Main.player before the square brackets, it works. Thanks so much!
 
That exact code didn't work, but if you take away the Main.player before the square brackets, it works. Thanks so much!
Woops my bad, that is indeed the correct way.
 
I have a problem that one day, all of my worlds got corrupted and I can't even enter new worlds when I create them,Is this a bug? Because I can't even access new worlds
 
Bluemagic, slow down, XD. Lol, I just got 0.7, now I gotta install the new version. Your a quick coder!
 
Can we create some kind of "placeholder" recipe, that can be used with any item?For example, crafting Night's Edge or any other with Modded Item of True Powah gives weapon +5 dmg or 2x sell value, you got the idea?


Also, can set bonus of armor mimic an accessory?So that if player equips a set, he have a wings?
 
If I wanted to animate a placeable object in my inventory and when it's placed how would I do that?
 
Can we create some kind of "placeholder" recipe, that can be used with any item?For example, crafting Night's Edge or any other with Modded Item of True Powah gives weapon +5 dmg or 2x sell value, you got the idea?


Also, can set bonus of armor mimic an accessory?So that if player equips a set, he have a wings?

I guess boht of these are possible, but they would be difficult to implement. For the placeholder recipe, you would probably have to iterate through all of the recipes in Main.recipe, and then probably get all of the components through requiredItem[] and requiredTile[] (iterate through these also after each entry in Main.recipe) and then add your placeholder recipe. But then again, this may result in more than 4000 recipes for the game, so you can probably check the items in the recipe with createItem. So you should probably do this in ModRecipe or the Mod file on load. I may try and make this but I don;t know if it will work.

You can probably mimic an accessory effect like wings using ModPlayer, since the items themselves do not give the effects. For example, for wings you could probably set a value for the wings variable for player to use a vanilla wing, however I don't know if it will use the wing texture for it when you change the wings variable. You would need to check in the ModPlayer updates hook to see if the player is wearing the set and then set the variable in there for example, you could set player.carpet = true.
 
I guess boht of these are possible, but they would be difficult to implement. For the placeholder recipe, you would probably have to iterate through all of the recipes in Main.recipe, and then probably get all of the components through requiredItem[] and requiredTile[] (iterate through these also after each entry in Main.recipe) and then add your placeholder recipe. But then again, this may result in more than 4000 recipes for the game, so you can probably check the items in the recipe with createItem. So you should probably do this in ModRecipe or the Mod file on load. I may try and make this but I don;t know if it will work.

You can probably mimic an accessory effect like wings using ModPlayer, since the items themselves do not give the effects. For example, for wings you could probably set a value for the wings variable for player to use a vanilla wing, however I don't know if it will use the wing texture for it when you change the wings variable. You would need to check in the ModPlayer updates hook to see if the player is wearing the set and then set the variable in there for example, you could set player.carpet = true.

Okay, thanks for information! :)
 
Back
Top Bottom