Merge branch 'master' of https://github.com/UncleDanny/CalamityMod
No files matched your search
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,36 @@
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Buffs.Summon
|
||||
{
|
||||
public class MagicHatBuff : ModBuff
|
||||
{
|
||||
public override void SetDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Magic Hat");
|
||||
Description.SetDefault("The hat carries your soul, bound by a contract");
|
||||
Main.buffNoTimeDisplay[Type] = true;
|
||||
Main.buffNoSave[Type] = true;
|
||||
}
|
||||
|
||||
public override void Update(Player player, ref int buffIndex)
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (player.ownedProjectileCounts[ModContent.ProjectileType<MagicHat>()] > 0)
|
||||
{
|
||||
modPlayer.magicHat = true;
|
||||
}
|
||||
if (!modPlayer.magicHat)
|
||||
{
|
||||
player.DelBuff(buffIndex);
|
||||
buffIndex--;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.buffTime[buffIndex] = 18000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 509 B |
@@ -1,4 +1,6 @@
|
||||
using Terraria.ModLoader;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.NPCs.AcidRain;
|
||||
|
||||
namespace CalamityMod.Items.SummonItems
|
||||
{
|
||||
@@ -16,6 +18,14 @@ namespace CalamityMod.Items.SummonItems
|
||||
item.maxStack = 20;
|
||||
item.rare = 9;
|
||||
item.bait = 69420;
|
||||
item.useStyle = 1;
|
||||
item.autoReuse = true;
|
||||
item.useTurn = true;
|
||||
item.useAnimation = 15;
|
||||
item.useTime = 10;
|
||||
item.consumable = true;
|
||||
item.noUseGraphic = true;
|
||||
item.makeNPC = (short)ModContent.NPCType<BloodwormNormal>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Items.Tools;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using CalamityMod.Tiles.Furniture.CraftingStations;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Summon
|
||||
{
|
||||
public class BensUmbrella : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Ben's Umbrella");
|
||||
Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" +
|
||||
"Summons a magic hat to hover above your head\n" +
|
||||
"The hat will release a variety of objects to assault your foes\n" +
|
||||
"Requires 5 minion slots to use\n" +
|
||||
"There can only be one");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.mana = 99;
|
||||
item.damage = 3001;
|
||||
item.useStyle = 1;
|
||||
item.width = 74;
|
||||
item.height = 72;
|
||||
item.useTime = 36;
|
||||
item.useAnimation = 36;
|
||||
item.noMelee = true;
|
||||
item.knockBack = 0f;
|
||||
item.value = Item.buyPrice(5, 0, 0, 0);
|
||||
item.Calamity().postMoonLordRarity = 16;
|
||||
item.rare = 10;
|
||||
item.UseSound = SoundID.Item68;
|
||||
item.autoReuse = true;
|
||||
item.shoot = ModContent.ProjectileType<MagicHat>();
|
||||
item.shootSpeed = 10f;
|
||||
item.summon = true;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
Projectile p = Main.projectile[i];
|
||||
if (p.active && p.type == ModContent.ProjectileType<MagicHat>() && p.owner == player.whoAmI)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
position = Main.MouseWorld;
|
||||
speedX = 0;
|
||||
speedY = 0;
|
||||
for (int x = 0; x < Main.projectile.Length; x++)
|
||||
{
|
||||
Projectile projectile = Main.projectile[x];
|
||||
if (projectile.active && projectile.owner == player.whoAmI && projectile.type == type)
|
||||
{
|
||||
projectile.Kill();
|
||||
}
|
||||
}
|
||||
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<SpikecragStaff>());
|
||||
recipe.AddIngredient(ModContent.ItemType<RadiantResolution>());
|
||||
recipe.AddIngredient(ItemID.Umbrella);
|
||||
recipe.AddIngredient(ItemID.TopHat);
|
||||
recipe.AddIngredient(ModContent.ItemType<ShadowspecBar>(), 4);
|
||||
recipe.AddTile(ModContent.TileType<DraedonsForge>());
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -50,9 +50,9 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ItemID.StaffoftheFrostHydra);
|
||||
recipe.AddIngredient(ItemID.RavenStaff);
|
||||
recipe.AddIngredient(ModContent.ItemType<CosmiliteBar>(), 5);
|
||||
recipe.AddIngredient(ModContent.ItemType<EndothermicEnergy>(), 15);
|
||||
recipe.AddIngredient(ModContent.ItemType<NightmareFuel>(), 15);
|
||||
recipe.AddTile(ModContent.TileType<DraedonsForge>());
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<Sirius>());
|
||||
recipe.AddIngredient(ModContent.ItemType<CorvidHarbingerStaff>());
|
||||
recipe.AddIngredient(ModContent.ItemType<AncientIceChunk>());
|
||||
recipe.AddIngredient(ModContent.ItemType<ElementalAxe>());
|
||||
recipe.AddIngredient(ModContent.ItemType<EnergyStaff>());
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Summon
|
||||
item.damage = 555;
|
||||
item.knockBack = 3f;
|
||||
item.autoReuse = true;
|
||||
item.useTime = item.useAnimation = 40;
|
||||
item.useTime = item.useAnimation = 36;
|
||||
item.shoot = ModContent.ProjectileType<RadiantResolutionAura>();
|
||||
item.shootSpeed = 10f;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
{
|
||||
DisplayName.SetDefault("Bloodworm");
|
||||
Main.npcFrameCount[npc.type] = 7;
|
||||
Main.npcCatchable[npc.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Buffs.Summon;
|
||||
using CalamityMod.CalPlayer;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicAxe : ModProjectile
|
||||
{
|
||||
private int counter = 0;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Axe");
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 52;
|
||||
projectile.height = 52;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 0;
|
||||
projectile.timeLeft = 180;
|
||||
projectile.penetrate = -1;
|
||||
projectile.minion = true;
|
||||
projectile.tileCollide = false;
|
||||
projectile.extraUpdates = 1;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 4;
|
||||
projectile.alpha = 255;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
|
||||
projectile.rotation += 0.075f;
|
||||
projectile.alpha -= 50;
|
||||
float num634 = 1200f;
|
||||
float num635 = 2500f;
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<MagicAxe>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (projectile.ai[1] <= 30)
|
||||
{
|
||||
projectile.ai[1]++;
|
||||
return;
|
||||
}
|
||||
bool flag24 = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
counter += 1;
|
||||
projectile.extraUpdates = 4;
|
||||
if (counter > 30)
|
||||
{
|
||||
counter = 1;
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.extraUpdates = 1;
|
||||
projectile.numUpdates = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag24 = true;
|
||||
}
|
||||
}
|
||||
if (flag24)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2 vector46 = projectile.position;
|
||||
float homingRange = 700f;
|
||||
bool homeIn = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float num646 = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if ((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < homingRange) || !homeIn)
|
||||
{
|
||||
homingRange = num646;
|
||||
vector46 = npc.Center;
|
||||
homeIn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num645 = 0; num645 < Main.npc.Length; num645++)
|
||||
{
|
||||
NPC nPC2 = Main.npc[num645];
|
||||
if (nPC2.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
|
||||
if ((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < homingRange) || !homeIn)
|
||||
{
|
||||
homingRange = num646;
|
||||
vector46 = nPC2.Center;
|
||||
homeIn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float num647 = num634;
|
||||
if (homeIn)
|
||||
{
|
||||
num647 = num635;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > num647)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (homeIn && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vector47 = vector46 - projectile.Center;
|
||||
float num648 = vector47.Length();
|
||||
vector47.Normalize();
|
||||
if (num648 > 200f)
|
||||
{
|
||||
float scaleFactor2 = 24f; //8
|
||||
vector47 *= scaleFactor2;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num649 = 12f; //4
|
||||
vector47 *= -num649;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; //41
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag26 = false;
|
||||
float num636 = 400f;
|
||||
if (!flag26)
|
||||
{
|
||||
flag26 = projectile.ai[0] == 1f;
|
||||
}
|
||||
float num650 = 6f;
|
||||
if (flag26)
|
||||
{
|
||||
num650 = 15f;
|
||||
}
|
||||
Vector2 center2 = projectile.Center;
|
||||
Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f);
|
||||
float playerDist = vector48.Length();
|
||||
if (playerDist > 200f && num650 < 8f)
|
||||
{
|
||||
num650 = 8f;
|
||||
}
|
||||
if (playerDist < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (playerDist > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (playerDist > 70f)
|
||||
{
|
||||
vector48.Normalize();
|
||||
vector48 *= num650;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
|
||||
}
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
if (counter > 0)
|
||||
{
|
||||
counter += Main.rand.Next(1, 4);
|
||||
}
|
||||
if (counter > 30)
|
||||
{
|
||||
counter = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
if (counter == 0 && homeIn && homingRange < 500f)
|
||||
{
|
||||
counter += 1;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
projectile.ai[0] = 2f;
|
||||
Vector2 value20 = vector46 - projectile.Center;
|
||||
value20.Normalize();
|
||||
projectile.velocity = value20 * 16f; //8
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(0, 255, 111, projectile.alpha);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 120);
|
||||
target.AddBuff(ModContent.BuffType<GlacialState>(), 120);
|
||||
target.AddBuff(ModContent.BuffType<Plague>(), 120);
|
||||
target.AddBuff(ModContent.BuffType<HolyFlames>(), 120);
|
||||
}
|
||||
|
||||
public override void OnHitPvp(Player target, int damage, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 120);
|
||||
target.AddBuff(ModContent.BuffType<GlacialState>(), 120);
|
||||
target.AddBuff(ModContent.BuffType<Plague>(), 120);
|
||||
target.AddBuff(ModContent.BuffType<HolyFlames>(), 120);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 555 B |
@@ -0,0 +1,56 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicBat : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Baseball Bat");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 20;
|
||||
projectile.height = 20;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = 1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.timeLeft = 150;
|
||||
projectile.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f;
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(80, 200, 120, projectile.alpha);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 67, dspeed.X, dspeed.Y, 50, default, 1.2f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D tex = Main.projectileTexture[projectile.type];
|
||||
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 454 B |
@@ -0,0 +1,145 @@
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicBird : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Bird");
|
||||
Main.projFrames[projectile.type] = 7;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.friendly = true;
|
||||
projectile.width = 14;
|
||||
projectile.height = 14;
|
||||
projectile.minion = true;
|
||||
projectile.minionSlots = 0f;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.tileCollide = false;
|
||||
projectile.extraUpdates = 1;
|
||||
projectile.alpha = 255;
|
||||
projectile.timeLeft = 180;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi);
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter > 6)
|
||||
{
|
||||
projectile.frame++;
|
||||
projectile.frameCounter = 0;
|
||||
}
|
||||
if (projectile.frame >= 7)
|
||||
{
|
||||
projectile.frame = 0;
|
||||
}
|
||||
projectile.ai[0]++;
|
||||
projectile.ai[1]++;
|
||||
if (projectile.ai[0] >= 20f)
|
||||
{
|
||||
Vector2 dspeed = projectile.velocity * Main.rand.NextFloat(0.3f,0.6f);
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 67, dspeed.X, dspeed.Y, 50, default, 1.2f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
projectile.ai[0] = 0f;
|
||||
}
|
||||
|
||||
//Homing
|
||||
if (projectile.ai[1] > 30f)
|
||||
HomingAI();
|
||||
//Fade in
|
||||
if (projectile.alpha > 0)
|
||||
{
|
||||
projectile.alpha -= 15;
|
||||
}
|
||||
if (projectile.alpha < 0)
|
||||
{
|
||||
projectile.alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void HomingAI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
int targetIdx = -1;
|
||||
float maxHomingRange = 700f;
|
||||
bool hasHomingTarget = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float dist = (projectile.Center - npc.Center).Length();
|
||||
if (dist < maxHomingRange)
|
||||
{
|
||||
targetIdx = player.MinionAttackTargetNPC;
|
||||
maxHomingRange = dist;
|
||||
hasHomingTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Main.npc.Length; ++i)
|
||||
{
|
||||
NPC npc = Main.npc[i];
|
||||
if (npc == null || !npc.active)
|
||||
continue;
|
||||
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float dist = (projectile.Center - npc.Center).Length();
|
||||
if (dist < maxHomingRange)
|
||||
{
|
||||
targetIdx = i;
|
||||
maxHomingRange = dist;
|
||||
hasHomingTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Home in on said closest NPC.
|
||||
if (hasHomingTarget)
|
||||
{
|
||||
NPC target = Main.npc[targetIdx];
|
||||
Vector2 homingVector = (target.Center - projectile.Center).SafeNormalize(Vector2.Zero) * 32f;
|
||||
float homingRatio = 15f;
|
||||
projectile.velocity = (projectile.velocity * homingRatio + homingVector) / (homingRatio + 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 67, dspeed.X, dspeed.Y, 50, default, 1.2f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(255, 239, 0, projectile.alpha);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,58 @@
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicBullet : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Bullet");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 4;
|
||||
projectile.height = 4;
|
||||
projectile.light = 0.5f;
|
||||
projectile.alpha = 255;
|
||||
projectile.extraUpdates = 7;
|
||||
projectile.scale = 1.18f;
|
||||
projectile.friendly = true;
|
||||
projectile.minion = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.aiStyle = 1;
|
||||
aiType = 242;
|
||||
projectile.penetrate = 1;
|
||||
projectile.timeLeft = 600;
|
||||
projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<MarkedforDeath>(), 180);
|
||||
target.AddBuff(ModContent.BuffType<ArmorCrunch>(), 180);
|
||||
target.AddBuff(ModContent.BuffType<WarCleave>(), 180);
|
||||
target.AddBuff(BuffID.BetsysCurse, 180);
|
||||
target.AddBuff(BuffID.Ichor, 180);
|
||||
}
|
||||
|
||||
public override void OnHitPvp(Player target, int damage, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<MarkedforDeath>(), 180);
|
||||
target.AddBuff(ModContent.BuffType<ArmorCrunch>(), 180);
|
||||
target.AddBuff(ModContent.BuffType<WarCleave>(), 180);
|
||||
target.AddBuff(BuffID.BetsysCurse, 180);
|
||||
target.AddBuff(BuffID.Ichor, 180);
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(189, 51, 164, projectile.alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 130 B |
@@ -0,0 +1,165 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicHammer : ModProjectile
|
||||
{
|
||||
private int counter = 0;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Hammer");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 4;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 60;
|
||||
projectile.height = 60;
|
||||
projectile.alpha = 255;
|
||||
projectile.friendly = true;
|
||||
projectile.minion = true;
|
||||
projectile.penetrate = 10;
|
||||
projectile.timeLeft = 180;
|
||||
projectile.tileCollide = false;
|
||||
projectile.extraUpdates = 1;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 5;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.localAI[1] += 1f;
|
||||
if (projectile.localAI[1] > 10f && Main.rand.NextBool(3))
|
||||
{
|
||||
projectile.alpha -= 5;
|
||||
if (projectile.alpha < 50)
|
||||
{
|
||||
projectile.alpha = 50;
|
||||
}
|
||||
}
|
||||
projectile.rotation += 0.075f;
|
||||
if (counter <= 30)
|
||||
{
|
||||
counter++;
|
||||
return;
|
||||
}
|
||||
int num716 = -1;
|
||||
Vector2 vector59 = projectile.Center;
|
||||
float num717 = 700f;
|
||||
if (projectile.localAI[0] > 0f)
|
||||
{
|
||||
projectile.localAI[0] -= 1f;
|
||||
}
|
||||
Player player = Main.player[projectile.owner];
|
||||
if (projectile.ai[0] == 0f && projectile.localAI[0] == 0f)
|
||||
{
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (float)(player.MinionAttackTargetNPC + 1)))
|
||||
{
|
||||
Vector2 center4 = npc.Center;
|
||||
float num719 = Vector2.Distance(center4, vector59);
|
||||
if (num719 < num717)
|
||||
{
|
||||
num717 = num719;
|
||||
vector59 = center4;
|
||||
num716 = player.MinionAttackTargetNPC;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num718 = 0; num718 < Main.npc.Length; num718++)
|
||||
{
|
||||
NPC nPC6 = Main.npc[num718];
|
||||
if (nPC6.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (float)(num718 + 1)))
|
||||
{
|
||||
Vector2 center4 = nPC6.Center;
|
||||
float num719 = Vector2.Distance(center4, vector59);
|
||||
if (num719 < num717)
|
||||
{
|
||||
num717 = num719;
|
||||
vector59 = center4;
|
||||
num716 = num718;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num716 >= 0)
|
||||
{
|
||||
projectile.ai[0] = (float)(num716 + 1);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
if (projectile.localAI[0] == 0f && projectile.ai[0] == 0f)
|
||||
{
|
||||
projectile.localAI[0] = 30f;
|
||||
}
|
||||
bool flag32 = false;
|
||||
if (projectile.ai[0] != 0f)
|
||||
{
|
||||
int num720 = (int)(projectile.ai[0] - 1f);
|
||||
if (Main.npc[num720].active && !Main.npc[num720].dontTakeDamage && Main.npc[num720].immune[projectile.owner] == 0)
|
||||
{
|
||||
float num721 = Main.npc[num720].position.X + (float)(Main.npc[num720].width / 2);
|
||||
float num722 = Main.npc[num720].position.Y + (float)(Main.npc[num720].height / 2);
|
||||
float num723 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num721) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num722);
|
||||
if (num723 < 1000f)
|
||||
{
|
||||
flag32 = true;
|
||||
vector59 = Main.npc[num720].Center;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
flag32 = false;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
if (flag32)
|
||||
{
|
||||
Vector2 v = vector59 - projectile.Center;
|
||||
float num724 = projectile.velocity.ToRotation();
|
||||
float num725 = v.ToRotation();
|
||||
double num726 = (double)(num725 - num724);
|
||||
num726 = MathHelper.WrapAngle((float)num726);
|
||||
projectile.velocity = projectile.velocity.RotatedBy(num726 * 0.25, default);
|
||||
}
|
||||
float num727 = projectile.velocity.Length();
|
||||
projectile.velocity.Normalize();
|
||||
projectile.velocity *= num727 + 0.0025f;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(255, 56, 0, projectile.alpha);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 67, dspeed.X, dspeed.Y, 50, default, 1.2f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 586 B |
@@ -0,0 +1,178 @@
|
||||
using CalamityMod.Buffs.Summon;
|
||||
using CalamityMod.CalPlayer;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicHat : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Magic Hat");
|
||||
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
|
||||
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 5f;
|
||||
projectile.timeLeft = 18000;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.timeLeft *= 5;
|
||||
projectile.minion = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
CalamityGlobalProjectile modProj = projectile.Calamity();
|
||||
|
||||
//set up minion buffs and bools
|
||||
bool hatExists = projectile.type == ModContent.ProjectileType<MagicHat>();
|
||||
player.AddBuff(ModContent.BuffType<MagicHatBuff>(), 3600);
|
||||
if (hatExists)
|
||||
{
|
||||
if (player.dead)
|
||||
{
|
||||
modPlayer.magicHat = false;
|
||||
}
|
||||
if (modPlayer.magicHat)
|
||||
{
|
||||
projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
|
||||
//projectile movement
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f;
|
||||
if (player.gravDir == -1f)
|
||||
{
|
||||
projectile.position.Y = projectile.position.Y + 150f;
|
||||
projectile.rotation = MathHelper.Pi;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.rotation = 0f;
|
||||
}
|
||||
projectile.position.X = (float)(int)projectile.position.X;
|
||||
projectile.position.Y = (float)(int)projectile.position.Y;
|
||||
|
||||
//I don't know what this is
|
||||
float num395 = (float)Main.mouseTextColor / 200f - 0.35f;
|
||||
num395 *= 0.2f;
|
||||
projectile.scale = num395 + 0.95f;
|
||||
|
||||
//on summon dust and flexible damage
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
int dustAmt = 50;
|
||||
for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++)
|
||||
{
|
||||
int dustEffects = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 234, 0f, 0f, 0, default, 1f);
|
||||
Main.dust[dustEffects].velocity *= 2f;
|
||||
Main.dust[dustEffects].scale *= 1.15f;
|
||||
}
|
||||
modProj.spawnedPlayerMinionDamageValue = (player.allDamage + player.minionDamage - 1f);
|
||||
modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage;
|
||||
projectile.localAI[0] += 1f;
|
||||
}
|
||||
if ((player.allDamage + player.minionDamage - 1f) != modProj.spawnedPlayerMinionDamageValue)
|
||||
{
|
||||
int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue /
|
||||
modProj.spawnedPlayerMinionDamageValue *
|
||||
(player.allDamage + player.minionDamage - 1f));
|
||||
projectile.damage = damage2;
|
||||
}
|
||||
|
||||
//finding an enemy, then shooting projectiles at it
|
||||
if (projectile.owner == Main.myPlayer)
|
||||
{
|
||||
float projPosX = projectile.position.X;
|
||||
float projPosY = projectile.position.Y;
|
||||
float detectionRange = 1500f;
|
||||
bool enemyDetected = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false))
|
||||
{
|
||||
float xDist = npc.position.X + (float)(npc.width / 2);
|
||||
float yDist = npc.position.Y + (float)(npc.height / 2);
|
||||
float enemyDist = Math.Abs(projPosX + (float)(projectile.width / 2) - xDist) + Math.Abs(projPosY + (float)(projectile.height / 2) - yDist);
|
||||
if (enemyDist < detectionRange)
|
||||
{
|
||||
detectionRange = enemyDist;
|
||||
projPosX = xDist;
|
||||
projPosY = yDist;
|
||||
enemyDetected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < Main.npc.Length; index++)
|
||||
{
|
||||
NPC target = Main.npc[index];
|
||||
if (target.CanBeChasedBy(projectile, true))
|
||||
{
|
||||
float xDist = target.position.X + (float)(target.width / 2);
|
||||
float yDist = target.position.Y + (float)(target.height / 2);
|
||||
float enemyDist = Math.Abs(projPosX + (float)(projectile.width / 2) - xDist) + Math.Abs(projPosY + (float)(projectile.height / 2) - yDist);
|
||||
if (enemyDist < detectionRange)
|
||||
{
|
||||
detectionRange = enemyDist;
|
||||
projPosX = xDist;
|
||||
projPosY = yDist;
|
||||
enemyDetected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enemyDetected)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
if ((projectile.ai[1] % 5f) == 0f)
|
||||
{
|
||||
int amount = Main.rand.Next(1, 2);
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
int projType = Utils.SelectRandom(Main.rand, new int[]
|
||||
{
|
||||
ModContent.ProjectileType<MagicUmbrella>(),
|
||||
ModContent.ProjectileType<MagicRifle>(),
|
||||
ModContent.ProjectileType<MagicHammer>(),
|
||||
ModContent.ProjectileType<MagicAxe>(),
|
||||
ModContent.ProjectileType<MagicBird>()
|
||||
});
|
||||
float velocityX = Main.rand.NextFloat(-10f, 10f);
|
||||
float velocityY = Main.rand.NextFloat(-15f, -8f);
|
||||
Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), velocityX, velocityY, projType, projectile.damage, 0f, projectile.owner, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//glowmask effect
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(200, 200, 200, 200);
|
||||
}
|
||||
|
||||
//no contact damage
|
||||
public override bool CanDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 502 B |
@@ -0,0 +1,235 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicRifle : ModProjectile
|
||||
{
|
||||
private int counter = 0;
|
||||
private bool canHome = false;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Rifle");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 0f;
|
||||
projectile.timeLeft = 180;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.minion = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<MagicRifle>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (counter <= 30)
|
||||
{
|
||||
counter++;
|
||||
canHome = true;
|
||||
}
|
||||
float homingRange = 700f;
|
||||
float num634 = 1300f;
|
||||
float num635 = 2600f;
|
||||
float num636 = 600f;
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
float num646 = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if ((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < homingRange) || !flag25)
|
||||
{
|
||||
vector46 = npc.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num645 = 0; num645 < Main.npc.Length; num645++)
|
||||
{
|
||||
NPC nPC2 = Main.npc[num645];
|
||||
if (nPC2.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
|
||||
if ((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < homingRange) || !flag25)
|
||||
{
|
||||
homingRange = num646;
|
||||
vector46 = nPC2.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float num647 = num634;
|
||||
if (flag25)
|
||||
{
|
||||
num647 = num635;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > num647)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (flag25 && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vector47 = vector46 - projectile.Center;
|
||||
float num648 = vector47.Length();
|
||||
vector47.Normalize();
|
||||
if (num648 > 200f)
|
||||
{
|
||||
float scaleFactor2 = 18f; //12
|
||||
vector47 *= scaleFactor2;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num649 = 9f;
|
||||
vector47 *= -num649;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag26 = false;
|
||||
if (!flag26)
|
||||
{
|
||||
flag26 = projectile.ai[0] == 1f;
|
||||
}
|
||||
float num650 = 12f;
|
||||
if (flag26)
|
||||
{
|
||||
num650 = 30f;
|
||||
}
|
||||
Vector2 center2 = projectile.Center;
|
||||
Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f);
|
||||
float num651 = vector48.Length();
|
||||
if (num651 > 200f && num650 < 16f)
|
||||
{
|
||||
num650 = 16f;
|
||||
}
|
||||
if (num651 < num636 && flag26)
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 70f)
|
||||
{
|
||||
vector48.Normalize();
|
||||
vector48 *= num650;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
|
||||
}
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
if (flag25)
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
projectile.rotation = (vector46 - projectile.Center).ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
||||
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135));
|
||||
}
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 4);
|
||||
}
|
||||
if (projectile.ai[1] > 90f)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
float scaleFactor3 = 6f;
|
||||
int projType = ModContent.ProjectileType<MagicBullet>();
|
||||
if (flag25 && projectile.ai[1] == 0f)
|
||||
{
|
||||
if (Main.rand.NextBool(5))
|
||||
{
|
||||
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.25f);
|
||||
}
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
Vector2 value19 = vector46 - projectile.Center;
|
||||
value19.Normalize();
|
||||
value19 *= scaleFactor3;
|
||||
Main.PlaySound(SoundID.Item40, projectile.position);
|
||||
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, projType, projectile.damage, 0f, Main.myPlayer, 0f, 0f);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(148, 0, 211, projectile.alpha);
|
||||
}
|
||||
|
||||
public override bool CanDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 604 B |
@@ -0,0 +1,298 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class MagicUmbrella : ModProjectile
|
||||
{
|
||||
private int counter = 0;
|
||||
private bool canHome = false;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Umbrella");
|
||||
ProjectileID.Sets.MinionShot[projectile.type] = true;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 10;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 14;
|
||||
projectile.height = 14;
|
||||
projectile.netImportant = true;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.minionSlots = 0f;
|
||||
projectile.timeLeft = 180;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.minion = true;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 10;
|
||||
projectile.alpha = 255;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Player player = Main.player[projectile.owner];
|
||||
projectile.rotation += 0.075f;
|
||||
projectile.alpha -= 50;
|
||||
float num633 = 700f;
|
||||
float num634 = 1000f;
|
||||
float num635 = 2200f;
|
||||
float num636 = 150f;
|
||||
float num637 = 0.05f;
|
||||
for (int num638 = 0; num638 < Main.projectile.Length; num638++)
|
||||
{
|
||||
bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType<MagicUmbrella>();
|
||||
if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner &&
|
||||
flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
|
||||
{
|
||||
if (projectile.position.X < Main.projectile[num638].position.X)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + num637;
|
||||
}
|
||||
if (projectile.position.Y < Main.projectile[num638].position.Y)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - num637;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + num637;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (counter <= 30)
|
||||
{
|
||||
counter++;
|
||||
canHome = true;
|
||||
}
|
||||
bool flag24 = false;
|
||||
if (projectile.ai[0] == 2f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
projectile.extraUpdates = 1;
|
||||
if (projectile.ai[1] > 40f)
|
||||
{
|
||||
projectile.ai[1] = 1f;
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.extraUpdates = 0;
|
||||
projectile.numUpdates = 0;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag24 = true;
|
||||
}
|
||||
}
|
||||
if (flag24)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canHome)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2 vector46 = projectile.position;
|
||||
bool flag25 = false;
|
||||
if (player.HasMinionAttackTargetNPC)
|
||||
{
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
if (npc.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
float num646 = Vector2.Distance(npc.Center, projectile.Center);
|
||||
if ((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < num633) || !flag25)
|
||||
{
|
||||
num633 = num646;
|
||||
vector46 = npc.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num645 = 0; num645 < Main.npc.Length; num645++)
|
||||
{
|
||||
NPC nPC2 = Main.npc[num645];
|
||||
if (nPC2.CanBeChasedBy(projectile, false) && canHome)
|
||||
{
|
||||
float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
|
||||
if ((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < num633) || !flag25)
|
||||
{
|
||||
num633 = num646;
|
||||
vector46 = nPC2.Center;
|
||||
flag25 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float num647 = num634;
|
||||
if (flag25)
|
||||
{
|
||||
num647 = num635;
|
||||
}
|
||||
if (Vector2.Distance(player.Center, projectile.Center) > num647)
|
||||
{
|
||||
projectile.ai[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (flag25 && projectile.ai[0] == 0f)
|
||||
{
|
||||
Vector2 vector47 = vector46 - projectile.Center;
|
||||
float num648 = vector47.Length();
|
||||
vector47.Normalize();
|
||||
if (num648 > 200f)
|
||||
{
|
||||
float scaleFactor2 = 9f; //8
|
||||
vector47 *= scaleFactor2;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num649 = 4f;
|
||||
vector47 *= -num649;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag26 = false;
|
||||
if (!flag26)
|
||||
{
|
||||
flag26 = projectile.ai[0] == 1f;
|
||||
}
|
||||
float num650 = 6f;
|
||||
if (flag26)
|
||||
{
|
||||
num650 = 15f;
|
||||
}
|
||||
Vector2 center2 = projectile.Center;
|
||||
Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f);
|
||||
float num651 = vector48.Length();
|
||||
if (num651 > 200f && num650 < 8f)
|
||||
{
|
||||
num650 = 8f;
|
||||
}
|
||||
if (num651 < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
{
|
||||
projectile.ai[0] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 2000f)
|
||||
{
|
||||
projectile.position.X = player.Center.X - (float)(projectile.width / 2);
|
||||
projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (num651 > 70f)
|
||||
{
|
||||
vector48.Normalize();
|
||||
vector48 *= num650;
|
||||
projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
|
||||
}
|
||||
else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
|
||||
{
|
||||
projectile.velocity.X = -0.15f;
|
||||
projectile.velocity.Y = -0.05f;
|
||||
}
|
||||
}
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
projectile.ai[1] += (float)Main.rand.Next(1, 4);
|
||||
}
|
||||
if (projectile.ai[1] > 40f)
|
||||
{
|
||||
projectile.ai[1] = 0f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.ai[0] == 0f)
|
||||
{
|
||||
if (projectile.ai[1] == 0f && flag25 && num633 < 500f)
|
||||
{
|
||||
projectile.ai[1] += 1f;
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
{
|
||||
projectile.ai[0] = 2f;
|
||||
Vector2 value20 = vector46 - projectile.Center;
|
||||
value20.Normalize();
|
||||
projectile.velocity = value20 * 9f; //8
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
return new Color(75, 255, 255, projectile.alpha);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f));
|
||||
int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
for (int n = 0; n < Main.rand.Next(1, 3); n++) //1 to 2 baseball bats
|
||||
{
|
||||
float x = target.position.X + (float)Main.rand.Next(-400, 400);
|
||||
float y = target.position.Y - (float)Main.rand.Next(500, 800);
|
||||
Vector2 vector = new Vector2(x, y);
|
||||
float num13 = target.position.X + (float)(target.width / 2) - vector.X;
|
||||
float num14 = target.position.Y + (float)(target.height / 2) - vector.Y;
|
||||
num13 += (float)Main.rand.Next(-100, 101);
|
||||
int num15 = 29;
|
||||
float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14));
|
||||
num16 = (float)num15 / num16;
|
||||
num13 *= num16;
|
||||
num14 *= num16;
|
||||
Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType<MagicBat>(), (int)((double)projectile.damage * 0.1 * Main.rand.Next(4, 7)), (int)((double)projectile.knockBack * 0.1 * Main.rand.Next(7, 10)), projectile.owner, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitPvp(Player target, int damage, bool crit)
|
||||
{
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
for (int n = 0; n < Main.rand.Next(1, 3); n++) //1 to 2 baseball bats
|
||||
{
|
||||
float x = target.position.X + (float)Main.rand.Next(-400, 400);
|
||||
float y = target.position.Y - (float)Main.rand.Next(500, 800);
|
||||
Vector2 vector = new Vector2(x, y);
|
||||
float num13 = target.position.X + (float)(target.width / 2) - vector.X;
|
||||
float num14 = target.position.Y + (float)(target.height / 2) - vector.Y;
|
||||
num13 += (float)Main.rand.Next(-100, 101);
|
||||
int num15 = 29;
|
||||
float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14));
|
||||
num16 = (float)num15 / num16;
|
||||
num13 *= num16;
|
||||
num14 *= num16;
|
||||
Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType<MagicBat>(), (int)((double)projectile.damage * 0.1 * Main.rand.Next(4, 7)), (int)((double)projectile.knockBack * 0.1 * Main.rand.Next(7, 10)), projectile.owner, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 493 B |