tModLoader Official tModLoader Help Thread

How would I make a fishing rod?
Code:
this.useStyle = 1;
this.useAnimation = 8;
this.useTime = 8;
this.useSound = 1;

item.shoot is changing depending on the type:
Code:
this.shoot = 361 + type - 2291;
If you want to try out, here are the checked type for fishing poles:
Code:
type == 2289 || (type >= 2291 && type <= 2296)
[doublepost=1475681223,1475681057][/doublepost]
Is there any way I would be able to change the tool tips for vannila items?
You sure can, by overriding vanilla SetDefaults in a GlobalItem class. Taken from ExampleMod:
Code:
    public class CopperShortsword : GlobalItem
    {
        public override void SetDefaults(Item item)
        {
            if (item.type == ItemID.CopperShortsword)
            {
                item.damage = 50;
            }
        }
    }
tl;dr: check for item type, change anything.
[doublepost=1475681298][/doublepost]
An error occurred while loading CorruptionCandles
This mod has automatically been disabled.

Items/Placeable/CursedCandle
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
GetTexture, this means tML can't load the texture for this sprite. Make sure they're in the same location and have the exact same name (in this case, CursedCandle)
[doublepost=1475681393][/doublepost]
Could you please tell me how?
Use any of the ModifyHit hooks available for your ModProjectile. Example:
Code:
        public override void ModifyHitNPC(Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit)
        {
                target.AddBuff(BuffID.OnFire, Main.rand.Next(6, 12) * 60);
                target.AddBuff(BuffID.Ichor, Main.rand.Next(6, 12) * 60);
       }
This gives any hit NPC the On Fire and Ichor debuff for 6 up to 11 seconds. (time is in ticks, hence * 60)
 
c:\Users\Drew Welch\Documents\My Games\Terraria\ModLoader\Mod Sources\GmodTowerWeps\Items\Weapons\SuperShotty.cs(45,43) : warning CS0162: Unreachable code detected c:\Users\Drew Welch\Documents\My Games\Terraria\ModLoader\Mod Sources\GmodTowerWeps\Items\Weapons\SuperShotty.cs(42,24) : error CS0161: 'GmodTowerWeps.Items.Weapons.SuperShotty.Shoot(Terraria.Player, ref Microsoft.Xna.Framework.Vector2, ref float, ref float, ref int, ref int, ref float)': not all code paths return a value
Let me help you out. ftfy, your code had several syntax issues and pretty bad formatting. I changed it for you.
The Shoot method returns a bool, you returned false in all situations so you can just return false at the end of your code. The main reason for the code breaking was syntax errors. (most likely due to your bad formatting)
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using GmodTowerWeps.Items;

namespace GmodTowerWeps.Items.Weapons
{
    public class SuperShotty : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            texture = "GmodTowerWeps/Items/Weapons/SuperShotty";
            return true;
        }
       
        public override void SetDefaults()
        {
            item.name = "Super Shotty";
            item.damage = 135;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "Fires a massive spread of bullets that causes recoil";
            item.toolTip2 = "Who needs legendary weapons when you have a shotgun?";
            item.useTime = 48;
            item.useAnimation = 48;
            item.useStyle = 5;
            item.noMelee = true;
            item.knockBack = 5;
            item.value = 12000000;
            item.rare = 9;
            item.useSound = 36;
            item.autoReuse = false;
            item.shoot = 10;
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
            item.expert = true;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int numberProjectiles = 30 + Main.rand.Next(5);
            for (int i = 0; i < numberProjectiles; i++)
            {
                Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(40));
                Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
            }
            if (player.direction > 0)
            {
                player.velocity.X -= 15f;
            }
            if (player.direction < 0)
            {
                player.velocity.X += 15f;
            }
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Shotgun, 1);
            recipe.AddIngredient(ItemID.IllegalGunParts, 1);
            recipe.AddIngredient(ItemID.LunarBar, 25);
            recipe.AddIngredient(ItemID.FragmentVortex, 35);
            recipe.AddIngredient(ItemID.GravityGlobe, 1);
            recipe.AddTile(TileID.LunarCraftingStation);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
