Standalone [1.3] tModLoader - A Modding API

How to modify vanilla items, NPCs etc? For example adding drops for enemies or adding attributes to armor.
ExampleMod has plenty of examples of changing Vanilla stuff. It is usually in a class with Global in the name. Search the source code for examples.
 
em so I was going to the dungeon In a new world but a op charecter and when i wasnt even in the jungle two queen bees spawn i tried to record so i went abit away from them so i could click start recording(something happend to my hotkeys and had to go to the program ) when i came to the game they disappeared maybe i whent to far away from them or they just disappeared
 
How can I check that plantera has been downed?
NPC.downedPlantBoss
[doublepost=1459005417,1459004969][/doublepost]So I have this gun, that when shot, sends you backwards. Problem is, you can go through tiles with my current code. Is there a way to check my next position, and stop my character if it would be in a tile? Is there just an easier way to accomplish this items effect?

Code:
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            float spread = 2f * 0.1750f;
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);
            double randomAngle = baseAngle + (Main.rand.NextFloat() - 0.75f) * spread;
            float randomSpeed = Main.rand.NextFloat() * 0.2f + 1f;
            speedX = baseSpeed * randomSpeed * (float)Math.Sin(randomAngle);
            speedY = baseSpeed * randomSpeed * (float)Math.Cos(randomAngle);
           
            if (player.direction > 0)
            {
                player.position.X -= 10;
                return true;
            }
            if (player.direction < 0)
            {
                player.position.X += 10;
                return true;
            }
            return true;
        }
 
ExampleMod has plenty of examples of changing Vanilla stuff. It is usually in a class with Global in the name. Search the source code for examples.
I searched for items and other stuff and I've only found Aglet. But it only adds recipe, doesn't change attributes. I know, Copper Shortsword, but I would like NPCs and equipables.

Also, how can I make that armor will give effects in vanity slot?
 
NPC.downedPlantBoss
[doublepost=1459005417,1459004969][/doublepost]So I have this gun, that when shot, sends you backwards. Problem is, you can go through tiles with my current code. Is there a way to check my next position, and stop my character if it would be in a tile? Is there just an easier way to accomplish this items effect?

Code:
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            float spread = 2f * 0.1750f;
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);
            double randomAngle = baseAngle + (Main.rand.NextFloat() - 0.75f) * spread;
            float randomSpeed = Main.rand.NextFloat() * 0.2f + 1f;
            speedX = baseSpeed * randomSpeed * (float)Math.Sin(randomAngle);
            speedY = baseSpeed * randomSpeed * (float)Math.Cos(randomAngle);
         
            if (player.direction > 0)
            {
                player.position.X -= 10;
                return true;
            }
            if (player.direction < 0)
            {
                player.position.X += 10;
                return true;
            }
            return true;
        }

Instead of changing player position, just change player velocity. It has a less likely chance of going through blocks.
 
I searched for items and other stuff and I've only found Aglet. But it only adds recipe, doesn't change attributes. I know, Copper Shortsword, but I would like NPCs and equipables.

Also, how can I make that armor will give effects in vanity slot?
You use a GlobalSomething class, check the itemid in setdefaults, change whatever you want. If you want to add an effect, do the same for one of the update accessories hooks.

You can try having the code for your moditem also in update visuals.

Hey guys, where can I get the spritesheet used by the guide? The ExamplePerson spritesheet is too hard to follow.
You can go to the steam Terraria directory and you'll find the NPC_22.xnb and all the other textures. Convert them to png with the program linked to in my signature

https://dl.dropboxusercontent.com/u/41490830/TerrariaModding/XNB 4.0 Exporter.zip
 
You use a GlobalSomething class, check the itemid in setdefaults, change whatever you want. If you want to add an effect, do the same for one of the update accessories hooks.

You can try having the code for your moditem also in update visuals.


You can go to the steam Terraria directory and you'll find the NPC_22.xnb and all the other textures. Convert them to png with the program linked to in my signature

https://dl.dropboxusercontent.com/u/41490830/TerrariaModding/XNB 4.0 Exporter.zip
Uh, tried it and it crashed
 
It says that "Something has caused this program to stop working properly"
Weird, btw I never type anything in the box, I just have the unzipped exe and a few xnbs in a random folder and click go. You can try that. If you still can't get it to work, I can PM you maybe
 
You use a GlobalSomething class, check the itemid in setdefaults, change whatever you want. If you want to add an effect, do the same for one of the update accessories hooks.

You can try having the code for your moditem also in update visuals.


You can go to the steam Terraria directory and you'll find the NPC_22.xnb and all the other textures. Convert them to png with the program linked to in my signature

https://dl.dropboxusercontent.com/u/41490830/TerrariaModding/XNB 4.0 Exporter.zip
So for the vanity I have to write:
public override void UpdateVisual(Player player)
{
player.something = something;
}
Right?
 
Back
Top Bottom