burning_pixel
Duke Fishron
How would I make a fishing rod?
How would I make a fishing rod?
this.useStyle = 1;
this.useAnimation = 8;
this.useTime = 8;
this.useSound = 1;
this.shoot = 361 + type - 2291;
type == 2289 || (type >= 2291 && type <= 2296)
You sure can, by overriding vanilla SetDefaults in a GlobalItem class. Taken from ExampleMod:Is there any way I would be able to change the tool tips for vannila items?
public class CopperShortsword : GlobalItem
{
public override void SetDefaults(Item item)
{
if (item.type == ItemID.CopperShortsword)
{
item.damage = 50;
}
}
}
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)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)
Use any of the ModifyHit hooks available for your ModProjectile. Example:Could you please tell me how?
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);
}
Let me help you out. ftfy, your code had several syntax issues and pretty bad formatting. I changed it for you.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
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();
}
}
}
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.2Can 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)
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.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?
public override void SetupStartInventory(IList<Item> items)
{
items.Clear();
}
public override void SetDefaults(Item item)
{
if (item.type == ItemID.CactusPickaxe)
{
item.pick = 0;
}
}
public override void SetDefaults(Item item)
{
if (item.type == ItemID.CactusPickaxe)
{
item.tileBoost = 5;
}
}
You can use the UseItem hook available in a ModItem class.How do I get a custom potion to apply a custom buff?
public override bool UseItem(Item item, Player player)
{
player.AddBuff(BuffID.OnFire, 360, false);
return base.UseItem(item, player);
}
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();
}
}
}
Do you have autoload properties set to true?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:
You mean in the main cs? I think so:Do you have autoload properties set to true?
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.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 }; } } }
Ah, that fixed it. Thanks both of you.Fix the namespace of the item to match the folder structure.
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 ='.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(); } } }
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();
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();
ftfyCode: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();
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);
}
}
}
}
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);
}
}
}
}
Yes you can =phello how can I add lifesteal to a boomerang weapon?
I said how can I add lifesteal, not can I :/Yes you can =p
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 trafficIs 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.
It's not all that hard.ok I found out how to add a glow/light effect but still no luck with lifesteal, any help would be appreciated
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
}
On top of that, you could add a little bit of randomization to the heal using Main.rand (just a random example)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.
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
}