tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
My terraria went through this weird stage when I had tAPI. After I played a bit with my character, when I turned my computer off all my data on tAPI was erased. When I put the old files before my character/world files were erased, in the character selection screen where it should say my characters name it was completely blank. When I loaded my world save (which was not blank and normal), I crashed.
MODS:
Thorium+
TUWM
Dark Souls weapons
Ulterria

EDIT: Not sure but this was in my logs:
Ionic.Zip.ZipException: Cannot read that as a ZipFile
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.Read(System.String fileName, System.IO.TextWriter statusMessageWriter, System.Text.Encoding encoding, System.EventHandler`1[[Ionic.Zip.ReadProgressEventArgs, Ionic.Zip.Reduced, Version=1.9.1.9000, Culture=neutral, PublicKeyToken=null]] readProgress)
at Terraria.WorldFile.ActualLoadWorld(System.String world)
at Terraria.WorldFile.loadWorld()
at Terraria.WorldGen.playWorldCallBack(System.Object threadContext)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object state)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Ionic.Zip.BadReadException: Bad signature (0x00000066) at position 0x00000000
at Ionic.Zip.ZipEntry.ReadHeader(Ionic.Zip.ZipEntry ze, System.Text.Encoding defaultEncoding)
at Ionic.Zip.ZipEntry.ReadEntry(Ionic.Zip.ZipContainer zc, System.Boolean first)
at Ionic.Zip.ZipFile.ReadIntoInstance_Orig(Ionic.Zip.ZipFile zf)
at Ionic.Zip.ZipFile.ReadIntoInstance(Ionic.Zip.ZipFile zf)
 
Update: When I create another character, the world also doesn't work.
Also, my character reset. I had all the files, but i'm not quite sure.
I only moved my world/player info into my Docs/Terraria/tAPI, not sure if it should've been somewhere else.
http://imgur.com/ed7s6oK,HC4iJEj#0
The second image is in my character folder.
(this is all in my Docs/Terraria/tAPI/Players folder.
 
Last edited:
How could I edit the recipes of an already existing vanilla item? Like, remove a recipe, add one, etc.
 
How do I make a projectile bounce like Water Bolt?
NoScope already answered you, just set aiStyle to eight.
I haven't tried it before but I think you add this into projectile json.
"aiStyle": 8, // 8 for bounce
game's code:
Code:
this.name = "Water Bolt";
this.width = 16;
this.height = 16;
this.aiStyle = 8;
this.friendly = true;
this.alpha = 255;
this.timeLeft /= 2;
this.penetrate = 10;
this.magic = true;
 
You need to override ModNPC like this:
Code:
[GlobalModAttribute]
public class Dummy : ModNPC
Then override the SetupLootRules method. Here's an example from my mod:
Code:
public override void SetupLootRules(NPC unused)
    {
        LootRule.settingUp = true;

        LootRule[] rules = new LootRule[1];
        LootRule frostMoon = new LootRule("Frost Moon").Rules(new Func<NPC, bool>[]{LootRule.ruleFrostMoon});
        Func<NPC, bool>[] small = {((NPC npc) => NPC.waveCount >= 11 && NPC.waveCount < 15)};
        Func<NPC, bool>[] large = {((NPC npc) => NPC.waveCount >= 15)};
        LootRule[] conditionals = new LootRule[2];
        conditionals[0] = new LootRule(null).Rules(small).Chance((NPC npc) => 0.2 * (NPC.waveCount - 10)).Item("Bluemagic:Icicle");
        conditionals[1] = new LootRule(null).Rules(large).Stack(4, 6).Item("Bluemagic:Icicle");
        rules[0] = frostMoon.LootRules(conditionals);
        LootRule.AddFor("Ice Queen", rules);

        rules = new LootRule[1];
        rules[0] = new LootRule(null).Item("Bluemagic:Bubble").Stack(5, 7);
        LootRule.AddFor("Duke Fishron", rules);

        rules = new LootRule[1];
        LootRule pumpkinMoon = new LootRule("Pumpkin Moon").Rules(new Func<NPC, bool>[]{LootRule.rulePumpkinMoon});
        small = new Func<NPC, bool>[]{((NPC npc) => NPC.waveCount >= 11 && NPC.waveCount < 15)};
        large = new Func<NPC, bool>[]{((NPC npc) => NPC.waveCount >= 15)};
        conditionals = new LootRule[2];
        conditionals[0] = new LootRule(null).Rules(small).Chance((NPC npc) => 0.2 * (NPC.waveCount - 10)).Item("Bluemagic:ScytheBlade");
        conditionals[1] = new LootRule(null).Rules(large).Stack(4, 6).Item("Bluemagic:ScytheBlade");
        rules[0] = pumpkinMoon.LootRules(conditionals);
        LootRule.AddFor("Pumpking", rules);

        LootRule.settingUp = false;
    }



I'd recommend using Main.NewText to display the coordinates of all the spawns onto your screen. That way, you can make sure the code is being called and you'll know where to look.
i made it teleport the player to the coordinates. do i need to multiply them by 16?
 
Yeah, since tile coordinates are counted by tiles and entity coordinates are counted by pixels.
Found a solution. apparently EmptyTileCheck doesn't work so well in checking multiple blocks at once... so i made it check the corners and the platform below all separately, and killing any tile in the way. now it works!

EDIT: how can i make my tile make the blocks below it unbreakable? (like demon altars in vanilla)
 
Last edited:
Is there any way built-in way to modify character saving/loading? I need to save one additional float for each item in player's inventory. Or atleast how can i know when the game is being saved/closed?
 
Last edited:
Apologize if this has been brought up before but tAPI crashes during an ice queen fight, saying Reindeer Balls not found.
 
Is there any way built-in way to modify character saving/loading?
Figured it out. Here's an example if anyone needs it.
In ModPlayer:
Code:
public override void Save(BinBuffer bb)
     {
       #region Save "SaveFloatTest"   
         bb.Write(Main.localPlayer.position.X);
         Main.NewText("Saved "+Main.localPlayer.position.X);
       #endregion
     }
     public override void Load(BinBuffer bb)
     {
       try
       {
         #region Load "SaveFloatTest"
           var flo=bb.ReadFloat();
           Main.NewText("Loaded "+flo);
         #endregion
         base.Load(bb);
       }
       catch
       {

       }
     }
Devs really need to finish that tapi documentation..
 
Halp? I'm saving and loading some things in ModPlayer, but it only works until i restart the game. (No errors, no wrong/default values, just like there's no such variables in save)
Code:
public override void Save(BinBuffer bb)
     {
       var player=Main.localPlayer;
       #region Save "Overhaul"
           bb.Write(player.position);
           for(var i=0;i<59;i++)
           {
             bb.Write(player.inventory[i].shootSpeed);
           }
       #endregion
       base.Save(bb);
     }
     public override void Load(BinBuffer bb)
     {
       var player=Main.localPlayer;
       try
       {
         #region Load "Overhaul"
           setLater=new float[59];
           positionOnLoad=bb.ReadVector2();
           for(var i=0;i<59;i++)
           {
               var shootSpd=bb.ReadFloat();
               setLater[i]=shootSpd;
           }
         #endregion
         base.Load(bb);
       }
       catch
       {
       }
     }
Any ideas?

Edit: Somehow fixed it, but that fix does not even make any sense. Forget about it.
 
Last edited:
Halp? I'm saving and loading some things in ModPlayer, but it only works until i restart the game. (No errors, no wrong/default values, just like there's no such variables in save)
Code:
public override void Save(BinBuffer bb)
     {
       var player=Main.localPlayer;
       #region Save "Overhaul"
           bb.Write(player.position);
           for(var i=0;i<59;i++)
           {
             bb.Write(player.inventory[i].shootSpeed);
           }
       #endregion
       base.Save(bb);
     }
     public override void Load(BinBuffer bb)
     {
       var player=Main.localPlayer;
       try
       {
         #region Load "Overhaul"
           setLater=new float[59];
           positionOnLoad=bb.ReadVector2();
           for(var i=0;i<59;i++)
           {
               var shootSpd=bb.ReadFloat();
               setLater[i]=shootSpd;
           }
         #endregion
         base.Load(bb);
       }
       catch
       {
       }
     }
Any ideas?
why do you use "var" for new variables? just use the specific types like "float" or "int" etc
 
How would I make an NPC always rotate away from another NPC? Like this:
View attachment 46387
What exactly do you mean? If you want them to rotate in different directions, you can always add to npc.rotation for one of them and subtract from npc.rotation for the other. Or if it's a single NPC with multiple rotating parts, you can call SpriteBatch.Draw in the PostDraw method.
 
What exactly do you mean? If you want them to rotate in different directions, you can always add to npc.rotation for one of them and subtract from npc.rotation for the other. Or if it's a single NPC with multiple rotating parts, you can call SpriteBatch.Draw in the PostDraw method.
Nevermind about that, I changed my mind.
You delete your post.
 
Status
Not open for further replies.
Back
Top Bottom