Added Kylie and unified line endings.

This commit is contained in:
Ozzatron committed 2019-09-29 21:21:51 -04:00
1 parent 4fbb660720
commit 5ffc030c47
15 files changed
+227 -41

No files matched your search

@@ -56,4 +56,4 @@ namespace CalamityMod.Items.CalamityCustomThrowingDamage
return false;
}
}
}
}
@@ -44,4 +44,4 @@ namespace CalamityMod.Items.CalamityCustomThrowingDamage
return false;
}
}
}
}
@@ -0,0 +1,68 @@
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
namespace CalamityMod.Items.CalamityCustomThrowingDamage
{
public class Kylie : CalamityDamageItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Kylie");
Tooltip.SetDefault("Throws three short ranged boomerangs if stealth is full\n" + "Also known as Dowak");
}
public override void SafeSetDefaults()
{
item.damage = 40;
item.knockBack = 12;
item.thrown = true;
item.crit = 16;
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 3;
item.useTime = 25;
item.useAnimation = 25;
item.width = 32;
item.height = 46;
item.useStyle = 1;
item.UseSound = SoundID.Item1;
item.shootSpeed = 9f;
item.shoot = mod.ProjectileType("KylieBoomerang");
item.noMelee = true;
item.noUseGraphic = true;
item.GetGlobalItem<CalamityGlobalItem>(mod).rogue = true;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
CalamityPlayer p = Main.player[Main.myPlayer].GetCalamityPlayer();
//If stealth is full, shoot a spread of 3 boomerangs with reduced range
if(p.StealthStrikeAvailable())
{
int spread = 10;
for (int i = 0; i <3; i++)
{
Vector2 perturbedspeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(spread));
Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, mod.ProjectileType("Kylieproj"), item.damage, item.knockBack, player.whoAmI,0f,1f);
spread -= 10;
}
return false;
}
return true;
}
public override bool CanUseItem(Player player)
{
//If you have more than one boomerang, you cant shoot another
int MAX = 1;
int launched = 0;
foreach (Projectile projectile in Main.projectile)
if (projectile.type == item.shoot && projectile.owner == item.owner && projectile.active)
{
launched++;
}
return (launched >= MAX) ? false : true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

+1 -1
View File
@@ -70,4 +70,4 @@ namespace CalamityMod.Projectiles.Rogue
}
}
}
}
}
@@ -73,4 +73,4 @@ namespace CalamityMod.Projectiles.Rogue
return false;
}
}
}
}
@@ -66,4 +66,4 @@ namespace CalamityMod.Projectiles.Rogue
return false;
}
}
}
}
@@ -34,4 +34,4 @@ namespace CalamityMod.Projectiles.Rogue
projectile.alpha += 5;
}
}
}
}
@@ -67,4 +67,4 @@ namespace CalamityMod.Projectiles.Rogue
}
}
}
}
}
+1 -1
View File
@@ -129,7 +129,7 @@ namespace CalamityMod.Projectiles.Rogue
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
{
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
return false;
}
@@ -57,4 +57,4 @@ namespace CalamityMod.Projectiles.Rogue
}
}
}
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Rogue
// ai[1] = 1 means that the projectile is a stealth strike, in which case it pierces infinitely.
if (projectile.ai[1] == 1f)
projectile.penetrate = projectile.maxPenetrate = -1;
// Boomerang rotation
projectile.rotation += 0.4f * (float)projectile.direction;
+118
View File
@@ -0,0 +1,118 @@
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class KylieBoomerang : ModProjectile
{
//This variable will be used for the stealth strike
internal float timer = 0f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Kylie");
}
public override void SetDefaults()
{
projectile.friendly = true;
projectile.width = 40;
projectile.height = 40;
projectile.penetrate = -1;
projectile.timeLeft = 360;
projectile.tileCollide = false;
drawOffsetX = 6 * projectile.spriteDirection;
Mod calamity = ModLoader.GetMod("CalamityMod");
projectile.GetGlobalProjectile<CalamityGlobalProjectile>(calamity).rogue = true;
}
public override void AI()
{
//Constant rotation
projectile.rotation += 0.2f;
projectile.ai[0]++;
//Dust trail
if(Main.rand.Next(15) == 0)
{
int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 7, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 100, default(Color), 0f);
Main.dust[d].position = projectile.Center;
}
//Constant sound effects
if (projectile.soundDelay == 0)
{
projectile.soundDelay = 15;
Main.PlaySound(SoundID.Item7, projectile.position);
}
//Slopes REEEEEEEEEEEE
if (projectile.ai[0] == 3f)
{
projectile.tileCollide = true;
}
//Decide the range of the boomerang depending on stealth
if (projectile.ai[1] == 1)
{
timer = 30f;
}
else
{
timer = 60f;
}
//Home in on the player after certain time
if (projectile.ai[0] >= timer)
{
projectile.tileCollide = false;
Player target = Main.player[projectile.owner];
float var2 = target.position.X + (target.width / 2);
float var3 = target.position.Y + (target.height / 2);
float homingstrenght = 11f;
Vector2 vector1 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f);
float var6 = var2 - vector1.X;
float var7 = var3 - vector1.Y;
float var8 = (float)Math.Sqrt(var6 * var6 + var7 * var7);
var8 = homingstrenght / var8;
var6 *= var8;
var7 *= var8;
projectile.velocity.X = (projectile.velocity.X * 20f + var6) / 21f;
projectile.velocity.Y = (projectile.velocity.Y * 20f + var7) / 21f;
//Kill projectile if it collides with player
if (Main.myPlayer == projectile.owner)
{
Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
Rectangle value2 = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height);
if (rectangle.Intersects(value2))
{
projectile.Kill();
}
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
//Start homing at player if you hit an enemy
projectile.ai[0] = 90;
projectile.tileCollide = false;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
//Bounce off tiles and start homing on player if it hits a tile
Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height);
Main.PlaySound(0, projectile.position);
if (projectile.velocity.X != oldVelocity.X)
{
projectile.velocity.X = -oldVelocity.X;
}
if (projectile.velocity.Y != oldVelocity.Y)
{
projectile.velocity.Y = -oldVelocity.Y;
}
projectile.ai[0] = 90;
projectile.tileCollide = false;
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

