Skip to content
dol-leodagan edited this page Sep 28, 2015 · 4 revisions

Attributes

DOL Server will look for the Following Attributes in your Assemblies to trigger specific behaviors.

Using Attributes tagging when extending "Core" Features is the best way to keep modifications to a minimum and prevent the need of changing low-level classes source file.

Game Server Scripts Enabled Attributes

  • ScriptLoadedEventAttribute / ScriptUnLoadedEventAttribute

Usage : Static Methods triggered before Game Server is Started / Stopped, ideal use case is features initializations making sure Core dependencies are available.

[ScriptLoadedEventAttribute]
public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args) { }
[ScriptUnloadedEvent]
public static void ScriptUnloaded(DOLEvent e, object sender, EventArgs args) { }
  • GameServerStartedEventAttribute / GameServerStoppedEventAttribute

Usage : Same as above except Methods are triggered on Game Server Start / Stop.

  • CmdAttribute

Usage : Targets Classes Implementing ICommandHandler Interface, automatically discover available in-game slash Commands for Player or Privileged Accounts.

[CmdAttribute("&serverinfo", ePrivLevel.Player, "Shows information about the server", "/serverinfo")]
public class ServerInfoCommandHandler : AbstractCommandHandler, ICommandHandler { }
  • DataTable

Usage : Targets Classes derived from DataObject, registering them as Database Table. DataTable class are used to auto-create a Database Table at startup, obeying DataElement / PrimaryKey / Relation Attributes to build the table definition.

[DataTable(TableName = "TownCrierMessages")]
public class TownCrierMessage : DataObject { }

Warning : TableName has to be Unique through all Project, when building your own module try to use some prefix to prevent collision.

  • DatabaseUpdateAttribute

Usage : Targets Classes implementing IDatabaseUpdater to be used as Database Migration Script on Server Startup. Update Methods will be triggered right after DOL Server finished registering DataTable thus having all definitions available for migration.

Warning : this can't be used for Table Definition Migration, if you change the DataObject of a Table you won't be able to match the previous columns values if they're not fields of the updated Runtime Object.

[DatabaseUpdate]
public class AutoXMLDatabaseUpdate : IDatabaseUpdater { }
  • ServerPropertyAttribute

Usage : Targets public static fields, register the field in ServerProperty table allowing for user-customized values at Startup or Runtime. The main use of this Attribute is to create Configuration Values that can be fine tuned by servers Admin through a simple database Table.

[ServerProperty("startup", "starting_money", "Starting Money - Edit this to change the amount in copper of money new characters start the game with, max 214 plat", 0)]
public static long STARTING_MONEY;

Warning : The ServerProperty Key String has to be unique through all Project, the Category String is used to Group Values by common Theme.

  • PropertyCalculatorAttribute

Usage : Targets Classes that implement IPropertyCalculator Interface, this allow to override default "Core" properties calculators with your own class, you can't add new PropertyCalculator this way except if it wasn't implemented in Core, Game Server Script Calculators will always replace "Core" Calculator on Startup if there is identical ID Match.

[PropertyCalculator(eProperty.SpellDamage)]
public class SpellDamagePercentCalculator : PropertyCalculator { }
  • ServerRulesAttribute

Usage : Targets Classes that implement IServerRules Interface, this allow to override or extend default "Core" Server Rules with your own Ruleset implementation, the Ruleset Type can be changed in serverconfig.xml, you cannot extend the hardcoded ruleset but you can implement missing ones or override existing ones...

[ServerRules(eGameServerType.GST_Normal)]
public class NormalServerRules : AbstractServerRules { }
  • RefreshCommandAttribute

Usage : Targets Static Methods that enable Data Cache refreshing, the Refresh Command Handler will search these attributes to give Privileged Players ability to rebuild cached collections. The targeted Method can return any object that will be displayed in user Log as string refresh status.

[RefreshCommandAttribute]
public static void InitRefreshCmdCache() { }
  • CharacterClassAttribute

Usage : Targets Classes that implement ICharacterClass, it can override "Core" Character Classes to implement your own Character Class behavior.

[CharacterClassAttribute((int)eCharacterClass.Fighter, "Fighter", "Fighter")]
public class ClassFighter : CharacterClassBase { }
  • NPCGuildScriptAttribute

Usage : Targets Classes derived from GameNPC, Match NPC GuildName Server-Wide against NPCGuildScriptAttribute to auto-set NPC Class.

[NPCGuildScript("Acolyte Trainer", eRealm.Albion)]
public class AcolyteTrainer : GameTrainer { }

Warning : Multiple Script on a given Guild Name in the same Assembly can produce unexpected results.

  • SpellHandlerAttribute

Usage : Targets Classes that implement ISpellHandler Interface to target specific Spell Behavior for a given SpellType. If this is used in Game Server Script it can override existing Spell Handlers, or extend existing ones from "Core".

[SpellHandlerAttribute("Bladeturn")]
public class BladeturnSpellHandler : SpellHandler { }
  • PacketHandlerAttribute

Usage : Targets Classes that implement IPacketHandler Interface, Packet Handler are meant to handle received Client Packet and trigger according methods based on Packet Code and Player Status, using this Attribute in Game Server Script allows to override default Core Packet Handlers or even add Handler for unimplemented Packet Codes.

[PacketHandlerAttribute(PacketHandlerType.TCP, eClientPackets.DisbandFromGroup, "Disband From Group Request Handler", eClientStatus.PlayerInGame)]
public class DisbandFromGroupHandler : IPacketHandler { }
  • PacketLibAttribute

Usage : Targets Classes that implement IPacketLib Interface, raw version is used to attach each PacketLib to the given Client Version, using this Attribute Handler in Game Server Script can be tricky as you would need to override all Client Versions and Base Class to implement most needed Send Packet Methods... It can still be used to fix some network code in a given Packet Lib Revision.

[PacketLib(1109, GameClient.eClientVersion.Version1109)]
public class PacketLib1109 : PacketLib1108