can teleport to owned mines
This commit is contained in:
@@ -274,60 +274,84 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetCity == null)
|
if (targetCity == null){
|
||||||
return;
|
Mine mineTele = null;
|
||||||
|
for(Mine mine : Mine.getMinesToTeleportTo(player)){
|
||||||
//verify level required to teleport or repledge
|
if(mine.getObjectUUID() == msg.getCityID()){
|
||||||
|
mineTele = mine;
|
||||||
Guild toGuild = targetCity.getGuild();
|
}
|
||||||
|
}
|
||||||
if (toGuild != null)
|
if(mineTele == null){
|
||||||
if (isTeleport) {
|
|
||||||
if (player.getLevel() < toGuild.getTeleportMin() || player.getLevel() > toGuild.getTeleportMax())
|
|
||||||
return;
|
|
||||||
} else if (player.getLevel() < toGuild.getRepledgeMin() || player.getLevel() > toGuild.getRepledgeMax())
|
|
||||||
return;
|
return;
|
||||||
|
}else {
|
||||||
|
int time = MBServerStatics.TELEPORT_TIME_IN_SECONDS;
|
||||||
|
msg.setTeleportTime(time);
|
||||||
|
Building tower = Mine.getTower(mineTele);
|
||||||
|
if (tower == null)
|
||||||
|
return;
|
||||||
|
Vector3fImmutable teleportLoc = Vector3fImmutable.getRandomPointOnCircle(tower.getLoc(), 10);
|
||||||
|
if (time > 0) {
|
||||||
|
//TODO add timer to teleport
|
||||||
|
TeleportJob tj = new TeleportJob(player, npc, teleportLoc, origin, true);
|
||||||
|
JobScheduler.getInstance().scheduleJob(tj, time * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//finish porting to a city
|
||||||
|
//verify level required to teleport or repledge
|
||||||
|
|
||||||
boolean joinedGuild = false;
|
Guild toGuild = targetCity.getGuild();
|
||||||
|
|
||||||
//if repledge, reguild the player
|
if (toGuild != null)
|
||||||
|
if (isTeleport) {
|
||||||
|
if (player.getLevel() < toGuild.getTeleportMin() || player.getLevel() > toGuild.getTeleportMax())
|
||||||
|
return;
|
||||||
|
} else if (player.getLevel() < toGuild.getRepledgeMin() || player.getLevel() > toGuild.getRepledgeMax())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!isTeleport)
|
boolean joinedGuild = false;
|
||||||
joinedGuild = GuildManager.joinGuild(player, targetCity.getGuild(), targetCity.getObjectUUID(), GuildHistoryType.JOIN);
|
|
||||||
|
|
||||||
int time;
|
//if repledge, reguild the player
|
||||||
|
|
||||||
if (!isTeleport) //repledge
|
if (!isTeleport)
|
||||||
time = MBServerStatics.REPLEDGE_TIME_IN_SECONDS;
|
joinedGuild = GuildManager.joinGuild(player, targetCity.getGuild(), targetCity.getObjectUUID(), GuildHistoryType.JOIN);
|
||||||
else
|
|
||||||
time = MBServerStatics.TELEPORT_TIME_IN_SECONDS;
|
|
||||||
|
|
||||||
//resend message
|
int time;
|
||||||
msg.setTeleportTime(time);
|
|
||||||
|
|
||||||
if ((!isTeleport && joinedGuild) || (isTeleport)) {
|
if (!isTeleport) //repledge
|
||||||
|
time = MBServerStatics.REPLEDGE_TIME_IN_SECONDS;
|
||||||
|
else
|
||||||
|
time = MBServerStatics.TELEPORT_TIME_IN_SECONDS;
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
//resend message
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
msg.setTeleportTime(time);
|
||||||
|
|
||||||
|
if ((!isTeleport && joinedGuild) || (isTeleport)) {
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
//teleport player to city
|
||||||
|
|
||||||
|
Vector3fImmutable teleportLoc;
|
||||||
|
|
||||||
|
if (targetCity.getTOL().getRank() == 8)
|
||||||
|
teleportLoc = targetCity.getTOL().getStuckLocation();
|
||||||
|
else
|
||||||
|
teleportLoc = Vector3fImmutable.getRandomPointOnCircle(targetCity.getTOL().getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
|
||||||
|
|
||||||
|
if (time > 0) {
|
||||||
|
//TODO add timer to teleport
|
||||||
|
TeleportJob tj = new TeleportJob(player, npc, teleportLoc, origin, true);
|
||||||
|
JobScheduler.getInstance().scheduleJob(tj, time * 1000);
|
||||||
|
} else if (joinedGuild) {
|
||||||
|
player.teleport(teleportLoc);
|
||||||
|
player.setSafeMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//teleport player to city
|
|
||||||
|
|
||||||
Vector3fImmutable teleportLoc;
|
|
||||||
|
|
||||||
if (targetCity.getTOL().getRank() == 8)
|
|
||||||
teleportLoc = targetCity.getTOL().getStuckLocation();
|
|
||||||
else
|
|
||||||
teleportLoc = Vector3fImmutable.getRandomPointOnCircle(targetCity.getTOL().getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
|
|
||||||
|
|
||||||
if (time > 0) {
|
|
||||||
//TODO add timer to teleport
|
|
||||||
TeleportJob tj = new TeleportJob(player, npc, teleportLoc, origin, true);
|
|
||||||
JobScheduler.getInstance().scheduleJob(tj, time * 1000);
|
|
||||||
} else if (joinedGuild) {
|
|
||||||
player.teleport(teleportLoc);
|
|
||||||
player.setSafeMode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PowersBase getPowerforHermit(NPC npc) {
|
private static PowersBase getPowerforHermit(NPC npc) {
|
||||||
|
|||||||
@@ -673,8 +673,11 @@ public class Mine extends AbstractGameObject {
|
|||||||
_playerMemory.removeAll(toRemove);
|
_playerMemory.removeAll(toRemove);
|
||||||
}
|
}
|
||||||
public static Building getTower(Mine mine){
|
public static Building getTower(Mine mine){
|
||||||
|
Building tower = BuildingManager.getBuildingFromCache(mine.buildingID);
|
||||||
return null;
|
if(tower != null)
|
||||||
|
return tower;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
public static void serializeForClientMsgTeleport(Mine mine, ByteBufferWriter writer) {
|
public static void serializeForClientMsgTeleport(Mine mine, ByteBufferWriter writer) {
|
||||||
AbstractCharacter guildRuler;
|
AbstractCharacter guildRuler;
|
||||||
@@ -685,17 +688,18 @@ public class Mine extends AbstractGameObject {
|
|||||||
// Cities aren't a mine without a TOL. Time to early exit.
|
// Cities aren't a mine without a TOL. Time to early exit.
|
||||||
// No need to spam the log here as non-existant TOL's are indicated
|
// No need to spam the log here as non-existant TOL's are indicated
|
||||||
// during bootstrap routines.
|
// during bootstrap routines.
|
||||||
|
Building tower = Mine.getTower(mine);
|
||||||
|
if (tower == null) {
|
||||||
|
|
||||||
if (Mine.getTower(mine) == null) {
|
Logger.error("NULL TOWER FOR " + mine.zoneName + " mine");
|
||||||
|
return;
|
||||||
Logger.error("NULL TOL FOR " + mine.zoneName + " mine");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Assign mine owner
|
// Assign mine owner
|
||||||
|
|
||||||
if (Mine.getTower(mine) != null && Mine.getTower(mine).getOwner() != null)
|
if (tower.getOwner() != null)
|
||||||
guildRuler = Mine.getTower(mine).getOwner();
|
guildRuler = tower.getOwner();
|
||||||
else
|
else
|
||||||
guildRuler = null;
|
guildRuler = null;
|
||||||
|
|
||||||
@@ -712,7 +716,7 @@ public class Mine extends AbstractGameObject {
|
|||||||
// Begin Serialzing soverign guild data
|
// Begin Serialzing soverign guild data
|
||||||
writer.putInt(mine.getObjectType().ordinal());
|
writer.putInt(mine.getObjectType().ordinal());
|
||||||
writer.putInt(mine.getObjectUUID());
|
writer.putInt(mine.getObjectUUID());
|
||||||
writer.putString(Mine.getTower(mine).getName());
|
writer.putString(mine.zoneName + " Mine");
|
||||||
writer.putInt(rulingGuild.getObjectType().ordinal());
|
writer.putInt(rulingGuild.getObjectType().ordinal());
|
||||||
writer.putInt(rulingGuild.getObjectUUID());
|
writer.putInt(rulingGuild.getObjectUUID());
|
||||||
|
|
||||||
@@ -767,11 +771,8 @@ public class Mine extends AbstractGameObject {
|
|||||||
else
|
else
|
||||||
writer.putString(rulingNation.getName());
|
writer.putString(rulingNation.getName());
|
||||||
|
|
||||||
if(Mine.getTower(mine) != null) {
|
writer.putInt(1);
|
||||||
writer.putInt(Mine.getTower(mine).getRank());
|
|
||||||
} else{
|
|
||||||
writer.putInt(1);
|
|
||||||
}
|
|
||||||
writer.putInt(0xFFFFFFFF);
|
writer.putInt(0xFFFFFFFF);
|
||||||
|
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
@@ -781,20 +782,17 @@ public class Mine extends AbstractGameObject {
|
|||||||
else
|
else
|
||||||
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName());
|
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName());
|
||||||
|
|
||||||
|
|
||||||
writer.putLocalDateTime(LocalDateTime.now());
|
writer.putLocalDateTime(LocalDateTime.now());
|
||||||
|
|
||||||
// writer.put((byte) mine.established.getDayOfMonth());
|
if(tower != null) {
|
||||||
// writer.put((byte) mine.established.minusMonths(1).getMonth().getValue());
|
writer.putFloat(tower.loc.x);
|
||||||
// writer.putInt((int) years);
|
writer.putFloat(tower.loc.y);
|
||||||
// writer.put((byte) hours);
|
writer.putFloat(tower.loc.z);
|
||||||
// writer.put((byte) minutes);
|
} else{
|
||||||
// writer.put((byte) seconds);
|
writer.putFloat(0);
|
||||||
|
writer.putFloat(0);
|
||||||
writer.putFloat(Mine.getTower(mine).loc.x);
|
writer.putFloat(0);
|
||||||
writer.putFloat(Mine.getTower(mine).loc.y);
|
}
|
||||||
writer.putFloat(Mine.getTower(mine).loc.z);
|
|
||||||
|
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
|
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user