Sync with L2jServer HighFive Jun 14th 2015.

This commit is contained in:
MobiusDev 2015-06-14 11:51:57 +00:00
parent a3707acaaa
commit 166d6ff9d4
48 changed files with 675 additions and 356 deletions

View File

@ -1,4 +1,4 @@
#the hexID to auth into login
#Wed May 13 23:14:37 EEST 2015
#The HexId to Auth into LoginServer
#Fri Jan 02 01:25:33 EET 2015
HexID=-2ad66b3f483c22be097019f55c8abdf0
ServerID=14

View File

@ -28,10 +28,12 @@ import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.xml.impl.DoorData;
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.TeleportWhereType;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
@ -93,6 +95,7 @@ public final class Beleth extends AbstractNpcAI
private L2PcInstance _killer;
private int _allowedObjId;
private int _killedCount;
private long _lastAttack;
private final List<L2Npc> _minions = new CopyOnWriteArrayList<>();
private Beleth()
@ -372,11 +375,17 @@ public final class Beleth extends AbstractNpcAI
c.setIsImmobilized(false);
}
_lastAttack = System.currentTimeMillis();
startQuestTimer("CHECK_ATTACK", 60000, null, null);
startQuestTimer("SPAWN25", 60000, null, null);
break;
}
case "SPAWN25":
{
_minions.clear();
int a = 0;
for (int i = 0; i < 16; i++)
{
@ -534,6 +543,33 @@ public final class Beleth extends AbstractNpcAI
}
break;
}
case "CHECK_ATTACK":
{
if ((_lastAttack + 900000) < System.currentTimeMillis())
{
GrandBossManager.getInstance().setBossStatus(REAL_BELETH, ALIVE);
for (L2Character charInside : ZONE.getCharactersInside())
{
if (charInside != null)
{
if (charInside.isNpc())
{
charInside.deleteMe();
}
else if (charInside.isPlayer())
{
charInside.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(charInside, TeleportWhereType.TOWN));
}
}
}
cancelQuestTimer("CHECK_ATTACK", null, null);
}
else
{
startQuestTimer("CHECK_ATTACK", 60000, null, null);
}
break;
}
}
return super.onAdvEvent(event, npc, player);
}
@ -718,6 +754,8 @@ public final class Beleth extends AbstractNpcAI
{
if (npc.getId() == REAL_BELETH)
{
cancelQuestTimer("CHECK_ATTACK", null, null);
setBelethKiller(killer);
GrandBossManager.getInstance().setBossStatus(REAL_BELETH, DEAD);
final long respawnTime = (Config.BELETH_SPAWN_INTERVAL + getRandom(-Config.BELETH_SPAWN_RANDOM, Config.BELETH_SPAWN_RANDOM)) * 3600000;
@ -749,7 +787,7 @@ public final class Beleth extends AbstractNpcAI
startQuestTimer("SPAWN26", 1000, null, null);
}
else if ((npc.getId() == FAKE_BELETH) && (npc.getObjectId() == _allowedObjId))
else if (npc.getObjectId() == _allowedObjId)
{
deleteAll();

View File

@ -157,6 +157,7 @@ public final class EffectMasterHandler
Resurrection.class,
ResurrectionSpecial.class,
Root.class,
RunAway.class,
ServitorShare.class,
SetSkill.class,
ShilensBreath.class,

View File

@ -217,9 +217,8 @@ public class ClanBoard implements IWriteBoardHandler
}
i = 0;
int nbp;
nbp = ClanTable.getInstance().getClans().length / 8;
if ((nbp * 8) != ClanTable.getInstance().getClans().length)
int nbp = ClanTable.getInstance().getClanCount() / 8;
if ((nbp * 8) != ClanTable.getInstance().getClanCount())
{
nbp++;
}

View File

@ -86,9 +86,9 @@ public final class HomeBoard implements IParseBoardHandler
CommunityBoardHandler.getInstance().addBypass(activeChar, "Home", command);
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/" + customPath + "home.html");
html = html.replaceAll("%fav_count%", String.valueOf(getFavoriteCount(activeChar)));
html = html.replaceAll("%region_count%", String.valueOf(getRegionCount(activeChar)));
html = html.replaceAll("%clan_count%", String.valueOf(getClansCount()));
html = html.replaceAll("%fav_count%", Integer.toString(getFavoriteCount(activeChar)));
html = html.replaceAll("%region_count%", Integer.toString(getRegionCount(activeChar)));
html = html.replaceAll("%clan_count%", Integer.toString(ClanTable.getInstance().getClanCount()));
CommunityBoardHandler.separateAndSend(html, activeChar);
}
else if (command.startsWith("_bbstop;"))
@ -206,13 +206,4 @@ public final class HomeBoard implements IParseBoardHandler
{
return 0; // TODO: Implement.
}
/**
* Gets the clans count.
* @return the clans count
*/
private static int getClansCount()
{
return ClanTable.getInstance().getClans().length;
}
}

View File

@ -18,12 +18,8 @@
*/
package handlers.effecthandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.instance.L2DefenderInstance;
import com.l2jserver.gameserver.model.actor.instance.L2FortCommanderInstance;
@ -33,7 +29,6 @@ import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.effects.EffectFlag;
import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.util.Util;
/**
* Fear effect implementation.
@ -41,8 +36,6 @@ import com.l2jserver.gameserver.util.Util;
*/
public final class Fear extends AbstractEffect
{
public static final int FEAR_RANGE = 500;
public Fear(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
@ -77,7 +70,7 @@ public final class Fear extends AbstractEffect
@Override
public boolean onActionTime(BuffInfo info)
{
fearAction(info, false);
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID, info.getEffector(), false);
return false;
}
@ -89,34 +82,6 @@ public final class Fear extends AbstractEffect
info.getEffected().abortCast();
}
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID);
fearAction(info, true);
}
private void fearAction(BuffInfo info, boolean start)
{
double radians = Math.toRadians(start ? Util.calculateAngleFrom(info.getEffector(), info.getEffected()) : Util.convertHeadingToDegree(info.getEffected().getHeading()));
int posX = (int) (info.getEffected().getX() + (FEAR_RANGE * Math.cos(radians)));
int posY = (int) (info.getEffected().getY() + (FEAR_RANGE * Math.sin(radians)));
int posZ = info.getEffected().getZ();
if (!info.getEffected().isPet())
{
info.getEffected().setRunning();
}
// If pathfinding enabled the creature will go to the defined destination (retail like).
// Otherwise it will go to the nearest obstacle.
final Location destination;
if (Config.PATHFINDING > 0)
{
destination = new Location(posX, posY, posZ, info.getEffected().getInstanceId());
}
else
{
destination = GeoData.getInstance().moveCheck(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), posX, posY, posZ, info.getEffected().getInstanceId());
}
info.getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID, info.getEffector(), true);
}
}

View File

@ -47,7 +47,6 @@ public final class Grow extends AbstractEffect
if (info.getEffected().isNpc())
{
L2Npc npc = (L2Npc) info.getEffected();
npc.setCollisionHeight(npc.getTemplate().getCollisionHeight());
npc.setCollisionRadius(npc.getTemplate().getfCollisionRadius());
}
}
@ -58,7 +57,6 @@ public final class Grow extends AbstractEffect
if (info.getEffected().isNpc())
{
L2Npc npc = (L2Npc) info.getEffected();
npc.setCollisionHeight(npc.getTemplate().getCollisionHeightGrown());
npc.setCollisionRadius(npc.getTemplate().getCollisionRadiusGrown());
}
}

