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

@ -0,0 +1,74 @@
/*
* 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 ai.others;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.util.Util;
import ai.AbstractNpcAI;
/**
* @author Mobius
*/
public class RandomWalkingGuards extends AbstractNpcAI
{
private static final int[] GUARDS =
{
31032, // talking island
31033, // elf village
31034, // dark elf village
31036, // orc village
31035, // dwarf village
};
// Others
private static final int MIN_WALK_DELAY = 15000;
private static final int MAX_WALK_DELAY = 45000;
private RandomWalkingGuards()
{
addSpawnId(GUARDS);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equals("RANDOM_WALK") && (npc != null))
{
if (!npc.isInCombat())
{
addMoveToDesire(npc, GeoData.getInstance().moveCheck(npc.getLocation(), Util.getRandomPosition(npc.getSpawn().getLocation(), 0, Config.MAX_DRIFT_RANGE), npc.getInstanceWorld()), 23);
}
startQuestTimer("RANDOM_WALK", getRandom(MIN_WALK_DELAY, MAX_WALK_DELAY), npc, null);
}
return super.onAdvEvent(event, npc, player);
}
@Override
public String onSpawn(L2Npc npc)
{
startQuestTimer("RANDOM_WALK", getRandom(MIN_WALK_DELAY, MAX_WALK_DELAY), npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new RandomWalkingGuards();
}
}

View File

@ -1097,7 +1097,7 @@
</speed>
<abnormalResist physical="10" magical="10" />
</stats>
<status attackable="false" undying="false" talkable="false" />
<status attackable="false" undying="false" talkable="false" randomWalk="true" />
<skill_list>
<skill id="4045" level="1" /> <!-- Resist Full Magic Attack -->
<skill id="4408" level="1" /> <!-- HP Increase (1x) -->
@ -1137,7 +1137,7 @@
</speed>
<abnormalResist physical="10" magical="10" />
</stats>
<status attackable="false" undying="false" talkable="false" />
<status attackable="false" undying="false" talkable="false" randomWalk="true" />
<skill_list>
<skill id="4045" level="1" /> <!-- Resist Full Magic Attack -->
<skill id="4408" level="1" /> <!-- HP Increase (1x) -->
@ -1177,7 +1177,7 @@
</speed>
<abnormalResist physical="10" magical="10" />
</stats>
<status attackable="false" undying="false" talkable="false" />
<status attackable="false" undying="false" talkable="false" randomWalk="true" />
<skill_list>
<skill id="4045" level="1" /> <!-- Resist Full Magic Attack -->
<skill id="4408" level="1" /> <!-- HP Increase (1x) -->
@ -1217,7 +1217,7 @@
</speed>
<abnormalResist physical="10" magical="10" />
</stats>
<status attackable="false" undying="false" talkable="false" />
<status attackable="false" undying="false" talkable="false" randomWalk="true" />
<skill_list>
<skill id="4045" level="1" /> <!-- Resist Full Magic Attack -->
<skill id="4408" level="1" /> <!-- HP Increase (1x) -->
@ -1257,7 +1257,7 @@
</speed>
<abnormalResist physical="10" magical="10" />
</stats>
<status attackable="false" undying="false" talkable="false" />
<status attackable="false" undying="false" talkable="false" randomWalk="true" />
<skill_list>
<skill id="4045" level="1" /> <!-- Resist Full Magic Attack -->
<skill id="4408" level="1" /> <!-- HP Increase (1x) -->

View File

@ -158,6 +158,22 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
return false;
}
if (me instanceof L2GuardInstance)
{
L2World.getInstance().forEachVisibleObjectInRange(me, L2GuardInstance.class, 500, guard ->
{
if (guard.isAttackingNow() && (guard.getTarget() == player))
{
me.getAI().startFollow(player);
me.addDamageHate(player, 0, 10);
}
});
if (player.getReputation() < 0)
{
return true;
}
}
}
else if (me.isMonster())
{
@ -334,7 +350,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
_globalAggro--;
}
}
// Add all autoAttackable L2Character in L2Attackable Aggro Range to its _aggroList with 0 damage and 1 hate
// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
if (_globalAggro >= 0)
@ -354,15 +369,22 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
return;
}
}
// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
final int hating = npc.getHating(t);
// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
if (hating == 0)
{
npc.addDamageHate(t, 0, 1);
// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
final int hating = npc.getHating(t);
// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
if (hating == 0)
{
npc.addDamageHate(t, 0, 1);
}
if (npc instanceof L2GuardInstance)
{
L2World.getInstance().forEachVisibleObjectInRange(npc, L2GuardInstance.class, 500, guard ->
{
guard.addDamageHate(t, 0, 10);
});
}
}
}
});
@ -422,7 +444,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
}
// Check if the actor is a L2GuardInstance
if ((npc instanceof L2GuardInstance) && !npc.isWalker())
if ((npc instanceof L2GuardInstance) && !npc.isWalker() && !npc.isRandomWalkingEnabled())
{
// Order to the L2GuardInstance to return to its home location because there's no target to attack
npc.returnHome();

View File

@ -259,7 +259,7 @@ public class L2CharacterAI extends AbstractAI
// Set the AI attack target (change target)
setTarget(target);
stopFollow();
// stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);
@ -278,7 +278,7 @@ public class L2CharacterAI extends AbstractAI
// Set the AI attack target
setTarget(target);
stopFollow();
// stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);

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);

