2025-02-26 18:31:16 -05:00
|
|
|
using Arrowgene.Ddon.GameServer.Characters;
|
2025-06-28 07:04:30 -04:00
|
|
|
using Arrowgene.Ddon.GameServer.Party;
|
2025-02-26 18:31:16 -05:00
|
|
|
using Arrowgene.Ddon.GameServer.Scripting.Interfaces;
|
2025-06-28 07:04:30 -04:00
|
|
|
using Arrowgene.Ddon.Shared.Model;
|
2025-02-26 18:31:16 -05:00
|
|
|
using Arrowgene.Ddon.Shared.Model.Quest;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2025-06-28 07:04:30 -04:00
|
|
|
using System.Linq;
|
2025-02-26 18:31:16 -05:00
|
|
|
|
|
|
|
|
namespace Arrowgene.Ddon.GameServer.Scripting
|
|
|
|
|
{
|
|
|
|
|
public class MonsterCautionSpotModule : GameServerScriptModule
|
|
|
|
|
{
|
|
|
|
|
public override string ModuleRoot => Path.Combine("area_rank", "monster_caution_spots");
|
|
|
|
|
public override string Filter => "*.csx";
|
|
|
|
|
public override bool ScanSubdirectories => true;
|
|
|
|
|
public override bool EnableHotLoad => true;
|
|
|
|
|
|
|
|
|
|
public Dictionary<QuestAreaId, List<IMonsterSpotInfo>> EnemyGroups { get; private set; }
|
|
|
|
|
|
|
|
|
|
public MonsterCautionSpotModule()
|
|
|
|
|
{
|
|
|
|
|
EnemyGroups = new Dictionary<QuestAreaId, List<IMonsterSpotInfo>>();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-28 07:04:30 -04:00
|
|
|
public bool IsEnabledCautionSpotGroup(DdonGameServer server, PartyGroup party, StageLayoutId stageLayoutId, QuestAreaId areaId)
|
|
|
|
|
{
|
|
|
|
|
if (party.Leader == null || !EnemyGroups.ContainsKey(areaId))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cautionSpot = EnemyGroups[areaId].Where(x => x.StageLayoutId.Equals(stageLayoutId)).FirstOrDefault();
|
|
|
|
|
if (cautionSpot == null || !cautionSpot.CautionPlayer)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var leaderClient = party.Leader.Client;
|
2026-06-07 19:42:05 +01:00
|
|
|
if (cautionSpot.QuestUnlockId != QuestId.None && !leaderClient.Character.HasQuestCompleted(cautionSpot.QuestUnlockId))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-28 07:04:30 -04:00
|
|
|
return server.AreaRankManager.GetEffectiveRank(leaderClient.Character, areaId) >= cautionSpot.RequiredAreaRank;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-29 02:07:13 -07:00
|
|
|
public override bool EvaluateResult(string path, object result, IDictionary<string, object> variables)
|
2025-02-26 18:31:16 -05:00
|
|
|
{
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-29 02:07:13 -07:00
|
|
|
IMonsterSpotInfo spotInfo = (IMonsterSpotInfo)result;
|
2025-02-26 18:31:16 -05:00
|
|
|
if (spotInfo == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spotInfo.Initialize();
|
|
|
|
|
|
|
|
|
|
if (!EnemyGroups.ContainsKey(spotInfo.AreaId))
|
|
|
|
|
{
|
|
|
|
|
EnemyGroups[spotInfo.AreaId] = new List<IMonsterSpotInfo>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove if there are overlaps
|
|
|
|
|
EnemyGroups[spotInfo.AreaId].RemoveAll(x => spotInfo.GetLocation().Equals(x.GetLocation()));
|
|
|
|
|
// Add the new entry to the list
|
|
|
|
|
EnemyGroups[spotInfo.AreaId].Add(spotInfo);
|
|
|
|
|
|
|
|
|
|
var quest = QuestManager.GetQuestByQuestId(QuestId.WorldManageMonsterCaution);
|
|
|
|
|
if (quest != null)
|
|
|
|
|
{
|
|
|
|
|
LibDdon.RegenerateQuest(quest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|