Skill handling #169
Closed
exectails
started this conversation in
Discussions
Replies: 2 comments
-
I'd prefer the second option.
👍 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Since we're already very much going in the proposed direction, I think we can close this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I haven't taken a close look at how exactly ToS's skills work yet, but I'd like to talk about something before people try to implement them, as there are two conflicting approaches to it.
If you look at Athena or OdinMS for example, you will see that they basically handle skills in switch-cases. Related skills go into the same function, and what happens then is decided based on the skill's id. Here's a quick example of what something like that might look like.
RL example from eAthena:
There's basically a function and/or switch for any eventuality. Variables, buffs, effects, you name it. This approach has a huge advantage: it reduces redundancies. In your typical MMO there are very few skills that have actual special effects. For example, most damage dealing skills do pretty much the same thing, but with varying amounts of splash and damage. As a result, implementing a new damage skill in this system is generally as simple as adding a few fall-through cases, if any, because even defaulting might be an option.
This system was a little confusing to me when I started poking around eAthena as a beginner, because it wasn't compatible with what I expected. If I wanted to, say, change the damage of a skill and maybe play around with its effects, I couldn't search for a single function that handled one skill in its entirety. Instead I had to search for the general handler functions related to the thing I wanted to change, then find the switch, and either find the case for my skill, or add it if it didn't exist yet. The defaulting made it harder, because you might not even be able to search for the skill's id. It can be hard to wrap your head around this, and modding becomes harder.
For that reason I said to myself "if I ever create a server, I'll do better", so I went OOP for our Mabinogi emulator Aura. There, every skill has its own handler class, and you can change an entire skill's behavior in there. No jumping around, no searching, you want skill X, you get skill X.
This, in my opinion, is much more manageable. Anybody is able to easily look up that one skill's handler and figure out what it does, because it's all right there, it leaves no questions open. The skill does exactly what it says in its handler, no more and no less.
It also eliminates one potential source of bugs. In eAthena I know of at least one case where a damage buff affected a new skill for a while that wasn't supposed to receive that buff. It was applied because the switch-case defaulted. While you could argue that that's a minor point, because in a dedicated handler design there's a potential for forgetting to include effects or buffs, I would argue that with handlers you can at least see that it's missing.
One disadvantage is redundancy, lots of it. Every slightly similar skill's handler will look pretty much the same. You can try to use inheritance to reduce that, but I've found that to not work very well, as it makes things even more confusing than the switch-case approach. Not only can't you find everything in one handler anymore, you don't even know which handler to look in from the potential countless parent handlers, and you constantly wonder where to put something new.
The other disadvantage is maintenance. If anything changes about the majority of damage dealing skills, you potentially have to modify every single damage skill handler, instead of a single switch-case.
I was glad that I decided to use dedicated handlers in Aura in the end, because Mabinogi's skills turned out to be very special. There was redundancy, but in hindsight I can't imagine doing it any other way, it would've been a mess. Many skills had multiple phases, skill specific parameters coming from the client, features you couldn't really generalize, and all in all, from dozens of skills, there might've been 3-4 instances where a switch-case would've actually worked well.
That doesn't mean that it's necessarily right for ToS and Melia, but it's something we should consider.
Beta Was this translation helpful? Give feedback.
All reactions