Standalone [1.3] tModLoader - A Modding API

Soooo I made a drop for a mod mob using GlobalNPC! (I think it isn't supported yet)
Maybe someone already did it.
Code:
    if(npc.type == mod.NPCType("BossName")  && Main.rand.Next(1) == 0)

    {
        Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ItemName"));
    }
Well, that certainly works as a temporary solution :p
In the next update you'll be able to put that in the NPC's own file.

Okay i fixed that one but i've encountered afew others and the last one i don't understand is this one :

c:\Users\Izzy\Documents\My Games\Terraria\ModLoader\Mod Sources\Hardmode Arkhalis\Eclipse.cs(23,29) : error CS0116: A namespace cannot directly contain members such as fields or methods
That means you have your curly braces in the wrong order. The namespace should contain only the class, and the class should contain everything.

Hey guys :( I want an npc (modded) to drop an mod item but i dont know the format or load method :(
Please Help :)
Thanks In Advance
You don't know how what format or load method does what?
 
So basically and sorry to msg you @bluemagic123 i know your busy but like if i wanted to make an npc (modded) and i wanted it to drop an item what code must i put in and where
thanks for help :)
 
v0.4.1:
-Add PreAI, AI, and PostAI hooks for projectiles and NPCs - Complete
-Add FindFrame and HitEffect hooks for NPCs - Complete
-Add aiType field for ModProjectile and ModNPC + animationType field for ModNPC - Complete
-Add support for gores
-Add TileCollideStyle, OnTileCollide, PreKill, and Kill hooks for projectiles
-Add PreNPCLoot and NPCLoot hooks for NPCs
-Make it easier to customize vanilla NPC loot
-Add more hooks for projectiles and NPCs
-Add even more hooks for projectiles and NPCs

Now that's what i'm waiting for the most. :happy:
 
So basically and sorry to msg you @bluemagic123 i know your busy but like if i wanted to make an npc (modded) and i wanted it to drop an item what code must i put in and where
thanks for help :)
You can either do what zadum did and use a GlobalNPC, or you can wait for the next update when I add the NPCLoot hook to ModNPC.
 
That means you have your curly braces in the wrong order. The namespace should contain only the class, and the class should contain everything.

Ok so i got that curly brace fixed but now it gives me this ->

c:\Users\Izzy\Documents\My Games\Terraria\ModLoader\Mod Sources\Hardmode Arkhalis\Eclipse.cs(23,17) : error CS1518: Expected class, delegate, enum, interface, or struct

What does that mean? I am extremly new to all this modding. The part the report refers to is this one

}
}

public override void Load}()
{
AddItem("Eclipse", new Eclipse(), "HardmodeArkhalis/Items/Eclipse")}
 
Ok so i got that curly brace fixed but now it gives me this ->

c:\Users\Izzy\Documents\My Games\Terraria\ModLoader\Mod Sources\Hardmode Arkhalis\Eclipse.cs(23,17) : error CS1518: Expected class, delegate, enum, interface, or struct

What does that mean? I am extremly new to all this modding. The part the report refers to is this one

}
}

public override void Load}()
{
AddItem("Eclipse", new Eclipse(), "HardmodeArkhalis/Items/Eclipse")}
Um, why do you have a curly brace right after the word "Load"?
I recommend looking at the example mod to see how to format stuff.
 
@bluemagic123 Should NPC.cs really take over 40 mins to decompile? I set the decompile on single threaded so the RAM doesn't get overloaded, but it just sits there. 5% CPU usage, occasional spikes of CPU, and 90+% RAM usage (6gb ram).
 
@bluemagic123 Should NPC.cs really take over 40 mins to decompile? I set the decompile on single threaded so the RAM doesn't get overloaded, but it just sits there. 5% CPU usage, occasional spikes of CPU, and 90+% RAM usage (6gb ram).
If I remember correctly, NPC is what takes the longest to decompile. Partially because the decompiler often decides to decompile other stuff in the middle of decompiling NPC.
 
If I remember correctly, NPC is what takes the longest to decompile. Partially because the decompiler often decides to decompile other stuff in the middle of decompiling NPC.
How long does it take for you to decompile terraria? If you can remember, that is. [offtopic] I'm currently decompiling Terraria while (on my linux pc) farming piranhas for compasses. So far: ~10 hooks, 1 robot hat and 0 compasses. [/offtopic]
 
