세력 시스템
src - constants - AboutHina.java 을 열어주세요
public static String a1 = "블랙윙";
public static String a2 = "레지스탕스";
public static String buff1 = "분노";
public static String buff2 = "홀리심볼";
public static int setpoint = 100;
추가해주세요
-----------------------------------------------------------------------------------------------------------------------
src - client - HinaPlayer.java 을 열어주세요
public void setSia(int a) {
sia = a;
}
public final int getSia() {
return sia;
}
public void HelloSia() {
client.getSession().write(MainPacketCreator.getNPCTalk(9030200, (byte) 0, "당신은 #e" + AllianceName(getSia()) + "#n 세력 이군요?\r\n오늘의 #e" + AllianceName(getSia()) + "#n 세력의 버프는#b" + AboutHina.buff1 + "#k입니다.", "00 00", (byte) 0));
}
public void HelloSia1() {
client.getSession().write(MainPacketCreator.getNPCTalk(9030200, (byte) 0, "당신은 #e" + AllianceName(getSia()) + "#n 세력 이군요?\r\n오늘의 #e" + AllianceName(getSia()) + "#n 세력의 버프는#r" + AboutHina.buff2 + "#k입니다.", "00 00", (byte) 0));
}
}
추가 해주세요
-------------------------------------------------------------------------------------------------------------------
src - server - maps - HinaMap,java 열어주세요
public int getForceMob(int mapid,int ch) {
Connection con = MYSQL.getConnection();
PreparedStatement ps;
try {
ps = con.prepareStatement("SELECT * FROM forcemap where mapid = ? AND channel=?");
ps.setInt(1, mapid);
ps.setInt(2, ch);//아마 될꺼임
ResultSet rs = ps.executeQuery();
if (rs.next())
return rs.getInt("mobcount");
ps.close();
rs.close();
} catch (SQLException ex) {
}
return 0;
}
public int getForceMap(int mapid,int ch) {
Connection con = MYSQL.getConnection();
PreparedStatement ps;
try {
ps = con.prepareStatement("SELECT * FROM forcemap where mapid = ? AND channel=?");
ps.setInt(1, mapid);
ps.setInt(2, ch);//아마 될꺼임
ResultSet rs = ps.executeQuery();
if (rs.next())
return rs.getInt("force");
ps.close();
rs.close();
} catch (SQLException ex) {
}
return 0;
}
public final void killMonster(final HinaMonster monster, final HinaPlayer chr, final boolean withDrops, final boolean second, final byte animation) {
검색 해주세요
} else if (alliance[channel] == 0 && chr.getEventInstance() == null) {
gainMobCount((byte) chr.getSia());
int a=0;
if (AboutHina.setpoint >= (getMobCount((byte) chr.getSia()))) {
double rnd = (Math.round(((double) getMobCount((byte) chr.getSia()) / (double) AboutHina.setpoint * 100.0D) * 100) / 100.0D);//왜하필 더블이니 ㅋㅋㅋㅋㅋㅋ
// chr.send(UIPacket.showInfo(chr.AllianceName(chr.getSia()) + "세력 <" + getMapName() + "> 점령율 " + rnd + "%"));
for(int i=0;i<=rnd;i++){
a=i;
}
//점령된맵 확인 메소드
chr.send(UIPacket.AchievementRatio(a));//해보셔요
if ((getMobCount((byte) chr.getSia())) % 100 == 0) {
SaveMobCount((byte) chr.getSia(), false);
}
} else {
alliance[channel] = (byte) chr.getSia();
client.AllianceSystem.addForceMap(mapid, channel, (byte) chr.getSia());
SaveMobCount((byte) chr.getSia(), true);
WorldBroadcasting.broadcastGM(MainPacketCreator.getGMText(8, "[시스템] " + channel + "채널 < " + getMapName() + " > " + chr.AllianceName(chr.getSia()) + "세력이 점령하였습니다.").getBytes());
chr.gainSpirit(4001129, 10);
chr.checkforcemap(true);
chr.getClient().getSession().write(MainPacketCreator.getNPCTalk(2007, (byte) 0, "#r축하드립니다!!#k\r\n맵점령에 성공하여 점령 코인 10개를 휙득하셧습니다.", "00 00", (byte) 0));
client.AllianceSystem.main();
}
}
if (withDrops) {
if (dropOwner == null) {
dropOwner = chr;
}
dropFromMonster(dropOwner, monster);
}
}
추가 해주세요
--------------------------------------------------------------------------------------------------------------------
src - client - AllianceSystem.java 라는 파일을 만들어주세요
package client;
import constants.AboutHina;
import database.MYSQL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import launch.ChannelServer;
import server.maps.HinaMap;
import tools.Pair;
public class AllianceSystem
{
public static int dntmd = 0;
public static int[] event = new int[AboutHina.CuC + 1];
private static Map<Integer, Pair<Integer, Byte>> forceGroup = new HashMap();
private static List<Pair<Byte, Integer>> point = new LinkedList();
private static Map<Pair<Integer, Byte>, Byte> forceMap = new HashMap();
public static void main() {//이거...?? 점령맵 메소드임.끄어어 하하 뎨햇 필요없음
try {
HinaMap map;
PreparedStatement ps1 = MYSQL.getConnection().prepareStatement("SELECT * FROM forcemap");
ResultSet rs1 = ps1.executeQuery();
while (rs1.next()) {
if (rs1.getInt("mobcount") >= AboutHina.setpoint);
addForceMap(rs1.getInt("mapid"), rs1.getByte("channel"), rs1.getByte("force"));
map = ChannelServer.getInstance(rs1.getInt("channel")).getMapFactory().getMap(rs1.getInt("mapid"));
map.alliance[rs1.getInt("channel")] = rs1.getByte("force");
map.setTime(rs1.getLong("time"));
}
rs1.close();
ps1.close();
} catch (SQLException e) {
System.out.println("AllianceSystem Error");
}
}
public static String allianc() {
if(dntmd == 1) {
return AboutHina.a1;
} else {
return AboutHina.a2;
}
}
public static void Savedntmd(int force) {
Connection con = MYSQL.getConnection();
PreparedStatement ps = null;
try {
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
con.setAutoCommit(false);
ps = MYSQL.getConnection().prepareStatement("UPDATE auth_server_login SET `force` = ?");
ps.setInt(1, force);
ps.execute();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void relode() {
int num = 0;
try {
PreparedStatement ps = MYSQL.getConnection().prepareStatement("SELECT * FROM auth_server_login WHERE loginserverid = ?");
ps.setInt(1, 1);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
dntmd = rs.getByte("force");
}
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
num = dntmd;
}
public static int getForcePoint(byte force) {
try {
int pointing = 0;
if (point.isEmpty()) {
try {
PreparedStatement ps = MYSQL.getConnection().prepareStatement("SELECT * FROM `force` Where `forceid` = ?");
ps.setInt(1, force);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
point.add(new Pair<Byte,Integer>(rs.getByte("forceid"),rs.getInt("point")));
}
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
Iterator<Pair<Byte,Integer>> allpoint;
allpoint = point.iterator();
Pair<Byte,Integer> pointall;
while (allpoint.hasNext()) {
pointall = allpoint.next();
if (pointall.getLeft() == force) {
pointing += pointall.getRight();
}
}
return pointing;
} catch (Exception ex) {
ex.printStackTrace();
return 0;
}
}
public static void gainForcePoint(int point, byte i) {
try {
PreparedStatement ps = MYSQL.getConnection().prepareStatement("UPDATE `force` SET `point` = ? WHERE forceid = ?");
ps.setInt(1, point);
ps.setByte(2, i);
ps.execute();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Pair<Integer, Byte> getForceGroup(int charid) {
synchronized (forceGroup) {
if (forceGroup.containsKey(charid)) {
return forceGroup.get(charid);
}
}
return new Pair<Integer, Byte>(-1, (byte) -1);
}
public static HashMap<Integer, Pair<Integer, Byte>> getForceGroups(byte force) {
try {
synchronized (forceGroup) {
HashMap<Integer, Pair<Integer, Byte>> forceGroups = new HashMap<Integer, Pair<Integer, Byte>>();
for (final Map.Entry<Integer,Pair<Integer, Byte>> forces : forceGroup.entrySet()) {
if (forces.getValue().getRight() == force) {
forceGroups.put(forces.getKey(), forces.getValue());
}
}
return forceGroups;
}
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
public static void addForceGroup(int charid, int channel, byte forceid) {
synchronized (forceGroup) {
forceGroup.put(charid, new Pair<Integer, Byte>(channel, forceid));
}
}
public static void addForceMap(int mapid, byte channel, byte forceid) {
synchronized (forceMap) {
forceMap.put(new Pair<Integer, Byte>(mapid,channel), forceid);
}
}
public static void removeForceMap(int mapid,byte channel) {
synchronized (forceMap) {
if (forceMap.containsKey(new Pair<Integer, Byte>(mapid,channel))) {
forceMap.remove(new Pair<Integer, Byte>(mapid,channel));
}
}
}
public static HashMap<Pair<Integer, Byte>,Byte> getForceMaps(int force) {
try {
synchronized (forceMap) {
HashMap<Pair<Integer, Byte>,Byte> forceMaps = new HashMap<Pair<Integer, Byte>,Byte>();
for (final Map.Entry<Pair<Integer, Byte>,Byte> maps : forceMap.entrySet()) {
if (maps.getValue() == force) {
forceMaps.put(maps.getKey(), maps.getValue());
}
}
return forceMaps;
}
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
}
위의 내용을 넣어주세요
---------------------------------------------------------------------------------------------------------------------
src - community - AllianceSystem.java 라는 파일을 만들어주세요
package community;
import constants.AboutHina;
import database.MYSQL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import launch.ChannelServer;
import server.maps.HinaMap;
import tools.Pair;
public class AllianceSystem {
public static int dntmd = 0;
public static int[] event = new int[AboutHina.CuC + 1];
private static Map<Integer, Pair<Integer, Byte>> forceGroup = new HashMap();
private static List<Pair<Byte, Integer>> point = new LinkedList();
private static Map<Pair<Integer, Byte>, Byte> forceMap = new HashMap();
public static void main() {
try {
HinaMap map;
PreparedStatement ps1 = MYSQL.getConnection().prepareStatement("SELECT * FROM forcemap");
ResultSet rs1 = ps1.executeQuery();
while (rs1.next()) {
if (rs1.getInt("mobcount") >= AboutHina.setpoint);
addForceMap(rs1.getInt("mapid"), rs1.getByte("channel"), rs1.getByte("force"));
map = ChannelServer.getInstance(rs1.getInt("channel")).getMapFactory().getMap(rs1.getInt("mapid"));
map.alliance[rs1.getInt("channel")] = rs1.getByte("force");
map.setTime(rs1.getLong("time"));
}
rs1.close();
ps1.close();
} catch (SQLException e) {
System.out.println("AllianceSystem Error");
}
}
public static String allianc() {
if(dntmd == 1) {
return AboutHina.a1;
} else {
return AboutHina.a2;
}
}
public static void Savedntmd(int force) {
Connection con = MYSQL.getConnection();
PreparedStatement ps = null;
try {
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
con.setAutoCommit(false);
ps = MYSQL.getConnection().prepareStatement("UPDATE auth_server_login SET `force` = ?");
ps.setInt(1, force);
ps.execute();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void relode() {
int num = 0;
try {
PreparedStatement ps = MYSQL.getConnection().prepareStatement("SELECT * FROM auth_server_login WHERE loginserverid = ?");
ps.setInt(1, 1);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
dntmd = rs.getByte("force");
}
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
num = dntmd;
}
public static int getForcePoint(byte force) {
try {
int pointing = 0;
if (point.isEmpty()) {
try {
PreparedStatement ps = MYSQL.getConnection().prepareStatement("SELECT * FROM `force` Where `forceid` = ?");
ps.setInt(1, force);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
point.add(new Pair<Byte,Integer>(rs.getByte("forceid"),rs.getInt("point")));
}
rs.close();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
Iterator<Pair<Byte,Integer>> allpoint;
allpoint = point.iterator();
Pair<Byte,Integer> pointall;
while (allpoint.hasNext()) {
pointall = allpoint.next();
if (pointall.getLeft() == force) {
pointing += pointall.getRight();
}
}
return pointing;
} catch (Exception ex) {
ex.printStackTrace();
return 0;
}
}
public static void gainForcePoint(int point, byte i) {
try {
PreparedStatement ps = MYSQL.getConnection().prepareStatement("UPDATE `force` SET `point` = ? WHERE forceid = ?");
ps.setInt(1, point);
ps.setByte(2, i);
ps.execute();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Pair<Integer, Byte> getForceGroup(int charid) {
synchronized (forceGroup) {
if (forceGroup.containsKey(charid)) {
return forceGroup.get(charid);
}
}
return new Pair<Integer, Byte>(-1, (byte) -1);
}
public static HashMap<Integer, Pair<Integer, Byte>> getForceGroups(byte force) {
try {
synchronized (forceGroup) {
HashMap<Integer, Pair<Integer, Byte>> forceGroups = new HashMap<Integer, Pair<Integer, Byte>>();
for (final Map.Entry<Integer,Pair<Integer, Byte>> forces : forceGroup.entrySet()) {
if (forces.getValue().getRight() == force) {
forceGroups.put(forces.getKey(), forces.getValue());
}
}
return forceGroups;
}
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
public static void addForceGroup(int charid, int channel, byte forceid) {
synchronized (forceGroup) {
forceGroup.put(charid, new Pair<Integer, Byte>(channel, forceid));
}
}
public static void removeForceGroup(int charid) {
synchronized (forceGroup) {
if (forceGroup.containsKey(charid)) {
forceGroup.remove(charid);
}
}
}
public static void addForceMap(int mapid, byte channel, byte forceid) {
synchronized (forceMap) {
forceMap.put(new Pair<Integer, Byte>(mapid,channel), forceid);
}
}
public static void removeForceMap(int mapid,byte channel) {
synchronized (forceMap) {
if (forceMap.containsKey(new Pair<Integer, Byte>(mapid,channel))) {
forceMap.remove(new Pair<Integer, Byte>(mapid,channel));
}
}
}
public static HashMap<Pair<Integer, Byte>,Byte> getForceMaps(int force) {
try {
synchronized (forceMap) {
HashMap<Pair<Integer, Byte>,Byte> forceMaps = new HashMap<Pair<Integer, Byte>,Byte>();
for (final Map.Entry<Pair<Integer, Byte>,Byte> maps : forceMap.entrySet()) {
if (maps.getValue() == force) {
forceMaps.put(maps.getKey(), maps.getValue());
}
}
return forceMaps;
}
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
}
위의 내용을 넣어주세요
---------------------------------------------------------------------------------------------------------------------
src - scripting - NPCConversationManager.java 파일을 열어주세요
public String getForceMap(int force) {
try {
StringBuilder sb = new StringBuilder();
StringBuilder sp = new StringBuilder();
sb.append("#e#b::현재 ").append(getPlayer().AllianceName(force)).append(" 소유 맵::#k#l\r\n\r\n");
for (final Map.Entry<Pair<Integer, Byte>,Byte> maps : AllianceSystem.getForceMaps(force).entrySet()) {
if (maps.getKey().getRight() == 1 && ChannelServer.getInstance(maps.getKey().getRight()).getMapFactory().getMap(maps.getKey().getLeft().intValue()).getTime() != 0)
sb.append(maps.getKey().getRight()).append("채널 ").append(ChannelServer.getInstance(maps.getKey().getRight()).getMapFactory().getMap(maps.getKey().getLeft()).getMapName()).append("\r\n");
else if (maps.getKey().getRight() == 2 && ChannelServer.getInstance(maps.getKey().getRight()).getMapFactory().getMap(maps.getKey().getLeft()).getTime() != 0) {
sb.append(maps.getKey().getRight()).append("채널 ").append(ChannelServer.getInstance(maps.getKey().getRight().byteValue()).getMapFactory().getMap(maps.getKey().getLeft()).getMapName()).append("\r\n");
}
}
return sb.toString() + sp.toString();
} catch (Exception ex) {
return "";
}
}
추가 해주세요
---------------------------------------------------------------------------------------------------------------------
sql 파일을 하나 만들어주세요
-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version 6.0.0-alpha-community-nt-debug
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
--
-- Definition of table `forcemap`
--
DROP TABLE IF EXISTS `forcemap`;
CREATE TABLE `forcemap` (
`mapid` int(11) NOT NULL,
`mobcount` int(11) NOT NULL,
`force` int(1) NOT NULL,
`channel` int(2) NOT NULL,
`time` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
--
-- Dumping data for table `forcemap`
--
/*!40000 ALTER TABLE `forcemap` DISABLE KEYS */;
INSERT INTO `forcemap` (`mapid`,`mobcount`,`force`,`channel`,`time`) VALUES
/*!40000 ALTER TABLE `forcemap` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
넣고 통쿼리 읽듯이 해주시면 됩니다
--------------------------------------------------------------------------------------------------------------------
세력 버프를 주고 싶으실경우 엔피시에
if(cm.getPlayer().getSia() == 1){
cm.getPlayer().HelloSia();
cm.giveBuff(2311003,20);
// cm.teachSkill(80000007,3,3);
cm.dispose();
} else if(cm.getPlayer().getSia() == 2){
cm.getPlayer().HelloSia1();
cm.giveBuff(1101006,20);
cm.dispose();
}else{
cm.sendOk("세력이 없다면 버프를 받을수 없습니다.");
를 넣어주시면 되고
점령한 맵을 확인하고 싶다하시면
cm.sendOk(cm.getForceMap(cm.getPlayer().getSia()));
cm.dispose();
을 넣어주시면됩니다
--------------------------------------------------------------------------------------------------------------------

cksals33 님의 최근 댓글
감사용 2017 04.03