Standalone [1.3] tModLoader - A Modding API

Come again with another question: how do pots drop items?
In detail, I made some little items and I want them to be dropped when certain pot was broken. Maybe just add a few items into the vanilla pot drop list.
Dunno whether express this in the way as it should be... :)hope it is intelligible.

BTW, is modifying content of a natural generated chest possible now?
 
Come again with another question: how do pots drop items?
In detail, I made some little items and I want them to be dropped when certain pot was broken. Maybe just add a few items into the vanilla pot drop list.
Dunno whether express this in the way as it should be... :)hope it is intelligible.

BTW, is modifying content of a natural generated chest possible now?
I'm not sure about pots, I'll have to look into it, but ExampleMods exampleworld has an example of placing items in ice chests.
 
Yet I got another issue here: where is the suit attribution being kept in vanilla source code?
I'm tryna make myself some life steal effects, and I think maybe I can get it from the Spectre suit. However, I searched from item to player, nothing was found. Where are these attribution defined?
 
Yet I got another issue here: where is the suit attribution being kept in vanilla source code?
I'm tryna make myself some life steal effects, and I think maybe I can get it from the Spectre suit. However, I searched from item to player, nothing was found. Where are these attribution defined?

It's in the UpdateArmorSets method in Player.cs. The Spectre set activates the ghostHeal bool, which in turn is used in Projectile.cs.
 
It's in the UpdateArmorSets method in Player.cs. The Spectre set activates the ghostHeal bool, which in turn is used in Projectile.cs.
Found it. Now I know it is something like the vampire heal, and I cannot understand how it works.
I'm just trying to make myself a life stealing blade, a melee weapon. I may not need to the method complicated like this and they often involve a projectile feedback which is also unnecessary. So the reason I was looking up in these effects is that I wanna find how a NPC's damage is calculated - how to gain the damage when a NPC gets hit?
It is annoying to ask these question that the anwser of it could be gained through existed data... but I've looked the whole source code for the whole afternoon, I'm dazzle now...
 
Found it. Now I know it is something like the vampire heal, and I cannot understand how it works.
I'm just trying to make myself a life stealing blade, a melee weapon. I may not need to the method complicated like this and they often involve a projectile feedback which is also unnecessary. So the reason I was looking up in these effects is that I wanna find how a NPC's damage is calculated - how to gain the damage when a NPC gets hit?
It is annoying to ask these question that the anwser of it could be gained through existed data... but I've looked the whole source code for the whole afternoon, I'm dazzle now...

You can use tModLoader's OnHitNPC for that, damage is one of the parameters.
 
Uhhhh... Can someone help me with this error? Same thing happens with every mod I try to build.

Failed it load C: \ \ Users\\JAKUB\\Documents\\My Games\\Terraria\\ModLoader\\Mod Sources\\ExampleMod\\build. txt
System.FormatException: Wrong format of the entrance sequence.
in System.Version.VersionResult.SetFailure (ParseFailureKind failure, String argument)
in System.Version.TryParseComponent (String component, String componentName, VersionResult& result, Int32 & parsedComponent)
in System.Version.TryParseVersion (String version, VersionResult& result)
in System.Version.Parse (String input)
in System.Version.. ctor (String version)
in Terraria.ModLoader.BuildProperties.ReadBuildFile (String modDir)
in Terraria.ModLoader.ModCompile.ReadProperties (String modFolder, IBuildStatus status)
 
Uhhhh... Can someone help me with this error? Same thing happens with every mod I try to build.

Failed it load C: \ \ Users\\JAKUB\\Documents\\My Games\\Terraria\\ModLoader\\Mod Sources\\ExampleMod\\build. txt
System.FormatException: Wrong format of the entrance sequence.
in System.Version.VersionResult.SetFailure (ParseFailureKind failure, String argument)
in System.Version.TryParseComponent (String component, String componentName, VersionResult& result, Int32 & parsedComponent)
in System.Version.TryParseVersion (String version, VersionResult& result)
in System.Version.Parse (String input)
in System.Version.. ctor (String version)
in Terraria.ModLoader.BuildProperties.ReadBuildFile (String modDir)
in Terraria.ModLoader.ModCompile.ReadProperties (String modFolder, IBuildStatus status)
If your version has letters or isn't 2-4 numbers separated by periods, you'll have that problem.
[doublepost=1461020177,1461019725][/doublepost]
OK, I'm gonna learn a bit about that and meanwhile waiting your mighty solution of pots!
Looks like pots are hard coded without any hooks yet. So no luck there.
 
