Autor Tema: [Skill - Confusion] - Error  (Leído 47 veces)

canonmagic

  • Newbie
  • *
  • Mensajes: 39
  • Karma: +0/-0
    • Ver Perfil
[Skill - Confusion] - Error
« en: Junio 20, 2018, 02:32:14 pm »
Buenas, tanto esta habilidad como el resto que trabajan con el "EffectConfused" no estan funcionando, al lanzarla el efecto se activa e incluso se ve el efecto visual verdoso tipico de la confusion pero el mob sigue atacando al mismo objetivo aun teniendo otros mobs alrededor.
« Última modificación: Junio 22, 2018, 07:31:34 pm por fissban »

fissban

  • Administrador
  • Full Member
  • *
  • Mensajes: 144
  • Karma: +0/-0
    • Ver Perfil
Re:[Skill - Confusion] - Error
« Respuesta #1 en: Junio 20, 2018, 09:22:22 pm »
Bueno eh echo varias pruebas y al parecer lo logre pero toque varias cosas de los ai de los mobs asique deberiamos hacer un buen test por las dudas, aqui te dejo el diff.

Código
Index: java/net/sf/l2j/gameserver/handler/skill/SkillDisablers.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/skill/SkillDisablers.java (revision 1097)
+++ java/net/sf/l2j/gameserver/handler/skill/SkillDisablers.java (working copy)
@@ -167,12 +167,13 @@
  {
  if (monster.getTemplate().getRace() == NpcRaceType.UNDEAD)
  {
- monster.getAI().notifyEvent(CtrlEventType.AGGRESSION, null, -((L2MonsterInstance) target).getHating(((L2MonsterInstance) target).getMostHated()));
+ monster.stopHating(target);
+ monster.getAI().notifyEvent(CtrlEventType.AGGRESSION, null, -monster.getHating(monster.getMostHated()));
  }
  }
  else
  {
- monster.getAI().notifyEvent(CtrlEventType.AGGRESSION, null, -((L2MonsterInstance) target).getHating(((L2MonsterInstance) target).getMostHated()));
+ monster.getAI().notifyEvent(CtrlEventType.AGGRESSION, null, -monster.getHating(monster.getMostHated()));
  }
  }
  }
Index: java/net/sf/l2j/gameserver/handler/skill/SkillMdam.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/skill/SkillMdam.java (revision 1097)
+++ java/net/sf/l2j/gameserver/handler/skill/SkillMdam.java (working copy)
@@ -53,8 +53,8 @@
  return;
  }
 
- boolean sps = activeChar.isChargedShot(ShotType.SPIRITSHOTS);
- boolean bss = activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
+ var sps = activeChar.isChargedShot(ShotType.SPIRITSHOTS);
+ var bss = activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
 
  for (L2Object target2 : targets)
  {
@@ -69,15 +69,15 @@
  continue;
  }
 
- boolean mcrit = Formulas.calcMCrit(activeChar.getStat().getMCriticalHit(target, skill));
+ var mcrit = Formulas.calcMCrit(activeChar.getStat().getMCriticalHit(target, skill));
 
- int damage = (int) Formulas.calcMagicDam(activeChar, target, skill, sps, bss, mcrit);
+ var damage = (int) Formulas.calcMagicDam(activeChar, target, skill, sps, bss, mcrit);
 
  if (Config.LOG_VERY_HIGH_DAMAGE)
  {
  if ((damage > Config.LOG_DMG) && (activeChar instanceof L2PcInstance))
  {
- String name = "";
+ var name = "";
  if (target instanceof L2RaidBossInstance)
  {
  name = "RaidBoss ";
Index: java/net/sf/l2j/gameserver/model/actor/L2Attackable.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Attackable.java (revision 1093)
+++ java/net/sf/l2j/gameserver/model/actor/L2Attackable.java (working copy)
@@ -773,16 +773,25 @@
  ai.addHate(aggro);
  }
 
+ // Notify the L2Attackable AI with EVT_ATTACKED
+ if (damage > 0)
+ {
+ getAI().notifyEvent(CtrlEventType.ATTACKED, attacker);
+ }
  // Set the intention to the L2Attackable to AI_INTENTION_ACTIVE
- if ((aggro > 0) && (getAI().getIntention() == CtrlIntentionType.IDLE))
+ else if ((aggro > 0) && (getAI().getIntention() == CtrlIntentionType.IDLE))
  {
  getAI().setIntention(CtrlIntentionType.ACTIVE);
  }
-
- // Notify the L2Attackable AI with EVT_ATTACKED
- if (damage > 0)
+ else if (ai.getHate() <= 0)
  {
- getAI().notifyEvent(CtrlEventType.ATTACKED, attacker);
+ if (getMostHated() == null)
+ {
+ aggroList.clear();
+
+ getAI().setIntention(CtrlIntentionType.ACTIVE);
+ setWalking();
+ }
  }
  }
  }
Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 1097)
+++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
@@ -5051,7 +5051,7 @@
 
  broadcastPacket(new ChangeWaitType(this, ChangeWait.WT_STOP_FAKEDEATH));
  broadcastPacket(new Revive(this));
