I guys, I'm trying to make a mod to remove the Mana Sickness debuff from the game, but even with the documentation I can't figure out how to do it. Could you give me some help please ?
Use this hook to adjust the offset: https://github.com/bluemagic123/tModLoader/wiki/ModItem#public-virtual-vector2-holdoutoffsetHi, sorry if i do not use button search, but i am not english, so for found my answer when you do not talk correctly english....
And i think, this subject is the correct subject for post my question. Maybe not, after all... i have not idea... but like i create this first small mod with modloader...
When i create a weapon ( i am a very beginner), i have create for that, a small sprite.
But in game, my character with exemple of boomstick look like that:
Vanilla:
My file:
Same picture, but i do not found problem. I want like the first picture but not success...
Thank you.
How do I make an item shoot projectiles that rain from the sky like blizzard staff or starfury?
Thanks, I got it to work now. But how can I make the 2nd Projectile(beam) go faster, without turning it's sprite ?How do I make it so a mob only spawns during some kind of event? Like when it's raining or something.
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)
{
Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, item.shoot, damage, knockBack, item.owner); \\To shoot the projectile decided by item.shoot}
Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("Insertbeamhere"), damage, knockBack, item.owner); \\ the extra projectile
return false;public override void AI()
{
projectile.ai[1] += 1f;}
if (projectile.ai[1] >= 33f) \\ How often it spawns new projectiles
{
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y , speedX, speedY, mod.ProjectileType("InsertProjectileHere"), (int)(projectile.damage * 1.0f), 0, projectile.owner);}
projectile.ai[1] -= 30f;
What you could do, is makeI guys, I'm trying to make a mod to remove the Mana Sickness debuff from the game, but even with the documentation I can't figure out how to do it. Could you give me some help please ?
You could try multiplying the velocities, for example by 2.Thanks, I got it to work now. But how can I make the 2nd Projectile(beam) go faster, without turning it's sprite ?
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace DoomMod.Weapons
{
public class BFG : ModItem
{
public override void SetDefaults()
{
item.name = "Big Freaking Gun";
item.damage = 100;
item.ranged = true;
item.width = 48;
item.height = 29;
item.toolTip = "Works well when you need to clear out a room.";
item.useTime = 5;
item.useAnimation = 5;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
//item.useSound = mod.GetSoundSlot(SoundType.Custom, "Sounds/PlasmaRifle");
item.autoReuse = true;
item.shoot = mod.ProjectileType("BFGShot"); //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = mod.ProjectileType("Cell");
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
//recipe.AddTile(null, "ExampleWorkbench");
recipe.SetResult(this);
recipe.AddRecipe();
}
public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)((angle * 0.0174532925) * 0.0);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray[i] = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
return (Vector2[])posArray;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2[] speeds = randomSpread(speedX, speedY, 8, 1);
for (int i = 0; i < 1; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
}
Main.PlaySound(SoundLoader.customSoundType, (int)position.X, (int)position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/PlasmaRifle"));
return false;
}
}
}
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace DoomMod.Weapons
{
public class Cell : ModItem
{
public override void SetDefaults()
{
item.name = "Cell";
item.damage = 1;
item.ranged = true;
item.width = 17;
item.height = 12;
item.maxStack = 999;
item.toolTip = "This is a modded bullet ammo.";
item.consumable = true;
item.knockBack = 1.5f;
item.value = 10;
item.rare = 2;
//item.shoot = mod.ProjectileType("BFGShot"); I am using this ammo for another weapon, so I can not use item.Shoot
item.shootSpeed = 16f;
item.ammo = mod.ProjectileType("Cell");
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
//recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this, 50);
recipe.AddRecipe();
}
}
}
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace DoomMod.Projectiles
{
public class BFGShot : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "BFG Ball";
projectile.width = 13;
projectile.height = 13;
projectile.aiStyle = 1;
projectile.friendly = true;
projectile.ranged = true;
projectile.penetrate = 1;
projectile.timeLeft = 600;
projectile.alpha = 255;
projectile.light = 0.5f;
projectile.extraUpdates = 1;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 1;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
aiType = ProjectileID.Bullet;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.Kill();
return false;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);
for (int k = 0; k < projectile.oldPos.Length; k++)
{
Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);
spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
}
return true;
}
/*public override void AI()
{
projectile.velocity.Y += projectile.ai[0];
if (Main.rand.Next(3) == 0)
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("Sparkle"), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
}
}*/
public override void Kill(int timeLeft)
{
for (int k = 0; k < 5; k++)
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, mod.DustType("Sparkle"), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
}
//Main.PlaySound(SoundLoader.customSoundType, (int)projectile.position.X, (int)projectile.position.Y, mod.GetSoundSlot(SoundType.Custom, "Sounds/PlasmaRifle"));
}
}
}
error CS1703: An assembly with the same identity 'Ionic.Zip.Reduced, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' has already been imported. Try removing one of the duplicate references.
Delete the IonicZip dll in the C:\Program Files (x86)\Steam\steamapps\common\terraria folder if you have one.How do I get rid of this error when I load my mod source in-game?
Code:error CS1703: An assembly with the same identity 'Ionic.Zip.Reduced, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' has already been imported. Try removing one of the duplicate references.
What do you mean by instance of the world? If you tell me what you are trying to do, I can help. player.whoAmI corresponds to the player's index in the Main.player array.Where do i get the instance of the world that the player is currently in? And how do i get the number from a player class that shows at which index it is in main.player[]
Delete the IonicZip dll in the C:\Program Files (x86)\Steam\steamapps\common\terraria folder if you have one.
What do you mean by instance of the world? If you tell me what you are trying to do, I can help. player.whoAmI corresponds to the player's index in the Main.player array.
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using BMod.Items;
using BMod.Items.Weapons;
using BMod.Projectiles;
namespace BMod
{
public class BMod : Mod
{
public BMod()
{
Properties = new ModProperties()
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.Wood, 200);
recipe.AddIngredient(ItemID.Gel, 75);
recipe.AddTile(18);
recipe.SetResult(ItemID.SlimeStaff);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.Wood, 20);
recipe.AddIngredient(ItemID.PinkGel, 10);
recipe.AddTile(18);
recipe.SetResult(ItemID.SlimeStaff);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.Wood, 20);
recipe.AddIngredient(ItemID.StoneBlock, 10);
recipe.AddTile(18);
recipe.SetResult(ItemID.WoodenBoomerang);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.Wood, 10);
recipe.AddIngredient(ItemID.Torch, 20);
recipe.AddTile(18);
recipe.SetResult(ItemID.WandofSparking);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 15);
recipe.AddTile(16);
recipe.SetResult(ItemID.ChainKnife);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddCraftGroup(null, "Iron/Lead Bar", 1);
recipe.AddTile(16);
recipe.SetResult(ItemID.Shuriken, 30);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 1);
recipe.AddTile(16);
recipe.SetResult(ItemID.ThrowingKnife, 30);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.StoneBlock, 2);
recipe.AddTile(18);
recipe.SetResult(ItemID.MusketBall, 1);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddCraftGroup(null, "Iron/Lead Bar", 1);
recipe.AddTile(16);
recipe.SetResult(ItemID.MusketBall, 25);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 1);
recipe.AddTile(16);
recipe.SetResult(ItemID.SilverBullet, 25);
recipe.anyWood = true;
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 15);
recipe.AddIngredient(ItemID.StoneBlock, 200);
recipe.AddIngredient(ItemID.Wood, 100);
recipe.AddTile(16);
recipe.SetResult(ItemID.RedRyder, 1);
recipe.anyWood = true;
recipe.AddRecipe();
}
public override void AddCraftGroups()
{
AddCraftGroup("Copper/Tin Bar", Lang.misc[37] + " " + Main.itemName[ItemID.CopperBar],
ItemID.CopperBar, ItemID.TinBar);
AddCraftGroup("Iron/Lead Bar", Lang.misc[37] + " " + Main.itemName[ItemID.IronBar],
ItemID.IronBar, ItemID.LeadBar);
AddCraftGroup("Silver/Tungsten Bar", Lang.misc[37] + " " + Main.itemName[ItemID.SilverBar],
ItemID.SilverBar, ItemID.TungstenBar);
AddCraftGroup("Gold/Platinum Bar", Lang.misc[37] + " " + Main.itemName[ItemID.GoldBar],
ItemID.GoldBar, ItemID.PlatinumBar);
AddCraftGroup("Demonite/Crimtane Bar", Lang.misc[37] + " " + Main.itemName[ItemID.DemoniteBar],
ItemID.DemoniteBar, ItemID.CrimtaneBar);
}
}
}
c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\BMod.cs(113,24) : error CS0115: 'BMod.BMod.AddCraftGroups()': no suitable method found to override
Vanilla Terraria changed some code in 1.3.1, so now instead of CraftGroups, there are Recipe Groups. Look in Example Mod for an example you can follow.I cant implement craftgroups without a error(and if possible is there a way to do craftgroups without ruining my recipe codes with them without having to redo them?)
Code:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using BMod.Items; using BMod.Items.Weapons; using BMod.Projectiles; namespace BMod { public class BMod : Mod { public BMod() { Properties = new ModProperties() { Autoload = true, AutoloadGores = true, AutoloadSounds = true }; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(this); recipe.AddIngredient(ItemID.Wood, 200); recipe.AddIngredient(ItemID.Gel, 75); recipe.AddTile(18); recipe.SetResult(ItemID.SlimeStaff); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddIngredient(ItemID.Wood, 20); recipe.AddIngredient(ItemID.PinkGel, 10); recipe.AddTile(18); recipe.SetResult(ItemID.SlimeStaff); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddIngredient(ItemID.Wood, 20); recipe.AddIngredient(ItemID.StoneBlock, 10); recipe.AddTile(18); recipe.SetResult(ItemID.WoodenBoomerang); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddIngredient(ItemID.Wood, 10); recipe.AddIngredient(ItemID.Torch, 20); recipe.AddTile(18); recipe.SetResult(ItemID.WandofSparking); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 15); recipe.AddTile(16); recipe.SetResult(ItemID.ChainKnife); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddCraftGroup(null, "Iron/Lead Bar", 1); recipe.AddTile(16); recipe.SetResult(ItemID.Shuriken, 30); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 1); recipe.AddTile(16); recipe.SetResult(ItemID.ThrowingKnife, 30); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddIngredient(ItemID.StoneBlock, 2); recipe.AddTile(18); recipe.SetResult(ItemID.MusketBall, 1); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddCraftGroup(null, "Iron/Lead Bar", 1); recipe.AddTile(16); recipe.SetResult(ItemID.MusketBall, 25); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 1); recipe.AddTile(16); recipe.SetResult(ItemID.SilverBullet, 25); recipe.anyWood = true; recipe.AddRecipe(); recipe = new ModRecipe(this); recipe.AddCraftGroup(null, "Silver/Tungsten Bar", 15); recipe.AddIngredient(ItemID.StoneBlock, 200); recipe.AddIngredient(ItemID.Wood, 100); recipe.AddTile(16); recipe.SetResult(ItemID.RedRyder, 1); recipe.anyWood = true; recipe.AddRecipe(); } public override void AddCraftGroups() { AddCraftGroup("Copper/Tin Bar", Lang.misc[37] + " " + Main.itemName[ItemID.CopperBar], ItemID.CopperBar, ItemID.TinBar); AddCraftGroup("Iron/Lead Bar", Lang.misc[37] + " " + Main.itemName[ItemID.IronBar], ItemID.IronBar, ItemID.LeadBar); AddCraftGroup("Silver/Tungsten Bar", Lang.misc[37] + " " + Main.itemName[ItemID.SilverBar], ItemID.SilverBar, ItemID.TungstenBar); AddCraftGroup("Gold/Platinum Bar", Lang.misc[37] + " " + Main.itemName[ItemID.GoldBar], ItemID.GoldBar, ItemID.PlatinumBar); AddCraftGroup("Demonite/Crimtane Bar", Lang.misc[37] + " " + Main.itemName[ItemID.DemoniteBar], ItemID.DemoniteBar, ItemID.CrimtaneBar); } } }
Code:c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\BMod.cs(113,24) : error CS0115: 'BMod.BMod.AddCraftGroups()': no suitable method found to override
great... that means Ill have to configure every single recipe with craft group in my mod doesnt itVanilla Terraria changed some code in 1.3.1, so now instead of CraftGroups, there are Recipe Groups. Look in Example Mod for an example you can follow.