Fixed guards not moving.

This commit is contained in:
MobiusDev
2017-08-09 16:37:18 +00:00
parent b201ce15e3
commit 5ab60b4287
20 changed files with 307 additions and 92 deletions

View File

@@ -1386,13 +1386,13 @@ public class L2Attackable extends L2Npc
setWalking();
// check the region where this mob is, do not activate the AI if region is inactive.
if (!isInActiveRegion())
{
if (hasAI())
{
getAI().stopAITask();
}
}
// if (!isInActiveRegion())
// {
// if (hasAI())
// {
// getAI().stopAITask();
// }
// }
}
@Override

View File

@@ -24,12 +24,14 @@ import com.l2jmobius.gameserver.ai.L2SpecialSiegeGuardAI;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.entity.Castle;
import com.l2jmobius.gameserver.model.entity.Fort;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class L2DefenderInstance extends L2Attackable
@@ -53,6 +55,16 @@ public class L2DefenderInstance extends L2Attackable
return new L2SpecialSiegeGuardAI(this);
}
@Override
public void addDamage(L2Character attacker, int damage, Skill skill)
{
super.addDamage(attacker, damage, skill);
L2World.getInstance().forEachVisibleObjectInRange(this, L2DefenderInstance.class, 500, defender ->
{
defender.addDamageHate(attacker, 0, 10);
});
}
/**
* Return True if a siege is in progress and the L2Character attacker isn't a Defender.
* @param attacker The L2Character that the L2SiegeGuardInstance try to attack

View File

@@ -23,13 +23,13 @@ import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.L2WorldRegion;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
@@ -66,21 +66,34 @@ public class L2GuardInstance extends L2Attackable
return super.isAutoAttackable(attacker);
}
@Override
public void addDamage(L2Character attacker, int damage, Skill skill)
{
super.addDamage(attacker, damage, skill);
getAI().startFollow(attacker);
addDamageHate(attacker, 0, 10);
L2World.getInstance().forEachVisibleObjectInRange(this, L2GuardInstance.class, 500, guard ->
{
guard.getAI().startFollow(attacker);
guard.addDamageHate(attacker, 0, 10);
});
}
/**
* Set the home location of its L2GuardInstance.
*/
@Override
public void onSpawn()
{
setRandomWalking(false);
super.onSpawn();
setRandomWalking(getTemplate().isRandomWalkEnabled());
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
// check the region where this mob is, do not activate the AI if region is inactive.
final L2WorldRegion region = L2World.getInstance().getRegion(this);
if ((region != null) && (!region.isActive()))
{
getAI().stopAITask();
}
// final L2WorldRegion region = L2World.getInstance().getRegion(this);
// if ((region != null) && (!region.isActive()))
// {
// getAI().stopAITask();
// }
}
/**

View File

@@ -147,7 +147,7 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
_talkable = set.getBoolean("talkable", true);
_undying = set.getBoolean("undying", true);
_showName = set.getBoolean("showName", true);
_randomWalk = set.getBoolean("randomWalk", true);
_randomWalk = set.getBoolean("randomWalk", !_type.equals("L2Guard"));
_randomAnimation = set.getBoolean("randomAnimation", true);
_flying = set.getBoolean("flying", false);
_canMove = set.getBoolean("canMove", true);