All pastes #32443 Raw Edit

Miscellany

public text v1 · immutable
#32443 ·published 2005-12-05 00:02 UTC
rendered paste body
Index: C:/java/net/sf/l2j/gameserver/model/L2Skill.java
===================================================================
--- C:/java/net/sf/l2j/gameserver/model/L2Skill.java	(revision 1777)
+++ C:/java/net/sf/l2j/gameserver/model/L2Skill.java	(working copy)
@@ -962,61 +962,94 @@
         }
         case TARGET_AREA:
         {
-            if((!(target instanceof L2Attackable)
-                    && !(target instanceof L2PcInstance)) || target.isAlikeDead() ||
-                    (this.getCastRange() >= 0 && (target == null || target == activeChar)))
+            if (
+                    (                                               // )
+                            !(target instanceof L2Attackable) &&    //   Target is not L2Attackable and
+                            !(target instanceof L2PcInstance)       //   Target is not L2PcInstance
+                    ) ||                                            // ) or
+                    (                                               // (
+                            this.getCastRange() >= 0 &&             //   Range skill and
+                            (                                       //   (
+                                    target == null ||               //     No target or
+                                    target == activeChar ||         //     Target is self or
+                                    target.isAlikeDead()            //     Target is dead/fake death
+                            )                                       //   )
+                    )                                               // )
+                )
             {
                 activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
                 return null;
             }
             
-            int charX, charY, charZ, targetX, targetY, targetZ, dx, dy, dz;
-            int radius = getSkillRadius();
-
             L2Character cha;
             if (this.getCastRange() >= 0)
+            {
                 cha = target;
+                targetList.add((L2Character)cha); // Add target to target list
+            }
             else
                 cha = activeChar;
 
+            boolean skillUserIsL2PcInstance = (activeChar instanceof L2PcInstance);
+            boolean effectOriginIsL2PcInstance = (cha instanceof L2PcInstance);
+            boolean objIsL2PcInstance;
+            int charX, charY, charZ, targetX, targetY, targetZ, dx, dy, dz;
+            int radius = getSkillRadius();
             for (L2Object obj : cha.getKnownObjects())
             {
-                if (obj instanceof L2Attackable)
+                target = (L2Character) obj;
+                if(!target.isAlikeDead())   // If target is is not dead of fake death
                 {
-                    target = (L2Character) obj;
-                    if(!target.isAlikeDead())
+                    charX = cha.getX();
+                    charY = cha.getY();
+                    charZ = cha.getZ();
+                    targetX = obj.getX();
+                    targetY = obj.getY();
+                    targetZ = obj.getZ();
+                    
+                    dx = Math.abs(charX - targetX);
+                    dy = Math.abs(charY - targetY);
+                    dz = Math.abs(charZ - targetZ);
+                    
+                    if (dx*dx + dy*dy + dz*dz > radius*radius) // Go to next obj if obj isn't in range
+                        continue;
+
+                    objIsL2PcInstance = (obj instanceof L2PcInstance);
+
+                    if (skillUserIsL2PcInstance)                // Skill attacker is L2PcInstance, hit everything except
                     {
-                        // Don't add this target if this is a PC->PC pvp casting and pvp condition not met
-                        if (cha instanceof L2PcInstance && !((L2PcInstance)cha).checkPvpSkill(obj, this))
+                        if (
+                                (                               // (
+                                        objIsL2PcInstance &&    //   obj is L2PcInstance and
+                                        (                       //   (
+                                                (               //     In same clan
+                                                        (((L2PcInstance)activeChar).getClan() != null && ((L2PcInstance)obj).getClan() != null) &&
+                                                        ((L2PcInstance)activeChar).getClan().getClanId() == ((L2PcInstance)obj).getClan().getClanId()
+                                                ) ||            //     or in same party
+                                                (
+                                                        (((L2PcInstance)activeChar).getParty() != null && ((L2PcInstance)obj).getParty() != null) &&
+                                                        ((L2PcInstance)activeChar).getParty().getPartyLeaderOID() == ((L2PcInstance)obj).getParty().getPartyLeaderOID()
+                                                ) ||            //     or not pvp with 
+                                                !((L2PcInstance)activeChar).checkPvpSkill(obj, this)
+                                        )                       //   )
+                                )
+                            )
                             continue;
-                        
-                        // check if both attacker and target are L2PcInstances and if they are in same party or clan
-                        if (   (cha instanceof L2PcInstance && obj instanceof L2PcInstance) && 
-                             (   ((L2PcInstance)cha).getClanId() == ((L2PcInstance)obj).getClanId() || 
-                             (  (((L2PcInstance)cha).getParty() != null && ((L2PcInstance)obj).getParty() != null) &&
-                                 ((L2PcInstance)cha).getParty().getPartyLeaderOID() == ((L2PcInstance)obj).getParty().getPartyLeaderOID() )))
+                    }
+                    else                                                // Skill user is not L2PcInstance
+                    {
+                        if (effectOriginIsL2PcInstance &&               // If effect starts at L2PcInstance and
+                                !objIsL2PcInstance)                     // Object is not L2PcInstance
                             continue;
-                        
-                        charX = cha.getX();
-                        charY = cha.getY();
-                        charZ = cha.getZ();
-                        targetX = obj.getX();
-                        targetY = obj.getY();
-                        targetZ = obj.getZ();
-                        
-                        dx = Math.abs(charX - targetX);
-                        dy = Math.abs(charY - targetY);
-                        dz = Math.abs(charZ - targetZ);
-                        
-                        if (dx*dx + dy*dy + dz*dz > radius*radius)
-                            continue;
-                        
-                        targetList.add((L2Character)obj);
                     }
+
+                    targetList.add((L2Character)obj);   // Add obj to target lists
                 }
             }
-            targetList.add((L2Character)cha);
             
+            if (targetList.size() == 0)
+                return null;
+
             return targetList.toArray(new L2Character[targetList.size()]);
         }
         case TARGET_MULTIFACE: