Skip to content

Commit

Permalink
Add experimental implementations of commands
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonKaminski committed Feb 9, 2025
1 parent c9ef17e commit 8b2e841
Show file tree
Hide file tree
Showing 87 changed files with 1,406 additions and 742 deletions.
5 changes: 5 additions & 0 deletions UdpHosts/GameServer/Data/CharacterInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public bool ConsumeResource(uint sdbId, uint cost)
}
}

public uint GetResourceQuantity(uint sdbId)
{
return _resources.TryGetValue(sdbId, out var value) ? value.Quantity : 0;
}

public void AddLoadout(Loadout loadout)
{
_loadouts.Add(loadout.FrameLoadoutId, loadout);
Expand Down
1 change: 1 addition & 0 deletions UdpHosts/GameServer/Data/CharacterLoadout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public CharacterLoadout(LoadoutReferenceData refData)
public uint GliderID { get; set; }
public uint ChassisID { get; set; }
public uint BackpackID { get; set; }
public uint ChassisChangeTime { get; set; } = 0;
public ChassisWarpaintResult ChassisWarpaint { get; set; }

public VisualsBlock GetChassisVisuals()
Expand Down
13 changes: 13 additions & 0 deletions UdpHosts/GameServer/Entities/Character/CharacterEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,11 @@ public void SetSpawnTime(uint time)
}
}

public void SetNpcType(ushort npcType)
{
Character_ObserverView.NPCTypeProp = npcType;
}

public void SetWeaponIndex(WeaponIndexData value)
{
WeaponIndex = value;
Expand Down Expand Up @@ -949,6 +954,14 @@ public void SetGliderProfileId(uint profileId)
}
}

public void SetHoverProfileId(uint profileId)
{
if (Character_CombatController != null)
{
Character_CombatController.HoverProfileIdProp = profileId;
}
}

public void SetAuthorizedTerminal(AuthorizedTerminalData value)
{
AuthorizedTerminal = value;
Expand Down
11 changes: 11 additions & 0 deletions UdpHosts/GameServer/Entities/Vehicle/VehicleEntity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using AeroMessages.Common;
using AeroMessages.GSS.V66;
Expand Down Expand Up @@ -629,6 +630,16 @@ public void ChangeOccupantSeat(CharacterEntity character, byte requestedSeatInde
}
}

public void SlotAbility(uint abilityId)
{
var index = Abilities.FirstOrDefault(a => a.Value == 0).Key;

Abilities[index] = abilityId;

Vehicle_CombatController?.GetType().GetProperty($"SlottedAbility_{index}Prop")
?.SetValue(Vehicle_CombatController, abilityId, null);
}

private void InitFields()
{
HostilityInfo = new HostilityInfoData { Flags = 0 | HostilityInfoData.HostilityFlags.Faction, FactionId = 1 };
Expand Down
1 change: 1 addition & 0 deletions UdpHosts/GameServer/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum PlayerStatus

void Login(ulong characterId);
void EnterZoneAck();
void ExitZoneAck();
void Ready();
void Respawn();
void Jump();
Expand Down
6 changes: 6 additions & 0 deletions UdpHosts/GameServer/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ private void Matrix_PacketAvailable(GamePacket packet)
Factory.Get<BaseController>().Init(this, Player, AssignedShard, Logger);
Player.EnterZoneAck();
break;
case MatrixPacketType.ExitZone:
NetChannels[ChannelType.Matrix].SendMessage(new ExitZone());
break;
case MatrixPacketType.ExitZoneAck:
Player.ExitZoneAck();
break;
case MatrixPacketType.KeyframeRequest:
var query = packet.Unpack<KeyframeRequest>();
Logger.Verbose($"KeyframeRequest with {query.EntityRequests?.Length ?? 0} entity requests and {query.RefRequests?.Length ?? 0} ref requests. Total scoped for player: {AssignedShard.EntityMan.GetNumberOfScopedEntities(Player)}");
Expand Down
7 changes: 6 additions & 1 deletion UdpHosts/GameServer/NetworkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public void EnterZoneAck()
AssignedShard.EntityMan.Add(CharacterEntity.EntityId, CharacterEntity);
}

public void ExitZoneAck()
{
AssignedShard.EntityMan.Remove(CharacterEntity);
}

public void Respawn()
{
var outpostId = FindClosestAvailableOutpost(CurrentZone, CurrentOutpostId);
Expand Down Expand Up @@ -290,7 +295,7 @@ public void HandleFireWeaponProjectile(uint time, Vector3 aim)
AssignedShard.WeaponSim.OnFireWeaponProjectile(CharacterEntity, time, aim);
}