View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.effecthandlers;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.ai.L2AttackableAI;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.util.Rnd;
/**
* Run Away effect implementation.
* @author Zoey76
*/
public final class RunAway extends AbstractEffect
{
private final int _power;
private final int _time;
public RunAway(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
_power = params.getInt("power", 0);
_time = params.getInt("time", 0);
}
@Override
public boolean isInstant()
{
return true;
}
@Override
public void onStart(BuffInfo info)
{
if (!info.getEffected().isAttackable())
{
return;
}
if (Rnd.get(100) > _power)
{
return;
}
if (info.getEffected().isCastingNow() && info.getEffected().canAbortCast())
{
info.getEffected().abortCast();
}
((L2AttackableAI) info.getEffected().getAI()).setFearTime(_time);
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID, info.getEffector(), true);
}
}

View File

@ -29,7 +29,6 @@ import com.l2jserver.gameserver.enums.ChatType;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.PcCondOverride;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Instance;
@ -242,7 +241,7 @@ public final class DarkCloudMansion extends AbstractInstance
@Override
protected boolean checkConditions(L2PcInstance player)
{
if (debug || player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
if (debug)
{
return true;
}

View File

@ -955,6 +955,7 @@
<param consumeItemId="1459" consumeItemCount="4" />
<param lifeTime="1200" />
<param expMultiplier="#ench1expPenalty" />
<param summonPoints="4" />
</effect>
</enchant1for>
</skill>
@ -1334,13 +1335,13 @@
</effect>
<effect name="ConsumeBody" />
</enchant1for>
<enchant1for>
<enchant2for>
<effect name="Sweeper" />
<effect name="ManaHealByLevel">
<param power="#ench2DrainMp" />
</effect>
<effect name="ConsumeBody" />
</enchant1for>
</enchant2for>
</skill>
<skill id="44" levels="3" name="Remedy">
<table name="#dispelAbnormals"> BLEEDING,3 BLEEDING,7 BLEEDING,9 </table>

View File

@ -312,6 +312,7 @@
<table name="#magicLvl"> 55 58 60 62 64 66 68 70 72 74 </table>
<table name="#mpConsume"> 50 53 55 58 59 61 63 65 67 68 </table>
<table name="#ench1Cost"> 66 65 64 63 62 61 60 58 57 56 55 54 53 52 51 49 48 47 46 45 44 43 41 40 39 38 37 36 35 34 </table>
<table name="#ench2Power"> 30 31 32 32 33 34 34 35 36 36 37 38 38 39 40 40 41 42 42 43 44 44 45 46 46 47 48 48 49 50 </table>
<table name="#ench2LethalStrikeRate"> 25 25 25 26 26 26 26 27 27 27 27 28 28 28 29 29 29 29 30 30 30 30 31 31 31 31 32 32 32 33 </table>
<table name="#ench3Attack"> 191 196 201 206 211 216 221 227 232 237 242 247 252 257 263 268 273 278 283 288 293 298 304 309 314 319 324 329 334 340 </table>
<table name="#ench4HolyAttack"> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 </table>
@ -343,19 +344,28 @@
<target race="UNDEAD" />
</cond>
<for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</for>
<enchant2for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="#ench2Power" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="#ench2LethalStrikeRate" />
</effect>
</enchant2for>
<enchant3for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
@ -1820,6 +1830,7 @@
<table name="#magicLvl"> 55 58 60 62 64 66 68 70 72 74 </table>
<table name="#mpConsume"> 50 53 55 58 59 61 63 65 67 68 </table>
<table name="#ench1Cost"> 66 65 64 63 62 61 60 58 57 56 55 54 53 52 51 49 48 47 46 45 44 43 41 40 39 38 37 36 35 34 </table>
<table name="#ench2Power"> 30 31 32 32 33 34 34 35 36 36 37 38 38 39 40 40 41 42 42 43 44 44 45 46 46 47 48 48 49 50 </table>
<table name="#ench2LethalStrikeRate"> 25 25 25 26 26 26 26 27 27 27 27 28 28 28 29 29 29 29 30 30 30 30 31 31 31 31 32 32 32 33 </table>
<table name="#ench3Attack"> 191 196 201 206 211 216 221 227 232 237 242 247 252 257 263 268 273 278 283 288 293 298 304 309 314 319 324 329 334 340 </table>
<table name="#ench4DarkAttack"> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 </table>
@ -1851,19 +1862,28 @@
<target race="DIVINE" />
</cond>
<for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</for>
<enchant2for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="#ench2Power" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="#ench2LethalStrikeRate" />
</effect>
</enchant2for>
<enchant3for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>

View File

@ -7,6 +7,7 @@
<table name="#magicLvl"> 56 58 60 62 64 66 68 70 72 74 </table>
<table name="#mpConsume"> 41 43 44 46 48 49 51 52 53 55 </table>
<table name="#mpInitialConsume"> 11 11 11 12 12 13 13 13 14 14 </table>
<table name="#ench1Power"> 30 31 32 32 33 34 34 35 36 36 37 38 38 39 40 40 41 42 42 43 44 44 45 46 46 47 48 48 49 50 </table>
<table name="#ench1LethalStrikeRate"> 25 25 25 26 26 26 27 27 27 28 28 28 28 29 29 29 30 30 30 31 31 31 31 32 32 32 33 33 33 34 </table>
<table name="#ench2mpConsume"> 53 52 51 50 49 48 48 47 46 45 44 43 42 41 40 39 38 38 37 36 35 34 33 32 31 30 29 29 28 27 </table>
<table name="#ench2mpInitialConsume"> 13 13 12 12 12 12 12 11 11 11 11 10 10 10 10 9 9 9 9 9 8 8 8 8 7 7 7 7 7 6 </table>
@ -42,25 +43,37 @@
<target race="UNDEAD" />
</cond>
<for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</for>
<enchant1for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="#ench1Power" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="#ench1LethalStrikeRate" />
</effect>
</enchant1for>
<enchant2for>
<effect name="Fear" abnormalTime="#ench2Time" />
<effect name="RunAway">
<param power="#ench1Power" />
<param time="#ench2Time" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</enchant2for>
<enchant3for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>

View File

@ -1885,13 +1885,14 @@
<skill id="2286" levels="6" name="Scroll: Recovery">
<!-- Confirmed CT2.5 -->
<table name="#levelRange"> 1;19 20;39 40;51 52;60 61;75 76;85 </table>
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="rideState" val="NONE;STRIDER;WYVERN;WOLF" />
<table name="#itemConsumeId"> 8594 8595 8596 8597 8598 8599 </table>
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="itemConsumeCount" val="1" />
<set name="itemConsumeId" val="#itemConsumeId" />
<set name="magicLvl" val="1" />
<set name="operateType" val="ACTIVE_INSTANT" />
<set name="rideState" val="NONE;STRIDER;WYVERN;WOLF" />
<set name="simultaneousCast" val="true" />
<set name="targetType" val="SELF" />
<cond msgId="113" addName="1">
<and>

View File

@ -1572,8 +1572,11 @@
<set name="targetType" val="ONE" />
<set name="trait" val="DERANGEMENT" />
<for>
<effect name="RunAway">
<param power="40" />
<param time="20" />
</effect>
<effect name="Fear" />
<!-- FIXME: We need an instant effect that will work only vs monsters and fear them with 40% chance for 20 seconds here -->
</for>
</skill>
<skill id="5174" levels="15" name="Poison">

View File

@ -1258,7 +1258,7 @@
<skill id="5493" levels="1" name="Naia Production">
<set name="castRange" val="800" />
<set name="channelingSkillId" val="5106" />
<set name="channelingSkillId" val="5106" />
<set name="channelingTickInterval" val="2" />
<set name="effectPoint" val="1" />
<set name="effectRange" val="1000" />
<set name="hitTime" val="25000" />
@ -1271,6 +1271,9 @@
<set name="reuseDelay" val="1000" />
<set name="rideState" val="NONE;STRIDER;WYVERN;WOLF" />
<set name="targetType" val="ONE" />
<cond msgId="109">
<target npcId="32331" />
</cond>
</skill>
<skill id="5494" levels="1" name="Gust">
<!-- Confirmed CT2.5 -->

View File

@ -258,6 +258,7 @@
<xs:attribute type="xs:short" name="skillId1" use="optional" />
<xs:attribute type="xs:short" name="skillId2" use="optional" />
<xs:attribute type="xs:short" name="skillId3" use="optional" />
<xs:attribute type="xs:string" name="time" use="optional" />
<xs:attribute type="xs:string" name="KNOCKDOWN" use="optional" />
<xs:attribute type="xs:integer" name="speed" use="optional" />
<xs:attribute type="xs:integer" name="distance" use="optional" />

View File

@ -157,6 +157,7 @@ public final class EffectMasterHandler
Resurrection.class,
ResurrectionSpecial.class,
Root.class,
RunAway.class,
ServitorShare.class,
SetSkill.class,
ShilensBreath.class,

View File

@ -217,9 +217,8 @@ public class ClanBoard implements IWriteBoardHandler
}
i = 0;
int nbp;
nbp = ClanTable.getInstance().getClans().length / 8;
if ((nbp * 8) != ClanTable.getInstance().getClans().length)
int nbp = ClanTable.getInstance().getClanCount() / 8;
if ((nbp * 8) != ClanTable.getInstance().getClanCount())
{
nbp++;
}

View File

@ -86,9 +86,9 @@ public final class HomeBoard implements IParseBoardHandler
CommunityBoardHandler.getInstance().addBypass(activeChar, "Home", command);
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/" + customPath + "home.html");
html = html.replaceAll("%fav_count%", String.valueOf(getFavoriteCount(activeChar)));
html = html.replaceAll("%region_count%", String.valueOf(getRegionCount(activeChar)));
html = html.replaceAll("%clan_count%", String.valueOf(getClansCount()));
html = html.replaceAll("%fav_count%", Integer.toString(getFavoriteCount(activeChar)));
html = html.replaceAll("%region_count%", Integer.toString(getRegionCount(activeChar)));
html = html.replaceAll("%clan_count%", Integer.toString(ClanTable.getInstance().getClanCount()));
CommunityBoardHandler.separateAndSend(html, activeChar);
}
else if (command.startsWith("_bbstop;"))
@ -206,13 +206,4 @@ public final class HomeBoard implements IParseBoardHandler
{
return 0; // TODO: Implement.
}
/**
* Gets the clans count.
* @return the clans count
*/
private static int getClansCount()
{
return ClanTable.getInstance().getClans().length;
}
}

