tModLoader Tutorial: [4] Projectiles

Well, depending on what AI style you are using, a simple way to make a quick flicker of light would be using a counter and have the projectile have light for a certain amount of ticks then disable it, so it should look something like this

Code:
public override void AI()
{
   projectile.ai[0] += 1f;
   //If the counter is less than a tenth of a second
   if(projectile.ai[0] < 6)
   {
      projectile.light = 0.1f; //shine light
   }
   else
   {
      projectile.light = 0f; //Don't shine light if its more than a tenth of a second
   }
}


I have it inside my "public class Item1 : ModItem

c:\Users\Tyler\Documents\My Games\Terraria\ModLoader\Mod Sources\TylersGunMod\Items\Glock18\Glock18.cs(44,24) : error CS0115: 'TylersGunMod.Items.Glock18.Glock18.AI()': no suitable method found to override
 
I have it inside my "public class Item1 : ModItem

c:\Users\Tyler\Documents\My Games\Terraria\ModLoader\Mod Sources\TylersGunMod\Items\Glock18\Glock18.cs(44,24) : error CS0115: 'TylersGunMod.Items.Glock18.Glock18.AI()': no suitable method found to override
Well, that is a different case... I thought your problem was with projectiles, not a gun. Most likely case is just have it spawn glowing dust inside one of the hooks like Shoot().
 
Well, that is a different case... I thought your problem was with projectiles, not a gun. Most likely case is just have it spawn glowing dust inside one of the hooks like Shoot().

Thanks for pointing that out, I accidentally had put it in the gun .cs file and not the projectile. However, it still doesn't make light.

EDIT: 0.1f was just too small, I fixed it.
 
So, i have made a sword called "True Enchanted Sword" that shoots projectile but the projectile i'm shooting is always facing up, when i shoot it to the left it goes to the left but the projectile is facing up idk how to fix it

the sword code :
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EthiraciumMOD.Items
{
public class TrueEnchantedSword : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Enchanted Sword");
Tooltip.SetDefault("The True form of the Enchanted Sword.");
}
public override void SetDefaults()
{
item.damage = 64;
item.melee = true;
item.width = 60;
item.height = 60;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 6;
item.value = 100000;
item.rare = 8;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = mod.ProjectileType("TrueEnchantedProjectile");
item.shootSpeed = 8f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.EnchantedSword);
recipe.AddIngredient(ItemID.BeamSword);
recipe.AddIngredient(ItemID.BrokenHeroSword);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();

recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Arkhalis);
recipe.AddIngredient(ItemID.BeamSword);
recipe.AddIngredient(ItemID.BrokenHeroSword);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------------
the projectile code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace EthiraciumMOD.Projectiles
{
class TrueEnchantedProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Enchanted Projectile");
}
public override void SetDefaults()
{
projectile.width = 20;
projectile.height = 30;
projectile.friendly = true;
projectile.melee = true;
projectile.tileCollide = true;
projectile.penetrate = 2;
projectile.timeLeft = 200;
projectile.light = 0.75f;
projectile.extraUpdates = 1;
projectile.ignoreWater = true;
Main.PlaySound(SoundID.Item60.WithVolume(.9f));
}
}
}
 
Help me i get this error while trying to compile my mod

c:\Users\User\Documents\My Games\Terraria\ModLoader\Mod Sources\Danillofirstmod\Projectiles\MightProjectile.cs(23,55) : error CS1031: Type Awaited

(Note: It originaly was written Tipo esperado,not type awaited. I just translated it (Im Brazilian)

Here is the code for my projectile


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace Danillofirstmod.Projectiles
{
class MightProjectile : ModProjectile
{
public override void SetDefaults()
{
projectile.CloneDefaults(ProjectileID.InfluxWaver);
projectile.name = "MightProjectile";
aiType = ProjectileID.InfluxWaver;
}

public override bool Autoload(ref string name,, ref string texture)
{
texture = "Terraria/Projectile_" + ProjectileID.InfluxWaver;
return true;
}

public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.OnFire, 5 * 60);
}
}
}

Here is the code of my sword (If it has anything to do with the error)


using Terraria.ModLoader;

namespace Danillofirstmod.Items
{
public class SwordOfMight : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Sword Of Might");
Tooltip.SetDefault("This powerfull sword was made for the bravest and mightest warriors.");
}
public override void SetDefaults()
{
item.damage = 70;
item.shoot = MightProjectile
item.melee = true;
item.width = 50;
item.height = 50;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 20;
item.value = 10000;
item.rare = 5;
item.UseSound = SoundID.Item33;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.SoulOfMight,30)
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
namespace Scaredmod.Projectiles
{
public class Projectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Projectile");
}

public override void SetDefaults()
{
projectile.arrow = true;
projectile.width = 10;
projectile.height = 10;
projectile.aiStyle = 3;
projectile.friendly = true;
projectile.ranged = true;
aiType = ProjectileID.WoodenArrowFriendly;
}

// Additional hooks/methods here.
}
}


Errors Come From This Help (ModProjectile Thing)
 
Anyone know why this ain't working?
error picture:
1679749881080.png

Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Modthingig.Projectiles
{
public class DirtOrb : ModProjectile
{
public override void SetDefaults()
{
projectile.Damage = 7;
projectile.widith = 5;
projectile.height = 5;
projectile.name = "Dirt Orb";
projectiles.aistyle = 0;
projectile.timeLeft = 600;
projectile.friendly = true;
aiType = ProjectileID.SwordBeam;
}
public override bool Autoload(ref string name, ref string texture)
{
texture = "Terraria/Projectile_" + ProjectileID.DirtBall;
return true;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.Oozed, 3 * 60);
}
}
}
 
Last edited:
Back
Top Bottom