Skip to content

Commit

Permalink
Add IPacketLib.SendSoundEffect(ushort,Position,ushort)
Browse files Browse the repository at this point in the history
Deprecate old version
  • Loading branch information
NetDwarf committed Oct 24, 2023
1 parent 0aab17a commit 71920e0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions DOLServer/ConsolePacketLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void SendDisableSkill(ICollection<Tuple<Skill, int>> skills) { }
public void SendUpdateIcons(IList changedEffects, ref int lastUpdateEffectsCount) { }
public void SendLevelUpSound() { }
public void SendRegionEnterSound(byte soundId) { }
public void SendSoundEffect(ushort soundId, Position position, ushort radius) { }
public void SendSoundEffect(ushort soundId, ushort zoneId, ushort x, ushort y, ushort z, ushort radius) { }
public void SendDebugMessage(string format, params object[] parameters) { }
public void SendDebugPopupMessage(string format, params object[] parameters) { }
Expand Down
3 changes: 2 additions & 1 deletion GameServer/commands/gmcommands/cast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using DOL.GS.PacketHandler;
using DOL.Language;
using DOL.GS.Effects;
using DOL.GS.Geometry;

namespace DOL.GS.Commands
{
Expand Down Expand Up @@ -150,7 +151,7 @@ public void OnCommand(GameClient client, string[] args)
case "sound":
DisplayMessage(client,
LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Cast.SoundPlayed", id.ToString()));
client.Player.Out.SendSoundEffect((ushort)id, 0, 0, 0, 0, 0);
client.Player.Out.SendSoundEffect((ushort)id, Position.Zero, 0);
break;
#endregion
#region Default
Expand Down
2 changes: 2 additions & 0 deletions GameServer/packets/Server/IPacketLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ void SendDialogBox(eDialogCode code, ushort data1, ushort data2, ushort data3, u
void SendSiegeWeaponCloseInterface();
void SendSiegeWeaponInterface(GameSiegeWeapon siegeWeapon, int time);
void SendLivingDataUpdate(GameLiving living, bool updateStrings);
void SendSoundEffect(ushort soundId, Position position, ushort radius);
[Obsolete("Use .SendSoundEffect(ushort,Position,ushort) instead!")]
void SendSoundEffect(ushort soundId, ushort zoneId, ushort x, ushort y, ushort z, ushort radius);
//keep
void SendKeepInfo(IGameKeep keep);
Expand Down
12 changes: 12 additions & 0 deletions GameServer/packets/Server/PacketLib168.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4153,6 +4153,18 @@ public virtual void SendLivingDataUpdate(GameLiving living, bool updateStrings)
}
}

public virtual void SendSoundEffect(ushort soundId, Position pos, ushort radius)
{
var region = WorldMgr.GetRegion(pos.RegionID);
if(region == null) return;

var zone = region.GetZone(pos.Coordinate);
if(zone == null) return;

var zoneCoord = pos - zone.Offset;
SendSoundEffect(soundId, zone.ID, (ushort)zoneCoord.X, (ushort)zoneCoord.Y, (ushort)zoneCoord.Z, radius);
}

public virtual void SendSoundEffect(ushort soundId, ushort zoneId, ushort x, ushort y, ushort z, ushort radius)
{
using (var pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.SoundEffect)))
Expand Down
5 changes: 3 additions & 2 deletions GameServer/quests/QuestsMgr/DataQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

using log4net;
using DOL.GS.Finance;
using DOL.GS.Geometry;

namespace DOL.GS.Quests
{
Expand Down Expand Up @@ -1969,7 +1970,7 @@ public static void RewardQuestNotify(DOLEvent e, object sender, EventArgs args)
GameNPC npc = giver as GameNPC;
player.Out.SendNPCsQuestEffect(npc, npc.GetQuestIndicator(player));
}
player.Out.SendSoundEffect(7, 0, 0, 0, 0, 0);
player.Out.SendSoundEffect(7, Position.Zero, 0);
break;
}
}
Expand Down Expand Up @@ -3064,7 +3065,7 @@ public virtual bool FinishQuest(GameObject obj, bool checkCustomStep)

