Added fixed attributes, added Invulnerability command, fixed compilation issue, more translations

This commit is contained in:
Lucca Faria Ferri 2023-01-22 09:43:32 -08:00
parent 9aa4ddd07a
commit b11eb31c51
6 changed files with 87 additions and 17 deletions

View File

@ -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
{

View File

@ -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;

View File

@ -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<FixedAttribute, Action<GameAttributeMap>> _attributeMap = new();
public void Add(FixedAttribute name, Action<GameAttributeMap> 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);
}
}
}

View File

@ -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
/// </summary>
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
/// </summary>
public void BroadcastChangedIfRevealed()
{
FixedMap.Apply(this);
if (_parent.World != null)
SendChangedMessage(_parent.World.Players.Values
.Where(@player => @player.RevealedObjects.ContainsKey(_parent.GlobalID))

View File

@ -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;

View File

@ -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;
}