Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Fake Players
#11
Sky03611 Написал:Использую сборку Interlude.su
В сурсах встроены Fake Players.
Все сделал. Поставил спавнятся, но они только точатся и не бегают(пробегают 2 шага после спавна и стоять)
Прикладываю сурс. Реализовано ли вообще это тут?
package ru.catssoftware.gameserver.datatables;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.LineNumberReader;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Logger;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

import javolution.text.TextBuilder;
import javolution.util.FastList;
import javolution.util.FastMap;
import ru.catssoftware.Config;
import ru.catssoftware.L2DatabaseFactory;
import ru.catssoftware.gameserver.ThreadPoolManager;
import ru.catssoftware.gameserver.ai.CtrlIntention;
import ru.catssoftware.gameserver.geodata.GeoData;
import ru.catssoftware.gameserver.model.L2CharPosition;
import ru.catssoftware.gameserver.model.L2ItemInstance;
import ru.catssoftware.gameserver.model.Location;
import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance;
import ru.catssoftware.gameserver.network.serverpackets.MagicSkillUse;
import ru.catssoftware.tools.random.Rnd;

public class FakePlayersTablePlus {

private static Logger _log = Logger.getLogger(EventSpawnList.class.getName());
// полный список всех obj_Id ботов
private static int _fakesCount = 0;
private static int _fakesLimit = 0;
private static String _fakeAcc = "fh4f#67$euro";
private static FastMap<Integer, L2Fantome> _fakes = new FastMap<Integer, L2Fantome>().shared("FakePlayersTablePlus._fakes");
private static FastList<Integer> _fakesIds = new FastList<Integer>();
/**
* Городские
*/
private volatile int _fakesTownTotal = 0;
// координаты
private static int _locsCount = 0;
private static FastList<Location> _fakesTownLoc = new FastList<Location>();
// стоячие в городах: волна_спауна,список_заспавненных
private static Map<Integer, ConcurrentLinkedQueue<L2PcInstance>> _fakesTown = new ConcurrentHashMap<Integer, ConcurrentLinkedQueue<L2PcInstance>>();
// сидячие кучки кланов в городах: клан,список_заспавненных
private static Map<Integer, ConcurrentLinkedQueue<L2PcInstance>> _fakesTownClan = new ConcurrentHashMap<Integer, ConcurrentLinkedQueue<L2PcInstance>>();
private static Map<Integer, ConcurrentLinkedQueue<Integer>> _fakesTownClanList = new ConcurrentHashMap<Integer, ConcurrentLinkedQueue<Integer>>();
// сеты
private static int _setsCount = 0;
private static FastList<L2Set> _sets = new FastList<L2Set>();
private static int _setsArcherCount = 0;
private static FastList<L2Set> _setsArcher = new FastList<L2Set>();
// рек, если любишь маму
private static ConcurrentLinkedQueue<L2PcInstance> _fakesTownRec = new ConcurrentLinkedQueue<L2PcInstance>();
/**
* * Олимп*
*/
// стоячие возле олимп столбов
private static ConcurrentLinkedQueue<L2PcInstance> _fakesOly = new ConcurrentLinkedQueue<L2PcInstance>();
// сеты
private static int _setsOlyCount = 0;
private static FastList<L2Set> _setsOly = new FastList<L2Set>();
/**
* дополнительно*
*/
//цвета
private static int _nameColCount = 0;
private static int _titleColCount = 0;
private static FastList<Integer> _nameColors = new FastList<Integer>();
private static FastList<Integer> _titleColors = new FastList<Integer>();
private static FakePlayersTablePlus _instance;
//фразы
private static int _fakesEnchPhsCount = 0;
private static FastList<String> _fakesEnchPhrases = new FastList<String>();
private static int _fakesLastPhsCount = 0;
private static FastList<String> _fakesLastPhrases = new FastList<String>();

public static FakePlayersTablePlus getInstance() {
return _instance;
}

public static void init() {
_instance = new FakePlayersTablePlus();
_instance.load();
}

public FakePlayersTablePlus() {
}

public void load() {
parceArmors();
parceArcherArmors();
parceOlyArmors();
parceColors();
cacheLastPhrases();
if (Config.ALLOW_FAKE_PLAYERS_PLUS) {
parceTownLocs();
parceTownClans();
parceTownRecs();
cacheFantoms();
cacheEnchantPhrases();

_fakesLimit = Config.FAKE_PLAYERS_PLUS_COUNT_FIRST + Config.FAKE_PLAYERS_PLUS_COUNT_NEXT + 10;
_fakesTown.put(1, new ConcurrentLinkedQueue<L2PcInstance>());
_fakesTown.put(2, new ConcurrentLinkedQueue<L2PcInstance>());
}
}

private void cacheFantoms() {
new Thread(new Runnable() {

@Override
public void run() {
String name = "";
String new_name = "";
Connection con = null;
PreparedStatement st = null;
//PreparedStatement st2 = null;
//PreparedStatement st3 = null;
ResultSet rs = null;
//ResultSet rs2 = null;
L2PcInstance fantom = null;
try {
con = L2DatabaseFactory.getInstance().getConnection(con);
con.setTransactionIsolation(1);
st = con.prepareStatement("SELECT charId,char_name,title,x,y,z,clanid FROM characters WHERE account_name = ?");
st.setString(1, _fakeAcc);
rs = st.executeQuery();
rs.setFetchSize(250);
while (rs.next()) {
//System.out.println("##1# " + name);
name = rs.getString("char_name");
//
_fakesIds.add(rs.getInt("charId"));
_fakes.put(rs.getInt("charId"), new L2Fantome(name, rs.getString("title"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("clanid")));
}
} catch (Exception e) {
_log.warning("FakePlayersTablePlus: could not load chars from DB: " + e);
} finally {
try {
if (st != null) {
st.close();
}
if (rs != null) {
rs.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
_log.info("FakePlayersTablePlus: Cached " + _fakes.size() + " players.");
if (!_fakes.isEmpty()) {
_fakesCount = _fakes.size() - 1;
ThreadPoolManager.getInstance().scheduleGeneral(new FantomTask(1), Config.FAKE_PLAYERS_PLUS_DELAY_FIRST); //360000
}
}
}).start();
}

public class FantomTask implements Runnable {

public int task;

/**
* 1 - спаун первой волны 2 - спаун 2 волны
*
*/
public FantomTask(int task) {
this.task = task;
}

public void run() {
switch (task) {
case 1:
_log.info("FakePlayersTablePlus: 1st wave, spawn started.");
int count = 0;
int fakeObjId = 0;
L2PcInstance fantom = null;
while (count < Config.FAKE_PLAYERS_PLUS_COUNT_FIRST) {
try {
//System.out.println("FakePlayersTablePlus: #1### " + count + " player.");
fakeObjId = getRandomFake();
//_log.info("FakePlayersTablePlus: #2### " + fakeObjId + " player.");
if (_fakesTown.get(1).contains(fakeObjId)) {
continue;
}
//System.out.println("FakePlayersTablePlus: #3### " + count + " player.");

fantom = restoreFake(fakeObjId);
// if (fantom == null) {
// System.out.println("FakePlayersTablePlus: #!!!!!!!!!!!!!!!!ayer.");
// }
//System.out.println("FakePlayersTablePlus: #4### " + count + " player.");
wearFantom(fantom);
//System.out.println("FakePlayersTablePlus: #5### " + count + " player.");

if (Rnd.get(100) < 45) {
try {
Thread.sleep(900);
} catch (InterruptedException e) {
}

if (Rnd.get(100) < 3) {
fantom.sitDown();
}

fantom.broadcastPacket(new MagicSkillUse(fantom, fantom, 2154, 1, 0, 0, true));
try {
Thread.sleep(300);
} catch (InterruptedException e) {
}
fantom.broadcastPacket(new MagicSkillUse(fantom, fantom, 2164, 1, 0, 0, true));
}
//System.out.println("FakePlayersTablePlus: #6### " + count + " player.");

//_log.info("FakePlayersTablePlus: #5### " + count + " player.");
_fakesTown.get(1).add(fantom);
//System.out.println("FakePlayersTablePlus: #7### " + count + " player.");
try {
Thread.sleep(Config.FAKE_PLAYERS_PLUS_DELAY_SPAWN_FIRST);
} catch (InterruptedException e) {
}
count++;
_fakesTownTotal++;
//System.out.println("FakePlayersTablePlus: #8### " + count + " player.");

} catch (Exception e) {
}
}
_log.info("FakePlayersTablePlus: 1st wave, spawned " + count + " players.");
ThreadPoolManager.getInstance().scheduleGeneral(new FantomTaskDespawn(1), Config.FAKE_PLAYERS_PLUS_DESPAWN_FIRST);
ThreadPoolManager.getInstance().scheduleGeneral(new FantomTask(2), Config.FAKE_PLAYERS_PLUS_DELAY_NEXT);
ThreadPoolManager.getInstance().scheduleGeneral(new Social(), 12000);
ThreadPoolManager.getInstance().scheduleGeneral(new CheckCount(), 300000);
break;
case 2:
_log.info("FakePlayersTablePlus: 2nd wave, spawn started.");
int count2 = 0;
int fakeObjId2 = 0;
L2PcInstance fantom2 = null;
while (count2 < Config.FAKE_PLAYERS_PLUS_COUNT_NEXT) {
try {
fakeObjId2 = getRandomFake();
if (_fakesTown.get(2).contains(fakeObjId2)) {
continue;
}

fantom2 = restoreFake(fakeObjId2);
wearFantom(fantom2);

if (Rnd.get(100) < 45) {
try {
Thread.sleep(900);
} catch (InterruptedException e) {
}

if (Rnd.get(100) < 3) {
fantom2.sitDown();
}

fantom2.broadcastPacket(new MagicSkillUse(fantom2, fantom2, 2154, 1, 0, 0, true));
try {
Thread.sleep(300);
} catch (InterruptedException e) {
}
fantom2.broadcastPacket(new MagicSkillUse(fantom2, fantom2, 2164, 1, 0, 0, true));
}
_fakesTown.get(2).add(fantom2);
try {
Thread.sleep(Config.FAKE_PLAYERS_PLUS_DELAY_SPAWN_NEXT);
} catch (InterruptedException e) {
}
count2++;
_fakesTownTotal++;
} catch (Exception e) {
}
}
_log.info("FakePlayersTablePlus: 2nd wave, spawned " + count2 + " players.");
ThreadPoolManager.getInstance().scheduleGeneral(new FantomTaskDespawn(2), Config.FAKE_PLAYERS_PLUS_DESPAWN_NEXT);
break;
}
}
}

public class FantomTaskDespawn implements Runnable {

public int task;

/**
* 1 - Despawn первой волны 1 - Despawn первой волны
*
*/
public FantomTaskDespawn(int task) {
this.task = task;
}

public void run() {
Location loc = null;
L2PcInstance next = null;
ConcurrentLinkedQueue<L2PcInstance> players = _fakesTown.get(task);
for (L2PcInstance fantom : players) {
if (fantom == null) {
continue;
}

loc = fantom.getLoc();
fantom.kick();
fantom.setOnlineStatus(false);
_fakesTown.get(task).remove(fantom);
_fakesTownTotal--;

try {
Thread.sleep((task == 1 ? Config.FAKE_PLAYERS_PLUS_DELAY_DESPAWN_FIRST : Config.FAKE_PLAYERS_PLUS_DELAY_DESPAWN_NEXT));
} catch (InterruptedException e) {
}

if (_fakesTownTotal > _fakesLimit) {
continue;
}

next = restoreFake(getRandomFakeNext());
next.getPosition().setXYZInvisible(loc.getX(), loc.getY(), loc.getZ());

wearFantom(next);

if (Rnd.get(100) < 45) {
try {
Thread.sleep(900);
} catch (InterruptedException e) {
}

if (Rnd.get(100) < 3) {
next.sitDown();
}

next.broadcastPacket(new MagicSkillUse(next, next, 2154, 1, 0, 0, true));

try {
Thread.sleep(300);
} catch (InterruptedException e) {
}
next.broadcastPacket(new MagicSkillUse(next, next, 2164, 1, 0, 0, true));
}

_fakesTown.get(task).add(next);
_fakesTownTotal++;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
loc = null;
next = null;
ThreadPoolManager.getInstance().scheduleGeneral(new FantomTaskDespawn(1), (task == 1 ? Config.FAKE_PLAYERS_PLUS_DESPAWN_FIRST : Config.FAKE_PLAYERS_PLUS_DESPAWN_NEXT));
}
}

public class Social implements Runnable {

public Social() {
}

public void run() {
TextBuilder tb = new TextBuilder();
for (Map.Entry<Integer, ConcurrentLinkedQueue<L2PcInstance>> entry : _fakesTown.entrySet()) {
Integer wave = entry.getKey();
ConcurrentLinkedQueue<L2PcInstance> players = entry.getValue();
if (wave == null || players == null) {
continue;
}

if (players.isEmpty()) {
continue;
}

int count = 0;
for (L2PcInstance player : players) {
if (Rnd.get(100) < 65) {
switch (Rnd.get(2)) {
case 0:
case 1:
L2ItemInstance wpn = player.getActiveWeaponInstance();
int enhchant = wpn.getEnchantLevel();
if (Rnd.get(100) < 66 && enhchant < Config.ENCHANT_MAX_WEAPON) {
wpn.setEnchantLevel(enhchant + 1);
} else if (Rnd.get(100) < 70) {
wpn.setEnchantLevel(3);
/*if (nextench > 13 && Rnd.get(100) < 2) {
tb.append("!");
for (int i = Rnd.get(2, 13); i > 0; i--) {
tb.append("!");
}
player.sayString(getRandomEnchantPhrase() + tb.toString(), 1);
tb.clear();
}*/
}
player.sendItems(true);
player.broadcastUserInfo();
break;
case 2:
if (Rnd.get(100) < 45) {
int posX = player.getX();
int posY = player.getY();
int posZ = player.getZ();
for (int i = 6; i > 0; i--) {
switch (Rnd.get(6)) {
case 1:
posX += 20;
posY += 20;
break;
case 2:
posX += 20;
posY += 30;
break;
case 3:
posX += 49;
posY -= 20;
break;
case 4:
posX += 10;
posY -= 20;
break;
case 5:
posX -= 20;
posY -= 1;
break;
case 6:
posX -= 20;
posY += 40;
break;
default:
posX -= 30;
posY += 40;
break;
}
//if (GeoData.getInstance().canSeeTarget(posX, posY, _activeChar.getZ(), _activeChar.getX(), _activeChar.getY(), _activeChar.getZ())) {
if (GeoData.getInstance().canMoveFromToTarget(posX, posY, player.getZ(), player.getX(), player.getY(), player.getZ(), 1)) {
posZ = player.getZ();
break;
}
}
player.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(posX, posY, posZ, 0));
}
break;
}
try {
Thread.sleep(Rnd.get(500, 1500));
} catch (InterruptedException e) {
}
count++;
}
if (count > 55) {
break;
}
}
}
tb.clear();
tb = null;
ThreadPoolManager.getInstance().scheduleGeneral(new Social(), 12000);
}
}

private String getRandomEnchantPhrase() {
return _fakesEnchPhrases.get(Rnd.get(_fakesEnchPhsCount));
}

public String getRandomLastPhrase() {
return _fakesLastPhrases.get(Rnd.get(_fakesLastPhsCount));
}

public class CheckCount implements Runnable {

public CheckCount() {
}

public void run() {
for (Map.Entry<Integer, ConcurrentLinkedQueue<L2PcInstance>> entry : _fakesTown.entrySet()) {
Integer wave = entry.getKey();
ConcurrentLinkedQueue<L2PcInstance> players = entry.getValue();
if (wave == null || players == null) {
continue;
}

if (players.isEmpty()) {
continue;
}

int limit = wave == 1 ? Config.FAKE_PLAYERS_PLUS_COUNT_FIRST : Config.FAKE_PLAYERS_PLUS_COUNT_NEXT;
int overflow = players.size() - limit;
if (overflow < 1) {
continue;
}

for (L2PcInstance fantom : players) {
fantom.kick();
fantom.setOnlineStatus(false);
_fakesTown.get(wave).remove(fantom);
_fakesTownTotal--;

overflow--;
if (overflow == 0) {
break;
}
}
}
ThreadPoolManager.getInstance().scheduleGeneral(new CheckCount(), 300000);
}
}

static class L2Set {

public int body;
public int gaiters;
public int gloves;
public int boots;
public int weapon;
public int custom;

L2Set(int bod, int gaiter, int glove, int boot, int weapon, int custom) {
this.body = bod;
this.gaiters = gaiter;
this.gloves = glove;
this.boots = boot;
this.weapon = weapon;
this.custom = custom;
}
}

static class L2Fantome {

public String name;
public String title;
public int x;
public int y;
public int z;
public int clanId;

L2Fantome(String name, String title, int x, int y, int z, int clanId) {
this.name = name;
this.title = title;

this.x = x;
this.y = y;
this.z = z;

this.clanId = clanId;
}
}

private void parceArmors() {
if (!_sets.isEmpty()) {
_sets.clear();
}

LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/town_sets.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
//#верх,низ,перчатки,ботинки,оружие,аксессуар
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}

String[] items = line.split(",");

int custom = 0;
try {
custom = Integer.parseInt(items[5]);
} catch (Exception e) {
custom = 0;
}
_sets.add(new L2Set(Integer.parseInt(items[0]), Integer.parseInt(items[1]), Integer.parseInt(items[2]), Integer.parseInt(items[3]), Integer.parseInt(items[4]), custom));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}
_setsCount = _sets.size() - 1;
}

private void parceArcherArmors() {
if (!_setsArcher.isEmpty()) {
_setsArcher.clear();
}

LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/archer_sets.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
//#верх,низ,перчатки,ботинки,оружие,аксессуар
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}

String[] items = line.split(",");

int custom = 0;
try {
custom = Integer.parseInt(items[5]);
} catch (Exception e) {
custom = 0;
}
_setsArcher.add(new L2Set(Integer.parseInt(items[0]), Integer.parseInt(items[1]), Integer.parseInt(items[2]), Integer.parseInt(items[3]), Integer.parseInt(items[4]), custom));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}
_setsArcherCount = _setsArcher.size() - 1;
}

private void parceOlyArmors() {
LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/oly_sets.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
//#верх,низ,перчатки,ботинки,оружие,аксессуар
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}
String[] items = line.split(",");

int custom = 0;
try {
custom = Integer.parseInt(items[5]);
} catch (Exception e) {
custom = 0;
}
_setsOly.add(new L2Set(Integer.parseInt(items[0]), Integer.parseInt(items[1]), Integer.parseInt(items[2]), Integer.parseInt(items[3]), Integer.parseInt(items[4]), custom));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}
_setsOlyCount = _setsOly.size() - 1;
}

