Standalone [1.3] tModLoader - A Modding API

Can someone help me make a tile count as station for various other ones too? Like, if there is xxx block here, you can use it as both an Anvil and a workbench, etc. I would like to use a Campfire for mine. Thanks!
 
Can someone help me make a tile count as station for various other ones too? Like, if there is xxx block here, you can use it as both an Anvil and a workbench, etc. I would like to use a Campfire for mine. Thanks!
You can use adjtiles to have your custom tile act as other tiles. https://github.com/bluemagic123/tModLoader/search?utf8=✓&q=adjtiles

It sounds like you want a vanilla campfire to work as anvil and workbenches, I think you can do that with globaltile in a similar manner to all the examples I linked you to.
 
I found a bug with The Tremor & Thorium mods(they said come here) that no NPC's or bosses will in multiplayer on the t modloader server file, I have confirmed it's not just the world either by summoning a boss in single player with the exact world file in the exact same location, as soon as I got on the world I started getting NPC's and boss summons worked, please fix this as soon as you can!
 
How would I check whether an NPC was behind the player, and if so, make sure a homing projectile does not target them, even if the player turns and faces the NPC after firing the projectile?
 
Why isn't this hotkey working?
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using imkSushisMod.Items;
using imkSushisMod.NPCs;

namespace imkSushisMod {
public class imkSushisMod : Mod
{
       public override void SetModInfo(out string name, ref ModProperties properties)
    {
        name = "imkSushisMod";
        properties.Autoload = true;
    }
        public override void AddRecipes()
    {
        RecipeHelper.AddInterchangeableRecipes(this);
        RecipeHelper.AddMelterRecipes(this);
        RecipeHelper.AddExtraRecipes(this);
        RecipeHelper.AddItemRecipes(this);
    }

    public override void Load()
    {
        RegisterHotKey("sushi", "O");
    }

public virtual void HotKeyPressed(string name)
{
if (name == "sushi")
{
        Main.player[Main.myPlayer].KillMe(999, 0, true, "Oops");
}
}
}}
 
Why isn't this hotkey working?
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using imkSushisMod.Items;
using imkSushisMod.NPCs;

namespace imkSushisMod {
public class imkSushisMod : Mod
{
       public override void SetModInfo(out string name, ref ModProperties properties)
    {
        name = "imkSushisMod";
        properties.Autoload = true;
    }
        public override void AddRecipes()
    {
        RecipeHelper.AddInterchangeableRecipes(this);
        RecipeHelper.AddMelterRecipes(this);
        RecipeHelper.AddExtraRecipes(this);
        RecipeHelper.AddItemRecipes(this);
    }

    public override void Load()
    {
        RegisterHotKey("sushi", "O");
    }

public virtual void HotKeyPressed(string name)
{
if (name == "sushi")
{
        Main.player[Main.myPlayer].KillMe(999, 0, true, "Oops");
}
}
}}

There might be more wrong with this, but I'm pretty sure at least the virtual keyword isn't right. That should be override.
 
How would I check whether an NPC was behind the player, and if so, make sure a homing projectile does not target them, even if the player turns and faces the NPC after firing the projectile?

You can use player.direction and npc.position to determine whether or not a NPC was behind the player. If you want the projectile to choose a target immediately when it's cast, you can run all enemies in range through the if statement and you're done. If you want it to be able to choose a new target during its lifetime, it gets more complicated. I suppose you could make an array of (in)valid targets at the beginning of the cast and then only let the projectile target NPCs that are (not) in it, but I don''t know if that's the most efficient way.

This compares the position of the NPC with the direction the player is facing (in pseudo-code):
Code:
if ( ( npc.Center.X < player.Center.X  &&  player.direction == 1) || ( npc.Center.X > player.Center.X && player.direction == -1) )
{
 // true if the NPC is not being faced, false if it is.
}

// Alternatively:

if ( ( npc.Center.X > player.Center.X  &&  player.direction == 1) || ( npc.Center.X < player.Center.X && player.direction == -1) )
{
 // true if the NPC is being faced, false if it's not.
}
 
I'm trying to make a projectile which stays still after hitting the ground, rather than killing itself.
I have tried:

public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.velocity.X = 0;
projectile.velocity.Y = 0;
return false;
}

and I have tried using the
'public override void TileCollideStyle(ref int width, ref int height, ref bool fallThrough)'
method too with the same code inside but nothing is working (The projectile just goes through the ground). What am I doing wrong?

[doublepost=1459077458,1459077280][/doublepost]Actually dw. I got it working
 
Unsure if this is the right place to ask, but it looks like every time I try to build a new world, Terraria crashes with some sort of memory problem.
Is this because I have too many mods enabled?
 
Someone knows how to draw a sprite batch while a mob is under a buff?
My Code:
Code:
//Inside the GlobalNPC
public virtual void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
        {
            GNPCInfo info = (GNPCInfo)npc.GetModInfo(mod, "GNPCInfo");
            //56x56  is the batch image size.
           
            while(info.Frost)
            {
                Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y);
                spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f);
            }
           
        }
 
Servers still don't work joining with Steam. Using two windows computers, installed Tremor and Thorium Mod. Getting either 'connection lost', or it gets stuck on 'found server.' I thought it said it was fixed
 
Someone knows how to draw a sprite batch while a mob is under a buff?
My Code:
Code:
//Inside the GlobalNPC
public virtual void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
        {
            GNPCInfo info = (GNPCInfo)npc.GetModInfo(mod, "GNPCInfo");
            //56x56  is the batch image size.
        
            while(info.Frost)
            {
                Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y);
                spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f);
            }
        
        }

Try this:

Code:
public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
        {        
            if(npc.hasBuff(mod.BuffType("Frost")) != -1)
            {
                Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y);
                spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f);
                return false;
            }
            return true;        
        }

Untested, should (highly) theoretically work. If default(Color) gives an error, just change it to Color.white and that should work.
 
Try this:

Code:
public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
        {       
            if(npc.hasBuff(mod.BuffType("Frost")) != -1)
            {
                Vector2 drawPos = new Vector2(npc.position.X,npc.position.Y);
                spriteBatch.Draw(mod.GetTexture("Extras/Frozen"), drawPos, null, default(Color), 0f, drawPos, npc.scale * 2 , SpriteEffects.None, 0f);
                return false;
            }
            return true;       
        }

Untested, should (highly) theoretically work. If default(Color) gives an error, just change it to Color.white and that should work.
WORKED! thanks budy, buuuut... when the mod is with the buff, he turns invisible:D
 
Back
Top Bottom