Standalone [1.3] tModLoader - A Modding API

I'm not sure what you are planning for projectiles, but the number one thing I'd want is the ability to have them run their own custom AI loop instead of being forced to use one that already exists in Terraria. I've been able to "fake it" pretty well so far though by reassigning the aiStyle of another projectile. Hooks for hitting an NPC and hitting a tile would also be nice if that's workable.
An AI hook is actually my top priority for projectiles, since it defines most of their behavior and many vanilla aiStyles rely on the projectile's type. Hooks for hitting an NPC is also planned (and also required for one of my goals for the NPC hook update).
There's already a hook for hitting a tile. The KillTile hook is actually for whenever anything attacks a tile (I find that name a bit misleading but it's what's in the source code). If the fail parameter is true then the tile was just hit and not mined.
 
I didnt know much (or really any) about that to begin with, but I find it easier to download the example mod and (with notepad++ or similar) reverse engineer the codes until you can make a completely new [insert item name here]!
[DOUBLEPOST=1439162525,1439162416][/DOUBLEPOST]Judging by recent comments, I take it that the new update allows for us to make projectiles? If so, could I get a basic copy of a code of one to see how it works?
Okay, thanks.

Does any of the .json things work when using C#?

Is there still something like
"friendly:true"
Or however it worked
 
Okay, thanks.

Does any of the .json things work when using C#?

Is there still something like
"friendly:true"
Or however it worked
Something like "friendly": true would be replaced by npc.friendly = true; in the SetDefaults hook. There are many examples of how this is done for items and tiles in the example mod.
 
You should do what you want to do. Converting the json parts to cs shouldn't be too hard (it's essentially just a different syntax), although converting a large amount of stuff can be tedious. In the end, it will depend on how much effort you're willing to put in and how rewarding you expect success will feel.
I totally agree... Im gonna start the new thread now!
 
Thank you very much. Can I still edit the original items with this mod making mod?
Yes, you will override the GlobalItem class.
You should really look into some basic c# tutorials which will get you covered. I'm sure there's some in my help thread, second post. Link is in OP.
[DOUBLEPOST=1439197378,1439196970][/DOUBLEPOST]Can't wait for on hit ^^
 
Yes, you will override the GlobalItem class.
You should really look into some basic c# tutorials which will get you covered. I'm sure there's some in my help thread, second post. Link is in OP.
[DOUBLEPOST=1439197378,1439196970][/DOUBLEPOST]Can't wait for on hit ^^
Thank you.
 
Does OnHitPvp, or OnHitNPC detect self-damage? I'd like to make a weapon, that does certain things when you damage yourself.
If so, then does it detect explosion too? (I mean if the player suffers damage from an area.)
 
Last edited:
Have 2 questions:

1. How to make a tile that can be placed on a table?
2. Why this won't work?
Code:
        TileObjectData.newTile.CopyFrom(TileObjectData.Style3x1);
It says:
Code:
c:\My Documents\My Games\Terraria\ModLoader\Mod Sources\Tremor\Tiles\WoodenTVRack.cs(18,56) : error CS0117: "Terraria.ObjectData.TileObjectData" does not contain a definition for "Style3x1"
 
Have 2 questions:

1. How to make a tile that can be placed on a table?
2. Why this won't work?
Code:
        TileObjectData.newTile.CopyFrom(TileObjectData.Style3x1);
It says:
Code:
c:\My Documents\My Games\Terraria\ModLoader\Mod Sources\Tremor\Tiles\WoodenTVRack.cs(18,56) : error CS0117: "Terraria.ObjectData.TileObjectData" does not contain a definition for "Style3x1"
because there probably aren't any 3x1 tiles in the vanilla code
 
Have 2 questions:

1. How to make a tile that can be placed on a table?
2. Why this won't work?
Code:
        TileObjectData.newTile.CopyFrom(TileObjectData.Style3x1);
It says:
Code:
c:\My Documents\My Games\Terraria\ModLoader\Mod Sources\Tremor\Tiles\WoodenTVRack.cs(18,56) : error CS0117: "Terraria.ObjectData.TileObjectData" does not contain a definition for "Style3x1"

Literally what the error says.
Code:
Style4x2;
Style2x2;
Style1x2;
Style1x1;
StyleAlch;
StyleDye;
Style2x1;
Style6x3;
StyleSmallCage;
StyleOnTable1x1;
Style1x2Top;
Style1xX;
Style2xX;
Style3x2;
Style3x3;
Style3x4;

These are the available ones according to the Terraria source.
 