private void parceTownClans() {
LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/town_clans.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
int clanId = 0;
//#ид_клана:ид_игрокa,ид_игрокa,ид_игрокa,ид_игрокa
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}

String[] items = line.split(":");
clanId = Integer.parseInt(items[0]);

String[] pls = items[1].split(",");
ConcurrentLinkedQueue<Integer> players = new ConcurrentLinkedQueue<Integer>();
for (String plid : pls) {
players.add(Integer.parseInt(plid));
}
_fakesTownClanList.put(clanId, players);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}
}

private void parceTownRecs() {
/*LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try
{
File Data = new File("./config/fake/town_rec.txt");
if (!Data.exists())
return;

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
int clanId = 0;
//#x,y,x:название_магазина,итем_ид,кол-во,цена,продажа0/покупка1,оффлайн1да/0нет
String line;
while((line = lnr.readLine()) != null)
{
if(line.trim().length() == 0 || line.startsWith("#"))
continue;

String[] items = line.split(":");
clanId = Integer.parseInt(items[0]);

String[] pls = items[1].split(",");
ConcurrentLinkedQueue<Integer> players = new ConcurrentLinkedQueue<Integer>();
for (String plid : pls)
{
players.add(Integer.parseInt(plid));
}
_fakesTownClanList.put(clanId, players);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (fr != null)
fr.close();
if (br != null)
br.close();
if (lnr != null)
lnr.close();
}
catch(Exception e1)
{}
}*/
}

