ddon-server/Arrowgene.Ddon.GameServer/Scripting/Modules/InstanceEnemyPropertyGeneratorModule.cs
Paul Campbell bb2ec29ea9 feat: Area/Dungeon Boss AP reward
- Enemies which are now labeled as an area boss will reward AP when
  the group is defeated.
- The amount of AP is configurable via the new setting AreaBossApReward.
  - The default value is 500 AP for the current Area the defeated enemy
    is in.
- Added a new member to instance enemy properties which allows a rank to
  be assigned to a scripts. The rank helps to control the order scripts
  are executed. The scripts with a lower rank are executed before
  scripts with a higher rank.
- Added a new script module InstanceEnemyDropGenerator. This module can
  be used to have the server assign drops to an enemy when killed.
  Intended to eventually replace the event item generator via json.
- Fixed a few await warnings introduced from PR #919 related to
  scripting.
2025-07-05 10:36:47 -04:00

47 lines
1.5 KiB
C#

using Arrowgene.Ddon.GameServer.Scripting.Interfaces;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Arrowgene.Ddon.GameServer.Scripting
{
public class InstanceEnemyPropertyGeneratorModule : GameServerScriptModule
{
public override string ModuleRoot => Path.Combine("enemies", "instance_properties");
public override string Filter => "*.csx";
public override bool ScanSubdirectories => true;
public override bool EnableHotLoad => true;
private Dictionary<string, IInstanceEnemyPropertyGenerator> InstanceEnemyProperties { get; }
public InstanceEnemyPropertyGeneratorModule()
{
InstanceEnemyProperties = new Dictionary<string, IInstanceEnemyPropertyGenerator>();
}
public List<IInstanceEnemyPropertyGenerator> GetGenerators()
{
return InstanceEnemyProperties.Values.OrderBy(x => x.ScriptRank).ToList();
}
public override bool EvaluateResult(string path, object result, IDictionary<string, object> variables)
{
if (result == null)
{
return false;
}
var generator = (IInstanceEnemyPropertyGenerator)result;
if (generator == null)
{
return false;
}
string scriptName = Path.GetFileNameWithoutExtension(path);
InstanceEnemyProperties[scriptName] = generator;
return true;
}
}
}