tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
I don't know if it's still relevant, but I have some more info on that timer bug.
If the timer has an odd number of colored wires attached to it, it will activate itself and shut itself off.
For example if the timer is connected to only red wires, it will shut itself off. If it is connected to red and green, it will not. If it is connected to all three colors then it will shut itself off. I suspect this is because with an even number it is actually activating itself twice and turning itself back on.
 
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Terraria;

using TAPI;

namespace ROTD
{
    public class ModBase :
      {
  
        public override void OnAllModsLoaded()
         {
            // Replace vanilla Timer textures
            if(!Main.dedServ) {
                Main.itemTexture[383] = textures["Vanilla/Item_383"];
                Main.itemTexture[384] = textures["Vanilla/Item_384"];
                Main.itemTexture[385] = textures["Vanilla/Item_385"];
                Main.itemTexture[386] = textures["Vanilla/Item_386"];
                Main.itemTexture[387] = textures["Vanilla/Item_387"];
                Main.itemTexture[388] = textures["Vanilla/Item_388"];
                Main.itemTexture[483] = textures["Vanilla/Item_483"];
                Main.projectileTexture[57] = textures["Vanilla/Projectile_57"];
                Main.projectileTexture[58] = textures["Vanilla/Projectile_58"];
                Main.projectileTexture[59] = textures["Vanilla/Projectile_59"];
                Main.projectileTexture[60] = textures["Vanilla/Projectile_60"];
                Main.projectileTexture[61] = textures["Vanilla/Projectile_61"];
                Main.projectileTexture[62] = textures["Vanilla/Projectile_62"];
            }
         }
    }
}

