2025-07-05 10:31:02 -04:00
|
|
|
using Arrowgene.Ddon.GameServer.Scripting.Modules;
|
2024-12-23 14:40:57 -05:00
|
|
|
using Arrowgene.Ddon.Server;
|
|
|
|
|
using Arrowgene.Ddon.Shared.Scripting;
|
|
|
|
|
using Arrowgene.Logging;
|
2025-06-26 18:28:09 -04:00
|
|
|
using System.Collections.Generic;
|
2025-02-24 11:14:09 -05:00
|
|
|
using System.IO;
|
2024-12-23 14:40:57 -05:00
|
|
|
|
|
|
|
|
namespace Arrowgene.Ddon.GameServer.Scripting
|
|
|
|
|
{
|
|
|
|
|
public class GlobalVariables
|
|
|
|
|
{
|
2024-12-26 22:26:23 -05:00
|
|
|
public GlobalVariables()
|
2024-12-23 14:40:57 -05:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public class GameServerScriptManager : ScriptManager<GlobalVariables>
|
|
|
|
|
{
|
|
|
|
|
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(GameServerScriptManager));
|
|
|
|
|
|
|
|
|
|
private DdonGameServer Server { get; }
|
|
|
|
|
private GlobalVariables Globals { get; }
|
|
|
|
|
public NpcExtendedFacilityModule NpcExtendedFacilityModule { get; private set; } = new NpcExtendedFacilityModule();
|
2024-12-23 17:38:08 -05:00
|
|
|
public GameItemModule GameItemModule { get; private set; } = new GameItemModule();
|
2024-12-23 21:36:26 -05:00
|
|
|
public MixinModule MixinModule { get; private set; } = new MixinModule();
|
2024-12-26 22:26:23 -05:00
|
|
|
public QuestModule QuestModule { get; private set; } = new QuestModule();
|
2024-12-31 12:39:20 -05:00
|
|
|
public ChatCommandModule ChatCommandModule { get; private set; } = new ChatCommandModule();
|
2025-02-03 00:56:57 -05:00
|
|
|
public PointModifierModule PointModifierModule { get; private set; } = new PointModifierModule();
|
2025-02-24 11:14:09 -05:00
|
|
|
public AddendumModule AddendumModule { get; private set; } = new AddendumModule();
|
2025-02-26 18:31:16 -05:00
|
|
|
public MonsterCautionSpotModule MonsterCautionSpotModule { get; private set; } = new MonsterCautionSpotModule();
|
|
|
|
|
public InstanceEnemyPropertyGeneratorModule InstanceEnemyPropertyGeneratorModule { get; private set; } = new InstanceEnemyPropertyGeneratorModule();
|
2025-06-09 01:11:59 -04:00
|
|
|
public JobOrbTreeModule SkillAugmentationModule { get; private set; } = new JobOrbTreeModule("job_orb_tree/skill_augmentation");
|
|
|
|
|
public JobOrbTreeModule SpecialSkillAugmentationModule { get; private set; } = new JobOrbTreeModule("job_orb_tree/special_skill_augmentation");
|
|
|
|
|
public JobOrbTreeSpecialConditionModule JobOrbSpecialConditionModule { get; private set; } = new();
|
2024-08-23 16:49:44 -04:00
|
|
|
public JobEmblemStatModule JobEmblemStatModule { get; private set; } = new JobEmblemStatModule();
|
2025-07-05 10:31:02 -04:00
|
|
|
public InstanceEnemyDropModule InstanceEnemyDropModule { get; private set; } = new();
|
2026-04-24 21:13:15 -04:00
|
|
|
public SchedulerTaskModule SchedulerTaskModule { get; private set; } = new SchedulerTaskModule();
|
2026-05-30 16:37:22 -04:00
|
|
|
public OfficialPawnModule OfficialPawnModule { get; private set; } = new OfficialPawnModule();
|
2024-08-23 16:49:44 -04:00
|
|
|
|
2025-02-26 11:39:36 -05:00
|
|
|
public GameServerScriptManager(DdonGameServer server) : base(server.AssetRepository.AssetsPath, ".")
|
2024-12-23 14:40:57 -05:00
|
|
|
{
|
|
|
|
|
Server = server;
|
2024-12-26 22:26:23 -05:00
|
|
|
Globals = new GlobalVariables();
|
|
|
|
|
|
|
|
|
|
// Initialize LibDdon Singleton
|
|
|
|
|
LibDdon.SetServer(server);
|
2024-12-23 14:40:57 -05:00
|
|
|
|
|
|
|
|
// Add modules to the list so the generic logic can iterate over all scripting modules
|
2025-02-26 18:31:16 -05:00
|
|
|
AddModule(ChatCommandModule);
|
|
|
|
|
AddModule(GameItemModule);
|
|
|
|
|
AddModule(MixinModule);
|
|
|
|
|
AddModule(NpcExtendedFacilityModule);
|
|
|
|
|
AddModule(PointModifierModule);
|
|
|
|
|
AddModule(InstanceEnemyPropertyGeneratorModule);
|
2024-08-26 18:41:49 -04:00
|
|
|
AddModule(SkillAugmentationModule);
|
2024-08-23 16:49:44 -04:00
|
|
|
AddModule(JobEmblemStatModule);
|
2025-06-09 01:11:59 -04:00
|
|
|
AddModule(SpecialSkillAugmentationModule);
|
|
|
|
|
AddModule(JobOrbSpecialConditionModule);
|
2025-02-26 18:31:16 -05:00
|
|
|
AddModule(MonsterCautionSpotModule);
|
2025-07-05 10:31:02 -04:00
|
|
|
AddModule(InstanceEnemyDropModule);
|
2026-04-24 21:13:15 -04:00
|
|
|
AddModule(SchedulerTaskModule);
|
2026-05-30 16:37:22 -04:00
|
|
|
AddModule(OfficialPawnModule);
|
2024-12-23 14:40:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize(Globals);
|
|
|
|
|
}
|
2025-02-24 11:14:09 -05:00
|
|
|
|
2025-06-26 18:28:09 -04:00
|
|
|
protected override void CompileScripts(List<ScriptModule> modules = null)
|
|
|
|
|
{
|
|
|
|
|
base.CompileScripts(modules);
|
|
|
|
|
|
|
|
|
|
// World Manage Quests have a dependency on Caution Spots, so load quests after
|
|
|
|
|
// caution spots
|
|
|
|
|
base.CompileScripts([QuestModule]);
|
|
|
|
|
AddModule(QuestModule);
|
|
|
|
|
|
|
|
|
|
// This module should run last since it applies fine grained modifications to other modules
|
|
|
|
|
base.CompileScripts([AddendumModule]);
|
|
|
|
|
AddModule(AddendumModule);
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-24 11:14:09 -05:00
|
|
|
protected override void OnChanged(object sender, FileSystemEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ChangeType != WatcherChangeTypes.Changed)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var module = GetModuleFromFilePath(e.FullPath);
|
|
|
|
|
if (module == null)
|
|
|
|
|
{
|
|
|
|
|
// No module associated with this script
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnChanged(sender, e);
|
|
|
|
|
|
|
|
|
|
if (!module.GetType().Equals(typeof(AddendumModule)))
|
|
|
|
|
{
|
|
|
|
|
if (AddendumModule.Scripts.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
// No addendums to be reapplied
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Logger.Info("Reapplying addendums");
|
|
|
|
|
foreach (var watcher in AddendumModule.Watchers)
|
|
|
|
|
{
|
|
|
|
|
watcher.EnableRaisingEvents = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var script in AddendumModule.Scripts)
|
|
|
|
|
{
|
|
|
|
|
CompileScript(AddendumModule, script);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
foreach (var watcher in AddendumModule.Watchers)
|
|
|
|
|
{
|
|
|
|
|
watcher.EnableRaisingEvents = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-23 14:40:57 -05:00
|
|
|
}
|
|
|
|
|
}
|