Standalone [1.3] tModLoader - A Modding API

I have another problem my gun isnt showing any ammo/is not shooting any bullets. Please Help! :rslime::redspin:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tesseract.Items.Weapons
{
    public class DoomShroom : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Doom Shroom";
            item.damage = 23;
            item.ranged = true;
            item.width = 50;
            item.height = 25;
            item.toolTip = "Neighbour! These Shrooms are protecting me from the zombie";
            item.useTime = 38;
            item.useAnimation = 38;
            item.useStyle = 5;
            item.noMelee = true;
            item.knockBack = 7;
            item.value = 10000;
            item.rare = 2;
            item.autoReuse = false;
            item.shoot = 10;
            item.shootSpeed = 10f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
        {
            var posArray = new Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            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, 6);
            for (int i = 0; i < 5; ++i)
            {
                Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
            }
            return false;
        }
    }
}
 
I have another problem my gun isnt showing any ammo/is not shooting any bullets. Please Help! :rslime::redspin:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tesseract.Items.Weapons
{
    public class DoomShroom : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Doom Shroom";
            item.damage = 23;
            item.ranged = true;
            item.width = 50;
            item.height = 25;
            item.toolTip = "Neighbour! These Shrooms are protecting me from the zombie";
            item.useTime = 38;
            item.useAnimation = 38;
            item.useStyle = 5;
            item.noMelee = true;
            item.knockBack = 7;
            item.value = 10000;
            item.rare = 2;
            item.autoReuse = false;
            item.shoot = 10;
            item.shootSpeed = 10f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
        {
            var posArray = new Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            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, 6);
            for (int i = 0; i < 5; ++i)
            {
                Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
            }
            return false;
        }
    }
}
Take a look at ExampleGun in ExampleMod. Your item.useAmmo is wrong.
 
Take a look at ExampleGun in ExampleMod. Your item.useAmmo is wrong.
Haha I am so not good at coding Ty! :happy:
But can you help me with my other problem
I made a Boss that is supposed to Spawn NPCs but it won't.
Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tesseract.NPCs.Boss
{
    public class Sporish : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Sporish";
            npc.displayName = "Sporish";
            npc.aiStyle = 1;
            npc.lifeMax = 5000;
            npc.damage = 40;
            npc.defense = 18;
            npc.knockBackResist = 0f;
            npc.width = 110;
            npc.height = 125;
            animationType = Terraria.ID.NPCID.BlueSlime;
            Main.npcFrameCount[npc.type] = 4;
            npc.value = Item.buyPrice(0, 1, 20, 45);
            npc.npcSlots = 1f;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = false;
            npc.noTileCollide = false;
            npc.buffImmune[24] = true;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            music = Terraria.ID.MusicID.Boss3;
            npc.netAlways = false;
        }
        public override void AutoloadHead(ref string headTexture, ref string bossHeadTexture)
        {
            bossHeadTexture = "Tesseract/NPCs/Boss/Sporish_Head_Boss";
        }
        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = Terraria.ID.ItemID.LesserHealingPotion;
        }
        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);
            npc.damage = (int)(npc.damage * 0.6f);
        }
        public override void AI()
        {
            npc.ai[0]++;
            Player P = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;

            npc.ai[1]++;
            if (npc.ai[1] >= 140)
            {
                float Speed = 10f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 13;
                int type = mod.ProjectileType("LaunchingMushroom");
                Main.PlaySound(10, (int)npc.position.X, (int)npc.position.Y, 17);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }
            if (npc.ai[0] % 600 == 3)

            {
                NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("SporeHouse"));
            }
            npc.ai[1] += 0;
        }
    }
}
 