[doublepost=1475682251,1475682181][/doublepost]
Can someone help a total noob(me) in a problem?
What does this error code mean and how to fix it?
I'll show my code, which is pretty much copypasted from the example mod if it is needed
Code:
Failed to load C:\Users\Samu\Documents\My Games\Terraria\ModLoader\Mod Sources\Headband\build.txt
System.FormatException: Input string was not in a correct format.
   at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String argument)
   at System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent)
   at System.Version.TryParseVersion(String version, VersionResult& result)
   at System.Version.Parse(String input)
   at System.Version..ctor(String version)
   at Terraria.ModLoader.BuildProperties.ReadBuildFile(String modDir)
   at Terraria.ModLoader.ModCompile.ReadProperties(String modFolder, IBuildStatus status)
This means you entered something in your version property in build.txt that isn't allowed, namely letters. You can only use periods and numbers. eg: 1.0.1.2
 
So with tModLoader is it possible to...

-Remove the starting copper items?
-Reduce the pickaxe power of a pickaxe?(Cactus Pickaxe)
-Change the range of an existing pickaxe?
-Change starting hearts?
1. If you want to remove the items a player starts with, you can use the SetupStartInventory in a ModPlayer class. If you wish to see more elaborate usage of this hook, I suggest you take a look at my Fast Start mod's code.
Code:
public override void SetupStartInventory(IList<Item> items)
{
    items.Clear();
}
2. To change a vanilla's item's properties you need to override its SetDefaults from a GlobalItem class.
Code:
public override void SetDefaults(Item item)
{
    if (item.type == ItemID.CactusPickaxe)
    {
        item.pick = 0;
    }
}
3. I believe this is tied to the player instance, but items have a tileBoost property. Can do this the same way as 2.
Code:
public override void SetDefaults(Item item)
{
    if (item.type == ItemID.CactusPickaxe)
    {
        item.tileBoost = 5;
    }
}
4. Do you mean changing the starting health of a character? In such a case, I doubt it's possible. I wouldn't know how to do it with the current available hooks.
[doublepost=1475685975,1475685688][/doublepost]
How do I get a custom potion to apply a custom buff?
You can use the UseItem hook available in a ModItem class.
This override will grant the On Fire! debuff for 6 seconds.
Code:
public override bool UseItem(Item item, Player player)
{
    player.AddBuff(BuffID.OnFire, 360, false);
    return base.UseItem(item, player);
}
 