if (StartType == eStartType.RewardQuest)
{
m_questPlayer.Out.SendSoundEffect(11, 0, 0, 0, 0, 0);
m_questPlayer.Out.SendSoundEffect(11, Position.Zero, 0);
}
if (!string.IsNullOrEmpty(m_dataQuest.FinishText)) // Give users option to have 'finish' text with rewardquest too
{
Expand Down
5 changes: 3 additions & 2 deletions GameServer/quests/QuestsMgr/DataQuestRewardQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using DOL.GS.Finance;
using System.Collections.Specialized;
using System.Text;
using DOL.GS.Geometry;

namespace DOL.GS.Quests
{
Expand Down Expand Up @@ -1696,7 +1697,7 @@ public static void DQRewardQuestNotify(DOLEvent e, object sender, EventArgs args
var npc = giver as GameNPC;
player.Out.SendNPCsQuestEffect(npc, npc.GetQuestIndicator(player));
}
player.Out.SendSoundEffect(7, 0, 0, 0, 0, 0);
player.Out.SendSoundEffect(7, Position.Zero, 0);
player.Out.SendMessage("You have acquired the quest: " + dq.Name, eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow);
if (!string.IsNullOrWhiteSpace(dq.AcceptText))
{
Expand Down Expand Up @@ -1844,7 +1845,7 @@ public virtual bool FinishQuest(GameObject obj)


// TODO swap sound depending on realm
m_questPlayer.Out.SendSoundEffect(11, 0, 0, 0, 0, 0);
m_questPlayer.Out.SendSoundEffect(11, Position.Zero, 0);

if (obj is GameNPC)
{
Expand Down
5 changes: 3 additions & 2 deletions GameServer/quests/QuestsMgr/RewardQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using DOL.Language;
using DOL.GS.PacketHandler;
using DOL.GS.Finance;
using DOL.GS.Geometry;

namespace DOL.GS.Quests
{
Expand Down Expand Up @@ -226,7 +227,7 @@ public override void Notify(DOLEvent e, object sender, EventArgs args)
public override void OnQuestAssigned(GamePlayer player)
{
player.Out.SendMessage(String.Format(LanguageMgr.GetTranslation(player.Client.Account.Language, "RewardQuest.OnQuestAssigned", Name)), eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow);
player.Out.SendSoundEffect(7, 0, 0, 0, 0, 0);
player.Out.SendSoundEffect(7, Position.Zero, 0);
}

/// <summary>
Expand All @@ -239,7 +240,7 @@ public override void FinishQuest()
if (QuestPlayer.Inventory.IsSlotsFree(inventorySpaceRequired, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
{
base.FinishQuest();
QuestPlayer.Out.SendSoundEffect(11, 0, 0, 0, 0, 0);
QuestPlayer.Out.SendSoundEffect(11, Position.Zero, 0);
QuestPlayer.GainExperience(GameLiving.eXPSource.Quest, Rewards.Experience);
QuestPlayer.AddMoney(Currency.Copper.Mint(Rewards.Money));
InventoryLogging.LogInventoryAction("(QUEST;" + Name + ")", QuestPlayer, eInventoryActionType.Quest, Rewards.Money);
Expand Down
1 change: 1 addition & 0 deletions Tests/IntegrationTests/TestPacketLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ public void SendLivingDataUpdate(GameLiving living, bool updateStrings)
{
if (SendLivingDataUpdateMethod != null) SendLivingDataUpdateMethod(this, living, updateStrings);
}
public void SendSoundEffect(ushort soundId, Position position, ushort radius) { }
public Action<TestPacketLib, ushort, ushort, ushort, ushort, ushort, ushort> SendSoundEffectMethod { get; set; }
public void SendSoundEffect(ushort soundId, ushort zoneId, ushort x, ushort y, ushort z, ushort radius)
{
Expand Down

0 comments on commit 71920e0

Please sign in to comment.