Literally what the error says.
Code:
Style4x2;
Style2x2;
Style1x2;
Style1x1;
StyleAlch;
StyleDye;
Style2x1;
Style6x3;
StyleSmallCage;
StyleOnTable1x1;
Style1x2Top;
Style1xX;
Style2xX;
Style3x2;
Style3x3;
Style3x4;

These are the available ones according to the Terraria source.
That's not fun :(
In tAPI there was a possibility of making tiles of any size...
 
That's not fun :(
In tAPI there was a possibility of making tiles of any size...

I don't really like making tiles, but I think it was implemented differently in tAPI, too. (not like Style3x1, etc.)
Maybe there's another way to make it, but again, I'm not really into making tiles.
 
Does OnHitPvp, or OnHitNPC detect self-damage? I'd like to make a weapon, that does certain things when you damage yourself.
If so, then does it detect explosion too? (I mean if the player suffers damage from an area.)
Those hooks don't detect self-damage, since they're only for when the player is swinging the item. However, stuff like that should be possible once I add more hooks for projectiles. (Explosions are basically just projectiles growing in size.)

That's not fun :(
In tAPI there was a possibility of making tiles of any size...
It's still possible to make tiles of any size, you just need to do more work. This new TileObjectData system is something added to vanilla Terraria in 1.3.
Code:
TileObjectData.newTile.Width = 3;
TileObjectData.newTile.Height = 1;
TIleObjectData.newTile.Origin = new Point16(0, 1);
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
Note you will have to include "using Terraria.DataStructures;" and "using Terraria.Enums;" at the top.
 
Does OnHitPvp, or OnHitNPC detect self-damage? I'd like to make a weapon, that does certain things when you damage yourself.
If so, then does it detect explosion too? (I mean if the player suffers damage from an area.)
Is it a katana that can be used to kill the player in order to prevent loss of coins?

Whoops, I slipped one of my own ideas away...

Credit me.
 
Those hooks don't detect self-damage, since they're only for when the player is swinging the item. However, stuff like that should be possible once I add more hooks for projectiles. (Explosions are basically just projectiles growing in size.)


It's still possible to make tiles of any size, you just need to do more work. This new TileObjectData system is something added to vanilla Terraria in 1.3.
Code:
TileObjectData.newTile.Width = 3;
TileObjectData.newTile.Height = 1;
TIleObjectData.newTile.Origin = new Point16(0, 1);
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
Note you will have to include "using Terraria.DataStructures;" and "using Terraria.Enums;" at the top.
Now I'm getting
Code:
c:\My Documents\My Games\Terraria\ModLoader\Mod Sources\Tremor\Tiles\WoodenTVRack.cs(22,1) : error CS0103: Name "TIleObjectData" not in the current context
 
Now I'm getting
Code:
c:\My Documents\My Games\Terraria\ModLoader\Mod Sources\Tremor\Tiles\WoodenTVRack.cs(22,1) : error CS0103: Name "TIleObjectData" not in the current context
Looks like I typo'd "TileObjectData" as "TIleObjectData". I do that all the time :(
 
Looks like I typo'd "TileObjectData" as "TIleObjectData". I do that all the time :(
Now I'm getting invisible table o_O

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace Tremor.Tiles {
public class WoodenTVRack : ModTile
{
    public override void SetDefaults()
    {
        Main.tileSolidTop[Type] = true;
        Main.tileFrameImportant[Type] = true;
        Main.tileNoAttach[Type] = true;
        Main.tileTable[Type] = true;
        Main.tileLavaDeath[Type] = true;
TileObjectData.newTile.Width = 3;
TileObjectData.newTile.Height = 1;
TileObjectData.newTile.Origin = new Point16(0, 1);
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
        TileObjectData.newTile.CoordinateHeights = new int[]{18};
        TileObjectData.addTile(Type);
        AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
        mapColor = new Color(179, 146, 113);
        mapName = "WoodenTVRack";
    }

    public override void KillMultiTile(int i, int j, int frameX, int frameY)
    {
        Item.NewItem(i * 16, j * 16, 32, 16, mod.ItemType("WoodenTVRack"));
    }
}}

Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tremor.Items {
public class WoodenTVRack : ModItem
{
    public override void SetDefaults()
    {
        item.name = "Wooden TVRack";
        item.width = 44;
        item.height = 16;
        item.maxStack = 99;
        AddTooltip("");
        item.useTurn = true;
        item.autoReuse = true;
        item.useAnimation = 15;
        item.useTime = 10;
        item.useStyle = 1;
        item.consumable = true;
        item.value = 150;
        item.createTile = mod.TileType("WoodenTVRack");
    }

    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(ItemID.DirtBlock, 1);
        recipe.SetResult(this);
        recipe.AddRecipe();
    }
}}
 
Back
Top Bottom