fink
Member
Hello,
(Should this be in Support? As I don't need support with ServUO per say, I posted here - casual discussion.)
I am programming a system where players can unlock various abilities. I get around the code pretty easily, but I don't have much experience when it comes to building systems that are scalable and well thought-out. I'd like to get the community's input if my direction makes sense or am I headed in a wall.
The abilities will be very varied :
I created a BaseWeaponAction, from which abilities like Armor Ignore inherit.
I will create a BaseSpellAction.
I made my own CustomBaseWeapon inheriting BaseWeapon overriding the existing OnHit function as I don't want to deal with all the OSI stuff. It calls the player's current active action's methods for the bonuses to take into account when calculating the damage to apply:
If I take my version of Armor Ignore as an example, my class ArmorIgnoreAction has the following methods :
So far this architecture seems to be OK with what I foresee. Here are what I think may be a problem and would like second opinions :
Thanks for sharing your expertise!
(Should this be in Support? As I don't need support with ServUO per say, I posted here - casual discussion.)
I am programming a system where players can unlock various abilities. I get around the code pretty easily, but I don't have much experience when it comes to building systems that are scalable and well thought-out. I'd like to get the community's input if my direction makes sense or am I headed in a wall.
The abilities will be very varied :
- Weapon abilities like OSI (AI, Whirlwind, Double Strike, etc.)
- Spell abilities (damage/speed/mana cost enhancements, AoE enhancements with special effects, etc.)
- Weapon and Spell passives that can be toggled for various OnHit/OnMiss/OnBeingHit/etc. effects
- Monster special abilities
- Probably more varied interactions as I flesh out the system
- OnBeforeSwing
- OnSwing
- OnHit
- OnMiss
- GetDamageIncreasePerct()
- GetFlatDamageBonus()
I created a BaseWeaponAction, from which abilities like Armor Ignore inherit.
I will create a BaseSpellAction.
I made my own CustomBaseWeapon inheriting BaseWeapon overriding the existing OnHit function as I don't want to deal with all the OSI stuff. It calls the player's current active action's methods for the bonuses to take into account when calculating the damage to apply:
C#:
IAction action = atker_PM.ActiveAction;
bonusDamageFlat += action.BonusDamageFlat();
bonusDamagePerct += action.BonusDamagePerct();
bonusArmoreIgnorePerct += action.BonusArmoreIgnorePerct();
bonusHitchancePerct += action.BonusHitChancePerct();
action.OnHit(attacker, defender);
If I take my version of Armor Ignore as an example, my class ArmorIgnoreAction has the following methods :
C#:
public override double BonusArmoreIgnorePerct()
{
return 100;
}
public override void OnHit(Mobile attacker, Mobile defender)
{
UseAction(); //Triggers cooldowns, usage costs, etc.
attacker.SendLocalizedMessage(1060076); // Your attack penetrates their armor!
defender.SendLocalizedMessage(1060077); // The blow penetrated your armor!
defender.PlaySound(0x56);
defender.FixedParticles(0x3728, 200, 25, 9942, EffectLayer.Waist);
return;
}
So far this architecture seems to be OK with what I foresee. Here are what I think may be a problem and would like second opinions :
- The cooldowns of my abilities are handled with Callback methods : is this an issue or a bad practice? I never worked with callbacks and not sure if I should use a "LastUse" tick count and compare periodically instead.
- The way the damage calculation is done right now, I have to add a method for each and every bonus I wanna use in my damage calculation, and for each bonus source. One work around I see is creating a "Damage" class that can be passed to the current ability's OnHit method (and any other bonus sources). Calling one method per sources instead of one line per damage stat per sources.
Thanks for sharing your expertise!