- getAI().notifyEvent(CtrlEventType.FAKE_DEATH, null);
+ getAI().notifyEvent(CtrlEventType.FAKE_DEATH);
  }
 
  /**
@@ -5064,7 +5064,7 @@
  */
  public final void stopFear()
  {
- getAI().notifyEvent(CtrlEventType.AFRAID, null);
+ getAI().notifyEvent(CtrlEventType.AFRAID);
  updateAbnormalEffect();
  }
 
@@ -5078,14 +5078,14 @@
  */
  public final void stopMuted()
  {
- getAI().notifyEvent(CtrlEventType.MUTED, null);
+ getAI().notifyEvent(CtrlEventType.MUTED);
  updateAbnormalEffect();
  }
 
  public final void stopPhysicalMuted()
  {
  setIsPhysicalMuted(false);
- getAI().notifyEvent(CtrlEventType.PHYSICAL_MUTED, null);
+ getAI().notifyEvent(CtrlEventType.PHYSICAL_MUTED);
  updateAbnormalEffect();
  }
 
@@ -5105,7 +5105,7 @@
  stopEffects(EffectType.ROOT);
  }
 
- getAI().notifyEvent(CtrlEventType.ROOTED, null);
+ getAI().notifyEvent(CtrlEventType.ROOTED);
  updateAbnormalEffect();
  }
 
@@ -5125,7 +5125,7 @@
  stopEffects(EffectType.SLEEP);
  }
 
- getAI().notifyEvent(CtrlEventType.SLEEPING, null);
+ getAI().notifyEvent(CtrlEventType.SLEEPING);
  updateAbnormalEffect();
  }
 
@@ -5145,7 +5145,7 @@
  stopEffects(EffectType.STUN);
  }
 
- getAI().notifyEvent(CtrlEventType.STUNNED, null);
+ getAI().notifyEvent(CtrlEventType.STUNNED);
  updateAbnormalEffect();
  }
 
@@ -5159,7 +5159,7 @@
  */
  public final void stopParalyze()
  {
- getAI().notifyEvent(CtrlEventType.PARALYZED, null);
+ getAI().notifyEvent(CtrlEventType.PARALYZED);
  updateAbnormalEffect();
  }
 
