Standalone [1.3] tModLoader - A Modding API

that sounds confusing
Uhm.. Lemme try to give you an example in psuedo code:
Code:
/// HEAD 
public override void AI
{
    if(npc.ai[0] == 0)
    {            
        int npcToFollow = npc.whoAmI;
        for(int i = 0; i < 10; ++i)
        {                    
            int newNPC;   
            if(i < 9)
                newNPC = NPC.NewNPC(npc.position.X, npc.position.Y, mod.NPCType("BodyPart");
            else
                newNPC = NPC.NewNPC(npc.position.X, npc.position.Y, mod.NPCType("TailPart"); // We only want one tail.

            Main.npc[newNPC].ai[0] = npcToFollow;
            npcToFollow = newNPC;
        }
        npc.ai[0] = 1; // Can only be triggered once
    }

    // Direction and moving code.
}

// TAIL & BODY
public override void AI
{
    NPC target = Main.npc[(int)npc.ai[0]];
    // Now we have the part that was spawned (quite litterally) before this one, so we'll be able to follow it.
}
 
Uhm.. Lemme try to give you an example in psuedo code:
Code:
/// HEAD
public override void AI
{
    if(npc.ai[0] == 0)
    {           
        int npcToFollow = npc.whoAmI;
        for(int i = 0; i < 10; ++i)
        {                   
            int newNPC;  
            if(i < 9)
                newNPC = NPC.NewNPC(npc.position.X, npc.position.Y, mod.NPCType("BodyPart");
            else
                newNPC = NPC.NewNPC(npc.position.X, npc.position.Y, mod.NPCType("TailPart"); // We only want one tail.

            Main.npc[newNPC].ai[0] = npcToFollow;
            npcToFollow = newNPC;
        }
        npc.ai[0] = 1; // Can only be triggered once
    }

    // Direction and moving code.
}

// TAIL & BODY
public override void AI
{
    NPC target = Main.npc[(int)npc.ai[0]];
    // Now we have the part that was spawned (quite litterally) before this one, so we'll be able to follow it.
}
alright thanks. One last sidenotive kinda thing; How do you make a monster 'leech' life from you when it hits you? Im assuming its an onhitplayer (does that even exist)
 
alright thanks. One last sidenotive kinda thing; How do you make a monster 'leech' life from you when it hits you? Im assuming its an onhitplayer (does that even exist)
Yup, something like:
Code:
public override void OnHitPlayer(Player target, int damage, bool crit)
{
    // Here we can calculate the amount we want to leech using the damage value. I'm just 'leeching' half of the damage done.
    int leechAmount = damage / 2;
    if( (leechAmount + npc.life) > npc.lifeMax) // If the amount we leech exceeds the max life of the player, we'll want to cut it down to the max value possible.
    { 
        leechAmount = npc.lifeMax - npc.life;
    }
    npc.life += leechAmount; // HEAL!
}
 
Yup, something like:
Code:
public override void OnHitPlayer(Player target, int damage, bool crit)
{
    // Here we can calculate the amount we want to leech using the damage value. I'm just 'leeching' half of the damage done.
    int leechAmount = damage / 2;
    if( (leechAmount + npc.life) > npc.lifeMax) // If the amount we leech exceeds the max life of the player, we'll want to cut it down to the max value possible.
    {
        leechAmount = npc.lifeMax - npc.life;
    }
    npc.life += leechAmount; // HEAL!
}

yay thanks
[DOUBLEPOST=1457609648,1457609432][/DOUBLEPOST]One FINAL THING! what is the TileID for all furnaces and the tileid for all anvils?
 
yay thanks
[DOUBLEPOST=1457609648,1457609432][/DOUBLEPOST]One FINAL THING! what is the TileID for all furnaces and the tileid for all anvils?
TileID.Furnaces OR 17
TileID.Anvils OR 16
(Hardmode Anvils) TileID.MythrilAnvil OR 134

If you want to know more, check this page.
 
what what is the line
recipe.AddIngredient(null, "ExampleItem");
for vanilla items?
 
what what is the line
recipe.AddIngredient(null, "ExampleItem");
for vanilla items?
Code:
// Dirt Block example:
recipe.AddIngredient(ItemID.DirtBlock);
// OR
recipe.AddIngredient(2);
Check here for a list of all items and their corresponding numerical IDs.
 
ok THIS IS MY LAST THING what ID do i use for the moon lord drops because there are hands head ect.
 
How do you open the tModLoaderInstaller??
 
How do you open the tModLoaderInstaller??
You double-click it?
Is it not working for you? If so, you can always manually copy+paste the files.
 
tModLoaderInstaller opens with java but my java doesn't work
[DOUBLEPOST=1457614891,1457614798][/DOUBLEPOST]
You double-click it?
Is it not working for you? If so, you can always manually copy+paste the files.
 

Attachments

  • 2016-03-10.png
    2016-03-10.png
    523.9 KB · Views: 246
tModLoaderInstaller opens with java but my java doesn't work
Then you can do it like I said.
Head over to your Terraria steam folder and copy+paste all files (excluding the readme and the installer that is) into that folder (even if you're not on mac, you'll still want to copy the TerrariaMac.exe over (really, just everything excluding the two files mentioned earlier)).
 
Then you can do it like I said.
Head over to your Terraria steam folder and copy+paste all files (excluding the readme and the installer that is) into that folder (even if you're not on mac, you'll still want to copy the TerrariaMac.exe over (really, just everything excluding the two files mentioned earlier)).
It worked but my characters and worlds are gone
 
It worked but my characters and worlds are gone
If you want to use your vanilla characters/world you'll have to copy them over to the tModLoader save folders (these are created seperately so you can switch back 'n forth between tModLoader and vanilla without problems).
If you go to C:\Users\USERNAME\Documents\My Games\Terraria you'll see folders named Worlds, Players, and ModLoader. You'll want to copy all files of the character/world you want to use from their respective folders into the folder that are named the same, but are in the ModLoader folder (I hope that's clear).
 
Made an account just to let you know that modded NPC's/Enemies disappearing upon taking damage in multiplayer has happened to at least two other players, me and my friend, who is hosting the server. Modded enemies work perfectly in dealing damage, walking around, etc. but when they take damage they instantly disappear. They don't drop anything, have any animation, or do anything but just vanish. Hope this confirms that bug.
 
Is there a way that I can remove all drops except for one that I add?
 
Is there a way that I can remove all drops except for one that I add?
Drops from vanilla NPCs I'm guessing?
You can have a class derive from GlobalNPC, override PreNPCLoot, spawn your item and return false (to stop vanilla loot to spawn):
Code:
public override bool PreNPCLoot(NPC npc)
{
    if(npc.type == NPCID.SkeletronHead)
    {
        Item.NewItem(blablabla);
        return false;
    }
    return false;
}
 
Drops from vanilla NPCs I'm guessing?
You can have a class derive from GlobalNPC, override PreNPCLoot, spawn your item and return false (to stop vanilla loot to spawn):
Code:
public override bool PreNPCLoot(NPC npc)
{
    if(npc.type == NPCID.SkeletronHead)
    {
        Item.NewItem(blablabla);
        return false;
    }
    return false;
}
If say I wanted the EoC to drop a dirt block, but nothing else at all.
 
Back
Top Bottom