Selaa lähdekoodia

BETA: Moving L2AttackableAIScript logic to core to avoid creation of 65k+ listeners and fixing issue with one-skill-kill monsters not giving exp.
* Reported by: yksdtc, u3games.
* Tested by: yksdtc, Dinger

Rumen Nikiforov 11 vuotta sitten
vanhempi
sitoutus
3a9c40a3ce

+ 14 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java

@@ -775,10 +775,23 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 						if (npc.isInsideRadius(called, factionRange, true, false) && called.hasAI())
 						{
 							if ((Math.abs(originalAttackTarget.getZ() - called.getZ()) < 600) && npc.getAttackByList().contains(originalAttackTarget) && ((called.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (called.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE)) && (called.getInstanceId() == npc.getInstanceId()))
-							// && GeoData.getInstance().canSeeTarget(called, npc))
 							{
 								if (originalAttackTarget.isPlayable())
 								{
+									if (originalAttackTarget.isInParty() && originalAttackTarget.getParty().isInDimensionalRift())
+									{
+										byte riftType = originalAttackTarget.getParty().getDimensionalRift().getType();
+										byte riftRoom = originalAttackTarget.getParty().getDimensionalRift().getCurrentRoom();
+										
+										if ((npc instanceof L2RiftInvaderInstance) && !DimensionalRiftManager.getInstance().getRoom(riftType, riftRoom).checkIfInZone(npc.getX(), npc.getY(), npc.getZ()))
+										{
+											continue;
+										}
+									}
+									
+									// By default, when a faction member calls for help, attack the caller's attacker.
+									// Notify the AI with EVT_AGGRESSION
+									npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, originalAttackTarget, 1);
 									EventDispatcher.getInstance().notifyEventAsync(new OnAttackableFactionCall(called, getActiveChar(), originalAttackTarget.getActingPlayer(), originalAttackTarget.isSummon()), called);
 								}
 								else if ((called instanceof L2Attackable) && (getAttackTarget() != null) && (called.getAI()._intention != CtrlIntention.AI_INTENTION_ATTACK))

+ 28 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Attackable.java

@@ -344,6 +344,22 @@ public class L2Attackable extends L2Npc
 			// Delayed notification
 			EventDispatcher.getInstance().notifyEventAsyncDelayed(new OnAttackableKill(killer.getActingPlayer(), this, killer.isSummon()), this, _onKillDelay);
 		}
+		
+		// Notify to minions if there are.
+		if (isMonster())
+		{
+			final L2MonsterInstance mob = (L2MonsterInstance) this;
+			if ((mob.getLeader() != null) && mob.getLeader().hasMinions())
+			{
+				final int respawnTime = Config.MINIONS_RESPAWN_TIME.containsKey(getId()) ? Config.MINIONS_RESPAWN_TIME.get(getId()) * 1000 : -1;
+				mob.getLeader().getMinionList().onMinionDie(mob, respawnTime);
+			}
+			
+			if (mob.hasMinions())
+			{
+				mob.getMinionList().onMasterDie(false);
+			}
+		}
 		return true;
 	}
 	
@@ -645,17 +661,14 @@ public class L2Attackable extends L2Npc
 					WalkingManager.getInstance().stopMoving(this, false, true);
 				}
 				
+				getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, attacker);
+				addDamageHate(attacker, damage, (damage * 100) / (getLevel() + 7));
+				
 				final L2PcInstance player = attacker.getActingPlayer();
 				if (player != null)
 				{
 					EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAttack(player, this, damage, skill, attacker.isSummon()), this);
 				}
-				// for now hard code damage hate caused by an L2Attackable
-				else
-				{
-					getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, attacker);
-					addDamageHate(attacker, damage, (damage * 100) / (getLevel() + 7));
-				}
 			}
 			catch (Exception e)
 			{
@@ -696,6 +709,15 @@ public class L2Attackable extends L2Npc
 		
 		if ((targetPlayer != null) && (aggro == 0))
 		{
+			addDamageHate(attacker, 0, 1);
+			
+			// Set the intention to the L2Attackable to AI_INTENTION_ACTIVE
+			if (getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
+			{
+				getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
+			}
+			
+			// Notify to scripts
 			EventDispatcher.getInstance().notifyEventAsync(new OnAttackableAggroRangeEnter(this, targetPlayer, attacker.isSummon()), this);
 		}
 		else if ((targetPlayer == null) && (aggro == 0))

+ 33 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -19,6 +19,7 @@
 package com.l2jserver.gameserver.model.actor;
 
 import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
+import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_ATTACK;
 import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
 
 import java.util.ArrayList;
@@ -6209,6 +6210,38 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
 						if ((npcMob.isInsideRadius(player, 1000, true, true)))
 						{
 							EventDispatcher.getInstance().notifyEventAsync(new OnNpcSkillSee(npcMob, player, skill, targets, isSummon()), npcMob);
+							
+							// On Skill See logic
+							if (npcMob.isAttackable())
+							{
+								final L2Attackable attackable = (L2Attackable) npcMob;
+								
+								int skillEffectPoint = skill.getEffectPoint();
+								
+								if (player.hasSummon())
+								{
+									if ((targets.length == 1) && Util.contains(targets, player.getSummon()))
+									{
+										skillEffectPoint = 0;
+									}
+								}
+								
+								if (skillEffectPoint > 0)
+								{
+									if (attackable.hasAI() && (attackable.getAI().getIntention() == AI_INTENTION_ATTACK))
+									{
+										L2Object npcTarget = attackable.getTarget();
+										for (L2Object skillTarget : targets)
+										{
+											if ((npcTarget == skillTarget) || (npcMob == skillTarget))
+											{
+												L2Character originalCaster = isSummon() ? getSummon() : player;
+												attackable.addDamageHate(originalCaster, 0, (skillEffectPoint * 150) / (attackable.getLevel() + 7));
+											}
+										}
+									}
+								}
+							}
 						}
 					}
 				}