Um I know I posted this complaint twice, but no one is helping me out so I am going to say it again. So, recently I downloaded the Tremor Mod, and when I play, some sounds are missing. These sounds include but aren't limited to the sound of coins being spent/picked up, and occasionally the music disappears as well. Thanks!

P.S. I play on Mac.
 
That's about what i was thinking of doing, I just can't seem to find the specific code/calls to do the checking if a mount item is equipped and which one it is.

- Aerlock
Anyone have any idea on how to do this? I've been looking through the example mod and not having any luck finding the code to check an equipped accessory/mount.

- Aerlock
 
Anyone have any idea on how to do this? I've been looking through the example mod and not having any luck finding the code to check an equipped accessory/mount.

- Aerlock
player.miscEquips are the pet, light pet, mount, cart, and hook slots. You can try something like this for swapping the pet with inventory slot 0:
Code:
Utils.Swap<Item>(ref Main.player[Main.myPlayer].miscEquips[0], ref Main.player[Main.myPlayer].inventory[0]);
If you just want to check the pet, just
Code:
Main.player[Main.myPlayer].miscEquips[0].type == ItemID.ZephyrFish
Um I know I posted this complaint twice, but no one is helping me out so I am going to say it again. So, recently I downloaded the Tremor Mod, and when I play, some sounds are missing. These sounds include but aren't limited to the sound of coins being spent/picked up, and occasionally the music disappears as well. Thanks!

P.S. I play on Mac.
Looking into it.
 
Um I know I posted this complaint twice, but no one is helping me out so I am going to say it again. So, recently I downloaded the Tremor Mod, and when I play, some sounds are missing. These sounds include but aren't limited to the sound of coins being spent/picked up, and occasionally the music disappears as well. Thanks!

P.S. I play on Mac.
Does it happen on a different Mod?
Does it happen with Tremor Mod removed?
Does it happen if you revert back to vanilla Terraria?
What Model Mac?
What OS version?

My guess, having never tried Tremor and being pretty new to tModLoader, is that there's something going on with that mod that's affecting the sound playback in your game.

- Aerlock
[doublepost=1461035130,1461034810][/doublepost]
player.miscEquips are the pet, light pet, mount, cart, and hook slots. You can try something like this for swapping the pet with inventory slot 0:
Code:
Utils.Swap<Item>(ref Main.player[Main.myPlayer].miscEquips[0], ref Main.player[Main.myPlayer].inventory[0]);
If you just want to check the pet, just
Code:
Main.player[Main.myPlayer].miscEquips[0].type == ItemID.ZephyrFish
Thanks! This is exactly what I couldn't find! Where should I have been looking for this? The Terraria code?

- Aerlock
 
I think I've never been more confused... I have this item, that gives you a buff and produces this projectile, that stays with you as you move around. This projectile also spawns its actual damage in intervals as to avoid rapid damage. The issue, and stay with me on this, is that when I leave the general spawn area, the projectile will kill itself... I cant explain it any better than that, If I use the item when i spawn and about 20 tiles left or right, it works fine. Pass that limit and poof, it vanishes. Any ideas?

Code:
public override void AI()
        {
            Player player = Main.player[Main.myPlayer];
        
            if (player.HasBuff(mod.BuffType("EnchantedShieldBuff")) < 1)
            {
                projectile.Kill();
            }
            projectile.light = 0.1f;
            projectile.position.X = player.Center.X - 39;
            projectile.position.Y = player.Center.Y - 22;
        
            projectile.ai[1]++;
        
            if (projectile.ai[1] >= 0)
            {
                Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, mod.ProjectileType("EnchantedShieldDamage"), 14, 0, projectile.owner, 0f, 0f);

                projectile.ai[1] = -20;
            }
        
            if (projectile.timeLeft != 360 || projectile.timeLeft != 290 || projectile.timeLeft != 230 || projectile.timeLeft != 180 || projectile.timeLeft != 140 ||
                projectile.timeLeft != 110 || projectile.timeLeft != 90 || projectile.timeLeft != 80 || projectile.timeLeft != 75 || projectile.timeLeft != 70
                || projectile.timeLeft != 65 || projectile.timeLeft != 60 || projectile.timeLeft != 55 || projectile.timeLeft <= 50)
                {
                    projectile.alpha = 50;
                }
        
            if (projectile.timeLeft == 360)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 290)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 230)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 180)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 140)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 110)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 90)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 80)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 75)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 70)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 65)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 60)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 55)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft <= 50)
            {
                projectile.Kill();
            }
        }
    
        public override void Kill(int timeLeft)
        {
            Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 43);
        
            for (int k = 0; k < 20; k++)
            {
                int DustID = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 5, projectile.height + 5, 59, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1.8f);
                Main.dust[DustID].noGravity = true;
            }
        }
 
Last edited:
Looks like pots are hard coded without any hooks yet. So no luck there.
See. Then let us move forward.

I'm trying to make a whole new class differentiating from the vanilla melee, ranged and magic. I think it can be called, say, Rogue? Basically I'm making it a whole new chunk of equipment and give bonus to throwing damage - yep, it majors in throwing.
But critical problems have been found. I made lots of throwing items in addition to the vanilla throwing weapons. However, as it turned out, throwing items cannot possess prefixes, which are unfair compared to other classed in the game. So I'm just wanting it to be throwing damage and at the same time have access to the prefixes.
In this way, I realized potential bugs may appear. Since throwing items are all consumable, what if I add a few of the non-prefix items into the prefixed one? I dare not think.
In order to avoid this kind of conflict, and meanwhile make the throwing items more endurable, I'm thinking about something like AMA's javelin in Diablo 2. I.e. I can make the throwing items into some kinds of weapons, they won't disappear when they're used up. They will become unusable, and can be used when resupplied. Maybe this is some kinds of the durability system? I dunno.
  • Then, intending to realize these designs, I think I first need to make a whole new class of damage, which seems pretty possible according the ModPlayer's hooks. Achieving this can, in part, solve the prefix's problem.
  • Real problem is that I'm not gonna make it something like the guns or the bows, meaning I don't want it to use ammo. When used up, what is resupplied are themselves, instead of extra ammo...... Em... I still think it is a kind of durability system. Maybe a throwing item got 999 as its maximum durability. It will reduce one every time it is used. And will recover 1 when picked up the dropping item, or be fully resupplied when remade?
If these two effects come true. I think my job is pretty much done. Most urgent question is about this durability. I dunno whether I state it clearly, but... that's it. Hope it is understandable. And is it possible?
 
Nice mod, the server support is great, but. i was playing with a friend and used a weapon, then he said that i was using a mount, i wasn't.

is this a bug or the mods i'm using?


PD: You should fix the modded enemy spawning, their spawn rate is really low, actually we're not seeing modded enemys in a normal rate like the vanilla ones.


Sorry for the bad english, have a nice day
 
SetDefaults: Main.projFrames[projectile.type] = 4;
AI: Non-cycling

projectile.frameCounter++;
if (projectile.frameCounter == 10)
{
projectile.frame = 1;
}
if (projectile.frameCounter == 20)
{
projectile.frame = 2;
}
if (projectile.frameCounter == 30)
{
projectile.frame = 3;
}

AI: Cycling:
projectile.frameCounter++;
if (projectile.frameCounter == 10)
{
projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type];
projectile.frameCounter = 0;
}

Image: frames stacked horizontally on top of each other
Where do I put AI: Non-cycling (or do I need to replace it with something?) and projectile.frameCounter++;?
 
I think I've never been more confused... I have this item, that gives you a buff and produces this projectile, that stays with you as you move around. This projectile also spawns its actual damage in intervals as to avoid rapid damage. The issue, and stay with me on this, is that when I leave the general spawn area, the projectile will kill itself... I cant explain it any better than that, If I use the item when i spawn and about 20 tiles left or right, it works fine. Pass that limit and poof, it vanishes. Any ideas?