View File

@ -18,12 +18,8 @@
*/
package handlers.effecthandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.instance.L2DefenderInstance;
import com.l2jserver.gameserver.model.actor.instance.L2FortCommanderInstance;
@ -33,7 +29,6 @@ import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.effects.EffectFlag;
import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.util.Util;
/**
* Fear effect implementation.
@ -41,8 +36,6 @@ import com.l2jserver.gameserver.util.Util;
*/
public final class Fear extends AbstractEffect
{
public static final int FEAR_RANGE = 500;
public Fear(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
@ -77,7 +70,7 @@ public final class Fear extends AbstractEffect
@Override
public boolean onActionTime(BuffInfo info)
{
fearAction(info, false);
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID, info.getEffector(), false);
return false;
}
@ -89,34 +82,6 @@ public final class Fear extends AbstractEffect
info.getEffected().abortCast();
}
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID);
fearAction(info, true);
}
private void fearAction(BuffInfo info, boolean start)
{
double radians = Math.toRadians(start ? Util.calculateAngleFrom(info.getEffector(), info.getEffected()) : Util.convertHeadingToDegree(info.getEffected().getHeading()));
int posX = (int) (info.getEffected().getX() + (FEAR_RANGE * Math.cos(radians)));
int posY = (int) (info.getEffected().getY() + (FEAR_RANGE * Math.sin(radians)));
int posZ = info.getEffected().getZ();
if (!info.getEffected().isPet())
{
info.getEffected().setRunning();
}
// If pathfinding enabled the creature will go to the defined destination (retail like).
// Otherwise it will go to the nearest obstacle.
final Location destination;
if (Config.PATHFINDING > 0)
{
destination = new Location(posX, posY, posZ, info.getEffected().getInstanceId());
}
else
{
destination = GeoData.getInstance().moveCheck(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), posX, posY, posZ, info.getEffected().getInstanceId());
}
info.getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID, info.getEffector(), true);
}
}

View File

@ -47,7 +47,6 @@ public final class Grow extends AbstractEffect
if (info.getEffected().isNpc())
{
L2Npc npc = (L2Npc) info.getEffected();
npc.setCollisionHeight(npc.getTemplate().getCollisionHeight());
npc.setCollisionRadius(npc.getTemplate().getfCollisionRadius());
}
}
@ -58,7 +57,6 @@ public final class Grow extends AbstractEffect
if (info.getEffected().isNpc())
{
L2Npc npc = (L2Npc) info.getEffected();
npc.setCollisionHeight(npc.getTemplate().getCollisionHeightGrown());
npc.setCollisionRadius(npc.getTemplate().getCollisionRadiusGrown());
}
}

View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.effecthandlers;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.ai.L2AttackableAI;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.util.Rnd;
/**
* Run Away effect implementation.
* @author Zoey76
*/
public final class RunAway extends AbstractEffect
{
private final int _power;
private final int _time;
public RunAway(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
_power = params.getInt("power", 0);
_time = params.getInt("time", 0);
}
@Override
public boolean isInstant()
{
return true;
}
@Override
public void onStart(BuffInfo info)
{
if (!info.getEffected().isAttackable())
{
return;
}
if (Rnd.get(100) > _power)
{
return;
}
if (info.getEffected().isCastingNow() && info.getEffected().canAbortCast())
{
info.getEffected().abortCast();
}
((L2AttackableAI) info.getEffected().getAI()).setFearTime(_time);
info.getEffected().getAI().notifyEvent(CtrlEvent.EVT_AFRAID, info.getEffector(), true);
}
}

View File

@ -1335,13 +1335,13 @@
</effect>
<effect name="ConsumeBody" />
</enchant1for>
<enchant1for>
<enchant2for>
<effect name="Sweeper" />
<effect name="ManaHealByLevel">
<param power="#ench2DrainMp" />
</effect>
<effect name="ConsumeBody" />
</enchant1for>
</enchant2for>
</skill>
<skill id="44" levels="3" name="Remedy">
<table name="#dispelAbnormals"> BLEEDING,3 BLEEDING,7 BLEEDING,9 </table>

View File

@ -312,6 +312,7 @@
<table name="#magicLvl"> 55 58 60 62 64 66 68 70 72 74 </table>
<table name="#mpConsume"> 50 53 55 58 59 61 63 65 67 68 </table>
<table name="#ench1Cost"> 66 65 64 63 62 61 60 58 57 56 55 54 53 52 51 49 48 47 46 45 44 43 41 40 39 38 37 36 35 34 </table>
<table name="#ench2Power"> 30 31 32 32 33 34 34 35 36 36 37 38 38 39 40 40 41 42 42 43 44 44 45 46 46 47 48 48 49 50 </table>
<table name="#ench2LethalStrikeRate"> 25 25 25 26 26 26 26 27 27 27 27 28 28 28 29 29 29 29 30 30 30 30 31 31 31 31 32 32 32 33 </table>
<table name="#ench3Attack"> 191 196 201 206 211 216 221 227 232 237 242 247 252 257 263 268 273 278 283 288 293 298 304 309 314 319 324 329 334 340 </table>
<table name="#ench4HolyAttack"> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 </table>
@ -343,19 +344,28 @@
<target race="UNDEAD" />
</cond>
<for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</for>
<enchant2for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="#ench2Power" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="#ench2LethalStrikeRate" />
</effect>
</enchant2for>
<enchant3for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
@ -1763,6 +1773,7 @@
<table name="#magicLvl"> 55 58 60 62 64 66 68 70 72 74 </table>
<table name="#mpConsume"> 50 53 55 58 59 61 63 65 67 68 </table>
<table name="#ench1Cost"> 66 65 64 63 62 61 60 58 57 56 55 54 53 52 51 49 48 47 46 45 44 43 41 40 39 38 37 36 35 34 </table>
<table name="#ench2Power"> 30 31 32 32 33 34 34 35 36 36 37 38 38 39 40 40 41 42 42 43 44 44 45 46 46 47 48 48 49 50 </table>
<table name="#ench2LethalStrikeRate"> 25 25 25 26 26 26 26 27 27 27 27 28 28 28 29 29 29 29 30 30 30 30 31 31 31 31 32 32 32 33 </table>
<table name="#ench3Attack"> 191 196 201 206 211 216 221 227 232 237 242 247 252 257 263 268 273 278 283 288 293 298 304 309 314 319 324 329 334 340 </table>
<table name="#ench4DarkAttack"> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 </table>
@ -1794,19 +1805,28 @@
<target race="DIVINE" />
</cond>
<for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</for>
<enchant2for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="#ench2Power" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="#ench2LethalStrikeRate" />
</effect>
</enchant2for>
<enchant3for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>

