Standalone [1.3] tModLoader - A Modding API

how to i create multiple recipes for one item?? this one doesnt work:

Code:
public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "MagicSnow", 5);
            recipe.AddIngredient(ItemID.DemoniteBar, 1);
            recipe.AddIngredient(ItemID.ShadowScale, 1);
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this);
            recipe.AddRecipe();
          
            recipe.AddIngredient(null, "MagicSnow", 5);
            recipe.AddIngredient(ItemID.CrimtaneBar, 1);
            recipe.AddIngredient(ItemID.TissueSample, 1);
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
You'll want to reset your recipe variable, so before you begin your second recipe, use
Code:
recipe = new ModRecipe(mod);
 
also, another question:

how do i make my Projectiles make dust when they hit a tile?
i want em to explode into dust like the Terra Beam does (so they not just disappear)
 
also, another question:

how do i make my Projectiles make dust when they hit a tile?
i want em to explode into dust like the Terra Beam does (so they not just disappear)
As I matter of fact, I was just busy with such a thing:
Code:
public override void Kill(int timeLeft)
{
    for (int i = 4; i < 31; i++)
    {
        float x = projectile.oldVelocity.X * (30f / i);
        float y = projectile.oldVelocity.Y * (30f / i);
        int newDust = Dust.NewDust(new Vector2(projectile.oldPosition.X - x, projectile.oldPosition.Y - y), 8, 8, DustID.AmberBolt, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default(Color), 1.8f);
        Main.dust[newDust].noGravity = true;
        Main.dust[newDust].velocity *= 0.5f;
        newDust = Dust.NewDust(new Vector2(projectile.oldPosition.X - x, projectile.oldPosition.Y - y), 8, 8, DustID.AmberBolt, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default(Color), 1.4f);
        Main.dust[newDust].velocity *= 0.05f;
        Main.dust[newDust].noGravity = true;
    }
}
Do make sure to change the dust type (DustID.AmberBolt) to the dust type you want to use.
 
i want it to be multicolered dust, the projectile spawns a dust with 4 different colors:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SacredTools.Projectiles
{

    public class MoonBeam : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Moon Beam";  //projectile name
            projectile.width = 20;       //projectile width
            projectile.height = 28;  //projectile height
            projectile.friendly = true;      //make that the projectile will not damage you
            projectile.melee = true;         //
            projectile.tileCollide = true;   //make that the projectile will be destroed if it hits the terrain
            projectile.penetrate = 5;      //how many npc will penetrate
            projectile.timeLeft = 200;   //how many time this projectile has before disepire
            projectile.light = 0.75f;    // projectile light
            projectile.extraUpdates = 1;
            projectile.ignoreWater = true;  
        }
        public override void AI()           //this make that the projectile will face the corect way
        {                                                           // |
            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
            projectile.velocity.Y += projectile.ai[0];
    
    
            if (projectile.localAI[0] == 0f)
            {
                Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20);
                projectile.localAI[0] = 1f;
            }
            int num666 = 8;
            Color color = new Color(36, 158, 184);
            int rand = Main.rand.Next(4);
            switch (rand)
            {
                case 0:
                color = new Color(255, 135, 0);
                break;
                case 1:
                color = new Color(255, 0, 248);
                break;
                case 2:
                color = new Color(28, 201, 132);
                break;
                case 3:
                color = new Color(9, 222, 255);
                break;
            }
            int num667 = Dust.NewDust(new Vector2(projectile.position.X + (float)num666 + 6, projectile.position.Y + (float)num666), projectile.width - num666 * 2, projectile.height - num666 * 2, 66, 0f, 0f, 0,color, 1.5f);  //projectile dust color
            Main.dust[num667].velocity *= 0.5f;
            Main.dust[num667].velocity += projectile.velocity * 0.1f;
            Main.dust[num667].noGravity = true;
            Main.dust[num667].noLight = false;
            Main.dust[num667].scale = 1.5f;
        }
           
           
       
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(mod.BuffType("MoonCurse"), 500);
            target.AddBuff(BuffID.Chilled, 500);
            target.AddBuff(BuffID.Frostburn, 500);
        }
       
       
       
       
       
    }
}

i want the dustexplosion to be multicolored aswell
 
i want it to be multicolered dust, the projectile spawns a dust with 4 different colors:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SacredTools.Projectiles
{

    public class MoonBeam : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Moon Beam";  //projectile name
            projectile.width = 20;       //projectile width
            projectile.height = 28;  //projectile height
            projectile.friendly = true;      //make that the projectile will not damage you
            projectile.melee = true;         //
            projectile.tileCollide = true;   //make that the projectile will be destroed if it hits the terrain
            projectile.penetrate = 5;      //how many npc will penetrate
            projectile.timeLeft = 200;   //how many time this projectile has before disepire
            projectile.light = 0.75f;    // projectile light
            projectile.extraUpdates = 1;
            projectile.ignoreWater = true; 
        }
        public override void AI()           //this make that the projectile will face the corect way
        {                                                           // |
            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
            projectile.velocity.Y += projectile.ai[0];
   
   
            if (projectile.localAI[0] == 0f)
            {
                Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20);
                projectile.localAI[0] = 1f;
            }
            int num666 = 8;
            Color color = new Color(36, 158, 184);
            int rand = Main.rand.Next(4);
            switch (rand)
            {
                case 0:
                color = new Color(255, 135, 0);
                break;
                case 1:
                color = new Color(255, 0, 248);
                break;
                case 2:
                color = new Color(28, 201, 132);
                break;
                case 3:
                color = new Color(9, 222, 255);
                break;
            }
            int num667 = Dust.NewDust(new Vector2(projectile.position.X + (float)num666 + 6, projectile.position.Y + (float)num666), projectile.width - num666 * 2, projectile.height - num666 * 2, 66, 0f, 0f, 0,color, 1.5f);  //projectile dust color
            Main.dust[num667].velocity *= 0.5f;
            Main.dust[num667].velocity += projectile.velocity * 0.1f;
            Main.dust[num667].noGravity = true;
            Main.dust[num667].noLight = false;
            Main.dust[num667].scale = 1.5f;
        }
          
          
      
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(mod.BuffType("MoonCurse"), 500);
            target.AddBuff(BuffID.Chilled, 500);
            target.AddBuff(BuffID.Frostburn, 500);
        }
      
      
      
      
      
    }
}

