ddon-server/Arrowgene.Ddon.GameServer/Scripting/GameServerScriptManager.cs
Paul Campbell 937b2e04ce feat: Official Pawns
- Added support for server admin to define offical pawns.
- Added support for dynamically defined official pawns which change
  based on the hiring player level.
- Added a new settings file official_pawns.csx
- Added new official pawns
  - Annuate, Puala, Rumi and WhiteKnight
2026-05-31 08:31:27 -04:00

131 lines
5.4 KiB
C#

using Arrowgene.Ddon.GameServer.Scripting.Modules;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Scripting;
using Arrowgene.Logging;
using System.Collections.Generic;
using System.IO;
namespace Arrowgene.Ddon.GameServer.Scripting
{
public class GlobalVariables
{
public GlobalVariables()
{
}
};
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();
public GameItemModule GameItemModule { get; private set; } = new GameItemModule();
public MixinModule MixinModule { get; private set; } = new MixinModule();
public QuestModule QuestModule { get; private set; } = new QuestModule();
public ChatCommandModule ChatCommandModule { get; private set; } = new ChatCommandModule();
public PointModifierModule PointModifierModule { get; private set; } = new PointModifierModule();
public AddendumModule AddendumModule { get; private set; } = new AddendumModule();
public MonsterCautionSpotModule MonsterCautionSpotModule { get; private set; } = new MonsterCautionSpotModule();
public InstanceEnemyPropertyGeneratorModule InstanceEnemyPropertyGeneratorModule { get; private set; } = new InstanceEnemyPropertyGeneratorModule();
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();
public JobEmblemStatModule JobEmblemStatModule { get; private set; } = new JobEmblemStatModule();
public InstanceEnemyDropModule InstanceEnemyDropModule { get; private set; } = new();
public SchedulerTaskModule SchedulerTaskModule { get; private set; } = new SchedulerTaskModule();
public OfficialPawnModule OfficialPawnModule { get; private set; } = new OfficialPawnModule();
public GameServerScriptManager(DdonGameServer server) : base(server.AssetRepository.AssetsPath, ".")
{
Server = server;
Globals = new GlobalVariables();
// Initialize LibDdon Singleton
LibDdon.SetServer(server);
// Add modules to the list so the generic logic can iterate over all scripting modules
AddModule(ChatCommandModule);
AddModule(GameItemModule);
AddModule(MixinModule);
AddModule(NpcExtendedFacilityModule);
AddModule(PointModifierModule);
AddModule(InstanceEnemyPropertyGeneratorModule);
AddModule(SkillAugmentationModule);
AddModule(JobEmblemStatModule);
AddModule(SpecialSkillAugmentationModule);
AddModule(JobOrbSpecialConditionModule);
AddModule(MonsterCautionSpotModule);
AddModule(InstanceEnemyDropModule);
AddModule(SchedulerTaskModule);
AddModule(OfficialPawnModule);
}
public override void Initialize()
{
base.Initialize(Globals);
}
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);
}
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;
}
}
}
}
}
}