private void parceTownLocs() {
_fakesTownLoc.clear();

LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/town_locs.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}

String[] items = line.split(",");
_fakesTownLoc.add(new Location(Integer.parseInt(items[0]), Integer.parseInt(items[1]), Integer.parseInt(items[2])));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}

_locsCount = _fakesTownLoc.size() - 1;
}

private void cacheEnchantPhrases() {
_fakesEnchPhrases.clear();

LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/phrases_enchant.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}

_fakesEnchPhrases.add(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}

_fakesEnchPhsCount = _fakesEnchPhrases.size() - 1;
}

private void cacheLastPhrases() {
_fakesLastPhrases.clear();

LineNumberReader lnr = null;
BufferedReader br = null;
FileReader fr = null;
try {
File Data = new File("./config/mods/fake/phrases_last.txt");
if (!Data.exists()) {
return;
}

fr = new FileReader(Data);
br = new BufferedReader(fr);
lnr = new LineNumberReader(br);
String line;
while ((line = lnr.readLine()) != null) {
if (line.trim().length() == 0 || line.startsWith("#")) {
continue;
}

_fakesLastPhrases.add(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
}
if (lnr != null) {
lnr.close();
}
} catch (Exception e1) {
}
}

_fakesLastPhsCount = _fakesLastPhrases.size() - 1;
}