i want the dustexplosion to be multicolored aswell
That's possible, just apply the color change to the dust spawned in the Kill method.
 
could you insert it into the code for me please?
idk wat to change ._.
It's litterally just fusing the color code and the Kill code together:
Code:
public override void Kill(int timeLeft)
{
    for (int i = 4; i < 31; i++)
    {
        Color color = new Color(36, 158, 184);
        int rand = Main.rand.Next(4);
        switch (rand)
        {
            case 0:
            color = new Color(255, 135, 0);
            break;
            case 1:
            color = new Color(255, 0, 248);
            break;
            case 2:
            color = new Color(28, 201, 132);
            break;
            case 3:
            color = new Color(9, 222, 255);
            break;
        }
      
        float x = projectile.oldVelocity.X * (30f / i);
        float y = projectile.oldVelocity.Y * (30f / i);
        int newDust = Dust.NewDust(new Vector2(projectile.oldPosition.X - x, projectile.oldPosition.Y - y), 8, 8, DustID.AmberBolt, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, color, 1.8f);
        Main.dust[newDust].noGravity = true;
        Main.dust[newDust].velocity *= 0.5f;
        newDust = Dust.NewDust(new Vector2(projectile.oldPosition.X - x, projectile.oldPosition.Y - y), 8, 8, DustID.AmberBolt, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, color, 1.4f);
        Main.dust[newDust].velocity *= 0.05f;
        Main.dust[newDust].noGravity = true;
    }
}
 
do i still have to remove the DustID.AmberBolt??
Well, for that you'll want to look at which dust type you're using.
I was using DustID.AmberBolt in my code, now in your own color dust, you were using the direct integral type 66.
So you want to replace DustID.AmberBolt with 66.
 
Hey ho guys!

Maybe someone could help me with a problem.
I'm playing on a Mac and installed everything but i can't browse any mods...

when i click on the mod browser there is just no mod to see i tried reloading but its not working.


Looking forward to get some informations about that!

greetings Manu
 
hmmmm.... the TileHit dust kinda spawns offset above the Projectile...
[doublepost=1468411918,1468411890][/doublepost]and, idk wats wrong, im on windows cant rly help u
 
Is it possible to make a tModLoader dedicated Server on Linuux (Debian) ? If you know a good tutorial, please let me know. I can't simply download the files of terraria from steam network on my server + add the files and replace them with the TML Files... It just crashes...
 
next question:

how do i add more Loot to the GlobalNPC file??
i want to add some drops to the Towers

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SacredTools.NPCs
{
    public class ModGlobalNPC : GlobalNPC
    {
        public override void NPCLoot(NPC npc)
        {

           
            if ((npc.type == NPCID.PossessedArmor) || (npc.type == NPCID.Wraith) || (npc.type == NPCID.Reaper))
            {
                if (Main.rand.Next(2) == 0)   //item rarity
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OblivionOre")); //Item spawn
                }
            }
           
           
       
        }
    }
}
 
next question:

how do i add more Loot to the GlobalNPC file??
i want to add some drops to the Towers

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SacredTools.NPCs
{
    public class ModGlobalNPC : GlobalNPC
    {
        public override void NPCLoot(NPC npc)
        {

          
            if ((npc.type == NPCID.PossessedArmor) || (npc.type == NPCID.Wraith) || (npc.type == NPCID.Reaper))
            {
                if (Main.rand.Next(2) == 0)   //item rarity
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OblivionOre")); //Item spawn
                }
            }
          
          
      
        }
    }
}
Code:
public override void NPCLoot(NPC npc)
{  
    if ((npc.type == NPCID.PossessedArmor) || (npc.type == NPCID.Wraith) || (npc.type == NPCID.Reaper))
    {
        if (Main.rand.Next(2) == 0)   //item rarity
        {
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OblivionOre")); //Item spawn
        }
    }
    else if(npc.type == NPCID.LunarTowerNebula)
    {
        // Drop your tower stuff
    }
    else if(npc.type == NPCID.LunarTowerStardust)
    {
        // Drop your tower stuff
    }   
    // Etc. etc.
}
 
wow! thank you m8!

you will come into my credits too ^-^

(do you want a special item?)
[doublepost=1468419490,1468419203][/doublepost]also, is if (Main.rand.Next(2) == 0) //item rarity

33% or 50% ??
 
wow! thank you m8!

you will come into my credits too ^-^

(do you want a special item?)
[doublepost=1468419490,1468419203][/doublepost]also, is if (Main.rand.Next(2) == 0) //item rarity

33% or 50% ??
That's 50%, since the max number is excluded (meaning this function will yield either 0 or 1).
 
Back
Top Bottom