They do have the same name, my cs file is named "CursedCandle.cs" and my png file is named "CursedCandle.png" and I also have "CursedCandle_Flame.png" in the same folder. This is the cs file for it:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExampleMod.Items.Placeable
{
    public class CursedCandle : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Cursed Candle";
            item.width = 16;
            item.height = 20;
            item.maxStack = 99;
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.rare = 10;
            item.createTile = mod.TileType("CursedCandle");
            item.flame = true;
            item.value = 50;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.AdamantiteBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
         
            recipe.AddIngredient(ItemID.TitaniumBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
Last edited:
Do you have autoload properties set to true?
You mean in the main cs? I think so:

This is my CorruptionCandles.cs (the cs named after the mod):
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace CorruptionCandles
{
    public class CorruptionCandles : Mod
    {
        public CorruptionCandles()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
}
 
You mean in the main cs? I think so:

This is my CorruptionCandles.cs (the cs named after the mod):
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace CorruptionCandles
{
    public class CorruptionCandles : Mod
    {
        public CorruptionCandles()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
}
Fix the namespace of the item to match the folder structure.
 
Fix the namespace of the item to match the folder structure.
Ah, that fixed it. Thanks both of you.

EDIT: I realized that I made the crafting wrong. I want a recipe that includes adamantite and another that includes titanium, but I had the recipes combined as one so I seperated them. Now I'm getting this error so I can tell I'm doing it wrong:

c:\Users\cntdr\Documents\My Games\Terraria\ModLoader\Mod Sources\CorruptionCandles\Items\Placeable\CursedCandle.cs(37,14) : error CS0128: A local variable named 'recipe' is already defined in this scope

Here's my code:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CorruptionCandles.Items.Placeable
{
    public class CursedCandle : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Cursed Candle";
            item.width = 16;
            item.height = 20;
            item.maxStack = 99;
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.rare = 10;
            item.createTile = mod.TileType("CursedCandle");
            item.flame = true;
            item.value = 50;
        }

        public override void AddRecipes()
        {
           
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.AdamantiteBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
           
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TitaniumBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
Last edited:
Ah, that fixed it. Thanks both of you.

EDIT: I realized that I made the crafting wrong. I want a recipe that includes adamantite and another that includes titanium, but I had the recipes combined as one so I seperated them. Now I'm getting this error so I can tell I'm doing it wrong:

c:\Users\cntdr\Documents\My Games\Terraria\ModLoader\Mod Sources\CorruptionCandles\Items\Placeable\CursedCandle.cs(37,14) : error CS0128: A local variable named 'recipe' is already defined in this scope

Here's my code:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CorruptionCandles.Items.Placeable
{
    public class CursedCandle : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Cursed Candle";
            item.width = 16;
            item.height = 20;
            item.maxStack = 99;
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.rare = 10;
            item.createTile = mod.TileType("CursedCandle");
            item.flame = true;
            item.value = 50;
        }

        public override void AddRecipes()
        {
         
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.AdamantiteBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
         
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TitaniumBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
You are declaring two recipes with the same name, which causes a syntax error. Either change the second one to 'recipe2', or reuse the same one by replacing the second 'ModRecipe recipe =' with 'recipe ='.
 
ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.AdamantiteBar, 1); recipe.AddIngredient(ItemID.CursedTorch, 1); recipe.AddTile(TileID.WorkBenches); recipe.SetResult(this); recipe.AddRecipe(); ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.TitaniumBar, 1); recipe.AddIngredient(ItemID.CursedTorch, 1); recipe.AddTile(TileID.WorkBenches); recipe.SetResult(this); recipe.AddRecipe();
Code:
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.AdamantiteBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
          
            recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TitaniumBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
ftfy
 
Code:
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.AdamantiteBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
       
            recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TitaniumBar, 1);
            recipe.AddIngredient(ItemID.CursedTorch, 1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
ftfy

Thanks that fixed it.

EDIT: Okay, I'm having a difficult time with my candles' tile. I tried to fix the problems the best I can, but now I'm stuck. This is my codes:

Code:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace CorruptionCandles.Tiles
{
    public class CursedCandle : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileFrameImportant[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style1xX);
            TileObjectData.newTile.UsesCustomCanPlace = true;
            TileObjectData.newTile.Height = 1;
            TileObjectData.newTile.Width = 1;
            TileObjectData.newTile.Origin = new Point16(0, 0);
            TileObjectData.newTile.CoordinateHeights = new int[]{ 16, 16, 22 };
            TileObjectData.addTile(Type);
            AddMapEntry(new Color(0, 255, 0));
            dustType = 1;
            animationFrameHeight = 20;
            disableSmartCursor = true;
            drop = mod.ItemType("CursedCandle");
            AddMapEntry(new Color(0, 255, 0), "Torch");
            dustType = mod.DustType("Sparkle");
            torch = true;
        }

        public override void NumDust(int i, int j, bool fail, ref int num)
        {
            num = Main.rand.Next(1, 3);
        }

        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            Tile tile = Main.tile[i, j];
            if (tile.frameX < 66)
            {
                r = 0.0f;
                g = 1.0f;
                b = 0.0f;
            }
        }

        public override void NearbyEffects(int i, int j, bool closer)
        {
            if(closer)
            {
                Main.player[Main.myPlayer].AddBuff(mod.BuffType("CursedCandle"), 2);
            }
        }

        public override void AnimateTile(ref int frame, ref int frameCounter)
        {
            frame = Main.tileFrame[TileID.WaterCandle];
            frameCounter = Main.tileFrameCounter[TileID.WaterCandle];
        }

        public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
        {
            ulong randSeed = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)((ulong)i));
            Color color = new Color(100, 100, 100, 0);
            int frameX = Main.tile[i, j].frameX;
            int frameY = Main.tile[i, j].frameY;
            int width = 16;
            int offsetY = 0;
            int height = 20;
            if (WorldGen.SolidTile(i, j - 1))
            {
                offsetY = 2;
                if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1))
                {
                    offsetY = 4;
                }
            }
            Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange);
            if (Main.drawToScreen)
            {
                zero = Vector2.Zero;
            }
            for (int k = 0; k < 7; k++)
            {
                float x = (float)Utils.RandomInt(ref randSeed, -10, 11) * 0.15f;
                float y = (float)Utils.RandomInt(ref randSeed, -10, 1) * 0.35f;
                Main.spriteBatch.Draw(mod.GetTexture("Tiles/CursedCandle_Flame"), new Vector2((float)(i * 16 - (int)Main.screenPosition.X) - (width - 16f) / 2f + x, (float)(j * 16 - (int)Main.screenPosition.Y + offsetY) + y) + zero, new Rectangle(frameX, frameY, width, height), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
            }
        }

    }
}