private L2Set getRandomSet() {
return _sets.get(Rnd.get(_setsCount));
}

private L2Set getRandomArcherSet() {
return _setsArcher.get(Rnd.get(_setsArcherCount));
}

private int getRandomFake() {
return _fakesIds.get(Rnd.get(_fakesIds.size() - 1));//Rnd.get(468504530, 468865578);
}

private int getRandomFakeNext() {
int obj = 0;
for (int i = 6; i > 0; i--) {
obj = getRandomFake();

if (_fakesTown.get(1).contains(obj) || _fakesTown.get(2).contains(obj)) {
continue;
}

return obj;
}
return getRandomFakeNext();
}

private int getRandomClan() {
return Rnd.get(511158000, 511158008);
}

private Location getRandomLoc() {
/*int id = Rnd.get(_locsCount);
Location loc = _fakesTownLoc.remove(id);
return loc;*/
Location loc = null;
try {
loc = _fakesTownLoc.remove(_fakesTownTotal);
} catch (Exception e) {
//loc = _fakesTownLoc.get(Rnd.get(_locsCount));
}
if (loc == null) {
loc = _fakesTownLoc.remove(Rnd.get(_locsCount));
}

if (_fakesTownLoc.isEmpty()) {
parceTownLocs();
}

return loc;
}

