wip galeforce
This commit is contained in:
1 parent
b756e6e924
commit
abcac387cf
7 files changed
+276
-13
No files matched your search
@@ -5,6 +5,8 @@ using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Projectiles.Magic;
|
||||
using System.Linq;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
@@ -15,31 +17,55 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
Item.damage = 8;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.width = 32;
|
||||
Item.height = 52;
|
||||
Item.width = 38;
|
||||
Item.height = 68;
|
||||
Item.useTime = 20;
|
||||
Item.useAnimation = 20;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.channel = true;
|
||||
Item.knockBack = 3f;
|
||||
Item.value = CalamityGlobalItem.Rarity3BuyPrice;
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.UseSound = SoundID.Item5;
|
||||
Item.UseSound = SoundID.Item17;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ProjectileID.WoodenArrowFriendly;
|
||||
Item.shoot = ModContent.ProjectileType<GaleforceHoldout>();
|
||||
Item.shootSpeed = 20f;
|
||||
Item.useAmmo = AmmoID.Arrow;
|
||||
//Item.useAmmo = AmmoID.Arrow;
|
||||
Item.Calamity().canFirePointBlankShots = true;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
public override void HoldItem(Player player)
|
||||
{
|
||||
for (int i = -8; i <= 8; i += 8)
|
||||
player.Calamity().mouseWorldListener = true;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType<GaleforceHoldout>());
|
||||
}
|
||||
|
||||
public override void UseItemFrame(Player player)
|
||||
{
|
||||
//Calculate the dirction in which the players arms should be pointing at.
|
||||
Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX);
|
||||
float armPointingDirection = (playerToCursor.ToRotation());
|
||||
|
||||
player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2);
|
||||
player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2);
|
||||
}
|
||||
|
||||
public override void UseStyle(Player player, Rectangle heldItemFrame)
|
||||
{
|
||||
if (player.Calamity().mouseWorld.X > player.Center.X)
|
||||
{
|
||||
Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i));
|
||||
Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType<FeatherLarge>(), damage / 4, 0f, player.whoAmI);
|
||||
player.ChangeDir(1);
|
||||
}
|
||||
return true;
|
||||
else
|
||||
{
|
||||
player.ChangeDir(-1);
|
||||
}
|
||||
|
||||
CalamityUtils.CleanHoldStyle(player, player.compositeFrontArm.rotation + MathHelper.PiOver2, player.GetFrontHandPosition(player.compositeFrontArm.stretch, player.compositeFrontArm.rotation).Floor(), new Vector2(38, 68), new Vector2(-9, 0));
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 909 B |
@@ -269,4 +269,5 @@ WyvernFeatherPink.DisplayName: Feather
|
||||
WyvernFeatherPurple.DisplayName: Feather
|
||||
WyvernProjectile.DisplayName: Wyvern
|
||||
YharimsCrystalBeam.DisplayName: Yharim's Beam
|
||||
YharimsCrystalPrism.DisplayName: Yermes Christal
|
||||
YharimsCrystalPrism.DisplayName: Yermes Christal
|
||||
GaleforceHoldout.DisplayName: Galeforce Holdout
|
||||
@@ -252,4 +252,6 @@ VoidragonTentacle.DisplayName: Voidragon Tentacle
|
||||
WaterSpout.DisplayName: Spout
|
||||
WulfrumScrapBullet.DisplayName: High Speed Scrap
|
||||
ArcherfishRing.DisplayName: Archerfish Ring
|
||||
SeaDragonMuzzleBlast.DisplayName: Seadragon Muzzle Blast
|
||||
SeaDragonMuzzleBlast.DisplayName: Seadragon Muzzle Blast
|
||||
GaleforceHoldout.DisplayName: Galeforce Holdout
|
||||
GaleforceArrow.DisplayName: Galeforce Arrow
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
public class GaleforceArrow : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
||||
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 10;
|
||||
Projectile.height = 10;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.arrow = true;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.timeLeft = 300;
|
||||
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration;
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
|
||||
SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) - MathHelper.ToRadians(90);
|
||||
|
||||
Vector2 destination = Projectile.Center;
|
||||
bool locatedTarget = false;
|
||||
|
||||
// Find a target.
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2);
|
||||
if (!Main.npc[i].CanBeChasedBy(Projectile, false) || !Projectile.WithinRange(Main.npc[i].Center, 340f + extraDistance))
|
||||
continue;
|
||||
|
||||
Vector2 coneHomeCheck = (Main.npc[i].Center - Projectile.Center).SafeNormalize(Vector2.Zero) + Projectile.velocity.SafeNormalize(Vector2.Zero);
|
||||
if (Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && (Math.Abs(coneHomeCheck.X) > 1.15f || Math.Abs(coneHomeCheck.Y) > 1.15f))
|
||||
{
|
||||
destination = Main.npc[i].Center;
|
||||
locatedTarget = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (locatedTarget)
|
||||
{
|
||||
// Home in on the target.
|
||||
Vector2 homeDirection = (destination - Projectile.Center).SafeNormalize(Vector2.UnitY);
|
||||
Projectile.velocity = (Projectile.velocity * 12f + homeDirection * 20f) / (12f + 1f);
|
||||
}
|
||||
|
||||
if (Projectile.velocity.Length() < 20f)
|
||||
{
|
||||
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 20f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 409 B |
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using CalamityMod.Items.Weapons.Magic;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
|
||||
namespace CalamityMod.Projectiles.Ranged
|
||||
{
|
||||
//Holdout, but invisible. It may as well be named "GaleforceHandler"
|
||||
public class GaleforceHoldout : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Ranged";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public static float MaxCharge = 50;
|
||||
public static int ShotProjectiles = 5;
|
||||
|
||||
public ref float Charge => ref Projectile.ai[0];
|
||||
public float ChargeProgress => MathHelper.Clamp(Charge, 0, MaxCharge) / MaxCharge;
|
||||
public float FullChargeProgress => MathHelper.Clamp(Charge, 0, MaxCharge * 1.5f) / (MaxCharge * 1.5f);
|
||||
public float Spread => MathHelper.PiOver2 * (1 - (float)Math.Pow(ChargeProgress, 1.5) * 0.95f);
|
||||
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 38;
|
||||
Projectile.height = 68;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Ranged;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override bool? CanDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Owner.channel)
|
||||
{
|
||||
Projectile.timeLeft = 2;
|
||||
Owner.itemTime = 25;
|
||||
Owner.itemAnimation = 25;
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
}
|
||||
|
||||
float pointingRotation = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation();
|
||||
Projectile.Center = Owner.MountedCenter + pointingRotation.ToRotationVector2() * 40f;
|
||||
|
||||
if (Projectile.soundDelay <= 0)
|
||||
{
|
||||
//SoundEngine.PlaySound(CoralSpout.ChargeSound with { Pitch = 0.5f * ChargeProgress}, Owner.MountedCenter);
|
||||
Projectile.soundDelay = 10;
|
||||
}
|
||||
|
||||
Charge++;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
float angle = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation();
|
||||
|
||||
Effect effect = Filters.Scene["CalamityMod:SpreadTelegraph"].GetShader().Shader;
|
||||
effect.Parameters["centerOpacity"].SetValue(0.7f);
|
||||
effect.Parameters["mainOpacity"].SetValue((float)Math.Sqrt(ChargeProgress));
|
||||
effect.Parameters["halfSpreadAngle"].SetValue(Spread / 2f);
|
||||
effect.Parameters["edgeColor"].SetValue(Color.Lerp(Color.LightGray, Color.Coral, 0).ToVector3());
|
||||
effect.Parameters["centerColor"].SetValue(Color.Lerp(Color.Gray, Color.Coral, 0).ToVector3());
|
||||
effect.Parameters["edgeBlendLength"].SetValue(0.07f);
|
||||
effect.Parameters["edgeBlendStrength"].SetValue(8f);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/InvisibleProj").Value;
|
||||
|
||||
Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.White, angle, new Vector2(texture.Width / 2f, texture.Height/2f), 700f, 0, 0);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
float mainAngle = (Projectile.Center - Owner.MountedCenter).ToRotation();
|
||||
Texture2D arrowTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/GaleforceArrow").Value;
|
||||
|
||||
for (int i = 0; i < ShotProjectiles; i++)
|
||||
{
|
||||
float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / ((float)ShotProjectiles - 1));
|
||||
float direction = mainAngle + angleOffset;
|
||||
Vector2 displacement = (direction + MathHelper.Pi / 12f).ToRotationVector2();
|
||||
Main.EntitySpriteDraw(arrowTexture, Owner.MountedCenter - Main.screenPosition + (displacement * 26f), null, Color.White, direction - MathHelper.Pi/2, new Vector2(texture.Width / 2f, texture.Height / 2f), 1f, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
float mainAngle = (Projectile.Center - Owner.MountedCenter).ToRotation();
|
||||
|
||||
SoundEngine.PlaySound(SoundID.Item5 with { Volume = SoundID.Item167.Volume * 0.4f + 0.2f * ChargeProgress }, Owner.MountedCenter);
|
||||
|
||||
for (int i = 0; i < ShotProjectiles; i++)
|
||||
{
|
||||
float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / ((float)ShotProjectiles - 1));
|
||||
Vector2 direction = (mainAngle + angleOffset).ToRotationVector2();
|
||||
|
||||
int realDamage = Projectile.damage;
|
||||
|
||||
if (Owner.whoAmI == Main.myPlayer)
|
||||
{
|
||||
float speed = 20f;
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter + direction * 30f, direction * speed, ModContent.ProjectileType<GaleforceArrow>(), realDamage, Projectile.knockBack, Owner.whoAmI, ChargeProgress);
|
||||
}
|
||||
|
||||
Color pulseColor = Main.rand.NextBool() ? Color.Gray : Color.LightGray;
|
||||
Particle pulse = new DirectionalPulseRing(Owner.MountedCenter + direction * 44f, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), direction.ToRotation(), 0.04f, 0.2f, 30);
|
||||
GeneralParticleHandler.SpawnParticle(pulse);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user