• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

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

Turbanik

Terrarian
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

Turbanik

Terrarian
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

Top Bottom