private L2PcInstance restoreFake(int objId) {
//System.out.println("##restoreFake###1#");
L2Fantome fake = _fakes.get(objId);
if (fake == null) {
return null;
}
//System.out.println("##restoreFake###2#");

L2PcInstance fantom = L2PcInstance.restoreFake(objId);
//System.out.println("##restoreFake###2.1#");
fantom.setName(fake.name);
//System.out.println("##restoreFake###2.2#");
fantom.setTitle(fake.title);

//System.out.println("##restoreFake###3#");
fantom.getAppearance().setNameColor(getNameColor());
fantom.getAppearance().setTitleColor(getTitleColor());

//System.out.println("##restoreFake###4#");
//if (fake.clanId > 0)
// fantom.setClan(ClanTable.getInstance().getClan(fake.clanId));
/*if (Rnd.get(100) < 40) {
fantom.setClan(ClanTable.getInstance().getClan(getRandomClan()));
}*/
//System.out.println("##restoreFake###5#");
int heading = Rnd.get(65535);
Location loc = getRandomLoc();
fantom.setHeading(heading);
fantom.getPosition().setHeading(heading);

int posX = loc.getX();
int posY = loc.getY();
int posZ = loc.getZ();
for (int i = 6; i > 0; i--) {
switch (Rnd.get(6)) {
case 1:
posX += 20;
posY += 20;
break;
case 2:
posX += 20;
posY += 30;
break;
case 3:
posX += 49;
posY -= 20;
break;
case 4:
posX += 10;
posY -= 20;
break;
case 5:
posX -= 20;
posY -= 1;
break;
case 6:
posX -= 20;
posY += 40;
break;
default:
posX -= 30;
posY += 40;
break;
}
//if (GeoData.getInstance().canSeeTarget(posX, posY, _activeChar.getZ(), _activeChar.getX(), _activeChar.getY(), _activeChar.getZ())) {
if (GeoData.getInstance().canMoveFromToTarget(posX, posY, loc.getZ(), loc.getX(), loc.getY(), loc.getZ(), 1)) {
posZ = loc.getZ();
break;
}
}

if (posZ == 0) {
//_activeChar.sendMessage("В данном месте не получается вызвать страйдера.");
//return;
posX = loc.getX() + 10;
posY = loc.getY() - 20;
posZ = loc.getZ();
}

fantom.getPosition().setXYZInvisible(posX, posY, posZ);
//System.out.println("##restoreFake###6#");
return fantom;
}

