Help with Lightning

Turbanik🌳

Terrarian
Hello , I would like to ask you something. Now I'm making a mod for Terraria . I want to make a Lightning weapon like in Thorium mod. I'm trying to do it but everytime I fail. I dont know the right code and my lightning kills me. Please can somebody help me to do it right?

Want to do this
 

Attachments

  • Lightning.png
    Lightning.png
    281.4 KB · Views: 178
Can you post the code being used? Did you make your new projectile friendly?
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace VariousStuffExpansion.Projectiles
{
public class LightningOrb : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("LightningOrb");
}

public override void SetDefaults()
{
projectile.arrow = false;
projectile.width = 10;
projectile.height = 10;
projectile.aiStyle = 465;
projectile.penetrate = 10;
projectile.CloneDefaults(465);
projectile.friendly = true;
projectile.timeLeft = 250;
aiType = (465);

}

// Additional hooks/methods here.
}
}








It spawns an orb that is shooting me with cultist Lightning , but I want it to shoot from my staff.






its wrong
 

Attachments

  • LightningisCool.png
    LightningisCool.png
    791.3 KB · Views: 137
Can you post the code being used? Did you make your new projectile friendly?
using Microsoft.Xna.Framework;
using System;
using System.Diagnostics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace VariousStuffExpansion.Items
{
public class ZeusLightning : ModItem
{
public override void SetStaticDefaults()
{

}

public override void SetDefaults()
{
item.damage = 200;
item.magic = true; //Становится луком
item.width = 22;
item.height = 44;
item.useTime = 5;
item.useAnimation = 30;
item.crit = 10;
item.useStyle = 5;
item.shoot = 10;
item.shootSpeed = 8; //скорость полета стрелы
item.knockBack = 7;
item.mana = 30;
item.value = 90000;
item.shoot = (466);
item.rare = 5;
item.UseSound = SoundID.Item21;
item.autoReuse = true;
item.useTurn = false;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(3467, 10);
recipe.AddIngredient(3457, 16);
recipe.AddIngredient(2623, 1);
recipe.AddTile(412);
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 = 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, 10, 10);
for (int i = 0; i < 1; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
}
}





Its code of my weapon







I change something abd get this




this lightning is similar


and all time shoots at the right side
 

Attachments

  • RightLightning.png
    RightLightning.png
    351.6 KB · Views: 92
  • LeftLightning.png
    LeftLightning.png
    177.1 KB · Views: 76
Back
Top Bottom