How long does it take for you to decompile terraria? If you can remember, that is. [offtopic] I'm currently decompiling Terraria while (on my linux pc) farming piranhas for compasses. So far: ~10 hooks, 1 robot hat and 0 compasses. [/offtopic]
It normally takes me almost two hours. And that's when I let it freeze up my computer.
And I know the feel; once when I was farming blindfolds I ended up getting at least 5 of every other rare drop from dark mummies :p
 
It normally takes me almost two hours. And that's when I let it freeze up my computer.
And I know the feel; once when I was farming blindfolds I ended up getting at least 5 of every other rare drop from dark mummies :p
I'll probably run it overnight to update the mod loader when Terraria updates. At least, if it works with Linux. The exe (and .dll) files are on a flash drive, but I think it loads it all into memory before decompiling, as it doesn't seem to be accessing the flash drive that much. As I can't seem to find out until this compiles, does the Patch tModLoader button generate the patches that you apply with bspatch or does it compile Terraria? I should also be able to make a linux/mac patcher, as bsdiff/bspatch work on linux/osx.
 
I'll probably run it overnight to update the mod loader when Terraria updates. At least, if it works with Linux. The exe (and .dll) files are on a flash drive, but I think it loads it all into memory before decompiling, as it doesn't seem to be accessing the flash drive that much. As I can't seem to find out until this compiles, does the Patch tModLoader button generate the patches that you apply with bspatch or does it compile Terraria? I should also be able to make a linux/mac patcher, as bsdiff/bspatch work on linux/osx.
Basically, what the tool does is patch the code, rather than the exe. So the Patch Merged button will patch the decompiled source code to merge the client and serve code, the Patch Terraria button will patch the merged code to get a recompilable Terraria code, and the Patch tModLoader button will patch the recompilable Terraria code to get the tModLoader code.
 
Basically, what the tool does is patch the code, rather than the exe. So the Patch Merged button will patch the decompiled source code to merge the client and serve code, the Patch Terraria button will patch the merged code to get a recompilable Terraria code, and the Patch tModLoader button will patch the recompilable Terraria code to get the tModLoader code.
So to release a new version, you click all three patch buttons, then compile the tModLoader code then diff it?
Slightly stupid question, but do you compile the code using VS or some other program?
 
So to release a new version, you click all three patch buttons, then compile the tModLoader code then diff it?
Well, the merge and Terraria patches never change unless Terraria itself updates, since they only exist to get a recompilable Terraria. What I do to commit on Github is click the "Diff tModLoader" button to create new patches for the tModLoader code, then commit the patches.
Now, to release a new version, all I do is run bsdiff on the vanilla Terraria.exe and the modded Terraria.exe, separately from the tool.
 
Well, the merge and Terraria patches never change unless Terraria itself updates, since they only exist to get a recompilable Terraria. What I do to commit on Github is click the "Diff tModLoader" button to create new patches for the tModLoader code, then commit the patches.
Now, to release a new version, all I do is run bsdiff on the vanilla Terraria.exe and the modded Terraria.exe, separately from the tool.
Cool. Expect to see a tModLoader linux version from me if nothing goes wrong! Also, if you want you can add my changes to the setup tool to the github repo. All it does is search for assemblies in SteamDir, as there are a few dlls there in Linux Terraria. It shouldn't break Windows support.
[DOUBLEPOST=1439665483,1439665353][/DOUBLEPOST]still decompiling NPC.cs. I have restarted it twice though, but it has been running for a few hours. At least it has 25% cpu usage rather than 5%.


Edit: By the way, I'm in the UK, so leaving it running overnight might mean in the day for you.
 
Cool. Expect to see a tModLoader linux version from me if nothing goes wrong! Also, if you want you can add my changes to the setup tool to the github repo. All it does is search for assemblies in SteamDir, as there are a few dlls there in Linux Terraria. It shouldn't break Windows support.
[DOUBLEPOST=1439665483,1439665353][/DOUBLEPOST]still decompiling NPC.cs. I have restarted it twice though, but it has been running for a few hours. At least it has 25% cpu usage rather than 5%.


Edit: By the way, I'm in the UK, so leaving it running overnight might mean in the day for you.

You can use jetbrains dot peek, it's free, I decompiled Terraria in about ~15 mins into a MVS solution
 
Back
Top Bottom