@@ -5184,7 +5184,6 @@
  public final void startConfused()
  {
  getAI().notifyEvent(CtrlEventType.CONFUSED);
- updateAbnormalEffect();
  }
 
  /**
@@ -5212,7 +5211,6 @@
  abortAttack();
  abortCast();
  getAI().notifyEvent(CtrlEventType.AFRAID);
- updateAbnormalEffect();
  }
 
  /**
@@ -5222,7 +5220,6 @@
  {
  abortCast();
  getAI().notifyEvent(CtrlEventType.MUTED);
- updateAbnormalEffect();
  }
 
  /**
@@ -5233,7 +5230,6 @@
  setIsPhysicalMuted(true);
  abortAttack();
  getAI().notifyEvent(CtrlEventType.PHYSICAL_MUTED);
- updateAbnormalEffect();
  }
 
  /**
@@ -5243,7 +5239,6 @@
  {
  stopMove(null);
  getAI().notifyEvent(CtrlEventType.ROOTED);
- updateAbnormalEffect();
  }
 
  /**
@@ -5256,7 +5251,6 @@
  stopMove(null);
  getAI().notifyEvent(CtrlEventType.SLEEPING);
  getAI().setIntention(CtrlIntentionType.IDLE);
- updateAbnormalEffect();
  }
 
  /**
@@ -5273,7 +5267,6 @@
  stopMove(null);
  getAI().notifyEvent(CtrlEventType.STUNNED);
  getAI().setIntention(CtrlIntentionType.IDLE);
- updateAbnormalEffect();
  }
 
  /**
@@ -5290,6 +5283,5 @@
  stopMove(null);
  getAI().notifyEvent(CtrlEventType.PARALYZED);
  getAI().setIntention(CtrlIntentionType.IDLE);
- updateAbnormalEffect();
  }
 }
Index: java/net/sf/l2j/gameserver/model/actor/ai/AttackableAI.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/ai/AttackableAI.java (revision 1092)
+++ java/net/sf/l2j/gameserver/model/actor/ai/AttackableAI.java (working copy)
@@ -223,11 +223,6 @@
  return false;
  }
 
- if ((target instanceof L2Attackable) && me.isConfused())
- {
- return GeoEngine.getInstance().canSeeTarget(me, target);
- }
-
  // Check if the target isn't another L2Npc
  if (target instanceof L2Npc)
  {
@@ -533,7 +528,16 @@
  return;
  }
 
- L2Character attackTarget = npc.getMostHated();
+ L2Character attackTarget;
+
+ if (npc.isConfused() && getTarget() != null && getTarget() instanceof L2Character)
+ {
+ attackTarget = (L2Character) getTarget();
+ }
+ else
+ {
+ attackTarget = npc.getMostHated();
+ }
 
  // If target doesn't exist, is dead or if timeout is expired (non-aggro mobs or mobs which are too far stop to attack)
  if ((attackTarget == null) || attackTarget.isAlikeDead() || ((attackTimeOut < System.currentTimeMillis()) && (!npc.isAggressive() || (Math.sqrt(npc.getPlanDistanceSq(attackTarget.getX(), attackTarget.getY())) > (npc.getAggroRange() * 2)))))
@@ -637,37 +641,14 @@
  }
  }
 
- setTarget(attackTarget);
- npc.setTarget(attackTarget);
-
- /**
- * COMMON INFORMATIONS<br>
- * Used for range and distance check.
- */
-
- // Get all information needed to choose between physical or magical attack
-
- // Force mobs to attack anybody if confused
- L2Character hated;
- if (activeActor.isConfused() || ((((L2Attackable) activeActor).getMostHated() == null) && (attackTarget instanceof L2Attackable)))
- {
- hated = attackTarget;
- }
- else
- {
- hated = ((L2Attackable) activeActor).getMostHated();
- }
-
- if (hated == null)
+ if (attackTarget == null)
  {
  setIntention(CtrlIntentionType.ACTIVE);
  return;
  }
 
- if (hated != attackTarget)
- {
- setTarget(hated);
- }
+ setTarget(attackTarget);
+ npc.setTarget(attackTarget);
 
  attackTimeOut = MAX_ATTACK_TIMEOUT + System.currentTimeMillis();
 
@@ -741,7 +722,7 @@
  }
 
  // We should calculate new distance cuz mob can have changed the target
- double dist = activeActor.getPlanDistanceSq(hated.getX(), hated.getY());
+ double dist = activeActor.getPlanDistanceSq(attackTarget.getX(), attackTarget.getY());
  int collision = (int) npc.getTemplate().getCollisionRadius();
  int combinedCollision = collision + collision;
  int range = npc.getStat().getPhysicalAttackRange() + combinedCollision;
@@ -749,7 +730,7 @@
  if (npc.isMovementDisabled())
  {
  // If you are immobilized and do not have to rank your goal we are looking for a new one
- if (!Util.checkIfInRange(range, activeActor, hated, false))
+ if (!Util.checkIfInRange(range, activeActor, attackTarget, false))
  {
  attackTarget = targetReconsider(range, true);
  }
@@ -763,7 +744,7 @@
  return;
  }
 
