2 - Afflicted buff no longer displayers 0 seconds in the icon list. 3 - Adjusted various tooltips to specify whether actual movement speed is increased or just max movement speed/acceleration. 4 - Tried, and failed, to implement the summon buffs and minions not vanishing after you die, I need help with this. 5 - Added defense damage system. 6 - Aquatic Emblem killed my game when I tried to sync it, I need help with this. 7 - Added new movement speed calcs so that they actually affect your wing and run speeds. 8 - New Draedon's Heart effect. 9 - Hide of Astrum Deus drops astral stars on true melee hits. 10 - Fixed i-frames not working properly sometimes with shield dashes and mounts. 11 - I-frame bonuses now work! 12 - Increased the defense Elysian Guard buff gives you from 20 to 40. 13 - Flight time boosts are now additive instead of multiplicative. 14 - Reworked Abyssal Diving Suit a bit to grant less movement speed loss and less DR as the suit takes damage. 15 - Yharon Lore now sets flight time to int.MaxValue. 16 - Adjusted every single post-ML item rarity I could find to make more sense. 17 - Adjusted every single recipe that used darksun frags and ascendant spirit essence to just use ascendant spirit essense. 18 - Merged Yharon phase 1 and 2 into a single tier. 19 - Moved buffed eclipse to post-DoG. 20 - Death Mode item tooltip now states the exact life regen changes. 21 - Cryogen Lore, King Slime Lore and alcohols that reduced defense now reduce the stat by a percentage instead of a flat amount. 22 - Ascendant Spirit Essence now requires 5 darksun frags to craft. 23 - Auric Bar recipe requires 10 ore instead of 20. 24 - Moved Dragonfruit to post-Yharon by making it require Yharon Soul Frags instead of darksun frags. 25 - Plague Engine summons update twice as fast. 26 - Elemental Axe damage reduced from 140 to 100 and made the axes have their own immunity frame timers. 27 - Buffed all movement speed prefixes. 28 - Buffed all defense prefixes as the game progresses. 29 - Precise and Lucky give 1 armor pen. 30 - Added Rarity 11 to various post-ML items. 31 - Removed now-useless mod call for downed buffed mothron. 32 - Made various NPCs and projectiles able to deal damage to player defense. 33 - DoG phase 1 and 2 head and tail take less damage the further away the target is. 34 - Post-ML boss potion drop changes. 35 - Providence and Yharon bullet hells now fire projectiles at multiple players every now and then, up to a max of 10. 36 - Dragon Scales can only be bought post-Yharon. 37 - Reduced post-ML Aureus damage. 38 - Reduced post-DoG event damage. 39 - Doubled post-DoG event spawn rate so it feels like a slaughter. 40 - Increased Old Duke despawn range. 41 - Old Duke deals 75% less contact damage while tired. 42 - Gave Providence, Old Duke and rev+ Providence improved player targeting. 43 - Hopefully fixed Golem Free Head hitbox in rev+. 44 - Duke Fishron Sharknado sharks don't deal damage for 42 frames after they've spawned in to avoid bullshit hits. 45 - Cosmic Discharge flail updates twice as fast. 46 - Phantasmal Ruin lost souls no longer home in and spawn half as many homing souls on death. 47 - Yanmei's Knife no longer mauls Astrum Deus. 48 - Leather recipe edit to require less evil shit. 49 - Removed unnecessary buffed eclipse and downed buffed mothron booleans. 50 - Finally, some good fucking food.
313 lines
14 KiB
C#
313 lines
14 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.ItemTypeLastReforgedSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleItemTypeLastReforged(reader);
|
|
break;
|
|
case CalamityModMessageType.ReforgeTierSafetySync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleReforgeTierSafety(reader);
|
|
break;
|
|
/*case CalamityModMessageType.AquaticBoostSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleAquaticBoost(reader);
|
|
break;*/
|
|
case CalamityModMessageType.MoveSpeedStatSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleMoveSpeedStat(reader);
|
|
break;
|
|
case CalamityModMessageType.DefenseDamageSync:
|
|
Main.player[reader.ReadInt32()].Calamity().HandleDefenseDamage(reader);
|
|
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,
|
|
|
|
MoveSpeedStatSync,
|
|
|
|
DefenseDamageSync,
|
|
|
|
StressSync,
|
|
AdrenalineSync,
|
|
|
|
//AquaticBoostSync,
|
|
|
|
TeleportPlayer,
|
|
BossRushStage,
|
|
DoGCountdownSync,
|
|
BossSpawnCountdownSync,
|
|
BRHostileProjKillSync,
|
|
ArmoredDiggerCountdownSync,
|
|
BossTypeSync,
|
|
DeathCountSync,
|
|
|
|
NPCRegenerationSync,
|
|
|
|
DeathModeUnderworldTimeSync,
|
|
DeathModeBlizzardTimeSync,
|
|
DeathBossSpawnCountdownSync,
|
|
|
|
ItemTypeLastReforgedSync,
|
|
ReforgeTierSafetySync,
|
|
|
|
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
|
|
}
|
|
}
|