Compatibility with MythicLib damage system
I've been trying to build up an interface between the damage systems from Mythic and the MMO plugins.
Reason
It would be nice if elemental damage from MM was handled like elemental damage in MythicLib. This direction is implemented and working up to some extent. Similarly, it would also be nice to have MythicMobs detect and consider elemental damage from MythicLib.
Both plugins have features which modify the damage output based on damage cause. MythicMobs has damage modifiers, ML has tons of stats interacting with damage types and elements. Hence the need of being able to recognize damageMetas from other plugins.
Problem 1: structure of DamageMetadata
MythicMobs currently allows for one damage type, one amount, and a maximum of one element per DamageMetadata. MythicLib allows for multiple packets, which are basically sub-attacks. Packets have a set of damage types + one optional element. The final damage is the sum of all packets.
It's easy to implement the first direction of such interface: MM -> ML, because the DamageMetadata class is "contained" (ignoring most boolean options) in the ML DamageMeta class. Also, this direction is implemented and running in latest ML dev builds. It's working fine as long as the element names PERFECTLY MATCH in ML and MM. That means, MythicLib fully identifies and takes into account the DamageMetadatas from MM.
MythicMobs needs modularity with its damage system, and needs to have a script that detects and considers DamageMetadatas from ML. Here is a small "example "script that would adapt a DamageMetadata from ML to one from MM:
// Take a random element from all the packets.
@Nullable
private String findFirstElement(DamageMetadata damageMeta) {
for (DamagePacket packet : damageMeta.getPackets())
if (packet.getElement() != null)
return packet.getElement().getId();
return null;
}
private io.lumine.mythic.api.skills.damage.DamageMetadata adaptDamageMetadata(SkillCaster who, DamageMetadata damageMetadata) {
return new io.lumine.mythic.api.skills.damage.DamageMetadata(who,
damageMetadata.getDamage(),
findFirstElement(damageMetadata),
false,
false,
false,
false,
EntityDamageEvent.DamageCause.ENTITY_ATTACK);
}
That being said, the DmgMetadata structure issue just puts a limit to MM-ML compatibility. I've tried implementing a simple "adapter" script that would run on Bukkit damage events, which would transform DM's from ML into DM's from MM. That did not work, here's why:
Problem 2: event priorities
I've tried a lot of different things and I cannot implement this on my end. The reason has to do with event priorities. MythicLib applies tons of things (like on-hit effects, elemental damage etc.) using damage events on priority HIGHEST. Such an adapter script would be useless when ran at priority HIGHEST because MM has already done all its calculations. If I use a priority like LOWER, I risk conflicting with flag plugins like WG, Residence which prevent PvP in certain zones. I've done the assumption that MM runs at priority NORMAL or HIGH which should be the case imo.
That is to say, I think things have to be done on MM end. Hope you can provide more compatibility tools when redoing the dmg system, being able to achieve this in-depth damage system compatibility would be a nice advancement. I can provide more information if required
... Bugs
This creates weird issues were elements & damage types are only recognized in a specific direction (MM -> ML). On-hit elemental damage from ML is not recognized by MM on melee/projectiles attacks. Nevertheless, the mmodamage
mechanic works fine within MM (because it is coded to register the right DM's in both ML and MM).