+31 -31
View File
@@ -63,42 +63,42 @@ namespace CalamityMod
npc.lifeMax = revengeance.Value;
}
}
/// <summary>
/// Detects nearby hostile NPCs from a given point
/// </summary>
/// <param name="origin">The position where we wish to check for nearby NPCs</param>
/// <summary>
/// Detects nearby hostile NPCs from a given point
/// </summary>
/// <param name="origin">The position where we wish to check for nearby NPCs</param>
/// <param name="maxDistanceToCheck">Maximum amount of pixels to check around the origin</param>
public static NPC ClosestNPCAt(this Vector2 origin, float maxDistanceToCheck)
{
NPC closestTarget = null;
float distance = maxDistanceToCheck;
for (int index = 0; index < Main.npc.Length; index++)
{
//doesn't matter what the attacker is in CanBeChasedBy? wtf.
if (Main.npc[index].CanBeChasedBy(null, false) && Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1))
{
if (Vector2.Distance(origin, Main.npc[index].Center) < distance)
{
distance = Vector2.Distance(origin, Main.npc[index].Center);
closestTarget = Main.npc[index];
}
}
public static NPC ClosestNPCAt(this Vector2 origin, float maxDistanceToCheck)
{
NPC closestTarget = null;
float distance = maxDistanceToCheck;
for (int index = 0; index < Main.npc.Length; index++)
{
//doesn't matter what the attacker is in CanBeChasedBy? wtf.
if (Main.npc[index].CanBeChasedBy(null, false) && Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1))
{
if (Vector2.Distance(origin, Main.npc[index].Center) < distance)
{
distance = Vector2.Distance(origin, Main.npc[index].Center);
closestTarget = Main.npc[index];
}
}
}
return closestTarget;
return closestTarget;
}
/// <summary>
/// Detects nearby hostile NPCs from a given point with minion support
/// </summary>
/// <param name="origin">The position where we wish to check for nearby NPCs</param>
/// <param name="maxDistanceToCheck">Maximum amount of pixels to check around the origin</param>
/// <summary>
/// Detects nearby hostile NPCs from a given point with minion support
/// </summary>
/// <param name="origin">The position where we wish to check for nearby NPCs</param>
/// <param name="maxDistanceToCheck">Maximum amount of pixels to check around the origin</param>
/// <param name="owner">Owner of the minion</param>
public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner)
{
if (owner.HasMinionAttackTargetNPC)
{
return Main.npc[owner.MinionAttackTargetNPC];
public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner)
{
if (owner.HasMinionAttackTargetNPC)
{
return Main.npc[owner.MinionAttackTargetNPC];
}
return ClosestNPCAt(origin,maxDistanceToCheck);
return ClosestNPCAt(origin,maxDistanceToCheck);
}
}