L2JMobius

The Kamael Confuse skill on monster need check

uchihasv · 12 · 5721

Offline uchihasv

  • Knight
  • ***
    • Posts: 54
Check pls Confuse skills(switching attack target) on monster.
They realy get MAD after confuse skill and can attack u in any range without move and can switch attack target to any NPC(not only mobs, include guards) in far range and go to him to attacking infinitely.


Offline AnsS

  • Heir
  • **
    • Posts: 37
I dont know how it needs to be work exactly, but if you want to change Confuse effect to switch target only monsters, do this:

Code: [Select]
diff --git a/dist/game/data/scripts/handlers/effecthandlers/Confuse.java b/dist/game/data/scripts/handlers/effecthandlers/Confuse.java
--- a/dist/game/data/scripts/handlers/effecthandlers/Confuse.java (date 1609953339310)
+++ b/dist/game/data/scripts/handlers/effecthandlers/Confuse.java (date 1609953339310)
@@ -25,6 +25,7 @@
 import org.l2jmobius.gameserver.model.StatSet;
 import org.l2jmobius.gameserver.model.World;
 import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance;
 import org.l2jmobius.gameserver.model.effects.AbstractEffect;
 import org.l2jmobius.gameserver.model.effects.EffectFlag;
 import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -70,7 +71,7 @@
  final List<Creature> targetList = new ArrayList<>();
  // Getting the possible targets
 
- World.getInstance().forEachVisibleObject(effected, Creature.class, targetList::add);
+ World.getInstance().forEachVisibleObject(effected, MonsterInstance.class, targetList::add);
 
  // if there is no target, exit function
  if (!targetList.isEmpty())

forEachVisibleObject method has an overload, where you can set range too. For example set range to 600:

Code: [Select]
diff --git a/dist/game/data/scripts/handlers/effecthandlers/Confuse.java b/dist/game/data/scripts/handlers/effecthandlers/Confuse.java
--- a/dist/game/data/scripts/handlers/effecthandlers/Confuse.java (date 1609953650912)
+++ b/dist/game/data/scripts/handlers/effecthandlers/Confuse.java (date 1609953650912)
@@ -25,6 +25,7 @@
 import org.l2jmobius.gameserver.model.StatSet;
 import org.l2jmobius.gameserver.model.World;
 import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance;
 import org.l2jmobius.gameserver.model.effects.AbstractEffect;
 import org.l2jmobius.gameserver.model.effects.EffectFlag;
 import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -70,7 +71,7 @@
  final List<Creature> targetList = new ArrayList<>();
  // Getting the possible targets
 
- World.getInstance().forEachVisibleObject(effected, Creature.class, targetList::add);
+ World.getInstance().forEachVisibleObject(effected, MonsterInstance.class, 600, targetList::add);
 
  // if there is no target, exit function
  if (!targetList.isEmpty())


Offline uchihasv

  • Knight
  • ***
    • Posts: 54
I think confuse should switch target only to attackable monsters and any players(with they summons).



Offline felipeafa

  • Knight
  • ***
    • Posts: 56
Check pls Confuse skills(switching attack target) on monster.
They realy get MAD after confuse skill and can attack u in any range without move and can switch attack target to any NPC(not only mobs, include guards) in far range and go to him to attacking infinitely.

I have been reported it months ago, but no solution after all.. All skills with Confuse effect not working.  :-\
1105 - Madness;
1213 - Seal of Mirage;

Skill 1105 Madness
Confuses the enemy into attacking random targets.

Skill 1213 Seal of Mirage
Throws nearby enemies into chaos, causing them to attack anybody randomly.

Iris comment.
Quote
"It doesn't. "Confuse" effects only works on mobs in retail servers.

When using these skills, there is a chance of making the mob start attacking another nearby monster that is already in combat, or another player that is not "friendly" with the effector.

If there are no other nearby monsters in combat, or players that are not friendly with the effector, the skill will never work.
If the "effected" is not currently attacking the "effector" directly, the skill will never work.


If the target is attacking you, and there is at least 1 nearby monster in combat, or a player that isn't friendly towards you (same party/clan/alliance/cc), and the skill chance successes, your target will be forced to attack that other monster/player for the duration of the skill, and therefore will ignore the threat level accumulated by you and/or other players against him."

This bug affect all project H5, Classic (all), and GOD+.


Offline uchihasv

  • Knight
  • ***
    • Posts: 54
I'm look in Skill Confusion xml with id 2 and this skill use RandomizeHate, not Confuse effect.

And big issue is if u use this skill: monster stop moving(like rooted, but without visual effect) and continue attack u in any range(melee mobs) without moving.

I'm try replace effect RandomizeHate to Confuse and in this case Skill do not any effect on monster(do not switch attack and no bug with stop moving and attack in range).

And i'm see deeper in core and found this in CreatureAI:
Code: [Select]
protected void onEvtConfused(Creature attacker)
{
// Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)
clientStopMoving(null);

// Launch actions corresponding to the Event onAttacked
onEvtAttacked(attacker);
}

But this method looks like wrong and unfinished, because it not do what says in this event comment:

Quote from: CtrlEvent
/** The creature attack anyone randomly **/
EVT_CONFUSED,


Offline felipeafa

  • Knight
  • ***
    • Posts: 56
I'm look in Skill Confusion xml with id 2 and this skill use RandomizeHate, not Confuse effect.