View File

@ -7,6 +7,7 @@
<table name="#magicLvl"> 56 58 60 62 64 66 68 70 72 74 </table>
<table name="#mpConsume"> 41 43 44 46 48 49 51 52 53 55 </table>
<table name="#mpInitialConsume"> 11 11 11 12 12 13 13 13 14 14 </table>
<table name="#ench1Power"> 30 31 32 32 33 34 34 35 36 36 37 38 38 39 40 40 41 42 42 43 44 44 45 46 46 47 48 48 49 50 </table>
<table name="#ench1LethalStrikeRate"> 25 25 25 26 26 26 27 27 27 28 28 28 28 29 29 29 30 30 30 31 31 31 31 32 32 32 33 33 33 34 </table>
<table name="#ench2mpConsume"> 53 52 51 50 49 48 48 47 46 45 44 43 42 41 40 39 38 38 37 36 35 34 33 32 31 30 29 29 28 27 </table>
<table name="#ench2mpInitialConsume"> 13 13 12 12 12 12 12 11 11 11 11 10 10 10 10 9 9 9 9 9 8 8 8 8 7 7 7 7 7 6 </table>
@ -42,25 +43,37 @@
<target race="UNDEAD" />
</cond>
<for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</for>
<enchant1for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="#ench1Power" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="#ench1LethalStrikeRate" />
</effect>
</enchant1for>
<enchant2for>
<effect name="Fear" abnormalTime="#ench2Time" />
<effect name="RunAway">
<param power="#ench1Power" />
<param time="#ench2Time" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
</enchant2for>
<enchant3for>
<effect name="Fear" abnormalTime="20" />
<effect name="RunAway">
<param power="30" />
<param time="20" />
</effect>
<effect name="Lethal">
<param fullLethal="25" />
</effect>
@ -267,7 +280,7 @@
<enchant1 name="mpConsume" val="116" />
<enchant1 name="mpInitialConsume" val="29" />
<cond>
<and>
<and>
<player canSummonServitor="true" />
<player hasFreeSummonPoints="4" />
</and>
@ -309,7 +322,7 @@
<enchant1 name="mpConsume" val="116" />
<enchant1 name="mpInitialConsume" val="29" />
<cond>
<and>
<and>
<player canSummonServitor="true" />
<player hasFreeSummonPoints="4" />
</and>
@ -353,7 +366,7 @@
<enchant1 name="mpConsume" val="116" />
<enchant1 name="mpInitialConsume" val="29" />
<cond>
<and>
<and>
<player canSummonServitor="true" />
<player hasFreeSummonPoints="4" />
</and>

View File

@ -1521,8 +1521,11 @@
<set name="targetType" val="ONE" />
<set name="trait" val="DERANGEMENT" />
<for>
<effect name="RunAway">
<param power="40" />
<param time="20" />
</effect>
<effect name="Fear" />
<!-- FIXME: We need an instant effect that will work only vs monsters and fear them with 40% chance for 20 seconds here -->
</for>
</skill>
<skill id="5174" levels="15" name="Poison">

View File

@ -258,6 +258,7 @@
<xs:attribute type="xs:short" name="skillId1" use="optional" />
<xs:attribute type="xs:short" name="skillId2" use="optional" />
<xs:attribute type="xs:short" name="skillId3" use="optional" />
<xs:attribute type="xs:string" name="time" use="optional" />
<xs:attribute type="xs:string" name="KNOCKDOWN" use="optional" />
<xs:attribute type="xs:integer" name="speed" use="optional" />
<xs:attribute type="xs:integer" name="distance" use="optional" />

View File

@ -328,11 +328,9 @@ public abstract class AbstractAI implements Ctrl
/**
* Launch the L2CharacterAI onEvt method corresponding to the Event. <FONT COLOR=#FF0000><B> <U>Caution</U> : The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned period)</B></FONT>
* @param evt The event whose the AI must be notified
* @param arg0 The first parameter of the Event (optional target)
* @param arg1 The second parameter of the Event (optional target)
*/
@Override
public final void notifyEvent(CtrlEvent evt, Object arg0, Object arg1)
public final void notifyEvent(CtrlEvent evt, Object... args)
{
if ((!_actor.isVisible() && !_actor.isTeleporting()) || !_actor.hasAI())
{
@ -345,31 +343,31 @@ public abstract class AbstractAI implements Ctrl
onEvtThink();
break;
case EVT_ATTACKED:
onEvtAttacked((L2Character) arg0);
onEvtAttacked((L2Character) args[0]);
break;
case EVT_AGGRESSION:
onEvtAggression((L2Character) arg0, ((Number) arg1).intValue());
onEvtAggression((L2Character) args[0], ((Number) args[1]).intValue());
break;
case EVT_STUNNED:
onEvtStunned((L2Character) arg0);
onEvtStunned((L2Character) args[0]);
break;
case EVT_PARALYZED:
onEvtParalyzed((L2Character) arg0);
onEvtParalyzed((L2Character) args[0]);
break;
case EVT_SLEEPING:
onEvtSleeping((L2Character) arg0);
onEvtSleeping((L2Character) args[0]);
break;
case EVT_ROOTED:
onEvtRooted((L2Character) arg0);
onEvtRooted((L2Character) args[0]);
break;
case EVT_CONFUSED:
onEvtConfused((L2Character) arg0);
onEvtConfused((L2Character) args[0]);
break;
case EVT_MUTED:
onEvtMuted((L2Character) arg0);
onEvtMuted((L2Character) args[0]);
break;
case EVT_EVADED:
onEvtEvaded((L2Character) arg0);
onEvtEvaded((L2Character) args[0]);
break;
case EVT_READY_TO_ACT:
if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow())
@ -378,7 +376,7 @@ public abstract class AbstractAI implements Ctrl
}
break;
case EVT_USER_CMD:
onEvtUserCmd(arg0, arg1);
onEvtUserCmd(args[0], args[1]);
break;
case EVT_ARRIVED:
// happens e.g. from stopmove but we don't process it if we're casting
@ -395,10 +393,10 @@ public abstract class AbstractAI implements Ctrl
}
break;
case EVT_ARRIVED_BLOCKED:
onEvtArrivedBlocked((Location) arg0);
onEvtArrivedBlocked((Location) args[0]);
break;
case EVT_FORGET_OBJECT:
onEvtForgetObject((L2Object) arg0);
onEvtForgetObject((L2Object) args[0]);
break;
case EVT_CANCEL:
onEvtCancel();
@ -412,6 +410,11 @@ public abstract class AbstractAI implements Ctrl
case EVT_FINISH_CASTING:
onEvtFinishCasting();
break;
case EVT_AFRAID:
{
onEvtAfraid((L2Character) args[0], (Boolean) args[1]);
break;
}
}
// Do next action.
@ -479,6 +482,8 @@ public abstract class AbstractAI implements Ctrl
protected abstract void onEvtFinishCasting();
protected abstract void onEvtAfraid(L2Character effector, boolean start);
/**
* Cancel action client side by sending Server->Client packet ActionFailed to the L2PcInstance actor. <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
*/