Haha I am so not good at coding Ty! :happy:
But can you help me with my other problem
I made a Boss that is supposed to Spawn NPCs but it won't.
Code:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tesseract.NPCs.Boss
{
    public class Sporish : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Sporish";
            npc.displayName = "Sporish";
            npc.aiStyle = 1;
            npc.lifeMax = 5000;
            npc.damage = 40;
            npc.defense = 18;
            npc.knockBackResist = 0f;
            npc.width = 110;
            npc.height = 125;
            animationType = Terraria.ID.NPCID.BlueSlime;
            Main.npcFrameCount[npc.type] = 4;
            npc.value = Item.buyPrice(0, 1, 20, 45);
            npc.npcSlots = 1f;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = false;
            npc.noTileCollide = false;
            npc.buffImmune[24] = true;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            music = Terraria.ID.MusicID.Boss3;
            npc.netAlways = false;
        }
        public override void AutoloadHead(ref string headTexture, ref string bossHeadTexture)
        {
            bossHeadTexture = "Tesseract/NPCs/Boss/Sporish_Head_Boss";
        }
        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = Terraria.ID.ItemID.LesserHealingPotion;
        }
        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);
            npc.damage = (int)(npc.damage * 0.6f);
        }
        public override void AI()
        {
            npc.ai[0]++;
            Player P = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;

            npc.ai[1]++;
            if (npc.ai[1] >= 140)
            {
                float Speed = 10f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 13;
                int type = mod.ProjectileType("LaunchingMushroom");
                Main.PlaySound(10, (int)npc.position.X, (int)npc.position.Y, 17);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[1] = 0;
            }
            if (npc.ai[0] % 600 == 3)

            {
                NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("SporeHouse"));
            }
            npc.ai[1] += 0;
        }
    }
}
To debug things like this, so something like
Main.NewText("SporeHouse id is " + mod.NPCType("SporeHouse"));
in that if statement before NPC.NewNPC and watch the chat, make sure it says the id is >0. If that's working, then you know the problem is the SporeHouse npc.
 
To debug things like this, so something like
Main.NewText("SporeHouse id is " + mod.NPCType("SporeHouse"));
in that if statement before NPC.NewNPC and watch the chat, make sure it says the id is >0. If that's working, then you know the problem is the SporeHouse npc.
Sorry but I don't know what you mean by that (my main language is not English) I will send the code of SporeHouse maybe that helps?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tesseract.NPCs
{
    public class SporeHouse : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "SporeHouse";
            npc.displayName = "Spore House";
            npc.width = 50;
            npc.height = 42;
            npc.damage = 10;
            npc.defense = 15;
            npc.lifeMax = 90;
            npc.HitSound = SoundID.NPCHit16;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 60f;
            npc.knockBackResist = 0f;
            npc.aiStyle = 0;
            Main.npcFrameCount[npc.type] = 4;
            aiType = NPCID.BlueSlime;
            animationType = NPCID.BlueSlime;
        }
       
        public override void FindFrame(int frameHeight)
        {
            npc.frameCounter -= 0.5F;
            npc.frameCounter %= Main.npcFrameCount[npc.type];
            int frame = (int)npc.frameCounter;
            npc.frame.Y = frame * frameHeight;

            npc.spriteDirection = npc.direction;
        }
        public override void NPCLoot()
        {        
        }
    }
}
 
In the WorldGen.TileRunner method, what does strength and step do exactly. I would like to make an ore that can only spawn as a 2x2 cube somewhere underground. Any help with either of those would be appreciated.
 
Sorry but I don't know what you mean by that (my main language is not English) I will send the code of SporeHouse maybe that helps?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tesseract.NPCs
{
    public class SporeHouse : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "SporeHouse";
            npc.displayName = "Spore House";
            npc.width = 50;
            npc.height = 42;
            npc.damage = 10;
            npc.defense = 15;
            npc.lifeMax = 90;
            npc.HitSound = SoundID.NPCHit16;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 60f;
            npc.knockBackResist = 0f;
            npc.aiStyle = 0;
            Main.npcFrameCount[npc.type] = 4;
            aiType = NPCID.BlueSlime;
            animationType = NPCID.BlueSlime;
        }
      
        public override void FindFrame(int frameHeight)
        {
            npc.frameCounter -= 0.5F;
            npc.frameCounter %= Main.npcFrameCount[npc.type];
            int frame = (int)npc.frameCounter;
            npc.frame.Y = frame * frameHeight;

            npc.spriteDirection = npc.direction;
        }
        public override void NPCLoot()
        {       
        }
    }
}
I got it kinda? It says ID 581 i thought i wasnt spawning but it takes really long for her to spawn the Sporehouses how do i change it zo it spawn more often?
 
