Finished staff of shifting sands.

A lot of testing is needed because it's a NPC converted to a projectile and a bit hacky.
Known bugs:
    * Tail does not spawn
    * Minion slots are ignored
This commit is contained in:
FyloZ 2020-06-23 01:11:46 -04:00
parent 06fa4569a8
commit f67fdce869
8 changed files with 607 additions and 500 deletions

View File

@ -1,7 +1,6 @@
using Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler; using Decimation.Content.Projectiles.DuneWyrm;
using Decimation.Lib.Items; using Decimation.Lib.Items;
using Decimation.Lib.Util; using Decimation.Lib.Util;
using Terraria;
using Terraria.ModLoader; using Terraria.ModLoader;
namespace Decimation.Content.Items.Weapons.DuneWyrm namespace Decimation.Content.Items.Weapons.DuneWyrm
@ -11,6 +10,7 @@ namespace Decimation.Content.Items.Weapons.DuneWyrm
protected override string ItemName => "Staff of Shifting Sands"; protected override string ItemName => "Staff of Shifting Sands";
protected override int Damages => 30; protected override int Damages => 30;
protected override DamageType DamagesType => DamageType.Summon; protected override DamageType DamagesType => DamageType.Summon;
protected override int ProjectileId => ModContent.ProjectileType<AncientTombCrawlerHead>();
protected override void InitWeapon() protected override void InitWeapon()
{ {
@ -18,12 +18,5 @@ namespace Decimation.Content.Items.Weapons.DuneWyrm
item.height = 42; item.height = 42;
item.rare = Rarity.LightRed.GetRarityValue(); item.rare = Rarity.LightRed.GetRarityValue();
} }
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType<AncientTombCrawlerFriendly>());
return true;
}
} }
} }

View File

