Addition of fake player system.

This commit is contained in:
MobiusDev
2017-11-26 02:33:09 +00:00
parent fffb78c071
commit 749b2775a8
339 changed files with 12524 additions and 717 deletions

View File

@@ -88,7 +88,7 @@ public final class Wisp extends AbstractNpcAI
final L2Character creature = event.getSeen();
final L2Npc npc = (L2Npc) event.getSeer();
if (creature.isPlayer())
if (creature.isPlayer() || creature.isFakePlayer())
{
npc.setTarget(creature);
npc.doCast(npc.getId() == WISP ? WISP_HEAL.getSkill() : LARGE_WISP_HEAL.getSkill());

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 custom.FakePlayers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import ai.AbstractNpcAI;
/**
* TODO: Move it to L2Character.
* @author Mobius
*/
public class PvpFlaggingStopTask extends AbstractNpcAI
{
private PvpFlaggingStopTask()
{
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if ((npc == null) || npc.isDead())
{
return null;
}
if (event.startsWith("FLAG_CHECK"))
{
final L2Object target = npc.getTarget();
if ((target != null) && (target.isPlayable() || target.isFakePlayer()))
{
npc.setScriptValue(1); // in combat
cancelQuestTimer("FINISH_FLAG" + npc.getObjectId(), npc, null);
cancelQuestTimer("REMOVE_FLAG" + npc.getObjectId(), npc, null);
startQuestTimer("FINISH_FLAG" + npc.getObjectId(), Config.PVP_NORMAL_TIME - 20000, npc, null);
startQuestTimer("FLAG_CHECK" + npc.getObjectId(), 5000, npc, null);
}
}
else if (event.startsWith("FINISH_FLAG"))
{
if (npc.isScriptValue(1))
{
npc.setScriptValue(2); // blink status
npc.broadcastInfo(); // update flag status
startQuestTimer("REMOVE_FLAG" + npc.getObjectId(), 20000, npc, null);
}
}
else if (event.startsWith("REMOVE_FLAG"))
{
if (npc.isScriptValue(2))
{
npc.setScriptValue(0); // not in combat
npc.broadcastInfo(); // update flag status
}
}
return super.onAdvEvent(event, npc, player);
}
public static void main(String[] args)
{
new PvpFlaggingStopTask();
}
}

View File

@@ -0,0 +1,115 @@
/*
* 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 custom.FakePlayers;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.skills.SkillCaster;
import ai.AbstractNpcAI;
/**
* Town Fake Player walkers that receive buffs from Adventurer NPC.
* @author Mobius
*/
public class RecieveAdventurerBuffs extends AbstractNpcAI
{
// NPCs
private static final int[] ADVENTURERS_GUIDE =
{
32327,
33950,
};
private static final int[] FAKE_PLAYER_IDS =
{
80000
};
// Skills
// private static final SkillHolder KNIGHT = new SkillHolder(15648, 1); // Knight's Harmony (Adventurer)
private static final SkillHolder WARRIOR = new SkillHolder(15649, 1); // Warrior's Harmony (Adventurer)
private static final SkillHolder WIZARD = new SkillHolder(15650, 1); // Wizard's Harmony (Adventurer)
private static final SkillHolder[] GROUP_BUFFS =
{
new SkillHolder(15642, 1), // Horn Melody (Adventurer)
new SkillHolder(15643, 1), // Drum Melody (Adventurer)
new SkillHolder(15644, 1), // Pipe Organ Melody (Adventurer)
new SkillHolder(15645, 1), // Guitar Melody (Adventurer)
new SkillHolder(15646, 1), // Harp Melody (Adventurer)
new SkillHolder(15647, 1), // Lute Melody (Adventurer)
new SkillHolder(15651, 1), // Prevailing Sonata (Adventurer)
new SkillHolder(15652, 1), // Daring Sonata (Adventurer)
new SkillHolder(15653, 1), // Refreshing Sonata (Adventurer)
};
private RecieveAdventurerBuffs()
{
if (Config.FAKE_PLAYERS_ENABLED)
{
addSpawnId(FAKE_PLAYER_IDS);
}
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.startsWith("AUTOBUFF") && (npc != null) && !npc.isDead())
{
if (!npc.isMoving())
{
for (L2Npc nearby : L2World.getInstance().getVisibleObjects(npc, L2Npc.class, 100))
{
if (CommonUtil.contains(ADVENTURERS_GUIDE, nearby.getId()))
{
for (SkillHolder holder : GROUP_BUFFS)
{
SkillCaster.triggerCast(nearby, npc, holder.getSkill());
}
if (ClassId.getClassId(FakePlayerData.getInstance().getInfo(npc.getId()).getClassId()).isMage())
{
SkillCaster.triggerCast(nearby, npc, WIZARD.getSkill());
}
else
{
SkillCaster.triggerCast(nearby, npc, WARRIOR.getSkill());
}
break;
}
}
}
startQuestTimer("AUTOBUFF" + npc.getObjectId(), 30000, npc, null);
}
return super.onAdvEvent(event, npc, player);
}
@Override
public String onSpawn(L2Npc npc)
{
startQuestTimer("AUTOBUFF" + npc.getObjectId(), 1000, npc, null);
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new RecieveAdventurerBuffs();
}
}

