특정시간 상점스폰(퍼옴)
L1SpawnUtil.java
public static void NpcTimeSpawn(int x, int y, short MapId, int Heading,
int npcId, int randomRange, boolean isUsePainwand,
int timeMillisToDelete) {
try {
L1NpcInstance npc = NpcTable.getInstance().newNpcInstance(npcId);
npc.setId(ObjectIdFactory.getInstance().nextId());
npc.setMap(MapId);
if (randomRange == 0) {
// npc.getLocation().set(pc.getLocation());
npc.getLocation().forward(Heading);
} else {
int tryCount = 0;
do {
tryCount++;
npc.setX(x + (int) (Math.random() * randomRange)
- (int) (Math.random() * randomRange));
npc.setY(y + (int) (Math.random() * randomRange)
- (int) (Math.random() * randomRange));
if (npc.getMap().isInMap(npc.getLocation())
&& npc.getMap().isPassable(npc.getLocation())) {
break;
}
Thread.sleep(1);
} while (tryCount < 50);
if (tryCount >= 50) {
// npc.getLocation().set(pc.getLocation());
npc.getLocation().forward(Heading);
}
}
npc.setHomeX(npc.getX());
npc.setHomeY(npc.getY());
npc.getMoveState().setHeading(Heading);
if (isUsePainwand) {
if (npc instanceof L1MonsterInstance) {
L1MonsterInstance mon = (L1MonsterInstance) npc;
mon.set_storeDroped(2);
}
}
L1World.getInstance().storeObject(npc);
L1World.getInstance().addVisibleObject(npc);
npc.getLight().turnOnOffLight();
npc.startChat(L1NpcInstance.CHAT_TIMING_APPEARANCE);
if (0 < timeMillisToDelete) {
L1NpcDeleteTimer timer = new L1NpcDeleteTimer(npc,
timeMillisToDelete);
timer.begin();
}
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
// 위 부분 추가 (해당 윗부분 npc스폰에 관련된 소스의 출처는 일팩입니다)
시간별 랜덤으로 뜨게 할 소스에 추가할 부분
import l1j.server.server.utils.L1SpawnUtil;
L1SpawnUtil.NpcTimeSpawn(맵x, 맵y, (short) 맵id, 방향, Npc id, 1, false, //팩에맞게 좌표와 엔피시조절
(1000 * 60 * 10)); //10분동안 떠있는다
public static void NpcTimeSpawn(int x, int y, short MapId, int Heading,
int npcId, int randomRange, boolean isUsePainwand,
int timeMillisToDelete) {
try {
L1NpcInstance npc = NpcTable.getInstance().newNpcInstance(npcId);
npc.setId(ObjectIdFactory.getInstance().nextId());
npc.setMap(MapId);
if (randomRange == 0) {
// npc.getLocation().set(pc.getLocation());
npc.getLocation().forward(Heading);
} else {
int tryCount = 0;
do {
tryCount++;
npc.setX(x + (int) (Math.random() * randomRange)
- (int) (Math.random() * randomRange));
npc.setY(y + (int) (Math.random() * randomRange)
- (int) (Math.random() * randomRange));
if (npc.getMap().isInMap(npc.getLocation())
&& npc.getMap().isPassable(npc.getLocation())) {
break;
}
Thread.sleep(1);
} while (tryCount < 50);
if (tryCount >= 50) {
// npc.getLocation().set(pc.getLocation());
npc.getLocation().forward(Heading);
}
}
npc.setHomeX(npc.getX());
npc.setHomeY(npc.getY());
npc.getMoveState().setHeading(Heading);
if (isUsePainwand) {
if (npc instanceof L1MonsterInstance) {
L1MonsterInstance mon = (L1MonsterInstance) npc;
mon.set_storeDroped(2);
}
}
L1World.getInstance().storeObject(npc);
L1World.getInstance().addVisibleObject(npc);
npc.getLight().turnOnOffLight();
npc.startChat(L1NpcInstance.CHAT_TIMING_APPEARANCE);
if (0 < timeMillisToDelete) {
L1NpcDeleteTimer timer = new L1NpcDeleteTimer(npc,
timeMillisToDelete);
timer.begin();
}
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
// 위 부분 추가 (해당 윗부분 npc스폰에 관련된 소스의 출처는 일팩입니다)
시간별 랜덤으로 뜨게 할 소스에 추가할 부분
import l1j.server.server.utils.L1SpawnUtil;
L1SpawnUtil.NpcTimeSpawn(맵x, 맵y, (short) 맵id, 방향, Npc id, 1, false, //팩에맞게 좌표와 엔피시조절
(1000 * 60 * 10)); //10분동안 떠있는다

단올아빠 님의 최근 댓글
감사합니딘 2024 04.26 감사합니다 2024 04.26 어그래. 부자되세요 2023 01.02 에휴. 진짜 욕나오지마 내입이 드러워질까봐 참는다 포인트로 부자나되라 2023 01.02 빨리지우세요 다른사람들도 생각좀해주세요 2023 01.02