Skip to content

Commit

Permalink
Replace WorldMgr.GetxxxCloseToSpot parameter
Browse files Browse the repository at this point in the history
Replace ushort+Coordinate parameter with Position
Replace GameLiving.GroundTargetLocation with .GroundTargetPosition
  • Loading branch information
NetDwarf committed Oct 25, 2023
1 parent 73607cb commit 71cf1a0
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 125 deletions.
2 changes: 1 addition & 1 deletion GameServer/commands/gmcommands/jump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void OnCommand(GameClient client, string[] args)
#region Jump to GT
if (args.Length == 3 && args[1].ToLower() == "to" && args[2].ToLower() == "gt")
{
client.Player.MoveTo(Position.Create(client.Player.CurrentRegionID, client.Player.GroundTargetLocation, client.Player.Orientation));
client.Player.MoveTo(client.Player.GroundTargetPosition.With(orientation: client.Player.Orientation));
return;
}
#endregion Jump to GT
Expand Down
6 changes: 3 additions & 3 deletions GameServer/commands/playercommands/GroundAssist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public void OnCommand(GameClient client, string[] args)
return;
}

if (target.GroundTargetLocation == Coordinate.Nowhere)
if (target.GroundTargetPosition == Position.Nowhere)
{
client.Out.SendMessage(LanguageMgr.GetTranslation(client, "Scripts.Players.Groundassist.NoTarget", target.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
client.Player.Out.SendChangeGroundTarget(target.GroundTargetLocation);
client.Player.GroundTargetLocation = target.GroundTargetLocation;
client.Player.Out.SendChangeGroundTarget(target.GroundTargetPosition.Coordinate);
client.Player.GroundTargetPosition = target.GroundTargetPosition;
}
}
}
4 changes: 2 additions & 2 deletions GameServer/commands/playercommands/gtrange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public void OnCommand(GameClient client, string[] args)
if (IsSpammingCommand(client.Player, "gtrange"))
return;

if (client.Player.GroundTargetLocation != Coordinate.Nowhere)
if (client.Player.GroundTargetPosition != Position.Nowhere)
{
var range = (int)client.Player.Location.DistanceTo(client.Player.GroundTargetLocation);
var range = (int)client.Player.Location.DistanceTo(client.Player.GroundTargetPosition);
client.Out.SendMessage(LanguageMgr.GetTranslation(client, "Scripts.Players.Gtrange.Range", range), eChatType.CT_System, eChatLoc.CL_SystemWindow);
}
else
Expand Down
6 changes: 3 additions & 3 deletions GameServer/gameobjects/GameLiving.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5674,13 +5674,13 @@ public virtual bool IsSitting

[Obsolete("Use GroundTargetLocation instead!")]
public virtual Point3D GroundTarget
=> GroundTargetLocation.ToPoint3D();
=> GroundTargetPosition.Coordinate.ToPoint3D();

[Obsolete("Use GroundTargetLocation_set instead!")]
public virtual void SetGroundTarget(int groundX, int groundY, int groundZ)
=> GroundTargetLocation = Coordinate.Create(groundX, groundY, groundZ);
=> GroundTargetPosition = Position.Create(Position.RegionID, groundX, groundY, groundZ);

public virtual Coordinate GroundTargetLocation { get; set; } = Coordinate.Nowhere;
public virtual Position GroundTargetPosition { get; set; } = Position.Nowhere;

/// <summary>
/// Gets or Sets the current level of the Object
Expand Down
6 changes: 3 additions & 3 deletions GameServer/gameobjects/GamePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10853,13 +10853,13 @@ public virtual void Sit(bool sit)
UpdatePlayerStatus();
}

public override Coordinate GroundTargetLocation
public override Position GroundTargetPosition
{
set
{
base.GroundTargetLocation = value;
base.GroundTargetPosition = value;
Out.SendMessage(String.Format("You ground-target {0},{1},{2}", value.X, value.Y, value.Z), eChatType.CT_System, eChatLoc.CL_SystemWindow);
if (SiegeWeapon != null) SiegeWeapon.GroundTargetLocation = value;
if (SiegeWeapon != null) SiegeWeapon.GroundTargetPosition = value;
}
}

