Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Maple2.Model/Game/User/IPlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public interface IPlayerInfo {
public AchievementInfo AchievementInfo { get; set; }
// Dungeon
public Dictionary<int, DungeonEnterLimit> DungeonEnterLimits { get; set; }
// Guild
public long GuildId { get; set; }
public string GuildName { get; set; }

// Timestamp
public long UpdateTime { get; set; }
Expand Down
19 changes: 13 additions & 6 deletions Maple2.Model/Game/User/PlayerInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Numerics;
using System.Numerics;
using Maple2.Model.Common;
using Maple2.Model.Enum;
using Maple2.PacketLib.Tools;
Expand Down Expand Up @@ -34,6 +31,8 @@ public static implicit operator PlayerInfo(Player player) {
PremiumTime = player.Character.PremiumTime,
LastOnlineTime = player.Character.LastOnlineTime,
DungeonEnterLimits = [],
GuildId = player.Character.GuildId,
GuildName = player.Character.GuildName,
};
}

Expand Down Expand Up @@ -75,8 +74,8 @@ public void WriteTo(IByteWriter writer) {
writer.Write<SkinColor>(default);
writer.WriteLong();
writer.Write<AchievementInfo>(default);
writer.WriteLong(); // Guild Id
writer.WriteUnicodeString(); // Guild Name
writer.WriteLong(GuildId);
writer.WriteUnicodeString(GuildName);
writer.WriteUnicodeString(Motto);
writer.WriteUnicodeString(Picture);
writer.WriteByte((byte) ClubIds.Count);
Expand Down Expand Up @@ -129,6 +128,10 @@ public class CharacterInfo {
public short Channel { get; set; }
public long LastOnlineTime { get; set; }

// Guild
public long GuildId { get; set; }
public string GuildName { get; set; }

public long UpdateTime { get; set; }
public bool Online => Channel != 0;

Expand All @@ -155,6 +158,8 @@ public CharacterInfo(CharacterInfo other) {
MapId = other.MapId;
Channel = other.Channel;
LastOnlineTime = other.LastOnlineTime;
GuildId = other.GuildId;
GuildName = other.GuildName;
}

public static implicit operator CharacterInfo(Player player) {
Expand All @@ -169,6 +174,8 @@ public static implicit operator CharacterInfo(Player player) {
level: player.Character.Level) {
MapId = player.Character.MapId,
Channel = player.Character.Channel,
GuildId = player.Character.GuildId,
GuildName = player.Character.GuildName,
};
}
}
4 changes: 4 additions & 0 deletions Maple2.Server.Core/Sync/PlayerInfoUpdateEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public PlayerInfoUpdateEvent(IPlayerInfo player, PlayerUpdateRequest request) {
Type |= UpdateField.Profile;
} else if (request.HasGender && player.Gender != (Gender) request.Gender) {
Type |= UpdateField.Profile;
} else if (request.HasGuildId && player.GuildId != request.GuildId) {
Type |= UpdateField.Profile;
} else if (request.HasGuildName && player.GuildName != request.GuildName) {
Type |= UpdateField.Profile;
}
if (request.HasJob && player.Job != (Job) request.Job) {
Type |= UpdateField.Job;
Expand Down
4 changes: 4 additions & 0 deletions Maple2.Server.Core/Sync/PlayerInfoUpdateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public static void Update(this IPlayerInfo self, UpdateField type, IPlayerInfo o
self.Name = other.Name;
self.Motto = other.Motto;
self.Picture = other.Picture;
self.GuildId = other.GuildId;
self.GuildName = other.GuildName;
}
if (type.HasFlag(UpdateField.Job)) {
self.Job = other.Job;
Expand Down Expand Up @@ -124,6 +126,8 @@ public static void SetFields(this PlayerUpdateRequest request, UpdateField type,
request.Motto = info.Motto;
request.Picture = info.Picture;
request.LastOnlineTime = info.LastOnlineTime;
request.GuildId = info.GuildId;
request.GuildName = info.GuildName;
}
if (type.HasFlag(UpdateField.Job)) {
request.Job = (int) info.Job;
Expand Down
26 changes: 15 additions & 11 deletions Maple2.Server.Core/proto/sync.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ message PlayerUpdateRequest {
optional int32 channel = 12;
optional int64 premium_time = 13;
optional int64 last_online_time = 14;
optional HealthUpdate health = 15;
optional HomeUpdate home = 16;
optional TrophyUpdate trophy = 17;
repeated ClubUpdate clubs = 18;
repeated DungeonEnterLimitUpdate dungeon_enter_limits = 19;
optional int64 guild_id = 15;
optional string guild_name = 16;
optional HealthUpdate health = 17;
optional HomeUpdate home = 18;
optional TrophyUpdate trophy = 19;
repeated ClubUpdate clubs = 20;
repeated DungeonEnterLimitUpdate dungeon_enter_limits = 21;

// Batch updates in a queue rather than immediately forwarding.
bool async = 20;
bool async = 22;
}

message PlayerUpdateResponse {
Expand All @@ -91,9 +93,11 @@ message PlayerInfoResponse {
int64 last_online_time = 12;
int32 map_id = 13;
int32 channel = 14;
HealthUpdate health = 15;
HomeUpdate home = 16;
TrophyUpdate trophy = 17;
repeated ClubUpdate clubs = 18;
repeated DungeonEnterLimitUpdate dungeon_enter_limits = 19;
int64 guild_id = 15;
string guild_name = 16;
HealthUpdate health = 17;
HomeUpdate home = 18;
TrophyUpdate trophy = 19;
repeated ClubUpdate clubs = 20;
repeated DungeonEnterLimitUpdate dungeon_enter_limits = 21;
}
4 changes: 4 additions & 0 deletions Maple2.Server.Game/Manager/PartyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ public void SetDungeon(int dungeonId, int dungeonRoomId, bool set) {
session.Send(PartyPacket.DungeonReset(set, dungeonId));
}

public int GuildMemberCount() {
return Party?.Members.Values.Count(member => member.Info.GuildId == session.Player.Value.Character.GuildId) ?? 0;
}

public void SetPartySearch(PartySearch? partySearch) {
if (Party == null) {
return;
Expand Down
5 changes: 3 additions & 2 deletions Maple2.Server.Game/Manager/QuestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ public void Update(ConditionType type, long counter = 1, string targetString = "
.Concat(accountValues.Values.Where(quest => quest.State != QuestState.Completed));
foreach (Quest quest in quests) {
// TODO: Not sure if ProgressMap really means that only progress counts in this map. It doesn't make sense for some quests.
/*if (quest.Metadata.Basic.ProgressMaps != null && !quest.Metadata.Basic.ProgressMaps.Contains(session.Player.Value.Character.MapId)) {
// Testing only on FieldMission for now.
if (quest.Metadata.Basic.Type == QuestType.FieldMission && quest.Metadata.Basic.ProgressMaps != null && !quest.Metadata.Basic.ProgressMaps.Contains(session.Player.Value.Character.MapId)) {
continue;
}*/
}

foreach (Quest.Condition condition in quest.Conditions.Values.Where(condition => condition.Metadata.Type == type)) {
// Already meets the requirement and does not need to be updated
Expand Down
1 change: 1 addition & 0 deletions Maple2.Server.Game/Manager/StatsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private void AddEquips(FieldPlayer player) {
Log.Logger.Debug("Calculating Gearscore. Item ID: {id} - Gearscore: {gearscore} - Rarity: {rarity}, Enchant Level: {enchantLevel}, Limit Break Level: {limitBreakLevel}", item.Metadata.Id, item.Metadata.Property.GearScore, item.Rarity, item.Enchant?.Enchants ?? 0, item.LimitBreak?.Level ?? 0);
Values.GearScore += player.Field.Lua.CalcItemLevel(item.Metadata.Property.GearScore, item.Rarity, item.Type.Type, item.Enchant?.Enchants ?? 0, item.LimitBreak?.Level ?? 0).Item1;
player.Session.Dungeon.UpdateDungeonEnterLimit();
player.Session.ConditionUpdate(ConditionType.item_gear_score, counter: Values.GearScore);

if (item.Socket != null) {
for (int index = 0; index < item.Socket.UnlockSlots; index++) {
Expand Down
8 changes: 8 additions & 0 deletions Maple2.Server.Game/PacketHandlers/InstrumentHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ private void HandleStartScore(GameSession session, IByteReader packet) {
}
session.Instrument.Score = score;

session.ConditionUpdate(ConditionType.music_play_score, codeLong: score.Id, targetLong: session.Field.MapId);

score.RemainUses--;
session.Field.Broadcast(InstrumentPacket.StartScore(session.Instrument, score));
session.Send(InstrumentPacket.RemainUses(score.Uid, score.RemainUses));
Expand Down Expand Up @@ -170,6 +172,11 @@ private void HandleStopScore(GameSession session) {
// Modifier is the number of 500ms ticks that have passed.
session.Exp.AddExp(expType, (totalTickTime - 500) / 500);

session.ConditionUpdate(ConditionType.music_play_instrument_time, counter: totalTickTime / 1000, targetLong: session.Field.MapId, codeLong: session.Instrument.Value.Id);
if (session.Instrument.Ensemble) {
session.ConditionUpdate(ConditionType.play_ensenble_time, counter: totalTickTime / 1000, targetLong: session.Field.MapId);
}

session.Field.RemoveInstrument(session.Instrument.ObjectId);
session.Instrument = null;
}
Expand Down Expand Up @@ -214,6 +221,7 @@ private void HandleJoinEnsemble(GameSession session, IByteReader packet) {
memberSession.Field.Broadcast(InstrumentPacket.StartScore(memberSession.Instrument, memberSession.StagedScoreItem));
memberSession.Send(InstrumentPacket.RemainUses(memberSession.StagedScoreItem.Uid, memberSession.StagedScoreItem.RemainUses));
memberSession.ConditionUpdate(ConditionType.music_play_ensemble);
memberSession.ConditionUpdate(ConditionType.music_play_ensemble_in, codeLong: memberSession.Field.MapId, targetLong: memberSession.Field.MapId);
}
}

Expand Down
12 changes: 9 additions & 3 deletions Maple2.Server.Game/Session/GameSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,15 @@ public bool EnterField() {
return false;
}

if (!Player.Value.Unlock.Maps.Contains(Player.Value.Character.MapId) && Field.Metadata.Property.ExploreType > 0) {
ExpType expType = Field.Metadata.Property.ExploreType == 1 ? ExpType.mapCommon : ExpType.mapHidden;
Exp.AddExp(expType);
if (!Player.Value.Unlock.Maps.Contains(Player.Value.Character.MapId)) {
if (Field.Metadata.Property.ExploreType > 0) {
ExpType expType = Field.Metadata.Property.ExploreType == 1 ? ExpType.mapCommon : ExpType.mapHidden;
Exp.AddExp(expType);
}

ConditionUpdate(ConditionType.explore_continent, codeLong: (int) Field.Metadata.Property.Continent);
ConditionUpdate(ConditionType.continent, codeLong: (int) Field.Metadata.Property.Continent);
ConditionUpdate(ConditionType.explore, codeLong: Field.MapId);
}

Player.Value.Unlock.Maps.Add(Player.Value.Character.MapId);
Expand Down
25 changes: 25 additions & 0 deletions Maple2.Server.Game/Util/ConditionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ namespace Maple2.Server.Game.Util;

public static class ConditionUtil {
public static bool Check(this ConditionMetadata condition, GameSession session, string targetString = "", long targetLong = 0, string codeString = "", long codeLong = 0) {
if (condition.PartyCount > 0) {
if (session.Party.Party == null || session.Party.Party.Members.Count < condition.PartyCount) {
return false;
}
}

if (condition.GuildPartyCount > 0) {
if (session.Party.Party == null || session.Party.GuildMemberCount() < condition.GuildPartyCount) {
return false;
}
}
bool code = condition.Codes == null || condition.Codes.CheckCode(session, condition.Type, codeString, codeLong);
bool target = condition.Target == null || condition.Target.CheckTarget(session, condition.Type, targetString, targetLong);
return target && code;
Expand Down Expand Up @@ -97,6 +108,12 @@ private static bool CheckCode(this ConditionMetadata.Parameters code, GameSessio
case ConditionType.holdtime:
case ConditionType.riding:
case ConditionType.fish_big:
case ConditionType.music_play_instrument_time:
case ConditionType.music_play_ensemble_in:
case ConditionType.music_play_score:
case ConditionType.explore_continent:
case ConditionType.continent:
case ConditionType.explore:
if (code.Range != null && InRange((ConditionMetadata.Range<int>) code.Range, (int) longValue)) {
return true;
}
Expand Down Expand Up @@ -141,6 +158,7 @@ private static bool CheckCode(this ConditionMetadata.Parameters code, GameSessio
case ConditionType.wedding_propose_decline:
case ConditionType.wedding_propose_declined:
case ConditionType.wedding_hall_cancel:
case ConditionType.item_gear_score:
return true;
}
return false;
Expand Down Expand Up @@ -196,6 +214,9 @@ private static bool CheckTarget(this ConditionMetadata.Parameters target, GameSe
case ConditionType.holdtime:
case ConditionType.riding:
case ConditionType.skill:
case ConditionType.music_play_instrument_time:
case ConditionType.music_play_score:
case ConditionType.music_play_ensemble_in:
if (target.Range != null && target.Range.Value.Min >= longValue &&
target.Range.Value.Max <= longValue) {
return true;
Expand Down Expand Up @@ -263,6 +284,10 @@ private static bool CheckTarget(this ConditionMetadata.Parameters target, GameSe
case ConditionType.wedding_propose_decline:
case ConditionType.wedding_propose_declined:
case ConditionType.wedding_hall_cancel:
case ConditionType.explore_continent:
case ConditionType.continent:
case ConditionType.explore:
case ConditionType.item_gear_score:
return true;
}
return false;
Expand Down