View File

@ -100,8 +100,7 @@ public interface Ctrl
/**
* Notify an event.
* @param evt the event
* @param arg0 the arg0
* @param arg1 the arg1
* @param args the args
*/
void notifyEvent(CtrlEvent evt, Object arg0, Object arg1);
void notifyEvent(CtrlEvent evt, Object... args);
}

View File

@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GameTimeController;
@ -56,6 +57,7 @@ import com.l2jserver.gameserver.model.events.EventDispatcher;
import com.l2jserver.gameserver.model.events.impl.character.npc.attackable.OnAttackableFactionCall;
import com.l2jserver.gameserver.model.events.impl.character.npc.attackable.OnAttackableHate;
import com.l2jserver.gameserver.model.events.returns.TerminateReturn;
import com.l2jserver.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
import com.l2jserver.gameserver.model.zone.ZoneId;
@ -67,30 +69,53 @@ import com.l2jserver.util.Rnd;
*/
public class L2AttackableAI extends L2CharacterAI implements Runnable
{
/**
* Fear task.
* @author Zoey76
*/
public static class FearTask implements Runnable
{
private final L2Character _effected;
private final L2Character _effector;
private boolean _start;
public FearTask(L2Character effected, L2Character effector, boolean start)
{
_effected = effected;
_effector = effector;
_start = start;
}
@Override
public void run()
{
final int fearTimeLeft = ((L2AttackableAI) _effected.getAI()).getFearTime() - FEAR_TICKS;
((L2AttackableAI) _effected.getAI()).setFearTime(fearTimeLeft);
_effected.getAI().onEvtAfraid(_effector, _start);
_start = false;
}
}
protected static final int FEAR_TICKS = 5;
private static final int RANDOM_WALK_RATE = 30; // confirmed
// private static final int MAX_DRIFT_RANGE = 300;
private static final int MAX_ATTACK_TIMEOUT = 1200; // int ticks, i.e. 2min
/**
* The L2Attackable AI task executed every 1s (call onEvtThink method).
*/
/** The L2Attackable AI task executed every 1s (call onEvtThink method). */
private Future<?> _aiTask;
/**
* The delay after which the attacked is stopped.
*/
/** The delay after which the attacked is stopped. */
private int _attackTimeout;
/**
* The L2Attackable aggro counter.
*/
/** The L2Attackable aggro counter. */
private int _globalAggro;
/**
* The flag used to indicate that a thinking action is in progress, to prevent recursive thinking.
*/
/** The flag used to indicate that a thinking action is in progress, to prevent recursive thinking. */
private boolean _thinking;
private int timepass = 0;
private int chaostime = 0;
private int _timePass = 0;
private int _chaosTime = 0;
private final L2NpcTemplate _skillrender;
int lastBuffTick;
private int _lastBuffTick;
// Fear parameters
private int _fearTime;
private Future<?> _fearTask = null;
/**
* Constructor of L2AttackableAI.
@ -376,7 +401,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
// self and buffs
if ((lastBuffTick + 30) < GameTimeController.getInstance().getGameTicks())
if ((_lastBuffTick + 30) < GameTimeController.getInstance().getGameTicks())
{
for (Skill sk : _skillrender.getAISkills(AISkillScope.BUFF))
{
@ -385,13 +410,35 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
break;
}
}
lastBuffTick = GameTimeController.getInstance().getGameTicks();
_lastBuffTick = GameTimeController.getInstance().getGameTicks();
}
// Manage the Attack Intention : Stop current Attack (if necessary), Start a new Attack and Launch Think Event
super.onIntentionAttack(target);
}
@Override
protected void onEvtAfraid(L2Character effector, boolean start)
{
if ((_fearTime > 0) && (_fearTask == null))
{
_fearTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new FearTask(_actor, effector, start), 0, FEAR_TICKS, TimeUnit.SECONDS);
_actor.startAbnormalVisualEffect(AbnormalVisualEffect.TURN_FLEE);
}
else
{
super.onEvtAfraid(effector, start);
if ((_fearTime <= 0) && (_fearTask != null))
{
_fearTask.cancel(true);
_fearTask = null;
_actor.stopAbnormalVisualEffect(AbnormalVisualEffect.TURN_FLEE);
setIntention(CtrlIntention.AI_INTENTION_IDLE);
}
}
}
protected void thinkCast()
{
if (checkTargetLost(getCastTarget()))
@ -898,29 +945,29 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
// BOSS/Raid Minion Target Reconsider
if (npc.isRaid() || npc.isRaidMinion())
{
chaostime++;
_chaosTime++;
if (npc instanceof L2RaidBossInstance)
{
if (!((L2MonsterInstance) npc).hasMinions())
{
if (chaostime > Config.RAID_CHAOS_TIME)
if (_chaosTime > Config.RAID_CHAOS_TIME)
{
if (Rnd.get(100) <= (100 - ((npc.getCurrentHp() * 100) / npc.getMaxHp())))
{
aggroReconsider();
chaostime = 0;
_chaosTime = 0;
return;
}
}
}
else
{
if (chaostime > Config.RAID_CHAOS_TIME)
if (_chaosTime > Config.RAID_CHAOS_TIME)
{
if (Rnd.get(100) <= (100 - ((npc.getCurrentHp() * 200) / npc.getMaxHp())))
{
aggroReconsider();
chaostime = 0;
_chaosTime = 0;
return;
}
}
@ -928,25 +975,25 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
}
else if (npc instanceof L2GrandBossInstance)
{
if (chaostime > Config.GRAND_CHAOS_TIME)
if (_chaosTime > Config.GRAND_CHAOS_TIME)
{
double chaosRate = 100 - ((npc.getCurrentHp() * 300) / npc.getMaxHp());
if (((chaosRate <= 10) && (Rnd.get(100) <= 10)) || ((chaosRate > 10) && (Rnd.get(100) <= chaosRate)))
{
aggroReconsider();
chaostime = 0;
_chaosTime = 0;
return;
}
}
}
else
{
if (chaostime > Config.MINION_CHAOS_TIME)
if (_chaosTime > Config.MINION_CHAOS_TIME)
{
if (Rnd.get(100) <= (100 - ((npc.getCurrentHp() * 200) / npc.getMaxHp())))
{
aggroReconsider();
chaostime = 0;
_chaosTime = 0;
return;
}
}
@ -2692,7 +2739,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
*/
public void setTimepass(int TP)
{
timepass = TP;
_timePass = TP;
}
/**
@ -2700,11 +2747,21 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
*/
public int getTimepass()
{
return timepass;
return _timePass;
}
public L2Attackable getActiveChar()
{
return (L2Attackable) _actor;
}
public int getFearTime()
{
return _fearTime;
}
public void setFearTime(int fearTime)
{
_fearTime = fearTime;
}
}

View File