Code:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace CorruptionCandles.Tiles
{
    public class CrimsonCandle : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileFrameImportant[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style1xX);
            TileObjectData.newTile.UsesCustomCanPlace = true;
            TileObjectData.newTile.Height = 1;
            TileObjectData.newTile.Width = 1;
            TileObjectData.newTile.Origin = new Point16(0, 0);
            TileObjectData.newTile.CoordinateHeights = new int[]{ 16, 16, 22 };
            TileObjectData.addTile(Type);
            AddMapEntry(new Color(0, 255, 0));
            dustType = 1;
            animationFrameHeight = 20;
            disableSmartCursor = true;
            drop = mod.ItemType("CrimsonCandle");
            AddMapEntry(new Color(0, 255, 0), "Torch");
            dustType = mod.DustType("Sparkle");
            torch = true;
        }

        public override void NumDust(int i, int j, bool fail, ref int num)
        {
            num = Main.rand.Next(1, 3);
        }

        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            Tile tile = Main.tile[i, j];
            if (tile.frameX < 66)
            {
                r = 0.0f;
                g = 1.0f;
                b = 0.0f;
            }
        }

        public override void NearbyEffects(int i, int j, bool closer)
        {
            if(closer)
            {
                Main.player[Main.myPlayer].AddBuff(mod.BuffType("CrimsonCandle"), 2);
            }
        }

        public override void AnimateTile(ref int frame, ref int frameCounter)
        {
            frame = Main.tileFrame[TileID.WaterCandle];
            frameCounter = Main.tileFrameCounter[TileID.WaterCandle];
        }

        public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
        {
            ulong randSeed = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)((ulong)i));
            Color color = new Color(100, 100, 100, 0);
            int frameX = Main.tile[i, j].frameX;
            int frameY = Main.tile[i, j].frameY;
            int width = 16;
            int offsetY = 0;
            int height = 20;
            if (WorldGen.SolidTile(i, j - 1))
            {
                offsetY = 2;
                if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1))
                {
                    offsetY = 4;
                }
            }
            Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange);
            if (Main.drawToScreen)
            {
                zero = Vector2.Zero;
            }
            for (int k = 0; k < 7; k++)
            {
                float x = (float)Utils.RandomInt(ref randSeed, -10, 11) * 0.15f;
                float y = (float)Utils.RandomInt(ref randSeed, -10, 1) * 0.35f;
                Main.spriteBatch.Draw(mod.GetTexture("Tiles/CrimsonCandle_Flame"), new Vector2((float)(i * 16 - (int)Main.screenPosition.X) - (width - 16f) / 2f + x, (float)(j * 16 - (int)Main.screenPosition.Y + offsetY) + y) + zero, new Rectangle(frameX, frameY, width, height), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
            }
        }

    }
}