public void wearFantom(L2PcInstance fantom) {
//System.out.println("##wearFantom###1#");
L2Set set = getRandomSet();
//System.out.println("##wearFantom###2#");
L2ItemInstance body = ItemTable.getInstance().createDummyItem(set.body);
L2ItemInstance gaiters = ItemTable.getInstance().createDummyItem(set.gaiters);
L2ItemInstance gloves = ItemTable.getInstance().createDummyItem(set.gloves);
L2ItemInstance boots = ItemTable.getInstance().createDummyItem(set.boots);
L2ItemInstance weapon = ItemTable.getInstance().createDummyItem(set.weapon);
//System.out.println("##wearFantom###3#" + (fantom.getInventory() == null) + "##" + (body == null));
fantom.getInventory().equipItemAndRecord(body);
// System.out.println("##wearFantom###3.1#");
fantom.getInventory().equipItemAndRecord(gaiters);
///System.out.println("##wearFantom###3.2#");
fantom.getInventory().equipItemAndRecord(gloves);
// System.out.println("##wearFantom###3.3#");
fantom.getInventory().equipItemAndRecord(boots);
//System.out.println("##wearFantom###3.4#");

if (set.custom > 0) {
//System.out.println("##wearFantom###3.5#");
L2ItemInstance custom = ItemTable.getInstance().createDummyItem(set.custom);
//System.out.println("##wearFantom###3.6#");
fantom.getInventory().equipItemAndRecord(custom);
//System.out.println("##wearFantom###3.7#");
}

// System.out.println("##wearFantom###4#");
//weapon.setEnchantLevel((Rnd.get(6) + Rnd.get(6))); // 2 кубика надежнее
weapon.setEnchantLevel(Rnd.get(Config.FAKE_PLAYERS_ENCHANT.id, Config.FAKE_PLAYERS_ENCHANT.count)); // 2 кубика надежнее
/*if (Rnd.get(100) < 30) {
weapon.setAugmentation(new L2Augmentation(1067847165, 3250, 1));
}*/
fantom.getInventory().equipItemAndRecord(weapon);
//System.out.println("##wearFantom###5#");

//fantom.getAppearance().setInvisible();
fantom.enableAllSkills();
fantom.spawnMe();
//L2World.getInstance().storeObject(this);
fantom.setOnlineStatus(true);
//fantom.broadcastPacket(new StartRotation(fantom.getObjectId(), fantom.getHeading(), 1, 65535));
//fantom.broadcastPacket(new StopRotation(fantom.getObjectId(), fantom.getHeading(), 65535));
//fantom.setHeading(fantom.getHeading());

//fantom.getAppearance().setVisible();
//fantom.broadcastUserInfo();
//fantom.broadcastPacket(new ValidateLocation(fantom));
//System.out.println("##wearFantom###6#");
//System.out.println("##wearFantom###7#");
int posX = fantom.getX();
int posY = fantom.getY();
for (int i = 6; i > 0; i--) {
switch (Rnd.get(6)) {
case 1:
posX += 10;
posY += 10;
break;
case 2:
posX += 10;
posY += 10;
break;
case 3:
posX += 10;
posY -= 10;
break;
case 4:
posX += 10;
posY -= 10;
break;
case 5:
posX -= 10;
posY -= 10;
break;
case 6:
posX -= 10;
posY += 10;
break;
default:
posX -= 10;
posY += 10;
break;
}
}
fantom.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(posX, posY, fantom.getZ(), 0));
}