View File

@ -158,6 +158,22 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
return false;
}
if (me instanceof L2GuardInstance)
{
L2World.getInstance().forEachVisibleObjectInRange(me, L2GuardInstance.class, 500, guard ->
{
if (guard.isAttackingNow() && (guard.getTarget() == player))
{
me.getAI().startFollow(player);
me.addDamageHate(player, 0, 10);
}
});
if (player.getReputation() < 0)
{
return true;
}
}
}
else if (me.isMonster())
{
@ -334,7 +350,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
_globalAggro--;
}
}
// Add all autoAttackable L2Character in L2Attackable Aggro Range to its _aggroList with 0 damage and 1 hate
// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
if (_globalAggro >= 0)
@ -354,15 +369,22 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
return;
}
}
// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
final int hating = npc.getHating(t);
// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
if (hating == 0)
{
npc.addDamageHate(t, 0, 1);
// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
final int hating = npc.getHating(t);
// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
if (hating == 0)
{
npc.addDamageHate(t, 0, 1);
}
if (npc instanceof L2GuardInstance)
{
L2World.getInstance().forEachVisibleObjectInRange(npc, L2GuardInstance.class, 500, guard ->
{
guard.addDamageHate(t, 0, 10);
});
}
}
}
});
@ -422,7 +444,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
}
// Check if the actor is a L2GuardInstance
if ((npc instanceof L2GuardInstance) && !npc.isWalker())
if ((npc instanceof L2GuardInstance) && !npc.isWalker() && !npc.isRandomWalkingEnabled())
{
// Order to the L2GuardInstance to return to its home location because there's no target to attack
npc.returnHome();

View File

@ -259,7 +259,7 @@ public class L2CharacterAI extends AbstractAI
// Set the AI attack target (change target)
setTarget(target);
stopFollow();
// stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);
@ -278,7 +278,7 @@ public class L2CharacterAI extends AbstractAI
// Set the AI attack target
setTarget(target);
stopFollow();
// stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);

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);

View File

@ -158,6 +158,22 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
return false;
}
if (me instanceof L2GuardInstance)
{
L2World.getInstance().forEachVisibleObjectInRange(me, L2GuardInstance.class, 500, guard ->
{
if (guard.isAttackingNow() && (guard.getTarget() == player))
{
me.getAI().startFollow(player);
me.addDamageHate(player, 0, 10);
}
});
if (player.getReputation() < 0)
{
return true;
}
}
}
else if (me.isMonster())
{
@ -334,7 +350,6 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
_globalAggro--;
}
}
// Add all autoAttackable L2Character in L2Attackable Aggro Range to its _aggroList with 0 damage and 1 hate
// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
if (_globalAggro >= 0)
@ -354,15 +369,22 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
return;
}
}
// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
final int hating = npc.getHating(t);
// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
if (hating == 0)
{
npc.addDamageHate(t, 0, 1);
// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
final int hating = npc.getHating(t);
// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
if (hating == 0)
{
npc.addDamageHate(t, 0, 1);
}
if (npc instanceof L2GuardInstance)
{
L2World.getInstance().forEachVisibleObjectInRange(npc, L2GuardInstance.class, 500, guard ->
{
guard.addDamageHate(t, 0, 10);
});
}
}
}
});
@ -422,7 +444,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
}
// Check if the actor is a L2GuardInstance
if ((npc instanceof L2GuardInstance) && !npc.isWalker())
if ((npc instanceof L2GuardInstance) && !npc.isWalker() && !npc.isRandomWalkingEnabled())
{
// Order to the L2GuardInstance to return to its home location because there's no target to attack
npc.returnHome();

View File

@ -259,7 +259,7 @@ public class L2CharacterAI extends AbstractAI
// Set the AI attack target (change target)
setTarget(target);
stopFollow();
// stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);
@ -278,7 +278,7 @@ public class L2CharacterAI extends AbstractAI
// Set the AI attack target
setTarget(target);
stopFollow();
// stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);

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);