I tried to use the code, but the code does not want to build. What did I do wrong?:(
[DOUBLEPOST=1421475177][/DOUBLEPOST]The textures put in a folder
"Vanilla"
 
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Terraria;

using TAPI;

namespace ROTD
{
    public class ModBase :
      {
 
        public override void OnAllModsLoaded()
         {
            // Replace vanilla Timer textures
            if(!Main.dedServ) {
                Main.itemTexture[383] = textures["Vanilla/Item_383"];
                Main.itemTexture[384] = textures["Vanilla/Item_384"];
                Main.itemTexture[385] = textures["Vanilla/Item_385"];
                Main.itemTexture[386] = textures["Vanilla/Item_386"];
                Main.itemTexture[387] = textures["Vanilla/Item_387"];
                Main.itemTexture[388] = textures["Vanilla/Item_388"];
                Main.itemTexture[483] = textures["Vanilla/Item_483"];
                Main.projectileTexture[57] = textures["Vanilla/Projectile_57"];
                Main.projectileTexture[58] = textures["Vanilla/Projectile_58"];
                Main.projectileTexture[59] = textures["Vanilla/Projectile_59"];
                Main.projectileTexture[60] = textures["Vanilla/Projectile_60"];
                Main.projectileTexture[61] = textures["Vanilla/Projectile_61"];
                Main.projectileTexture[62] = textures["Vanilla/Projectile_62"];
            }
         }
    }
}

I tried to use the code, but the code does not want to build. What did I do wrong?:(
[DOUBLEPOST=1421475177][/DOUBLEPOST]The textures put in a folder
"Vanilla"
"public class ModBase :"

You forgot TAPI.ModBase after the colon.

Random other note, the comment still says timer, lol :dryadtongue:
 
"public class ModBase :"

You forgot TAPI.ModBase after the colon.

Random other note, the comment still says timer, lol :dryadtongue:
When I write TAPI.ModBase, there are many error =(.
[DOUBLEPOST=1421480280][/DOUBLEPOST]In different places, in different .cs files, all modifications 0-0
 
Oh! Works! It works! Thank you very much, MiraiMai, for your help :D
[DOUBLEPOST=1421480897][/DOUBLEPOST]TAPI.Mods+LoadException: ROTD.tapi: TAPI.Mod+LoadException: More than one ModBase found.
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()

:confused:
 
Hi,
How would i make a minion? I dont think theres an ai built in and there is no example in the template mod.
There is an example and prewritten AI in base mod. AIMinionFighter – Custom AI that works similarly to fighter minion AI. (uses ai[0, 1]). That's all there is to it, use that for the AI and you have a minion.You could check if he actually uses it in G realm for a usage example.
I created a new world and now it doesn't have errors anymore. Geez, I'm about to attempt to make a first ever custom AI. So far I've copied some code to make him hover above the player. I don't really know where to start, though.
It's very difficult to make an AI from scratch, unless you want something very simple. You're much better off studying an existing AI and using it as a template, assuming you can read code. If you can't, I would put some serious effort into trying to learn.

Grox the great released base mod which has premade AI segments you can use.
Code:
AIRotate  Custom AI that will cause the npc to rotate around a point in a fixed circle.
AIPounce  Custom AI that will cause the npc to 'pounce' at the given target when it is within range.
AIPath  Custom AI that will cause the npc to follow the path of given points. (uses ai[0, 1, 2])
AITackle  Custom AI that will cause the npc to 'tackle' a specific point given. (uses ai[0, 1, 2])
AIGravitate  Custom AI that will cause the npc to 'gravitate' near a specific point given. (uses ai[0, 1, 2])
WalkupHalfBricks Code based on vanilla halfbrick walkup code, checks for and attempts to walk over half tiles.
AttemptJump  Code based on vanilla jumping code, checks for and attempts to jump over tiles and gaps when needed.
AttemptOpenDoor  Attempts to interact with a door.

AIWeapon  A cleaned up (and edited) copy of Possessed Weapon AI. (aiStyle 23) (Enchanted Sword, Demon Hammer, etc.)
AISnail  A cleaned up (and edited) copy of Snail AI. (Snail, etc.) (AIStyle 67)
AISpore  A cleaned up (and edited) copy of Spore AI. (Fungi Spore, Plantera Spore, etc.) (AIStyle 50)
AICharger  A cleaned up (and edited) copy of Charger AI. (Unicorns, wolves, etc.) (AIStyle 26)
AIFriendly  A cleaned up (and edited) copy of Friendly AI. (Town NPCs, Bunnies, Penguins, etc.) (AIStyle 7)
AIEater  A cleaned up (and edited) copy of Eater of Souls AI. (EoS, Corruptor, etc.) (AIStyle 5)
AIWheel  A cleaned up (and edited) copy of Wheel AI. (Blazing Wheel) (AIStyle 21)
AISpider  A cleaned up (and edited) copy of Spider Wallwalking AI. (Blood Crawler, etc.) (AIStyle 40)
AISkull  A cleaned up (and edited) copy of Skull AI. (Cursed Skull) (AIStyle 10)
AIFloater  A cleaned up (and edited) copy of Floater AI. (Pixie, Gastropod, etc.) (AIStyle 22)
AIFlier  A cleaned up (and edited) copy of Flier AI. (Bat, Demon, etc.) (AIStyle 14)
AIPlant  A cleaned up (and edited) copy of Plant AI. (Man Eater, etc.) (AIStyle 13)
AIWorm  A cleaned up (and edited) copy of Worm AI. (Giant Worm, EoW, Wyvern, etc.) (AIStyle 6)
AITeleporter  A cleaned up (and edited) copy of Teleporter AI. (Fire Imps, Tim, Chaos Elementals, etc.) (AIStyle 8)
AIFish  A cleaned up (and edited) copy of Fish AI. (Goldfish, Angler Fish, etc.)
AIZombie  A cleaned up (and edited) copy of Zombie AI. (Stripped Fighter AI)
AIEye  A cleaned up copy of Demon Eye AI. (Flier AI)
AISlime  A cleaned up copy of Slime AI.
In fact, now that I look he already has a premade worm AI you can use. You should probably just use that or copy from it and give him credit.

It's amazing how much stuff grox has already included in base mod it's just undocumented.

If you're not sure what type of creature to make philosophically, ask yourself what would my creature add to the game?:
When I'm making creatures, first I thought hard mode creatures were too easy, because you can just fly over everything with wings and unload at them with machine gun. And giving stuff more health and damage doesn't really make it harder it is not hitting you anyway. And giving it long-range un dodgable lasers is cheesy and lame. So I tried to think of creatures with various tricks to resist this flying with a machine gun. So they have attacks that stop you from flying, or are hard to Dodge while flying, or that kill you if you try to just run away, or they resist machine-gun barrages, or barrages only break them into small parts that are harder to Dodge, or they are invisible so you don't know when to fly away, etc., etc.

Second I asked myself what type of cool creatures fit with the biome I'm trying to populate and aren't already in the game? So for jungle, witch doctors, headhunters, tigers, poison toads, etc.

Thirdly, I made a list of each depth and day/night and made sure there were at least two new creatures in each for jungle. So two daytime surface creatures, 2 nighttime surface creatures, and the same with sky, rock, dirt, and lava layers.

Fourthly, I tried to fill out each niche of the ecosystem in other words jungle has slimes, plants, fish, and bats so I tried to have not only harder ground enemies, but harder air and water enemies as well. In the official jungle patch the creator did the same thing.

Fifthly, I asked myself what makes the biome (jungle) unique/dangerous and try to think of things that enhance the natural danger of the jungle. So, trees grow quickly, so maybe creatures that can climb trees. And there is more than normal spawn rate, so there's a debuff like battle potion that makes creatures spawn even faster. And of course, there's several new types of poison, with new items to counter them.Also, nurse NPC's finally had a point.

Finally, when designing a boss, there's two additional things to think about. Firstly, traditionally bosses have several cool attack patterns, and often you can see what they're about to do a second or two in advance. Secondly, modern MMO RPG bosses have very specialized attacks that require you to analyze and counter their attacks in specific ways, or specifically require two or more players cooperating to beat. For a simple example say a boss constantly summons minions that can only be harmed by magic and the boss himself can only be harmed by melee. This doesn't actually FORCE you to fight him with two players, but depending on how fast the minion spawn, it puts a lot of pressure on you to do so.
 
Last edited:
You can yes, I suggest decompiling tAPI and looking in Main.cs, there is a bunch of Texture variables, you would just change them to be what you want from your mods loaded textures.

I do this in my mod Future Dance to replace the timer textures, this is how it works:
Code:
// Replace vanilla Timer textures
if(!Main.dedServ) {
    Main.tileTexture[144] = textures["Vanilla/Tile_Timers"];
    Main.itemTexture[583] = textures["Vanilla/Item_Timer_1"];
    Main.itemTexture[584] = textures["Vanilla/Item_Timer_3"];
    Main.itemTexture[585] = textures["Vanilla/Item_Timer_5"];
}

This is done in ModBase.OnAllModsLoaded, btw.

I've been considering texture packs for tAPI, but I'm not sure exactly how to do it or really have the time to work on it much :dryadtongue:


Are you 100% certain it isn't the texture? I can't think of what could cause that. Try using a 0% tolerance pick colour selection on the transparency, and see if there's some pixels to the side of the hat that you didnt notice.


Looking into the code for this, (never did music myself either) I think I found the answer.

You need to make a soundbank (.xsb) with your music and put it in the Wavebanks directory.

Then you need to make a Wavebanks.json, which has a single property "tracks", which is an array of music names.

Code:
{
     "tracks": [
        "Track1",
        "Track2",
        "Track3"
    ]
}

Then you do what you already know to use them :dryadsmile:

Random note, you can have 1 .xsb (music) 1 .xwb (sound effects) and the 1 json in this folder. The json is only for the soundbank though, not sure why it's called wavebanks :dryadrolleyes:


Set the weapon's "shoot" to the ID of one of the rockets (first one makes most sense) and set the "useAmmo" property to the ammo ID of rockets.

So I guess, use 134 for the "shoot" and 771 for the "useAmmo"

EDIT: Wow lots of missed messages, my browser didnt tell me there was more

I think it isn't the sprite but if you want I can upload them later. Today things went even crazier with the armor set(or it is supposed to be a vanity set actually). The legs and body sprite aren't where they are supposed to be. They are above the head as you can see in these pictures.
When I'm just wearing the pants.
2015-01-17 12_54_09-Terraria Part 3_ The Return of the Guide.png

When I'm just wearing the body and the legs.
2015-01-17 12_54_29-Terraria Part 3_ The Return of the Guide.png

And when I'm wearing all three parts.
2015-01-17 12_54_44-Terraria Part 3_ The Return of the Guide.png
 
Yes! Now my sprites work! I use Main.itemTexture and Main.tileTexture. But Main.projectileTexture and Main.NPCTexture won't work. Can you tell me how to fix it? ;)
 
Last edited:
I think it isn't the sprite but if you want I can upload them later. Today things went even crazier with the armor set(or it is supposed to be a vanity set actually). The legs and body sprite aren't where they are supposed to be. They are above the head as you can see in these pictures.
When I'm just wearing the pants.View attachment 21657
When I'm just wearing the body and the legs.View attachment 21658
And when I'm wearing all three parts.View attachment 21659
You are clearly doing something very very wrong, because that shouldn't happen, period. Me and multiple others have perfectly working armour sets. The only thing I can think of is if for some reason you have head slot set on all 3 pieces, for that. Still don't think it would cause that though.

Yes! Now my sprites work! I use Main.itemTexture and Main.tileTexture. But Main.projectileTexture and Main.NPCTexture won't work. Can you tell me how to fix it? ;)
Main.projectileTexture is right. Main.npcTexture has to be lower case.

And like I said, go figure out how to decompile tAPI, and look for these values your self. It's not our job to go look up value names for people, it's something extremely easy to do yourself.
 
Alright... I'm back ^^
(The RPG questions guy like 20 pages back - was a bit busy recently and I'm working on the mod during weekends...)

Got a couple more questions if you don't mind:
I don't quite understand the structure of BinBuffer...
  • Do variables get deleted from it as I load them or do I have to "manually" delete them?
  • Are we speaking about ~A~ BinBuffer or ~THE~ BinBuffer?
  • If in my case I'd like to save a/the BinBuffer each time the world is saved, what would be the good/best solution? (got some ideas how to do it, but help here would be awesome)
Thank you a lot for being so helpful! ^^

Edit: Forgot to ask if there's a way to check the NPC's current HP...
 
You are clearly doing something very very wrong, because that shouldn't happen, period. Me and multiple others have perfectly working armour sets. The only thing I can think of is if for some reason you have head slot set on all 3 pieces, for that. Still don't think it would cause that though.


Main.projectileTexture is right. Main.npcTexture has to be lower case.

And like I said, go figure out how to decompile tAPI, and look for these values your self. It's not our job to go look up value names for people, it's something extremely easy to do yourself.

I have done some armours before and they worked perfect. I did like I always have done so it should work. I will try to find a solution but I do think that nothing is wrong with my code or sprites.
 
Alright... I'm back ^^
(The RPG questions guy like 20 pages back - was a bit busy recently and I'm working on the mod during weekends...)

Got a couple more questions if you don't mind:
I don't quite understand the structure of BinBuffer...
  • Do variables get deleted from it as I load them or do I have to "manually" delete them?
  • Are we speaking about ~A~ BinBuffer or ~THE~ BinBuffer?
  • If in my case I'd like to save a/the BinBuffer each time the world is saved, what would be the good/best solution? (got some ideas how to do it, but help here would be awesome)
Thank you a lot for being so helpful! ^^
A BinBuffer is literally just a byte array, that is easier to add data to. It is what is used for writing custom data to files, and for sending data in multiplayer.

1) You are given a fresh, empty BinBuffer each time. This BinBuffer is written to the main BinBuffer before writing the file. So no, you don't have to delete anything.
2) Just an instance of BinBuffer. You can't manipulate the vanilla data or other mods data with the one given to you.
3) Check the docs for list of hooks. ( http://tapi.axxim.net/docs/?mode=hooks&doc=modworld ) ModPlayer has the same hooks (Initialize / Save / Load ), why they aren't listen I don't know :dryadrolleyes: Basically just write/read from the BinBuffer as needed in the appropriate hooks.

I have done some armours before and they worked perfect. I did like I always have done so it should work. I will try to find a solution but I do think that nothing is wrong with my code or sprites.
You shouldn't need any code for a vanity set, just a JSON for each piece. Unless you want special effects anyways, but you don't seem to be using any.

Either way though, it's hard to help with only seeing screenshots.
 
You are clearly doing something very very wrong, because that shouldn't happen, period. Me and multiple others have perfectly working armour sets. The only thing I can think of is if for some reason you have head slot set on all 3 pieces, for that. Still don't think it would cause that though.


Main.projectileTexture is right. Main.npcTexture has to be lower case.

And like I said, go figure out how to decompile tAPI, and look for these values your self. It's not our job to go look up value names for people, it's something extremely easy to do yourself.
Something went wrong.
Code:
        public override void OnAllModsLoaded()
         {
            // Replace vanilla Timer textures
            if(!Main.dedServ) {
                Main.itemTexture[483] = textures["Vanilla/Item_483"];
                Main.itemTexture[103] = textures["Vanilla/Item_103"];
                Main.itemTexture[120] = textures["Vanilla/Item_120"];
                Main.itemTexture[127] = textures["Vanilla/Item_127"];
                Main.itemTexture[197] = textures["Vanilla/Item_197"];
                Main.itemTexture[204] = textures["Vanilla/Item_204"];
                Main.itemTexture[122] = textures["Vanilla/Item_122"];
                Main.itemTexture[724] = textures["Vanilla/Item_724"];
                Main.itemTexture[155] = textures["Vanilla/Muramasa"];
                Main.npcTexture[134] = textures["Vanilla/DestroyerHead"];
                Main.npcTexture[135] = textures["Vanilla/DestroyerBody"];
                Main.npcTexture[136] = textures["Vanilla/DestroyerTail"];
            }
         }
I have this code. After starting tAPI I'm getting this error:
2xge7Mz.png
 
Something went wrong.
Code:
        public override void OnAllModsLoaded()
         {
            // Replace vanilla Timer textures
            if(!Main.dedServ) {
                Main.itemTexture[483] = textures["Vanilla/Item_483"];
                Main.itemTexture[103] = textures["Vanilla/Item_103"];
                Main.itemTexture[120] = textures["Vanilla/Item_120"];
                Main.itemTexture[127] = textures["Vanilla/Item_127"];
                Main.itemTexture[197] = textures["Vanilla/Item_197"];
                Main.itemTexture[204] = textures["Vanilla/Item_204"];
                Main.itemTexture[122] = textures["Vanilla/Item_122"];
                Main.itemTexture[724] = textures["Vanilla/Item_724"];
                Main.itemTexture[155] = textures["Vanilla/Muramasa"];
                Main.npcTexture[134] = textures["Vanilla/DestroyerHead"];
                Main.npcTexture[135] = textures["Vanilla/DestroyerBody"];
                Main.npcTexture[136] = textures["Vanilla/DestroyerTail"];
            }
         }
I have this code. After starting tAPI I'm getting this error:
2xge7Mz.png
One of the textures you tried using doesn't exist. the "Vanilla/blah" has to match the exact name of the .png file, without .png of course.
 
A BinBuffer is literally just a byte array, that is easier to add data to. It is what is used for writing custom data to files, and for sending data in multiplayer.

1) You are given a fresh, empty BinBuffer each time. This BinBuffer is written to the main BinBuffer before writing the file. So no, you don't have to delete anything.
2) Just an instance of BinBuffer. You can't manipulate the vanilla data or other mods data with the one given to you.
3) Check the docs for list of hooks. ( http://tapi.axxim.net/docs/?mode=hooks&doc=modworld ) ModPlayer has the same hooks (Initialize / Save / Load ), why they aren't listen I don't know :dryadrolleyes: Basically just write/read from the BinBuffer as needed in the appropriate hooks.


You shouldn't need any code for a vanity set, just a JSON for each piece. Unless you want special effects anyways, but you don't seem to be using any.

Either way though, it's hard to help with only seeing screenshots.

When I wrote code I meant JSON. Sorry for being unclear.
I remade the spritesheets and now it seems to work :happy:
I don't know what caused the problem but it may accidentally have been two layers in the sprite sheet even if it didn't said it was two layers.
Thanks for the help anyway! :)
 
Status
Not open for further replies.
Back
Top Bottom