From b11eb31c518a00974fde15d94d2ae873c35789aa Mon Sep 17 00:00:00 2001 From: Lucca Faria Ferri Date: Sun, 22 Jan 2023 09:43:32 -0800 Subject: [PATCH] Added fixed attributes, added Invulnerability command, fixed compilation issue, more translations --- .../CommandManager/GameCommands.cs | 26 +++++++++++++ .../GSSystem/ActorSystem/Actor.cs | 22 ++++++----- .../GSSystem/ObjectsSystem/FixedMap.cs | 38 +++++++++++++++++++ .../ObjectsSystem/GameAttributeMap.cs | 4 ++ .../PlayerSystem/ConversationManager.cs | 10 ++--- .../PowerSystem/Payloads/DeathPayload.cs | 4 +- 6 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/FixedMap.cs diff --git a/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs b/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs index 6540f0a..c1237f7 100644 --- a/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs +++ b/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs @@ -37,11 +37,37 @@ using System.Linq; using System.Text; //Blizzless Project 2022 using System.Threading.Tasks; +using DiIiS_NA.GameServer.GSSystem.ObjectsSystem; +using DiIiS_NA.LoginServer.AccountsSystem; //Blizzless Project 2022 using static DiIiS_NA.Core.MPQ.FileFormats.GameBalance; namespace DiIiS_NA.GameServer.CommandManager { + [CommandGroup("Invulnerable", "Makes you invulnerable")] + public class InvulnerableCommand : CommandGroup + { + [DefaultCommand] + public string Invulnerable(string[] @params, BattleClient invokerClient) + { + if (invokerClient?.InGameClient?.Player is not { } player) + return "You can not invoke this command from console."; + + if (player.Attributes.FixedMap.Contains(FixedAttribute.Invulnerable)) + { + player.Attributes.FixedMap.Remove(FixedAttribute.Invulnerable); + player.Attributes[GameAttribute.Invulnerable] = false; + player.Attributes.BroadcastChangedIfRevealed(); + return "You are no longer invulnerable."; + } + + player.Attributes.FixedMap.Add(FixedAttribute.Invulnerable, + attributes => { attributes[GameAttribute.Invulnerable] = true; }); + player.Attributes.BroadcastChangedIfRevealed(); + return "You are now invulnerable."; + } + } + [CommandGroup("spawn", "Spawns a mob.\nUsage: spawn [actorSNO] [amount]")] public class SpawnCommand : CommandGroup { diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs index 908e3ea..8a85524 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs @@ -681,19 +681,21 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem UnitAniimStartTime = 0, tAnim = new PlayAnimationMessageSpec[] { - new PlayAnimationMessageSpec - { - Duration = -2, - AnimationSNO = (int)animationSNO, - PermutationIndex = 0x0, - AnimationTag = 0, - Speed = 1.0f, + new PlayAnimationMessageSpec + { + Duration = -2, + AnimationSNO = (int)animationSNO, + PermutationIndex = 0x0, + AnimationTag = 0, + Speed = 1.0f, + } } - }, this); + }, + this); + } } - } - public void PlayAnimation(int animationType, AnimationSno animationSNO, float speed = 1.0f, int? ticksToPlay = null, int type2 = 0) + public void PlayAnimation(int animationType, AnimationSno animationSNO, float speed = 1.0f, int? ticksToPlay = null, int type2 = 0) { if (this.World == null || animationSNO == AnimationSno._NONE) return; diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/FixedMap.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/FixedMap.cs new file mode 100644 index 0000000..2021852 --- /dev/null +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/FixedMap.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using DiIiS_NA.Core.Logging; + +namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem +{ + public enum FixedAttribute + { + Invulnerable, + Speed + } + + public class FixedMap + { + private static readonly Logger _logger = LogManager.CreateLogger(nameof(FixedMap)); + private readonly Dictionary> _attributeMap = new(); + + public void Add(FixedAttribute name, Action action) + { + if (Contains(name)) + { + _attributeMap[name] += action; + _logger.Warn($"Fixed attribute {name} already exists. Action will be added."); + return; + } + _attributeMap.Add(name, action); + } + + public void Remove(FixedAttribute name) => _attributeMap.Remove(name); + public void Clear() => _attributeMap.Clear(); + public bool Contains(FixedAttribute name) => _attributeMap.ContainsKey(name); + public void Apply(GameAttributeMap map) + { + foreach (var action in _attributeMap.Values) + action(map); + } + } +} \ No newline at end of file diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/GameAttributeMap.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/GameAttributeMap.cs index cc65f60..a1d3f82 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/GameAttributeMap.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ObjectsSystem/GameAttributeMap.cs @@ -29,9 +29,11 @@ using System.Threading.Tasks; namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem { + public class GameAttributeMap { private static Logger Logger = LogManager.CreateLogger(); + public FixedMap FixedMap { get; } = new(); public struct KeyId { @@ -233,6 +235,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem /// public void BroadcastIfRevealed() { + FixedMap.Apply(this); if (_parent.World != null) SendMessage(_parent.World.Players.Values .Where(@player => @player.RevealedObjects.ContainsKey(_parent.GlobalID)) @@ -244,6 +247,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem /// public void BroadcastChangedIfRevealed() { + FixedMap.Apply(this); if (_parent.World != null) SendChangedMessage(_parent.World.Players.Values .Where(@player => @player.RevealedObjects.ContainsKey(_parent.GlobalID)) diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs index f837e64..b2c8621 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs @@ -801,11 +801,11 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem foreach (var wall in wrld.GetActorsBySNO(ActorSno._trdun_cath_bonewall_a_door)) if (wall.Position.Z > -23f) { - Wall.PlayAnimation(11, AnimationSno.trdun_cath_bonewall_a_death); - Wall.Attributes[GameAttribute.Deleted_On_Server] = true; - Wall.Attributes[GameAttribute.Could_Have_Ragdolled] = true; - Wall.Attributes.BroadcastChangedIfRevealed(); - Wall.Destroy(); + wall.PlayAnimation(11, AnimationSno.trdun_cath_bonewall_a_death); + wall.Attributes[GameAttribute.Deleted_On_Server] = true; + wall.Attributes[GameAttribute.Could_Have_Ragdolled] = true; + wall.Attributes.BroadcastChangedIfRevealed(); + wall.Destroy(); } break; diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs index eb32c88..1b2a781 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs @@ -270,7 +270,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads //Пчелы case ActorSno._sandwasp_a: case ActorSno._fleshpitflyer_leoric_inferno: - Target.PlayAnimation(11, 8535, 1f); + Target.PlayAnimation(11, AnimationSno.fleshpitflyer_death, 1f); break; //X1_LR_Boss_Angel_Corrupt_A case ActorSno._x1_lr_boss_angel_corrupt_a: @@ -282,7 +282,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads Target.PlayAnimation(11, animation, 1f); else { - Logger.Warn("Анимация смерти не обнаружена: ActorSNOId = {0}", Target.SNO); + Logger.Warn("Death animation not found: ActorSNOId = {0}", Target.SNO); } break; }