I'm having a lot of issues, so I don't know if this is too much for one post, so I'm not expecting help for all of this at once:

The 2 biggest problems:

  • The buff is added for a couple of seconds then it disappears.
  • The CrimsonCandle.cs is very similar to CursedCandle.cs, yet unlike the Cursed Candle, when I place the Crimson Candle down it has no animation and all background furniture and leaves becomes invisible.

My other problems are:

  • Neither of the torches are giving off light.
  • How do I make it so that the candle is only placed on surfaces like crafting tables, and platforms?
  • I also seem to be getting the animation wrong. I used the "public override void PostDraw" from ExampleTorch.cs as a reference, but I don't understand the whole thing. I attached the Cursed Candle image files. As the animation moves, I see the pink line on the right of the candle fluctuate between in different sizes between being drawn in a little bit and not being drawn at all.
 

Attachments

  • CursedCandle.png
    CursedCandle.png
    356 bytes · Views: 166
  • CursedCandle_Flame.png
    CursedCandle_Flame.png
    358 bytes · Views: 145
Last edited:
ok I found out how to add a glow/light effect but still no luck with lifesteal, any help would be appreciated
 
Is the "backend" for the mod browser down?

I was able to use it just fine for the past few days, but today, it locks up my game.
All I can do it ctrl-alt-del but can't even get to the Task Manager, because my entire screen turns white.
 
Is the "backend" for the mod browser down?

I was able to use it just fine for the past few days, but today, it locks up my game.
All I can do it ctrl-alt-del but can't even get to the Task Manager, because my entire screen turns white.
The mod browser is in beta and not entirely reliable, it's down more often than you might think. Usually this is due to high traffic
 
ok I found out how to add a glow/light effect but still no luck with lifesteal, any help would be appreciated
It's not all that hard.
There's a method for projectiles that's called when the projectile hits an NPC (look it up on the GitHub tModLoader wiki, I'm sure you can find it).
Then you just want to up the life of the player that owns the boomerang projectile in question. Example:
Code:
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
    Player player = Main.player[projectile.owner];

    // Get a correct heal amount.
    // What this code basically does is it checks if the player is missing life and if it is set a correct heal amount, which cannot exceed 10.
    // So if statLifeMax2 is 200 and the player has 100 health healAmount gets set to 10, but when it's 195 healAmount gets set to 5.    
    int healAmount = MathHelper.Clamp(player.statLifeMax2 - player.statLife, 0, 10);

    player.statLife += healAmount; // Up the life of the player by the healAmount value.
    player.HealEffect(healAmount); // Displays the heal text
}
Off the top of my head; that should work.
 
It's not all that hard.
There's a method for projectiles that's called when the projectile hits an NPC (look it up on the GitHub tModLoader wiki, I'm sure you can find it).
Then you just want to up the life of the player that owns the boomerang projectile in question. Example:
Off the top of my head; that should work.
On top of that, you could add a little bit of randomization to the heal using Main.rand (just a random example)
Code:
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
    Player player = Main.player[projectile.owner];

    // Get a correct heal amount.
    // What this code basically does is it checks if the player is missing life and if it is set a correct heal amount, which cannot exceed 10.
    // So if statLifeMax2 is 200 and the player has 100 health healAmount gets set to 10, but when it's 195 healAmount gets set to 5.  
    int healAmount = MathHelper.Clamp(player.statLifeMax2 - player.statLife, 0, 10);
    int realHeal = healAmount + Main.rand.Nex(1, 6) - 2;
   
    player.statLife += realHeal; // Up the life of the player by the healAmount value.
    player.HealEffect(realHeal); // Displays the heal text
}
 
Back
Top Bottom