65 고정엔피시 추가
MapleMapFactory.java
메소드 복붙 ㄱ
public void getFixNpc(MapleMap map, int mapid) {
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("SELECT * FROM spawnnpc WHERE mapid = ?");
ps.setInt(1, mapid);
rs = ps.executeQuery();
while (rs.next()) {
MapleNPC npc = MapleLifeFactory.getNPC(rs.getInt("npcid"));
npc.setCy(rs.getInt("cy"));
npc.setRx0(rs.getInt("rx0"));
npc.setRx1(rs.getInt("rx1"));
npc.setFh(rs.getInt("fh"));
npc.setPosition(new Point(npc.getRx0() + 50, npc.getCy()));
map.addMapObject(npc);
}
rs.close();
ps.close();
con.close();
} catch(SQLException ex) {
System.out.println("fix npc error ");
ex.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException ex) {
}
}
if (ps != null) {
try {
ps.close();
} catch (SQLException ex) {
}
}
if (rs != null) {
try {
rs.close();
} catch (SQLException ex) {
}
}
}
}
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("SELECT * FROM spawnnpc WHERE mapid = ?");
ps.setInt(1, mapid);
rs = ps.executeQuery();
while (rs.next()) {
MapleNPC npc = MapleLifeFactory.getNPC(rs.getInt("npcid"));
npc.setCy(rs.getInt("cy"));
npc.setRx0(rs.getInt("rx0"));
npc.setRx1(rs.getInt("rx1"));
npc.setFh(rs.getInt("fh"));
npc.setPosition(new Point(npc.getRx0() + 50, npc.getCy()));
map.addMapObject(npc);
}
rs.close();
ps.close();
con.close();
} catch(SQLException ex) {
System.out.println("fix npc error ");
ex.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException ex) {
}
}
if (ps != null) {
try {
ps.close();
} catch (SQLException ex) {
}
}
if (rs != null) {
try {
rs.close();
} catch (SQLException ex) {
}
}
}
}
-----
다음
public final MapleMap getMap(final int mapid, final boolean respawns, final boolean npcs, final boolean reactors) {
를 찾아 try문 밑에
getFixNpc(map, mapid);
----
그리고 커맨드 추가
public static class 고정엔피시 extends CommandExecute {
@Override
public int execute(MapleClient c, String[] splitted) {
int npcId = Integer.parseInt(splitted[1]);
MapleNPC npc = MapleLifeFactory.getNPC(npcId);
if (npc != null && !npc.getName().equals("MISSINGNO")) {
npc.setPosition(c.getPlayer().getPosition());
npc.setCy(c.getPlayer().getPosition().y);
npc.setRx0(c.getPlayer().getPosition().x + 50);
npc.setRx1(c.getPlayer().getPosition().x - 50);
npc.setFh(c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
c.getPlayer().getMap().addMapObject(npc);
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc, true));
} else {
c.getPlayer().dropMessage(6, "WZ에 존재하지 않는 NPC를 입력했습니다.");
return 0;
}
try {
String sql = "INSERT INTO spawnnpc(npcid, rx0, rx1, cy, fh, mapid) VALUES (? ,? ,? ,? ,? ,?)";
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement(sql);
ps.setInt(1, npcId);
ps.setInt(2, c.getPlayer().getPosition().x - 50);
ps.setInt(3, c.getPlayer().getPosition().x + 50);
ps.setInt(4, c.getPlayer().getPosition().y);
ps.setInt(5, c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
ps.setInt(6, c.getPlayer().getMapId());
ps.executeUpdate();
ps.close();
} catch (Exception e) {
System.err.println("fix npc error.");
e.printStackTrace();
}
return 1;
}
}
public int execute(MapleClient c, String[] splitted) {
int npcId = Integer.parseInt(splitted[1]);
MapleNPC npc = MapleLifeFactory.getNPC(npcId);
if (npc != null && !npc.getName().equals("MISSINGNO")) {
npc.setPosition(c.getPlayer().getPosition());
npc.setCy(c.getPlayer().getPosition().y);
npc.setRx0(c.getPlayer().getPosition().x + 50);
npc.setRx1(c.getPlayer().getPosition().x - 50);
npc.setFh(c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
c.getPlayer().getMap().addMapObject(npc);
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc, true));
} else {
c.getPlayer().dropMessage(6, "WZ에 존재하지 않는 NPC를 입력했습니다.");
return 0;
}
try {
String sql = "INSERT INTO spawnnpc(npcid, rx0, rx1, cy, fh, mapid) VALUES (? ,? ,? ,? ,? ,?)";
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement(sql);
ps.setInt(1, npcId);
ps.setInt(2, c.getPlayer().getPosition().x - 50);
ps.setInt(3, c.getPlayer().getPosition().x + 50);
ps.setInt(4, c.getPlayer().getPosition().y);
ps.setInt(5, c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
ps.setInt(6, c.getPlayer().getMapId());
ps.executeUpdate();
ps.close();
} catch (Exception e) {
System.err.println("fix npc error.");
e.printStackTrace();
}
return 1;
}
}
!고정엔피시 엔피시코드

피카츄염 님의 최근 댓글
ㅋㅋ 2018 05.29 클라 안되는대ㅔ여 2018 02.16 감사합니다 2018 02.12 클라 보내주세요 go_to_r@naver.com 2018 02.09 ㄳ 2018 02.01