Standalone [1.3] tModLoader - A Modding API

I'm not sure what you're suggesting is ever going to work. You could, however, allow the player to right-click while holding the 2.0 weapon to consume Overclockers from the inventory, which then save the cumulative bonus as custom data. There's an example of custom data management in ExamplePlayer, I think.
is there a way to directly use a vanilla sprite instead of copying and renaming them?
 
Is there currently any way to access Terraria's shader IDs? Is there a list somewhere? I can't seem to be able to access the proper GetShaderFromItemID method as used in vanilla code. As it is, it appears that we can "create" dyes, but we're unable to actually get the shader IDs that make them work.

Additionally, I think it would be cool if we were allowed to create new shaders.

EDIT: Another question: Is it possible to locate (and get the object of) a specific item in the inventory? For example: a worn armor piece, something in the main inventory, something in a dye slot, etc.
 
Last edited:
If i wanted to create a custom trap such as turrets etc for a mechanic class Where would i get the basic trap code so i can use it as a basis?
 
There are no booleans to indicate non-consumability (I hereby patent that word). Thankfully, tModLoader has a very useful solution to that in the form of the ConsumeAmmo hook.

Put this in your ModItem class (if it is a weapon, that is. If it's something else, let me know).
Code:
public override bool ConsumeAmmo(Player player)
{
    if (Main.rand.Next(3) == 0) // Generates a random number between 0 and 3 (0, 1 or 2)
    {
        return false;
    }
    return true;
}

If that doesn't work, add using Microsoft.Xna.Framework; to the top of your code.
Its an accessory, but I need that code for my next thing so thanks!
 
Am I right that NPC.downedBoss1 is Eye of Cthulhu, NPC.downedBoss2 is the Destroyer, and NPC.downedBoss3 is Skeletron?
 
im just full of questions, how can i shoot 3 projectiles, in the same direction, all projectile ID 145, but with different speeds?
 
im just full of questions, how can i shoot 3 projectiles, in the same direction, all projectile ID 145, but with different speeds?
I'm too lazy to write some code, but it involves a for loop multiplying the speeds by 1f, .8f, and .6f for each projectile, respectively.
 
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace Pack.Projectiles
{
    public class PossessedTempliteHammerP : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Possessed Templite Hammer";
            projectile.width = 52;
            projectile.height = 52;
            projectile.friendly = true;
            projectile.penetrate = -1;
            projectile.aiStyle = 3;
            projectile.melee = true;
            projectile.tileCollide = false;
            projectile.timeLeft = 60000;
            projectile.light = 1f;
        }
        public override void OnHitNPC(NPC n, int damage, float knockback, bool crit)
        {
            Player player = Main.player[projectile.owner];
            player.statLife += 10; //Heals by 10; Can be changed of course
            player.HealEffect(10); //Shows a green 10 above your head to show you've been healed; Can be changed of course
            if (projectile.ai[1] > 0)
                projectile.ai[0] = 0;
            if (projectile.ai[0] == 0f)
            {
                projectile.velocity *= -1;
            }
            projectile.netUpdate = true;
        }
        public override void PostAI()
        {
            Main.NewText("ai[0]: " + projectile.ai[0] + ", ai[1]: " + projectile.ai[1]);
            if (projectile.ai[0] == 1)
            {
                projectile.velocity *= 2;
            }

        }
    }
}
OK, so it seems that simply multiplying the projectile's velocity was a bad idea. Replace this:
Code:
if (projectile.ai[0] == 1)
            {
                projectile.velocity *= 2;
            }
with this:
Code:
if (projectile.ai[0] == 1)
            {
                Player myOwner = Main.player[projectile.owner]; //find the owner of this projectile
                Vector2 toMe = Vector2.Normalize(myOwner.Center - projectile.Center); //find the distance from this projectile to it's owner and convert to a unit vector.
                projectile.velocity += toMe * 1f; //add the above vector to this projectile's velocity -- change 1f to change the return speed
            }
That worked for me, and I've added comments that hopefully describe what's going on.
 
Back
Top Bottom