tModLoader Official tModLoader Help Thread

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 ?
 
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 ?

Maybe it's possible to detect and remove it inside the Update function of the ModPlayer class.
 
Do you know what do I have to modify from my tAPI mod to make it work with tModLoader ?

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using TAPI;

namespace NoManaSickness
{
public class MPlayer : TAPI.ModPlayer
{

public override void PostUpdate()
{
for (int index = 0; index < 22; ++index)
{
if (player.buffType[index] == 94)
{
player.buffTime[index] = 0;
player.buffType[index] = 0;
}
}
}
}
}
 
Hi, 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:
PJn3xpa.png

My file:
igeIrXc.png


Same picture, but i do not found problem. I want like the first picture but not success...


Thank you.
 
Hey guys, working on my first mod right now and a little confused on where to go next. I got my items showing up in-game and craftable and all that, I just need to know how to actually make them function now. How would I make this item have a glow around the player (like the mining helmet) and also increase mining speed?

Terraria_2016-06-02_17-41-17.png


It's an accessory. Also I don't want it to have to take any buff slots if possible. Thanks in advance! :happy:
 
Hi, 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:
PJn3xpa.png

My file:
igeIrXc.png


Same picture, but i do not found problem. I want like the first picture but not success...


Thank you.
Use this hook to adjust the offset: https://github.com/bluemagic123/tModLoader/wiki/ModItem#public-virtual-vector2-holdoutoffset
 
How do I make an item shoot projectiles that rain from the sky like blizzard staff or starfury?

If you set the projectile ID in item.shoot you can modify position shootdirection rotation and some other things in the shoot function.
Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)

btw
Main.MouseScreen + Main.screenPosition
Is used to get the position of the mouse. Both are a vector2 so you need to access the specific coordinates like a member.
 
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;​
}​
}
Thanks, I got it to work now. But how can I make the 2nd Projectile(beam) go faster, without turning it's sprite ?
 
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 ?
What you could do, is make the player all players immune to the mana sickness debuff. That seems the most logical way to me, at least.
[doublepost=1464967044,1464966972][/doublepost]
Thanks, I got it to work now. But how can I make the 2nd Projectile(beam) go faster, without turning it's sprite ?
You could try multiplying the velocities, for example by 2.
 
Three questions for ammo and projectiles:

1. How do you make an ranged weapon use multiple bullets per shot?
2. How do you make a projectile shoot multiple projectiles in the same general direction in the original projectiles direction upon collision?
3. How do you make a weapon use unique ammo? I tried to modify the wisp ammo from the ExampleMod, but my weapon does not show the ammo count or consume ammo.

Code:
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;
  }  
   }
}

Code:
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();
     }
   }
}

Code:
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"));
     }
   }
}
 
Just a random question, but what sort of stuff can you do with the buff "player.yoraiz0rEye"? Anything special (besides the obvious)?
 
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[]
 
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.
 
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.
Delete the IonicZip dll in the C:\Program Files (x86)\Steam\steamapps\common\terraria folder if you have one.

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[]
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.
 
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.

I wanted to check if the world has corruption or crimson.

I just looked at the original source code and WorldGen.crimson was used there, i tried it and it worked.
 
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
 
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
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.
 
Back
Top Bottom