Nefarious

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So I'm trying to follow the good rule of thumb to not alter original scripts.

Is there a way to inherit a skills main file and add to it but not edit the original script? Or any script for that matter?
So there's herding.cs, can I make a advherding.cs that'll entend the original script?

Any advice would help.
 
The term you're looking for is Inheritance

Easiest example is
public class BoneArms : BaseArmor

BoneArms inherits BaseArmor, which in turn inherits Item.cs (from the Server folder, also known as the Core)

When you inherit a class you have to be mindful of what the parent class(es) hold to avoid unintended behaviors, issues, and major bugs
 
From my understanding of inheritance, the issue is that it will force my new advanced script (advanatomy) to inherit anatomy.cs. anatomy.cs won't know to apply anything from advanatomy.cs.

I guess I'm answering my own question, anatomy.cs will have to be edited to be able to know what to apply from advanatonmy code.

Thank you for coming to my TED talk. LoL
 
Check out the EventSink.cs in the Server files, you can hook into many events and run your custom code, I find it invaluable for maintaining SPR between Distro and Custom! This would be all use case of course depending on what you want to achieve!
 
Well there are some ways to extend classes, and you can also use the partial keyword.

But you cant really override in a way you want to. So yes your TED talk is right on the money :D

Also while throwing around some nice keywords ;) reflection is also fun :)
 
If you're implementing a custom skill handler, they are already modular; make an exact copy of the Anatomy class, name it AdvancedAnatomy.

The hook is the OnUse method being assigned to the Callback of the Anatomy skill' SkillInfo table entry:
C#:
    [CallPriority(1)]
    public class AdvancedAnatomy
    {
        public static void Initialize()
        {
            SkillInfo.Table[(int)SkillName.Anatomy].Callback = new SkillUseCallback(OnUse);
        }
...
When your AdvancedAnatomy class' Initialize method is invoked, it will cause it to overwrite the original registration by the Anatomy class.
The overwrite can only happen if the Initialize methods are invoked in the right order, so to ensure that happens, we use the CallPriority attribute to sort the methods.

As the Anatomy class doesn't implement a CallPriority attribute, it inherently has a priority of 0 - if the CallPriority attribute is not set on either of them, it will be up to the ScriptCompiler to figure out which Initialize method to invoke first and that will be based on their original order of appearance during the project build process.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back