tAPI Getting Started with Modding

Status
Not open for further replies.
Code:
using Terraria;
using TAPI;

namespace Internalmodname
{
    public class Internalmodname : ModWorld
    {
        public override void WorldGenPostGen()
        {
            ModifyWorld();
        }

public void ModifyWorld()
{
Main.statusText = "Inserttexthere"; //This is what displays as your ore is being generated. feel free to tweak
int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //feel free to tweak
for(int i=0;i<Amount_Of_Spawns;i++) AddMyOres();
}
public void AddMyOres()
{
int LowX = 200; //after ocean on left edge of map
int HighX = Main.maxTilesX-200; //before ocean on right edge of map
int LowY = (int)Main.worldSurface; //where the brown background and the sky background meets
int HighY = Main.maxTilesY-200; //where hell and the grey background meets

int X = WorldGen.genRand.Next(LowX,HighX); //don't touch
int Y = WorldGen.genRand.Next(LowY,HighY); //don't touch

int OreMinimumSpread = 8; //minimum amount of ore in a vein. feel free to tweak
int OreMaximumSpread = 18; //Maximum amount of ore in a vein. feel free to tweak

int OreMinimumFrequency = 1; //feel free to tweak, this and the next line mean how frequent your ore spawns.
int OreMaximumFrequency = 15; //feel free to tweak

int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); //don't touch
int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); //don't touch

WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, TileDef.byName["Internalmodname:nameoforeintilesfolder"]);
}
    }
}
This piece of code should get to the main post.
 
Can somebody explain to me the different use/hold styles? Y'know, referring to the lines of code in any item's .json file that say "useStyle" and "holdStyle".
 
Berb, do you know how to create a custom AI? (Even just a simple one like make them move and perform tasks) I am tired of using vanilla AI so I just wanted to start my own AI.
or even know someone who knows someone who knows someone......... who knows how? :naughty:
 
Berb, do you know how to create a custom AI? (Even just a simple one like make them move and perform tasks) I am tired of using vanilla AI so I just wanted to start my own AI.
or even know someone who knows someone who knows someone......... who knows how? :naughty:
I kind of have a tutorial here: http://forums.terraria.org/index.php?threads/tutorial-custom-bosses-npc-ai-and-server-syncing.10474/
It's still in progress and has more information than you need (since it's for bosses), but it covers everything you need to consider when you're making an AI. This tutorial might get a bit complicated though :/
The things that AI does the most is to edit velocity and create projectiles.

On the other hand, if you want something simple, first you can just use a vanilla AI as usual. Then, create a class for your NPC, then when you override the AI method, just add in whatever extra things you want (such as creating a projectile, or editing the velocity your own way).
 
Hey @berberborscing do you know how make an npc drop an custom item?
Doesn't my NPC tutorial provide an example? The Night Owl drops Night Vision Goggles in it
Can somebody explain to me the different use/hold styles? Y'know, referring to the lines of code in any item's .json file that say "useStyle" and "holdStyle".
There are 5 use styles. 1 swings the item. 2 drinks it like a potion. 4 holds up the item like a life crystal. 5 holds it out like a gun.
 
Doesn't my NPC tutorial provide an example? The Night Owl drops Night Vision Goggles in it

There are 5 use styles. 1 swings the item. 2 drinks it like a potion. 4 holds up the item like a life crystal. 5 holds it out like a gun.

but like an exemple i want WoF drop a new item but this tutorial not show this :/
 
but like an exemple i want WoF drop a new item but this tutorial not show this :/
If you want to add drops to a vanilla NPC, you'll have to work with loot rules. Here's an example that you can insert into your ModBase class's OnLoad method:
Code:
LootRule.settingUp = true;
LootRule[] rules = new LootRule[1];
rules[0] = new LootRule().Item("ModName:ItemName").Stack(5, 10).Chance(0.5);
LootRule.AddFor("Wall of Flesh", rules[0]);
LootRule.settingUp = false;
What that code will do basically is make the WoF drop 5 to 10 of ItemName with a 50% chance.
 
If you want to add drops to a vanilla NPC, you'll have to work with loot rules. Here's an example that you can insert into your ModBase class's OnLoad method:
Code:
LootRule.settingUp = true;
LootRule[] rules = new LootRule[1];
rules[0] = new LootRule().Item("ModName:ItemName").Stack(5, 10).Chance(0.5);
LootRule.AddFor("Wall of Flesh", rules[0]);
LootRule.settingUp = false;
What that code will do basically is make the WoF drop 5 to 10 of ItemName with a 50% chance.
God, no. Don't change the value of LootRule.settingUp. Use proper hooks for adding loot instead, where settingUp is already true.
 
God, no. Don't change the value of LootRule.settingUp. Use proper hooks for adding loot instead, where settingUp is already true.
Which hooks are you talking about? I couldn't find any for editing vanilla monster drops yet.
And slightly off-topic, for custom NPCs, the SetupLootRules method doesn't work since settingUp happens to be false when it is called, so MarkModified() gets called which causes some NullReference exception when Restore() is called upon the NPC's death.
I'm still relatively new to modding; so if you could explain these things, thanks!
 
Status
Not open for further replies.
Back
Top Bottom