@ -31,6 +31,7 @@ import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_REST;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.ThreadPoolManager;
@ -58,6 +59,7 @@ import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.AutoAttackStop;
import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.Rnd;
/**
@ -90,6 +92,8 @@ public class L2CharacterAI extends AbstractAI
}
}
protected static final int FEAR_RANGE = 500;
/**
* Cast Task
* @author Zoey76
@ -276,7 +280,7 @@ public class L2CharacterAI extends AbstractAI
stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);
notifyEvent(CtrlEvent.EVT_THINK);
}
else
@ -295,7 +299,7 @@ public class L2CharacterAI extends AbstractAI
stopFollow();
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);
notifyEvent(CtrlEvent.EVT_THINK);
}
}
@ -341,7 +345,7 @@ public class L2CharacterAI extends AbstractAI
changeIntention(AI_INTENTION_CAST, skill, target);
// Launch the Think Event
notifyEvent(CtrlEvent.EVT_THINK, null);
notifyEvent(CtrlEvent.EVT_THINK);
}
/**
@ -955,6 +959,34 @@ public class L2CharacterAI extends AbstractAI
// do nothing
}
@Override
protected void onEvtAfraid(L2Character effector, boolean start)
{
double radians = Math.toRadians(start ? Util.calculateAngleFrom(effector, _actor) : Util.convertHeadingToDegree(_actor.getHeading()));
int posX = (int) (_actor.getX() + (FEAR_RANGE * Math.cos(radians)));
int posY = (int) (_actor.getY() + (FEAR_RANGE * Math.sin(radians)));
int posZ = _actor.getZ();
if (!_actor.isPet())
{
_actor.setRunning();
}
// If pathfinding enabled the creature will go to the defined destination (retail like).
// Otherwise it will go to the nearest obstacle.
final Location destination;
if (Config.PATHFINDING > 0)
{
destination = new Location(posX, posY, posZ, _actor.getInstanceId());
}
else
{
destination = GeoData.getInstance().moveCheck(_actor.getX(), _actor.getY(), _actor.getZ(), posX, posY, posZ, _actor.getInstanceId());
}
setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
}
protected boolean maybeMoveToPosition(ILocational worldPosition, int offset)
{
if (worldPosition == null)

View File

@ -286,7 +286,7 @@ public class TopicBBSManager extends BaseBBSManager
int nbp;
nbp = forum.getTopicSize() / 8;
if ((nbp * 8) != ClanTable.getInstance().getClans().length)
if ((nbp * 8) != ClanTable.getInstance().getClanCount())
{
nbp++;
}

View File

@ -23,9 +23,10 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -68,13 +69,7 @@ import com.l2jserver.util.EnumIntBitmask;
public class ClanTable
{
private static final Logger _log = Logger.getLogger(ClanTable.class.getName());
private final Map<Integer, L2Clan> _clans = new HashMap<>();
public L2Clan[] getClans()
{
return _clans.values().toArray(new L2Clan[_clans.size()]);
}
private final Map<Integer, L2Clan> _clans = new ConcurrentHashMap<>();
protected ClanTable()
{
@ -112,6 +107,24 @@ public class ClanTable
restorewars();
}
/**
* Gets the clans.
* @return the clans
*/
public Collection<L2Clan> getClans()
{
return _clans.values();
}
/**
* Gets the clan count.
* @return the clan count
*/
public int getClanCount()
{
return _clans.size();
}
/**
* @param clanId
* @return
@ -123,15 +136,7 @@ public class ClanTable
public L2Clan getClanByName(String clanName)
{
for (L2Clan clan : getClans())
{
if (clan.getName().equalsIgnoreCase(clanName))
{
return clan;
}
}
return null;
return getClans().stream().filter(c -> c.getName().equalsIgnoreCase(clanName)).findFirst().orElse(null);
}
/**

View File

@ -268,7 +268,7 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM clan_subpledges WHERE clan_subpledges.clan_id NOT IN (SELECT clan_id FROM clan_data);");
cleanCount += stmt.executeUpdate("DELETE FROM clan_wars WHERE clan_wars.clan1 NOT IN (SELECT clan_id FROM clan_data);");
cleanCount += stmt.executeUpdate("DELETE FROM clan_wars WHERE clan_wars.clan2 NOT IN (SELECT clan_id FROM clan_data);");
cleanCount += stmt.executeUpdate("DELETE FROM clanhall_functions WHERE clanhall_functions.hall_id NOT IN (SELECT id FROM clanhall WHERE ownerId <> 0);");
cleanCount += stmt.executeUpdate("DELETE FROM clanhall_functions WHERE clanhall_functions.hall_id NOT IN (SELECT id FROM clanhall WHERE ownerId <> 0 union all SELECT clanHallId FROM siegable_clanhall WHERE ownerId <> 0);");
cleanCount += stmt.executeUpdate("DELETE FROM siege_clans WHERE siege_clans.clan_id NOT IN (SELECT clan_id FROM clan_data);");
cleanCount += stmt.executeUpdate("DELETE FROM clan_notices WHERE clan_notices.clan_id NOT IN (SELECT clan_id FROM clan_data);");
cleanCount += stmt.executeUpdate("DELETE FROM auction_bid WHERE auction_bid.bidderId NOT IN (SELECT clan_id FROM clan_data);");

View File

@ -157,7 +157,12 @@ public final class AntiFeedManager
final AtomicInteger connectionCount = event.computeIfAbsent(addrHash, k -> new AtomicInteger());
return connectionCount.getAndIncrement() < (max + Config.L2JMOD_DUALBOX_CHECK_WHITELIST.getOrDefault(addrHash, 0));
if ((connectionCount.get() + 1) <= (max + Config.L2JMOD_DUALBOX_CHECK_WHITELIST.getOrDefault(addrHash, 0)))
{
connectionCount.incrementAndGet();
return true;
}
return false;
}
/**

View File

@ -336,9 +336,9 @@ public class CursedWeapon implements INamable
// Void Burst, Void Flow
_player.addSkill(CommonSkill.VOID_BURST.getSkill(), false);
_player.addTransformSkill(CommonSkill.VOID_BURST.getId());
_player.addTransformSkill(CommonSkill.VOID_BURST.getSkill());
_player.addSkill(CommonSkill.VOID_FLOW.getSkill(), false);
_player.addTransformSkill(CommonSkill.VOID_FLOW.getId());
_player.addTransformSkill(CommonSkill.VOID_FLOW.getSkill());
_player.sendSkillList();
}

View File

@ -6071,14 +6071,18 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
}
// Notify AI
if (skill.isBad() && !skill.hasEffectType(L2EffectType.HATE))
if (skill.isBad() && (skill.getTargetType() != L2TargetType.SELF) && !skill.hasEffectType(L2EffectType.HATE))
{
for (L2Object target : targets)
{
if ((target instanceof L2Character) && ((L2Character) target).hasAI())
if (target instanceof L2Character)
{
// notify target AI about the attack
((L2Character) target).getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, this);
final L2Character creature = (L2Character) target;
if (creature.hasAI())
{
// notify target AI about the attack
creature.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, this);
}
}
}
}

View File

@ -29,7 +29,6 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@ -37,6 +36,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentSkipListMap;
@ -215,6 +215,7 @@ import com.l2jserver.gameserver.model.events.impl.character.player.mentoring.OnP
import com.l2jserver.gameserver.model.events.impl.character.player.mentoring.OnPlayerMentorStatus;
import com.l2jserver.gameserver.model.fishing.L2Fish;
import com.l2jserver.gameserver.model.fishing.L2Fishing;
import com.l2jserver.gameserver.model.holders.AdditionalSkillHolder;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.gameserver.model.holders.PlayerEventHolder;
import com.l2jserver.gameserver.model.holders.SkillHolder;
@ -521,6 +522,7 @@ public final class L2PcInstance extends L2Playable
private long _offlineShopStart = 0;
private Transform _transformation;
private volatile Map<Integer, Skill> _transformSkills;
/** The table containing all L2RecipeList of the L2PcInstance */
private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new ConcurrentHashMap<>();
@ -754,7 +756,6 @@ public final class L2PcInstance extends L2Playable
private int _fishz = 0;
private final static SkillHolder FISHING_SKILL = new SkillHolder(1312, 1);
private volatile Set<Integer> _transformAllowedSkills;
private ScheduledFuture<?> _taskRentPet;
private ScheduledFuture<?> _taskWater;
@ -7727,7 +7728,7 @@ public final class L2PcInstance extends L2Playable
final TimeStamp t = getSkillReuseTimeStamp(skill.getReuseHashCode());
statement.setLong(5, (t != null) && t.hasNotPassed() ? t.getReuse() : 0);
statement.setDouble(6, (t != null) && t.hasNotPassed() ? t.getStamp() : 0);
statement.setLong(6, (t != null) && t.hasNotPassed() ? t.getStamp() : 0);
statement.setInt(7, 0); // Store type 0, active buffs/debuffs.
statement.setInt(8, getClassIndex());
@ -7758,7 +7759,7 @@ public final class L2PcInstance extends L2Playable
statement.setInt(3, t.getSkillLvl());
statement.setInt(4, -1);
statement.setLong(5, t.getReuse());
statement.setDouble(6, t.getStamp());
statement.setLong(6, t.getStamp());
statement.setInt(7, 1); // Restore type 1, skill reuse.
statement.setInt(8, getClassIndex());
statement.setInt(9, ++buff_index);
@ -7793,7 +7794,7 @@ public final class L2PcInstance extends L2Playable
ps2.setInt(2, ts.getItemId());
ps2.setInt(3, ts.getItemObjectId());
ps2.setLong(4, ts.getReuse());
ps2.setDouble(5, ts.getStamp());
ps2.setLong(5, ts.getStamp());
ps2.execute();
}
}
@ -10228,7 +10229,7 @@ public final class L2PcInstance extends L2Playable
continue;
}
if ((_transformation != null) && (!hasTransformSkill(s.getId()) && !s.allowOnTransform()))
if ((_transformation != null) && !s.isPassive())
{
continue;
}
@ -10258,7 +10259,48 @@ public final class L2PcInstance extends L2Playable
sl.addSkill(s.getDisplayId(), s.getDisplayLevel(), s.isPassive(), isDisabled, isEnchantable);
}
if (_transformation != null)
{
Map<Integer, Integer> ts = new TreeMap<>();
for (SkillHolder holder : _transformation.getTemplate(this).getSkills())
{
ts.putIfAbsent(holder.getSkillId(), holder.getSkillLvl());
if (ts.get(holder.getSkillId()) < holder.getSkillLvl())
{
ts.put(holder.getSkillId(), holder.getSkillLvl());
}
addTransformSkill(holder.getSkill());
}
for (AdditionalSkillHolder holder : _transformation.getTemplate(this).getAdditionalSkills())
{
if (getLevel() >= holder.getMinLevel())
{
ts.putIfAbsent(holder.getSkillId(), holder.getSkillLvl());
if (ts.get(holder.getSkillId()) < holder.getSkillLvl())
{
ts.put(holder.getSkillId(), holder.getSkillLvl());
}
addTransformSkill(holder.getSkill());
}
}
// Add collection skills.
for (L2SkillLearn skill : SkillTreesData.getInstance().getCollectSkillTree().values())
{
if (getKnownSkill(skill.getSkillId()) != null)
{
addTransformSkill(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel()));
}
}
for (Entry<Integer, Integer> transformSkill : ts.entrySet())
{
sl.addSkill(transformSkill.getKey(), transformSkill.getValue(), false, false, false);
}
}
sendPacket(sl);
}
@ -12857,29 +12899,34 @@ public final class L2PcInstance extends L2Playable
}
}
public void addTransformSkill(int id)
public void addTransformSkill(Skill sk)
{
if (_transformAllowedSkills == null)
if (_transformSkills == null)
{
synchronized (this)
{
if (_transformAllowedSkills == null)
if (_transformSkills == null)
{
_transformAllowedSkills = new HashSet<>();
_transformSkills = new HashMap<>();
}
}
}
_transformAllowedSkills.add(id);
_transformSkills.put(sk.getId(), sk);
}
public Skill getTransformSkill(int id)
{
return _transformSkills.get(id);
}
public boolean hasTransformSkill(int id)
{
return (_transformAllowedSkills != null) && _transformAllowedSkills.contains(id);
return _transformSkills.containsKey(id);
}
public synchronized void removeAllTransformSkills()
{
_transformAllowedSkills = null;
_transformSkills = null;
}
protected void startFeed(int npcId)