I need help.
I go on Multiplayer > Host & Play > I select a character and world > and then it crashes.
It seems to only crash for me, because my friend used the exact same mods and host & play was fine for them...

I have:
Zocklukas' Mod v1.1.8.5 - Enabled
Thorium Mod v1.3.1.6 - Enabled
Reduced Grinding v3.20 - Enabled
imkSushi Mod v3.1.1 - Disabled
Calamity Mod v1.1.7.57 - Disabled
Spirit Mod v1.1.1.6 - Disabled
HERO's Mod v0.1.4.5 - Disabled
Legend of Terraria 3 v1.0.5 - Disabled
RPG Classes v0.4.2.2 - Disabled
Cheat Sheet v0.2.5.13 - Enabled
More Chest Loot v0.3 - Disabled
Vanilla Tweaks v2.1 - Enabled
SacredTools v0.23.2 - Disabled
Mod of Randomness v0.7 - Enabled (My mod)
WorldGen Previewer v0.1.3.2 - Disabled
Tremor Mod Remastered v1.2.1.8 - Enabled (Not the over-sized 1.3 version)
 
Hello, I'm trying to make a weapon that does more damage to npcs in the corruption.

I've tried using if statements for the weapon damage (ZoneCorrupt) but it says this:

ZoneCorrupt doesn't exist in the current context.

Does anyone know how to do fix it?
 
How come mod browser doesn't work? Always comes up (even if it does load) saying its offline for a reason unknown... Any fixes? I've already tried spamming the refresh button so don't bother suggesting that, thanks.
 
I don't understand. When I open the game and open Mod Browser, the mods don't show up and if they show up, they suddenly start to copy and then Mod Browser becomes Offline for an unknown reason. I don't know why???!!!
 
I don't understand. When I open the game and open Mod Browser, the mods don't show up and if they show up, they suddenly start to copy and then Mod Browser becomes Offline for an unknown reason. I don't know why???!!!

It's because of how much the mod browser is being used (that's what I think).
 
Hello! Today I installed many mods and decided to try them out in the game. Everything works, but when I try to pick up any drop, my character stops moving, and mobs and NPCs continue to walk. How can I fix this?
[doublepost=1489250341,1489250275][/doublepost]
That's because the Mod Browser is offline.

See here for explanation.
I think this is due to the fact that the game is not licensed.
 
Hey so I am having this problem with tmodloader. When i try running the modded terraria i get this error message
 

Attachments

  • Capture.PNG
    Capture.PNG
    30.5 KB · Views: 157
I need help with getting a gun to shoot musket balls and to have a shotgun effect, any help?
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Tf2.Items.Weapons
{
    public class Scattergun : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Scattergun";
            item.damage = 15;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "Get on the point dumbass!";
            item.useTime = 38;
            item.useAnimation = 38;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 7;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 14;
            item.autoReuse = false;
            item.shoot = 10;
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public override void AddRecipes()  //How to craft this gun
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.IronBar, 10);   //you need 1 DirtBlock
            recipe.AddTile(TileID.Anvils);   //at work bench
            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);
            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, 6);
            for (int i = 0; i < 5; ++i)
            {
                Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
            }
            return false;
        }
    }
}
 
Hello! Today I installed many mods and decided to try them out in the game. Everything works, but when I try to pick up any drop, my character stops moving, and mobs and NPCs continue to walk. How can I fix this?
 
Hello! Today I installed many mods and decided to try them out in the game. Everything works, but when I try to pick up any drop, my character stops moving, and mobs and NPCs continue to walk. How can I fix this?
That used to happen to me, try uninstalling tmod and terraria and reinstalling them.
 
Back
Top Bottom