Networking stuff for the Dune Wyrm.
Changed Crystal Skull and Red Hot Shackle's sprites
This commit is contained in:
parent
16b387b796
commit
15d2947c33
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Decimation.Content.NPCs.Arachnus;
|
||||
using Decimation.Content.NPCs.DuneWyrm;
|
||||
using Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler;
|
||||
using Decimation.Content.UI;
|
||||
using Decimation.Lib.Util;
|
||||
using Microsoft.Xna.Framework;
|
||||
@ -15,8 +16,6 @@ namespace Decimation.Content
|
||||
{
|
||||
public class Decimation : Mod
|
||||
{
|
||||
public static Decimation Instance { set; get; }
|
||||
|
||||
public static AmuletSlotState amuletSlotState;
|
||||
private UserInterface amuletSlotInterface;
|
||||
|
||||
@ -26,7 +25,7 @@ namespace Decimation.Content
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
Properties = new ModProperties()
|
||||
Properties = new ModProperties
|
||||
{
|
||||
Autoload = true,
|
||||
AutoloadGores = true,
|
||||
@ -36,6 +35,8 @@ namespace Decimation.Content
|
||||
References.mod = this;
|
||||
}
|
||||
|
||||
public static Decimation Instance { set; get; }
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
@ -104,22 +105,11 @@ namespace Decimation.Content
|
||||
|
||||
public override void AddRecipeGroups()
|
||||
{
|
||||
RecipeGroup gems = new RecipeGroup(() => Lang.misc[37] + " Gem", new int[]
|
||||
{
|
||||
ItemID.Amethyst,
|
||||
ItemID.Topaz,
|
||||
ItemID.Emerald,
|
||||
ItemID.Sapphire,
|
||||
ItemID.Ruby,
|
||||
ItemID.Diamond,
|
||||
});
|
||||
RecipeGroup gems = new RecipeGroup(() => Lang.misc[37] + " Gem", ItemID.Amethyst, ItemID.Topaz,
|
||||
ItemID.Emerald, ItemID.Sapphire, ItemID.Ruby, ItemID.Diamond);
|
||||
|
||||
RecipeGroup threads = new RecipeGroup(() => Lang.misc[37] + " Thread", new int[]
|
||||
{
|
||||
ItemID.BlackThread,
|
||||
ItemID.GreenThread,
|
||||
ItemID.PinkThread
|
||||
});
|
||||
RecipeGroup threads = new RecipeGroup(() => Lang.misc[37] + " Thread", ItemID.BlackThread,
|
||||
ItemID.GreenThread, ItemID.PinkThread);
|
||||
|
||||
RecipeGroup.RegisterGroup("AnyGem", gems);
|
||||
RecipeGroup.RegisterGroup("AnyThread", threads);
|
||||
@ -133,20 +123,15 @@ namespace Decimation.Content
|
||||
{
|
||||
case DecimationModMessageType.Arachnus:
|
||||
Arachnus arachnus = (Arachnus) Main.npc[reader.ReadInt32()].modNPC;
|
||||
if (arachnus != null && arachnus.npc.active)
|
||||
{
|
||||
arachnus.HandlePacket(reader);
|
||||
}
|
||||
|
||||
if (arachnus != null && arachnus.npc.active) arachnus.HandlePacket(reader);
|
||||
break;
|
||||
case DecimationModMessageType.DuneWorm:
|
||||
case DecimationModMessageType.DuneWyrm:
|
||||
DuneWyrmHead duneWyrm = (DuneWyrmHead) Main.npc[reader.ReadInt32()].modNPC;
|
||||
if (duneWyrm != null && duneWyrm.npc.active)
|
||||
{
|
||||
// TODO multiplayer
|
||||
// duneWyrm.HandlePacket(reader);
|
||||
}
|
||||
|
||||
if (duneWyrm != null && duneWyrm.npc.active) duneWyrm.HandlePacket(reader);
|
||||
break;
|
||||
case DecimationModMessageType.AncientTombCrawler:
|
||||
AncientTombCrawler tombCrawler = (AncientTombCrawler) Main.npc[reader.ReadInt32()].modNPC;
|
||||
if (tombCrawler != null && tombCrawler.npc.active) tombCrawler.HandlePacket(reader);
|
||||
break;
|
||||
case DecimationModMessageType.SpawnBoss:
|
||||
int type = reader.ReadInt32();
|
||||
@ -155,17 +140,15 @@ namespace Decimation.Content
|
||||
if (Main.netMode != 1)
|
||||
NPC.SpawnOnPlayer(player, type);
|
||||
break;
|
||||
default:
|
||||
ErrorLogger.Log("DecimationMod: Unknown Message type: " + msgType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum DecimationModMessageType : byte
|
||||
internal enum DecimationModMessageType : byte
|
||||
{
|
||||
Arachnus,
|
||||
DuneWorm,
|
||||
DuneWyrm,
|
||||
AncientTombCrawler,
|
||||
SpawnBoss
|
||||
}
|
||||
}
|
||||
@ -15,11 +15,11 @@ namespace Decimation.Content.Items.Accessories
|
||||
|
||||
protected override void InitAccessory()
|
||||
{
|
||||
item.width = 24;
|
||||
item.height = 24;
|
||||
item.width = 35;
|
||||
item.height = 22;
|
||||
item.rare = Rarity.Green.GetRarityValue();
|
||||
this.item.value = Item.buyPrice(0, 0, 0, 10);
|
||||
this.item.defense = 2;
|
||||
item.value = Item.buyPrice(0, 0, 0, 10);
|
||||
item.defense = 2;
|
||||
}
|
||||
|
||||
protected override List<ModRecipe> GetAdditionalRecipes()
|
||||
@ -39,7 +39,5 @@ namespace Decimation.Content.Items.Accessories
|
||||
player.AddBuff(BuffID.Thorns, 1);
|
||||
Lighting.AddLight(player.Center, new Vector3(0.9f * 0.6f, 0.9f * 0.1f, 0.9f));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 549 B |
@ -23,6 +23,7 @@ namespace Decimation.Content.Items.Accessories
|
||||
item.value = Item.buyPrice(0, 0, 2);
|
||||
item.defense = 1;
|
||||
}
|
||||
|
||||
protected override List<ModRecipe> GetAdditionalRecipes()
|
||||
{
|
||||
ModRecipe recipe = GetNewModRecipe(this, 1, new List<int>() { TileID.Furnaces }, true);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 315 B After Width: | Height: | Size: 381 B |
@ -87,6 +87,7 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
{
|
||||
move *= speed / magnitude;
|
||||
}
|
||||
|
||||
float turnResistance = 50f;
|
||||
move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
|
||||
magnitude = (float) Math.Sqrt(move.X * move.X + move.Y * move.Y);
|
||||
@ -110,11 +111,17 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
{
|
||||
if (i >= 0 && i <= Main.maxTilesX && j >= 0 && j <= Main.maxTilesY)
|
||||
{
|
||||
if (Main.tile[i, j].type == ModContent.TileType<ShrineBrick>() || (Main.tile[i, j].type == ModContent.TileType<LockedShrineDoor>() || Main.tile[i, j].type == ModContent.TileType<ShrineDoorClosed>() || Main.tile[i, j].type == ModContent.TileType<ShrineDoorOpened>()) || Main.tile[i, j].type == ModContent.TileType<RedHotSpike>() || Main.tile[i, j].type == ModContent.TileType<ShrineAltar>())
|
||||
if (Main.tile[i, j].type == ModContent.TileType<ShrineBrick>() ||
|
||||
(Main.tile[i, j].type == ModContent.TileType<LockedShrineDoor>() ||
|
||||
Main.tile[i, j].type == ModContent.TileType<ShrineDoorClosed>() ||
|
||||
Main.tile[i, j].type == ModContent.TileType<ShrineDoorOpened>()) ||
|
||||
Main.tile[i, j].type == ModContent.TileType<RedHotSpike>() ||
|
||||
Main.tile[i, j].type == ModContent.TileType<ShrineAltar>())
|
||||
validBlockCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (validBlockCount < 15)
|
||||
tooFarFromShrine = true;
|
||||
else
|
||||
@ -130,7 +137,10 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
|
||||
private void CheckEnraged()
|
||||
{
|
||||
npc.ai[2] = !Main.player[npc.target].ZoneUnderworldHeight || !Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || CheckForShrine() ? 1 : 0;
|
||||
npc.ai[2] = !Main.player[npc.target].ZoneUnderworldHeight ||
|
||||
!Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || CheckForShrine()
|
||||
? 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
@ -172,14 +182,16 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
npc.ai[1] = 1;
|
||||
}
|
||||
// Increase speed
|
||||
else if (counter > 1320 && counter <= 1500 || (Main.expertMode && counter > 600 && counter < 800 && npc.life <= npc.lifeMax / 4))
|
||||
else if (counter > 1320 && counter <= 1500 ||
|
||||
(Main.expertMode && counter > 600 && counter < 800 && npc.life <= npc.lifeMax / 4))
|
||||
{
|
||||
if (counter == 1321)
|
||||
{
|
||||
if (Main.netMode == NetmodeID.SinglePlayer)
|
||||
Main.PlaySound(SoundID.Roar, (int) npc.position.X, (int) npc.position.Y, 0);
|
||||
if (Main.netMode == 2)
|
||||
GetPacket(ArachnusMessageType.RoarSound).Send();
|
||||
if (Main.netMode == NetmodeID.Server) GetPacket(ArachnusMessageType.RoarSound).Send();
|
||||
}
|
||||
|
||||
npc.ai[1] = 2;
|
||||
}
|
||||
else npc.ai[1] = 99;
|
||||
@ -188,7 +200,8 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
{
|
||||
float speedX = (float) (6 * Math.Cos(npc.rotation - Math.PI * 0.5f)) * 2;
|
||||
float speedY = (float) (6 * Math.Sin(npc.rotation - Math.PI * 0.5f)) * 2;
|
||||
Projectile.NewProjectile(new Vector2(mouthX, mouthY), new Vector2(speedX, speedY), ModContent.ProjectileType<ArachnusFireball>(), 30, 0f);
|
||||
Projectile.NewProjectile(new Vector2(mouthX, mouthY), new Vector2(speedX, speedY),
|
||||
ModContent.ProjectileType<ArachnusFireball>(), 30, 0f);
|
||||
}
|
||||
else if (counter % 5 == 0 && npc.ai[1] == 1)
|
||||
{
|
||||
@ -196,8 +209,12 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
{
|
||||
float speedX = (float) (7 * Math.Cos(npc.rotation - Math.PI * 0.5f));
|
||||
float speedY = (float) (7 * Math.Sin(npc.rotation - Math.PI * 0.5f));
|
||||
Projectile.NewProjectile(new Vector2(mouthX, mouthY), new Vector2(speedX, speedY), npc.ai[2] == 1 ? ModContent.ProjectileType<BlastofShadowFlame>() : ModContent.ProjectileType<BlastofHeat>(), 30, 0f, 255);
|
||||
Projectile.NewProjectile(new Vector2(mouthX, mouthY), new Vector2(speedX, speedY),
|
||||
npc.ai[2] == 1
|
||||
? ModContent.ProjectileType<BlastofShadowFlame>()
|
||||
: ModContent.ProjectileType<BlastofHeat>(), 30, 0f, 255);
|
||||
}
|
||||
|
||||
Main.PlaySound(SoundID.Item34, npc.position);
|
||||
if (Main.netMode == 2)
|
||||
GetPacket(ArachnusMessageType.FlamesSound).Send();
|
||||
@ -245,6 +262,7 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
writer.Write(counterMax);
|
||||
writer.Write(speed);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
counter = reader.ReadInt32();
|
||||
@ -260,6 +278,7 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
packet.Write((byte) type);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void HandlePacket(BinaryReader reader)
|
||||
{
|
||||
ArachnusMessageType type = (ArachnusMessageType) reader.ReadByte();
|
||||
@ -280,6 +299,7 @@ namespace Decimation.Content.NPCs.Arachnus
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<Hyperthermic>(), 900);
|
||||
}
|
||||
|
||||
base.OnHitPlayer(target, damage, crit);
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System.IO;
|
||||
using Decimation.Content.Items.Misc.Souls;
|
||||
using Decimation.Lib.NPCs;
|
||||
using Microsoft.Xna.Framework;
|
||||
@ -142,5 +143,35 @@ namespace Decimation.Content.NPCs.DuneWyrm.AncientTombCrawler
|
||||
npc.HitSound = SoundID.NPCHit1;
|
||||
undergroundSound = mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Earthquake");
|
||||
}
|
||||
|
||||
protected override void SendSoundPacket()
|
||||
{
|
||||
GetPacket(AncientTombCrawlerMessageType.UndergroundSound).Send();
|
||||
}
|
||||
|
||||
private ModPacket GetPacket(AncientTombCrawlerMessageType type)
|
||||
{
|
||||
ModPacket packet = mod.GetPacket();
|
||||
packet.Write((byte) DecimationModMessageType.AncientTombCrawler);
|
||||
packet.Write(npc.whoAmI);
|
||||
packet.Write((byte) type);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void HandlePacket(BinaryReader reader)
|
||||
{
|
||||
AncientTombCrawlerMessageType type = (AncientTombCrawlerMessageType) reader.ReadByte();
|
||||
switch (type)
|
||||
{
|
||||
case AncientTombCrawlerMessageType.UndergroundSound:
|
||||
Main.PlaySound(undergroundSound, npc.Center);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum AncientTombCrawlerMessageType
|
||||
{
|
||||
UndergroundSound
|
||||
}
|
||||
}
|
||||
@ -15,7 +15,6 @@ namespace Decimation.Content.NPCs.DuneWyrm
|
||||
[AutoloadBossHead]
|
||||
internal class DuneWyrmHead : DuneWyrm
|
||||
{
|
||||
private int _attackCounter;
|
||||
private int _previousTile = -1;
|
||||
private bool _spawnedAncientTombCrawler;
|
||||
|
||||
@ -65,12 +64,14 @@ namespace Decimation.Content.NPCs.DuneWyrm
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(_attackCounter);
|
||||
writer.Write(_previousTile);
|
||||
writer.Write(_spawnedAncientTombCrawler);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
_attackCounter = reader.ReadInt32();
|
||||
_previousTile = reader.ReadInt32();
|
||||
_spawnedAncientTombCrawler = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public override void CustomBehavior()
|
||||
@ -289,5 +290,35 @@ namespace Decimation.Content.NPCs.DuneWyrm
|
||||
npc.HitSound = SoundID.NPCHit1;
|
||||
undergroundSound = mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Earthquake");
|
||||
}
|
||||
|
||||
protected override void SendSoundPacket()
|
||||
{
|
||||
GetPacket(DuneWyrmMessageType.UndergroundSound).Send();
|
||||
}
|
||||
|
||||
private ModPacket GetPacket(DuneWyrmMessageType type)
|
||||
{
|
||||
ModPacket packet = mod.GetPacket();
|
||||
packet.Write((byte) DecimationModMessageType.DuneWyrm);
|
||||
packet.Write(npc.whoAmI);
|
||||
packet.Write((byte) type);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void HandlePacket(BinaryReader reader)
|
||||
{
|
||||
DuneWyrmMessageType type = (DuneWyrmMessageType) reader.ReadByte();
|
||||
switch (type)
|
||||
{
|
||||
case DuneWyrmMessageType.UndergroundSound:
|
||||
Main.PlaySound(undergroundSound, npc.Center);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum DuneWyrmMessageType
|
||||
{
|
||||
UndergroundSound
|
||||
}
|
||||
}
|
||||
@ -6,12 +6,12 @@ namespace Decimation.Content.Projectiles
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
this.projectile.CloneDefaults(ProjectileID.SpikyBall);
|
||||
this.projectile.damage = 30;
|
||||
this.projectile.width = 10;
|
||||
this.projectile.height = 16;
|
||||
this.projectile.friendly = false;
|
||||
this.projectile.hostile = true;
|
||||
projectile.CloneDefaults(ProjectileID.SpikyBall);
|
||||
projectile.damage = 30;
|
||||
projectile.width = 36;
|
||||
projectile.height = 32;
|
||||
projectile.friendly = false;
|
||||
projectile.hostile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 534 B |
@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace Decimation.Lib.NPCs
|
||||
@ -232,9 +233,14 @@ namespace Decimation.Lib.NPCs
|
||||
else
|
||||
{
|
||||
if (!flies && npc.behindTiles && npc.soundDelay == 0)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
npc.soundDelay = 120;
|
||||
|
||||
Main.PlaySound(undergroundSound, npc.position);
|
||||
if(Main.netMode == NetmodeID.Server) SendSoundPacket();
|
||||
}
|
||||
}
|
||||
|
||||
num193 = (float) Math.Sqrt(num191 * num191 + num192 * num192);
|
||||
@ -440,5 +446,7 @@ namespace Decimation.Lib.NPCs
|
||||
0f
|
||||
);
|
||||
}
|
||||
|
||||
protected abstract void SendSoundPacket();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user