Skip to content

Commit

Permalink
Rifting and Server dmg mitigation (buff)
Browse files Browse the repository at this point in the history
  • Loading branch information
FallenDev committed Dec 21, 2024
1 parent 13629c4 commit 7886368
Show file tree
Hide file tree
Showing 16 changed files with 526 additions and 60 deletions.
Binary file modified Server.Configurations/ZolianDB/ZolianAbilities.sql
Binary file not shown.
10 changes: 5 additions & 5 deletions Zolian.GameServer/Zolian.GameServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Chaos-Networking" Version="2.3.1" />
<PackageReference Include="Chaos-Networking" Version="2.3.3" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.0-preview3.24332.3" />
<PackageReference Include="Microsoft.DependencyValidation.Analyzers" Version="0.11.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Sentry" Version="5.0.0-alpha.1" />
<PackageReference Include="Sentry.Extensions.Logging" Version="5.0.0-alpha.1" />
<PackageReference Include="Sentry.Profiling" Version="5.0.0-alpha.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0-dev-02305" />
<PackageReference Include="Sentry" Version="5.0.0" />
<PackageReference Include="Sentry.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Sentry.Profiling" Version="5.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.1-dev-02308" />
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions Zolian.Server.Base/Enums/MonsterEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public enum MonsterType

/// <summary>
/// Common - 75% AC & Will Save
/// Tank - 100% AC & 30% Will Save
/// Caster - 30% AC & 100% Will Save
/// Tank - 98% AC & 50% Will Save
/// Caster - 50% AC & 98% Will Save
/// </summary>
public enum MonsterArmorType
{
Expand Down
93 changes: 90 additions & 3 deletions Zolian.Server.Base/GameScripts/Areas/Generic/Rift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@
using Darkages.Types;

using System.Collections.Concurrent;
using Darkages.Enums;
using Darkages.Object;
using Darkages.Sprites.Entity;
using Darkages.Templates;

namespace Darkages.GameScripts.Areas.Generic;

[Script("Rift")]
public class Rift : AreaScript
{
private int _monstersOnMap;
private readonly ConcurrentDictionary<long, Aisling> _playersOnMap = [];
private WorldServerTimer AnimTimer { get; }
private WorldServerTimer BossTimer { get; }
private bool _animate;

public Rift(Area area) : base(area)
{
Area = area;
AnimTimer = new WorldServerTimer(TimeSpan.FromMilliseconds(1 + 2000));
AnimTimer = new WorldServerTimer(TimeSpan.FromMilliseconds(2000));
BossTimer = new WorldServerTimer(TimeSpan.FromMilliseconds(1000));
}

public override void Update(TimeSpan elapsedTime)
Expand All @@ -30,6 +35,33 @@ public override void Update(TimeSpan elapsedTime)

if (_animate)
HandleMapAnimations(elapsedTime);

var a = BossTimer.Update(elapsedTime);
if (!a) return;
if (_playersOnMap.IsEmpty) return;
_monstersOnMap = ObjectManager.GetObjects<Monster>(Area, p => p is { Alive: true }).Count;
if (_monstersOnMap != 0) return;

var riftBossKilled = _playersOnMap.Values.FirstOrDefault(p => p.MonsterKillCounters["Rift Boss"].TotalKills >= 1);
if (riftBossKilled is not null)
{
// ToDo: Create rewards for main player who killed the boss

foreach (var player in _playersOnMap.Values)
{
player.Client.TransitionToMap(188, new Position(12, 22));
}

return;
}

var topKiller = _playersOnMap.Values.OrderByDescending(p => p.MonsterKillCounters["Rift Mob"].TotalKills).FirstOrDefault();
if (topKiller is null) return;
if (topKiller.MonsterKillCounters["Rift Mob"].TotalKills >= 20 && !topKiller.Client.SummonRiftBoss)
{
topKiller.SendTargetedClientMethod(PlayerScope.NearbyAislings, c => c.SendSound(114, true));
SummonRiftBoss(topKiller.Client);
}
}

public override void OnMapEnter(WorldClient client)
Expand All @@ -39,20 +71,25 @@ public override void OnMapEnter(WorldClient client)
client.SendSound((byte)Random.Shared.Next(119), true);
if (!_playersOnMap.IsEmpty)
_animate = true;
client.Aisling.MonsterKillCounters.Clear();
}

