Standalone [1.3] tModLoader - A Modding API

Also I can't launch it via steam itself, it will tell me the app is already running. Checked in manager, no Terraria.exe running.. ?
 
You're probably looking for this:
Code:
public override void Update(ref float gravity, ref float maxFallSpeed)
{
        Lighting.AddLight(item.position, Microsoft.Xna.Framework.Color.AliceBlue.ToVector3());
}

That is working, but not the color that we chose. The lighting is simply white. Doesn't matter if I change colors on the Color method either
 
That is working, but not the color that we chose. The lighting is simply white. Doesn't matter if I change colors on the Color method either

In that case, try this:
Code:
public override void Update(ref float gravity, ref float maxFallSpeed)
{
    Lighting.AddLight(item.position, 2, 3, 7);
}
The color there is more blue than Color.AliceBlue, but it also shouldn't be too bright to discern the color.
 
In that case, try this:
Code:
public override void Update(ref float gravity, ref float maxFallSpeed)
{
    Lighting.AddLight(item.position, 2, 3, 7);
}
The color there is more blue than Color.AliceBlue, but it also shouldn't be too bright to discern the color.

That does work, but it is far too bright (this whole spot is supposed to be pretty dark)

NcDlqWo.png
 
In that case, just tune down the color values.
For example:
Code:
public override void Update(ref float gravity, ref float maxFallSpeed)
{
        Lighting.AddLight(item.position, 0.5f, 0.33f, 1f);
}

Yeah I figured that.
Do you maybe have any clue how to use
public bool Shoot(Player player, Vector2 position, float speedX, float speedY, int type, int damage, float knockBack)
? My MVS is tripping, lol
 
-Make mods build as a single .tmod file that include image resources
If that means when you build a mod it saves as a single file, iether A: dont do that, for those who might want to edit it if its too balanced/unbalanced for them
B: make a "unbuild" or an ingame editor to edit it, this is just if its to balanced/unbalanced for people, or people like me, who like to edit stuff xD
 
If that means when you build a mod it saves as a single file, iether A: dont do that, for those who might want to edit it if its too balanced/unbalanced for them
B: make a "unbuild" or an ingame editor to edit it, this is just if its to balanced/unbalanced for people, or people like me, who like to edit stuff xD

What do you mean? You will keep mod sources as it is, but people can now steal your image files in 'Mods' . If it's all in the tmod file they can't.
 
Yeah I figured that.
Do you maybe have any clue how to use
public bool Shoot(Player player, Vector2 position, float speedX, float speedY, int type, int damage, float knockBack)
? My MVS is tripping, lol

After some testing, here's an example of what you can do.
Code:
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    if(Main.rand.Next(10)==0)
    {
        //spawn some other projectile
        Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, Terraria.ID.ProjectileID.MoonlordArrow, damage, knockBack, item.owner);
        //return false to prevent the weapon from firing it's normal projectile
        return false;
    }else
    if (Main.rand.Next(3) == 0)
    {
        //modify damage and knockback
        damage *= 2;
        knockBack *= 2;
        //fire an extra arrow
        Terraria.Projectile.NewProjectile(position.X, position.Y, speedX + Main.rand.NextFloat()-0.5f, speedY + Main.rand.NextFloat()-0.5f, item.shoot, damage, knockBack, item.owner);
    }
    //randomize the velocity a bit
    speedX *= (1f + Main.rand.NextFloat());
    speedY *= (1f + Main.rand.NextFloat());
    return true;
}
 
After some testing, here's an example of what you can do.
Code:
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    if(Main.rand.Next(10)==0)
    {
        //spawn some other projectile
        Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, Terraria.ID.ProjectileID.MoonlordArrow, damage, knockBack, item.owner);
        //return false to prevent the weapon from firing it's normal projectile
        return false;
    }else
    if (Main.rand.Next(3) == 0)
    {
        //modify damage and knockback
        damage *= 2;
        knockBack *= 2;
        //fire an extra arrow
        Terraria.Projectile.NewProjectile(position.X, position.Y, speedX + Main.rand.NextFloat()-0.5f, speedY + Main.rand.NextFloat()-0.5f, item.shoot, damage, knockBack, item.owner);
    }
    //randomize the velocity a bit
    speedX *= (1f + Main.rand.NextFloat());
    speedY *= (1f + Main.rand.NextFloat());
    return true;
}

