@@ -40,37 +40,29 @@ public void applyEffect(Effect effect) {
40
40
@ Override
41
41
public void startEffect (Effect effect ) {
42
42
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 ) {
44
45
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 ()));
68
61
}
62
+ SkillEngine .getInstance ().applyEffectDirectly (skillId , effector , getProvokeTarget (effector , target ));
69
63
}
70
- };
71
- }
72
-
73
- effect .addObserver (effect .getEffected (), observer );
64
+ }
65
+ });
74
66
}
75
67
76
68
private boolean shouldApply (Creature effector , Creature target , int attackSkillId ) {
0 commit comments