2 - Buffed DSA and DoG Lore by reducing the incrased damage taken. DSA went from 25% to 15% and DoG Lore went from 10% to 5%. 3 - Reduced Affliction damage boost by 2%. 4 - Trinket of Chi now gives its buff in 1 second instead of 2 seconds. 5 - Alchemical Flask and Plague Hive now disable the Plague debuff darkness effect. 6 - Increased Yharim's Insignia melee damage boost by 5%. 7 - Bloodworms have an increased chance to spawn and only spawn after the player has met the Old Duke at the end of the Acid Rain Tier 3. 8 - Amalgamated Brain damage boost decreased by 2% and the shade rain now triggers every 6 frames instead of at random. 9 - Void of Calamity now reduces damage reduction by 10% instead of 15% and the flames now rain down every 10 frames instead of at random. 10 - Heart of the Elements now boosts damage by 5% instead of 8% (7% if boobs are disabled). 11 - Rotten Brain now rains shade every 6 frames instead of at random. 12 - Amalgamated and Rotten Brain and Amalgam shade rain no longer penetrate. 13 - Samurai Badge downside removed. 14 - The Amalgam now rains shade and fire every 8 frames instead of at random. 15 - Void of Extinction rains fire down every 10 frames instead of at random. 16 - Removed Badge of Bravery from Yharim's Insignia recipe and Yharim's Insignia now takes Divine Geodes to craft. 17 - Buffed Galactus Blade damage by 25. 18 - Reduced Luxor's Gift projectile damage scaling values, the caps are still the same. 19 - Reduced Astrum Aureus HP by about 12.5%. 20 - Ceaseless Void Dark Energies now spread out. 21 - Desert Scourge out of desert enrage is more noticeable. 22 - DoG phase 1 and 2, Destroyer, Astrum Deus and Cosmic Guardians greatly increase speed when far away from their target. 23 - Hive Mind Hive Blobs die immediately when phase 1 dies. 24 - Leviathan and Anahita enrage is more noticeable. 25 - Plaguebringer Goliath Mines emit some light. 26 - Polter Clone turns invisible, aside from its glowmask, when it's lining up for its charge to convey that it doesn't deal contact damage. 27 - Ravager Flame Pillars spawn further away from the player. 28 - Detached Ravager Head stays further away from the player. 29 - SCal brothers move up and down more quickly. 30 - Cal Clone enrage is more noticeable. 31 - Astrum Aureus enrage is more noticeable. 32 - Made Eye of Cthulhu, Brain of Cthulhu, Twins and Eater of Worlds enrages more noticeable. 33 - Fixed Destroyer coiling issue. 34 - Destroyer changes color to purple during flight phase. 35 - Skeletron Prime rockets are slower. 36 - Moon Lord Phantasmal Eyes spawn slower and have a lower max velocity. 37 - Reduced damage of post-DoG moon enemies, post-Yharon eclipse enemies and post-ML dungeon enemies. 38 - Reduced many Cal Clone and Brimstone Elemental projectile-inflicted debuff durations. 39 - Cryogen projectiles turn blue during daytime. 40 - Made Ravager homing laser things hopefully more visible. 41 - Aegis Blade, Grand Guardian and Lion Heart true melee explosions deal less damage on each subsequent hit. 42 - Brimlash split projectiles home in quicker. 43 - Omage Biome Blade projectiles have less range. 44 - Death Mode Astral shader intensity reduced. 45 - Brimtone Elemental beam darts have larger gaps between them and now collide with tiles.
320 lines
15 KiB
C#
320 lines
15 KiB
C#
using CalamityMod.Events;
|
|
using CalamityMod.NPCs;
|
|
using CalamityMod.NPCs.NormalNPCs;
|
|
using CalamityMod.NPCs.OldDuke;
|
|
using CalamityMod.NPCs.Providence;
|
|
using CalamityMod.TileEntities;
|
|
using CalamityMod.World;
|
|
using System;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod
|
|
{
|
|
public class CalamityNetcode
|
|
{
|
|
public static void HandlePacket(Mod mod, BinaryReader reader, int whoAmI)
|
|
{
|
|
try
|
|
{
|
|
CalamityModMessageType msgType = (CalamityModMessageType)reader.ReadByte();
|
|
switch (msgType)
|
|
{
|
|
case CalamityModMessageType.MeleeLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleLevels(reader, 0);
|
|
break;
|
|
case CalamityModMessageType.RangedLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleLevels(reader, 1);
|
|
break;
|
|
case CalamityModMessageType.MagicLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleLevels(reader, 2);
|
|
break;
|
|
case CalamityModMessageType.SummonLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleLevels(reader, 3);
|
|
break;
|
|
case CalamityModMessageType.RogueLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleLevels(reader, 4);
|
|
break;
|
|
case CalamityModMessageType.ExactMeleeLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleExactLevels(reader, 0);
|
|
break;
|
|
case CalamityModMessageType.ExactRangedLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleExactLevels(reader, 1);
|
|
break;
|
|
case CalamityModMessageType.ExactMagicLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleExactLevels(reader, 2);
|
|
break;
|
|
case CalamityModMessageType.ExactSummonLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleExactLevels(reader, 3);
|
|
break;
|
|
case CalamityModMessageType.ExactRogueLevelSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleExactLevels(reader, 4);
|
|
break;
|
|
case CalamityModMessageType.StressSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleStress(reader);
|
|
break;
|
|
case CalamityModMessageType.BossRushStage:
|
|
int stage = reader.ReadInt32();
|
|
BossRushEvent.BossRushStage = stage;
|
|
break;
|
|
case CalamityModMessageType.AdrenalineSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleAdrenaline(reader);
|
|
break;
|
|
case CalamityModMessageType.TeleportPlayer:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleTeleport(reader.ReadInt32(), true, whoAmI);
|
|
break;
|
|
case CalamityModMessageType.DoGCountdownSync:
|
|
int countdown = reader.ReadInt32();
|
|
CalamityWorld.DoGSecondStageCountdown = countdown;
|
|
break;
|
|
case CalamityModMessageType.BossSpawnCountdownSync:
|
|
int countdown2 = reader.ReadInt32();
|
|
CalamityWorld.bossSpawnCountdown = countdown2;
|
|
break;
|
|
case CalamityModMessageType.BRHostileProjKillSync:
|
|
int countdown3 = reader.ReadInt32();
|
|
CalamityWorld.bossRushHostileProjKillCounter = countdown3;
|
|
break;
|
|
case CalamityModMessageType.DeathBossSpawnCountdownSync:
|
|
int countdown4 = reader.ReadInt32();
|
|
CalamityWorld.deathBossSpawnCooldown = countdown4;
|
|
break;
|
|
case CalamityModMessageType.ArmoredDiggerCountdownSync:
|
|
int countdown5 = reader.ReadInt32();
|
|
CalamityWorld.ArmoredDiggerSpawnCooldown = countdown5;
|
|
break;
|
|
case CalamityModMessageType.BossTypeSync:
|
|
int type = reader.ReadInt32();
|
|
CalamityWorld.bossType = type;
|
|
break;
|
|
case CalamityModMessageType.DeathCountSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleDeathCount(reader);
|
|
break;
|
|
case CalamityModMessageType.DeathModeUnderworldTimeSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleDeathModeUnderworldTime(reader);
|
|
break;
|
|
case CalamityModMessageType.DeathModeBlizzardTimeSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleDeathModeBlizzardTime(reader);
|
|
break;
|
|
case CalamityModMessageType.RevengeanceBoolSync:
|
|
bool revActive = reader.ReadBoolean();
|
|
CalamityWorld.revenge = revActive;
|
|
break;
|
|
case CalamityModMessageType.DeathBoolSync:
|
|
bool deathActive = reader.ReadBoolean();
|
|
CalamityWorld.death = deathActive;
|
|
break;
|
|
case CalamityModMessageType.DefiledBoolSync:
|
|
bool defiledActive = reader.ReadBoolean();
|
|
CalamityWorld.defiled = defiledActive;
|
|
break;
|
|
case CalamityModMessageType.IronHeartBoolSync:
|
|
bool ironHeartActive = reader.ReadBoolean();
|
|
CalamityWorld.ironHeart = ironHeartActive;
|
|
break;
|
|
case CalamityModMessageType.ArmageddonBoolSync:
|
|
bool armaActive = reader.ReadBoolean();
|
|
CalamityWorld.armageddon = armaActive;
|
|
break;
|
|
case CalamityModMessageType.DemonTrophyBoolSync:
|
|
bool demonModeBoost = reader.ReadBoolean();
|
|
CalamityWorld.demonMode = demonModeBoost;
|
|
break;
|
|
case CalamityModMessageType.NPCRegenerationSync:
|
|
byte npcIndex = reader.ReadByte();
|
|
Main.npc[npcIndex].lifeRegen = reader.ReadInt32();
|
|
break;
|
|
case CalamityModMessageType.AcidRainSync:
|
|
CalamityWorld.rainingAcid = reader.ReadBoolean();
|
|
CalamityWorld.acidRainPoints = reader.ReadInt32();
|
|
CalamityWorld.timeSinceAcidRainKill = reader.ReadInt32();
|
|
break;
|
|
case CalamityModMessageType.AcidRainUIDrawFadeSync:
|
|
CalamityWorld.acidRainExtraDrawTime = reader.ReadInt32();
|
|
break;
|
|
case CalamityModMessageType.AcidRainOldDukeSummonSync:
|
|
CalamityWorld.triedToSummonOldDuke = reader.ReadBoolean();
|
|
break;
|
|
case CalamityModMessageType.EncounteredOldDukeSync:
|
|
CalamityWorld.encounteredOldDuke = reader.ReadBoolean();
|
|
break;
|
|
case CalamityModMessageType.GaelsGreatswordSwingSync:
|
|
byte playerIndex = reader.ReadByte();
|
|
Main.player[playerIndex].Calamity().gaelSwipes = reader.ReadInt32();
|
|
break;
|
|
case CalamityModMessageType.SpawnSuperDummy:
|
|
int x = reader.ReadInt32();
|
|
int y = reader.ReadInt32();
|
|
// Not strictly necessary, but helps prevent unnecessary packetstorm in MP
|
|
if (Main.netMode != NetmodeID.MultiplayerClient)
|
|
NPC.NewNPC(x, y, ModContent.NPCType<SuperDummyNPC>());
|
|
break;
|
|
|
|
|
|
//
|
|
// Ozzatron's packets
|
|
//
|
|
case CalamityModMessageType.PowerCellFactory:
|
|
TEPowerCellFactory.ReadSyncPacket(mod, reader);
|
|
break;
|
|
case CalamityModMessageType.ChargingStationStandard:
|
|
TEChargingStation.ReadSyncPacket(mod, reader);
|
|
break;
|
|
case CalamityModMessageType.ChargingStationItemChange:
|
|
TEChargingStation.ReadItemSyncPacket(mod, reader);
|
|
break;
|
|
case CalamityModMessageType.Turret:
|
|
TEBaseTurret.ReadSyncPacket(mod, reader);
|
|
break;
|
|
case CalamityModMessageType.LabHologramProjector:
|
|
TELabHologramProjector.ReadSyncPacket(mod, reader);
|
|
break;
|
|
// This code has been edited to fail gracefully when trying to provide data for an invalid NPC.
|
|
case CalamityModMessageType.SyncCalamityNPCAIArray:
|
|
// Read the entire packet regardless of anything
|
|
byte npcIdx = reader.ReadByte();
|
|
float ai0 = reader.ReadSingle();
|
|
float ai1 = reader.ReadSingle();
|
|
float ai2 = reader.ReadSingle();
|
|
float ai3 = reader.ReadSingle();
|
|
|
|
// If the NPC in question isn't valid, don't do anything.
|
|
NPC npc = Main.npc[npcIdx];
|
|
if (!npc.active)
|
|
break;
|
|
|
|
CalamityGlobalNPC cgn = npc.Calamity();
|
|
cgn.newAI[0] = ai0;
|
|
cgn.newAI[1] = ai1;
|
|
cgn.newAI[2] = ai2;
|
|
cgn.newAI[3] = ai3;
|
|
break;
|
|
|
|
|
|
case CalamityModMessageType.ProvidenceDyeConditionSync:
|
|
byte npcIndex3 = reader.ReadByte();
|
|
(Main.npc[npcIndex3].modNPC as Providence).hasTakenDaytimeDamage = reader.ReadBoolean();
|
|
break;
|
|
case CalamityModMessageType.PSCChallengeSync:
|
|
byte npcIndex4 = reader.ReadByte();
|
|
(Main.npc[npcIndex4].modNPC as Providence).challenge = reader.ReadBoolean();
|
|
break;
|
|
|
|
case CalamityModMessageType.ServersideSpawnOldDuke:
|
|
byte playerIndex2 = reader.ReadByte();
|
|
|
|
if (Main.netMode != NetmodeID.Server)
|
|
break;
|
|
|
|
Player player = Main.player[playerIndex2];
|
|
if (!player.active || player.dead)
|
|
return;
|
|
|
|
Projectile projectile = null;
|
|
for (int i = 0; i < Main.maxProjectiles; i++)
|
|
{
|
|
projectile = Main.projectile[i];
|
|
if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == playerIndex2)
|
|
{
|
|
projectile = Main.projectile[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (projectile is null)
|
|
return;
|
|
|
|
int oldDuke = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y + 100, ModContent.NPCType<OldDuke>());
|
|
CalamityUtils.BossAwakenMessage(oldDuke);
|
|
break;
|
|
|
|
default:
|
|
CalamityMod.Instance.Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}.");
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (e is EndOfStreamException eose)
|
|
CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: Packet was too short, missing data, or otherwise corrupt.", eose);
|
|
else if (e is ObjectDisposedException ode)
|
|
CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: Packet reader disposed or destroyed.", ode);
|
|
else if (e is IOException ioe)
|
|
CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: An unknown I/O error occurred.", ioe);
|
|
else
|
|
throw e; // this either will crash the game or be caught by TML's packet policing
|
|
}
|
|
}
|
|
|
|
public static void SyncWorld()
|
|
{
|
|
if (Main.netMode == NetmodeID.Server)
|
|
NetMessage.SendData(MessageID.WorldData);
|
|
}
|
|
}
|
|
|
|
public enum CalamityModMessageType : byte
|
|
{
|
|
MeleeLevelSync,
|
|
RangedLevelSync,
|
|
MagicLevelSync,
|
|
SummonLevelSync,
|
|
RogueLevelSync,
|
|
|
|
ExactMeleeLevelSync,
|
|
ExactRangedLevelSync,
|
|
ExactMagicLevelSync,
|
|
ExactSummonLevelSync,
|
|
ExactRogueLevelSync,
|
|
|
|
StressSync,
|
|
AdrenalineSync,
|
|
|
|
TeleportPlayer,
|
|
BossRushStage,
|
|
DoGCountdownSync,
|
|
BossSpawnCountdownSync,
|
|
BRHostileProjKillSync,
|
|
ArmoredDiggerCountdownSync,
|
|
BossTypeSync,
|
|
DeathCountSync,
|
|
|
|
RevengeanceBoolSync,
|
|
DeathBoolSync,
|
|
DefiledBoolSync,
|
|
IronHeartBoolSync,
|
|
ArmageddonBoolSync,
|
|
DemonTrophyBoolSync,
|
|
|
|
NPCRegenerationSync,
|
|
|
|
DeathModeUnderworldTimeSync,
|
|
DeathModeBlizzardTimeSync,
|
|
DeathBossSpawnCountdownSync,
|
|
|
|
AcidRainSync,
|
|
AcidRainUIDrawFadeSync,
|
|
AcidRainOldDukeSummonSync,
|
|
EncounteredOldDukeSync,
|
|
|
|
GaelsGreatswordSwingSync,
|
|
|
|
SpawnSuperDummy,
|
|
SyncCalamityNPCAIArray,
|
|
|
|
ProvidenceDyeConditionSync, // We shouldn't fucking need this. Die in a hole, Multiplayer.
|
|
PSCChallengeSync, // See above
|
|
|
|
// These message types were written by Ozz. They are Ozz's working tile entity netcode. Do not touch them.
|
|
PowerCellFactory,
|
|
ChargingStationStandard,
|
|
ChargingStationItemChange,
|
|
Turret,
|
|
LabHologramProjector,
|
|
|
|
ServersideSpawnOldDuke
|
|
}
|
|
}
|