tModLoader Official tModLoader Help Thread

It seems I forgot to put a "." between "position" and "y".
I just realized that after I posted :p
Edit:
It seems I forgot to put a "." between "position" and "y".
I just tried the code out and the mod builds but the projectile doesn't spawn at all :/
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TEM.Items.Hardmode.Weapons
{
    public class Apophis : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Apophis";
            item.damage = 100;
            item.melee = true;
            item.width = 66;
            item.height = 66;
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 10;
            item.value = 0;
            item.rare = 10;
            item.useSound = 1;
            item.autoReuse = true;
        }
        public override Color? GetAlpha(Color lightColor)
        {
            return Color.White;
        }
        public virtual void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
        {
            Projectile.NewProjectile(target.position.X, target.position.Y - 100f, 0, 8, mod.ProjectileType("ApophisRock"), 10, 4f, Main.myPlayer, 0f, 0f);
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.FragmentSolar, 18);
            recipe.AddTile(TileID.LunarCraftingStation);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
 
I just realized that after I posted :p
[DOUBLEPOST=1454126189,1454125984][/DOUBLEPOST]
I just tried the code out and the mod builds but the projectile doesn't spawn at all :/
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TEM.Items.Hardmode.Weapons
{
    public class Apophis : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Apophis";
            item.damage = 100;
            item.melee = true;
            item.width = 66;
            item.height = 66;
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 10;
            item.value = 0;
            item.rare = 10;
            item.useSound = 1;
            item.autoReuse = true;
        }
        public override Color? GetAlpha(Color lightColor)
        {
            return Color.White;
        }
        public virtual void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
        {
            Projectile.NewProjectile(target.position.X, target.position.Y - 100f, 0, 8, mod.ProjectileType("ApophisRock"), 10, 4f, Main.myPlayer, 0f, 0f);
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.FragmentSolar, 18);
            recipe.AddTile(TileID.LunarCraftingStation);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
And wow, I'm forgetting a lot of things, change "virtual" to "override". Also I've been working on that projectile guide I think you wanted. Can't say when it will be done though.
 
And wow, I'm forgetting a lot of things, change "virtual" to "override". Also I've been working on that projectile guide I think you wanted. Can't say when it will be done though.
Damnit I always forget to look over that after I look at the code :/
I mean I know that I should put that but I forget :p
 
Damnit I always forget to look over that after I look at the code :/
I mean I know that I should put that but I forget :p
Does it work now?
[DOUBLEPOST=1454151964,1454151894][/DOUBLEPOST]
If I set Gravity and TileCollide to false will my boss "walk" on the ground?
Your boss will fall through everything and walk on 'the ground' beneath Hell.
edit: oh.. not sure what'd happen if gravity is also false
 
Does it work now?
[DOUBLEPOST=1454151964,1454151894][/DOUBLEPOST]
Your boss will fall through everything and walk on 'the ground' beneath Hell.
edit: oh.. not sure what'd happen if gravity is also false
Yeah I got it work
Also has anyone else been getting huge amounts of lag from armor recently?
Even vanilla armor for me :/
 
Where would i put the AddItem("Long Sword", new LongSword(), "MyMod/Items/Textures"); code like in a random .cs file in the mod folder i made in mode sources or would i put it in a specific area (probably stupid question).
 
How do I get my Boss to face the direction Im going, but only 2 directions? Like, say Im on the top left. I just want the boss to face left in general, not upwards at all. Like a zombie.
 
How do I get my Boss to face the direction Im going, but only 2 directions? Like, say Im on the top left. I just want the boss to face left in general, not upwards at all. Like a zombie.
If you've coded a boss yourself, you should know where to find the spot where you set the rotation of that boss. Remove that and just set 'npc.spriteDirection = npc.direction;' somewhere in your AI function.
 
If you've coded a boss yourself, you should know where to find the spot where you set the rotation of that boss. Remove that and just set 'npc.spriteDirection = npc.direction;' somewhere in your AI function.
Thanks! this was just a thing I couldnt find right away
 
Back
Top Bottom