- if (hated.isMoving())
+ if (attackTarget.isMoving())
  {
  range = range + 50;
  if (npc.isMoving())
@@ -815,7 +796,7 @@
  ItemWeapon weapon = activeActor.getActiveWeaponItem();
  if ((weapon != null) && (weapon.getType() == WeaponType.BOW))
  {
- if (Util.checkIfInRange(100, activeActor, hated, false) && (Rnd.get(4) > 1))
+ if (Util.checkIfInRange(100, activeActor, attackTarget, false) && (Rnd.get(4) > 1))
  {
  final int posX = npc.getX() + ((attackTarget.getX() < npc.getX()) ? 300 : -300);
  final int posY = npc.getY() + ((attackTarget.getY() < npc.getY()) ? 300 : -300);
@@ -833,7 +814,7 @@
  if (dist > (range * range))
  {
  // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
- if (hated.isMoving())
+ if (attackTarget.isMoving())
  {
  range -= 100;
  }
@@ -852,7 +833,7 @@
 
  // Finally, physical attacks
  clientStopMoving(null);
- getActor().doAttack(hated);
+ getActor().doAttack(attackTarget);
  }
 
  private static boolean canUseSkill(L2Character actor, Skill sk)
Index: java/net/sf/l2j/gameserver/model/actor/ai/CharacterAI.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/ai/CharacterAI.java (revision 1091)
+++ java/net/sf/l2j/gameserver/model/actor/ai/CharacterAI.java (working copy)
@@ -199,7 +199,7 @@
  stopFollow();
 
  // Launch the Think Event
- notifyEvent(CtrlEventType.THINK, null);
+ notifyEvent(CtrlEventType.THINK);
  }
  else
  {
@@ -208,16 +208,16 @@
  }
  else
  {
- // Set the Intention of this AbstractAI to AI_INTENTION_ATTACK
- changeIntention(CtrlIntentionType.ATTACK, target, null);
-
  // Set the AI attack target
  setTarget(target);
 
+ // Set the Intention of this AbstractAI to AI_INTENTION_ATTACK
+ changeIntention(CtrlIntentionType.ATTACK, target, null);
+
  stopFollow();
 
  // Launch the Think Event
- notifyEvent(CtrlEventType.THINK, null);
+ notifyEvent(CtrlEventType.THINK);
  }
  }
 
Index: java/net/sf/l2j/gameserver/model/skills/effects/type/EffectConfusion.java
===================================================================
--- java/net/sf/l2j/gameserver/model/skills/effects/type/EffectConfusion.java (revision 1091)
+++ java/net/sf/l2j/gameserver/model/skills/effects/type/EffectConfusion.java (working copy)
@@ -21,14 +21,11 @@
 import java.util.ArrayList;
 
 import net.sf.l2j.gameserver.model.actor.L2Character;
-import net.sf.l2j.gameserver.model.actor.L2Playable;
 import net.sf.l2j.gameserver.model.actor.ai.enums.CtrlIntentionType;
-import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.FlagType;
 import net.sf.l2j.gameserver.model.skills.effects.Effect;
 import net.sf.l2j.gameserver.model.skills.effects.EffectTemplate;
 import net.sf.l2j.gameserver.model.skills.effects.enums.EffectType;
 import net.sf.l2j.gameserver.model.skills.stats.Env;
-import net.sf.l2j.gameserver.util.Util;
 import net.sf.l2j.util.lib.Rnd;
 
 /**
@@ -36,6 +33,8 @@
  */
 public class EffectConfusion extends Effect
 {
+ private static final int RADIUS = 600;
+
  public EffectConfusion(Env env, EffectTemplate template)
  {
  super(env, template);
@@ -51,6 +50,8 @@
  public void onStart()
  {
  getEffected().startConfused();
+
+ onActionTime();
  }
 
  @Override
@@ -65,23 +66,11 @@
  var targetList = new ArrayList<L2Character>();
 
  // Getting the possible targets
- for (L2Character character : getEffector().getKnownList().getObjectType(L2Character.class))
+ for (var character : getEffected().getKnownList().getObjectTypeInRadius(L2Character.class, RADIUS))
  {
- if ((character != getEffected()) && Util.checkIfInShortRadius(600, getEffected(), character, true))
+ if (character != getEffector())
  {
- if (character instanceof L2Playable)
- {
- var player = ((L2Playable) character).getActingPlayer();
-
- if (player.getPvpFlag() != FlagType.NON_PVP || player.getKarma() > 0)
- {
- targetList.add(character);
- }
- }
- else
- {
- targetList.add(character);
- }
+ targetList.add(character);
  }
  }
 
@@ -95,6 +84,7 @@
  var target = targetList.get(Rnd.nextInt(targetList.size()));
 
  // Attacking the target
+ getEffected().setTarget(target);
  getEffected().getAI().setIntention(CtrlIntentionType.ATTACK, target);
 
  return true;


canonmagic

  • Newbie
  • *
  • Mensajes: 39
  • Karma: +0/-0
    • Ver Perfil
Re:[Skill - Confusion] - Error
« Respuesta #2 en: Junio 21, 2018, 04:42:47 pm »
Bueno, horita estuve probandolo un rato con los diferentes skills que utilizan el mismo efecto y parece que todos funcionan bien  ;D