public override void OnMapExit(WorldClient client)
{
_playersOnMap.TryRemove(client.Aisling.Serial, out _);
client.SummonRiftBoss = false;
client.Aisling.MonsterKillCounters.Clear();

if (!_playersOnMap.IsEmpty) return;

if (!_playersOnMap.IsEmpty) return;
_animate = false;
var monsters = ObjectManager.GetObjects<Monster>(Area, p => p is { Alive: true });
foreach (var monster in monsters)
monster.Value.Remove();
}

public override void OnPlayerWalk(WorldClient client, Position oldLocation, Position newLocation) => _playersOnMap.TryAdd(client.Aisling.Serial, client.Aisling);
public override void OnPlayerWalk(WorldClient client, Position oldLocation, Position newLocation) =>
_playersOnMap.TryAdd(client.Aisling.Serial, client.Aisling);

private void HandleMapAnimations(TimeSpan elapsedTime)
{
Expand All @@ -67,4 +104,54 @@ private void HandleMapAnimations(TimeSpan elapsedTime)
_playersOnMap.Values.FirstOrDefault()?.SendAnimationNearby(384, new Position(randA, randB));
}
}

private void SummonRiftBoss(WorldClient client)
{
var sprites = new List<int>
{
12, 376, 377, 379, 380, 397, 402, 403, 404, 411, 417
};

var boss = new MonsterTemplate
{
ScriptName = "Rift",
BaseName = "Rift Boss",
Name = $"{Random.Shared.NextInt64()}RiftBoss",
AreaID = Area.ID,
Image = (ushort)sprites.RandomIEnum(),
ElementType = ElementQualifer.Defined,
OffenseElement = ElementManager.Element.Terror,
DefenseElement = ElementManager.Element.Terror,
PathQualifer = PathQualifer.Wander,
SpawnType = SpawnQualifer.Defined,
DefinedX = (ushort)client.Aisling.X,
DefinedY = (ushort)client.Aisling.Y,
SpawnSize = 1,
MoodType = MoodQualifer.Aggressive,
MonsterType = MonsterType.Boss,
MonsterArmorType = Enum.GetValues<MonsterArmorType>().RandomIEnum(),
MonsterRace = MonsterRace.Demon,
IgnoreCollision = true,
Waypoints = [],
MovementSpeed = 800,
EngagedWalkingSpeed = Random.Shared.Next(800, 1400),
AttackSpeed = Random.Shared.Next(500, 1000),
CastSpeed = Random.Shared.Next(3000, 6000),
LootType = LootQualifer.RandomGold,
Level = (ushort)(client.Aisling.ExpLevel + client.Aisling.AbpLevel + Random.Shared.Next(1, 15)),
SkillScripts = [],
AbilityScripts = [],
SpellScripts = []
};

var monster = Monster.Create(boss, Area);
if (monster == null) return;
ObjectManager.AddObject(monster);

foreach (var (serial, players) in _playersOnMap)
{
players.Client.SendServerMessage(ServerMessageType.ActiveMessage, "{=bYou have proven yourself worthy.");
players.Client.SummonRiftBoss = true;
}
}
}
12 changes: 6 additions & 6 deletions Zolian.Server.Base/GameScripts/Creations/CreateMonster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,12 +1127,12 @@ private static void MonsterStatBoostOnType(Monster obj)
},
[MonsterType.Rift] = monster =>
{
monster.BonusStr += monster._Str * 25;
monster.BonusInt += monster._Int * 25;
monster.BonusDex += monster._Dex * 25;
monster.BonusMr += monster._Mr * 25;
monster.BonusHit += monster._Hit * 25;
monster.BonusDmg += monster._Dmg * 25;
monster.BonusStr += monster._Str * 22;
monster.BonusInt += monster._Int * 22;
monster.BonusDex += monster._Dex * 22;
monster.BonusMr += monster._Mr * 22;
monster.BonusHit += monster._Hit * 22;
monster.BonusDmg += monster._Dmg * 22;
},
[MonsterType.Boss] = monster =>
{
Expand Down
120 changes: 110 additions & 10 deletions Zolian.Server.Base/GameScripts/Creations/RewardScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ public abstract class RewardScript
[(300, 349)] = null,
[(350, 399)] = ["Folt Demon Band"],
[(400, 449)] = ["Neart Fire Ring", "Fios Ice Ring"],
[(450, 500)] = ["Rioga Kings Ring"]
[(450, 500)] = ["Rioga Kings Ring"],
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected internal static readonly Dictionary<(int, int), List<string>> BeltDrops = new()
Expand Down Expand Up @@ -80,7 +90,17 @@ public abstract class RewardScript
[(300, 349)] = null,
[(350, 399)] = null,
[(400, 449)] = null,
[(450, 500)] = null
[(450, 500)] = null,
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> BootDrops = new()
Expand All @@ -106,7 +126,17 @@ public abstract class RewardScript
[(300, 349)] = null,
[(350, 399)] = null,
[(400, 449)] = null,
[(450, 500)] = null
[(450, 500)] = null,
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> EarringDrops = new()
Expand Down Expand Up @@ -146,7 +176,17 @@ public abstract class RewardScript
[(300, 349)] = ["Ruby Triforce Earrings", "Empowered Ruby Triforce Earrings"],
[(350, 399)] = ["Gold Triforce Earrings", "Empowered Gold Triforce Earrings"],
[(400, 449)] = ["Stone Studded Clips"],
[(450, 500)] = ["Rioga Orb Earrings"]
[(450, 500)] = ["Rioga Orb Earrings"],
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> GreaveDrops = new()
Expand All @@ -172,7 +212,17 @@ public abstract class RewardScript
[(300, 349)] = ["Fios Poleyns", "Dith Poleyns", "Gnimh Poleyns", "Neart Poleyns"],
[(350, 399)] = ["Fios Poleyns", "Dith Poleyns", "Gnimh Poleyns", "Neart Poleyns"],
[(400, 449)] = ["Sacra Poleyns"],
[(450, 500)] = ["Gaeth Poleyns"]
[(450, 500)] = ["Gaeth Poleyns"],
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> HandDrops = new()
Expand All @@ -198,7 +248,17 @@ public abstract class RewardScript
[(300, 349)] = ["Encrusted Graspers"],
[(350, 399)] = ["Depth Encrusted Graspers"],
[(400, 449)] = ["Heavy Depth Encrusted Graspers"],
[(450, 500)] = ["Flawless Depth Graspers"]
[(450, 500)] = ["Flawless Depth Graspers"],
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> NecklaceDrops = new()
Expand Down Expand Up @@ -256,7 +316,17 @@ public abstract class RewardScript
[(300, 349)] = null,
[(350, 399)] = null,
[(400, 449)] = null,
[(450, 500)] = null
[(450, 500)] = null,
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> OffHandDrops = new()
Expand All @@ -282,7 +352,17 @@ public abstract class RewardScript
[(300, 349)] = null,
[(350, 399)] = null,
[(400, 449)] = null,
[(450, 500)] = null
[(450, 500)] = null,
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected internal static readonly Dictionary<(int, int), List<string>> ShieldDrops = new()
Expand Down Expand Up @@ -344,7 +424,17 @@ public abstract class RewardScript
[(300, 349)] = null,
[(350, 399)] = null,
[(400, 449)] = null,
[(450, 500)] = null
[(450, 500)] = null,
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

protected static readonly Dictionary<(int, int), List<string>> WristDrops = new()
Expand All @@ -370,7 +460,17 @@ public abstract class RewardScript
[(300, 349)] = ["Golden Talon Gauntlet"],
[(350, 399)] = null,
[(400, 449)] = null,
[(450, 500)] = null
[(450, 500)] = null,
[(501, 550)] = null,
[(551, 600)] = null,
[(601, 650)] = null,
[(651, 700)] = null,
[(701, 750)] = null,
[(751, 800)] = null,
[(801, 850)] = null,
[(851, 900)] = null,
[(901, 950)] = null,
[(951, 1000)] = null
};

// Reward based on Monster level
Expand Down
4 changes: 2 additions & 2 deletions Zolian.Server.Base/GameScripts/Formulas/Ac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public override long Calculate(Sprite obj, long value)
{
dmgMitigation = monster.Template.MonsterArmorType switch
{
MonsterArmorType.Caster when dmgMitigation >= 0.90f => 0.90f,
MonsterArmorType.Common when dmgMitigation >= 0.95f => 0.95f,
MonsterArmorType.Caster when dmgMitigation >= 0.50f => 0.50f,
MonsterArmorType.Common when dmgMitigation >= 0.75f => 0.75f,
MonsterArmorType.Tank when dmgMitigation >= 0.98f => 0.98f,
_ => dmgMitigation
};
Expand Down
Loading

0 comments on commit 7886368

Please sign in to comment.