Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d3e7f67

Browse files
authoredSep 17, 2024··
Fix with validations for attack and attacked observers
After talking with neon made fixes for what was before the commit that cause the bug
1 parent 2581d79 commit d3e7f67

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed
 

‎game-server/src/com/aionemu/gameserver/skillengine/effect/ProvokerEffect.java

+20-28
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,29 @@ public void applyEffect(Effect effect) {
4040
@Override
4141
public void startEffect(Effect effect) {
4242
Creature effector = effect.getEffector();
43-
ActionObserver observer;
43+
ObserverType observerType = hitType == HitType.NMLATK || hitType == HitType.BACKATK ? ObserverType.ATTACK : ObserverType.ATTACKED;
44+
effect.addObserver(effect.getEffected(), new ActionObserver(observerType) {
4445

45-
if (hitType == HitType.EVERYHIT) {
46-
observer = new ActionObserver(ObserverType.ATTACKED) {
47-
@Override
48-
public void attacked(Creature attacker, int attackSkillId) {
49-
if (shouldApply(effector, attacker, attackSkillId)) {
50-
if (effector instanceof Player player) {
51-
PacketSendUtility.sendPacket(player,
52-
SM_SYSTEM_MESSAGE.STR_SKILL_PROC_EFFECT_OCCURRED(DataManager.SKILL_DATA.getSkillTemplate(skillId).getL10n()));
53-
}
54-
SkillEngine.getInstance().applyEffectDirectly(skillId, effector, getProvokeTarget(effector, attacker));
55-
}
56-
}
57-
};
58-
} else {
59-
observer = new ActionObserver(ObserverType.ATTACK) {
60-
@Override
61-
public void attack(Creature attacked, int attackSkillId) {
62-
if (shouldApply(effector, attacked, attackSkillId)) {
63-
if (effector instanceof Player player) {
64-
PacketSendUtility.sendPacket(player,
65-
SM_SYSTEM_MESSAGE.STR_SKILL_PROC_EFFECT_OCCURRED(DataManager.SKILL_DATA.getSkillTemplate(skillId).getL10n()));
66-
}
67-
SkillEngine.getInstance().applyEffectDirectly(skillId, effector, getProvokeTarget(effector, attacked));
46+
@Override
47+
public void attack(Creature attacked, int attackSkillId) {
48+
tryApplyEffect(attacked, attackSkillId, effector);
49+
}
50+
51+
@Override
52+
public void attacked(Creature attacker, int attackSkillId) {
53+
tryApplyEffect(attacker, attackSkillId, effector);
54+
}
55+
56+
private void tryApplyEffect(Creature target, int attackSkillId, Creature effector) {
57+
if (shouldApply(effector, target, attackSkillId)) {
58+
if (effector instanceof Player player) {
59+
PacketSendUtility.sendPacket(player,
60+
SM_SYSTEM_MESSAGE.STR_SKILL_PROC_EFFECT_OCCURRED(DataManager.SKILL_DATA.getSkillTemplate(skillId).getL10n()));
6861
}
62+
SkillEngine.getInstance().applyEffectDirectly(skillId, effector, getProvokeTarget(effector, target));
6963
}
70-
};
71-
}
72-
73-
effect.addObserver(effect.getEffected(), observer);
64+
}
65+
});
7466
}
7567

7668
private boolean shouldApply(Creature effector, Creature target, int attackSkillId) {

0 commit comments

Comments
 (0)
Please sign in to comment.