View File

@@ -79,6 +79,7 @@ import handlers.admincommandhandlers.AdminEnchant;
import handlers.admincommandhandlers.AdminEventEngine;
import handlers.admincommandhandlers.AdminEvents;
import handlers.admincommandhandlers.AdminExpSp;
import handlers.admincommandhandlers.AdminFakePlayers;
import handlers.admincommandhandlers.AdminFightCalculator;
import handlers.admincommandhandlers.AdminFortSiege;
import handlers.admincommandhandlers.AdminGeodata;
@@ -410,6 +411,7 @@ public class MasterHandler
AdminEventEngine.class,
AdminEvents.class,
AdminExpSp.class,
AdminFakePlayers.class,
AdminFightCalculator.class,
AdminFortSiege.class,
AdminGeodata.class,

View File

@@ -192,7 +192,7 @@ public class L2NpcActionShift implements IActionShiftHandler
}
else if (Config.ALT_GAME_VIEWNPC)
{
if (!target.isNpc())
if (!target.isNpc() || target.isFakePlayer())
{
return false;
}

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 handlers.admincommandhandlers;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Mobius
*/
public class AdminFakePlayers implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_fakechat"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.startsWith("admin_fakechat"))
{
final String[] words = command.substring(15).split(" ");
if (words.length < 3)
{
activeChar.sendMessage("Usage: //fakechat playername fpcname message");
return false;
}
final L2PcInstance player = L2World.getInstance().getPlayer(words[0]);
if (player == null)
{
activeChar.sendMessage("Player not found.");
return false;
}
final String fpcName = FakePlayerData.getInstance().getProperName(words[1]);
if (fpcName == null)
{
activeChar.sendMessage("Fake player not found.");
return false;
}
String message = "";
for (int i = 0; i < words.length; i++)
{
if (i < 2)
{
continue;
}
message += (words[i] + " ");
}
FakePlayerChatManager.getInstance().sendChat(player, fpcName, message);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -32,6 +32,7 @@ import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
@@ -45,9 +46,12 @@ import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
import com.l2jmobius.gameserver.util.Util;
@@ -301,6 +305,25 @@ public class AdminReload implements IAdminCommandHandler
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Fishing data.");
break;
}
case "fakeplayers":
{
FakePlayerData.getInstance().load();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (obj.isFakePlayer())
{
obj.broadcastInfo();
}
}
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Fake Player data.");
break;
}
case "fakeplayerchat":
{
FakePlayerChatManager.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Fake Player Chat data.");
break;
}
default:
{
activeChar.sendMessage(RELOAD_USAGE);

View File

@@ -17,8 +17,10 @@
package handlers.chathandlers;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.handler.IChatHandler;
import com.l2jmobius.gameserver.instancemanager.FakePlayerChatManager;
import com.l2jmobius.gameserver.model.BlockList;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.PcCondOverride;
@@ -59,6 +61,28 @@ public final class ChatWhisper implements IChatHandler
return;
}
if (Config.FAKE_PLAYERS_ENABLED && (FakePlayerData.getInstance().getProperName(target) != null))
{
if (FakePlayerData.getInstance().isTalkable(target))
{
if (Config.FAKE_PLAYER_CHAT)
{
final String name = FakePlayerData.getInstance().getProperName(target);
activeChar.sendPacket(new CreatureSay(activeChar, null, "->" + name, type, text));
FakePlayerChatManager.getInstance().manageChat(activeChar, name, text);
}
else
{
activeChar.sendPacket(SystemMessageId.THAT_PERSON_IS_IN_MESSAGE_REFUSAL_MODE);
}
}
else
{
activeChar.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
}
return;
}
final L2PcInstance receiver = L2World.getInstance().getPlayer(target);
if ((receiver != null) && !receiver.isSilenceMode(activeChar.getObjectId()))

