New Game-Server configs, lots of improvements to items, actors (player, monster, bosses), quests, etc

This commit is contained in:
Lucca Faria Ferri 2023-01-29 04:44:31 -08:00
parent 976f448152
commit 734f35d611
35 changed files with 695 additions and 692 deletions

View File

@ -266,7 +266,7 @@ namespace DiIiS_NA.LoginServer.Battle
if (method.Name == "KeepAlive") if (method.Name == "KeepAlive")
{ {
Logger.Debug( Logger.Debug(
$"Call: $[olive]{service.GetType().Name}$[/]$, Service hash: $[olive]{header.ServiceHash}$[/]$, Method: $[olive]{method.Name}$[/]$, ID: $[olive]{header.MethodId}$[/]$"); $"Call: $[olive]${service.GetType().Name}$[/]$, Service hash: $[olive]${header.ServiceHash}$[/]$, Method: $[olive]${method.Name}$[/]$, ID: $[olive]${header.MethodId}$[/]$");
} }
else else
{ {

View File

@ -77,9 +77,9 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
const int seasonState = 1; const int seasonState = 1;
const int leaderboardEra = 1; const int leaderboardEra = 1;
const int anniversaryEventStatus = 1; const int anniversaryEventStatus = 1;
const int challangeRiftNumber = 1; const int challengeRiftNumber = 1;
const bool freeToPlay = true; const bool freeToPlay = true;
const bool storeStatus = true; // false const bool storeStatus = false; // false
const string catalogDigest = "C42DC6117A7008EDA2006542D6C07EAD096DAD90"; const string catalogDigest = "C42DC6117A7008EDA2006542D6C07EAD096DAD90";
const string catalogVersion = "633565800390338000"; const string catalogVersion = "633565800390338000";
const int regionId = 1; const int regionId = 1;
@ -89,7 +89,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
$" OnlineService.Season.State={seasonState}" + //Season status, 1 - Activated, 0 - Deactivated $" OnlineService.Season.State={seasonState}" + //Season status, 1 - Activated, 0 - Deactivated
$" OnlineService.Leaderboard.Era={leaderboardEra}" + $" OnlineService.Leaderboard.Era={leaderboardEra}" +
$" OnlineService.AnniversaryEvent.Status={anniversaryEventStatus}" + //Anniversary Event, 1st Old Tristam $" OnlineService.AnniversaryEvent.Status={anniversaryEventStatus}" + //Anniversary Event, 1st Old Tristam
$" ChallengeRift.ChallengeNumber={challangeRiftNumber}" + //Rift portal number. $" ChallengeRift.ChallengeNumber={challengeRiftNumber}" + //Rift portal number.
$" OnlineService.FreeToPlay={freeToPlay}" + //Shop for Platinum $" OnlineService.FreeToPlay={freeToPlay}" + //Shop for Platinum
$" OnlineService.Store.Status={(storeStatus ? "1" : "0")}" + //Store Status, 0 - Enabled, 1 - Disabled $" OnlineService.Store.Status={(storeStatus ? "1" : "0")}" + //Store Status, 0 - Enabled, 1 - Disabled
$" OnlineService.Store.ProductCatalogDigest={catalogDigest}" + //China $" OnlineService.Store.ProductCatalogDigest={catalogDigest}" + //China

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Spectre.Console; using Spectre.Console;
@ -93,6 +94,8 @@ public class AnsiTarget : LogTarget
{ {
if (CancellationTokenSource.IsCancellationRequested) if (CancellationTokenSource.IsCancellationRequested)
return; return;
try
{
if (IncludeTimeStamps) if (IncludeTimeStamps)
_table.AddRow( _table.AddRow(
new Markup(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"), GetStyleByLevel(level)), new Markup(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"), GetStyleByLevel(level)),
@ -107,25 +110,41 @@ public class AnsiTarget : LogTarget
new Markup(Cleanup(message), GetStyleByLevel(level)).LeftJustified(), new Markup(Cleanup(message), GetStyleByLevel(level)).LeftJustified(),
new Markup("", new Style(foreground: Color.Green3_1)).Centered()); new Markup("", new Style(foreground: Color.Green3_1)).Centered());
} }
catch (Exception ex)
{
Debugger.Break();
}
}
public override void LogException(Logger.Level level, string logger, string message, Exception exception) public override void LogException(Logger.Level level, string logger, string message, Exception exception)
{ {
if (CancellationTokenSource.IsCancellationRequested) if (CancellationTokenSource.IsCancellationRequested)
return; return;
try
{
if (IncludeTimeStamps) if (IncludeTimeStamps)
_table.AddRow( _table.AddRow(
new Markup(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"), GetStyleByLevel(level)), new Markup(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"), GetStyleByLevel(level)),
new Markup(level.ToString(), GetStyleByLevel(level)).RightJustified(), new Markup(level.ToString(), GetStyleByLevel(level)).RightJustified(),
new Markup(logger, GetStyleByLevel(level)).LeftJustified(), new Markup(logger, GetStyleByLevel(level)).LeftJustified(),
new Markup(Cleanup(message), GetStyleByLevel(level)).LeftJustified(), new Markup(Cleanup(message), GetStyleByLevel(level)).LeftJustified(),
new Markup($"[underline red3_1 on white]{exception.GetType().Name}[/]\n" + Cleanup(exception.Message), new Style(foreground: Color.Red3_1)).Centered()); new Markup(
$"[underline red3_1 on white]{exception.GetType().Name}[/]\n" + Cleanup(exception.Message),
new Style(foreground: Color.Red3_1)).Centered());
else else
_table.AddRow( _table.AddRow(
new Markup(level.ToString()).RightJustified(), new Markup(level.ToString()).RightJustified(),
new Markup(logger, GetStyleByLevel(level)).LeftJustified(), new Markup(logger, GetStyleByLevel(level)).LeftJustified(),
new Markup(message, GetStyleByLevel(level)).LeftJustified(), new Markup(message, GetStyleByLevel(level)).LeftJustified(),
new Markup($"[underline red3_1 on white]{exception.GetType().Name}[/]\n" + Cleanup(exception.Message), new Style(foreground: Color.Red3_1)).Centered()); new Markup(
$"[underline red3_1 on white]{exception.GetType().Name}[/]\n" + Cleanup(exception.Message),
new Style(foreground: Color.Red3_1)).Centered());
} }
catch (Exception ex)
{
Debugger.Break();
}
}
private static Style GetStyleByLevel(Logger.Level level) private static Style GetStyleByLevel(Logger.Level level)
{ {

View File

@ -1,6 +1,7 @@
//Blizzless Project 2022 //Blizzless Project 2022
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
@ -102,7 +103,14 @@ namespace DiIiS_NA.Core.Logging
public void Trace(string message, params object[] args) => Log(Level.Trace, message, args); public void Trace(string message, params object[] args) => Log(Level.Trace, message, args);
/// <param name="message">The log message.</param> /// <param name="message">The log message.</param>
public void MethodTrace(string message, [CallerMemberName] string methodName = "") => Log(Level.MethodTrace, $"$[olive]${methodName}()$[/]$: " + message, null); public void MethodTrace(string message, [CallerMemberName] string methodName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
{
#if DEBUG
Log(Level.MethodTrace, $"$[darkolivegreen3_2]${methodName}()$[/]$ @ {lineNumber}: " + message, null);
#else
Log(Level.MethodTrace, $"$[darkolivegreen3_2]${methodName}()$[/]$: " + message, null);
#endif
}
/// <param name="message">The log message.</param> /// <param name="message">The log message.</param>
public void Debug(string message) => Log(Level.Debug, message, null); public void Debug(string message) => Log(Level.Debug, message, null);

View File

@ -56,17 +56,17 @@ namespace DiIiS_NA.GameServer.ClientSystem
var game = GameManager.GetGameById(message.SGameId); var game = GameManager.GetGameById(message.SGameId);
Toon toon = null; Toon toon = null;
if (game != null) if (game != null)
toon = ToonManager.GetToonByLowID((ulong)message.HeroID, game.GameDBSession); toon = ToonManager.GetToonByLowID((ulong)message.HeroID, game.GameDbSession);
bool PVP = false; bool PVP = false;
if (PVP) if (PVP)
toon = new Toon(ToonManager.CreateFakeDBToon(toon.GameAccount.Owner.BattleTag, toon.GameAccount.DBGameAccount), game.GameDBSession); toon = new Toon(ToonManager.CreateFakeDBToon(toon.GameAccount.Owner.BattleTag, toon.GameAccount.DBGameAccount), game.GameDbSession);
if (game == null) if (game == null)
{ {
if (PVP) if (PVP)
{ {
game = GameManager.CreateGame(message.SGameId, 1); game = GameManager.CreateGame(message.SGameId, 1);
toon = ToonManager.GetToonByLowID((ulong)message.HeroID, game.GameDBSession); toon = ToonManager.GetToonByLowID((ulong)message.HeroID, game.GameDbSession);
game.SetAct(0); game.SetAct(0);
} }
else else

View File

@ -125,6 +125,15 @@ namespace DiIiS_NA.GameServer
set => Set(nameof(ChanceNormalUnidentified), value); set => Set(nameof(ChanceNormalUnidentified), value);
} }
/// <summary>
/// Resurrection charges on changing worlds
/// </summary>
public int ResurrectionCharges
{
get => GetInt(nameof(ResurrectionCharges), 3);
set => Set(nameof(ResurrectionCharges), value);
}
public static Config Instance { get; } = new(); public static Config Instance { get; } = new();
private Config() : base("Game-Server") private Config() : base("Game-Server")

View File

@ -220,7 +220,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
/// <param name="sno">SNOId of the actor.</param> /// <param name="sno">SNOId of the actor.</param>
/// <param name="tags">TagMapEntry dictionary read for the actor from MPQ's..</param> /// <param name="tags">TagMapEntry dictionary read for the actor from MPQ's..</param>
protected Actor(World world, ActorSno sno, TagMap tags, bool isMarker = false) protected Actor(World world, ActorSno sno, TagMap tags, bool isMarker = false)
: base(world, world.IsPvP ? World.NewActorPvPID : world.Game.NewActorGameID) : base(world, world.IsPvP ? World.NewActorPvPID : world.Game.NewActorGameId)
{ {
Tags = tags; Tags = tags;

View File

@ -235,7 +235,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
if (Encounter == 0) return; if (Encounter == 0) return;
//if (this.World.Game.CurrentEncounter.activated) return; //if (this.World.Game.CurrentEncounter.activated) return;
World.Game.CurrentEncounter.activated = true; World.Game.CurrentEncounter.Activated = true;
World.Game.CurrentEncounter.SnoId = Encounter; World.Game.CurrentEncounter.SnoId = Encounter;
foreach (Player plr in World.Game.Players.Values) foreach (Player plr in World.Game.Players.Values)

View File

@ -7,6 +7,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.MPQ.FileFormats;
namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
{ {
@ -66,6 +68,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
)/*Act Bosses*/] )/*Act Bosses*/]
public sealed class Boss : Monster public sealed class Boss : Monster
{ {
private static readonly Logger Logger = LogManager.CreateLogger(nameof(Boss));
public Boss(MapSystem.World world, ActorSno sno, TagMap tags) public Boss(MapSystem.World world, ActorSno sno, TagMap tags)
: base(world, sno, tags) : base(world, sno, tags)
{ {
@ -74,9 +77,9 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
//this.Attributes[GameAttribute.Immune_To_Charm] = true; //this.Attributes[GameAttribute.Immune_To_Charm] = true;
Attributes[GameAttribute.using_Bossbar] = true; Attributes[GameAttribute.using_Bossbar] = true;
Attributes[GameAttribute.InBossEncounter] = true; Attributes[GameAttribute.InBossEncounter] = true;
Attributes[GameAttribute.Hitpoints_Max] *= 10.0f; Attributes[GameAttribute.Hitpoints_Max] *= 4f;
Attributes[GameAttribute.Damage_Weapon_Min, 0] *= 7.8f; Attributes[GameAttribute.Damage_Weapon_Min, 0] *= 3f;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] *= 7.8f; Attributes[GameAttribute.Damage_Weapon_Delta, 0] *= 3f;
Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total]; Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total];
Attributes[GameAttribute.TeamID] = 10; Attributes[GameAttribute.TeamID] = 10;
@ -181,15 +184,10 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
public override int Quality public override int Quality
{ {
get get => (int) SpawnType.Boss;
{ set => Logger.Warn("Boss MonsterQuality setter not implemented.");
return (int)DiIiS_NA.Core.MPQ.FileFormats.SpawnType.Boss;
}
set
{
// TODO MonsterQuality setter not implemented. Throwing a NotImplementedError is catched as message not beeing implemented and nothing works anymore... // TODO MonsterQuality setter not implemented. Throwing a NotImplementedError is catched as message not beeing implemented and nothing works anymore...
} }
}
public override bool Reveal(PlayerSystem.Player player) public override bool Reveal(PlayerSystem.Player player)

View File

@ -29,7 +29,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void SetSkill(Player player, int SkillSNOId) public void SetSkill(Player player, int SkillSNOId)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First();
switch (SkillSNOId) switch (SkillSNOId)
{ {
case 102057: case 102057:
@ -40,7 +40,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill1SNOId = SkillSNOId; dbhireling.Skill1SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 102133: case 102133:
case 101461: case 101461:
@ -50,7 +50,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill2SNOId = SkillSNOId; dbhireling.Skill2SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 101990: case 101990:
case 220872: case 220872:
@ -60,7 +60,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill3SNOId = SkillSNOId; dbhireling.Skill3SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 101425: case 101425:
case 201524: case 201524:
@ -70,7 +70,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill4SNOId = SkillSNOId; dbhireling.Skill4SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
default: default:
return; return;
@ -79,12 +79,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void Retrain(Player player) public void Retrain(Player player)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First();
dbhireling.Skill1SNOId = -1; dbhireling.Skill1SNOId = -1;
dbhireling.Skill2SNOId = -1; dbhireling.Skill2SNOId = -1;
dbhireling.Skill3SNOId = -1; dbhireling.Skill3SNOId = -1;
dbhireling.Skill4SNOId = -1; dbhireling.Skill4SNOId = -1;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
player.HirelingInfo[3].Skill1SNOId = -1; player.HirelingInfo[3].Skill1SNOId = -1;
player.HirelingInfo[3].Skill2SNOId = -1; player.HirelingInfo[3].Skill2SNOId = -1;

View File

@ -448,7 +448,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void LoadInventory(Player player) public void LoadInventory(Player player)
{ {
_equipment.Add(player, new Dictionary<int, Item>()); _equipment.Add(player, new Dictionary<int, Item>());
var inventory_list = World.Game.GameDBSession.SessionQueryWhere<DBInventory>(dbi => dbi.DBToon.Id == player.Toon.PersistentID && dbi.HirelingId != 0 && dbi.HirelingId == Attributes[GameAttribute.Hireling_Class]); var inventory_list = World.Game.GameDbSession.SessionQueryWhere<DBInventory>(dbi => dbi.DBToon.Id == player.Toon.PersistentID && dbi.HirelingId != 0 && dbi.HirelingId == Attributes[GameAttribute.Hireling_Class]);
foreach (var inv_item in inventory_list) foreach (var inv_item in inventory_list)
{ {
Item item = ItemGenerator.LoadFromDB(player, inv_item); Item item = ItemGenerator.LoadFromDB(player, inv_item);
@ -476,7 +476,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
item.DBInventory.EquipmentSlot = slot; item.DBInventory.EquipmentSlot = slot;
item.DBInventory.LocationX = 0; item.DBInventory.LocationX = 0;
item.DBInventory.LocationY = 0; item.DBInventory.LocationY = 0;
World.Game.GameDBSession.SessionUpdate(item.DBInventory); World.Game.GameDbSession.SessionUpdate(item.DBInventory);
item.Attributes[GameAttribute.Item_Equipped] = true; item.Attributes[GameAttribute.Item_Equipped] = true;
_equipment[owner].Add(slot, item); _equipment[owner].Add(slot, item);
RefreshEquipment(owner); RefreshEquipment(owner);
@ -494,7 +494,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
item.Owner = owner; item.Owner = owner;
_equipment[owner].Remove(slot); _equipment[owner].Remove(slot);
World.Game.GameDBSession.SessionDelete(item.DBInventory); World.Game.GameDbSession.SessionDelete(item.DBInventory);
owner.Inventory.PickUp(item); owner.Inventory.PickUp(item);
item.Unreveal(owner); item.Unreveal(owner);
item.Attributes[GameAttribute.Item_Equipped] = false; item.Attributes[GameAttribute.Item_Equipped] = false;

View File

@ -31,7 +31,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void SetSkill(Player player, int SkillSNOId) public void SetSkill(Player player, int SkillSNOId)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First();
switch (SkillSNOId) switch (SkillSNOId)
{ {
case 102057: case 102057:
@ -42,7 +42,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill1SNOId = SkillSNOId; dbhireling.Skill1SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 102133: case 102133:
case 101461: case 101461:
@ -52,7 +52,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill2SNOId = SkillSNOId; dbhireling.Skill2SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 101990: case 101990:
case 220872: case 220872:
@ -62,7 +62,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill3SNOId = SkillSNOId; dbhireling.Skill3SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 101425: case 101425:
case 201524: case 201524:
@ -72,7 +72,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
dbhireling.Skill4SNOId = SkillSNOId; dbhireling.Skill4SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
default: default:
return; return;
@ -81,12 +81,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void Retrain(Player player) public void Retrain(Player player)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 3).ToList().First();
dbhireling.Skill1SNOId = -1; dbhireling.Skill1SNOId = -1;
dbhireling.Skill2SNOId = -1; dbhireling.Skill2SNOId = -1;
dbhireling.Skill3SNOId = -1; dbhireling.Skill3SNOId = -1;
dbhireling.Skill4SNOId = -1; dbhireling.Skill4SNOId = -1;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
player.HirelingInfo[3].Skill1SNOId = -1; player.HirelingInfo[3].Skill1SNOId = -1;
player.HirelingInfo[3].Skill2SNOId = -1; player.HirelingInfo[3].Skill2SNOId = -1;

View File

@ -29,7 +29,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void SetSkill(Player player, int SkillSNOId) public void SetSkill(Player player, int SkillSNOId)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 2).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 2).ToList().First();
switch (SkillSNOId) switch (SkillSNOId)
{ {
case 95675: case 95675:
@ -40,7 +40,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill1SNOId = SkillSNOId; dbhireling.Skill1SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 97436: case 97436:
case 30464: case 30464:
@ -50,7 +50,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill2SNOId = SkillSNOId; dbhireling.Skill2SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 95690: case 95690:
case 30458: case 30458:
@ -60,7 +60,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill3SNOId = SkillSNOId; dbhireling.Skill3SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 200169: case 200169:
case 30454: case 30454:
@ -70,7 +70,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill4SNOId = SkillSNOId; dbhireling.Skill4SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
default: default:
return; return;
@ -79,12 +79,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void Retrain(Player player) public void Retrain(Player player)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 2).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 2).ToList().First();
dbhireling.Skill1SNOId = -1; dbhireling.Skill1SNOId = -1;
dbhireling.Skill2SNOId = -1; dbhireling.Skill2SNOId = -1;
dbhireling.Skill3SNOId = -1; dbhireling.Skill3SNOId = -1;
dbhireling.Skill4SNOId = -1; dbhireling.Skill4SNOId = -1;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
player.HirelingInfo[2].Skill1SNOId = -1; player.HirelingInfo[2].Skill1SNOId = -1;
player.HirelingInfo[2].Skill2SNOId = -1; player.HirelingInfo[2].Skill2SNOId = -1;

View File

@ -29,7 +29,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void SetSkill(Player player, int SkillSNOId) public void SetSkill(Player player, int SkillSNOId)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 1).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 1).ToList().First();
switch (SkillSNOId) switch (SkillSNOId)
{ {
case 1747: case 1747:
@ -40,7 +40,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill1SNOId = SkillSNOId; dbhireling.Skill1SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 30357: case 30357:
case 93901: case 93901:
@ -50,7 +50,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill2SNOId = SkillSNOId; dbhireling.Skill2SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 30360: case 30360:
case 93888: case 93888:
@ -60,7 +60,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill3SNOId = SkillSNOId; dbhireling.Skill3SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
case 30356: case 30356:
case 30359: case 30359:
@ -70,7 +70,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
Attributes.SendChangedMessage(player.InGameClient); Attributes.SendChangedMessage(player.InGameClient);
dbhireling.Skill4SNOId = SkillSNOId; dbhireling.Skill4SNOId = SkillSNOId;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
break; break;
default: default:
return; return;
@ -79,12 +79,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public void Retrain(Player player) public void Retrain(Player player)
{ {
var dbhireling = player.World.Game.GameDBSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 1).ToList().First(); var dbhireling = player.World.Game.GameDbSession.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == player.Toon.PersistentID && dbh.Class == 1).ToList().First();
dbhireling.Skill1SNOId = -1; dbhireling.Skill1SNOId = -1;
dbhireling.Skill2SNOId = -1; dbhireling.Skill2SNOId = -1;
dbhireling.Skill3SNOId = -1; dbhireling.Skill3SNOId = -1;
dbhireling.Skill4SNOId = -1; dbhireling.Skill4SNOId = -1;
player.World.Game.GameDBSession.SessionUpdate(dbhireling); player.World.Game.GameDbSession.SessionUpdate(dbhireling);
player.HirelingInfo[1].Skill1SNOId = -1; player.HirelingInfo[1].Skill1SNOId = -1;
player.HirelingInfo[1].Skill2SNOId = -1; player.HirelingInfo[1].Skill2SNOId = -1;

View File

@ -59,7 +59,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
var toon = player.Toon.DBToon; var toon = player.Toon.DBToon;
toon.ChestsOpened++; toon.ChestsOpened++;
World.Game.GameDBSession.SessionUpdate(toon); World.Game.GameDbSession.SessionUpdate(toon);
} }
base.OnTargeted(player, message); base.OnTargeted(player, message);

View File

@ -45,7 +45,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
private void ReadWaypointId() private void ReadWaypointId()
{ {
bool isOpenWorld = World.Game.CurrentAct == 3000; bool isOpenWorld = World.Game.CurrentAct == 3000;
var actData = ((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][World.Game.CurrentActSNOid].Data).WayPointInfo.ToList(); var actData = ((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][World.Game.CurrentActSnoId].Data).WayPointInfo.ToList();
if (isOpenWorld) if (isOpenWorld)
actData = ((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70015].Data).WayPointInfo actData = ((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70015].Data).WayPointInfo
.Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70016].Data).WayPointInfo) .Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70016].Data).WayPointInfo)
@ -234,7 +234,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
if (World.Game.OpenedWaypoints.Contains(WaypointId) || World.Game.CurrentAct == 3000) return; if (World.Game.OpenedWaypoints.Contains(WaypointId) || World.Game.CurrentAct == 3000) return;
Logger.Debug("(OnTargeted) Waypoint has been activated: {0}, levelArea: {1}", WaypointId, SNOLevelArea); Logger.MethodTrace($"Waypoint has been activated: {WaypointId}, levelArea: {SNOLevelArea}");
World.BroadcastIfRevealed(plr => new WaypointActivatedMessage World.BroadcastIfRevealed(plr => new WaypointActivatedMessage
{ {

View File

@ -1,109 +1,73 @@
 
using System;
using System.Linq; using System.Linq;
using MonsterFF = DiIiS_NA.Core.MPQ.FileFormats.Monster; using MonsterFF = DiIiS_NA.Core.MPQ.FileFormats.Monster;
using GameBalance = DiIiS_NA.Core.MPQ.FileFormats.GameBalance; using GameBalance = DiIiS_NA.Core.MPQ.FileFormats.GameBalance;
using DiIiS_NA.GameServer.GSSystem.ObjectsSystem; using DiIiS_NA.GameServer.GSSystem.ObjectsSystem;
using DiIiS_NA.Core.Logging; using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.MPQ.FileFormats;
using DiIiS_NA.GameServer.GSSystem.TickerSystem; using DiIiS_NA.GameServer.GSSystem.TickerSystem;
using DiIiS_NA.GameServer.MessageSystem; using DiIiS_NA.GameServer.MessageSystem;
using DiIiS_NA.GameServer.Core.Types.SNO; using DiIiS_NA.GameServer.Core.Types.SNO;
using DiIiS_NA.GameServer.GSSystem.PlayerSystem; using DiIiS_NA.GameServer.GSSystem.PlayerSystem;
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.World; using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.World;
using DiIiS_NA.GameServer.Core.Types.TagMap; using DiIiS_NA.GameServer.Core.Types.TagMap;
using DiIiS_NA.GameServer.GSSystem.MapSystem;
using DiIiS_NA.GameServer.Core.Types.Math; using DiIiS_NA.GameServer.Core.Types.Math;
using DiIiS_NA.GameServer.GSSystem.AISystem.Brains; using DiIiS_NA.GameServer.GSSystem.AISystem.Brains;
using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations; using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations;
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.ACD; using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.ACD;
using DiIiS_NA.D3_GameServer.Core.Types.SNO; using DiIiS_NA.D3_GameServer.Core.Types.SNO;
using World = DiIiS_NA.GameServer.GSSystem.MapSystem.World;
namespace DiIiS_NA.GameServer.GSSystem.ActorSystem namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
{ {
public class Monster : Living, IUpdateable public class Monster : Living, IUpdateable
{ {
public override ActorType ActorType { get { return ActorType.Monster; } } private static readonly Logger Logger = LogManager.CreateLogger(nameof(Monster));
static readonly Logger Logger = LogManager.CreateLogger(); public override ActorType ActorType => ActorType.Monster;
public TickTimer DestroyTimer { get; }
public TickTimer DestroyTimer; private int _adjustedPlayers = 1;
private object _adjustLock = new object();
private int AdjustedPlayers = 1; private float _nativeHp = 0f;
private object adjustLock = new object();
private float _nativeHP = 0f;
private float _nativeDmg = 0f; private float _nativeDmg = 0f;
public Vector3D CorrectedPosition = null;
public override int Quality public override int Quality
{ {
get get => SNO == ActorSno._x1_lr_boss_mistressofpain ? 7 : (int)SpawnType.Normal;
{ set => Logger.Warn("Quality of monster cannot be changed");
if(SNO == ActorSno._x1_lr_boss_mistressofpain)
return 7;
return (int)DiIiS_NA.Core.MPQ.FileFormats.SpawnType.Normal;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Champion;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Rare;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Minion;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Unique;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Hireling;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Clone;
//return (int)Mooege.Common.MPQ.FileFormats.SpawnType.Boss;
}
set
{
}
} }
public int LoreSNOId public int LoreSnoId => Monster.IsValid ? ((MonsterFF)Monster.Target).SNOLore : -1;
{
get
{
return Monster.IsValid ? (Monster.Target as MonsterFF).SNOLore : -1;
}
}
public int MonsterType public int MonsterType => Monster.IsValid ? (int)((MonsterFF)Monster.Target).Type : -1;
{
get
{
return Monster.IsValid ? (int)(Monster.Target as MonsterFF).Type : -1;
}
}
public float HPMultiplier public float HpMultiplier => Monster.IsValid ? (1f + ((MonsterFF)Monster.Target).AttributeModifiers[4]) : 1f;
{
get
{
return Monster.IsValid ? (1f + (Monster.Target as MonsterFF).AttributeModifiers[4]) : 1f;
}
}
public float DmgMultiplier public float DmgMultiplier => Monster.IsValid ? (1f + ((MonsterFF)Monster.Target).AttributeModifiers[55]) : 1f;
{ public Vector3D BasePoint { get; set; }
get
{
return Monster.IsValid ? (1f + (Monster.Target as MonsterFF).AttributeModifiers[55]) : 1f;
}
}
/// <summary> /// <summary>
/// Gets the Actors summoning fields from the mpq's and returns them in format for Monsters. /// Gets the Actors summoning fields from the mpq's and returns them in format for Monsters.
/// Useful for the Monsters spawning/summoning skills. /// Useful for the Monsters spawning/summoning skills.
/// </summary> /// </summary>
public ActorSno[] SNOSummons public ActorSno[] SnoSummons => ((MonsterFF)Monster.Target).SNOSummonActor.Select(x => (ActorSno)x).ToArray();
{
get
{
return (Monster.Target as MonsterFF).SNOSummonActor.Select(x => (ActorSno)x).ToArray();
}
}
public Monster(World world, ActorSno sno, TagMap tags) public Monster(World world, ActorSno sno, TagMap tags)
: base(world, sno, tags) : base(world, sno, tags)
{ {
#if DEBUG
if (this is Boss boss)
{
Logger.Info($"Boss $[underline]${boss.SNO}$[/]$ created");
}
#endif
Field2 = 0x8; Field2 = 0x8;
GBHandle.Type = (int)ActorType.Monster; GBHandle.GBID = 1; GBHandle.Type = (int)ActorType.Monster; GBHandle.GBID = 1;
Attributes[GameAttribute.TeamID] = 9; Attributes[GameAttribute.TeamID] = 9;
if (Monster.Id != -1) if (Monster.Id != -1)
WalkSpeed = (Monster.Target as MonsterFF).AttributeModifiers[129]; WalkSpeed = ((MonsterFF)Monster.Target).AttributeModifiers[129];
//WalkSpeed /= 2f; //WalkSpeed /= 2f;
Brain = new MonsterBrain(this); Brain = new MonsterBrain(this);
@ -114,48 +78,49 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
public override void OnTargeted(Player player, TargetMessage message) public override void OnTargeted(Player player, TargetMessage message)
{ {
#if DEBUG
string monster = "monster";
if (this is Boss) monster = "boss";
Logger.MethodTrace($"Player {player.Name} targeted {monster} {GetType().Name}.");
#endif
} }
public void UpdateStats() public void UpdateStats()
{ {
var monsterLevels = (GameBalance)DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.GameBalance][19760].Data; var monsterLevels = (GameBalance)DiIiS_NA.Core.MPQ.MPQStorage.Data.Assets[SNOGroup.GameBalance][19760].Data;
bool full_hp = (Attributes[GameAttribute.Hitpoints_Cur] == Attributes[GameAttribute.Hitpoints_Max_Total]); bool fullHp = (Math.Abs(Attributes[GameAttribute.Hitpoints_Cur] - Attributes[GameAttribute.Hitpoints_Max_Total]) < 0.001);
Attributes[GameAttribute.Level] = World.Game.MonsterLevel; Attributes[GameAttribute.Level] = World.Game.MonsterLevel;
//this.Attributes[GameAttribute.Hitpoints_Max] = (int)monsterLevels.MonsterLevel[this.World.Game.MonsterLevel - 1].HPMin * (int)this.HPMultiplier * (int)this.World.Game.HPModifier; //this.Attributes[GameAttribute.Hitpoints_Max] = (int)monsterLevels.MonsterLevel[this.World.Game.MonsterLevel - 1].HPMin * (int)this.HPMultiplier * (int)this.World.Game.HPModifier;
int MonsterLevel = 1; int monsterLevel = 1;
if (World.Game.ConnectedPlayers.Count > 1) monsterLevel = World.Game.ConnectedPlayers.Length > 1 ? World.Game.ConnectedPlayers[0].Level : World.Game.InitialMonsterLevel;
MonsterLevel = World.Game.ConnectedPlayers[0].Level;
else
MonsterLevel = World.Game.InitialMonsterLevel;
Attributes[GameAttribute.Hitpoints_Max] = (int)((int)monsterLevels.MonsterLevel[MonsterLevel].HPMin + DiIiS_NA.Core.Helpers.Math.RandomHelper.Next(0, (int)monsterLevels.MonsterLevel[MonsterLevel].HPDelta) * HPMultiplier * World.Game.HPModifier); Attributes[GameAttribute.Hitpoints_Max] = (int)((int)monsterLevels.MonsterLevel[monsterLevel].HPMin + DiIiS_NA.Core.Helpers.Math.RandomHelper.Next(0, (int)monsterLevels.MonsterLevel[monsterLevel].HPDelta) * HpMultiplier * World.Game.HpModifier);
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = ((int)World.Game.ConnectedPlayers.Count + 1) * 1.5f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = ((int)World.Game.ConnectedPlayers.Length + 1) * 1.5f;
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] *= Config.Instance.RateMonsterHP; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] *= Config.Instance.RateMonsterHP;
if (World.Game.ConnectedPlayers.Count > 1) if (World.Game.ConnectedPlayers.Length > 1)
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// / 2f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// / 2f;
var HPM = Attributes[GameAttribute.Hitpoints_Max]; var hpMax = Attributes[GameAttribute.Hitpoints_Max];
var HPMT = Attributes[GameAttribute.Hitpoints_Max_Total]; var hpTotal = Attributes[GameAttribute.Hitpoints_Max_Total];
float DamageMin = monsterLevels.MonsterLevel[World.Game.MonsterLevel].Dmg * DmgMultiplier;// * 0.5f; float damageMin = monsterLevels.MonsterLevel[World.Game.MonsterLevel].Dmg * DmgMultiplier;// * 0.5f;
float DamageDelta = DamageMin; float damageDelta = damageMin;
Attributes[GameAttribute.Damage_Weapon_Min, 0] = DamageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG; Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] = DamageDelta; Attributes[GameAttribute.Damage_Weapon_Delta, 0] = damageDelta;
if (MonsterLevel > 30) if (monsterLevel > 30)
{ {
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.5f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.5f;
Attributes[GameAttribute.Damage_Weapon_Min, 0] = DamageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;// * 0.2f; Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;// * 0.2f;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] = DamageDelta; Attributes[GameAttribute.Damage_Weapon_Delta, 0] = damageDelta;
} }
if (MonsterLevel > 60) if (monsterLevel > 60)
{ {
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.7f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.7f;
Attributes[GameAttribute.Damage_Weapon_Min, 0] = DamageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;// * 0.15f; Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;// * 0.15f;
//this.Attributes[GameAttribute.Damage_Weapon_Delta, 0] = DamageDelta * 0.5f; //this.Attributes[GameAttribute.Damage_Weapon_Delta, 0] = DamageDelta * 0.5f;
} }
_nativeHP = Attributes[GameAttribute.Hitpoints_Max_Total]; _nativeHp = Attributes[GameAttribute.Hitpoints_Max_Total];
_nativeDmg = Attributes[GameAttribute.Damage_Weapon_Min, 0]; _nativeDmg = Attributes[GameAttribute.Damage_Weapon_Min, 0];
//if (full_hp) //if (full_hp)
Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total]; Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total];
@ -163,8 +128,8 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
} }
int _BleedFirstTick = 0; int _bleedFirstTick = 0;
int _CaltropsFirstTick = 0; int _caltropsFirstTick = 0;
public void Update(int tickCounter) public void Update(int tickCounter)
{ {
@ -194,24 +159,24 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
if (this is Boss) if (this is Boss)
{ {
if (!World.BuffManager.HasBuff<PowerSystem.Implementations.Caltrops.ActiveCalTrops>(this)) if (!World.BuffManager.HasBuff<PowerSystem.Implementations.Caltrops.ActiveCalTrops>(this))
_CaltropsFirstTick = tickCounter; _caltropsFirstTick = tickCounter;
if ((tickCounter - _CaltropsFirstTick) >= 2400) if ((tickCounter - _caltropsFirstTick) >= 2400)
{ {
var buff_owner = World.BuffManager.GetFirstBuff<PowerSystem.Implementations.Caltrops.ActiveCalTrops>(this).User; var buffOwner = World.BuffManager.GetFirstBuff<PowerSystem.Implementations.Caltrops.ActiveCalTrops>(this).User;
if (buff_owner is Player) if (buffOwner is Player player)
(buff_owner as Player).GrantAchievement(74987243307067); player.GrantAchievement(74987243307067);
} }
} }
if (!World.BuffManager.HasBuff<PowerSystem.Implementations.Rend.RendDebuff>(this)) if (!World.BuffManager.HasBuff<PowerSystem.Implementations.Rend.RendDebuff>(this))
_BleedFirstTick = tickCounter; _bleedFirstTick = tickCounter;
if ((tickCounter - _BleedFirstTick) >= 1200) if ((tickCounter - _bleedFirstTick) >= 1200)
{ {
var buff_owner = World.BuffManager.GetFirstBuff<PowerSystem.Implementations.Rend.RendDebuff>(this).User; var buffOwner = World.BuffManager.GetFirstBuff<PowerSystem.Implementations.Rend.RendDebuff>(this).User;
if (buff_owner is Player) if (buffOwner is Player player)
(buff_owner as Player).GrantAchievement(74987243307052); player.GrantAchievement(74987243307052);
} }
} }
@ -220,32 +185,29 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
if (!base.Reveal(player)) if (!base.Reveal(player))
return false; return false;
lock (_adjustLock)
lock (adjustLock)
{ {
int count = player.World.Game.Players.Count; int count = player.World.Game.Players.Count;
if (count > 0 && AdjustedPlayers != count) if (count > 0 && _adjustedPlayers != count)
{ {
Attributes[GameAttribute.Damage_Weapon_Min, 0] = _nativeDmg * (1f + (0.05f * (count - 1) * player.World.Game.Difficulty)); Attributes[GameAttribute.Damage_Weapon_Min, 0] = _nativeDmg * (1f + (0.05f * (count - 1) * player.World.Game.Difficulty));
Attributes[GameAttribute.Hitpoints_Max] = _nativeHP * (1f + ((0.75f + (0.1f * player.World.Game.Difficulty)) * (count - 1))); Attributes[GameAttribute.Hitpoints_Max] = _nativeHp * (1f + ((0.75f + (0.1f * player.World.Game.Difficulty)) * (count - 1)));
Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total]; Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total];
Attributes.BroadcastChangedIfRevealed(); Attributes.BroadcastChangedIfRevealed();
AdjustedPlayers = count; _adjustedPlayers = count;
} }
} }
return true; return true;
} }
public Vector3D basePoint = null;
public override void EnterWorld(Vector3D position) public override void EnterWorld(Vector3D position)
{ {
base.EnterWorld(position); base.EnterWorld(position);
if (!Spawner) if (!Spawner)
if (basePoint == null) if (BasePoint == null)
basePoint = position; BasePoint = position;
if (SNO == ActorSno._a3_battlefield_demonic_ballista) //ballistas hack if (SNO == ActorSno._a3_battlefield_demonic_ballista) //ballistas hack
{ {
@ -262,14 +224,14 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
/// </summary> /// </summary>
public void PlayLore() public void PlayLore()
{ {
if (LoreSNOId != -1) if (LoreSnoId != -1)
{ {
var players = GetPlayersInRange(); var players = GetPlayersInRange();
if (players != null) if (players != null)
{ {
foreach (var player in players.Where(player => !player.HasLore(LoreSNOId))) foreach (var player in players.Where(player => !player.HasLore(LoreSnoId)))
{ {
player.PlayLore(LoreSNOId, false); player.PlayLore(LoreSnoId, false);
} }
} }
} }

View File

@ -3,6 +3,7 @@ using GameBalance = DiIiS_NA.Core.MPQ.FileFormats.GameBalance;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -13,8 +14,6 @@ using DiIiS_NA.Core.Storage;
using DiIiS_NA.Core.Helpers.Hash; using DiIiS_NA.Core.Helpers.Hash;
using DiIiS_NA.GameServer.ClientSystem; using DiIiS_NA.GameServer.ClientSystem;
using DiIiS_NA.GameServer.GSSystem.TickerSystem; using DiIiS_NA.GameServer.GSSystem.TickerSystem;
using DiIiS_NA.GameServer.GSSystem.ActorSystem;
using DiIiS_NA.GameServer.GSSystem.MapSystem;
using DiIiS_NA.GameServer.GSSystem.QuestSystem; using DiIiS_NA.GameServer.GSSystem.QuestSystem;
using DiIiS_NA.GameServer.Core.Types.Math; using DiIiS_NA.GameServer.Core.Types.Math;
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Game; using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Game;
@ -32,11 +31,26 @@ using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings;
using DiIiS_NA.GameServer.GSSystem.GeneratorsSystem; using DiIiS_NA.GameServer.GSSystem.GeneratorsSystem;
using DiIiS_NA.GameServer.GSSystem.AISystem.Brains; using DiIiS_NA.GameServer.GSSystem.AISystem.Brains;
using System.Diagnostics; using System.Diagnostics;
using DiIiS_NA.Core.MPQ.FileFormats;
using DiIiS_NA.D3_GameServer.Core.Types.SNO; using DiIiS_NA.D3_GameServer.Core.Types.SNO;
using DiIiS_NA.D3_GameServer.GSSystem.GameSystem; using DiIiS_NA.D3_GameServer.GSSystem.GameSystem;
using Actor = DiIiS_NA.GameServer.GSSystem.ActorSystem.Actor;
using Monster = DiIiS_NA.GameServer.GSSystem.ActorSystem.Monster;
using Scene = DiIiS_NA.GameServer.GSSystem.MapSystem.Scene;
using World = DiIiS_NA.GameServer.GSSystem.MapSystem.World;
using DiIiS_NA.Core.MPQ.FileFormats;
namespace DiIiS_NA.GameServer.GSSystem.GameSystem namespace DiIiS_NA.GameServer.GSSystem.GameSystem
{ {
public enum ActEnum
{
Act1 = 0,
Act2 = 100,
Act3 = 200,
Act4 = 300,
Act5 = 400,
OpenWorld = 3000
}
public class Game : IMessageConsumer public class Game : IMessageConsumer
{ {
private static readonly Logger Logger = LogManager.CreateLogger(); private static readonly Logger Logger = LogManager.CreateLogger();
@ -51,7 +65,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// </summary> /// </summary>
public ConcurrentDictionary<GameClient, Player> Players { get; private set; } public ConcurrentDictionary<GameClient, Player> Players { get; private set; }
public List<Player> ConnectedPlayers = new List<Player>(); public ImmutableArray<Player> ConnectedPlayers => Players.Where(s => s.Value != null && s.Key.Connection.IsOpen() && !s.Key.IsLoggingOut)
.Select(s=>s.Value).ToImmutableArray();
public bool QuestSetup = false; public bool QuestSetup = false;
@ -84,20 +99,20 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// <summary> /// <summary>
/// DynamicId counter for objects. /// DynamicId counter for objects.
/// </summary> /// </summary>
private uint _lastObjectID = 10001; private uint _lastObjectId = 10001;
/// <summary> /// <summary>
/// Returns a new dynamicId for objects. /// Returns a new dynamicId for objects.
/// </summary> /// </summary>
private object obj = new object(); private readonly object _obj = new();
public uint NewActorGameID public uint NewActorGameId
{ {
get get
{ {
lock (obj) lock (_obj)
{ {
_lastObjectID++; _lastObjectId++;
return _lastObjectID; return _lastObjectId;
} }
} }
} }
@ -108,13 +123,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// </summary> /// </summary>
private readonly ConcurrentDictionary<WorldSno, World> _worlds; private readonly ConcurrentDictionary<WorldSno, World> _worlds;
public List<World> Worlds public List<World> Worlds => _worlds.Values.ToList();
{
get
{
return _worlds.Values.ToList();
}
}
public Mode GameMode = Mode.Campaign; public Mode GameMode = Mode.Campaign;
public enum Mode public enum Mode
@ -126,19 +135,19 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public struct BossEncounter public struct BossEncounter
{ {
public int SnoId; public int SnoId;
public bool activated; public bool Activated;
public int acceptedPlayers; public int AcceptedPlayers;
}; };
public Dictionary<WorldSno, List<Action>> OnLoadWorldActions = new Dictionary<WorldSno, List<Action>>(); public readonly Dictionary<WorldSno, List<Action>> OnLoadWorldActions = new();
public Dictionary<int, List<Action>> OnLoadSceneActions = new Dictionary<int, List<Action>>(); public readonly Dictionary<int, List<Action>> OnLoadSceneActions = new();
public BossEncounter CurrentEncounter = new BossEncounter { SnoId = -1, activated = false, acceptedPlayers = 0 }; public BossEncounter CurrentEncounter = new() { SnoId = -1, Activated = false, AcceptedPlayers = 0 };
/// <summary> /// <summary>
/// Starting world's sno. /// Starting world's sno.
/// </summary> /// </summary>
public WorldSno StartingWorldSNO { get; private set; } public WorldSno StartingWorldSno { get; private set; }
/// <summary> /// <summary>
/// Starting world's monster level /// Starting world's monster level
@ -147,7 +156,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public int MonsterLevel { get; private set; } public int MonsterLevel { get; private set; }
/// <summary> /// <summary>
/// Is it world without players? /// Is it a world without players?
/// </summary> /// </summary>
public bool Empty { get; private set; } public bool Empty { get; private set; }
@ -156,18 +165,12 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// </summary> /// </summary>
public bool Paused { get; private set; } public bool Paused { get; private set; }
private bool UpdateEnabled = true; private bool _updateEnabled = true;
/// <summary> /// <summary>
/// Starting world for the game. /// Starting world for the game.
/// </summary> /// </summary>
public World StartingWorld public World StartingWorld => GetWorld(StartingWorldSno);
{
get
{
return GetWorld(StartingWorldSNO);
}
}
/// <summary> /// <summary>
/// Player index counter. /// Player index counter.
@ -192,14 +195,19 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// </summary> /// </summary>
public int CurrentAct = -1; public int CurrentAct = -1;
public ActEnum CurrentActEnum => CurrentAct != -1 ? (ActEnum)CurrentAct : ActEnum.Act1;
private int _difficulty = 0;
/// <summary> /// <summary>
/// Current difficulty system id. /// Current difficulty system id.
/// Min: 0, Max: 19
/// </summary> /// </summary>
public int Difficulty = 0; public int Difficulty { get => _difficulty; set => _difficulty = Math.Clamp(value, 0, 19); }
public float HPModifier = 1f;
public float DmgModifier = 1f; public float HpModifier { get; set; } = 1f;
public float XPModifier = 1f; public float DmgModifier { get; set; } = 1f;
public float GoldModifier = 1f; public float XpModifier { get; set; } = 1f;
public float GoldModifier { get; set; } = 1f;
/// <summary> /// <summary>
/// Hardcore mode flag. /// Hardcore mode flag.
@ -207,41 +215,31 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public bool IsHardcore = false; public bool IsHardcore = false;
public bool IsSeasoned = false; public bool IsSeasoned = false;
public List<int> OpenedWaypoints = new List<int>(); public List<int> OpenedWaypoints = new();
public Dictionary<DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT, int> BountiesCompleted = new Dictionary<DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT, int>() public readonly Dictionary<BountyData.ActT, int> BountiesCompleted = new()
{ {
{DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT.A1, 0}, {BountyData.ActT.A1, 0},
{DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT.A2, 0}, {BountyData.ActT.A2, 0},
{DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT.A3, 0}, {BountyData.ActT.A3, 0},
{DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT.A4, 0}, {BountyData.ActT.A4, 0},
{DiIiS_NA.Core.MPQ.FileFormats.BountyData.ActT.A5, 0} {BountyData.ActT.A5, 0}
}; };
/// <summary> /// <summary>
/// Current act SNO id. /// Current act SNO id.
/// </summary> /// </summary>
public int CurrentActSNOid public int CurrentActSnoId =>
CurrentActEnum switch
{ {
get ActEnum.Act1 => 70015,
{ ActEnum.Act2 => 70016,
switch (CurrentAct) ActEnum.Act3 => 70017,
{ ActEnum.Act4 => 70018,
case 0: ActEnum.Act5 => 236915,
return 70015; ActEnum.OpenWorld => 70015,
case 100: _ => throw new ArgumentOutOfRangeException()
return 70016; };
case 200:
return 70017;
case 300:
return 70018;
case 400:
return 236915;
default:
return 70015;
}
}
}
/// <summary> /// <summary>
/// Last completed quest SNOid. /// Last completed quest SNOid.
@ -273,7 +271,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// <summary> /// <summary>
/// Database connection for this game /// Database connection for this game
/// </summary> /// </summary>
public GameDBSession GameDBSession; public GameDBSession GameDbSession;
/// <summary> /// <summary>
/// Update frequency for the game - 100 ms. /// Update frequency for the game - 100 ms.
@ -293,32 +291,29 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// <summary> /// <summary>
/// Returns the latest tick count. /// Returns the latest tick count.
/// </summary> /// </summary>
public int TickCounter public int TickCounter => _tickCounter;
{
get { return _tickCounter; }
}
/// <summary> // /// <summary>
/// Stopwatch that measures time takent to get a full Game.Update(). // /// Stopwatch that measures time takent to get a full Game.Update().
/// </summary> // /// </summary>
//private readonly Stopwatch _tickWatch; //private readonly Stopwatch _tickWatch;
/// <summary> /// <summary>
/// DynamicId counter for scene. /// DynamicId counter for scene.
/// </summary> /// </summary>
private uint _lastSceneID = 0x04000000; private uint _lastSceneId = 0x04000000;
/// <summary> /// <summary>
/// Returns a new dynamicId for scenes. /// Returns a new dynamicId for scenes.
/// </summary> /// </summary>
public uint NewSceneID public uint NewSceneId
{ {
get get
{ {
lock (obj) lock (_obj)
{ {
_lastSceneID++; _lastSceneId++;
return _lastSceneID; return _lastSceneId;
} }
} }
} }
@ -338,41 +333,29 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
} }
} }
public Vector3D StartPosition public Vector3D StartPosition =>
CurrentActEnum switch
{ {
get ActEnum.Act1 => StartingWorld.GetStartingPointById(24).Position,
{ ActEnum.Act2 => StartingWorld.GetStartingPointById(59).Position,
switch (CurrentAct) ActEnum.Act3 => StartingWorld.GetStartingPointById(172).Position,
{ ActEnum.Act4 => StartingWorld.GetStartingPointById(172).Position,
case 0: ActEnum.Act5 => StartingWorld.GetStartingPointById(172).Position,
return StartingWorld.GetStartingPointById(24).Position; ActEnum.OpenWorld => StartingWorld.GetStartingPointById(24).Position,
case 100: _ => StartingWorld.StartingPoints.First().Position
return StartingWorld.GetStartingPointById(59).Position; };
case 200:
return StartingWorld.GetStartingPointById(172).Position;
case 300:
return StartingWorld.GetStartingPointById(172).Position;
case 400:
return StartingWorld.GetStartingPointById(172).Position;
case 3000:
return StartingWorld.GetStartingPointById(24).Position;
default:
return StartingWorld.StartingPoints.First().Position;
}
}
}
/// <summary> /// <summary>
/// DynamicId counter for worlds. /// DynamicId counter for worlds.
/// </summary> /// </summary>
private uint _lastWorldID = 0x07000000; private uint _lastWorldId = 0x07000000;
public int WeatherSeed = DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(); public int WeatherSeed = DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next();
/// <summary> /// <summary>
/// Returns a new dynamicId for worlds. /// Returns a new dynamicId for worlds.
/// </summary> /// </summary>
public uint NewWorldID { get { return _lastWorldID++; } } public uint NewWorldId => _lastWorldId++;
public QuestManager QuestManager { get; private set; } public QuestManager QuestManager { get; private set; }
//public AI.Pather Pathfinder { get; private set; } //public AI.Pather Pathfinder { get; private set; }
@ -388,11 +371,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public Game(int gameId, int initalLevel, bool endless = false) public Game(int gameId, int initalLevel, bool endless = false)
{ {
GameId = gameId; GameId = gameId;
_lastObjectID = (uint)gameId * 100000; _lastObjectId = (uint)gameId * 100000;
Empty = true; Empty = true;
Players = new ConcurrentDictionary<GameClient, Player>(); Players = new ConcurrentDictionary<GameClient, Player>();
_worlds = new ConcurrentDictionary<WorldSno, World>(); _worlds = new ConcurrentDictionary<WorldSno, World>();
StartingWorldSNO = WorldSno.pvp_caout_arena_01;// FIXME: track the player's save point and toss this stuff. StartingWorldSno = WorldSno.pvp_caout_arena_01;// FIXME: track the player's save point and toss this stuff.
InitialMonsterLevel = initalLevel; InitialMonsterLevel = initalLevel;
MonsterLevel = initalLevel; MonsterLevel = initalLevel;
QuestManager = new QuestManager(this); QuestManager = new QuestManager(this);
@ -409,12 +392,12 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
loopThread.Start(); loopThread.Start();
WorldGenerator = new WorldGenerator(this); WorldGenerator = new WorldGenerator(this);
GameDBSession = new GameDBSession(); GameDbSession = new GameDBSession();
LockdownTimer = TickTimer.WaitSeconds(this, 60f, new Action<int>((q) => LockdownTimer = TickTimer.WaitSeconds(this, 60f, new Action<int>((q) =>
{ {
if (Empty || Players.IsEmpty) if (Empty || Players.IsEmpty)
{ {
Logger.Info("All players disconnected, closing game session."); Logger.Warn("All players disconnected, closing game session.");
Dispose(); Dispose();
GameManager.Games.Remove(GameId); GameManager.Games.Remove(GameId);
} }
@ -425,7 +408,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
#region update & tick managment #region update & tick managment
private object updateLock = new object(); private readonly object _updateLock = new();
public int MissedTicks = 0; public int MissedTicks = 0;
public bool UpdateInProgress = false; public bool UpdateInProgress = false;
@ -436,11 +419,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
{ {
while (Working) while (Working)
{ {
Stopwatch _tickWatch = new Stopwatch(); Stopwatch tickWatch = new Stopwatch();
_tickWatch.Restart(); tickWatch.Restart();
if (Players.Count == 0 && !Empty) if (Players.Count == 0 && !Empty)
{ {
Logger.Info("Все игроки отключены, сессия игры завершена"); Logger.Info("All players disconnected, game session closed");
Dispose(); Dispose();
GameManager.Games.Remove(GameId); GameManager.Games.Remove(GameId);
return; return;
@ -450,11 +433,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
Interlocked.Add(ref _tickCounter, (TickRate + MissedTicks)); // +6 ticks per 100ms. Verified by setting LogoutTickTimeMessage.Ticks to 600 which eventually renders a 10 sec logout timer on client. /raist Interlocked.Add(ref _tickCounter, (TickRate + MissedTicks)); // +6 ticks per 100ms. Verified by setting LogoutTickTimeMessage.Ticks to 600 which eventually renders a 10 sec logout timer on client. /raist
MissedTicks = 0; MissedTicks = 0;
if (UpdateEnabled && !Paused) if (_updateEnabled && !Paused)
{ {
// Lock Game instance to prevent incoming messages from modifying state while updating // Lock Game instance to prevent incoming messages from modifying state while updating
// only update worlds with active players in it - so mob brain()'s in empty worlds doesn't get called and take actions for nothing. /raist. // only update worlds with active players in it - so mob brain()'s in empty worlds doesn't get called and take actions for nothing. /raist.
lock (updateLock) lock (_updateLock)
{ {
foreach (var pair in _worlds.Where(pair => pair.Value.HasPlayersIn)) foreach (var pair in _worlds.Where(pair => pair.Value.HasPlayersIn))
{ {
@ -468,33 +451,40 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
} }
} }
if (PvPTimer != null) PvPTimer?.Update(_tickCounter);
PvPTimer.Update(_tickCounter); GlobalPvPTimer?.Update(_tickCounter);
LockdownTimer?.Update(_tickCounter);
if (GlobalPvPTimer != null) QuestTimer?.Update(_tickCounter);
GlobalPvPTimer.Update(_tickCounter);
if (LockdownTimer != null)
LockdownTimer.Update(_tickCounter);
if (QuestTimer != null)
QuestTimer.Update(_tickCounter);
} }
} }
_tickWatch.Stop(); tickWatch.Stop();
Stopwatch _calcWatch = new Stopwatch(); Stopwatch calcWatch = new();
_calcWatch.Restart(); calcWatch.Start();
var compensation = (int)(UpdateFrequency - _tickWatch.ElapsedMilliseconds); // the compensation value we need to sleep in order to get consistent 100 ms Game.Update(). var compensation = (int)(UpdateFrequency - tickWatch.ElapsedMilliseconds); // the compensation value we need to sleep in order to get consistent 100 ms Game.Update().
if (_tickWatch.ElapsedMilliseconds > UpdateFrequency) if (tickWatch.ElapsedMilliseconds > UpdateFrequency)
{ {
Logger.Trace("Game.Update() took [{0}ms] more than Game.UpdateFrequency [{1}ms].", _tickWatch.ElapsedMilliseconds, UpdateFrequency); if (tickWatch.ElapsedMilliseconds >= UpdateFrequency * 2)
compensation = (int)(UpdateFrequency - (_tickWatch.ElapsedMilliseconds % UpdateFrequency)); {
MissedTicks = TickRate * (int)(_tickWatch.ElapsedMilliseconds / UpdateFrequency); Logger.Error($"took [{tickWatch.ElapsedMilliseconds}ms] more than Game.UpdateFrequency [{UpdateFrequency}ms].");
} }
_calcWatch.Stop(); else if (tickWatch.ElapsedMilliseconds >= UpdateFrequency * 1.5)
Thread.Sleep(Math.Max(0, compensation - (int)_calcWatch.ElapsedMilliseconds)); // sleep until next Update(). {
Logger.Warn(
$"took [{tickWatch.ElapsedMilliseconds}ms] more than Game.UpdateFrequency [{UpdateFrequency}ms].");
}
else
{
Logger.Trace(
$"took [{tickWatch.ElapsedMilliseconds}ms] more than Game.UpdateFrequency [{UpdateFrequency}ms].");
}
compensation = (int)(UpdateFrequency - (tickWatch.ElapsedMilliseconds % UpdateFrequency));
MissedTicks = TickRate * (int)(tickWatch.ElapsedMilliseconds / UpdateFrequency);
}
calcWatch.Stop();
Thread.Sleep(Math.Max(0, compensation - (int)calcWatch.ElapsedMilliseconds)); // sleep until next Update().
} }
} }
#endregion #endregion
@ -507,7 +497,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// <param name="message"></param> /// <param name="message"></param>
public void Route(GameClient client, GameMessage message) public void Route(GameClient client, GameMessage message)
{ {
UpdateEnabled = false; _updateEnabled = false;
try try
{ {
switch (message.Consumer) switch (message.Consumer)
@ -538,13 +528,13 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
} }
finally finally
{ {
UpdateEnabled = true; _updateEnabled = true;
} }
} }
public void Consume(GameClient client, GameMessage message) public void Consume(GameClient client, GameMessage message)
{ {
lock (updateLock) lock (_updateLock)
{ {
if (message is PauseGameMessage) OnPause(client, (PauseGameMessage)message); if (message is PauseGameMessage) OnPause(client, (PauseGameMessage)message);
else if (message is RaiseGameDifficulty) RaiseDifficulty(client, (RaiseGameDifficulty)message); else if (message is RaiseGameDifficulty) RaiseDifficulty(client, (RaiseGameDifficulty)message);
@ -881,17 +871,17 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
} }
private int[] questsOrder_a1 = new[] { 87700, 72095, 72221, 72061, 117779, 72738, 73236, 72546, 72801, 136656 }; private readonly int[] _questsOrderA1 = new[] { 87700, 72095, 72221, 72061, 117779, 72738, 73236, 72546, 72801, 136656 };
private int[] questsOrder_a2 = new[] { 80322, 93396, 74128, 57331, 78264, 78266, 57335, 57337, 121792, 57339 }; private readonly int[] _questsOrderA2 = new[] { 80322, 93396, 74128, 57331, 78264, 78266, 57335, 57337, 121792, 57339 };
private int[] questsOrder_a3 = new[] { 93595, 93684, 93697, 203595, 101756, 101750, 101758 }; private readonly int[] _questsOrderA3 = new[] { 93595, 93684, 93697, 203595, 101756, 101750, 101758 };
private int[] questsOrder_a4 = new[] { 112498, 113910, 114795, 114901 }; private readonly int[] _questsOrderA4 = new[] { 112498, 113910, 114795, 114901 };
private int[] questsOrder_a5 = new[] { 251355, 284683, 285098, 257120, 263851, 273790, 269552, 273408 }; private readonly int[] _questsOrderA5 = new[] { 251355, 284683, 285098, 257120, 263851, 273790, 269552, 273408 };
private int[] questsOrder_openWorld = new[] { 312429 }; private readonly int[] _questsOrderOpenWorld = new[] { 312429 };
public void SetQuestProgress(int currQuest, int step) public void SetQuestProgress(int currQuest, int step)
@ -940,7 +930,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
{ {
case Mode.Portals: case Mode.Portals:
QuestsOrder = new int[] { -1 }; QuestsOrder = new int[] { -1 };
StartingWorldSNO = WorldSno.weekly_challenge_hub; StartingWorldSno = WorldSno.weekly_challenge_hub;
QuestProgress = new QuestRegistry(this); QuestProgress = new QuestRegistry(this);
break; break;
} }
@ -950,9 +940,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
if (PvP) if (PvP)
{ {
CurrentAct = 0; CurrentAct = 0;
QuestsOrder = questsOrder_a1; QuestsOrder = _questsOrderA1;
QuestProgress = new QuestRegistry(this); QuestProgress = new QuestRegistry(this);
StartingWorldSNO = WorldSno.pvp_caout_arena_01; StartingWorldSno = WorldSno.pvp_caout_arena_01;
return; return;
} }
if (CurrentAct != act) if (CurrentAct != act)
@ -962,39 +952,39 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
switch (act) switch (act)
{ {
case 0: case 0:
QuestsOrder = questsOrder_a1; QuestsOrder = _questsOrderA1;
StartingWorldSNO = WorldSno.trout_town; StartingWorldSno = WorldSno.trout_town;
QuestProgress = new ActI(this); QuestProgress = new ActI(this);
break; break;
case 100: case 100:
QuestsOrder = questsOrder_a2; QuestsOrder = _questsOrderA2;
StartingWorldSNO = WorldSno.caout_refugeecamp; StartingWorldSno = WorldSno.caout_refugeecamp;
QuestProgress = new ActII(this); QuestProgress = new ActII(this);
break; break;
case 200: case 200:
QuestsOrder = questsOrder_a3; QuestsOrder = _questsOrderA3;
StartingWorldSNO = WorldSno.a3dun_hub_keep; StartingWorldSno = WorldSno.a3dun_hub_keep;
QuestProgress = new ActIII(this); QuestProgress = new ActIII(this);
break; break;
case 300: case 300:
QuestsOrder = questsOrder_a4; QuestsOrder = _questsOrderA4;
StartingWorldSNO = WorldSno.a4dun_heaven_hub_keep; StartingWorldSno = WorldSno.a4dun_heaven_hub_keep;
QuestProgress = new ActIV(this); QuestProgress = new ActIV(this);
break; break;
case 400: case 400:
QuestsOrder = questsOrder_a5; QuestsOrder = _questsOrderA5;
StartingWorldSNO = WorldSno.x1_westmarch_hub; StartingWorldSno = WorldSno.x1_westmarch_hub;
QuestProgress = new ActV(this); QuestProgress = new ActV(this);
break; break;
case 3000: case 3000:
QuestsOrder = questsOrder_openWorld; QuestsOrder = _questsOrderOpenWorld;
StartingWorldSNO = WorldSno.x1_tristram_adventure_mode_hub; StartingWorldSno = WorldSno.x1_tristram_adventure_mode_hub;
QuestProgress = new OpenWorld(this); QuestProgress = new OpenWorld(this);
QuestManager.SetBounties(); QuestManager.SetBounties();
break; break;
default: default:
QuestsOrder = questsOrder_a1; QuestsOrder = _questsOrderA1;
StartingWorldSNO = WorldSno.trout_town; StartingWorldSno = WorldSno.trout_town;
QuestProgress = new QuestRegistry(this); QuestProgress = new QuestRegistry(this);
break; break;
} }
@ -1159,9 +1149,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
if (diff > 0) if (diff > 0)
{ {
var handicapLevels = (GameBalance)MPQStorage.Data.Assets[SNOGroup.GameBalance][256027].Data; var handicapLevels = (GameBalance)MPQStorage.Data.Assets[SNOGroup.GameBalance][256027].Data;
HPModifier = handicapLevels.HandicapLevelTables[diff].HPMod; HpModifier = handicapLevels.HandicapLevelTables[diff].HPMod;
DmgModifier = handicapLevels.HandicapLevelTables[diff].DmgMod; DmgModifier = handicapLevels.HandicapLevelTables[diff].DmgMod;
XPModifier = (1f + handicapLevels.HandicapLevelTables[diff].XPMod); XpModifier = (1f + handicapLevels.HandicapLevelTables[diff].XPMod);
GoldModifier = (1f + handicapLevels.HandicapLevelTables[diff].GoldMod); GoldModifier = (1f + handicapLevels.HandicapLevelTables[diff].GoldMod);
} }
foreach (var wld in _worlds) foreach (var wld in _worlds)
@ -1287,8 +1277,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
} }
else else
{ {
var TotalWinner = Players.Values.Where(p => p.Attributes[GameAttribute.TeamID] == (RedTeamWins > BlueTeamWins ? 2 : 3)).FirstOrDefault(); var totalWinner = Players.Values.Where(p => p.Attributes[GameAttribute.TeamID] == (RedTeamWins > BlueTeamWins ? 2 : 3)).FirstOrDefault();
BroadcastMessage("Winner: " + TotalWinner.Toon.Name); BroadcastMessage("Winner: " + totalWinner.Toon.Name);
} }
//foreach (var player in this.Players.Values) //foreach (var player in this.Players.Values)
@ -1331,7 +1321,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
plr.Connection.Disconnect(); plr.Connection.Disconnect();
_worlds.Clear(); _worlds.Clear();
Thread.Sleep(1000); Thread.Sleep(1000);
GameDBSession.SessionDispose(); GameDbSession.SessionDispose();
GameManager.Games.Remove(GameId); GameManager.Games.Remove(GameId);
} }
@ -1413,12 +1403,12 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
var levelArea = scene.Specification.SNOLevelAreas[0]; var levelArea = scene.Specification.SNOLevelAreas[0];
foreach (var g_player in Players) foreach (var gPlayer in Players)
{ {
if (g_player.Value.World == encWorld) if (gPlayer.Value.World == encWorld)
g_player.Value.Teleport(startPoint); gPlayer.Value.Teleport(startPoint);
else else
g_player.Value.ChangeWorld(encWorld, startPoint); gPlayer.Value.ChangeWorld(encWorld, startPoint);
} }
@ -1429,7 +1419,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
if (QuestProgress.QuestTriggers.ContainsKey(levelArea)) //EnterLevelArea if (QuestProgress.QuestTriggers.ContainsKey(levelArea)) //EnterLevelArea
{ {
var trigger = QuestProgress.QuestTriggers[levelArea]; var trigger = QuestProgress.QuestTriggers[levelArea];
if (trigger.triggerType == DiIiS_NA.Core.MPQ.FileFormats.QuestStepObjectiveType.EnterLevelArea) if (trigger.triggerType == QuestStepObjectiveType.EnterLevelArea)
{ {
try try
{ {
@ -1460,56 +1450,56 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
ActorID = (int)encWorld.GetActorBySNO(ActorSno._test_cainintro_greybox_bridge_trout_tempworking).DynamicID(plr), Duration = 1f, Snap = false ActorID = (int)encWorld.GetActorBySNO(ActorSno._test_cainintro_greybox_bridge_trout_tempworking).DynamicID(plr), Duration = 1f, Snap = false
}); });
Actor CainRun = null; Actor cainRun = null;
Actor CainQuest = null; Actor cainQuest = null;
//Убираем лишнего каина. //Убираем лишнего каина.
foreach (var Cain in encWorld.GetActorsBySNO(ActorSno._cain_intro)) foreach (var cain in encWorld.GetActorsBySNO(ActorSno._cain_intro))
if (Cain.Position.Y > 140) if (cain.Position.Y > 140)
{ {
Cain.SetVisible(false); cain.SetVisible(false);
foreach (var plr in Players.Values) Cain.Unreveal(plr); foreach (var plr in Players.Values) cain.Unreveal(plr);
CainQuest = Cain; cainQuest = cain;
} }
else else
{ {
Cain.SetVisible(true); cain.SetVisible(true);
foreach (var plr in Players.Values) Cain.Reveal(plr); foreach (var plr in Players.Values) cain.Reveal(plr);
CainRun = Cain; cainRun = cain;
} }
//Скелеты //Скелеты
var Skeletons = encWorld.GetActorsBySNO(ActorSno._skeleton_cain); var skeletons = encWorld.GetActorsBySNO(ActorSno._skeleton_cain);
//Камни //Камни
//var Rocks = encWorld.GetActorsBySNO(176); //var Rocks = encWorld.GetActorsBySNO(176);
//Берем позицию для леорика, а самого на мороз //Берем позицию для леорика, а самого на мороз
Vector3D FakeLeoricPosition = new Vector3D(0f, 0f, 0f); Vector3D fakeLeoricPosition = new Vector3D(0f, 0f, 0f);
foreach (var fake in encWorld.GetActorsBySNO(ActorSno._skeletonking_ghost)) foreach (var fake in encWorld.GetActorsBySNO(ActorSno._skeletonking_ghost))
{ {
FakeLeoricPosition = fake.Position; fakeLeoricPosition = fake.Position;
fake.Destroy(); fake.Destroy();
} }
//Берем каина //Берем каина
var FirstPoint = new Vector3D(120.92718f, 121.26151f, 0.099973306f); var firstPoint = new Vector3D(120.92718f, 121.26151f, 0.099973306f);
var SecondPoint = new Vector3D(120.73298f, 160.61829f, 0.31863004f); var secondPoint = new Vector3D(120.73298f, 160.61829f, 0.31863004f);
var SceletonPoint = new Vector3D(120.11514f, 140.77332f, 0.31863004f); var sceletonPoint = new Vector3D(120.11514f, 140.77332f, 0.31863004f);
var FirstfacingAngle = ActorSystem.Movement.MovementHelpers.GetFacingAngle(CainRun, FirstPoint); var firstfacingAngle = ActorSystem.Movement.MovementHelpers.GetFacingAngle(cainRun, firstPoint);
var SecondfacingAngle = ActorSystem.Movement.MovementHelpers.GetFacingAngle(FirstPoint, SecondPoint); var secondfacingAngle = ActorSystem.Movement.MovementHelpers.GetFacingAngle(firstPoint, secondPoint);
var ThirdfacingAngle = ActorSystem.Movement.MovementHelpers.GetFacingAngle(SecondPoint, FakeLeoricPosition); var thirdfacingAngle = ActorSystem.Movement.MovementHelpers.GetFacingAngle(secondPoint, fakeLeoricPosition);
//Подготовления завершены - НАЧИНАЕМ ТЕАТР=) //Подготовления завершены - НАЧИНАЕМ ТЕАТР=)
Task.Delay(3000).ContinueWith(delegate Task.Delay(3000).ContinueWith(delegate
{ {
CainRun.Move(FirstPoint, FirstfacingAngle); cainRun.Move(firstPoint, firstfacingAngle);
foreach (var plr in Players.Values) foreach (var plr in Players.Values)
plr.Conversations.StartConversation(80920);//Запуск диалога - 80920 //Фраза Каина, бежит первым до начала мостика, оглядывается. //"Cain_Run_CainIntro", 81080 - Анимация plr.Conversations.StartConversation(80920);//Запуск диалога - 80920 //Фраза Каина, бежит первым до начала мостика, оглядывается. //"Cain_Run_CainIntro", 81080 - Анимация
Task.Delay(5000).ContinueWith(delegate Task.Delay(5000).ContinueWith(delegate
{ {
foreach (var skeleton in Skeletons) foreach (var skeleton in skeletons)
{ {
skeleton.Move(SceletonPoint, ActorSystem.Movement.MovementHelpers.GetFacingAngle(skeleton, SceletonPoint)); skeleton.Move(sceletonPoint, ActorSystem.Movement.MovementHelpers.GetFacingAngle(skeleton, sceletonPoint));
} }
CainRun.Move(SecondPoint, SecondfacingAngle); cainRun.Move(secondPoint, secondfacingAngle);
Task.Delay(7000).ContinueWith(delegate Task.Delay(7000).ContinueWith(delegate
{ {
@ -1520,7 +1510,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
var bridge = encWorld.GetActorBySNO(ActorSno._test_cainintro_greybox_bridge_trout_tempworking); var bridge = encWorld.GetActorBySNO(ActorSno._test_cainintro_greybox_bridge_trout_tempworking);
bridge.PlayAnimation(5, (AnimationSno)bridge.AnimationSet.TagMapAnimDefault[AnimationSetKeys.DeathDefault]); bridge.PlayAnimation(5, (AnimationSno)bridge.AnimationSet.TagMapAnimDefault[AnimationSetKeys.DeathDefault]);
//} //}
foreach (var skeleton in Skeletons) foreach (var skeleton in skeletons)
{ {
//Убиваем скелетов //Убиваем скелетов
skeleton.Destroy(); skeleton.Destroy();
@ -1528,11 +1518,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
}); });
Task.Delay(5000).ContinueWith(delegate Task.Delay(5000).ContinueWith(delegate
{ {
CainRun.Move(SecondPoint, ThirdfacingAngle); cainRun.Move(secondPoint, thirdfacingAngle);
//(Должен быть диалог Король скилет.) //(Должен быть диалог Король скилет.)
var Leoric = encWorld.SpawnMonster(ActorSno._skeletonking_ghost, FakeLeoricPosition); var leoric = encWorld.SpawnMonster(ActorSno._skeletonking_ghost, fakeLeoricPosition);
Leoric.PlayActionAnimation(AnimationSno.skeletonking_ghost_spawn); leoric.PlayActionAnimation(AnimationSno.skeletonking_ghost_spawn);
Task.Delay(1000).ContinueWith(delegate Task.Delay(1000).ContinueWith(delegate
{ {
foreach (var plr in Players.Values) foreach (var plr in Players.Values)
@ -1541,7 +1531,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
{ {
//Leoric.PlayActionAnimation(9854); //Леорик призывает скелетов //Leoric.PlayActionAnimation(9854); //Леорик призывает скелетов
Leoric.PlayActionAnimation(AnimationSno.skeletonking_ghost_despawn); //Себаса leoric.PlayActionAnimation(AnimationSno.skeletonking_ghost_despawn); //Себаса
Task.Delay(1000).ContinueWith(delegate Task.Delay(1000).ContinueWith(delegate
{ {
foreach (var plr in Players.Values) foreach (var plr in Players.Values)
@ -1549,12 +1539,12 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
plr.InGameClient.SendMessage(new BoolDataMessage(Opcodes.CameraTriggerFadeToBlackMessage) { Field0 = true }); plr.InGameClient.SendMessage(new BoolDataMessage(Opcodes.CameraTriggerFadeToBlackMessage) { Field0 = true });
plr.InGameClient.SendMessage(new SimpleMessage(Opcodes.CameraSriptedSequenceStopMessage) { }); plr.InGameClient.SendMessage(new SimpleMessage(Opcodes.CameraSriptedSequenceStopMessage) { });
} }
CainQuest.SetVisible(true); cainQuest.SetVisible(true);
CainRun.SetVisible(false); cainRun.SetVisible(false);
foreach (var fake in encWorld.GetActorsBySNO(ActorSno._skeletonking_ghost)) foreach (var fake in encWorld.GetActorsBySNO(ActorSno._skeletonking_ghost))
{ {
FakeLeoricPosition = fake.Position; fakeLeoricPosition = fake.Position;
fake.Destroy(); fake.Destroy();
} }
}); });
@ -1573,13 +1563,13 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
case 158915: //ButcherLair case 158915: //ButcherLair
//if (this.CurrentAct == 0) //if (this.CurrentAct == 0)
var Butcher = encWorld.GetActorBySNO(ActorSno._butcher); var butcher = encWorld.GetActorBySNO(ActorSno._butcher);
if (Butcher != null) if (butcher != null)
(Butcher as Monster).Brain.DeActivate(); (butcher as Monster).Brain.DeActivate();
else else
{ {
Butcher = encWorld.SpawnMonster(ActorSno._butcher, new Vector3D { X = 93.022f, Y = 89.86f, Z = 0.1f }); butcher = encWorld.SpawnMonster(ActorSno._butcher, new Vector3D { X = 93.022f, Y = 89.86f, Z = 0.1f });
(Butcher as Monster).Brain.DeActivate(); (butcher as Monster).Brain.DeActivate();
} }
Task.Delay(1000).ContinueWith(delegate Task.Delay(1000).ContinueWith(delegate
{ {
@ -1589,10 +1579,10 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
Task.Delay(1000).ContinueWith(delegate Task.Delay(1000).ContinueWith(delegate
{ {
if (Butcher != null) if (butcher != null)
(Butcher as Monster).Brain.DeActivate(); (butcher as Monster).Brain.DeActivate();
foreach (var plr in Players.Values) foreach (var plr in Players.Values)
plr.InGameClient.SendMessage(new MessageSystem.Message.Definitions.Camera.CameraFocusMessage() { ActorID = (int)Butcher.DynamicID(plr), Duration = 1f, Snap = false }); plr.InGameClient.SendMessage(new MessageSystem.Message.Definitions.Camera.CameraFocusMessage() { ActorID = (int)butcher.DynamicID(plr), Duration = 1f, Snap = false });
foreach (var plr in Players.Values) foreach (var plr in Players.Values)
@ -1608,7 +1598,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
} }
Task.Delay(1500).ContinueWith(delegate Task.Delay(1500).ContinueWith(delegate
{ {
(Butcher as Monster).Brain.Activate(); (butcher as Monster).Brain.Activate();
}); });
}); });
}); });
@ -1620,46 +1610,46 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
foreach (var bounty in QuestManager.Bounties) foreach (var bounty in QuestManager.Bounties)
bounty.CheckLevelArea(levelArea); bounty.CheckLevelArea(levelArea);
CurrentEncounter.acceptedPlayers = 0; CurrentEncounter.AcceptedPlayers = 0;
CurrentEncounter.activated = false; CurrentEncounter.Activated = false;
} }
public void AcceptBossEncounter() public void AcceptBossEncounter()
{ {
CurrentEncounter.acceptedPlayers++; CurrentEncounter.AcceptedPlayers++;
if (CurrentEncounter.acceptedPlayers >= Players.Count) if (CurrentEncounter.AcceptedPlayers >= Players.Count)
TeleportToBossEncounter(CurrentEncounter.SnoId); TeleportToBossEncounter(CurrentEncounter.SnoId);
} }
public void DeclineBossEncounter() public void DeclineBossEncounter()
{ {
CurrentEncounter.activated = false; CurrentEncounter.Activated = false;
CurrentEncounter.acceptedPlayers = 0; CurrentEncounter.AcceptedPlayers = 0;
} }
public void AddOnLoadWorldAction(WorldSno worldSNO, Action action) public void AddOnLoadWorldAction(WorldSno worldSno, Action action)
{ {
Logger.Trace("AddOnLoadWorldAction: {0}", worldSNO); Logger.Trace("AddOnLoadWorldAction: {0}", worldSno);
if (Players.Values.Any(p => p.World != null && p.World.SNO == worldSNO)) if (Players.Values.Any(p => p.World != null && p.World.SNO == worldSno))
{ {
action.Invoke(); action.Invoke();
} }
else else
{ {
if (!OnLoadWorldActions.ContainsKey(worldSNO)) if (!OnLoadWorldActions.ContainsKey(worldSno))
OnLoadWorldActions.Add(worldSNO, new List<Action>()); OnLoadWorldActions.Add(worldSno, new List<Action>());
OnLoadWorldActions[worldSNO].Add(action); OnLoadWorldActions[worldSno].Add(action);
} }
} }
public void AddOnLoadSceneAction(int sceneSNO, Action action) public void AddOnLoadSceneAction(int sceneSno, Action action)
{ {
Logger.Trace("AddOnLoadSceneAction: {0}", sceneSNO); Logger.Trace("AddOnLoadSceneAction: {0}", sceneSno);
if (!OnLoadSceneActions.ContainsKey(sceneSNO)) if (!OnLoadSceneActions.ContainsKey(sceneSno))
OnLoadSceneActions.Add(sceneSNO, new List<Action>()); OnLoadSceneActions.Add(sceneSno, new List<Action>());
OnLoadSceneActions[sceneSNO].Add(action); OnLoadSceneActions[sceneSno].Add(action);
} }
#endregion #endregion
@ -1683,17 +1673,17 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
_worlds.TryRemove(world.SNO, out removed); _worlds.TryRemove(world.SNO, out removed);
} }
public World GetWorld(WorldSno worldSNO) public World GetWorld(WorldSno worldSno)
{ {
if (worldSNO == WorldSno.__NONE) if (worldSno == WorldSno.__NONE)
return null; return null;
World world; World world;
if (CurrentAct != 3000 && worldSNO == WorldSno.x1_tristram_adventure_mode_hub) //fix for a1 Tristram if (CurrentAct != 3000 && worldSno == WorldSno.x1_tristram_adventure_mode_hub) //fix for a1 Tristram
worldSNO = WorldSno.trout_town; worldSno = WorldSno.trout_town;
if (!WorldExists(worldSNO)) // If it doesn't exist, try to load it if (!WorldExists(worldSno)) // If it doesn't exist, try to load it
{ {
//Task loading = Task.Run(() => {world = this.WorldGenerator.Generate(worldSNO);}); //Task loading = Task.Run(() => {world = this.WorldGenerator.Generate(worldSNO);});
//if (!loading.Wait(TimeSpan.FromSeconds(30))) //if (!loading.Wait(TimeSpan.FromSeconds(30)))
@ -1712,21 +1702,21 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
timer.Start();*/ timer.Start();*/
//Task.Delay(1000).ContinueWith(t => { if (!this.WorldGenerator.Actions.Contains(action)) loaded = true; }).Wait(); //Task.Delay(1000).ContinueWith(t => { if (!this.WorldGenerator.Actions.Contains(action)) loaded = true; }).Wait();
//} //}
world = WorldGenerator.Generate(worldSNO); world = WorldGenerator.Generate(worldSno);
if (world == null) Logger.Warn("Failed to generate world with sno: {0}", worldSNO); if (world == null) Logger.Warn("Failed to generate world with sno: {0}", worldSno);
} }
_worlds.TryGetValue(worldSNO, out world); _worlds.TryGetValue(worldSno, out world);
return world; return world;
} }
public bool WorldExists(WorldSno worldSNO) public bool WorldExists(WorldSno worldSno)
{ {
return _worlds.ContainsKey(worldSNO); return _worlds.ContainsKey(worldSno);
} }
public bool WorldCleared(WorldSno worldSNO) public bool WorldCleared(WorldSno worldSno)
{ {
return _worlds[worldSNO].Actors.Values.OfType<Monster>().Where(m => m.OriginalLevelArea != -1 && !m.Dead).Count() < 5; return _worlds[worldSno].Actors.Values.OfType<Monster>().Where(m => m.OriginalLevelArea != -1 && !m.Dead).Count() < 5;
} }
/// <summary> /// <summary>
@ -1736,15 +1726,21 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
/// <returns><see cref="World"/></returns> /// <returns><see cref="World"/></returns>
public World GetWayPointWorldById(int id) public World GetWayPointWorldById(int id)
{ {
Logger.MethodTrace($"id {id}");
bool isOpenWorld = CurrentAct == 3000; bool isOpenWorld = CurrentAct == 3000;
var actData = ((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][CurrentActSNOid].Data).WayPointInfo.ToList(); ImmutableArray<WaypointInfo> actData;
if (isOpenWorld) if (isOpenWorld)
actData = ((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70015].Data).WayPointInfo actData = ((Act)MPQStorage.Data.Assets[SNOGroup.Act][70015].Data).WayPointInfo
.Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70016].Data).WayPointInfo) .Union(((Act)MPQStorage.Data.Assets[SNOGroup.Act][70016].Data).WayPointInfo)
.Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70017].Data).WayPointInfo) .Union(((Act)MPQStorage.Data.Assets[SNOGroup.Act][70017].Data).WayPointInfo)
.Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70018].Data).WayPointInfo) .Union(((Act)MPQStorage.Data.Assets[SNOGroup.Act][70018].Data).WayPointInfo)
.Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][236915].Data).WayPointInfo) .Union(((Act)MPQStorage.Data.Assets[SNOGroup.Act][236915].Data).WayPointInfo)
.Where(w => w.SNOWorld != -1).ToList(); .Where(w => w.SNOWorld != -1).ToImmutableArray();
else
{
actData = ((Act)MPQStorage.Data.Assets[SNOGroup.Act][CurrentActSnoId].Data).WayPointInfo.ToImmutableArray();
}
var wayPointInfo = actData.Where(w => w.Flags == 3 || (isOpenWorld ? (w.Flags == 2) : (w.Flags == 1))).ToList(); var wayPointInfo = actData.Where(w => w.Flags == 3 || (isOpenWorld ? (w.Flags == 2) : (w.Flags == 1))).ToList();
//Logger.Debug("GetWayPointWorldById: world id {0}", wayPointInfo[id].SNOWorld); //Logger.Debug("GetWayPointWorldById: world id {0}", wayPointInfo[id].SNOWorld);
return GetWorld((WorldSno)wayPointInfo[id].SNOWorld); return GetWorld((WorldSno)wayPointInfo[id].SNOWorld);

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using DiIiS_NA.Core.Extensions; using DiIiS_NA.Core.Extensions;
@ -191,10 +192,10 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (!Game.Empty) if (!Game.Empty)
{ {
SaveQuestProgress(true); SaveQuestProgress(true);
Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/], completed $[underline white]${Quests[Game.CurrentQuest].Completed}$[/]$"); Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/]$, completed $[underline white]${Quests[Game.CurrentQuest].Completed}$[/]$");
foreach (var player in Game.Players.Values) foreach (var player in Game.Players.Values)
{ {
int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp * Game.XPModifier); int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp * Game.XpModifier);
int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold * Game.GoldModifier); int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold * Game.GoldModifier);
if (Game.CurrentQuest != 312429) if (Game.CurrentQuest != 312429)
{ {
@ -269,7 +270,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
} }
OnQuestProgress(); OnQuestProgress();
AutoSetQuestMarker(); AutoSetQuestMarker();
Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/], step $[underline white]${Game.CurrentStep}$[/]$"); Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/]$, step $[underline white]${Game.CurrentStep}$[/]$");
} }
public void SideAdvance() public void SideAdvance()
@ -299,7 +300,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
foreach (var player in Game.Players.Values) foreach (var player in Game.Players.Values)
{ {
int xpReward = (int)(SideQuests[Game.CurrentSideQuest].RewardXp * Game.XPModifier); int xpReward = (int)(SideQuests[Game.CurrentSideQuest].RewardXp * Game.XpModifier);
int goldReward = (int)(SideQuests[Game.CurrentSideQuest].RewardGold * Game.GoldModifier); int goldReward = (int)(SideQuests[Game.CurrentSideQuest].RewardGold * Game.GoldModifier);
player.InGameClient.SendMessage(new QuestStepCompleteMessage() player.InGameClient.SendMessage(new QuestStepCompleteMessage()
@ -330,7 +331,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
} }
var toon = player.Toon.DBToon; var toon = player.Toon.DBToon;
toon.EventsCompleted++; toon.EventsCompleted++;
Game.GameDBSession.SessionUpdate(toon); Game.GameDbSession.SessionUpdate(toon);
player.CheckQuestCriteria(Game.CurrentSideQuest); player.CheckQuestCriteria(Game.CurrentSideQuest);
}; };
@ -538,19 +539,27 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
public void AutoSetQuestMarker() public void AutoSetQuestMarker()
{ {
Logger.MethodTrace(
$"{Game.QuestProgress.QuestTriggers.Count} triggers found on {Game.CurrentActEnum.ToString()} - quest {Game.CurrentQuest} step {Game.CurrentStep}");
// TODO: more triggers?
#if DEBUG
if (Game.QuestProgress.QuestTriggers.Count > 1)
Logger.Warn($"Found {Game.QuestProgress.QuestTriggers.Count} triggers on {Game.CurrentActEnum.ToString()} - quest {Game.CurrentQuest} step {Game.CurrentStep} but only one is supported");
#endif
if (Game.QuestProgress.QuestTriggers.Count == 1) if (Game.QuestProgress.QuestTriggers.Count == 1)
{ {
Logger.MethodTrace($"{Game.QuestProgress.QuestTriggers.Count} triggers found");
var trigger = Game.QuestProgress.QuestTriggers.First(); var trigger = Game.QuestProgress.QuestTriggers.First();
if (trigger.Value.triggerType == QuestStepObjectiveType.InteractWithActor) switch (trigger.Value.triggerType)
{
case QuestStepObjectiveType.InteractWithActor:
{
foreach (var world in Game.Worlds) foreach (var world in Game.Worlds)
{ {
var actors = world.GetActorsBySNO((ActorSno)trigger.Key).Where(d => d.Visible); var actor = world.GetActorsBySNO((ActorSno)trigger.Key).FirstOrDefault(d => d.Visible);
Actor actor = null;
if (actors.Count() == 1) actor = actors.First();
if (actor != null) if (actor != null)
foreach (var plr in world.Players.Values) world.BroadcastOperation(player =>
plr.InGameClient.SendMessage(new MapMarkerInfoMessage player.InGameClient.SendMessage(new MapMarkerInfoMessage
{ {
HashedName = StringHashHelper.HashItemName("QuestMarker"), HashedName = StringHashHelper.HashItemName("QuestMarker"),
Place = new WorldPlace { Position = actor.Position, WorldID = world.GlobalID }, Place = new WorldPlace { Position = actor.Position, WorldID = world.GlobalID },
@ -565,18 +574,20 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
RespectsFoW = false, RespectsFoW = false,
IsPing = true, IsPing = true,
PlayerUseFlags = 0 PlayerUseFlags = 0
}); }));
} }
if (trigger.Value.triggerType == QuestStepObjectiveType.HadConversation) break;
}
case QuestStepObjectiveType.HadConversation:
{
foreach (var world in Game.Worlds) foreach (var world in Game.Worlds)
{ {
var actors = world.Actors.Values.Where(d => d.Visible && (d is InteractiveNPC) && (d as InteractiveNPC).Conversations.Any(c => c.ConversationSNO == trigger.Key)); var actor = world.Actors.Values.FirstOrDefault(d => d.Visible && (d is InteractiveNPC npc)
Actor actor = null; && npc.Conversations.Any(c => c.ConversationSNO == trigger.Key));
if (actors.Count() == 1) actor = actors.First();
if (actor != null) if (actor != null)
foreach (var plr in world.Players.Values) world.BroadcastOperation(player =>
plr.InGameClient.SendMessage(new MapMarkerInfoMessage player.InGameClient.SendMessage(new MapMarkerInfoMessage
{ {
HashedName = StringHashHelper.HashItemName("QuestMarker"), HashedName = StringHashHelper.HashItemName("QuestMarker"),
Place = new WorldPlace { Position = actor.Position, WorldID = world.GlobalID }, Place = new WorldPlace { Position = actor.Position, WorldID = world.GlobalID },
@ -591,7 +602,11 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
RespectsFoW = false, RespectsFoW = false,
IsPing = true, IsPing = true,
PlayerUseFlags = 0 PlayerUseFlags = 0
}); }));
}
break;
}
} }
} }
} }
@ -670,30 +685,26 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
public bool HasCurrentQuest(int snoQuest, int Step, bool strictFilter) public bool HasCurrentQuest(int snoQuest, int Step, bool strictFilter)
{ {
if (Quests.ContainsKey(snoQuest) || SideQuests.ContainsKey(snoQuest)) if (!Quests.ContainsKey(snoQuest) && !SideQuests.ContainsKey(snoQuest)) return false;
{
if (strictFilter) if (strictFilter)
{ {
if ((Game.CurrentQuest == snoQuest) && (Game.CurrentStep == Step) if ((Game.CurrentQuest == snoQuest) && (Game.CurrentStep == Step) ||
||
(Game.CurrentSideQuest == snoQuest) && (Game.CurrentSideStep == Step)) (Game.CurrentSideQuest == snoQuest) && (Game.CurrentSideStep == Step))
return true; return true;
} }
else else
{ {
if ((Game.CurrentQuest == snoQuest || snoQuest == -1) && (Game.CurrentStep == Step || Step == -1 || Step == 0) if ((Game.CurrentQuest == snoQuest || snoQuest == -1) &&
|| (Game.CurrentStep == Step || Step == -1 || Step == 0) ||
(Game.CurrentSideQuest == snoQuest || snoQuest == -1) && (Game.CurrentSideStep == Step || Step == -1 || Step == 0)) (Game.CurrentSideQuest == snoQuest || snoQuest == -1) &&
(Game.CurrentSideStep == Step || Step == -1 || Step == 0))
return true; return true;
} }
}
return false; return false;
} }
public bool HasQuest(int snoQuest) public bool HasQuest(int snoQuest) => Quests.ContainsKey(snoQuest);
{
return Quests.ContainsKey(snoQuest);
}
public void SetQuestsForJoined(Player joinedPlayer) public void SetQuestsForJoined(Player joinedPlayer)
{ {
@ -710,14 +721,10 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
}); });
} }
public bool IsDone(int snoQuest) public bool IsDone(int snoQuest) => Quests.ContainsKey(snoQuest) && Quests[snoQuest].Completed;
{
return Quests.ContainsKey(snoQuest) && Quests[snoQuest].Completed;
}
public bool IsInQuestRange(QuestRange range) public bool IsInQuestRange(QuestRange range)
{ {
if (range.Header.SNOId == 312431) return (Game.CurrentAct == 3000); if (range.Header.SNOId == 312431) return (Game.CurrentAct == 3000);
if (range.Header.SNOId == 214766) return true; if (range.Header.SNOId == 214766) return true;
@ -725,19 +732,19 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
bool ended = false; bool ended = false;
foreach (var range_entry in range.Enitys) foreach (var rangeEntry in range.Enitys)
{ {
if (range_entry != null) if (rangeEntry != null)
{ {
if (range_entry.Start.SNOQuest == -1 || range_entry.Start.StepID == -1) if (rangeEntry.Start.SNOQuest == -1 || rangeEntry.Start.StepID == -1)
started = true; started = true;
else else
{ {
if (Quests.ContainsKey(range_entry.Start.SNOQuest) && Quests[range_entry.Start.SNOQuest].Steps.ContainsKey(range_entry.Start.StepID)) if (Quests.ContainsKey(rangeEntry.Start.SNOQuest) && Quests[rangeEntry.Start.SNOQuest].Steps.ContainsKey(rangeEntry.Start.StepID))
{ {
if (Quests[range_entry.Start.SNOQuest].Completed || if (Quests[rangeEntry.Start.SNOQuest].Completed ||
Quests[range_entry.Start.SNOQuest].Steps[range_entry.Start.StepID].Completed || Quests[rangeEntry.Start.SNOQuest].Steps[rangeEntry.Start.StepID].Completed ||
(Game.CurrentQuest == range_entry.Start.SNOQuest && Game.CurrentStep == range_entry.Start.StepID)) // rumford conversation needs current step (Game.CurrentQuest == rangeEntry.Start.SNOQuest && Game.CurrentStep == rangeEntry.Start.StepID)) // rumford conversation needs current step
started = true; started = true;
} }
//else logger.Warn("QuestRange {0} references unknown quest {1}", range.Header.SNOId, range.Start.SNOQuest); //else logger.Warn("QuestRange {0} references unknown quest {1}", range.Header.SNOId, range.Start.SNOQuest);
@ -745,14 +752,14 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
//Logger.Debug("IsInQuestRange {0} and started? {1} ", range.Header.SNOId, started); //Logger.Debug("IsInQuestRange {0} and started? {1} ", range.Header.SNOId, started);
if (range_entry.End.SNOQuest == -1 || range_entry.End.StepID < 0) if (rangeEntry.End.SNOQuest == -1 || rangeEntry.End.StepID < 0)
ended = false; ended = false;
else else
{ {
if (Quests.ContainsKey(range_entry.End.SNOQuest) && Quests[range_entry.End.SNOQuest].Steps.ContainsKey(range_entry.End.StepID)) if (Quests.ContainsKey(rangeEntry.End.SNOQuest) && Quests[rangeEntry.End.SNOQuest].Steps.ContainsKey(rangeEntry.End.StepID))
{ {
if (Quests[range_entry.End.SNOQuest].Completed || if (Quests[rangeEntry.End.SNOQuest].Completed ||
Quests[range_entry.End.SNOQuest].Steps[range_entry.End.StepID].Completed) Quests[rangeEntry.End.SNOQuest].Steps[rangeEntry.End.StepID].Completed)
ended = true; ended = true;
} }
//else logger.Warn("QuestRange {0} references unknown quest {1}", range.Header.SNOId, range.End.SNOQuest); //else logger.Warn("QuestRange {0} references unknown quest {1}", range.Header.SNOId, range.End.SNOQuest);
@ -811,7 +818,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
player.Toon.CurrentQuestId = Game.CurrentQuest; player.Toon.CurrentQuestId = Game.CurrentQuest;
player.Toon.CurrentQuestStepId = Game.CurrentStep; player.Toon.CurrentQuestStepId = Game.CurrentStep;
List<DBQuestHistory> query = Game.GameDBSession.SessionQueryWhere<DBQuestHistory>( List<DBQuestHistory> query = Game.GameDbSession.SessionQueryWhere<DBQuestHistory>(
dbi => dbi.DBToon.Id == player.Toon.PersistentID && dbi.QuestId == Game.CurrentQuest); dbi => dbi.DBToon.Id == player.Toon.PersistentID && dbi.QuestId == Game.CurrentQuest);
if (query.Count == 0) if (query.Count == 0)
{ {
@ -819,7 +826,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
questHistory.DBToon = player.Toon.DBToon; questHistory.DBToon = player.Toon.DBToon;
questHistory.QuestId = Game.CurrentQuest; questHistory.QuestId = Game.CurrentQuest;
questHistory.QuestStep = Game.CurrentStep; questHistory.QuestStep = Game.CurrentStep;
Game.GameDBSession.SessionSave(questHistory); Game.GameDbSession.SessionSave(questHistory);
} }
else else
{ {
@ -828,7 +835,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{ {
questHistory.QuestStep = Game.CurrentStep; questHistory.QuestStep = Game.CurrentStep;
if (questCompleted) questHistory.isCompleted = true; if (questCompleted) questHistory.isCompleted = true;
Game.GameDBSession.SessionUpdate(questHistory); Game.GameDbSession.SessionUpdate(questHistory);
} }
} }
} }
@ -908,7 +915,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
foreach (var player in QuestManager.Game.Players.Values) foreach (var player in QuestManager.Game.Players.Values)
{ {
List<GameServer.GSSystem.MapSystem.Scene> Scenes = new List<GameServer.GSSystem.MapSystem.Scene>(); List<GameServer.GSSystem.MapSystem.Scene> Scenes = new List<GameServer.GSSystem.MapSystem.Scene>();
int MonsterCount = 0; int monsterCount = 0;
foreach (var scene in QuestManager.Game.GetWorld(world).Scenes.Values) foreach (var scene in QuestManager.Game.GetWorld(world).Scenes.Values)
if (!scene.SceneSNO.Name.ToLower().Contains("filler")) if (!scene.SceneSNO.Name.ToLower().Contains("filler"))
if (scene.Specification.SNOLevelAreas[0] == LevelArea) if (scene.Specification.SNOLevelAreas[0] == LevelArea)
@ -916,7 +923,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
Scenes.Add(scene); Scenes.Add(scene);
foreach (var act in scene.Actors) foreach (var act in scene.Actors)
if (act is Monster) if (act is Monster)
MonsterCount++; monsterCount++;
} }
@ -929,22 +936,22 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
Counter = AdditionalTargetCounter, Counter = AdditionalTargetCounter,
Checked = (AdditionalTargetNeed <= AdditionalTargetCounter) ? 1 : 0 Checked = (AdditionalTargetNeed <= AdditionalTargetCounter) ? 1 : 0
}); });
if (MonsterCount < AdditionalTargetCounter + 20) if (monsterCount < AdditionalTargetCounter + 20)
{ {
while (MonsterCount < AdditionalTargetCounter + 20) while (monsterCount < AdditionalTargetCounter + 20)
{ {
GameServer.Core.Types.Math.Vector3D SSV = Scenes[RandomHelper.Next(0, Scenes.Count)].Position; GameServer.Core.Types.Math.Vector3D scenePoint = Scenes[RandomHelper.Next(0, Scenes.Count)].Position;
GameServer.Core.Types.Math.Vector3D SP = null; GameServer.Core.Types.Math.Vector3D point = null;
while (true) while (true)
{ {
SP = new GameServer.Core.Types.Math.Vector3D(SSV.X + RandomHelper.Next(0, 240), SSV.Y + RandomHelper.Next(0, 240), SSV.Z); point = new GameServer.Core.Types.Math.Vector3D(scenePoint.X + RandomHelper.Next(0, 240), scenePoint.Y + RandomHelper.Next(0, 240), scenePoint.Z);
if (QuestManager.Game.GetWorld(world).CheckLocationForFlag(SP, Scene.NavCellFlags.AllowWalk)) if (QuestManager.Game.GetWorld(world).CheckLocationForFlag(point, Scene.NavCellFlags.AllowWalk))
break; break;
} }
QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee[FastRandom.Instance.Next(GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee.Count())], SP); QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee[FastRandom.Instance.Next(GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee.Count())], point);
MonsterCount++; monsterCount++;
} }
} //Нужен дополнительный спаун монстров, их мало } // Need additional monster spawn, there are few of them
} }
if (Target == snoId) if (Target == snoId)
{ {
@ -963,23 +970,23 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (!TargetSpawned) if (!TargetSpawned)
if (QuestManager.Game.GetWorld(world).GetActorBySNO((ActorSno)Target) == null) if (QuestManager.Game.GetWorld(world).GetActorBySNO((ActorSno)Target) == null)
{ {
List<GameServer.GSSystem.MapSystem.Scene> Scenes = new List<GameServer.GSSystem.MapSystem.Scene>(); List<GameServer.GSSystem.MapSystem.Scene> scenes = new List<GameServer.GSSystem.MapSystem.Scene>();
foreach (var scene in QuestManager.Game.GetWorld(world).Scenes.Values) foreach (var scene in QuestManager.Game.GetWorld(world).Scenes.Values)
{ {
if (!scene.SceneSNO.Name.ToLower().Contains("filler")) if (!scene.SceneSNO.Name.ToLower().Contains("filler"))
if (scene.Specification.SNOLevelAreas[0] == LevelArea) if (scene.Specification.SNOLevelAreas[0] == LevelArea)
Scenes.Add(scene); scenes.Add(scene);
} }
GameServer.Core.Types.Math.Vector3D SSV = Scenes[RandomHelper.Next(0, Scenes.Count - 1)].Position; GameServer.Core.Types.Math.Vector3D scenePoint = scenes[RandomHelper.Next(0, scenes.Count - 1)].Position;
GameServer.Core.Types.Math.Vector3D SP = null; GameServer.Core.Types.Math.Vector3D point = null;
while (true) while (true)
{ {
SP = new GameServer.Core.Types.Math.Vector3D(SSV.X + RandomHelper.Next(0, 240), SSV.Y + RandomHelper.Next(0, 240), SSV.Z); point = new GameServer.Core.Types.Math.Vector3D(scenePoint.X + RandomHelper.Next(0, 240), scenePoint.Y + RandomHelper.Next(0, 240), scenePoint.Z);
if (QuestManager.Game.GetWorld(world).CheckLocationForFlag(SP, Scene.NavCellFlags.AllowWalk)) if (QuestManager.Game.GetWorld(world).CheckLocationForFlag(point, Scene.NavCellFlags.AllowWalk))
break; break;
} }
QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)Target, SP); QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)Target, point);
TargetSpawned = true; TargetSpawned = true;
} }
@ -1015,7 +1022,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{ {
foreach (var player in QuestManager.Game.Players.Values) foreach (var player in QuestManager.Game.Players.Values)
{ {
var xpReward = 1000 * player.Level * (1 + (player.Level / 7)) * QuestManager.Game.XPModifier; var xpReward = 1000 * player.Level * (1 + (player.Level / 7)) * QuestManager.Game.XpModifier;
if (Type == BountyData.BountyType.KillUnique) if (Type == BountyData.BountyType.KillUnique)
xpReward *= 1.8f; xpReward *= 1.8f;
if (Type == BountyData.BountyType.ClearDungeon) if (Type == BountyData.BountyType.ClearDungeon)
@ -1049,8 +1056,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
player.UpdateAchievementCounter(412, 1); player.UpdateAchievementCounter(412, 1);
} }
Finished = true; Finished = true;
QuestManager.Game.BountiesCompleted[Act]++; if (++QuestManager.Game.BountiesCompleted[Act] == 5)
if (QuestManager.Game.BountiesCompleted[Act] == 5)
{ {
switch (Act) switch (Act)
{ {

View File

@ -24,7 +24,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem.Implementations
target.Attributes[GameAttribute.DyeType] = Attributes[GameAttribute.DyeType]; target.Attributes[GameAttribute.DyeType] = Attributes[GameAttribute.DyeType];
target.DBInventory.DyeType = Attributes[GameAttribute.DyeType]; target.DBInventory.DyeType = Attributes[GameAttribute.DyeType];
player.World.Game.GameDBSession.SessionUpdate(target.DBInventory); player.World.Game.GameDbSession.SessionUpdate(target.DBInventory);
player.Inventory.SendVisualInventory(player); player.Inventory.SendVisualInventory(player);

View File

@ -359,7 +359,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
// DBInventory.Unidentified = false; // DBInventory.Unidentified = false;
Attributes[GameAttribute.Unidentified] = false; Attributes[GameAttribute.Unidentified] = false;
Owner.World.Game.GameDBSession.SessionUpdate(DBInventory); Owner.World.Game.GameDbSession.SessionUpdate(DBInventory);
if (Owner is Player player) if (Owner is Player player)
{ {
Unreveal(player); Unreveal(player);
@ -572,20 +572,20 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
{ {
Attributes[GameAttribute.Durability_Cur] = newDurability; Attributes[GameAttribute.Durability_Cur] = newDurability;
DBInventory.Durability = newDurability; DBInventory.Durability = newDurability;
Owner.World.Game.GameDBSession.SessionUpdate(DBInventory); Owner.World.Game.GameDbSession.SessionUpdate(DBInventory);
} }
public void UpdateTransmog(int newTransmogGBID) public void UpdateTransmog(int newTransmogGBID)
{ {
Attributes[GameAttribute.TransmogGBID] = newTransmogGBID; Attributes[GameAttribute.TransmogGBID] = newTransmogGBID;
DBInventory.TransmogGBID = newTransmogGBID; DBInventory.TransmogGBID = newTransmogGBID;
Owner.World.Game.GameDBSession.SessionUpdate(DBInventory); Owner.World.Game.GameDbSession.SessionUpdate(DBInventory);
} }
public void SaveAttributes() public void SaveAttributes()
{ {
DBInventory.Attributes = Attributes.Serialize(); DBInventory.Attributes = Attributes.Serialize();
Owner.World.Game.GameDBSession.SessionUpdate(DBInventory); Owner.World.Game.GameDbSession.SessionUpdate(DBInventory);
} }
public void UpdateStackCount(int newCount) public void UpdateStackCount(int newCount)
@ -597,7 +597,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
Attributes.SendChangedMessage((Owner as Player).InGameClient); Attributes.SendChangedMessage((Owner as Player).InGameClient);
DBInventory.Count = newCount; DBInventory.Count = newCount;
Owner.World.Game.GameDBSession.SessionUpdate(DBInventory); Owner.World.Game.GameDbSession.SessionUpdate(DBInventory);
} }
} }
@ -1242,7 +1242,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
target.Attributes.BroadcastChangedIfRevealed(); target.Attributes.BroadcastChangedIfRevealed();
target.DBInventory.DyeType = Attributes[GameAttribute.DyeType]; target.DBInventory.DyeType = Attributes[GameAttribute.DyeType];
player.World.Game.GameDBSession.SessionUpdate(target.DBInventory); player.World.Game.GameDbSession.SessionUpdate(target.DBInventory);
player.Inventory.SendVisualInventory(player); player.Inventory.SendVisualInventory(player);
@ -1359,7 +1359,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
player.Inventory.SendVisualInventory(player); player.Inventory.SendVisualInventory(player);
var dbToon = player.Toon.DBToon; var dbToon = player.Toon.DBToon;
dbToon.WingsActive = player.CurrentWingsPowerId; dbToon.WingsActive = player.CurrentWingsPowerId;
player.World.Game.GameDBSession.SessionUpdate(dbToon); player.World.Game.GameDbSession.SessionUpdate(dbToon);
return; return;
} }

View File

@ -130,7 +130,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
/// <summary> /// <summary>
/// Returns a new dynamicId for scenes. /// Returns a new dynamicId for scenes.
/// </summary> /// </summary>
public uint NewSceneID => IsPvP ? NewPvPSceneID : Game.NewSceneID; public uint NewSceneID => IsPvP ? NewPvPSceneID : Game.NewSceneId;
public bool IsPvP => SNO == WorldSno.pvp_duel_small_multi; //PvP_Duel_Small public bool IsPvP => SNO == WorldSno.pvp_duel_small_multi; //PvP_Duel_Small
@ -212,7 +212,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
/// <param name="game">The parent game.</param> /// <param name="game">The parent game.</param>
/// <param name="sno">The sno for the world.</param> /// <param name="sno">The sno for the world.</param>
public World(Game game, WorldSno sno) public World(Game game, WorldSno sno)
: base(sno == WorldSno.pvp_duel_small_multi ? 99999 : game.NewWorldID) : base(sno == WorldSno.pvp_duel_small_multi ? 99999 : game.NewWorldId)
{ {
WorldSNO = new SNOHandle(SNOGroup.Worlds, (int)sno); WorldSNO = new SNOHandle(SNOGroup.Worlds, (int)sno);

View File

@ -195,7 +195,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
if (expBonus > 0) if (expBonus > 0)
{ {
expBonus = (int)(expBonus * _player.World.Game.XPModifier); expBonus = (int)(expBonus * _player.World.Game.XpModifier);
_player.InGameClient.SendMessage(new KillCounterUpdateMessage() _player.InGameClient.SendMessage(new KillCounterUpdateMessage()
{ {

View File

@ -1967,7 +1967,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
_stashGrid.ResizeGrid(_owner.Attributes[GameAttribute.Shared_Stash_Slots] / 7, 7); _stashGrid.ResizeGrid(_owner.Attributes[GameAttribute.Shared_Stash_Slots] / 7, 7);
var dbGAcc = _owner.Toon.GameAccount.DBGameAccount; var dbGAcc = _owner.Toon.GameAccount.DBGameAccount;
dbGAcc.StashSize = _owner.Attributes[GameAttribute.Shared_Stash_Slots]; dbGAcc.StashSize = _owner.Attributes[GameAttribute.Shared_Stash_Slots];
_owner.World.Game.GameDBSession.SessionUpdate(dbGAcc); _owner.World.Game.GameDbSession.SessionUpdate(dbGAcc);
} }
if (_owner.Attributes[GameAttribute.Shared_Stash_Slots] >= 280) if (_owner.Attributes[GameAttribute.Shared_Stash_Slots] >= 280)
@ -1994,15 +1994,15 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
{ {
case 1: case 1:
item.DBInventory.FirstGem = gem.GBHandle.GBID; item.DBInventory.FirstGem = gem.GBHandle.GBID;
_owner.World.Game.GameDBSession.SessionUpdate(item.DBInventory); _owner.World.Game.GameDbSession.SessionUpdate(item.DBInventory);
break; break;
case 2: case 2:
item.DBInventory.SecondGem = gem.GBHandle.GBID; item.DBInventory.SecondGem = gem.GBHandle.GBID;
_owner.World.Game.GameDBSession.SessionUpdate(item.DBInventory); _owner.World.Game.GameDbSession.SessionUpdate(item.DBInventory);
break; break;
case 3: case 3:
item.DBInventory.ThirdGem = gem.GBHandle.GBID; item.DBInventory.ThirdGem = gem.GBHandle.GBID;
_owner.World.Game.GameDBSession.SessionUpdate(item.DBInventory); _owner.World.Game.GameDbSession.SessionUpdate(item.DBInventory);
break; break;
} }
@ -2067,7 +2067,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
item.DBInventory.SecondGem = -1; item.DBInventory.SecondGem = -1;
item.DBInventory.ThirdGem = -1; item.DBInventory.ThirdGem = -1;
_owner.World.Game.GameDBSession.SessionUpdate(item.DBInventory); _owner.World.Game.GameDbSession.SessionUpdate(item.DBInventory);
foreach (var gem in item.Gems) foreach (var gem in item.Gems)
gem.Unreveal(_owner); gem.Unreveal(_owner);
@ -2346,14 +2346,14 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
//load everything and make a switch on slot_id //load everything and make a switch on slot_id
Item item = null; Item item = null;
int goldAmount = (int)_owner.World.Game.GameDBSession.SessionGet<DBGameAccount>(_owner.Toon.GameAccount.PersistentID).Gold; int goldAmount = (int)_owner.World.Game.GameDbSession.SessionGet<DBGameAccount>(_owner.Toon.GameAccount.PersistentID).Gold;
// Logger.Warn($"User {this._owner.Toon.PersistentID} has {goldAmount} gold."); // Logger.Warn($"User {this._owner.Toon.PersistentID} has {goldAmount} gold.");
this.BloodShards = (int)_owner.World.Game.GameDBSession.SessionGet<DBGameAccount>(_owner.Toon.GameAccount.PersistentID).BloodShards; this.BloodShards = (int)_owner.World.Game.GameDbSession.SessionGet<DBGameAccount>(_owner.Toon.GameAccount.PersistentID).BloodShards;
// Clear already present items // Clear already present items
// LoadFromDB is called every time World is changed, even entering a dungeon // LoadFromDB is called every time World is changed, even entering a dungeon
_inventoryGrid.Clear(); _inventoryGrid.Clear();
// first of all load stash size // first of all load stash size
var slots = _owner.World.Game.GameDBSession.SessionGet<DBGameAccount>(_owner.Toon.GameAccount.PersistentID).StashSize; var slots = _owner.World.Game.GameDbSession.SessionGet<DBGameAccount>(_owner.Toon.GameAccount.PersistentID).StashSize;
if (slots > 0) if (slots > 0)
{ {
_owner.Attributes[GameAttribute.Shared_Stash_Slots] = slots; _owner.Attributes[GameAttribute.Shared_Stash_Slots] = slots;
@ -2364,7 +2364,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
// next read all items // next read all items
var allInventoryItems = _owner.World.Game.GameDBSession.SessionQueryWhere<DBInventory>( var allInventoryItems = _owner.World.Game.GameDbSession.SessionQueryWhere<DBInventory>(
dbi => dbi =>
dbi.DBToon != null && dbi.DBToon != null &&
dbi.HirelingId == 0 && dbi.HirelingId == 0 &&
@ -2435,7 +2435,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
// next load all stash items // next load all stash items
var stashInventoryItems = var stashInventoryItems =
_owner.World.Game.GameDBSession.SessionQueryWhere<DBInventory>( _owner.World.Game.GameDbSession.SessionQueryWhere<DBInventory>(
dbi => dbi =>
dbi.DBGameAccount.Id == _owner.Toon.GameAccount.PersistentID && dbi.DBGameAccount.Id == _owner.Toon.GameAccount.PersistentID &&
dbi.HirelingId == 0 && dbi.HirelingId == 0 &&
@ -2540,7 +2540,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
ItemGenerator.SaveToDB(item); ItemGenerator.SaveToDB(item);
//Logger.Debug("SaveItemToDB, SessionSave"); //Logger.Debug("SaveItemToDB, SessionSave");
_owner.World.Game.GameDBSession.SessionSave(item.DBInventory); _owner.World.Game.GameDbSession.SessionSave(item.DBInventory);
//Logger.Debug("SaveItemToDB success, item dbid: {0}", item.DBInventory.Id); //Logger.Debug("SaveItemToDB success, item dbid: {0}", item.DBInventory.Id);
} }
@ -2553,7 +2553,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
return; return;
//var inventory = item.Owner.World.Game.GameDBSession.SessionGet<DBInventory>(item.DBInventory.Id); //var inventory = item.Owner.World.Game.GameDBSession.SessionGet<DBInventory>(item.DBInventory.Id);
_owner.World.Game.GameDBSession.SessionDelete(item.DBInventory); _owner.World.Game.GameDbSession.SessionDelete(item.DBInventory);
//Logger.Debug("RemoveItemFromDB success, item dbid: {0}", item.DBInventory.Id); //Logger.Debug("RemoveItemFromDB success, item dbid: {0}", item.DBInventory.Id);
item.DBInventory = null; item.DBInventory = null;
@ -2576,7 +2576,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
else else
item.DBInventory.DBToon = (_owner as Player).Toon.DBToon; item.DBInventory.DBToon = (_owner as Player).Toon.DBToon;
item.Owner.World.Game.GameDBSession.SessionUpdate(item.DBInventory); item.Owner.World.Game.GameDbSession.SessionUpdate(item.DBInventory);
//Logger.Debug("ChangeItemSlotDB success, item dbid: {0}", item.DBInventory.Id); //Logger.Debug("ChangeItemSlotDB success, item dbid: {0}", item.DBInventory.Id);
} }
@ -2591,7 +2591,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
item.DBInventory.LocationX = locX; item.DBInventory.LocationX = locX;
item.DBInventory.LocationY = locY; item.DBInventory.LocationY = locY;
item.Owner.World.Game.GameDBSession.SessionUpdate(item.DBInventory); item.Owner.World.Game.GameDbSession.SessionUpdate(item.DBInventory);
//Logger.Debug("ChangeItemLocationDB success, item dbid: {0}", item.DBInventory.Id); //Logger.Debug("ChangeItemLocationDB success, item dbid: {0}", item.DBInventory.Id);
} }

View File

@ -380,7 +380,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
EventWeatherEnabled = false; EventWeatherEnabled = false;
var achievements = var achievements =
InGameClient.Game.GameDBSession.SessionQueryWhere<DBAchievements>(dba => InGameClient.Game.GameDbSession.SessionQueryWhere<DBAchievements>(dba =>
dba.DBGameAccount.Id == Toon.GameAccount.PersistentID); dba.DBGameAccount.Id == Toon.GameAccount.PersistentID);
BlacksmithUnlocked = achievements.Any(dba => dba.AchievementId == 74987243307766); BlacksmithUnlocked = achievements.Any(dba => dba.AchievementId == 74987243307766);
@ -1754,7 +1754,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void DeclineBossEncounter() public void DeclineBossEncounter()
{ {
InGameClient.Game.CurrentEncounter.activated = false; InGameClient.Game.CurrentEncounter.Activated = false;
} }
public void TransmuteItemsPlayer(GameClient client, TransmuteItemsMessage message) public void TransmuteItemsPlayer(GameClient client, TransmuteItemsMessage message)
@ -1892,36 +1892,35 @@ public class Player : Actor, IMessageConsumer, IUpdateable
exitSceneSno = scene.SceneSNO.Id; exitSceneSno = scene.SceneSNO.Id;
var exitSetted = false; var exitSetted = false;
foreach (var actor in nephalemPWorld.Actors.Values) foreach (var actor in nephalemPWorld.Actors.Values)
if (actor is Portal) if (actor is Portal actor1)
{ {
var p = actor as Portal; if (!actor1.CurrentScene.SceneSNO.Name.ToLower().Contains("entrance"))
if (!actor.CurrentScene.SceneSNO.Name.ToLower().Contains("entrance"))
{ {
if (!actor.CurrentScene.SceneSNO.Name.ToLower().Contains("exit")) if (!actor1.CurrentScene.SceneSNO.Name.ToLower().Contains("exit"))
{ {
actor.Destroy(); actor1.Destroy();
} }
else if (!exitSetted) else if (!exitSetted)
{ {
p.Destination.DestLevelAreaSNO = 288684; actor1.Destination.DestLevelAreaSNO = 288684;
p.Destination.WorldSNO = (int)InGameClient.Game.WorldOfPortalNephalemSec; actor1.Destination.WorldSNO = (int)InGameClient.Game.WorldOfPortalNephalemSec;
exitSetted = true; exitSetted = true;
var nephalemPWorldS2 = var nephalemPWorldS2 =
InGameClient.Game.GetWorld(InGameClient.Game.WorldOfPortalNephalemSec); InGameClient.Game.GetWorld(InGameClient.Game.WorldOfPortalNephalemSec);
foreach (var atr in nephalemPWorldS2.Actors.Values) foreach (var atr in nephalemPWorldS2.Actors.Values)
if (atr is Portal) if (atr is Portal portal1)
{ {
if (!atr.CurrentScene.SceneSNO.Name.ToLower().Contains("entrance")) if (!portal1.CurrentScene.SceneSNO.Name.ToLower().Contains("entrance"))
{ {
atr.Destroy(); portal1.Destroy();
} }
else else
{ {
(atr as Portal).Destination.DestLevelAreaSNO = 332339; portal1.Destination.DestLevelAreaSNO = 332339;
(atr as Portal).Destination.WorldSNO = portal1.Destination.WorldSNO =
(int)WorldSno.x1_tristram_adventure_mode_hub; (int)WorldSno.x1_tristram_adventure_mode_hub;
(atr as Portal).Destination.StartingPointActorTag = 172; portal1.Destination.StartingPointActorTag = 172;
} }
} }
else if (atr is Waypoint) else if (atr is Waypoint)
@ -1931,14 +1930,14 @@ public class Player : Actor, IMessageConsumer, IUpdateable
} }
else else
{ {
actor.Destroy(); actor1.Destroy();
} }
} }
else else
{ {
p.Destination.DestLevelAreaSNO = 332339; actor1.Destination.DestLevelAreaSNO = 332339;
p.Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub; actor1.Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub;
p.Destination.StartingPointActorTag = 24; actor1.Destination.StartingPointActorTag = 24;
} }
} }
else if (actor is Waypoint) else if (actor is Waypoint)
@ -2077,17 +2076,17 @@ public class Player : Actor, IMessageConsumer, IUpdateable
nephalemPWorld = InGameClient.Game.GetWorld(map); nephalemPWorld = InGameClient.Game.GetWorld(map);
foreach (var actor in nephalemPWorld.Actors.Values) foreach (var actor in nephalemPWorld.Actors.Values)
if (actor is Portal) if (actor is Portal portal1)
{ {
if (!actor.CurrentScene.SceneSNO.Name.ToLower().Contains("entrance")) if (!portal1.CurrentScene.SceneSNO.Name.ToLower().Contains("entrance"))
{ {
actor.Destroy(); portal1.Destroy();
} }
else else
{ {
(actor as Portal).Destination.DestLevelAreaSNO = 332339; portal1.Destination.DestLevelAreaSNO = 332339;
(actor as Portal).Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub; portal1.Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub;
(actor as Portal).Destination.StartingPointActorTag = 24; portal1.Destination.StartingPointActorTag = 24;
} }
} }
else if (actor is Waypoint) else if (actor is Waypoint)
@ -2267,7 +2266,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
var dbToon = Toon.DBToon; var dbToon = Toon.DBToon;
dbToon.ParagonBonuses = ParagonBonuses; dbToon.ParagonBonuses = ParagonBonuses;
World.Game.GameDBSession.SessionUpdate(dbToon); World.Game.GameDbSession.SessionUpdate(dbToon);
SetAttributesByItems(); SetAttributesByItems();
SetAttributesByItemProcs(); SetAttributesByItemProcs();
@ -2285,7 +2284,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
var dbToon = Toon.DBToon; var dbToon = Toon.DBToon;
dbToon.ParagonBonuses = ParagonBonuses; dbToon.ParagonBonuses = ParagonBonuses;
World.Game.GameDBSession.SessionUpdate(dbToon); World.Game.GameDbSession.SessionUpdate(dbToon);
SetAttributesByItems(); SetAttributesByItems();
SetAttributesByItemProcs(); SetAttributesByItemProcs();
@ -2304,10 +2303,10 @@ public class Player : Actor, IMessageConsumer, IUpdateable
private void OnMailRetrieve(GameClient client, MailRetrieveMessage message) private void OnMailRetrieve(GameClient client, MailRetrieveMessage message)
{ {
var dbMail = World.Game.GameDBSession.SessionGet<DBMail>((ulong)message.MailId); var dbMail = World.Game.GameDbSession.SessionGet<DBMail>((ulong)message.MailId);
if (dbMail == null || dbMail.DBToon.Id != Toon.PersistentID) return; if (dbMail == null || dbMail.DBToon.Id != Toon.PersistentID) return;
dbMail.Claimed = true; dbMail.Claimed = true;
World.Game.GameDBSession.SessionUpdate(dbMail); World.Game.GameDbSession.SessionUpdate(dbMail);
if (dbMail.ItemGBID != -1) if (dbMail.ItemGBID != -1)
Inventory.PickUp(ItemGenerator.CookFromDefinition(World, ItemGenerator.GetItemDefinition(dbMail.ItemGBID), Inventory.PickUp(ItemGenerator.CookFromDefinition(World, ItemGenerator.GetItemDefinition(dbMail.ItemGBID),
@ -2686,15 +2685,19 @@ public class Player : Actor, IMessageConsumer, IUpdateable
VacuumPickup(); VacuumPickup();
if (World.Game.OnLoadWorldActions.ContainsKey(World.SNO)) if (World.Game.OnLoadWorldActions.ContainsKey(World.SNO))
{ {
Logger.Debug("OnLoadWorldActions: {0}", World.SNO); Logger.MethodTrace($"OnLoadWorldActions: {World.SNO}");
lock (World.Game.OnLoadWorldActions[World.SNO]) lock (World.Game.OnLoadWorldActions[World.SNO])
{
foreach (var action in World.Game.OnLoadWorldActions[World.SNO])
{ {
try try
{ {
foreach (var action in World.Game.OnLoadWorldActions[World.SNO]) action.Invoke(); action();
} }
catch catch (Exception ex)
{ {
Logger.WarnException(ex, "OnLoadWorldActions");
}
} }
World.Game.OnLoadWorldActions[World.SNO].Clear(); World.Game.OnLoadWorldActions[World.SNO].Clear();
@ -2703,15 +2706,21 @@ public class Player : Actor, IMessageConsumer, IUpdateable
if (World.Game.OnLoadSceneActions.ContainsKey(CurrentScene.SceneSNO.Id)) if (World.Game.OnLoadSceneActions.ContainsKey(CurrentScene.SceneSNO.Id))
{ {
Logger.Debug("OnLoadSceneActions: {0}", CurrentScene.SceneSNO.Id); Logger.MethodTrace($"OnLoadSceneActions: {CurrentScene.SceneSNO.Id}");
Logger.MethodTrace(World.SNO.ToString());
lock (World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id]) lock (World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id])
{
foreach (var action in World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id])
{ {
try try
{ {
foreach (var action in World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id]) action.Invoke(); action();
} }
catch catch (Exception ex)
{ {
Logger.WarnException(ex, "OnLoadSceneActions");
}
} }
World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id].Clear(); World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id].Clear();
@ -2728,6 +2737,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
if (trigger.triggerType == DiIiS_NA.Core.MPQ.FileFormats.QuestStepObjectiveType.EnterLevelArea) if (trigger.triggerType == DiIiS_NA.Core.MPQ.FileFormats.QuestStepObjectiveType.EnterLevelArea)
try try
{ {
Logger.MethodTrace($"EnterLevelArea: {levelArea}");
trigger.questEvent.Execute(World); // launch a questEvent trigger.questEvent.Execute(World); // launch a questEvent
} }
catch (Exception e) catch (Exception e)
@ -2735,14 +2745,11 @@ public class Player : Actor, IMessageConsumer, IUpdateable
Logger.WarnException(e, "questEvent()"); Logger.WarnException(e, "questEvent()");
} }
} }
// Reset resurrection charges on zone change - TODO: do not reset charges on reentering the same zone
Attributes[GameAttribute.Corpse_Resurrection_Charges] = Attributes[GameAttribute.Corpse_Resurrection_Charges] = Config.Instance.ResurrectionCharges;
3; // Reset resurrection charges on zone change (TODO: do not reset charges on reentering the same zone)
#if DEBUG #if DEBUG
Logger.Warn("Player Location {0}, Scene: {1} SNO: {2} LevelArea: {3}", Toon.Name, Logger.Warn($"Player Location {Toon.Name}, Scene: {CurrentScene.SceneSNO.Name} SNO: {CurrentScene.SceneSNO.Id} LevelArea: {CurrentScene.Specification.SNOLevelAreas[0]}");
CurrentScene.SceneSNO.Name, CurrentScene.SceneSNO.Id, CurrentScene.Specification.SNOLevelAreas[0]);
#else
#endif #endif
} }
@ -2838,7 +2845,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void RefreshReveal() public void RefreshReveal()
{ {
var range = 200f; var range = 200f;
if (InGameClient.Game.CurrentEncounter.activated) if (InGameClient.Game.CurrentEncounter.Activated)
range = 360f; range = 360f;
foreach (var actor in GetActorsInRange(range).Where(actor => actor is not Player)) foreach (var actor in GetActorsInRange(range).Where(actor => actor is not Player))
@ -2888,7 +2895,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
//* //*
private void OnHirelingDismiss(GameClient client, PetAwayMessage message) private void OnHirelingDismiss(GameClient client, PetAwayMessage message)
{ {
Logger.MethodTrace($"{message.ActorID}"); Logger.MethodTrace(message.ActorID.ToString());
var petId = World.GetGlobalId(this, message.ActorID); var petId = World.GetGlobalId(this, message.ActorID);
var pet = World.GetActorByGlobalId(petId); var pet = World.GetActorByGlobalId(petId);
if (pet is Hireling) if (pet is Hireling)
@ -2905,16 +2912,16 @@ public class Player : Actor, IMessageConsumer, IUpdateable
switch (hireling.Attributes[GameAttribute.Hireling_Class]) switch (hireling.Attributes[GameAttribute.Hireling_Class])
{ {
case 1: case 1:
if (!(hireling is Templar)) return; if (hireling is not Templar templar) return;
(hireling as Templar).SetSkill(this, message.PowerSNOId); templar.SetSkill(this, message.PowerSNOId);
break; break;
case 2: case 2:
if (!(hireling is Scoundrel)) return; if (hireling is not Scoundrel scoundrel) return;
(hireling as Scoundrel).SetSkill(this, message.PowerSNOId); scoundrel.SetSkill(this, message.PowerSNOId);
break; break;
case 3: case 3:
if (!(hireling is Enchantress)) return; if (hireling is not Enchantress enchantress) return;
(hireling as Enchantress).SetSkill(this, message.PowerSNOId); enchantress.SetSkill(this, message.PowerSNOId);
break; break;
default: default:
break; break;
@ -2950,7 +2957,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
{ {
var activeSkills = Toon.DBActiveSkills; var activeSkills = Toon.DBActiveSkills;
activeSkills.PotionGBID = message.Field1; activeSkills.PotionGBID = message.Field1;
World.Game.GameDBSession.SessionUpdate(activeSkills); World.Game.GameDbSession.SessionUpdate(activeSkills);
} }
public void ToonStateChanged() public void ToonStateChanged()
@ -2999,7 +3006,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
Inventory.GrabSomeItems(ingr.ItemsGBID, ingr.Count); Inventory.GrabSomeItems(ingr.ItemsGBID, ingr.Count);
trainHelper.DbRef.Level++; trainHelper.DbRef.Level++;
World.Game.GameDBSession.SessionUpdate(trainHelper.DbRef); World.Game.GameDbSession.SessionUpdate(trainHelper.DbRef);
if (trainHelper.Achievement is not null) if (trainHelper.Achievement is not null)
GrantAchievement(trainHelper.Achievement.Value); GrantAchievement(trainHelper.Achievement.Value);
@ -3031,7 +3038,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
Logger.Trace("Learning transmog #{0}", transmogGBID); Logger.Trace("Learning transmog #{0}", transmogGBID);
learnedTransmogs.Add(transmogGBID); learnedTransmogs.Add(transmogGBID);
mystic_data.LearnedRecipes = SerializeBytes(learnedTransmogs); mystic_data.LearnedRecipes = SerializeBytes(learnedTransmogs);
World.Game.GameDBSession.SessionUpdate(mystic_data); World.Game.GameDbSession.SessionUpdate(mystic_data);
LoadCrafterData(); LoadCrafterData();
} }
@ -3487,7 +3494,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void RevealActorsToPlayer() public void RevealActorsToPlayer()
{ {
var Range = 200f; var Range = 200f;
if (InGameClient.Game.CurrentEncounter.activated) if (InGameClient.Game.CurrentEncounter.Activated)
Range = 360f; Range = 360f;
var specialWorlds = new WorldSno[] var specialWorlds = new WorldSno[]
@ -3506,15 +3513,15 @@ public class Player : Actor, IMessageConsumer, IUpdateable
if (actor is Player) // if the actors is already revealed, skip it. if (actor is Player) // if the actors is already revealed, skip it.
continue; continue;
if (World.SNO == WorldSno.x1_tristram_adventure_mode_hub && actor is Portal) if (World.SNO == WorldSno.x1_tristram_adventure_mode_hub && actor is Portal portal)
if ((actor as Portal).Destination.WorldSNO == (int)WorldSno.x1_tristram_adventure_mode_hub) if (portal.Destination.WorldSNO == (int)WorldSno.x1_tristram_adventure_mode_hub)
continue; continue;
if (World.SNO == WorldSno.trout_town && actor is Portal) if (World.SNO == WorldSno.trout_town && actor is Portal portal1)
if ((actor as Portal).Destination.WorldSNO == (int)WorldSno.trout_town && if (portal1.Destination.WorldSNO == (int)WorldSno.trout_town &&
(actor as Portal).Destination.DestLevelAreaSNO == 19947) portal1.Destination.DestLevelAreaSNO == 19947)
{ {
(actor as Portal).Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub; portal1.Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub;
(actor as Portal).Destination.StartingPointActorTag = 483; portal1.Destination.StartingPointActorTag = 483;
} }
if (actor.ActorType != ActorType.ClientEffect && actor.ActorType != ActorType.AxeSymbol && if (actor.ActorType != ActorType.ClientEffect && actor.ActorType != ActorType.AxeSymbol &&
@ -4258,7 +4265,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
serialized += totalDamage.ToString("F0"); serialized += totalDamage.ToString("F0");
var dbStats = Toon.DBToon; var dbStats = Toon.DBToon;
dbStats.Stats = serialized; dbStats.Stats = serialized;
World.Game.GameDBSession.SessionUpdate(dbStats); World.Game.GameDbSession.SessionUpdate(dbStats);
} }
public List<PlayerQuestRewardHistoryEntry> QuestRewardHistory public List<PlayerQuestRewardHistoryEntry> QuestRewardHistory
@ -4326,7 +4333,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void CheckBonusSets() public void CheckBonusSets()
{ {
var sets = World.Game.GameDBSession var sets = World.Game.GameDbSession
.SessionQueryWhere<DBBonusSets>(dbi => dbi.DBAccount.Id == Toon.GameAccount.AccountId).ToList(); .SessionQueryWhere<DBBonusSets>(dbi => dbi.DBAccount.Id == Toon.GameAccount.AccountId).ToList();
foreach (var bonusSet in sets) foreach (var bonusSet in sets)
{ {
@ -4357,14 +4364,14 @@ public class Player : Actor, IMessageConsumer, IUpdateable
} }
//BonusSetsList.CollectionEditions[bonusSet.SetId].Claim(this); //BonusSetsList.CollectionEditions[bonusSet.SetId].Claim(this);
World.Game.GameDBSession.SessionUpdate(bonusSet); World.Game.GameDbSession.SessionUpdate(bonusSet);
//this.InGameClient.SendMessage(new BroadcastTextMessage() { Field0 = "You have been granted with gifts from bonus pack!" }); //this.InGameClient.SendMessage(new BroadcastTextMessage() { Field0 = "You have been granted with gifts from bonus pack!" });
} }
} }
public HirelingInfo GetHirelingInfo(int type) public HirelingInfo GetHirelingInfo(int type)
{ {
var query = World.Game.GameDBSession var query = World.Game.GameDbSession
.SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == Toon.PersistentID && dbh.Class == type).ToList(); .SessionQueryWhere<DBHireling>(dbh => dbh.DBToon.Id == Toon.PersistentID && dbh.Class == type).ToList();
if (query.Count == 0) if (query.Count == 0)
{ {
@ -4433,14 +4440,14 @@ public class Player : Actor, IMessageConsumer, IUpdateable
{ {
learnedBlacksmithRecipes.Add(recipe); learnedBlacksmithRecipes.Add(recipe);
blacksmith_data.LearnedRecipes = SerializeBytes(learnedBlacksmithRecipes); blacksmith_data.LearnedRecipes = SerializeBytes(learnedBlacksmithRecipes);
World.Game.GameDBSession.SessionUpdate(blacksmith_data); World.Game.GameDbSession.SessionUpdate(blacksmith_data);
UpdateAchievementCounter(404, 1, 0); UpdateAchievementCounter(404, 1, 0);
} }
else if (artisan == ArtisanType.Jeweler) else if (artisan == ArtisanType.Jeweler)
{ {
learnedJewelerRecipes.Add(recipe); learnedJewelerRecipes.Add(recipe);
jeweler_data.LearnedRecipes = SerializeBytes(learnedJewelerRecipes); jeweler_data.LearnedRecipes = SerializeBytes(learnedJewelerRecipes);
World.Game.GameDBSession.SessionUpdate(jeweler_data); World.Game.GameDbSession.SessionUpdate(jeweler_data);
UpdateAchievementCounter(404, 1, 1); UpdateAchievementCounter(404, 1, 1);
} }
@ -4478,7 +4485,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
if (blacksmith_data == null) if (blacksmith_data == null)
{ {
var craft_data = var craft_data =
World.Game.GameDBSession.SessionQueryWhere<DBCraft>(dbc => World.Game.GameDbSession.SessionQueryWhere<DBCraft>(dbc =>
dbc.DBGameAccount.Id == Toon.GameAccount.PersistentID); dbc.DBGameAccount.Id == Toon.GameAccount.PersistentID);
blacksmith_data = craft_data.Single(dbc => blacksmith_data = craft_data.Single(dbc =>
@ -4555,7 +4562,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void LoadMailData() public void LoadMailData()
{ {
var mail_data = var mail_data =
World.Game.GameDBSession.SessionQueryWhere<DBMail>(dbm => World.Game.GameDbSession.SessionQueryWhere<DBMail>(dbm =>
dbm.DBToon.Id == Toon.PersistentID && dbm.Claimed == false); dbm.DBToon.Id == Toon.PersistentID && dbm.Claimed == false);
var mails = D3.Items.Mails.CreateBuilder(); var mails = D3.Items.Mails.CreateBuilder();
foreach (var mail in mail_data) foreach (var mail in mail_data)
@ -4856,14 +4863,14 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void SetProgress(int act, int difficulty) public void SetProgress(int act, int difficulty)
{ {
if (act > 400) return; if (act > 400) return;
var dbGAcc = World.Game.GameDBSession.SessionGet<DBGameAccount>(Toon.GameAccount.PersistentID); var dbGAcc = World.Game.GameDbSession.SessionGet<DBGameAccount>(Toon.GameAccount.PersistentID);
var progress = dbGAcc.BossProgress; var progress = dbGAcc.BossProgress;
if (progress[act / 100] == 0xff || progress[act / 100] < (byte)difficulty) if (progress[act / 100] == 0xff || progress[act / 100] < (byte)difficulty)
{ {
progress[act / 100] = (byte)difficulty; progress[act / 100] = (byte)difficulty;
dbGAcc.BossProgress = progress; dbGAcc.BossProgress = progress;
World.Game.GameDBSession.SessionUpdate(dbGAcc); World.Game.GameDbSession.SessionUpdate(dbGAcc);
} }
} }
@ -6019,7 +6026,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
Logger.Trace("Learning lore #{0}", loreSNOId); Logger.Trace("Learning lore #{0}", loreSNOId);
var dbToon = Toon.DBToon; var dbToon = Toon.DBToon;
dbToon.Lore = SerializeBytes(LearnedLore.m_snoLoreLearned.Take(LearnedLore.Count).ToList()); dbToon.Lore = SerializeBytes(LearnedLore.m_snoLoreLearned.Take(LearnedLore.Count).ToList());
World.Game.GameDBSession.SessionUpdate(dbToon); World.Game.GameDbSession.SessionUpdate(dbToon);
} }
} }

View File

@ -20,7 +20,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (User.GetActorsInRange(80f).Count < 100) if (User.GetActorsInRange(80f).Count < 100)
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
var monster = ActorFactory.Create(User.World, (ActorSno)(User as Monster).SNOSummons[0], new TagMap()); var monster = ActorFactory.Create(User.World, (ActorSno)(User as Monster).SnoSummons[0], new TagMap());
monster.Scale = 1.35f; monster.Scale = 1.35f;
monster.EnterWorld(RandomDirection(Target.Position, 3, 10)); monster.EnterWorld(RandomDirection(Target.Position, 3, 10));
World.BuffManager.AddBuff(User, monster, new SummonedBuff()); World.BuffManager.AddBuff(User, monster, new SummonedBuff());

View File

@ -16,26 +16,24 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations.MonsterSkills
public abstract class SingleProjectileSkill : ActionTimedSkill public abstract class SingleProjectileSkill : ActionTimedSkill
{ {
protected Projectile projectile; protected Projectile projectile;
protected float speed; private float _speed;
protected void SetProjectile(PowerContext context, ActorSno actorSNO, Vector3D position, float speed = 1f, Action<Actor> OnCollision = null) protected void SetProjectile(PowerContext context, ActorSno actorSNO, Vector3D position, float speed = 1f, Action<Actor> OnCollision = null)
{ {
if (User is Monster) if (User is Monster monster)
// FIXME: Non-exist world id // TODO: FIXME: Non-exist world id
if (User.World.WorldSNO.Id == 1 || if (monster.World.WorldSNO.Id is 1)
User.World.WorldSNO.Id == 1) position.Z = monster.Position.Z;
position.Z = (User as Monster).CorrectedPosition.Z; projectile = new(context, actorSNO, position)
projectile = new Projectile(context, actorSNO, position); {
OnCollision = OnCollision
};
projectile.OnCollision = OnCollision; _speed = speed;
this.speed = speed;
} }
protected IEnumerable<TickTimer> Launch() protected IEnumerable<TickTimer> Launch()
{ {
projectile.Launch(new Vector3D(Target.Position.X, Target.Position.Y, Target.Position.Z + 5f), _speed);
projectile.Launch(new Vector3D(Target.Position.X, Target.Position.Y, Target.Position.Z + 5f), speed);
yield break; yield break;
} }
} }

View File

@ -51,7 +51,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
public override IEnumerable<TickTimer> Main() public override IEnumerable<TickTimer> Main()
{ {
InFrontPostion(); InFrontPostion();
SummonMonster((User as Monster).SNOSummons[0]); SummonMonster((User as Monster).SnoSummons[0]);
yield break; yield break;
} }
} }
@ -76,7 +76,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (payload.Target == User && payload is DeathPayload) if (payload.Target == User && payload is DeathPayload)
{ {
if (User.GetActorsInRange(80f).Count > 100) return; if (User.GetActorsInRange(80f).Count > 100) return;
var monster = ActorFactory.Create(User.World, (User as Monster).SNOSummons[0], new TagMap()); var monster = ActorFactory.Create(User.World, (User as Monster).SnoSummons[0], new TagMap());
if (monster != null) if (monster != null)
{ {
monster.Scale = 1.35f; monster.Scale = 1.35f;
@ -111,7 +111,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
User.PlayAnimation(11, (AnimationSno)User.AnimationSet.TagMapAnimDefault[AnimationSetKeys.Explode]); User.PlayAnimation(11, (AnimationSno)User.AnimationSet.TagMapAnimDefault[AnimationSetKeys.Explode]);
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
var monster = ActorFactory.Create(User.World, (User as Monster).SNOSummons[0], new TagMap()); var monster = ActorFactory.Create(User.World, (User as Monster).SnoSummons[0], new TagMap());
monster.Scale = 1.35f; monster.Scale = 1.35f;
monster.EnterWorld(RandomDirection(User.Position, 1, 3)); monster.EnterWorld(RandomDirection(User.Position, 1, 3));
World.BuffManager.AddBuff(User, monster, new SummonedBuff()); World.BuffManager.AddBuff(User, monster, new SummonedBuff());
@ -185,7 +185,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{ {
RandomPostion(); RandomPostion();
if (User is Monster) if (User is Monster)
SummonMonster((User as Monster).SNOSummons[0]); SummonMonster((User as Monster).SnoSummons[0]);
yield break; yield break;
} }
} }
@ -206,7 +206,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
public override IEnumerable<TickTimer> Main() public override IEnumerable<TickTimer> Main()
{ {
UserPostion(); UserPostion();
SummonMonster((User as Monster).SNOSummons[0]); SummonMonster((User as Monster).SnoSummons[0]);
yield break; yield break;
} }
} }

View File

@ -390,7 +390,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
{ {
int grantedExp = 0; int grantedExp = 0;
if (plr.Attributes[GameAttribute.Level] <= Target.Attributes[GameAttribute.Level]) if (plr.Attributes[GameAttribute.Level] <= Target.Attributes[GameAttribute.Level])
grantedExp = (int)(Player.LevelBorders[plr.Attributes[GameAttribute.Level]] / (40 * Target.Attributes[GameAttribute.Level] * 0.85f) * (Target is Monster ? Math.Min((Target as Monster).HPMultiplier, 3f) : 1f)); grantedExp = (int)(Player.LevelBorders[plr.Attributes[GameAttribute.Level]] / (40 * Target.Attributes[GameAttribute.Level] * 0.85f) * (Target is Monster ? Math.Min((Target as Monster).HpMultiplier, 3f) : 1f));
else else
grantedExp = (int)(Player.LevelBorders[plr.Attributes[GameAttribute.Level]] / (40 * Target.Attributes[GameAttribute.Level] * 0.85f) * (1 - Math.Abs(plr.Attributes[GameAttribute.Level] - Target.Attributes[GameAttribute.Level]) / 20)); grantedExp = (int)(Player.LevelBorders[plr.Attributes[GameAttribute.Level]] / (40 * Target.Attributes[GameAttribute.Level] * 0.85f) * (1 - Math.Abs(plr.Attributes[GameAttribute.Level] - Target.Attributes[GameAttribute.Level]) / 20));
@ -401,7 +401,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
if (LootAndExp) if (LootAndExp)
{ {
grantedExp = (int)(grantedExp * plr.World.Game.XPModifier); grantedExp = (int)(grantedExp * plr.World.Game.XpModifier);
float tempEXP = grantedExp * Config.Instance.RateExp; float tempEXP = grantedExp * Config.Instance.RateExp;
@ -1152,7 +1152,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
player.AddTimedAction(3f, new Action<int>((q) => player.Revive(player.CheckPointPosition))); player.AddTimedAction(3f, new Action<int>((q) => player.Revive(player.CheckPointPosition)));
var toon = player.Toon.DBToon; var toon = player.Toon.DBToon;
toon.Deaths++; toon.Deaths++;
player.World.Game.GameDBSession.SessionUpdate(toon); player.World.Game.GameDbSession.SessionUpdate(toon);
} }
} }
//} //}

View File

@ -511,7 +511,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = () => OnAdvance = () =>
{ //go with Cain { //go with Cain
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
StartConversation(Game.GetWorld(WorldSno.trdun_cain_intro), 72496); StartConversation(Game.GetWorld(WorldSno.trdun_cain_intro), 72496);
ListenTeleport(19938, new Advance()); ListenTeleport(19938, new Advance());
} }
@ -1111,7 +1111,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = () => OnAdvance = () =>
{ //go to fallen star room { //go to fallen star room
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenTeleport(117411, new Advance()); ListenTeleport(117411, new Advance());
Game.AddOnLoadWorldAction(WorldSno.a1trdun_king_level08, () => Game.AddOnLoadWorldAction(WorldSno.a1trdun_king_level08, () =>
{ {
@ -1890,7 +1890,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
(LeahAfterEvent as ActorSystem.InteractiveNPC).Attributes[GameAttribute.Conversation_Icon, 0] = 2; (LeahAfterEvent as ActorSystem.InteractiveNPC).Attributes[GameAttribute.Conversation_Icon, 0] = 2;
(LeahAfterEvent as ActorSystem.InteractiveNPC).Attributes.BroadcastChangedIfRevealed(); (LeahAfterEvent as ActorSystem.InteractiveNPC).Attributes.BroadcastChangedIfRevealed();
ListenConversation(93337, new Advance()); ListenConversation(93337, new Advance());
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
} }
}); });
@ -2259,7 +2259,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = () => OnAdvance = () =>
{ //find Tyrael { //find Tyrael
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
Game.AddOnLoadWorldAction(WorldSno.trdun_butcherslair_02, () => Game.AddOnLoadWorldAction(WorldSno.trdun_butcherslair_02, () =>
{ {
SetActorOperable(Game.GetWorld(WorldSno.trdun_butcherslair_02), ActorSno._a1dun_leor_gate_a, true); SetActorOperable(Game.GetWorld(WorldSno.trdun_butcherslair_02), ActorSno._a1dun_leor_gate_a, true);

View File

@ -439,7 +439,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = 10, NextStep = 10,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //return to camp OnAdvance = new Action(() => { //return to camp
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
Game.AddOnLoadWorldAction(WorldSno.caout_cellar_alcarnus_main, () => Game.AddOnLoadWorldAction(WorldSno.caout_cellar_alcarnus_main, () =>
{ {
Open(Game.GetWorld(WorldSno.caout_cellar_alcarnus_main), ActorSno._caout_stingingwinds_arena_bridge); Open(Game.GetWorld(WorldSno.caout_cellar_alcarnus_main), ActorSno._caout_stingingwinds_arena_bridge);
@ -645,7 +645,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
world.ShowOnlyNumNPC(ActorSno._leahsewer, -1); //Leave all LeahSewer world.ShowOnlyNumNPC(ActorSno._leahsewer, -1); //Leave all LeahSewer
} }
}); });
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
}) })
}); });
@ -723,7 +723,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //talk with Adria in camp OnAdvance = new Action(() => { //talk with Adria in camp
var world = Game.GetWorld(WorldSno.a2dun_swr_adria_level01); var world = Game.GetWorld(WorldSno.a2dun_swr_adria_level01);
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
if (world.GetActorBySNO(ActorSno._adria) != null) if (world.GetActorBySNO(ActorSno._adria) != null)
RemoveConversations(world.GetActorBySNO(ActorSno._adria)); RemoveConversations(world.GetActorBySNO(ActorSno._adria));
@ -1501,7 +1501,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = 27, NextStep = 27,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //get Belial's soul OnAdvance = new Action(() => { //get Belial's soul
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
Game.AddOnLoadWorldAction(WorldSno.a2_belial_room_01, () => Game.AddOnLoadWorldAction(WorldSno.a2_belial_room_01, () =>
{ {
(Game.GetWorld(WorldSno.a2_belial_room_01).GetActorBySNO(ActorSno._a2dun_cald_belial_room_a_breakable_main) as BelialRoom).Rebuild(); (Game.GetWorld(WorldSno.a2_belial_room_01).GetActorBySNO(ActorSno._a2dun_cald_belial_room_a_breakable_main) as BelialRoom).Rebuild();

View File

@ -533,7 +533,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = 3, NextStep = 3,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //talk with Adria OnAdvance = new Action(() => { //talk with Adria
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenProximity(ActorSno._adria, new LaunchConversation(196366)); ListenProximity(ActorSno._adria, new LaunchConversation(196366));
ListenConversation(196366, new Advance()); ListenConversation(196366, new Advance());
if (Game.Empty) UnlockTeleport(6); if (Game.Empty) UnlockTeleport(6);
@ -669,7 +669,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = 1, NextStep = 1,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //Destroy Heart of Sin OnAdvance = new Action(() => { //Destroy Heart of Sin
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenKill(ActorSno._a3dun_crater_st_giantdemonheart_mob, 1, new Advance()); ListenKill(ActorSno._a3dun_crater_st_giantdemonheart_mob, 1, new Advance());
Game.AddOnLoadWorldAction(WorldSno.a3dun_crater_st_level04b, () => Game.AddOnLoadWorldAction(WorldSno.a3dun_crater_st_level04b, () =>
{ {
@ -708,7 +708,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = 5, NextStep = 5,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //get Azmodan's soul OnAdvance = new Action(() => { //get Azmodan's soul
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenProximity(ActorSno._azmodan_bss_soulremnants, new Advance()); ListenProximity(ActorSno._azmodan_bss_soulremnants, new Advance());
Game.AddOnLoadWorldAction(WorldSno.a3dun_azmodan_arena, () => Game.AddOnLoadWorldAction(WorldSno.a3dun_azmodan_arena, () =>
{ {
@ -889,7 +889,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = -1, NextStep = -1,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //complete OnAdvance = new Action(() => { //complete
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
}) })
}); });

View File

@ -110,7 +110,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = -1, NextStep = -1,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //complete OnAdvance = new Action(() => { //complete
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
}) })
}); });
@ -242,7 +242,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = 33, NextStep = 33,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //destroy Auriel's jail OnAdvance = new Action(() => { //destroy Auriel's jail
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
var Library = Game.GetWorld(WorldSno.a4dun_libraryoffate); var Library = Game.GetWorld(WorldSno.a4dun_libraryoffate);
StartConversation(Library, 217223); // Голос дъябло после битвы StartConversation(Library, 217223); // Голос дъябло после битвы
@ -444,7 +444,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
NextStep = -1, NextStep = -1,
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { //complete OnAdvance = new Action(() => { //complete
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
PlayCutscene(2); PlayCutscene(2);
}) })
}); });

View File

@ -735,7 +735,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
var malthael = Game.GetWorld(WorldSno.x1_urzael_arena).SpawnMonster(ActorSno._x1_malthael, new Vector3D { X = 97.65f, Y = 350.23f, Z = 0.1f }); var malthael = Game.GetWorld(WorldSno.x1_urzael_arena).SpawnMonster(ActorSno._x1_malthael, new Vector3D { X = 97.65f, Y = 350.23f, Z = 0.1f });
malthael.NotifyConversation(1); malthael.NotifyConversation(1);
}); });
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenInteract(ActorSno._x1_malthael, 1, new LaunchConversation(274423)); ListenInteract(ActorSno._x1_malthael, 1, new LaunchConversation(274423));
ListenConversation(274423, new Advance()); ListenConversation(274423, new Advance());
}) })
@ -1016,7 +1016,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { OnAdvance = new Action(() => {
//talk to Lorath //talk to Lorath
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
var world = Game.GetWorld(WorldSno.x1_adria_boss_arena_02); var world = Game.GetWorld(WorldSno.x1_adria_boss_arena_02);
foreach (var Myst in world.GetActorsBySNO(ActorSno._x1_npc_lorathnahr)) //284530 foreach (var Myst in world.GetActorsBySNO(ActorSno._x1_npc_lorathnahr)) //284530
@ -1033,7 +1033,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
{ {
world.GetActorBySNO(ActorSno._x1_npc_lorathnahr).NotifyConversation(1); world.GetActorBySNO(ActorSno._x1_npc_lorathnahr).NotifyConversation(1);
}); });
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
//ListenInteract(284530, 1, new LaunchConversation(260191)); //ListenInteract(284530, 1, new LaunchConversation(260191));
ListenConversation(260191, new Advance()); ListenConversation(260191, new Advance());
@ -1441,7 +1441,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
//enter Breach //enter Breach
var RamWorld = Game.GetWorld(WorldSno.x1_pand_batteringram); var RamWorld = Game.GetWorld(WorldSno.x1_pand_batteringram);
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenTeleport(271234, new Advance()); ListenTeleport(271234, new Advance());
Game.AddOnLoadWorldAction(WorldSno.x1_pand_batteringram, () => Game.AddOnLoadWorldAction(WorldSno.x1_pand_batteringram, () =>
{ {
@ -1625,7 +1625,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
Objectives = new List<Objective> { Objective.Default() }, Objectives = new List<Objective> { Objective.Default() },
OnAdvance = new Action(() => { OnAdvance = new Action(() => {
//Success //Success
Game.CurrentEncounter.activated = false; Game.CurrentEncounter.Activated = false;
ListenProximity(ActorSno._tyrael, new LaunchConversation(351334)); ListenProximity(ActorSno._tyrael, new LaunchConversation(351334));
ListenConversation(351334, new Advance()); ListenConversation(351334, new Advance());
if (Game.IsHardcore) if (Game.IsHardcore)

View File

@ -93,7 +93,7 @@ namespace DiIiS_NA.GameServer.GSSystem.SkillsSystem
} }
if (!Player.World.Game.PvP) if (!Player.World.Game.PvP)
{ {
Player.World.Game.GameDBSession.SessionUpdate(dbActiveSkills); Player.World.Game.GameDbSession.SessionUpdate(dbActiveSkills);
} }
} }
@ -115,7 +115,7 @@ namespace DiIiS_NA.GameServer.GSSystem.SkillsSystem
dbActiveSkills.Passive3 = PassiveSkills[3]; dbActiveSkills.Passive3 = PassiveSkills[3];
if (!Player.World.Game.PvP) if (!Player.World.Game.PvP)
{ {
Player.World.Game.GameDBSession.SessionUpdate(dbActiveSkills); Player.World.Game.GameDbSession.SessionUpdate(dbActiveSkills);
} }
} }