View File

@ -293,7 +293,7 @@ public class PcStatus extends PlayableStatus
setCurrentHp(value);
}
if (getActiveChar().getCurrentHp() < 0.5)
if ((getActiveChar().getCurrentHp() < 0.5) && !isHPConsumption)
{
getActiveChar().abortAttack();
getActiveChar().abortCast();

View File

@ -41,7 +41,7 @@ public final class NotifyAITask implements Runnable
{
if (_character != null)
{
_character.getAI().notifyEvent(_event, null);
_character.getAI().notifyEvent(_event);
}
}
}

View File

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
import com.l2jserver.gameserver.model.L2SkillLearn;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.AdditionalItemHolder;
@ -224,38 +223,6 @@ public final class Transform implements IIdentifiable
player.getAppearance().setVisibleTitle(getTitle());
}
// Add common skills.
for (SkillHolder holder : template.getSkills())
{
if (player.getSkillLevel(holder.getSkillId()) < holder.getSkillLvl())
{
player.addSkill(holder.getSkill(), false);
}
player.addTransformSkill(holder.getSkillId());
}
// Add skills depending on level.
for (AdditionalSkillHolder holder : template.getAdditionalSkills())
{
if (player.getLevel() >= holder.getMinLevel())
{
if (player.getSkillLevel(holder.getSkillId()) < holder.getSkillLvl())
{
player.addSkill(holder.getSkill(), false);
}
player.addTransformSkill(holder.getSkillId());
}
}
// Add collection skills.
for (L2SkillLearn skill : SkillTreesData.getInstance().getCollectSkillTree().values())
{
if (player.getKnownSkill(skill.getSkillId()) != null)
{
player.addTransformSkill(skill.getSkillId());
}
}
// Set inventory blocks if needed.
if (!template.getAdditionalItems().isEmpty())
{
@ -376,7 +343,7 @@ public final class Transform implements IIdentifiable
if (player.getSkillLevel(holder.getSkillId()) < holder.getSkillLvl())
{
player.addSkill(holder.getSkill(), false);
player.addTransformSkill(holder.getSkillId());
player.addTransformSkill(holder.getSkill());
}
}
}

View File

