Talking Island double walkers.

Contributed by Liamxroy.
This commit is contained in:
MobiusDev
2017-11-05 20:42:54 +00:00
parent 2ffde9c10a
commit 1ac94c03c9
30 changed files with 1635 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ package ai;
import java.util.logging.Logger;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
@@ -26,6 +28,7 @@ import com.l2jmobius.gameserver.model.holders.MinionHolder;
import com.l2jmobius.gameserver.model.quest.Quest;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.Util;
/**
* Abstract NPC AI class for datapack based AIs.
@@ -101,4 +104,36 @@ public abstract class AbstractNpcAI extends Quest
addMinion((L2MonsterInstance) npc, is.getId());
}
}
protected void followNpc(final L2Npc npc, int followedNpcId, int followingAngle, int minDistance, int maxDistance)
{
L2World.getInstance().forEachVisibleObject(npc, L2Npc.class, npcAround ->
{
if (npcAround.getId() != followedNpcId)
{
return;
}
final double distance = npc.calculateDistance(npcAround, true, false);
if ((distance >= maxDistance) && npc.isScriptValue(0))
{
npc.setRunning();
npc.setScriptValue(1);
}
else if ((distance <= (minDistance * 1.5)) && npc.isScriptValue(1))
{
npc.setWalking();
npc.setScriptValue(0);
}
final double course = Math.toRadians(followingAngle);
final double radian = Math.toRadians(Util.convertHeadingToDegree(npcAround.getHeading()));
final double nRadius = npc.getCollisionRadius() + npcAround.getCollisionRadius() + minDistance;
final int x = npcAround.getLocation().getX() + (int) (Math.cos(Math.PI + radian + course) * nRadius);
final int y = npcAround.getLocation().getY() + (int) (Math.sin(Math.PI + radian + course) * nRadius);
final int z = npcAround.getLocation().getZ();
npc.getAI().moveTo(new Location(x, y, z));
});
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.areas.TalkingIsland.Walkers;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
/**
* Allada AI.
* @author Gladicek
*/
public final class Allada extends AbstractNpcAI
{
// NPC
private static final int RINNE = 33234;
private static final int ALLADA = 33220;
// Items
private static final int WEAPON = 15304;
// Distances
private static final int MIN_DISTANCE = 70;
private static final int MAX_DISTANCE = 200;
private Allada()
{
addSpawnId(ALLADA);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
switch (event)
{
case "NPC_SHOUT":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.IT_S_A_MIRACLE_THAT_THE_TALKING_ISLAND_HAS_RESTORED);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
break;
}
case "WALK_AROUND_RINNE":
{
followNpc(npc, RINNE, 115, MIN_DISTANCE, MAX_DISTANCE);
break;
}
}
}
@Override
public String onSpawn(L2Npc npc)
{
npc.setRHandId(WEAPON);
followNpc(npc, RINNE, 115, MIN_DISTANCE, MAX_DISTANCE);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
getTimers().addRepeatingTimer("WALK_AROUND_RINNE", 1000, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Allada();
}
}

View File

@@ -0,0 +1,68 @@
/*
* 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.areas.TalkingIsland.Walkers;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
/**
* Mei AI.
* @author Gladicek
*/
public final class Mei extends AbstractNpcAI
{
// NPC
private static final int MEI = 33280;
private static final int ROTINA = 33027;
private Mei()
{
addSpawnId(MEI);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
if (event.equals("NPC_SHOUT"))
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.IF_YOU_IGNORE_THE_TRAINING_GROUNDS_YOU_LL_REGRET_IT);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
}
else if (event.equals("NPC_FOLLOW"))
{
addSpawn(ROTINA, npc.getX() + 10, npc.getY() + 10, npc.getZ() + 10, 0, false, 0);
}
}
@Override
public String onSpawn(L2Npc npc)
{
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
getTimers().addTimer("NPC_FOLLOW", 100, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Mei();
}
}

View File

