tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
Hello,
You seem to be having the same issue as me (no one has replied to it yet). If you find a fix, let me know =P I have been trying to get this crazy thing working for hours now!
Duplicate the post-tAPI-install Terraria.exe and rename it to tAPI.exe? (so you have both Terraria.exe and tAPI.exe which are actually the same thing)
 
Duplicate the post-tAPI-install Terraria.exe and rename it to tAPI.exe? (so you have both Terraria.exe and tAPI.exe which are actually the same thing)
I'l give that a go!
Edit: Aw yes! That worked! Silly me xD
Thanks Shockah!
BTW your mods are great.
 
Ok, I've done a little more experimenting with the minion setting in projectiles. Defining a projectile as a minion will prevent it from falling through stairs and stops it doing any damage to enemies regardless of what I set 'friendly' to. I fixed both of these problems simply by removing "minion": true from my .json file. I'm not sure if this is a bug or if there's something else that I'm doing wrong. Does anyone know more about this?

On a more important bug, I found that in multiplayer, the server would immediately crash when I hopped into a minecart. This would happen even if there was no other players and I had no mods enabled. I managed to get the error message with image-to-text software.

Unhandled Exception : System.Exception: Rethrown exception ———> System.Exception: Rethrown exception ———> System.NullReferenceException: Object reference not set to an instance of an object.
at Terraria.Mount.GetHeightfloost(Int32 MountType) in d:\Repo\git\tAPI\tAPI\Terraria\Mount.cs:line 675
at Terraria.Player.GrappleMovement() in d:\Repo\git\tAPI\tAPI\Terraria\Player.cs:line 8505
at Terraria.Player.UpdatePlayer(1nt32 i) in d:\Repo\git\tAPI\tAPI\Terraria\Player.cs:line 13564
at Terraria.Main.UpdateReal(GameTime gameTime) in d:\Repo\git\tAPI\tAPI\Terraria\Main.cs:line 4810
--- End of inner exception stack trace ---
at TAPI.ErrorHandling.Handle(Exception e) in d:\Repo\git\tAPI\tAPI\tAPI\Basics\ErrorHandling.cs:line 154
at Terraria.Main.Updatereal(GameTime gameTime) in d:\Repo\git\tAPI\tAPI\Terraria\Main.cs:line 4913
at Terraria.Main.Update(GameTime gameTime) in d:\Repo\git\tAPI\tAPI\Terraria\Main.cs:line 3302
--- End of inner exception stack trace ---
at TAPI.ErrorHandling.Handle(Exception e) in d:\Repo\git\tAPI\tAPI\tAPT\Basics\ErrorHandling.cs:line 154
at Terraria.Main.Update(GameTime gameTime) in d:\Repo\git\tAPI\tAPI\Terraria\Main.cs:line 3307
at Terraria.Main.DedServ() in d:\Repo\git\tAPI\tAPI\Terraria\Main.cs:line 1241
at Terraria.ProgramServer.Main(String[] args)

I wanted to confirm if this happened to anyone else before I reported this on the bug reporter.

One final thing, which isn't exactly a bug, just some unusual behaviour that I noticed. I was testing an item that fired a projectile in multiplayer while using the PreShoot and UseItem hooks. If player A used the item, then client A would only do PreShoot and client B would only do UseItem. Is this supposed to happen?
 
How do I make an armor set bonus detect how far enemies are away, and give me a buff when they are a certain amount of close to you?
 
How do I make an armor set bonus detect how far enemies are away, and give me a buff when they are a certain amount of close to you?
You'll essentially have to iterate over the Main.npc array, and calculate the distance to each active NPC. For example, this code will give you the distance to the closest hostile NPC (or -1 if there is no hostile NPC):
Code:
float closestDistance = -1f;
for(int k = 0; k < 200; k++)
{
    NPC npc = Main.npc[k];
    if(npc.active && !npc.friendly)
    {
        Vector2 offset = npc.Center - player.Center;
        float distance = (float)Math.Sqrt(offset.X * offset.X + offset.Y * offset.Y);
        if(distance < closestDistance || closestDistance < 0f)
        {
            closestDistance = distance;
        }
    }
}
 
You'll essentially have to iterate over the Main.npc array, and calculate the distance to each active NPC. For example, this code will give you the distance to the closest hostile NPC (or -1 if there is no hostile NPC):
Code:
float closestDistance = -1f;
for(int k = 0; k < 200; k++)
{
    NPC npc = Main.npc[k];
    if(npc.active && !npc.friendly)
    {
        Vector2 offset = npc.Center - player.Center;
        float distance = (float)Math.Sqrt(offset.X * offset.X + offset.Y * offset.Y);
        if(distance < closestDistance || closestDistance < 0f)
        {
            closestDistance = distance;
        }
    }
}
Or alternatively:
Code:
if(Vector2.Distance(npc.Center, player.Center) < closestDistance || closestDistance < 0f)
{
    closestDistance = Vector2.Distance(npc.Center, player.Center);
}

