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
9 changes: 2 additions & 7 deletions Maple2.Database/Model/CharacterConfig.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Maple2.Database.Extensions;
using Maple2.Database.Extensions;
using Maple2.Model.Enum;
using Maple2.Model.Game;
using Microsoft.EntityFrameworkCore;
Expand All@@ -23,8 +19,7 @@ internal class CharacterConfig {
public IList<int>? FavoriteStickers { get; set; }
public IList<long>? FavoriteDesigners { get; set; }
public IDictionary<LapenshardSlot, int>? Lapenshards { get; set; }
public long DeathTick { get; set; }
public int DeathCount { get; set; }
public int InstantRevivalCount { get; set; }
public IDictionary<int, int>? GatheringCounts { get; set; }
public IDictionary<int, int>? GuideRecords { get; set; }
public int ExplorationProgress { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Maple2.Database/Storage/Game/GameStorage.ServerInfo.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,6 +32,7 @@ public void DailyReset() {
Context.Database.ExecuteSqlRaw("UPDATE `account` SET `PrestigeLevelsGained` = DEFAULT");
Context.Database.ExecuteSqlRaw("UPDATE `account` SET `PremiumRewardsClaimed` = DEFAULT");
Context.Database.ExecuteSqlRaw("UPDATE `character-config` SET `GatheringCounts` = DEFAULT");
Context.Database.ExecuteSqlRaw("UPDATE `character-config` SET `InstantRevivalCount` = 0");
Context.Database.ExecuteSqlRaw("UPDATE `nurturing` SET `PlayedBy` = '[]'");
Context.Database.ExecuteSqlRaw("UPDATE `home` SET `DecorationRewardTimestamp` = 0");
// TODO: Death counter
Expand Down
14 changes: 5 additions & 9 deletions Maple2.Database/Storage/Game/GameStorage.User.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -310,11 +310,11 @@ public bool SaveCharacter(Character character) {
}

public (IList<KeyBind>? KeyBinds, IList<QuickSlot[]>? HotBars, List<SkillMacro>?, List<Wardrobe>?, List<int>? FavoriteStickers, List<long>? FavoriteDesigners,
IDictionary<LapenshardSlot, int>? Lapenshards, long DeathTick, int DeathCount, int ExplorationProgress, IDictionary<AttributePointSource, int>?,
IDictionary<LapenshardSlot, int>? Lapenshards, int InstantRevivalCount, int ExplorationProgress, IDictionary<AttributePointSource, int>?,
IDictionary<BasicAttribute, int>?, SkillPoint? SkillPoint, IDictionary<int, int>? GatheringCounts, IDictionary<int, int>? GuideRecords, SkillBook?) LoadCharacterConfig(long characterId) {
CharacterConfig? config = Context.CharacterConfig.Find(characterId);
if (config == null) {
return (null, null, null, null, null, null, null, 0, 0, 0, null, null, null, null, null, null);
return (null, null, null, null, null, null, null, 0, 0, null, null, null, null, null, null);
}

SkillBook? skillBook = config.SkillBook == null ? null : new SkillBook {
Expand DownExpand Up@@ -344,8 +344,7 @@ public bool SaveCharacter(Character character) {
config.FavoriteStickers?.Select(stickers => stickers).ToList(),
config.FavoriteDesigners?.Select(designer => designer).ToList(),
config.Lapenshards,
config.DeathTick,
config.DeathCount,
config.InstantRevivalCount,
config.ExplorationProgress,
config.StatPoints,
config.StatAllocation,
Expand All@@ -365,9 +364,7 @@ public bool SaveCharacterConfig(
IList<int> favoriteStickers,
IList<long> favoriteDesigners,
IDictionary<LapenshardSlot, int> lapenshards,
IList<SkillCooldown> skillCooldowns,
long deathTick,
int deathCount,
int instantRevivalCount,
int explorationProgress,
StatAttributes.PointAllocation allocation,
StatAttributes.PointSources statSources,
Expand All@@ -389,8 +386,7 @@ public bool SaveCharacterConfig(
config.FavoriteStickers = favoriteStickers;
config.FavoriteDesigners = favoriteDesigners;
config.Lapenshards = lapenshards;
config.DeathTick = deathTick;
config.DeathCount = deathCount;
config.InstantRevivalCount = instantRevivalCount;
config.ExplorationProgress = explorationProgress;
config.StatAllocation = allocation.Attributes.ToDictionary(
attribute => attribute,
Expand Down
2 changes: 1 addition & 1 deletion Maple2.File.Ingest/Maple2.File.Ingest.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="Crc32.NET" Version="1.2.0" />
<PackageReference Include="CsvHelper" Version="32.0.2" />
<PackageReference Include="Maple2.File.Parser.Tadeucci" Version="2.2.4" />
<PackageReference Include="Maple2.File.Parser.Tadeucci" Version="2.2.6" />
<PackageReference Include="DotRecast.Core" Version="2024.2.3" />
<PackageReference Include="DotRecast.Detour" Version="2024.2.3" />
<PackageReference Include="DotRecast.Recast" Version="2024.2.3" />
Expand Down
2 changes: 1 addition & 1 deletion Maple2.File.Ingest/Mapper/MapMapper.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ protected override IEnumerable<MapMetadata> Map() {
TutorialType: data.property.tutorialType,
RevivalReturnId: data.property.revivalreturnid,
EnterReturnId: data.property.enterreturnid,
AutoRevivalType: data.property.autoRevivalType,
AutoRevivalType: (AutoReviveType) data.property.autoRevivalType,
AutoRevivalTime: data.property.autoRevivalTime,
InfiniteMeretRevival: data.property.infinityMeratRevival,
NoRevivalHere: data.property.doNotRevivalHere,
Expand Down
7 changes: 5 additions & 2 deletions Maple2.File.Ingest/Mapper/ServerTableMapper.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,6 +148,7 @@ private Dictionary<int, Dictionary<int, ScriptConditionMetadata>> MergeNpcScript
Meso: ParseToIntKeyValuePair(scriptCondition.meso),
Level: ParseToIntKeyValuePair(scriptCondition.level),
AchieveCompleted: ParseToIntKeyValuePair(scriptCondition.achieve_complete),
DeathPenalty: scriptCondition.panelty == 1,
InGuild: scriptCondition.guild
));
}
Expand DownExpand Up@@ -210,7 +211,8 @@ private Dictionary<int, Dictionary<int, ScriptConditionMetadata>> MergeQuestScri
Meso: ParseToIntKeyValuePair(scriptCondition.meso),
Level: ParseToIntKeyValuePair(scriptCondition.level),
AchieveCompleted: ParseToIntKeyValuePair(scriptCondition.achieve_complete),
InGuild: scriptCondition.guild
InGuild: scriptCondition.guild,
DeathPenalty: scriptCondition.panelty == 1
));
}
results.Add(questId, scriptConditions);
Expand DownExpand Up@@ -391,7 +393,8 @@ private JobConditionTable ParseJobCondition() {
ChangeToJobCode: (JobCode) jobCondition.jobCode,
MapId: jobCondition.map,
MoveMapId: jobCondition.moveFieldID,
MovePortalId: jobCondition.movePortalID
MovePortalId: jobCondition.movePortalID,
DeathPenalty: jobCondition.panelty
));
}

Expand Down
1 change: 1 addition & 0 deletions Maple2.File.Ingest/MapperExtensions.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -327,6 +327,7 @@ public static BeginCondition Convert(this Maple2.File.Parser.Xml.Skill.BeginCond
CooldownTime: beginCondition.cooldownTime,
OnlyShadowWorld: beginCondition.onlyShadowWorld || beginCondition.isShadowWorld,
OnlyFlyableMap: beginCondition.onlyFlyableMap,
AllowDead: beginCondition.allowDeadState,
Weapon: beginCondition.weapon.Select(weapon => new BeginConditionWeapon(
new ItemType(1, (byte) weapon.lh),
new ItemType(1, (byte) weapon.rh))).ToArray(),
Expand Down
7 changes: 7 additions & 0 deletions Maple2.Model/Enum/Death.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
namespace Maple2.Model.Enum;

public enum DeathState : short {
Alive = 0,
FirstDeath = 1,
Metal = 2,
}
6 changes: 6 additions & 0 deletions Maple2.Model/Enum/Map.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,3 +47,9 @@ public enum Continent {
Kritias = 105,
ShadowWorld = 202,
}

public enum AutoReviveType {
None = 0,
Trigger = 1,
Countdown = 2, // Only map 65000003 - Treasure Island. Uses autoRevivalTime
}
4 changes: 3 additions & 1 deletion Maple2.Model/Game/User/Character.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,6 @@ public class Character {
public long StorageCooldown;
public long DoctorCooldown;

public int ReviveMapId;
public int ReturnMapId;
public Vector3 ReturnPosition;
public string Picture = string.Empty;
Expand All@@ -50,5 +49,8 @@ public class Character {
public AchievementInfo AchievementInfo;
public MarriageInfo MarriageInfo;
public readonly Dictionary<int, DungeonEnterLimit> DungeonEnterLimits = [];
public short DeathCount;
public long DeathTick;
public DeathState DeathState;
public long PremiumTime;
}
1 change: 1 addition & 0 deletions Maple2.Model/Game/User/IPlayerInfo.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ public interface IPlayerInfo {
// Health
public long CurrentHp { get; set; }
public long TotalHp { get; set; }
public DeathState DeathState { get; set; }
// Location
public int MapId { get; set; }
public short Channel { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions Maple2.Model/Game/User/PlayerInfo.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,9 +62,9 @@ public void WriteTo(IByteWriter writer) {
writer.WriteShort(Channel);
writer.WriteInt((int) Job.Code());
writer.Write<Job>(Job);
writer.WriteInt((int) CurrentHp);
writer.WriteInt((int) TotalHp);
writer.WriteShort();
writer.WriteInt((int) CurrentHp);
writer.Write<DeathState>(DeathState);
writer.WriteLong();
writer.WriteLong(); // Home Storage Access Time
writer.WriteLong(); // Home Doctor Access Time
Expand DownExpand Up@@ -123,6 +123,7 @@ public class CharacterInfo {
// Health
public long CurrentHp { get; set; }
public long TotalHp { get; set; }
public DeathState DeathState { get; set; }
// Location
public int MapId { get; set; }
public short Channel { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Maple2.Model/Metadata/BeginCondition.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,7 @@ public record BeginCondition(
float CooldownTime,
bool OnlyShadowWorld,
bool OnlyFlyableMap,
bool AllowDead,
IReadOnlyDictionary<BasicAttribute, long> Stat,
BeginConditionWeapon[]? Weapon,
BeginConditionTarget? Target,
Expand Down
2 changes: 2 additions & 0 deletions Maple2.Model/Metadata/Constants.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -928,6 +928,8 @@ public static class Constant {
public const int NextStateTriggerDefaultTick = 100;
public const int UserRevivalPaneltyTick = 3600000;
public const int UserRevivalPaneltyMinLevel = 10;
public const int maxDeadCount = 3;
public const byte hitPerDeadCount = 5;
public const int FishFightingProp = 3000;

public const float NpcLastSightRadius = 1800;
Expand Down
2 changes: 1 addition & 1 deletion Maple2.Model/Metadata/MapMetadata.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@ public record MapMetadataProperty(
int TutorialType,
int RevivalReturnId,
int EnterReturnId,
int AutoRevivalType,
AutoReviveType AutoRevivalType,
int AutoRevivalTime,
bool InfiniteMeretRevival,
bool NoRevivalHere,
Expand Down
1 change: 1 addition & 0 deletions Maple2.Model/Metadata/ServerTable/JobConditionTable.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,4 +26,5 @@ public record JobConditionMetadata(
JobCode ChangeToJobCode,
int MapId,
int MoveMapId,
bool DeathPenalty,
int MovePortalId);
1 change: 1 addition & 0 deletions Maple2.Model/Metadata/ServerTable/ScriptConditionTable.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,7 @@ public record ScriptConditionMetadata(
KeyValuePair<int, bool> Meso,
KeyValuePair<int, bool> Level,
KeyValuePair<int, bool> AchieveCompleted,
bool DeathPenalty,
bool InGuild) {

public record MaidData(
Expand Down
10 changes: 7 additions & 3 deletions Maple2.Server.Core/Sync/PlayerInfoUpdateEvent.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,12 +19,13 @@ public enum UpdateField {
PremiumTime = 512,
Clubs = 1024,
Dungeon = 2048,
Death = 4096,

// Presets
Buddy = Profile | Job | Level | Map | Channel | Home | Trophy,
Guild = Profile | Job | Level | GearScore | Map | Channel | Home | Trophy | Clubs,
Club = Profile | Job | Level | GearScore | Map | Channel | Home | Trophy | Clubs,
Party = Profile | Job | Level | GearScore | Health | Map | Channel | Home | Clubs | Dungeon,
Party = Profile | Job | Level | GearScore | Health | Map | Channel | Home | Clubs | Dungeon | Death,
GroupChat = Profile | Job | Level | Map | Channel | Home | Clubs,
Marriage = Profile,
All = int.MaxValue,
Expand DownExpand Up@@ -77,6 +78,9 @@ public PlayerInfoUpdateEvent(IPlayerInfo player, PlayerUpdateRequest request) {
Type |= UpdateField.Health;
}
}
if (request.HasDeathState && player.DeathState != (DeathState) request.DeathState) {
Type |= UpdateField.Death;
}
if (request.Home != null) {
if (player.PlotMapId != request.Home.MapId) {
Type |= UpdateField.Home;
Expand DownExpand Up@@ -106,13 +110,13 @@ public PlayerInfoUpdateEvent(IPlayerInfo player, PlayerUpdateRequest request) {
}
}

if (request.Clubs != null) {
if (request.Clubs.Count > 0) {
if (player.ClubIds != request.Clubs.Select(club => club.Id).ToList()) {
Type |= UpdateField.Clubs;
}
}

if (request.DungeonEnterLimits != null) {
if (request.DungeonEnterLimits.Count > 0) {
if (player.DungeonEnterLimits != request.DungeonEnterLimits.Select(dungeon => new KeyValuePair<int, DungeonEnterLimit>(dungeon.DungeonId, (DungeonEnterLimit) dungeon.Limit)).ToDictionary()) {
Type |= UpdateField.Dungeon;
}
Expand Down
9 changes: 9 additions & 0 deletions Maple2.Server.Core/Sync/PlayerInfoUpdateExtensions.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,9 @@ public static void Update(this IPlayerInfo info, PlayerInfoUpdateEvent update) {
info.CurrentHp = update.Request.Health.CurrentHp;
info.TotalHp = update.Request.Health.TotalHp;
}
if (update.Type.HasFlag(UpdateField.Death) && update.Request.HasDeathState) {
info.DeathState = (DeathState) update.Request.DeathState;
}
if (update.Type.HasFlag(UpdateField.Home) && update.Request.Home != null) {
info.HomeName = update.Request.Home.Name;
info.PlotMapId = update.Request.Home.MapId;
Expand DownExpand Up@@ -102,6 +105,9 @@ public static void Update(this IPlayerInfo self, UpdateField type, IPlayerInfo o
self.CurrentHp = other.CurrentHp;
self.TotalHp = other.TotalHp;
}
if (type.HasFlag(UpdateField.Death)) {
self.DeathState = other.DeathState;
}
if (type.HasFlag(UpdateField.Home)) {
self.HomeName = other.HomeName;
self.PlotMapId = other.PlotMapId;
Expand DownExpand Up@@ -156,6 +162,9 @@ public static void SetFields(this PlayerUpdateRequest request, UpdateField type,
TotalHp = info.TotalHp,
};
}
if (type.HasFlag(UpdateField.Death)) {
request.DeathState = (int) info.DeathState;
}
if (type.HasFlag(UpdateField.Home)) {
request.Home = new HomeUpdate {
Name = info.HomeName,
Expand Down
4 changes: 3 additions & 1 deletion Maple2.Server.Core/proto/sync.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,9 +65,10 @@ message PlayerUpdateRequest {
optional TrophyUpdate trophy = 19;
repeated ClubUpdate clubs = 20;
repeated DungeonEnterLimitUpdate dungeon_enter_limits = 21;
optional int32 death_state = 22;

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

message PlayerUpdateResponse {
Expand DownExpand Up@@ -100,4 +101,5 @@ message PlayerInfoResponse {
TrophyUpdate trophy = 19;
repeated ClubUpdate clubs = 20;
repeated DungeonEnterLimitUpdate dungeon_enter_limits = 21;
int32 death_state = 22;
}
10 changes: 9 additions & 1 deletion Maple2.Server.Core/proto/world/world.proto
Original file line numberDiff line numberDiff line change
Expand Up@@ -528,12 +528,13 @@ message PlayerConfigRequest {
message Save {
repeated BuffInfo buffs = 1;
repeated SkillCooldownInfo skill_cooldowns = 2;
DeathInfo death_info = 3;
}

message Get { }

int64 requester_id = 1;
oneof buff {
oneof player_config {
Save save = 2;
Get get = 3;
}
Expand All@@ -542,6 +543,7 @@ message PlayerConfigRequest {
message PlayerConfigResponse {
repeated BuffInfo buffs = 1;
repeated SkillCooldownInfo skill_cooldowns = 2;
DeathInfo death_info = 3;
}

message BuffInfo {
Expand All@@ -561,3 +563,9 @@ message SkillCooldownInfo {
int64 stop_time = 5;
int32 charges = 6;
}

message DeathInfo {
int32 count = 1;
int32 ms_remaining = 2;
int64 stop_time = 3;
}
Loading