//
private void parceColors() {
_nameColors = Config.FAKE_PLAYERS_NAME_CLOLORS;
_titleColors = Config.FAKE_PLAYERS_TITLE_CLOLORS;
_nameColCount = _nameColors.size() - 1;
_titleColCount = _titleColors.size() - 1;
}

private int getNameColor() {
return _nameColors.get(Rnd.get(_nameColCount));
}

private int getTitleColor() {
return _titleColors.get(Rnd.get(_titleColCount));
}

//
public void wearArcher(L2PcInstance fantom) {
//System.out.println("##wearFantom###1#");
L2Set set = getRandomArcherSet();
//System.out.println("##wearFantom###2#");
L2ItemInstance body = ItemTable.getInstance().createDummyItem(set.body);
L2ItemInstance gaiters = ItemTable.getInstance().createDummyItem(set.gaiters);
L2ItemInstance gloves = ItemTable.getInstance().createDummyItem(set.gloves);
L2ItemInstance boots = ItemTable.getInstance().createDummyItem(set.boots);
L2ItemInstance weapon = ItemTable.getInstance().createDummyItem(set.weapon);
///System.out.println("##wearFantom###3#");
fantom.getInventory().equipItemAndRecord(body);
fantom.getInventory().equipItemAndRecord(gaiters);
fantom.getInventory().equipItemAndRecord(gloves);
fantom.getInventory().equipItemAndRecord(boots);

if (set.custom > 0) {
L2ItemInstance custom = ItemTable.getInstance().createDummyItem(set.custom);
fantom.getInventory().equipItemAndRecord(custom);
}

//System.out.println("##wearFantom###4#");
//weapon.setEnchantLevel((Rnd.get(6) + Rnd.get(6))); // 2 кубика надежнее
weapon.setEnchantLevel(Rnd.get(Config.FAKE_PLAYERS_ENCHANT.id, Config.FAKE_PLAYERS_ENCHANT.count)); // 2 кубика надежнее
/*if (Rnd.get(100) < 30) {
weapon.setAugmentation(new L2Augmentation(1067847165, 3250, 1));
}*/
fantom.getInventory().equipItemAndRecord(weapon);
//System.out.println("##wearFantom###5#");

fantom.spawnMe();
fantom.setOnlineStatus(true);
//System.out.println("##wearFantom###6#");
//System.out.println("##wearFantom###7#");
}
}

Подниму тему 100 летней давности, запустил так же сборку инт.су, всё сделал вроде бы правильно, но боты так и не спавнятся.... подскажите пожалуйста, что я не до смотрел?
Ответ
#12
Доброго времени суток! Помогите, пожалуйста, найти сурсы L2TheGrand 2.0 или самые актуальные! Заранее благодарен!
Ответ
#13
дабы не плодить новые темы, у кого то есть эти боты или новее версия? спасибо.
Разработка эмулятора Blade and Soul
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Fake Death white7777x 5 1,761 07-06-2013, 04:37 AM
Последний пост: white7777x

Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)