It doesn't seem to work for my weapon (just a standard melee weapon with noMelee=true and it deals magic damage)
when I add item.shoot = 45 it does shoot, but stays in place forever..
 
What do you mean? You will keep mod sources as it is, but people can now steal your image files in 'Mods' . If it's all in the tmod file they can't.
oh, ok, but uh, why does all of the armour sets have a troll set bonus? i knew that ahead of time by trying to check where to craft it and how, i saw "
player.setBonus = "trollface.jpg";
player.meleeDamage *= 0.8f;
player.thrownDamage *= 0.8f;
player.rangedDamage *= 0.8f;
player.magicDamage *= 0.8f;
player.minionDamage *= 0.8f;
}"
so yeah, how do i remove this?
 
oh, ok, but uh, why does all of the armour sets have a troll set bonus? i knew that ahead of time by trying to check where to craft it and how, i saw "
player.setBonus = "trollface.jpg";
player.meleeDamage *= 0.8f;
player.thrownDamage *= 0.8f;
player.rangedDamage *= 0.8f;
player.magicDamage *= 0.8f;
player.minionDamage *= 0.8f;
}"
so yeah, how do i remove this?

It is just an example..
 
It is just an example..
i cant get how to remove it, am i just ment to NOT use a helmet? if its an example how do i edit it? if i increase the number my items go to like -453464356 damage and its annoying, if it was a plus it would be more usefull for editors but that just gets annoying how its a troll
 
It doesn't seem to work for my weapon (just a standard melee weapon with noMelee=true and it deals magic damage)
when I add item.shoot = 45 it does shoot, but stays in place forever..

Make sure item.shootSpeed is set, the demon sickle won't move otherwise. (although at least some other projectiles do)
 
Oh dear so many replies, maybe it wasn't such a good idea to release an update right before I went to bed. Sorry if I don't respond to everyone.

Is it possible to change recipes of vanilla items?
You'll have to loop through Main.recipe and check for the IDs for the requiredItem and createItem fields and manually replace the recipes yourself.

Hi, I have a question. I have two accessory how to do so would be wearing when one of them, the other can not wear it?
I might need to add another hook for that. I'll try to get that done next update.

I made a script to look up the recipe that created the right item.
Built the mod and then checked the log file.

Code:
public override void AddRecipes()
{
            int i;
            for(i=0;i<Main.recipe.Length;i++)
            {
                if(Main.recipe[i]!=null&&Main.recipe[i].createItem.type==3601)
                {
                    ErrorLogger.Log(Main.recipe[i].createItem.name);
                    ErrorLogger.Log(""+i);
                }
            }
}

Edit:
You can in fact 'remove' a vanilla recipe by replacing it with another and reducing the recipe count.

Code:
Main.recipe[1799] = Main.recipe[Recipe.numRecipes - 1];
Recipe.numRecipes --;

A word of caution though, Any alterations to vanilla recipes will not revert upon disabling your mod. You will need to restart Terraria in order for the changes to revert.

Also, when using the above method for deleting recipes additional recipes will be deleted each time you reload the mod. (unless additional steps are taken to prevent it.)
Hm, alterations to vanilla recipes should be repaired whenever the game reloads; I'll look into that.

i cant get how to remove it, am i just ment to NOT use a helmet? if its an example how do i edit it? if i increase the number my items go to like -453464356 damage and its annoying, if it was a plus it would be more usefull for editors but that just gets annoying how its a troll
What are you increasing it to? The player damage fields are multipliers, so if you set them too high there will probably be overflow or something. Try setting them to either *= 2f or += 1f.
 
What are you increasing it to? The player damage fields are multipliers, so if you set them too high there will probably be overflow or something. Try setting them to either *= 2f or += 1f.
oh ty, i was setting it to like player.meleeDamage *= 99999999999999999.8f; xD
p.s your shield got rekt by me, all i done was removed the else and that
 
Do you know if you could also get random directions? (top right bottom left etc)
I made something like that for someone once but don't remember what it is. Basically what I did was use Main.rand.Next based on the number of possible directions I wanted, multiplied that by the angle increment in radians, then used Math.Cos and Mat.Sin to set the velocities; these could be done from the Shoot method.
 
I can't even get it to shoot multiple projectiles via Shoot, I'm a moron.
I'm getting a random value between 1 and 6, then it has to shoot that amount. Doesn't work. I'm a moron.
<--- Moron
 
Back
Top Bottom