private void EnterZone(Zone z, uint outpostId = 0)
public void EnterZone(Zone z, uint outpostId = 0)
{
var spawnPoint = outpostId == 0
? new SpawnPoint { Position = z.POIs["spawn"] }
Expand Down
6 changes: 3 additions & 3 deletions UdpHosts/GameServer/StaticDB/Loaders/CustomDBLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public Dictionary<uint, NPCEquipMonsterCommandDef> LoadNPCEquipMonsterCommandDef

public Dictionary<uint, NPCSpawnCommandDef> LoadNPCSpawnCommandDef()
{
return LoadJSON<NPCSpawnCommandDef>("./StaticDB/CustomData/Todo/aptgss_agsNPCSpawnCommandDef.json")
return LoadJSON<NPCSpawnCommandDef>("./StaticDB/CustomData/aptgss_agsNPCSpawnCommandDef.json")
.ToDictionary(row => row.Id);
}

Expand Down Expand Up @@ -361,7 +361,7 @@ public Dictionary<uint, TinyObjectUpdateCommandDef> LoadTinyObjectUpdateCommandD

public Dictionary<uint, TurretControlCommandDef> LoadTurretControlCommandDef()
{
return LoadJSON<TurretControlCommandDef>("./StaticDB/CustomData/Todo/aptgss_agsTurretControlCommandDef.json")
return LoadJSON<TurretControlCommandDef>("./StaticDB/CustomData/aptgss_agsTurretControlCommandDef.json")
.ToDictionary(row => row.Id);
}

Expand Down Expand Up @@ -871,7 +871,7 @@ public Dictionary<uint, UnlockWarpaintsCommandDef> LoadUnlockWarpaintsCommandDef

public Dictionary<uint, UnpackItemCommandDef> LoadUnpackItemCommandDef()
{
return LoadJSON<UnpackItemCommandDef>("./StaticDB/CustomData/Todo/aptgss_UnpackItemCommandDef.json")
return LoadJSON<UnpackItemCommandDef>("./StaticDB/CustomData/aptgss_UnpackItemCommandDef.json")
.ToDictionary(row => row.Id);
}

Expand Down
5 changes: 5 additions & 0 deletions UdpHosts/GameServer/Systems/Aptitude/AptitudeTargets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public AptitudeTargets()
_targets = new();
}

public AptitudeTargets(AptitudeTargets initialTargets)
{
_targets = new List<IAptitudeTarget>(initialTargets.ToArray());
}

public AptitudeTargets(params IAptitudeTarget[] initialTargets)
{
_targets = new(initialTargets.Length);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Text;
using GameServer.Data.SDB.Records.customdata;

namespace GameServer.Aptitude;
Expand Down Expand Up @@ -33,6 +34,20 @@ public bool Execute(Context context)
}
else
{
StringBuilder stringBuilder = new();
stringBuilder.AppendLine("Active Effects (Self):");
var character = context.Self;
var activefx = character.GetActiveEffects();
foreach (var activeEffect in activefx)
{
if (activeEffect != null)
{
stringBuilder.AppendLine($"{activeEffect.Index} : {activeEffect.Effect?.Id}");
}
}

string message = stringBuilder.ToString();
Console.WriteLine(message);
Console.WriteLine($"Don't know which effect to remove for ImpactRemoveEffectCommand {Params.Id}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public bool Execute(Context context)
Context effectContext = new Context(context.Shard, context.Initiator)
{
InitTime = context.InitTime,
ExecutionHint = ExecutionHint.ApplyEffect
};

if (Params.PassRegister == 1)
Expand All @@ -43,7 +42,8 @@ public bool Execute(Context context)
if (active.Effect.Id == Params.EffectId)
{
targetHasEffect = true;
context.Abilities.DoRemoveEffect(active);
effectContext.ExecutionHint = ExecutionHint.RemoveEffect;
effectContext.Abilities.DoRemoveEffect(active);
break;
}
}
Expand All @@ -55,17 +55,12 @@ public bool Execute(Context context)

if (Params.PreApplyChain != 0)
{
var chain = context.Abilities.Factory.LoadChain(Params.PreApplyChain);
chain.Execute(new Context(context.Shard, context.Initiator)
{
ChainId = Params.PreApplyChain,
Targets = new AptitudeTargets(target),
InitTime = context.InitTime,
ExecutionHint = ExecutionHint.Proximity
});
var chain = effectContext.Abilities.Factory.LoadChain(Params.PreApplyChain);
chain.Execute(effectContext);
}

context.Abilities.DoApplyEffect(Params.EffectId, target, effectContext);
effectContext.ExecutionHint = ExecutionHint.ApplyEffect;
effectContext.Abilities.DoApplyEffect(Params.EffectId, target, effectContext);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using AeroMessages.Matrix.V25;
using GameServer.Data.SDB.Records.customdata;
using GameServer.Entities.Character;
using GameServer.Test;

namespace GameServer.Aptitude;

public class TeleportInstanceCommand : Command, ICommand
{
private TeleportInstanceCommandDef Params;

public TeleportInstanceCommand(TeleportInstanceCommandDef par)
: base(par)
{
Params = par;
}

public bool Execute(Context context)
{
if (Params.ZoneId == 0)
{
return true;
}

foreach (var target in context.Targets)
{
if (target is not CharacterEntity { Player: NetworkPlayer networkPlayer })
{
continue;
}

networkPlayer.NetChannels[ChannelType.Matrix].SendMessage(new ExitZone());

networkPlayer.EnterZone(DataUtils.GetZone(Params.ZoneId));
}

return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using GameServer.Entities;

namespace GameServer.Aptitude;
Expand All @@ -13,22 +14,24 @@ public BeginInteractionCommand(uint id)

public bool Execute(Context context)
{
if (context.Targets.Count > 0)
if (context.Targets.Count == 0)
{
var interactionEntity = context.Targets.Peek();
var hack = interactionEntity as BaseEntity;
var abilityId = hack.Interaction.StartedAbilityId;
if (abilityId != 0)
{
var actingEntity = context.Self;
context.Shard.Abilities.HandleActivateAbility(context.Shard, actingEntity, abilityId, context.Shard.CurrentTime, new AptitudeTargets(interactionEntity));
}

return true;
return false;
}
else

var interactionEntity = context.Targets.Peek();
var abilityId = ((BaseEntity)interactionEntity).Interaction.StartedAbilityId;
if (abilityId != 0)
{
return false;
var actingEntity = context.Self;
context.Shard.Abilities.HandleActivateAbility(
context.Shard,
interactionEntity,
abilityId,
context.Shard.CurrentTime,
new AptitudeTargets(actingEntity));
}

return true;
}
}
Loading

0 comments on commit 8b2e841

Please sign in to comment.