@ -11,6 +11,8 @@ namespace Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler
public class AncientTombCrawlerFriendlyHead : AncientTombCrawlerFriendly public class AncientTombCrawlerFriendlyHead : AncientTombCrawlerFriendly
{ {
public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerHead";
public override void SetDefaults() public override void SetDefaults()
{ {
npc.damage = 50; npc.damage = 50;
@ -39,6 +41,8 @@ namespace Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler
public class AncientTombCrawlerFriendlyBody : AncientTombCrawlerFriendly public class AncientTombCrawlerFriendlyBody : AncientTombCrawlerFriendly
{ {
public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerBody";
public override void SetDefaults() public override void SetDefaults()
{ {
npc.width = 24; npc.width = 24;
@ -59,6 +63,8 @@ namespace Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler
public class AncientTombCrawlerFriendlyTail : AncientTombCrawlerFriendly public class AncientTombCrawlerFriendlyTail : AncientTombCrawlerFriendly
{ {
public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerTail";
public override void SetDefaults() public override void SetDefaults()
{ {
npc.width = 20; npc.width = 20;
@ -89,7 +95,7 @@ namespace Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler
public override void SetStaticDefaults() public override void SetStaticDefaults()
{ {
DisplayName.SetDefault("Ancient Tomb Crawler"); DisplayName.SetDefault("Friendly Ancient Tomb Crawler");
} }
public override void Init() public override void Init()
@ -113,6 +119,11 @@ namespace Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler
undergroundSound = mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Earthquake"); undergroundSound = mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Earthquake");
} }
public override bool PreAI()
{
return false;
}
protected override void SendSoundPacket() protected override void SendSoundPacket()
{ {
// GetPacket(AncientTombCrawlerMessageType.UndergroundSound).Send(); // GetPacket(AncientTombCrawlerMessageType.UndergroundSound).Send();

View File

@ -0,0 +1,96 @@
using Decimation.Lib.Projectile;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ModLoader;
namespace Decimation.Content.Projectiles.DuneWyrm
{
class AncientTombCrawlerHead : AncientTombCrawler
{
public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerHead";
protected override void Init()
{
base.Init();
projectile.damage = 50;
projectile.width = 38;
projectile.height = 38;
projectile.minionSlots = 1f;
}
public override void InitWorm()
{
base.InitWorm();
Head = true;
}
}
class AncientTombCrawlerBody : AncientTombCrawler
{
public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerBody";
protected override void Init()
{
base.Init();
projectile.width = 24;
projectile.height = 24;
projectile.damage = 35;
}
}
class AncientTombCrawlerTail : AncientTombCrawler
{
public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerTail";
protected override void Init()
{
base.Init();
projectile.width = 20;
projectile.height = 20;
projectile.damage = 25;
}
public override void InitWorm()
{
base.InitWorm();
Tail = true;
}
}
public abstract class AncientTombCrawler : WormProjectile
{
protected override void Init()
{
projectile.aiStyle = -1;
projectile.penetrate = -1;
projectile.light = 1f;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.netImportant = true;
projectile.timeLeft = int.MaxValue;
projectile.hostile = false;
projectile.friendly = true;
}
public override void InitWorm()
{
MinLength = 8;
MaxLength = 8;
TailType = ModContent.ProjectileType<AncientTombCrawlerTail>();
BodyType = ModContent.ProjectileType<AncientTombCrawlerBody>();
HeadType = ModContent.ProjectileType<AncientTombCrawlerHead>();
Speed = 8f;
TurnSpeed = 0.1f;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Draw(Texture.Replace("Decimation/", ""), spriteBatch, lightColor);
return false;
}
}
}

View File

@ -20,7 +20,7 @@ namespace Decimation.Lib.Items
this.item.damage = Damages; this.item.damage = Damages;
this.item.shoot = ItemUtils.GetIdFromName(this.Projectile, typeof(Projectile), this.VanillaProjectile); this.item.shoot = ItemUtils.GetIdFromName(this.Projectile, typeof(Terraria.Projectile), this.VanillaProjectile);
this.item.ammo = this.Ammo; this.item.ammo = this.Ammo;
this.item.ranged = true; this.item.ranged = true;

View File

@ -58,7 +58,7 @@ namespace Decimation.Lib.Items
if (ProjectileName != null) if (ProjectileName != null)
item.shoot = item.shoot =
ItemUtils.GetIdFromName(ProjectileName, typeof(Projectile), VanillaProjectile); ItemUtils.GetIdFromName(ProjectileName, typeof(Terraria.Projectile), VanillaProjectile);
if (ProjectileId > -1) item.shoot = ProjectileId; if (ProjectileId > -1) item.shoot = ProjectileId;
if (AmmoName != null) if (AmmoName != null)

View File

@ -1,485 +1,504 @@
using System; using System;
using Decimation.Content.Projectiles; using Decimation.Content.Projectiles;
using Decimation.Lib.Util;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Terraria; using Terraria;
using Terraria.ID;
namespace Decimation.Lib.projectiles namespace Decimation.Lib.Projectile
{ {
public abstract class WormProjectile : DecimationProjectile public abstract class WormProjectile : DecimationProjectile
{ {
// protected int BodyType; protected int BodyType;
// protected bool Directional = false; protected bool Directional = false;
//
// protected bool Flies = false; protected bool Flies = false;
//
// /* ai[0] = follower /* ai[0] = follower
// * ai[1] = following * ai[1] = following
// * ai[2] = distanceFromTail * ai[2] = distanceFromTail
// * ai[3] = head * ai[3] = head
// */ */
// protected bool Head; protected bool Head;
// protected int HeadType; protected int HeadType;
// protected int MaxLength; protected int MaxLength;
// protected int MinLength; protected int MinLength;
// protected float Speed; protected float Speed;
// protected bool Tail; protected bool Tail;
// protected int TailType; protected int TailType;
//
// protected float TurnSpeed; protected float TurnSpeed;
//
// protected int Target; protected int Target;
// protected int RealLife; protected int RealLife;
//
// public override void AI() protected float DistanceFromTail;
// { protected float WormHead;
// if (projectile.localAI[1] == 0f)
// { public override void AI()
// projectile.localAI[1] = 1f; {
// Init(); if (projectile.localAI[1] == 0f)
// } {
// projectile.localAI[1] = 1f;
// if (projectile.ai[3] > 0f) RealLife = (int) projectile.ai[3]; InitWorm();
// if (!Head && projectile.timeLeft < 300) projectile.timeLeft = 300; }
// if (Target < 0 || Target == 255 || Main.player[Target].dead)
// TargetClosest(); if (WormHead > 0f) RealLife = (int) WormHead;
// if (Main.player[Target].dead && projectile.timeLeft > 300) projectile.timeLeft = 300;
// if (Main.netMode != 1) if (!Head && projectile.timeLeft < 300) projectile.timeLeft = 300;
// { if (Target < 0 || Target == 255 || !Main.npc[Target].active)
// if (!Tail && projectile.ai[0] == 0f) TargetClosest();
// { if (Main.player[projectile.owner].dead && projectile.timeLeft > 300) projectile.timeLeft = 300;
// if (Head)
// { Entity target;
// projectile.ai[3] = projectile.whoAmI; if (Target < 0)
// RealLife = projectile.whoAmI; {
// projectile.ai[2] = Main.rand.Next(MinLength, MaxLength + 1); target = Main.player[projectile.owner];
// projectile.ai[0] = Projectile.NewProjectile( }
// (int) (projectile.position.X + projectile.width / 2f), else
// (int) (projectile.position.Y + projectile.height), {
// 0f, target = Main.npc[Target];
// 0f, }
// BodyType,
// 0, if (Main.netMode != 1)
// 0f, {
// projectile.owner if (!Tail && projectile.ai[0] == 0f)
// ); {
// } if (Head)
// else if (projectile.ai[2] > 0f) {
// { WormHead = projectile.whoAmI;
// projectile.ai[0] = Projectile.NewProjectile( RealLife = projectile.whoAmI;
// (int) (projectile.position.X + projectile.width / 2f), DistanceFromTail = Main.rand.Next(MinLength, MaxLength + 1);
// (int) (projectile.position.Y + projectile.height), projectile.ai[0] = Terraria.Projectile.NewProjectile(
// 0f, (int) (projectile.position.X + projectile.width / 2f),
// 0f, (int) (projectile.position.Y + projectile.height),
// projectile.type, 0f,
// 0, 0f,
// 0f, BodyType,
// projectile.owner 0,
// ); 0f,
// } projectile.owner
// else );
// { }
// projectile.ai[0] = Projectile.NewProjectile( else if (DistanceFromTail > 0f)
// (int) (projectile.position.X + projectile.width / 2f), {
// (int) (projectile.position.Y + projectile.height), projectile.ai[0] = Terraria.Projectile.NewProjectile(
// 0f, (int) (projectile.position.X + projectile.width / 2f),
// 0f, (int) (projectile.position.Y + projectile.height),
// TailType, 0f,
// 0, 0f,
// 0f, projectile.type,
// projectile.whoAmI 0,
// ); 0f,
// } projectile.owner
// );
// Main.projectile[(int) projectile.ai[0]].ai[3] = projectile.ai[3]; }
// ((WormProjectile) Main.projectile[(int) projectile.ai[0]].modProjectile).RealLife = RealLife; else
// Main.projectile[(int) projectile.ai[0]].ai[1] = projectile.whoAmI; {
// Main.projectile[(int) projectile.ai[0]].ai[2] = projectile.ai[2] - 1f; projectile.ai[0] = Terraria.Projectile.NewProjectile(
// projectile.netUpdate = true; (int) (projectile.position.X + projectile.width / 2f),
// } (int) (projectile.position.Y + projectile.height),
// 0f,
// if (!Head && (!Main.projectile[(int) projectile.ai[1]].active || 0f,
// Main.projectile[(int) projectile.ai[1]].type != HeadType && TailType,
// Main.projectile[(int) projectile.ai[1]].type != BodyType)) 0,
// { 0f,
// // projectile.life = 0; projectile.whoAmI
// // projectile.HitEffect(); );
// projectile.active = false; }
// }
// ((WormProjectile) Main.projectile[(int) projectile.ai[0]].modProjectile).WormHead = WormHead;
// if (!Tail && (!Main.projectile[(int) projectile.ai[0]].active || ((WormProjectile) Main.projectile[(int) projectile.ai[0]].modProjectile).RealLife = RealLife;
// Main.projectile[(int) projectile.ai[0]].type != BodyType && Main.projectile[(int) projectile.ai[0]].ai[1] = projectile.whoAmI;
// Main.projectile[(int) projectile.ai[0]].type != TailType)) ((WormProjectile) Main.projectile[(int) projectile.ai[0]].modProjectile).DistanceFromTail =
// { DistanceFromTail - 1f;
// // projectile.life = 0; projectile.netUpdate = true;
// // projectile.HitEffect(); }
// projectile.active = false; }
// }
// var num180 = (int) (projectile.position.X / 16f) - 1;
// if (!projectile.active && Main.netMode == 2) var num181 = (int) ((projectile.position.X + projectile.width) / 16f) + 2;
// NetMessage.SendData(28, -1, -1, null, projectile.whoAmI, -1f); var num182 = (int) (projectile.position.Y / 16f) - 1;
// } var num183 = (int) ((projectile.position.Y + projectile.height) / 16f) + 2;
// if (num180 < 0) num180 = 0;
// var num180 = (int) (projectile.position.X / 16f) - 1; if (num181 > Main.maxTilesX) num181 = Main.maxTilesX;
// var num181 = (int) ((projectile.position.X + projectile.width) / 16f) + 2; if (num182 < 0) num182 = 0;
// var num182 = (int) (projectile.position.Y / 16f) - 1; if (num183 > Main.maxTilesY) num183 = Main.maxTilesY;
// var num183 = (int) ((projectile.position.Y + projectile.height) / 16f) + 2; var flag18 = Flies;
// if (num180 < 0) num180 = 0; if (!flag18)
// if (num181 > Main.maxTilesX) num181 = Main.maxTilesX; for (var num184 = num180; num184 < num181; num184++)
// if (num182 < 0) num182 = 0; for (var num185 = num182; num185 < num183; num185++)
// if (num183 > Main.maxTilesY) num183 = Main.maxTilesY; if (Main.tile[num184, num185] != null &&
// var flag18 = Flies; (Main.tile[num184, num185].nactive() &&
// if (!flag18) (Main.tileSolid[Main.tile[num184, num185].type] ||
// for (var num184 = num180; num184 < num181; num184++) Main.tileSolidTop[Main.tile[num184, num185].type] && Main.tile[num184, num185].frameY == 0) ||
// for (var num185 = num182; num185 < num183; num185++) Main.tile[num184, num185].liquid > 64))
// if (Main.tile[num184, num185] != null && {
// (Main.tile[num184, num185].nactive() && Vector2 vector17;
// (Main.tileSolid[Main.tile[num184, num185].type] || vector17.X = num184 * 16;
// Main.tileSolidTop[Main.tile[num184, num185].type] && Main.tile[num184, num185].frameY == 0) || vector17.Y = num185 * 16;
// Main.tile[num184, num185].liquid > 64)) if (projectile.position.X + projectile.width > vector17.X &&
// { projectile.position.X < vector17.X + 16f &&
// Vector2 vector17; projectile.position.Y + projectile.height > vector17.Y &&
// vector17.X = num184 * 16; projectile.position.Y < vector17.Y + 16f)
// vector17.Y = num185 * 16; {
// if (projectile.position.X + projectile.width > vector17.X && flag18 = true;
// projectile.position.X < vector17.X + 16f && }
// projectile.position.Y + projectile.height > vector17.Y && }
// projectile.position.Y < vector17.Y + 16f)
// { if (!flag18 && Head)
// flag18 = true; {
// // if (Main.rand.NextBool(100) && projectile.behindTiles && var rectangle = new Rectangle((int) projectile.position.X, (int) projectile.position.Y,
// // Main.tile[num184, num185].nactive()) projectile.width, projectile.height);
// // WorldGen.KillTile(num184, num185, true, true); var num186 = 1000;
// if (Main.netMode != 1 && Main.tile[num184, num185].type == 2) var flag19 = true;
// { for (var num187 = 0; num187 < 255; num187++)
// var arg_BFCA_0 = Main.tile[num184, num185 - 1].type; if (Main.player[num187].active)
// } {
// } var rectangle2 = new Rectangle((int) Main.player[num187].position.X - num186,
// } (int) Main.player[num187].position.Y - num186, num186 * 2, num186 * 2);
// if (rectangle.Intersects(rectangle2))
// if (!flag18 && Head) {
// { flag19 = false;
// var rectangle = new Rectangle((int) projectile.position.X, (int) projectile.position.Y, break;
// projectile.width, projectile.height); }
// var num186 = 1000; }
// var flag19 = true;
// for (var num187 = 0; num187 < 255; num187++) if (flag19) flag18 = true;
// if (Main.player[num187].active) }
// {
// var rectangle2 = new Rectangle((int) Main.player[num187].position.X - num186, if (Directional)
// (int) Main.player[num187].position.Y - num186, num186 * 2, num186 * 2); {
// if (rectangle.Intersects(rectangle2)) if (projectile.velocity.X < 0f)
// { projectile.spriteDirection = 1;
// flag19 = false; else if (projectile.velocity.X > 0f) projectile.spriteDirection = -1;
// break; }
// }
// } var num188 = Speed;
// var num189 = TurnSpeed;
// if (flag19) flag18 = true; var vector18 = new Vector2(projectile.position.X + projectile.width * 0.5f,
// } projectile.position.Y + projectile.height * 0.5f);
// var num191 = target.position.X + target.width / 2f;
// if (Directional) var num192 = target.position.Y + target.height / 2f;
// {
// if (projectile.velocity.X < 0f) num191 = (int) (num191 / 16f) * 16;
// projectile.spriteDirection = 1; num192 = (int) (num192 / 16f) * 16;
// else if (projectile.velocity.X > 0f) projectile.spriteDirection = -1; vector18.X = (int) (vector18.X / 16f) * 16;
// } vector18.Y = (int) (vector18.Y / 16f) * 16;
// num191 -= vector18.X;
// var num188 = Speed; num192 -= vector18.Y;
// var num189 = TurnSpeed; var num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192);
// var vector18 = new Vector2(projectile.position.X + projectile.width * 0.5f, if (projectile.ai[1] > 0f && projectile.ai[1] < Main.projectile.Length)
// projectile.position.Y + projectile.height * 0.5f); {
// var num191 = Main.player[Target].position.X + Main.player[Target].width / 2; try
// var num192 = Main.player[Target].position.Y + Main.player[Target].height / 2; {
// num191 = (int) (num191 / 16f) * 16; vector18 = new Vector2(projectile.position.X + projectile.width * 0.5f,
// num192 = (int) (num192 / 16f) * 16; projectile.position.Y + projectile.height * 0.5f);
// vector18.X = (int) (vector18.X / 16f) * 16; num191 = Main.projectile[(int) projectile.ai[1]].position.X +
// vector18.Y = (int) (vector18.Y / 16f) * 16; Main.projectile[(int) projectile.ai[1]].width / 2 -
// num191 -= vector18.X; vector18.X;
// num192 -= vector18.Y; num192 = Main.projectile[(int) projectile.ai[1]].position.Y +
// var num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192); Main.projectile[(int) projectile.ai[1]].height / 2 -
// if (projectile.ai[1] > 0f && projectile.ai[1] < Main.projectile.Length) vector18.Y;
// { }
// try catch
// { {
// vector18 = new Vector2(projectile.position.X + projectile.width * 0.5f, }
// projectile.position.Y + projectile.height * 0.5f);
// num191 = Main.projectile[(int) projectile.ai[1]].position.X + projectile.rotation = (float) Math.Atan2(num192, num191) + 1.57f;
// Main.projectile[(int) projectile.ai[1]].width / 2 - num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192);
// vector18.X; int num194 = projectile.width;
// num192 = Main.projectile[(int) projectile.ai[1]].position.Y + num193 = (num193 - num194) / num193;
// Main.projectile[(int) projectile.ai[1]].height / 2 - num191 *= num193;
// vector18.Y; num192 *= num193;
// } projectile.velocity = Vector2.Zero;
// catch projectile.position.X = projectile.position.X + num191;
// { projectile.position.Y = projectile.position.Y + num192;
// } if (Directional)
// {
// projectile.rotation = (float) Math.Atan2(num192, num191) + 1.57f; if (num191 < 0f) projectile.spriteDirection = 1;
// num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192); if (num191 > 0f) projectile.spriteDirection = -1;
// int num194 = projectile.width; }
// num193 = (num193 - num194) / num193; }
// num191 *= num193; else
// num192 *= num193; {
// projectile.velocity = Vector2.Zero; if (!flag18)
// projectile.position.X = projectile.position.X + num191; {
// projectile.position.Y = projectile.position.Y + num192; TargetClosest();
// if (Directional) projectile.velocity.Y = projectile.velocity.Y + 0.11f;
// { if (projectile.velocity.Y > num188) projectile.velocity.Y = num188;
// if (num191 < 0f) projectile.spriteDirection = 1; if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188 * 0.4)
// if (num191 > 0f) projectile.spriteDirection = -1; {
// } if (projectile.velocity.X < 0f)
// } projectile.velocity.X = projectile.velocity.X - num189 * 1.1f;
// else else
// { projectile.velocity.X = projectile.velocity.X + num189 * 1.1f;
// if (!flag18) }
// { else if (projectile.velocity.Y == num188)
// TargetClosest(); {
// projectile.velocity.Y = projectile.velocity.Y + 0.11f; if (projectile.velocity.X < num191)
// if (projectile.velocity.Y > num188) projectile.velocity.Y = num188; projectile.velocity.X = projectile.velocity.X + num189;
// if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188 * 0.4) else if (projectile.velocity.X > num191) projectile.velocity.X = projectile.velocity.X - num189;
// { }
// if (projectile.velocity.X < 0f) else if (projectile.velocity.Y > 4f)
// projectile.velocity.X = projectile.velocity.X - num189 * 1.1f; {
// else if (projectile.velocity.X < 0f)
// projectile.velocity.X = projectile.velocity.X + num189 * 1.1f; projectile.velocity.X = projectile.velocity.X + num189 * 0.9f;
// } else
// else if (projectile.velocity.Y == num188) projectile.velocity.X = projectile.velocity.X - num189 * 0.9f;
// { }
// if (projectile.velocity.X < num191) }
// projectile.velocity.X = projectile.velocity.X + num189; else
// else if (projectile.velocity.X > num191) projectile.velocity.X = projectile.velocity.X - num189; {
// }
// else if (projectile.velocity.Y > 4f)
// {
// if (projectile.velocity.X < 0f)
// projectile.velocity.X = projectile.velocity.X + num189 * 0.9f;
// else
// projectile.velocity.X = projectile.velocity.X - num189 * 0.9f;
// }
// }
// else
// {
// if (!Flies && projectile.BehindTiles() && projectile.soundDelay == 0) // if (!Flies && projectile.BehindTiles() && projectile.soundDelay == 0)
// if (Main.netMode != NetmodeID.MultiplayerClient) // if (Main.netMode != NetmodeID.MultiplayerClient)
// { // {
// projectile.soundDelay = 120; // projectile.soundDelay = 120;
//
// Main.PlaySound(undergroundSound, projectile.position); // Main.PlaySound(undergroundSound, projectile.position);
// if (Main.netMode == NetmodeID.Server) SendSoundPacket(); // if (Main.netMode == NetmodeID.Server) SendSoundPacket();
// } // }
//
// num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192); num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192);
// var num196 = Math.Abs(num191); var num196 = Math.Abs(num191);
// var num197 = Math.Abs(num192); var num197 = Math.Abs(num192);
// var num198 = num188 / num193; var num198 = num188 / num193;
// num191 *= num198; num191 *= num198;
// num192 *= num198; num192 *= num198;
// if (ShouldRun()) if (ShouldRun())
// { {
// if (Main.netMode != 1 && if (Main.netMode != 1 &&
// projectile.position.Y / 16f > (Main.rockLayer + Main.maxTilesY) / 2.0) projectile.position.Y / 16f > (Main.rockLayer + Main.maxTilesY) / 2.0)
// { {
// projectile.active = false; projectile.active = false;
// var num200 = (int) projectile.ai[0]; var num200 = (int) projectile.ai[0];
// while (num200 > 0 && num200 < 200 && Main.projectile[num200].active && while (num200 > 0 && num200 < 200 && Main.projectile[num200].active &&
// Main.projectile[num200].aiStyle == projectile.aiStyle) Main.projectile[num200].aiStyle == projectile.aiStyle)
// { {
// var num201 = (int) Main.projectile[num200].ai[0]; var num201 = (int) Main.projectile[num200].ai[0];
// Main.projectile[num200].active = false; Main.projectile[num200].active = false;
// projectile.life = 0; // projectile.life = 0;
// if (Main.netMode == 2) NetMessage.SendData(23, -1, -1, null, num200); if (Main.netMode == 2) NetMessage.SendData(23, -1, -1, null, num200);
// num200 = num201; num200 = num201;
// } }
//
// if (Main.netMode == 2) NetMessage.SendData(23, -1, -1, null, projectile.whoAmI); if (Main.netMode == 2) NetMessage.SendData(23, -1, -1, null, projectile.whoAmI);
// } }
//
// num191 = 0f; num191 = 0f;
// num192 = num188; num192 = num188;
// } }
//
// var flag21 = false; var flag21 = false;
// if (projectile.type == 87) if (projectile.type == 87)
// { {
// if ((projectile.velocity.X > 0f && num191 < 0f || projectile.velocity.X < 0f && num191 > 0f || if ((projectile.velocity.X > 0f && num191 < 0f || projectile.velocity.X < 0f && num191 > 0f ||
// projectile.velocity.Y > 0f && num192 < 0f || projectile.velocity.Y < 0f && num192 > 0f) && projectile.velocity.Y > 0f && num192 < 0f || projectile.velocity.Y < 0f && num192 > 0f) &&
// Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) > num189 / 2f && Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) > num189 / 2f &&
// num193 < 300f) num193 < 300f)
// { {
// flag21 = true; flag21 = true;
// if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188) if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188)
// projectile.velocity *= 1.1f; projectile.velocity *= 1.1f;
// } }
//
// if (projectile.position.Y > Main.player[Target].position.Y || if (projectile.position.Y > Main.npc[Target].position.Y ||
// Main.player[Target].position.Y / 16f > Main.worldSurface || Main.npc[Target].position.Y / 16f > Main.worldSurface ||
// Main.player[Target].dead) !Main.npc[Target].active)
// { {
// flag21 = true; flag21 = true;
// if (Math.Abs(projectile.velocity.X) < num188 / 2f) if (Math.Abs(projectile.velocity.X) < num188 / 2f)
// { {
// if (projectile.velocity.X == 0f) if (projectile.velocity.X == 0f)
// projectile.velocity.X = projectile.velocity.X - projectile.direction; projectile.velocity.X = projectile.velocity.X - projectile.direction;
// projectile.velocity.X = projectile.velocity.X * 1.1f; projectile.velocity.X = projectile.velocity.X * 1.1f;
// } }
// else else
// { {
// if (projectile.velocity.Y > -num188) if (projectile.velocity.Y > -num188)
// projectile.velocity.Y = projectile.velocity.Y - num189; projectile.velocity.Y = projectile.velocity.Y - num189;
// } }
// } }
// } }
//
// if (!flag21) if (!flag21)
// { {
// if (projectile.velocity.X > 0f && num191 > 0f || projectile.velocity.X < 0f && num191 < 0f || if (projectile.velocity.X > 0f && num191 > 0f || projectile.velocity.X < 0f && num191 < 0f ||
// projectile.velocity.Y > 0f && num192 > 0f || projectile.velocity.Y < 0f && num192 < 0f) projectile.velocity.Y > 0f && num192 > 0f || projectile.velocity.Y < 0f && num192 < 0f)
// { {
// if (projectile.velocity.X < num191) if (projectile.velocity.X < num191)
// { {
// projectile.velocity.X = projectile.velocity.X + num189; projectile.velocity.X = projectile.velocity.X + num189;
// } }
// else else
// { {
// if (projectile.velocity.X > num191) if (projectile.velocity.X > num191)
// projectile.velocity.X = projectile.velocity.X - num189; projectile.velocity.X = projectile.velocity.X - num189;
// } }
//
// if (projectile.velocity.Y < num192) if (projectile.velocity.Y < num192)
// { {
// projectile.velocity.Y = projectile.velocity.Y + num189; projectile.velocity.Y = projectile.velocity.Y + num189;
// } }
// else else
// { {
// if (projectile.velocity.Y > num192) if (projectile.velocity.Y > num192)
// projectile.velocity.Y = projectile.velocity.Y - num189; projectile.velocity.Y = projectile.velocity.Y - num189;
// } }
//
// if (Math.Abs(num192) < num188 * 0.2 && if (Math.Abs(num192) < num188 * 0.2 &&
// (projectile.velocity.X > 0f && num191 < 0f || (projectile.velocity.X > 0f && num191 < 0f ||
// projectile.velocity.X < 0f && num191 > 0f)) projectile.velocity.X < 0f && num191 > 0f))
// { {
// if (projectile.velocity.Y > 0f) if (projectile.velocity.Y > 0f)
// projectile.velocity.Y = projectile.velocity.Y + num189 * 2f; projectile.velocity.Y = projectile.velocity.Y + num189 * 2f;
// else else
// projectile.velocity.Y = projectile.velocity.Y - num189 * 2f; projectile.velocity.Y = projectile.velocity.Y - num189 * 2f;
// } }
//
// if (Math.Abs(num191) < num188 * 0.2 && if (Math.Abs(num191) < num188 * 0.2 &&
// (projectile.velocity.Y > 0f && num192 < 0f || (projectile.velocity.Y > 0f && num192 < 0f ||
// projectile.velocity.Y < 0f && num192 > 0f)) projectile.velocity.Y < 0f && num192 > 0f))
// { {
// if (projectile.velocity.X > 0f) if (projectile.velocity.X > 0f)
// projectile.velocity.X = projectile.velocity.X + num189 * 2f; projectile.velocity.X = projectile.velocity.X + num189 * 2f;
// else else
// projectile.velocity.X = projectile.velocity.X - num189 * 2f; projectile.velocity.X = projectile.velocity.X - num189 * 2f;
// } }
// } }
// else else
// { {
// if (num196 > num197) if (num196 > num197)
// { {
// if (projectile.velocity.X < num191) if (projectile.velocity.X < num191)
// projectile.velocity.X = projectile.velocity.X + num189 * 1.1f; projectile.velocity.X = projectile.velocity.X + num189 * 1.1f;
// else if (projectile.velocity.X > num191) else if (projectile.velocity.X > num191)
// projectile.velocity.X = projectile.velocity.X - num189 * 1.1f; projectile.velocity.X = projectile.velocity.X - num189 * 1.1f;
// if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188 * 0.5) if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188 * 0.5)
// { {
// if (projectile.velocity.Y > 0f) if (projectile.velocity.Y > 0f)
// projectile.velocity.Y = projectile.velocity.Y + num189; projectile.velocity.Y = projectile.velocity.Y + num189;
// else else
// projectile.velocity.Y = projectile.velocity.Y - num189; projectile.velocity.Y = projectile.velocity.Y - num189;
// } }
// } }
// else else
// { {
// if (projectile.velocity.Y < num192) if (projectile.velocity.Y < num192)
// projectile.velocity.Y = projectile.velocity.Y + num189 * 1.1f; projectile.velocity.Y = projectile.velocity.Y + num189 * 1.1f;
// else if (projectile.velocity.Y > num192) else if (projectile.velocity.Y > num192)
// projectile.velocity.Y = projectile.velocity.Y - num189 * 1.1f; projectile.velocity.Y = projectile.velocity.Y - num189 * 1.1f;
// if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188 * 0.5) if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < num188 * 0.5)
// { {
// if (projectile.velocity.X > 0f) if (projectile.velocity.X > 0f)
// projectile.velocity.X = projectile.velocity.X + num189; projectile.velocity.X = projectile.velocity.X + num189;
// else else
// projectile.velocity.X = projectile.velocity.X - num189; projectile.velocity.X = projectile.velocity.X - num189;
// } }
// } }
// } }
// } }
// } }
//
// projectile.rotation = (float) Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; projectile.rotation = (float) Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f;
// if (Head) if (Head)
// { {
// if (flag18) if (flag18)
// { {
// if (projectile.localAI[0] != 1f) projectile.netUpdate = true; if (projectile.localAI[0] != 1f) projectile.netUpdate = true;
// projectile.localAI[0] = 1f; projectile.localAI[0] = 1f;
// } }
// else else
// { {
// if (projectile.localAI[0] != 0f) projectile.netUpdate = true; if (projectile.localAI[0] != 0f) projectile.netUpdate = true;
// projectile.localAI[0] = 0f; projectile.localAI[0] = 0f;
// } }
//
// if ((projectile.velocity.X > 0f && projectile.oldVelocity.X < 0f || if ((projectile.velocity.X > 0f && projectile.oldVelocity.X < 0f ||
// projectile.velocity.X < 0f && projectile.oldVelocity.X > 0f || projectile.velocity.X < 0f && projectile.oldVelocity.X > 0f ||
// projectile.velocity.Y > 0f && projectile.oldVelocity.Y < 0f || projectile.velocity.Y > 0f && projectile.oldVelocity.Y < 0f ||
// projectile.velocity.Y < 0f && projectile.oldVelocity.Y > 0f) && !projectile.justHit) projectile.velocity.Y < 0f && projectile.oldVelocity.Y > 0f) /* && !projectile.justHit*/)
// { {
// projectile.netUpdate = true; projectile.netUpdate = true;
// return; return;
// } }
// } }
// } }
//
// CustomBehavior(); CustomBehavior();
// } }
//
// public virtual void Init() public virtual void InitWorm()
// { {
// } }
//
// public virtual bool ShouldRun() protected virtual void TargetClosest()
// { {
// return false; if (!Head) return;
// }
// Target = -1;
// public virtual void CustomBehavior() Player player13 = Main.player[projectile.owner];
// {
// } float num1105 = 700f;
// float num1106 = 1000f;
// public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
// { NPC ownerMinionAttackTargetNPC5 = projectile.OwnerMinionAttackTargetNPC;
// return Head ? (bool?) null : false; if (ownerMinionAttackTargetNPC5 != null && ownerMinionAttackTargetNPC5.CanBeChasedBy(this))
// } {
// float distance = projectile.Distance(ownerMinionAttackTargetNPC5.Center);
// protected void Draw(string texturePath, SpriteBatch spriteBatch, Color drawColor) if (distance < num1105 * 2f)
// { {
// var frameSize = new Vector2(projectile.width, projectile.height); Target = ownerMinionAttackTargetNPC5.whoAmI;
// var texture = mod.GetTexture(texturePath); }
// }
// spriteBatch.Draw
// ( if (Target < 0)
// texture, {
// new Vector2( for (int num1112 = 0; num1112 < 200; num1112++)
// projectile.position.X - Main.screenPosition.X + frameSize.X / 2, {
// projectile.position.Y - Main.screenPosition.Y + frameSize.Y / 2 NPC nPC15 = Main.npc[num1112];
// ), if (!nPC15.CanBeChasedBy(this) || !(player13.Distance(nPC15.Center) < num1106))
// projectile.frame, {
// drawColor, continue;
// projectile.rotation, }
// frameSize * 0.5f,
// projectile.scale, float num1113 = projectile.Distance(nPC15.Center);
// SpriteEffects.None, if (num1113 < num1105)
// 0f {
// ); Target = num1112;
// } }
// }
// protected abstract void SendSoundPacket(); }
}
public virtual bool ShouldRun()
{
return false;
}
public virtual void CustomBehavior()
{
}
protected void Draw(string texturePath, SpriteBatch spriteBatch, Color drawColor)
{
var frameSize = new Vector2(projectile.width, projectile.height);
var texture = mod.GetTexture(texturePath);
spriteBatch.Draw
(
texture,
new Vector2(
projectile.position.X - Main.screenPosition.X + frameSize.X / 2,
projectile.position.Y - Main.screenPosition.Y + frameSize.Y / 2
),
null,
drawColor,
projectile.rotation,
frameSize * 0.5f,
projectile.scale,
SpriteEffects.None,
0f
);
}
} }
} }

View File

@ -31,7 +31,7 @@ namespace Decimation.Lib.Util
int id = int.MinValue; int id = int.MinValue;
if (entityType == typeof(Item)) if (entityType == typeof(Item))
id = Mod.ItemType(name); id = Mod.ItemType(name);
else if (entityType == typeof(Projectile)) else if (entityType == typeof(Terraria.Projectile))
id = Mod.ProjectileType(name); id = Mod.ProjectileType(name);
else if (entityType == typeof(NPC)) id = Mod.NPCType(name); else if (entityType == typeof(NPC)) id = Mod.NPCType(name);
@ -50,7 +50,7 @@ namespace Decimation.Lib.Util
Type idType; Type idType;
if (entityType == typeof(Item)) if (entityType == typeof(Item))
idType = typeof(ItemID); idType = typeof(ItemID);
else if (entityType == typeof(Projectile)) else if (entityType == typeof(Terraria.Projectile))
idType = typeof(ProjectileID); idType = typeof(ProjectileID);
else if (entityType == typeof(NPCID)) else if (entityType == typeof(NPCID))
idType = typeof(NPCID); idType = typeof(NPCID);

View File

@ -1,12 +0,0 @@
using Terraria;
namespace Decimation.Lib.Util
{
public static class ProjectileUtils
{
public static bool BehindTiles(this Projectile projectile)
{
return Main.tile[(int) projectile.position.X, (int) projectile.position.Y].type == -1; // TODO ?
}
}
}