Vector2.Distance kinda eliminates the need of Math.Sqrt.
 
Last edited:
Check your .exe file and make sure it says tAPI.exe and not TerrariaOriginalBackup.exe
Yes ,i was using the tapi version,and i was fixed that problem .I reinstalled teraria,installed game launcher and the tapi and it started work ,but now i hae a other problem,My girlfriend can't conecting to my server . The problem it's their tapi can't found my server.He have my ip,and i don't change the port and have the same instalation.Where it's the problem?
-Sry for my language,i don't have time to write correctly-
 
I can't get tAPI Builder to even start. If I try to run it, I just get a box saying "tAPI builder encountered a problem and needs to close." I don't even get an error description.
 
helloo,

i am beginning in terraria modding and i have a problem.
is there anyway of getting two crafting recipes for one item, for example i have a sword modded but i want to have two ways of making the same sword.
would be awsome if someone helped me out!
 
I can't get tAPI Builder to even start. If I try to run it, I just get a box saying "tAPI builder encountered a problem and needs to close." I don't even get an error description.
Did you try copying Terraria.exe and renaming the copy to tAPI.exe?

helloo,

i am beginning in terraria modding and i have a problem.
is there anyway of getting two crafting recipes for one item, for example i have a sword modded but i want to have two ways of making the same sword.
would be awsome if someone helped me out!
It would be easiest to explain by example here, so here's an example from my mod:
Code:
    "recipes":
    [{
        "items": {"Adamantite Forge": 1, "Bluemagic:PuriumOre": 60},
        "tiles": ["Mythril Anvil"],
        "creates": 1
    },
    {
        "items": {"Titanium Forge": 1, "Bluemagic:PuriumOre": 60},
        "tiles": ["Mythril Anvil"],
        "creates": 1
    }]
This would allow the player to be able to use either an Adamantite Forge or a Titanium Forge to craft my custom item.
 
Yay tAPI Builder starts now! Thanks for the help. BTW, that seems like a kinda odd bug, is there any chance we could get the OP edited to mention that so other people don't have to bang their head on the wall over it?
 
I get this crash when I load my world

TAPI.Mods+LoadException: Notch.tapi: System.InvalidOperationException: An unexpected error has occurred.
at Microsoft.Xna.Framework.Graphics.Texture2D..ctor(GraphicsDevice graphicsDevice, Stream stream, Int32 width, Int32 height, XnaImageOperation operation)
at Microsoft.Xna.Framework.Graphics.Texture2D.FromStream(GraphicsDevice graphicsDevice, Stream stream)
at TAPI.Mod.<Load>b__0(BinBuffer bb)
at TAPI.Mods.HandleTapiModFile(FPath path, Action`1 action)
at TAPI.Mods.HandleModFile(FPath path, Action`1 action)
at TAPI.Mod.Load()
at TAPI.Mods.Load()
at TAPI.Mods.Load()

It with r14a
 
Or alternatively:
Code:
if(Vector2.Distance(npc.Center, player.Center) < closestDistance || closestDistance < 0f)
{
    closestDistance = Vector2.Distance(npc.Center, player.Center);
}

Vector2.Distance kinda eliminates the need of Math.Sqrt.

How do I know how much distance that is, anyway?
 
Um... I believe it's in pixels? For instance, if the NPC is 13 pixels straight above you, then the distance would be 13.
Tiles are 16x16 pixels, so that should help give you an idea.

But where do I input that in the code? In 0f? The statement in the brackets? Can you provide an example of like... 50 pixels?
 
But where do I input that in the code? In 0f? The statement in the brackets? Can you provide an example of like... 50 pixels?
I was... I... Blegh.
Code:
float closestDistance = 50f;
for(int k = 0; k < 200; k++)
{
    NPC npc = Main.npc[k];
    if(npc.active && !npc.friendly)
    {
        if(Vector2.Distance(npc.Center, player.Center) < closestDistance)
        {
            //do stuff here
        }
    }
}
Change "closestDistance" to whatever you wish (currently it's at 50f for 50 pixels).

Edit: Wait a minute... I think I may have done something wrong.

Edit 2: Fixed, I think.
 
Status
Not open for further replies.
Back
Top Bottom