Expand Down
24 changes: 12 additions & 12 deletions GameServer/gameobjects/GameSiegeWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ public Coordinate AimLocation
{
get
{
var targetLocation = Coordinate.Create(x: 0, y: 0, z: 0);
if(TargetObject != null) targetLocation = TargetObject.Location;
else if(GroundTargetLocation != Coordinate.Nowhere) targetLocation = GroundTargetLocation;
return targetLocation;
var targetPosition = Position.Zero;
if(TargetObject != null) targetPosition = TargetObject.Position;
else if(GroundTargetPosition != Position.Nowhere) targetPosition = GroundTargetPosition;
return targetPosition.Coordinate;
}
}
#endregion
Expand Down Expand Up @@ -244,10 +244,10 @@ public void Aim()
if (Owner.TargetObject == null) return;
if (!GameServer.ServerRules.IsAllowedToAttack(Owner, ((GameLiving)Owner.TargetObject), true)) return;
CurrentState &= ~eState.Aimed;
GroundTargetLocation = Owner.TargetObject.Location;
GroundTargetPosition = Owner.TargetObject.Position;
TargetObject = Owner.TargetObject;
SiegeWeaponTimer.CurrentAction = SiegeTimer.eAction.Aiming;
TurnTo(GroundTargetLocation);
TurnTo(GroundTargetPosition.Coordinate);
PreAction();
if (Owner != null)
{
Expand All @@ -271,8 +271,8 @@ public void Move()
{
if (!CanUse()) return;
if (!m_enableToMove) return;
if (Owner == null || Owner.GroundTargetLocation == Coordinate.Nowhere) return;
if (Location.DistanceTo(Owner.GroundTargetLocation) > 1000)
if (Owner == null || Owner.GroundTargetPosition == Position.Nowhere) return;
if (Location.DistanceTo(Owner.GroundTargetPosition) > 1000)
{
Owner.Out.SendMessage("Ground target is too far away to move to!", eChatType.CT_System,
eChatLoc.CL_SystemWindow);
Expand All @@ -286,7 +286,7 @@ public void Move()
}

//let's check if we are trying to move too close to a door, if we are, don't move
foreach (IDoor door in Owner.CurrentRegion.GetDoorsInRadius(Owner.GroundTargetLocation, (ushort)(AttackRange - 50), false))
foreach (IDoor door in Owner.CurrentRegion.GetDoorsInRadius(Owner.GroundTargetPosition.Coordinate, (ushort)(AttackRange - 50), false))
{
if (door is GameKeepDoor)
{
Expand All @@ -297,7 +297,7 @@ public void Move()

//unarmed siege weapon
CurrentState &= ~eState.Armed;
WalkTo(Owner.GroundTargetLocation, 100);
WalkTo(Owner.GroundTargetPosition.Coordinate, 100);
}

public void StopMove()
Expand Down Expand Up @@ -338,9 +338,9 @@ public void Fire()
}
return;
}
if (TargetObject != null) GroundTargetLocation = TargetObject.Location;
if (TargetObject != null) GroundTargetPosition = TargetObject.Position;

if (GroundTargetLocation == Coordinate.Nowhere) return;
if (GroundTargetPosition == Position.Nowhere) return;
new RegionTimer(this, new RegionTimerCallback(MakeDelayedDamage), GetActionDelay(SiegeTimer.eAction.Fire));
BroadcastFireAnimation(GetActionDelay(SiegeTimer.eAction.Fire));
if (Owner != null)
Expand Down
6 changes: 3 additions & 3 deletions GameServer/gameobjects/SiegeWeapon/gamesiegecatapult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ protected IList SelectTargets()
{
ArrayList list = new ArrayList(20);

foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(this.CurrentRegionID, GroundTargetLocation, (ushort)150))
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(GroundTargetPosition, (ushort)150))
{
if (GameServer.ServerRules.IsAllowedToAttack(Owner, player, true))
{
list.Add(player);
}
}
foreach (GameNPC npc in WorldMgr.GetNPCsCloseToSpot(this.CurrentRegionID, GroundTargetLocation, (ushort)150))
foreach (GameNPC npc in WorldMgr.GetNPCsCloseToSpot(GroundTargetPosition, (ushort)150))
{
if (GameServer.ServerRules.IsAllowedToAttack(Owner, npc, true))
{
Expand All @@ -94,7 +94,7 @@ public override void DoDamage()
//todo remove ammo + spell in db and uncomment
//m_spellHandler.StartSpell(player);
base.DoDamage();//anim mut be called after damage
if (GroundTargetLocation == Coordinate.Nowhere) return;
if (GroundTargetPosition == Position.Nowhere) return;
IList targets = SelectTargets();

foreach (GameLiving living in targets)
Expand Down
4 changes: 2 additions & 2 deletions GameServer/gameobjects/SiegeWeapon/gamesiegecauldron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public GameSiegeCauldron()
Effect = 0x8A1;
Model = 0xA2F;
CurrentState = eState.Aimed;
GroundTargetLocation = Location - Vector.Create(z: 100);
GroundTargetPosition = Position - Vector.Create(z: 100);
ActionDelay = new int[]
{
0, //none
Expand All @@ -56,7 +56,7 @@ public GameSiegeCauldron()

public override bool AddToWorld()
{
GroundTargetLocation = Location.With(z: Component.Keep.Z);
GroundTargetPosition = Position.With(z: Component.Keep.Z);
return base.AddToWorld();
}

Expand Down
10 changes: 5 additions & 5 deletions GameServer/housing/House.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public bool IsOccupied
{
get
{
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(RegionID, Position.Coordinate.With(z: 25000), WorldMgr.VISIBILITY_DISTANCE))
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(Position.With(z: 25000), WorldMgr.VISIBILITY_DISTANCE))
{
if (player.CurrentHouse == this && player.InHouse)
{
Expand Down Expand Up @@ -345,7 +345,7 @@ public Position OutdoorJumpPosition
/// </summary>
public void SendUpdate()
{
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(Position.RegionID, Position.Coordinate, HousingConstants.HouseViewingDistance))
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(Position, HousingConstants.HouseViewingDistance))
{
player.Out.SendHouse(this);
player.Out.SendGarden(this);
Expand All @@ -366,7 +366,7 @@ public void Enter(GamePlayer player)
IList<GamePlayer> list = GetAllPlayersInHouse();
if (list.Count == 0)
{
foreach (GamePlayer pl in WorldMgr.GetPlayersCloseToSpot(Position.RegionID, Position.Coordinate, HousingConstants.HouseViewingDistance))
foreach (GamePlayer pl in WorldMgr.GetPlayersCloseToSpot(Position, HousingConstants.HouseViewingDistance))
{
pl.Out.SendHouseOccupied(this, true);
}
Expand Down Expand Up @@ -457,7 +457,7 @@ public void Exit(GamePlayer player, bool silent)
IList<GamePlayer> list = GetAllPlayersInHouse();
if (list.Count == 0)
{
foreach (GamePlayer pl in WorldMgr.GetPlayersCloseToSpot(Position.RegionID, Position.Coordinate, HousingConstants.HouseViewingDistance))
foreach (GamePlayer pl in WorldMgr.GetPlayersCloseToSpot(Position, HousingConstants.HouseViewingDistance))
{
pl.Out.SendHouseOccupied(this, false);
}
Expand Down Expand Up @@ -565,7 +565,7 @@ public int GetGuildEmblemFlags()
public IList<GamePlayer> GetAllPlayersInHouse()
{
var ret = new List<GamePlayer>();
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(RegionID, Position.Coordinate.With(z: 25000), WorldMgr.VISIBILITY_DISTANCE))
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(Position.With(z: 25000), WorldMgr.VISIBILITY_DISTANCE))
{
if (player.CurrentHouse == this && player.InHouse)
{
Expand Down
2 changes: 1 addition & 1 deletion GameServer/housing/HouseMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public static void RemoveHouse(House house)
}

// remove the house for all nearby players
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(house.Position.RegionID, house.Position.Coordinate, WorldMgr.OBJ_UPDATE_DISTANCE))
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(house.Position, WorldMgr.OBJ_UPDATE_DISTANCE))
{
player.Out.SendRemoveHouse(house);
player.Out.SendGarden(house);
Expand Down
2 changes: 1 addition & 1 deletion GameServer/packets/Client/168/HousingPlaceItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void HandlePacket(GameClient client, GSPacketIn packet)
ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenItemPlacedName", orgitem.Name);

// update all nearby players
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(house.RegionID, house.Position.Coordinate, WorldMgr.OBJ_UPDATE_DISTANCE))
foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(house.Position, WorldMgr.OBJ_UPDATE_DISTANCE))
{
player.Out.SendGarden(house);
}
Expand Down
6 changes: 3 additions & 3 deletions GameServer/packets/Client/168/PlayerGroundTargetHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected override void OnTick()
{
var player = (GamePlayer) m_actionSource;
player.GroundTargetInView = ((m_flag & 0x100) != 0);
player.GroundTargetLocation = Coordinate.Create(m_x, m_y, (ushort) m_z);
player.GroundTargetPosition = Position.Create(player.Position.RegionID, m_x, m_y, (ushort) m_z);

if (!player.GroundTargetInView)
player.Out.SendMessage("Your ground target is not visible!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
Expand All @@ -98,7 +98,7 @@ protected override void OnTick()
if (player.Steed.OwnerID == player.InternalID)
{
player.Out.SendMessage("You usher your boat forward.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
player.Steed.WalkTo(player.GroundTargetLocation, player.Steed.MaxSpeed);
player.Steed.WalkTo(player.GroundTargetPosition.Coordinate, player.Steed.MaxSpeed);
return;
}
}
Expand All @@ -109,7 +109,7 @@ protected override void OnTick()
eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
}
player.Steed.WalkTo(player.GroundTargetLocation, player.Steed.MaxSpeed);
player.Steed.WalkTo(player.GroundTargetPosition.Coordinate, player.Steed.MaxSpeed);
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions GameServer/packets/Server/PacketLib1110.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ public override void SendSiegeWeaponFireAnimation(GameSiegeWeapon siegeWeapon, i
return;
using (var pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.SiegeWeaponAnimation)))
{
var targetLocation = siegeWeapon.TargetObject.Location;
if(targetLocation == Coordinate.Nowhere) targetLocation = siegeWeapon.GroundTargetLocation;
var targetLocation = siegeWeapon.TargetObject.Position;
if(targetLocation == Position.Nowhere) targetLocation = siegeWeapon.GroundTargetPosition;
pak.WriteInt((uint) siegeWeapon.ObjectID);
pak.WriteInt((uint) (targetLocation.X));
pak.WriteInt((uint) (targetLocation.Y));
Expand Down
8 changes: 4 additions & 4 deletions GameServer/realmabilities/handlers/DecimationTrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public override void Execute(GameLiving living)
}
}

if (living.GroundTargetLocation == Coordinate.Nowhere)
if (living.GroundTargetPosition == Position.Nowhere)
return;
if (living.Location.DistanceTo(living.GroundTargetLocation) > 1500 )
if (living.Location.DistanceTo(living.GroundTargetPosition) > 1500 )
return;
GamePlayer player = living as GamePlayer;
if (player == null)
Expand Down Expand Up @@ -136,14 +136,14 @@ private void removeHandlers()

private void getTargets()
{
foreach (GamePlayer target in WorldMgr.GetPlayersCloseToSpot(region, Coordinate.Create(traparea.X, traparea.Y, traparea.Z), 350))
foreach (GamePlayer target in WorldMgr.GetPlayersCloseToSpot(Position.Create(region, traparea.X, traparea.Y, traparea.Z), 350))
{
if (GameServer.ServerRules.IsAllowedToAttack(owner, target, true))
{
DamageTarget(target);
}
}
foreach (GameNPC target in WorldMgr.GetNPCsCloseToSpot(region, Coordinate.Create(traparea.X, traparea.Y, traparea.Z), 350))
foreach (GameNPC target in WorldMgr.GetNPCsCloseToSpot(Position.Create(region, traparea.X, traparea.Y, traparea.Z), 350))
{
if (GameServer.ServerRules.IsAllowedToAttack(owner, target, true))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void Execute(GameLiving living)
return;
}

if ( caster.GroundTargetLocation == Coordinate.Nowhere || caster.Location.DistanceTo(caster.GroundTargetLocation) > 1500)
if ( caster.GroundTargetPosition == Position.Nowhere || caster.Location.DistanceTo(caster.GroundTargetPosition) > 1500)
{
caster.Out.SendMessage("You groundtarget is too far away to use this ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
Expand Down Expand Up @@ -105,7 +105,7 @@ protected virtual int EndCast(RegionTimer timer)
if (!castWasSuccess)
return 0;
Statics.NegativeMaelstromBase nm = new Statics.NegativeMaelstromBase(dmgValue);
nm.CreateStatic(player, player.GroundTargetLocation, duration, 5, 350);
nm.CreateStatic(player, player.GroundTargetPosition.Coordinate, duration, 5, 350);
DisableSkill(player);
timer.Stop();
timer = null;
Expand Down
6 changes: 3 additions & 3 deletions GameServer/realmabilities/handlers/ThornweedFieldAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public override void Execute(GameLiving living)
return;
}

if (caster.GroundTargetLocation == Coordinate.Nowhere )
if (caster.GroundTargetPosition == Position.Nowhere )
{
caster.Out.SendMessage( "You must set a ground target to use this ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow );
return;
}
else if(caster.Location.DistanceTo(caster.GroundTargetLocation) > 1500)
else if(caster.Location.DistanceTo(caster.GroundTargetPosition) > 1500)
{
caster.Out.SendMessage("Your ground target is too far away to use this ability!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
return;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected virtual int EndCast(RegionTimer timer)
if (m_player.IsMezzed || m_player.IsStunned || m_player.IsSitting)
return 0;
Statics.ThornweedFieldBase twf = new Statics.ThornweedFieldBase(m_dmgValue);
twf.CreateStatic(m_player, m_player.GroundTargetLocation, m_duration, 3, 500);
twf.CreateStatic(m_player, m_player.GroundTargetPosition.Coordinate, m_duration, 3, 500);
DisableSkill(m_player);
timer.Stop();
timer = null;
Expand Down
4 changes: 2 additions & 2 deletions GameServer/spells/Animist/SummonAnimistFnF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public override bool CheckBeginCast(GameLiving selectedTarget)

Region rgn = WorldMgr.GetRegion(Caster.CurrentRegion.ID);

if (rgn == null || rgn.GetZone(Caster.GroundTargetLocation) == null)
if (rgn == null || rgn.GetZone(Caster.GroundTargetPosition.Coordinate) == null)
{
if (Caster is GamePlayer)
MessageToCaster(LanguageMgr.GetTranslation((Caster as GamePlayer).Client, "SummonAnimistFnF.CheckBeginCast.NoGroundTarget"), eChatType.CT_SpellResisted);
return false;
}

foreach (GameNPC npc in Caster.CurrentRegion.GetNPCsInRadius(Caster.GroundTargetLocation, (ushort)Properties.TURRET_AREA_CAP_RADIUS, false, true))
foreach (GameNPC npc in Caster.CurrentRegion.GetNPCsInRadius(Caster.GroundTargetPosition.Coordinate, (ushort)Properties.TURRET_AREA_CAP_RADIUS, false, true))
if (npc.Brain is TurretFNFBrain)
nCount++;

Expand Down
Loading

0 comments on commit 71cf1a0

Please sign in to comment.