Code:
public override void AI()
        {
            Player player = Main.player[Main.myPlayer];
       
            if (player.HasBuff(mod.BuffType("EnchantedShieldBuff")) < 1)
            {
                projectile.Kill();
            }
            projectile.light = 0.1f;
            projectile.position.X = player.Center.X - 39;
            projectile.position.Y = player.Center.Y - 22;
       
            projectile.ai[1]++;
       
            if (projectile.ai[1] >= 0)
            {
                Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, mod.ProjectileType("EnchantedShieldDamage"), 14, 0, projectile.owner, 0f, 0f);

                projectile.ai[1] = -20;
            }
       
            if (projectile.timeLeft != 360 || projectile.timeLeft != 290 || projectile.timeLeft != 230 || projectile.timeLeft != 180 || projectile.timeLeft != 140 ||
                projectile.timeLeft != 110 || projectile.timeLeft != 90 || projectile.timeLeft != 80 || projectile.timeLeft != 75 || projectile.timeLeft != 70
                || projectile.timeLeft != 65 || projectile.timeLeft != 60 || projectile.timeLeft != 55 || projectile.timeLeft <= 50)
                {
                    projectile.alpha = 50;
                }
       
            if (projectile.timeLeft == 360)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 290)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 230)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 180)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 140)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 110)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 90)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 80)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 75)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 70)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 65)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 60)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft == 55)
            {
                projectile.alpha = 255;
            }
            if (projectile.timeLeft <= 50)
            {
                projectile.Kill();
            }
        }
   
        public override void Kill(int timeLeft)
        {
            Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 43);
       
            for (int k = 0; k < 20; k++)
            {
                int DustID = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 5, projectile.height + 5, 59, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1.8f);
                Main.dust[DustID].noGravity = true;
            }
        }
Does it change anything if you check HasBuff < 0 instead of HasBuff < 1?

See. Then let us move forward.

I'm trying to make a whole new class differentiating from the vanilla melee, ranged and magic. I think it can be called, say, Rogue? Basically I'm making it a whole new chunk of equipment and give bonus to throwing damage - yep, it majors in throwing.
But critical problems have been found. I made lots of throwing items in addition to the vanilla throwing weapons. However, as it turned out, throwing items cannot possess prefixes, which are unfair compared to other classed in the game. So I'm just wanting it to be throwing damage and at the same time have access to the prefixes.
In this way, I realized potential bugs may appear. Since throwing items are all consumable, what if I add a few of the non-prefix items into the prefixed one? I dare not think.
In order to avoid this kind of conflict, and meanwhile make the throwing items more endurable, I'm thinking about something like AMA's javelin in Diablo 2. I.e. I can make the throwing items into some kinds of weapons, they won't disappear when they're used up. They will become unusable, and can be used when resupplied. Maybe this is some kinds of the durability system? I dunno.
  • Then, intending to realize these designs, I think I first need to make a whole new class of damage, which seems pretty possible according the ModPlayer's hooks. Achieving this can, in part, solve the prefix's problem.
  • Real problem is that I'm not gonna make it something like the guns or the bows, meaning I don't want it to use ammo. When used up, what is resupplied are themselves, instead of extra ammo...... Em... I still think it is a kind of durability system. Maybe a throwing item got 999 as its maximum durability. It will reduce one every time it is used. And will recover 1 when picked up the dropping item, or be fully resupplied when remade?
If these two effects come true. I think my job is pretty much done. Most urgent question is about this durability. I dunno whether I state it clearly, but... that's it. Hope it is understandable. And is it possible?
You could probably make a custom field that stores the durability, decrease this custom field in the Shoot hook, check to make sure this durability is positive in the CanUse hook, and use the OnPickup hook to increase this field.

Nice mod, the server support is great, but. i was playing with a friend and used a weapon, then he said that i was using a mount, i wasn't.

is this a bug or the mods i'm using?


PD: You should fix the modded enemy spawning, their spawn rate is really low, actually we're not seeing modded enemys in a normal rate like the vanilla ones.


Sorry for the bad english, have a nice day
The modded enemy spawn rate is a problem with the mods you're using. For the mount problem, we'll need more information for what mods you're using.
 
Back
Top Bottom