View File

@@ -40,5 +40,4 @@ public class PlayerLevelCondition implements ICondition
{
return creature.isPlayer() && (creature.getLevel() >= _minLevel) && (creature.getLevel() < _maxLevel);
}
}

View File

@@ -16,9 +16,11 @@
*/
package handlers.playeractions;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlEvent;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.ai.NextAction;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.handler.IPlayerActionHandler;
import com.l2jmobius.gameserver.model.ActionDataHolder;
import com.l2jmobius.gameserver.model.L2Object;
@@ -97,6 +99,15 @@ public final class SocialAction implements IPlayerActionHandler
return true;
}
private void scheduleDeny(L2PcInstance player)
{
if (player != null)
{
player.sendPacket(SystemMessageId.THE_COUPLE_ACTION_WAS_DENIED);
player.onTransactionResponse();
}
}
private void useCoupleSocial(L2PcInstance player, int id)
{
if (player == null)
@@ -105,7 +116,26 @@ public final class SocialAction implements IPlayerActionHandler
}
final L2Object target = player.getTarget();
if ((target == null) || !target.isPlayer())
if ((target == null))
{
player.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
if (FakePlayerData.getInstance().isTalkable(target.getName()))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_REQUESTED_A_COUPLE_ACTION_WITH_C1);
sm.addString(target.getName());
player.sendPacket(sm);
if (!player.isProcessingRequest())
{
ThreadPoolManager.schedule(() -> scheduleDeny(player), 10000);
player.blockRequest();
}
return;
}
if (!target.isPlayer())
{
player.sendPacket(SystemMessageId.INVALID_TARGET);
return;

View File

@@ -216,11 +216,14 @@ public class Q10766_ANewCraft extends Quest
@Id(WINDY_HEALING_POTION_1)
public void onItemCreate(OnItemCreate event)
{
final L2PcInstance player = event.getActiveChar();
final QuestState qs = getQuestState(player, false);
if ((qs != null) && (qs.isCond(3)) && (getQuestItemsCount(qs.getPlayer(), AIR_STONE) >= 1) && (getQuestItemsCount(qs.getPlayer(), WINDY_HEALING_POTION_1) >= 1))
final L2PcInstance player = event.getActiveChar().getActingPlayer();
if (player != null)
{
qs.setCond(4, true);
final QuestState qs = getQuestState(player, false);
if ((qs != null) && (qs.isCond(3)) && (getQuestItemsCount(qs.getPlayer(), AIR_STONE) >= 1) && (getQuestItemsCount(qs.getPlayer(), WINDY_HEALING_POTION_1) >= 1))
{
qs.setCond(4, true);
}
}
}
}

View File

@@ -141,11 +141,14 @@ public class Q10767_AWholeNewLevelOfAlchemy extends Quest
@Id(HIGH_GRADE_LOVE_POTION)
public void onItemCreate(OnItemCreate event)
{
final L2PcInstance player = event.getActiveChar();
final QuestState qs = getQuestState(player, false);
if ((qs != null) && (qs.isCond(1)) && (getQuestItemsCount(qs.getPlayer(), SUPERIOR_WINDY_HEALING_POTION) >= 1000) && (getQuestItemsCount(qs.getPlayer(), SUPERIOR_WINDY_QUIK_HEALING_POTION) >= 1000) && (getQuestItemsCount(qs.getPlayer(), HIGH_GRADE_LOVE_POTION) >= 1000))
final L2PcInstance player = event.getActiveChar().getActingPlayer();
if (player != null)
{
qs.setCond(2, true);
final QuestState qs = getQuestState(player, false);
if ((qs != null) && (qs.isCond(1)) && (getQuestItemsCount(qs.getPlayer(), SUPERIOR_WINDY_HEALING_POTION) >= 1000) && (getQuestItemsCount(qs.getPlayer(), SUPERIOR_WINDY_QUIK_HEALING_POTION) >= 1000) && (getQuestItemsCount(qs.getPlayer(), HIGH_GRADE_LOVE_POTION) >= 1000))
{
qs.setCond(2, true);
}
}
}
}