Standalone [1.3] tModLoader - A Modding API

And need to change AI of drill's projectile or ammo's projectile?
This is not as easy as 'chaning the aiStyle or aiType' of your projectile.
You'll need to manipulate your code directly using the PreAI, AI or PostAI functions (these can all be found on the tModLoader GitHub wiki).
 
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MyMod.Projectiles.Drills
{
public class MyDrill : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "My Drill";
projectile.width = 22;
projectile.height = 22;
projectile.aiStyle = 20;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.hide = true;
projectile.ownerHitCheck = false;
projectile.melee = true;
}
public override void AI()
{
What i need to write here? ***using projectile.ai[0] or [1], the player expends ammo.***
}
}
}
 
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MyMod.Projectiles.Drills
{
public class MyDrill : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "My Drill";
projectile.width = 22;
projectile.height = 22;
projectile.aiStyle = 20;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.hide = true;
projectile.ownerHitCheck = false;
projectile.melee = true;
}
public override void AI()
{
What i need to write here? ***using projectile.ai[0] or [1], the player expends ammo.***
}
}
}
use code with brackets to put your code.
EDIT:Anyone know how to make an item craftable with both gold bar and platinum bar?
 
Last edited:
There ought to be more options in the config file for tModLoader, like disabling the double tap for the Shield of Cthulhu dash, to make it better for hotkey mods. This should be fine, as the tModLoader config file is separate from the Vanilla one.
 
guys im trying to make an item but when i build it i get error CS0103 with ItemID and TilesID help
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace DarkSaddle.Items
{
    public class DarkSaddle : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Dark Slimy Saddle";
            item.width = 34;
            item.height = 26;
            item.toolTip = "So Slimy.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.value = 30000;
            item.rare = 2;
            item.useSound = 79;
            item.noMelee = true;
            item.mountType = mod.MountType("SlimerMount");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.MarbleBlock, 20);
            recipe.AddIngredient(ItemID.GoldBar, 20);
            recipe.AddTile(TileID.Workbenches);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
 
guys im trying to make an item but when i build it i get error CS0103 with ItemID and TilesID help
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace DarkSaddle.Items
{
    public class DarkSaddle : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Dark Slimy Saddle";
            item.width = 34;
            item.height = 26;
            item.toolTip = "So Slimy.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.value = 30000;
            item.rare = 2;
            item.useSound = 79;
            item.noMelee = true;
            item.mountType = mod.MountType("SlimerMount");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.MarbleBlock, 20);
            recipe.AddIngredient(ItemID.GoldBar, 20);
            recipe.AddTile(TileID.Workbenches);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
In the future it'd help if you could post the whole error. I can see the fault right away in this case, though:

This has to do with namespaces. Every class falls under a certain namespace (as you can see, this items' namespace is
DarkSaddle.Items). 'ItemID', 'TileID', 'BuffID', etc. all fall under the 'Terraria.ID' namespace. If you want to use a class from other namespaces, you'll have to include that namespace in your code:
Code:
using Terraria.ID;
These so called 'using statements' are placed at the top of your file (along with the other using statements) ;)
 
In the future it'd help if you could post the whole error. I can see the fault right away in this case, though:

This has to do with namespaces. Every class falls under a certain namespace (as you can see, this items' namespace is
DarkSaddle.Items). 'ItemID', 'TileID', 'BuffID', etc. all fall under the 'Terraria.ID' namespace. If you want to use a class from other namespaces, you'll have to include that namespace in your code:
Code:
using Terraria.ID;
These so called 'using statements' are placed at the top of your file (along with the other using statements) ;)
Thanks, i dont put the error here because its written on portuguese >_>.

EDIT: now its giving me this error error CS0117: 'Terraria.ID.TileID' não contém uma definição para 'Workbenches'
 
It means there is a bug on Mac/Linux when decoding MP3 files. Anyway, Tremor mod has a new version that works since the mp3 files were removed.

I'm still recieving an error on the new version of Tremor.
The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Terraria.ModLoader.ModLoader.LoadMod (Terraria.ModLoader.IO.TmodFile modFile, Terraria.ModLoader.BuildProperties properties) [0x00000] in <filename unknown>:0
at Terraria.ModLoader.ModLoader.LoadMods () [0x00000] in <filename unknown>:0
 
Can someone tell me how to make that boss drops something ???? Pls i'm blind.

Nad english :(
[DOUBLEPOST=1453760351,1453760332][/DOUBLEPOST]Bad*
 
Can someone tell me how to make that boss drops something ???? Pls i'm blind.

Nad english :(
[DOUBLEPOST=1453760351,1453760332][/DOUBLEPOST]Bad*
public override void NPCLoot()
{
int amountToDrop = Main.rand.Next(3,10);
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.PalmWood, amountToDrop);
if(Main.rand.Next(60) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("LivingTwig"));
}
}

Here is what I used.
 
Hello, a´random reply. It works with accessories but only during one frame after equipping. It should work with tiles as well.
Lol I've given up on that long ago. I actually just started modding again sort of (I have a mod ready for adding items and stuff but I just haven't gotten myself to do it).
 
One last thing (maybe) How i can make the boss that fly and Charges at you?

In Poland is 23:45 xd
[DOUBLEPOST=1453761958,1453761708][/DOUBLEPOST]One last thing maybe how can i make boss that fly and charge at you?

In Poland is 23:47
 
Anybody know how I would make my weapon spawn a projectile like the starfury or meteor staff and make the projectile I made for it spawn another projectile on enemy collision and death?
 
How do i access the Terraria steam folder?
C:\Program Files (x86)\Steam\steamapps\common\terraria
How do I get my npc to spawn near the beaches?
See how octopus does it. Basically check above rocklayer, and make sure x position is in outer 250 tiles.
https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/NPCs/Octopus.cs#L112
Anybody know how I would make my weapon spawn a projectile like the starfury or meteor staff and make the projectile I made for it spawn another projectile on enemy collision and death?
You just change the position and speed in shoot to spawn above the player and point at Main.MouseWorld. Then you can use PreKill or OnTileCollide to call Projectile.NewProjectile to spawn other projectiles.
 
I try to make like cthulhu hand i have a black hand witch purple eye and i try to make it like moon lord hand :D
[DOUBLEPOST=1453764672,1453764638][/DOUBLEPOST]Sry for English
 
Back
Top Bottom