@@ -0,0 +1,77 @@
/*
* 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.areas.TalkingIsland.Walkers;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
/**
* Remons AI.
* @author Gladicek
*/
public final class Remons extends AbstractNpcAI
{
// NPC
private static final int REMONS = 33570;
private static final int SOROS = 33218;
// Distances
private static final int MIN_DISTANCE = 70;
private static final int MAX_DISTANCE = 200;
private Remons()
{
addSpawnId(REMONS);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
switch (event)
{
case "NPC_SHOUT":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.PERHAPS_EVEN_THE_VILLAGE_BECOMES_DANGEROUS);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
break;
}
case "WALK_AROUND_SOROS":
{
followNpc(npc, SOROS, 240, MIN_DISTANCE, MAX_DISTANCE);
break;
}
}
}
@Override
public String onSpawn(L2Npc npc)
{
followNpc(npc, SOROS, 240, MIN_DISTANCE, MAX_DISTANCE);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
getTimers().addRepeatingTimer("WALK_AROUND_SOROS", 1000, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Remons();
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.areas.TalkingIsland.Walkers;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
/**
* Rinne AI.
* @author Gladicek
*/
public final class Rinne extends AbstractNpcAI
{
// NPC
private static final int RINNE = 33234;
private static final int ALLADA = 33220;
// Items
private static final int WEAPON = 15302;
private Rinne()
{
addSpawnId(RINNE);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
switch (event)
{
case "TID_LEFTWALK":
{
npc.setRHandId(WEAPON);
getTimers().addTimer("TID_STRAIGHTWALK", (5000 + getRandom(5)) * 1000, npc, null);
break;
}
case "TID_STRAIGHTWALK":
{
npc.setRHandId(0);
getTimers().addTimer("TID_LEFTWALK", (5000 + getRandom(5)) * 1000, npc, null);
break;
}
case "NPC_SHOUT":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.ALL_RACES_CAME_TOGETHER_TO_REBUILD_TALKING_ISLAND_VILLAGE);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
break;
}
case "NPC_FOLLOW":
{
addSpawn(ALLADA, npc.getX() + 10, npc.getY() + 10, npc.getZ(), 0, false, 0);
break;
}
}
}
@Override
public String onSpawn(L2Npc npc)
{
getTimers().addTimer("TID_LEFTWALK", (5000 + getRandom(5)) * 1000, npc, null);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
getTimers().addTimer("NPC_FOLLOW", 100, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Rinne();
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.areas.TalkingIsland.Walkers;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
/**
* Rotina AI.
* @author Gladicek
*/
public final class Rotina extends AbstractNpcAI
{
// NPC
private static final int ROTINA = 33027;
private static final int MEI = 33280;
// Items
private static final int WEAPON = 15304;
// Distances
private static final int MIN_DISTANCE = 70;
private static final int MAX_DISTANCE = 200;
private Rotina()
{
addSpawnId(ROTINA);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
switch (event)
{
case "NPC_SHOUT":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.YOU_LL_EARN_TONS_OF_ITEMS_USING_THE_TRAINING_GROUNDS);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
break;
}
case "WALK_AROUND_MEI":
{
followNpc(npc, MEI, 115, MIN_DISTANCE, MAX_DISTANCE);
break;
}
}
}
@Override
public String onSpawn(L2Npc npc)
{
npc.setRHandId(WEAPON);
followNpc(npc, MEI, 115, MIN_DISTANCE, MAX_DISTANCE);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
getTimers().addRepeatingTimer("WALK_AROUND_MEI", 1000, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Rotina();
}
}

View File

@@ -0,0 +1,73 @@
/*
* 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.areas.TalkingIsland.Walkers;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
/**
* Soros AI.
* @author Gladicek
*/
public final class Soros extends AbstractNpcAI
{
// NPC
private static final int SOROS = 33218;
private static final int REMONS = 33570;
private Soros()
{
addSpawnId(SOROS);
}
@Override
public void onTimerEvent(String event, StatsSet params, L2Npc npc, L2PcInstance player)
{
switch (event)
{
case "NPC_SHOUT":
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.SOMETHING_LIKE_THAT_COMES_OUT_OF_THE_RUINS);
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
break;
}
case "NPC_FOLLOW":
{
addSpawn(REMONS, npc.getX() + 10, npc.getY() + 10, npc.getZ() + 10, 0, false, 0);
break;
}
}
}
@Override
public String onSpawn(L2Npc npc)
{
getTimers().addTimer("NPC_SHOUT", (10 + getRandom(5)) * 1000, npc, null);
getTimers().addTimer("NPC_FOLLOW", 100, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Soros();
}
}