And big issue is if u use this skill: monster stop moving(like rooted, but without visual effect) and continue attack u in any range(melee mobs) without moving.

I'm try replace effect RandomizeHate to Confuse and in this case Skill do not any effect on monster(do not switch attack and no bug with stop moving and attack in range).

And i'm see deeper in core and found this in CreatureAI:
Code: [Select]
protected void onEvtConfused(Creature attacker)
{
// Stop the actor movement server side AND client side by sending Server->Client packet StopMove/StopRotation (broadcast)
clientStopMoving(null);

// Launch actions corresponding to the Event onAttacked
onEvtAttacked(attacker);
}

But this method looks like wrong and unfinished, because it not do what says in this event comment:

Quote from: CtrlEvent
/** The creature attack anyone randomly **/
EVT_CONFUSED,
On free and paid sources have the same problem and no solution at all..
I'll try something and share here.


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16130
On free and paid sources have the same problem and no solution at all..

By now you should know that, I do not respond well to people forcing words to have their work done.
If you are unhappy with getting 5 up to 30 commits daily (for the last month only), maybe you should stop being a subscriber.
When I will feel like working on something, I will.


Offline felipeafa

  • Knight
  • ***
    • Posts: 56
On free and paid sources have the same problem and no solution at all..

By now you should know that, I do not respond well to people forcing words to have their work done.
If you are unhappy with getting 5 up to 30 commits daily (for the last month only), maybe you should stop being a subscriber.
When I will feel like working on something, I will.

I'm ok with your rules and happy with your subs, boss!  ;)
Sry about the comment, i did not intend to offend! :-\


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16130
Since you been so nice, I might help.
Just need testing.

Code: [Select]
/*
 * This file is part of the L2J Mobius project.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package handlers.effecthandlers;

import java.util.ArrayList;
import java.util.List;

import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.effects.EffectFlag;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.stats.Formulas;

/**
 * Confuse effect implementation.
 * @author littlecrow
 */
public class Confuse extends AbstractEffect
{
private final int _chance;

public Confuse(StatSet params)
{
_chance = params.getInt("chance", 100);
}

@Override
public boolean calcSuccess(Creature effector, Creature effected, Skill skill)
{
return Formulas.calcProbability(_chance, effector, effected, skill);
}

@Override
public long getEffectFlags()
{
return EffectFlag.CONFUSED.getMask();
}

@Override
public boolean isInstant()
{
return true;
}

@Override
public void instant(Creature effector, Creature effected, Skill skill, ItemInstance item)
{
if ((effector == null) || (effected == null) || effected.isRaid() || effected.isRaidMinion())
{
return;
}

final List<Creature> targetList = new ArrayList<>();
for (Creature creature : World.getInstance().getVisibleObjectsInRange(effector, Creature.class, 600))
{
if (!effected.isAutoAttackable(creature) || creature.isRaid() || creature.isRaidMinion())
{
continue;
}

targetList.add(creature);
}

if (!targetList.isEmpty())
{
final Creature target = targetList.get(Rnd.get(targetList.size()));
effected.setTarget(target);
effected.getAI().notifyEvent(CtrlEvent.EVT_CONFUSED);

if (effected.isAttackable())
{
((Attackable) effected).addDamageHate(target, 0, 999);
}
else if (target.isAttackable()) // no?
{
((Attackable) target).addDamageHate(effected, 0, 999);
}

effected.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
}
}
}


Offline uchihasv

  • Knight
  • ***
    • Posts: 54
Do not work, mobs just stop and attacking u in range, if replace RandomizeHate to Confuse, just do nothing.


Offline GoshaVlad

  • Vassal
  • *
    • Posts: 5
If you have such a problem that skills Skill 1105 Madness and 1213 - Seal of Mirage do not work, and monsters do not want to hit each other, and the skill just never works.

Insturction how to make Skill 1105 Madness and 1213 - Seal of Mirage start working -.

1. open the skills xml > game/data/stats/skills
(you need to find the id of your skills)
2. change the lines
         <effect name="Confuse" abnormalTime="20">
            <chance>60</chance>
         </effect>
on the lines -
         <effect name="RandomizeHate">
            <chance>60</chance>
         </effect>
3. open the script RandomizeHate.java > game\data\scripts\handlers\effecthandlers
4. change the lines
      effectedMob.stopHating(effector);
      effectedMob.addDamageHate(target, 0, hate);
to the lines
      effectedMob.getAI().startFollow(target);
      effectedMob.addDamageHate(target, 0, 100000);
5. ready. now monsters attack each other, do not stand still and do not dumb.
(but now they will attack any monster they see, even if it is very, very far away)
6. to fix it., in RandomizeHate.java we change the lines -
      World.getInstance().forEachVisibleObject(effected, Creature.class, cha ->.
      {
         if ((cha != effectedMob) && (cha != effector))
         {
            // Аггро не может быть передано мобу той же фракции.
            if (cha.isAttackable() && ((Attackable) cha).isInMyClan(effectedMob))
            {
               return;
            }
            targetList.add(cha);
         }
      });
to the line -
      World.getInstance().forEachVisibleObjectInRange(effected, Creature.class, 600, targetList::add);
7.Done. Now that skill is working perfectly.

Attention, now some skills do not work correctly, namely - id 2, id 12 and id 2074 (I just removed them from the game, but you can try to fix them if you assign effect name= TargetCancel or DeleteHateOfMe).