@ -40,6 +40,7 @@ import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.ItemContainer;
import com.l2jserver.gameserver.network.SystemMessageId;
public class Auction
@ -288,23 +289,37 @@ public class Auction
}
/**
* Return Item in WHC
* @param Clan
* @param quantity
* @param penalty
* Returns the item to the clan warehouse.
* @param clanName the clan name
* @param quantity the Adena value
* @param penalty if {@code true} fees are applied
*/
private void returnItem(String Clan, long quantity, boolean penalty)
private void returnItem(String clanName, long quantity, boolean penalty)
{
if (penalty)
{
quantity *= 0.9; // take 10% tax fee if needed
}
final L2Clan clan = ClanTable.getInstance().getClanByName(clanName);
if (clan == null)
{
_log.warning("Clan " + clanName + " doesn't exist!");
return;
}
final ItemContainer cwh = clan.getWarehouse();
if (cwh == null)
{
_log.warning("There has been a problem with " + clanName + "'s clan warehouse!");
return;
}
// avoid overflow on return
final long limit = MAX_ADENA - ClanTable.getInstance().getClanByName(Clan).getWarehouse().getAdena();
final long limit = MAX_ADENA - cwh.getAdena();
quantity = Math.min(quantity, limit);
ClanTable.getInstance().getClanByName(Clan).getWarehouse().addItem("Outbidded", ADENA_ID, quantity, null, null);
cwh.addItem("Outbidded", ADENA_ID, quantity, null, null);
}
/**

View File

@ -92,6 +92,12 @@ public final class SiegableHall extends ClanHall
{
_nextSiege.setTimeInMillis(nextSiege);
}
if (getOwnerId() != 0)
{
_isFree = false;
loadFunctions();
}
}
public void spawnDoor()

View File

@ -459,11 +459,6 @@ public final class Skill implements IIdentifiable
return _isSuicideAttack;
}
public boolean allowOnTransform()
{
return isPassive();
}
/**
* Return the power of the skill.
* @param activeChar

View File

@ -21,7 +21,6 @@ package com.l2jserver.gameserver.model.skills;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.gameserver.GeoData;
@ -74,7 +73,7 @@ public class SkillChannelizer implements Runnable
// Verify for same status.
if (isChanneling())
{
_log.log(Level.WARNING, "Character: " + toString() + " is attempting to channel skill but he already does!");
_log.warning("Character: " + _channelizer + " is attempting to channel skill but he already does!");
return;
}
@ -88,7 +87,7 @@ public class SkillChannelizer implements Runnable
// Verify for same status.
if (!isChanneling())
{
_log.log(Level.WARNING, "Character: " + toString() + " is attempting to stop channel skill but he does not!");
_log.warning("Character: " + _channelizer + " is attempting to stop channel skill but he does not!");
return;
}
@ -153,7 +152,7 @@ public class SkillChannelizer implements Runnable
final Skill baseSkill = SkillData.getInstance().getSkill(_skill.getChannelingSkillId(), 1);
if (baseSkill == null)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": skill " + _skill + " couldn't find effect id skill: " + _skill.getChannelingSkillId() + " !");
_log.warning(getClass().getSimpleName() + ": skill " + _skill + " couldn't find effect id skill: " + _skill.getChannelingSkillId() + " !");
_channelizer.abortCast();
return;
}
@ -196,7 +195,7 @@ public class SkillChannelizer implements Runnable
final Skill skill = SkillData.getInstance().getSkill(_skill.getChannelingSkillId(), skillLevel);
if (skill == null)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Non existent channeling skill requested: " + _skill);
_log.warning(getClass().getSimpleName() + ": Non existent channeling skill requested: " + _skill);
_channelizer.abortCast();
return;
}
@ -229,7 +228,7 @@ public class SkillChannelizer implements Runnable
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error while channelizing skill: " + _skill + " channelizer: " + _channelizer + " channelized: " + _channelized, e);
_log.warning("Error while channelizing skill: " + _skill + " channelizer: " + _channelizer + " channelized: " + _channelized + "; " + e.getMessage());
}
}
}

View File

@ -70,9 +70,13 @@ public final class RequestMagicSkillUse extends L2GameClientPacket
}
else
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
_log.warning("Skill Id " + _magicId + " not found in player!");
return;
skill = activeChar.getTransformSkill(_magicId);
if (skill == null)
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
_log.warning("Skill Id " + _magicId + " not found in player : " + activeChar);
return;
}
}
}
}

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.network.clientpackets;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import com.l2jserver.Config;
@ -59,8 +60,8 @@ public final class UseItem extends L2GameClientPacket
/** Weapon Equip Task */
private static class WeaponEquipTask implements Runnable
{
L2ItemInstance item;
L2PcInstance activeChar;
private final L2ItemInstance item;
private final L2PcInstance activeChar;
protected WeaponEquipTask(L2ItemInstance it, L2PcInstance character)
{
@ -71,12 +72,6 @@ public final class UseItem extends L2GameClientPacket
@Override
public void run()
{
// If character is still engaged in strike we should not change weapon
if (activeChar.isAttackingNow())
{
return;
}
// Equip or unEquip
activeChar.useEquippableItem(item, false);
}
@ -139,8 +134,10 @@ public final class UseItem extends L2GameClientPacket
return;
}
_itemId = item.getId();
// Char cannot use item when dead
if (activeChar.isDead() || !activeChar.getInventory().canManipulateWithItemId(item.getId()))
if (activeChar.isDead() || !activeChar.getInventory().canManipulateWithItemId(_itemId))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS);
sm.addItemName(item);
@ -153,7 +150,6 @@ public final class UseItem extends L2GameClientPacket
return;
}
_itemId = item.getId();
if (activeChar.isFishing() && ((_itemId < 6535) || (_itemId > 6540)))
{
// You cannot do anything else while fishing
@ -352,7 +348,7 @@ public final class UseItem extends L2GameClientPacket
}
else if (activeChar.isAttackingNow())
{
ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), activeChar.getAttackEndTime() - System.currentTimeMillis());
ThreadPoolManager.getInstance().scheduleGeneral(new WeaponEquipTask(item, activeChar), TimeUnit.MILLISECONDS.convert(activeChar.getAttackEndTime() - System.nanoTime(), TimeUnit.NANOSECONDS));
}
else
{

View File

@ -45,62 +45,71 @@ public final class RequestAnswerFriendInvite extends L2GameClientPacket
@Override
protected void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player != null)
final L2PcInstance player = getActiveChar();
if (player == null)
{
L2PcInstance requestor = player.getActiveRequester();
if (requestor == null)
{
return;
}
if (_response == 1)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId) VALUES (?, ?), (?, ?)"))
{
statement.setInt(1, requestor.getObjectId());
statement.setInt(2, player.getObjectId());
statement.setInt(3, player.getObjectId());
statement.setInt(4, requestor.getObjectId());
statement.execute();
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.THAT_PERSON_HAS_BEEN_SUCCESSFULLY_ADDED_TO_YOUR_FRIEND_LIST);
requestor.sendPacket(msg);
// Player added to your friend list
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED_TO_YOUR_FRIENDS_LIST);
msg.addString(player.getName());
requestor.sendPacket(msg);
requestor.addFriend(player);
// has joined as friend.
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_JOINED_AS_A_FRIEND);
msg.addString(requestor.getName());
player.sendPacket(msg);
player.addFriend(requestor);
// Send notifications for both player in order to show them online
player.sendPacket(new FriendAddRequestResult(requestor, 1));
requestor.sendPacket(new FriendAddRequestResult(player, 1));
player.sendPacket(new FriendList(player));
requestor.sendPacket(new FriendList(requestor));
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not add friend objectid: " + e.getMessage(), e);
}
}
else
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_FAILED_TO_ADD_A_FRIEND_TO_YOUR_FRIENDS_LIST);
requestor.sendPacket(msg);
player.sendPacket(new FriendAddRequestResult(requestor, 0));
requestor.sendPacket(new FriendAddRequestResult(player, 0));
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
return;
}
final L2PcInstance requestor = player.getActiveRequester();
if (requestor == null)
{
return;
}
if (player.getFriendList().containsValue(requestor.getObjectId()) //
|| requestor.getFriendList().containsValue(player.getObjectId()))
{
requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_PLAYER_IS_ALREADY_REGISTERED_ON_YOUR_FRIENDS_LIST));
return;
}
if (_response == 1)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId) VALUES (?, ?), (?, ?)"))
{
statement.setInt(1, requestor.getObjectId());
statement.setInt(2, player.getObjectId());
statement.setInt(3, player.getObjectId());
statement.setInt(4, requestor.getObjectId());
statement.execute();
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.THAT_PERSON_HAS_BEEN_SUCCESSFULLY_ADDED_TO_YOUR_FRIEND_LIST);
requestor.sendPacket(msg);
// Player added to your friend list
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ADDED_TO_YOUR_FRIENDS_LIST);
msg.addString(player.getName());
requestor.sendPacket(msg);
requestor.addFriend(player);
// has joined as friend.
msg = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_JOINED_AS_A_FRIEND);
msg.addString(requestor.getName());
player.sendPacket(msg);
player.addFriend(requestor);
// Send notifications for both player in order to show them online
player.sendPacket(new FriendAddRequestResult(requestor, 1));
requestor.sendPacket(new FriendAddRequestResult(player, 1));
player.sendPacket(new FriendList(player));
requestor.sendPacket(new FriendList(requestor));
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not add friend objectid: " + e.getMessage(), e);
}
}
else
{
SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_FAILED_TO_ADD_A_FRIEND_TO_YOUR_FRIENDS_LIST);
requestor.sendPacket(msg);
player.sendPacket(new FriendAddRequestResult(requestor, 0));
requestor.sendPacket(new FriendAddRequestResult(player, 0));
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
}
@Override