Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b944847b8a | |||
| cdf6465f60 |
@@ -24,3 +24,5 @@
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
*.code-workspace
|
||||
|
||||
|
||||
+16
-33
@@ -9,13 +9,15 @@
|
||||
package engine;
|
||||
|
||||
import ch.claude_martin.enumbitset.EnumBitSetHelper;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.ItemBase;
|
||||
import engine.objects.Shrine;
|
||||
import engine.objects.Zone;
|
||||
import engine.powers.EffectsBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -137,8 +139,8 @@ public class Enum {
|
||||
HALFGIANTMALE(2010, MonsterType.HalfGiant, RunSpeed.STANDARD, CharacterSex.MALE, 1.15f),
|
||||
HUMANMALE(2011, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.MALE, 1),
|
||||
HUMANFEMALE(2012, MonsterType.Human, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
|
||||
IREKEIMALE(2013, MonsterType.Irekei, RunSpeed.IREKEI, CharacterSex.MALE, 1.1f),
|
||||
IREKEIFEMALE(2014, MonsterType.Irekei, RunSpeed.IREKEI, CharacterSex.FEMALE, 1.1f),
|
||||
IREKEIMALE(2013, MonsterType.Irekei, RunSpeed.STANDARD, CharacterSex.MALE, 1.1f),
|
||||
IREKEIFEMALE(2014, MonsterType.Irekei, RunSpeed.STANDARD, CharacterSex.FEMALE, 1.1f),
|
||||
SHADEMALE(2015, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.MALE, 1),
|
||||
SHADEFEMALE(2016, MonsterType.Shade, RunSpeed.STANDARD, CharacterSex.FEMALE, 1),
|
||||
MINOMALE(2017, MonsterType.Minotaur, RunSpeed.MINOTAUR, CharacterSex.MALE, 1.3f),
|
||||
@@ -170,8 +172,6 @@ public class Enum {
|
||||
}
|
||||
|
||||
public static RaceType getRaceTypebyRuneID(int runeID) {
|
||||
if(runeID == 1999)
|
||||
return _raceTypeByID.get(2017);
|
||||
return _raceTypeByID.get(runeID);
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ public class Enum {
|
||||
SENTINEL(0, 0, 0, 0, 0, 0, 0),
|
||||
STANDARD(6.1900001f, 13.97f, 4.2199998f, 13.97f, 6.3299999f, 18.379999f, 6.5f),
|
||||
CENTAUR(6.1900001f, 16.940001f, 5.5500002f, 16.940001f, 6.3299999f, 18.379999f, 6.5f),
|
||||
MINOTAUR(6.6300001f, 15.95f, 4.2199998f, 15.95f, 6.3299999f, 18.379999f, 6.5f),
|
||||
IREKEI(6.499500105f, 14.6685f, 4.2199998f, 14.6685f, 6.3299999f, 18.379999f, 6.5f);
|
||||
MINOTAUR(6.6300001f, 15.95f, 4.2199998f, 15.95f, 6.3299999f, 18.379999f, 6.5f);
|
||||
|
||||
private float walkStandard;
|
||||
private float walkCombat;
|
||||
private float runStandard;
|
||||
@@ -469,14 +469,11 @@ public class Enum {
|
||||
|
||||
// 14001 does not have a banestone to bind at
|
||||
|
||||
if (ruinZone.getLoadNum() == 14001) {
|
||||
if (ruinZone.getLoadNum() == 14001)
|
||||
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30);
|
||||
}else {
|
||||
//spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc()
|
||||
//.add(new Vector3fImmutable(-196.016f, 2.812f, 203.621f)), 30);
|
||||
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(BuildingManager.getBuilding(27977).loc,30f);
|
||||
|
||||
}
|
||||
else
|
||||
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc()
|
||||
.add(new Vector3fImmutable(-196.016f, 2.812f, 203.621f)), 30);
|
||||
}
|
||||
|
||||
|
||||
@@ -779,7 +776,6 @@ public class Enum {
|
||||
Combat,
|
||||
Spires,
|
||||
Snare,
|
||||
Snared,
|
||||
Stun,
|
||||
Blind,
|
||||
Root,
|
||||
@@ -882,7 +878,6 @@ public class Enum {
|
||||
Siege,
|
||||
Slash,
|
||||
Snare,
|
||||
Snared,
|
||||
Sorcery,
|
||||
Spear,
|
||||
SpearMastery,
|
||||
@@ -962,17 +957,6 @@ public class Enum {
|
||||
Wizardry;
|
||||
|
||||
public static SourceType GetSourceType(String modName) {
|
||||
switch(modName){
|
||||
case "Slashing":
|
||||
modName = "Slash";
|
||||
break;
|
||||
case "Crushing":
|
||||
modName = "Crush";
|
||||
break;
|
||||
case "Piercing":
|
||||
modName = "Pierce";
|
||||
break;
|
||||
}
|
||||
SourceType returnMod;
|
||||
if (modName.isEmpty())
|
||||
return SourceType.None;
|
||||
@@ -1032,7 +1016,6 @@ public class Enum {
|
||||
Silence,
|
||||
Slash,
|
||||
Snare,
|
||||
Snared,
|
||||
Stance,
|
||||
Stun,
|
||||
Summon,
|
||||
@@ -1157,7 +1140,6 @@ public class Enum {
|
||||
SkillDebuff,
|
||||
SlashResistanceDebuff,
|
||||
Snare,
|
||||
Snared,
|
||||
StackableAttrCONBuff,
|
||||
StackableAttrDEXBuff,
|
||||
StackableAttrSTRBuff,
|
||||
@@ -1214,6 +1196,7 @@ public class Enum {
|
||||
Durability,
|
||||
ExclusiveDamageCap,
|
||||
Fade,
|
||||
Fear,
|
||||
Fly,
|
||||
Health,
|
||||
HealthFull,
|
||||
@@ -2324,9 +2307,9 @@ public class Enum {
|
||||
|
||||
public enum CityBoundsType {
|
||||
|
||||
GRID(544),
|
||||
ZONE(672),
|
||||
PLACEMENT(673);
|
||||
GRID(640),
|
||||
ZONE(875),
|
||||
PLACEMENT(876);
|
||||
|
||||
public final float extents;
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ import engine.net.AbstractNetMsg;
|
||||
import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.net.client.msg.LoadCharacterMsg;
|
||||
import engine.net.client.msg.LoadStructureMsg;
|
||||
import engine.net.client.msg.MoveToPointMsg;
|
||||
import engine.net.client.msg.UnloadObjectsMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -518,10 +521,10 @@ public enum InterestManager implements Runnable {
|
||||
|
||||
// Update loaded upbjects lists
|
||||
|
||||
player.isBoxed = PlayerCharacter.checkIfBoxed(player);
|
||||
player.setDirtyLoad(true);
|
||||
updateStaticList(player, origin);
|
||||
updateMobileList(player, origin);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) {
|
||||
|
||||
@@ -10,13 +10,17 @@
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.objects.Bane;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class dbBaneHandler extends dbHandlerBase {
|
||||
|
||||
@@ -85,139 +89,6 @@ public class dbBaneHandler extends dbHandlerBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean SET_BANE_TIME_NEW(int hour, int cityUUID) {
|
||||
hour += 12; // Adjust hour
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement getStatement = connection.prepareStatement("SELECT `placementDate`, `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?");
|
||||
PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `time_set`=? WHERE `cityUUID`=?")) {
|
||||
|
||||
// Retrieve placementDate and liveDate
|
||||
getStatement.setInt(1, cityUUID);
|
||||
try (ResultSet rs = getStatement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
DateTime placementDate = new DateTime(rs.getTimestamp("placementDate").getTime());
|
||||
Timestamp liveDateTimestamp = rs.getTimestamp("liveDate");
|
||||
|
||||
// Explicitly check if liveDate is null
|
||||
DateTime toSet;
|
||||
if (liveDateTimestamp == null) {
|
||||
// If liveDate is null, default to placementDate
|
||||
toSet = placementDate;
|
||||
} else {
|
||||
// If liveDate is not null, use it
|
||||
DateTime liveDate = new DateTime(liveDateTimestamp.getTime());
|
||||
toSet = liveDate;
|
||||
}
|
||||
|
||||
// Adjust the time
|
||||
toSet = toSet.withHourOfDay(hour).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0);
|
||||
|
||||
// Update liveDate and time_set flag
|
||||
updateStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis()));
|
||||
updateStatement.setInt(2, 1); // time_set flag
|
||||
updateStatement.setInt(3, cityUUID);
|
||||
|
||||
updateStatement.execute();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean SET_BANE_DAY_NEW(int dayOffset, int cityUUID) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement getStatement = connection.prepareStatement("SELECT `placementDate`, `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?");
|
||||
PreparedStatement updateStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=?, `day_set`=? WHERE `cityUUID`=?")) {
|
||||
|
||||
// Retrieve placementDate and liveDate
|
||||
getStatement.setInt(1, cityUUID);
|
||||
try (ResultSet rs = getStatement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
DateTime placementDate = new DateTime(rs.getTimestamp("placementDate").getTime());
|
||||
Timestamp liveDateTimestamp = rs.getTimestamp("liveDate");
|
||||
|
||||
// Explicitly check if liveDate is null
|
||||
DateTime liveDate;
|
||||
if (liveDateTimestamp == null) {
|
||||
// If liveDate is null, default to placementDate
|
||||
liveDate = placementDate;
|
||||
} else {
|
||||
// If liveDate is not null, use it
|
||||
liveDate = new DateTime(liveDateTimestamp.getTime());
|
||||
}
|
||||
|
||||
// Calculate the new liveDate while preserving the time component
|
||||
DateTime updatedDate = placementDate.plusDays(dayOffset)
|
||||
.withHourOfDay(liveDate.getHourOfDay())
|
||||
.withMinuteOfHour(liveDate.getMinuteOfHour())
|
||||
.withSecondOfMinute(liveDate.getSecondOfMinute())
|
||||
.withMillisOfSecond(liveDate.getMillisOfSecond());
|
||||
|
||||
// Update liveDate and day_set flag
|
||||
updateStatement.setTimestamp(1, new java.sql.Timestamp(updatedDate.getMillis()));
|
||||
updateStatement.setInt(2, 1); // day_set flag
|
||||
updateStatement.setInt(3, cityUUID);
|
||||
|
||||
updateStatement.execute();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean SET_BANE_CAP_NEW(int count, int cityUUID) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_size`=? WHERE `cityUUID`=?")) {
|
||||
|
||||
preparedStatement.setInt(1, count);
|
||||
preparedStatement.setLong(2, cityUUID);
|
||||
|
||||
preparedStatement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_set`=? WHERE `cityUUID`=?")) {
|
||||
|
||||
preparedStatement.setInt(1, 1);
|
||||
preparedStatement.setLong(2, cityUUID);
|
||||
|
||||
preparedStatement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `cap_size`=? WHERE `cityUUID`=?")) {
|
||||
|
||||
preparedStatement.setInt(1, count);
|
||||
preparedStatement.setLong(2, cityUUID);
|
||||
|
||||
preparedStatement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean REMOVE_BANE(Bane bane) {
|
||||
|
||||
if (bane == null)
|
||||
@@ -236,25 +107,4 @@ public class dbBaneHandler extends dbHandlerBase {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public DateTime getLiveDate(int cityUUID) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT `liveDate` FROM `dyn_banes` WHERE `cityUUID`=?")) {
|
||||
|
||||
statement.setInt(1, cityUUID);
|
||||
|
||||
try (ResultSet rs = statement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
Timestamp liveDateTimestamp = rs.getTimestamp("liveDate");
|
||||
if (liveDateTimestamp != null) {
|
||||
return new DateTime(liveDateTimestamp.getTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
return null; // Return null if liveDate is not found or an error occurs
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ package engine.db.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.*;
|
||||
@@ -92,16 +95,7 @@ public class dbCityHandler extends dbHandlerBase {
|
||||
|
||||
return objectList;
|
||||
}
|
||||
public Integer GET_CAPITAL_CITY_COUNT() {
|
||||
|
||||
int cityCount = 0;
|
||||
for(Realm realm : Realm._realms.values()){
|
||||
if(realm.isRuled())
|
||||
cityCount ++;
|
||||
}
|
||||
|
||||
return cityCount;
|
||||
}
|
||||
public ArrayList<City> GET_CITIES_BY_ZONE(final int objectUUID) {
|
||||
|
||||
ArrayList<City> cityList = new ArrayList<>();
|
||||
|
||||
@@ -98,54 +98,32 @@ public class dbContractHandler extends dbHandlerBase {
|
||||
|
||||
public void LOAD_SELL_LIST_FOR_CONTRACT(final Contract contract) {
|
||||
|
||||
if(!contract.getName().contains("Sage")) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype` WHERE `contractID` = ?;")) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype` WHERE `contractID` = ?;")) {
|
||||
|
||||
preparedStatement.setInt(1, contract.getObjectUUID());
|
||||
preparedStatement.setInt(1, contract.getObjectUUID());
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
while (rs.next()) {
|
||||
|
||||
int type = rs.getInt("type");
|
||||
int value = rs.getInt("value");
|
||||
int type = rs.getInt("type");
|
||||
int value = rs.getInt("value");
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
contract.getBuyItemType().add(value);
|
||||
break;
|
||||
case 2:
|
||||
contract.getBuySkillToken().add(value);
|
||||
break;
|
||||
case 3:
|
||||
contract.getBuyUnknownToken().add(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}else{
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype`;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
int value = rs.getInt("value");
|
||||
if(!contract.getBuySkillToken().contains(value))
|
||||
contract.getBuySkillToken().add(value);
|
||||
|
||||
if(!contract.getBuyItemType().contains(value))
|
||||
switch (type) {
|
||||
case 1:
|
||||
contract.getBuyItemType().add(value);
|
||||
|
||||
if(!contract.getBuyUnknownToken().contains(value))
|
||||
break;
|
||||
case 2:
|
||||
contract.getBuySkillToken().add(value);
|
||||
break;
|
||||
case 3:
|
||||
contract.getBuyUnknownToken().add(value);
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,9 @@ public class dbEffectsBaseHandler extends dbHandlerBase {
|
||||
case Stunned:
|
||||
abstractEffectModifier = new StunnedEffectModifier(rs);
|
||||
break;
|
||||
case Fear:
|
||||
abstractEffectModifier = new FearEffectModifier(rs);
|
||||
break;
|
||||
case Value:
|
||||
abstractEffectModifier = new ValueEffectModifier(rs);
|
||||
if (effectBase != null) {
|
||||
|
||||
@@ -32,6 +32,7 @@ public abstract class dbHandlerBase {
|
||||
try {
|
||||
if (rs.next()) {
|
||||
abstractGameObject = localClass.getConstructor(ResultSet.class).newInstance(rs);
|
||||
|
||||
DbManager.addToCache(abstractGameObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -56,28 +57,12 @@ public abstract class dbHandlerBase {
|
||||
while (rs.next()) {
|
||||
|
||||
int id = rs.getInt(1);
|
||||
try {
|
||||
if (rs.getInt("capSize") == 0) {
|
||||
continue;
|
||||
}
|
||||
}catch(Exception e){
|
||||
//not a mine
|
||||
}
|
||||
|
||||
if (DbManager.inCache(localObjectType, id)) {
|
||||
objectList.add((T) DbManager.getFromCache(localObjectType, id));
|
||||
} else {
|
||||
try{
|
||||
if(rs.getInt("mineLiveHour") == 1)
|
||||
continue;
|
||||
}catch(Exception e){
|
||||
//not a mine
|
||||
}
|
||||
AbstractGameObject toAdd = localClass.getConstructor(ResultSet.class).newInstance(rs);
|
||||
DbManager.addToCache(toAdd);
|
||||
if(toAdd.getObjectType().equals(GameObjectType.Zone) && rs.getInt("canLoad") == 0){
|
||||
continue;
|
||||
}
|
||||
objectList.add((T) toAdd);
|
||||
|
||||
if (toAdd != null && toAdd instanceof AbstractWorldObject)
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.HashMap;
|
||||
|
||||
public class dbItemBaseHandler extends dbHandlerBase {
|
||||
|
||||
public static final HashMap<Integer,Float> dexReductions = new HashMap<>();
|
||||
public dbItemBaseHandler() {
|
||||
|
||||
}
|
||||
@@ -46,14 +45,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_DEX_REDUCTION(ItemBase itemBase) {
|
||||
if(dexReductions.containsKey(itemBase.getUUID())){
|
||||
itemBase.dexReduction = dexReductions.get(itemBase.getUUID());
|
||||
}else{
|
||||
itemBase.dexReduction = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_ANIMATIONS(ItemBase itemBase) {
|
||||
|
||||
ArrayList<Integer> tempList = new ArrayList<>();
|
||||
@@ -103,21 +94,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
// Check if a result was found
|
||||
if (rs.next()) {
|
||||
int ID = rs.getInt("ID");
|
||||
float factor = rs.getInt("item_bulk_factor");
|
||||
dexReductions.put(ID,factor);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
|
||||
|
||||
@@ -134,13 +134,9 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
try {
|
||||
worked = rs.getBoolean("result");
|
||||
}catch(Exception e){
|
||||
worked = false;
|
||||
}
|
||||
}
|
||||
if (rs.next())
|
||||
worked = rs.getBoolean("result");
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
@@ -500,18 +496,4 @@ public class dbItemHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean UPDATE_NUM_ITEMS(final Item item, int newValue) {
|
||||
if (item.getItemBase().getType().equals(ItemType.GOLD))
|
||||
return false;
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
|
||||
preparedStatement.setInt(1, newValue);
|
||||
preparedStatement.setLong(2, item.getObjectUUID());
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,32 +131,6 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public int BANE_COMMANDER_EXISTS(final int objectUUID) {
|
||||
|
||||
int uid = 0;
|
||||
|
||||
String query = "SELECT `UID` FROM `obj_npc` WHERE `npc_buildingID` = ? LIMIT 1;";
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(query)) {
|
||||
|
||||
preparedStatement.setInt(1, objectUUID);
|
||||
|
||||
try (ResultSet rs = preparedStatement.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
// Retrieve the UID column value
|
||||
uid = rs.getInt("UID");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
||||
public int MOVE_NPC(long npcID, long parentID, float locX, float locY, float locZ) {
|
||||
|
||||
int rowCount;
|
||||
@@ -202,18 +176,6 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void updateSpecialPricing(final NPC npc){
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET specialPrice=? WHERE UID = ?")) {
|
||||
preparedStatement.setInt(1, npc.getSpecialPrice());
|
||||
preparedStatement.setInt(2, npc.getDBID());
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
public void updateDatabase(final NPC npc) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
|
||||
@@ -13,7 +13,6 @@ import engine.Enum.GameObjectType;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.*;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -32,6 +31,7 @@ public class AddNPCCmd extends AbstractDevCmd {
|
||||
int contractID;
|
||||
String name = "";
|
||||
int level = 0;
|
||||
|
||||
if (words.length < 2) {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
@@ -39,54 +39,59 @@ public class AddNPCCmd extends AbstractDevCmd {
|
||||
try {
|
||||
contractID = Integer.parseInt(words[0]);
|
||||
level = Integer.parseInt(words[1]);
|
||||
|
||||
for (int i = 2; i < words.length; i++) {
|
||||
name += words[i];
|
||||
if (i + 1 < words.length)
|
||||
name += "";
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
throwbackError(pc,
|
||||
"Failed to parse supplied contractID or level to an Integer.");
|
||||
return; // NaN
|
||||
}
|
||||
|
||||
Contract contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
|
||||
|
||||
if (contract == null || level < 1 || level > 75) {
|
||||
throwbackError(pc,
|
||||
"Invalid addNPC Command. Need contract ID, and level");
|
||||
return; // NaN
|
||||
}
|
||||
|
||||
// Pick a random name
|
||||
if (name.isEmpty())
|
||||
name = NPCManager.getPirateName(contract.getMobbaseID());
|
||||
|
||||
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
|
||||
if (zone == null) {
|
||||
throwbackError(pc, "Failed to find zone to place npc in.");
|
||||
return;
|
||||
}
|
||||
Building building = null;
|
||||
|
||||
if (target != null)
|
||||
if (target.getObjectType() == GameObjectType.Building) {
|
||||
building = (Building)target;
|
||||
Building parentBuilding = (Building) target;
|
||||
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level);
|
||||
return;
|
||||
}
|
||||
NPC created;
|
||||
Guild guild = null;
|
||||
Vector3fImmutable loc;
|
||||
if(building != null){
|
||||
guild = building.getGuild();
|
||||
loc = building.loc;
|
||||
} else{
|
||||
loc = pc.loc;
|
||||
|
||||
NPC npc = NPC.createNPC(name, contractID,
|
||||
pc.getLoc(), null, zone, (short) level, null);
|
||||
|
||||
if (npc != null) {
|
||||
WorldGrid.addObject(npc, pc);
|
||||
ChatManager.chatSayInfo(pc,
|
||||
"NPC with ID " + npc.getDBID() + " added");
|
||||
this.setResult(String.valueOf(npc.getDBID()));
|
||||
} else {
|
||||
throwbackError(pc, "Failed to create npc of contract type "
|
||||
+ contractID);
|
||||
Logger.error(
|
||||
"Failed to create npc of contract type " + contractID);
|
||||
}
|
||||
created = NPC.createNPC(name, contractID, loc, guild, zone, (short)level, building);
|
||||
created.bindLoc = loc;
|
||||
if(building != null) {
|
||||
created.buildingUUID = building.getObjectUUID();
|
||||
created.building = building;
|
||||
NPCManager.slotCharacterInBuilding(created);
|
||||
}
|
||||
created.setLoc(created.bindLoc);
|
||||
created.updateDatabase();
|
||||
throwbackInfo(pc, "Created NPC with UUID: " + created.getObjectUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum.ItemContainerType;
|
||||
import engine.Enum.ItemType;
|
||||
import engine.Enum.OwnerType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Eighty
|
||||
*/
|
||||
public class GimmeCmd extends AbstractDevCmd {
|
||||
|
||||
public GimmeCmd() {
|
||||
super("gimme");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
int amt = 0;
|
||||
int currentGold = pc.getCharItemManager().getGoldInventory().getNumOfItems();
|
||||
amt = 10000000 - currentGold;
|
||||
if (!pc.getCharItemManager().addGoldToInventory(amt, true)) {
|
||||
throwbackError(pc, "Failed to add gold to inventory");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.chatSayInfo(pc, amt + " gold added to inventory");
|
||||
|
||||
if(pc.level < 75) {
|
||||
pc.setLevel((short) 75);
|
||||
ChatManager.chatSayInfo(pc, "Level set to 75");
|
||||
}
|
||||
pc.getCharItemManager().updateInventory();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Round up current gold in inventory to 10,000,000";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "'./gimme";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
/**
|
||||
* ./hotzone <- display the current hotzone & time remaining
|
||||
* ./hotzone random <- change hotzone to random new zone
|
||||
*/
|
||||
|
||||
public class HotzoneCmd extends AbstractDevCmd {
|
||||
|
||||
public HotzoneCmd() {
|
||||
super("hotzone");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void _doCmd(PlayerCharacter playerCharacter, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
StringBuilder data = new StringBuilder();
|
||||
String outString;
|
||||
|
||||
for (String s : words) {
|
||||
data.append(s);
|
||||
data.append(' ');
|
||||
}
|
||||
|
||||
String input = data.toString().trim();
|
||||
|
||||
if (input.length() == 0) {
|
||||
outString = "Current hotZone: " + ZoneManager.hotZone.getName() + "\r\n";
|
||||
outString += "Available hotZones: " + ZoneManager.availableHotZones();
|
||||
throwbackInfo(playerCharacter, outString);
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.equalsIgnoreCase("random")) {
|
||||
ZoneManager.generateAndSetRandomHotzone();
|
||||
outString = "New hotZone: " + ZoneManager.hotZone.getName() + "\r\n";
|
||||
outString += "Available hotZones: " + ZoneManager.availableHotZones();
|
||||
throwbackInfo(playerCharacter, outString);
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.equalsIgnoreCase("reset")) {
|
||||
ZoneManager.resetHotZones();
|
||||
throwbackInfo(playerCharacter, "Available hotZones: " + ZoneManager.availableHotZones());
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Use no arguments to see the current hotzone or \"random\" to change it randomly.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String _getUsageString() {
|
||||
return "'./hotzone [random]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,13 +15,9 @@ import engine.Enum.GameObjectType;
|
||||
import engine.Enum.TargetColor;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.PowersBase;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.util.StringUtils;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
@@ -341,9 +337,7 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += "Swimming : " + targetPC.isSwimming();
|
||||
output += newline;
|
||||
output += "isMoving : " + targetPC.isMoving();
|
||||
output += newline;
|
||||
output += "Zerg Multiplier : " + targetPC.ZergMultiplier+ newline;
|
||||
output += "Hidden : " + targetPC.getHidden();
|
||||
|
||||
break;
|
||||
|
||||
case NPC:
|
||||
@@ -498,16 +492,13 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "No building found." + newline;
|
||||
}
|
||||
|
||||
output += "Damage: " + targetMob.mobBase.getDamageMin() + " - " + targetMob.mobBase.getDamageMax() + newline;
|
||||
output += "ATR: " + targetMob.mobBase.getAttackRating() + newline;
|
||||
output += "DEF: " + targetMob.defenseRating + newline;
|
||||
output += "RANGE: " + targetMob.getRange() + newline;
|
||||
output += "Effects:" + newline;
|
||||
for(MobBaseEffects mbe : targetMob.mobBase.mobbaseEffects){
|
||||
EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken());
|
||||
output += eb.getName() + newline;
|
||||
int max = (int)(4.882 * targetMob.level + 121.0);
|
||||
if(max > 321){
|
||||
max = 321;
|
||||
}
|
||||
int min = (int)(4.469 * targetMob.level - 3.469);
|
||||
output += "Min Loot Roll = " + min;
|
||||
output += "Max Loot Roll = " + max;
|
||||
break;
|
||||
case Item: //intentional passthrough
|
||||
case MobLoot:
|
||||
@@ -538,13 +529,6 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Corpse:
|
||||
Corpse corpse = (Corpse)target;
|
||||
Long timeLeft = MBServerStatics.CORPSE_CLEANUP_TIMER_MS - (System.currentTimeMillis() - corpse.spawnedTime);
|
||||
output += "Despawn in: " + timeLeft;
|
||||
output += newline;
|
||||
break;
|
||||
}
|
||||
|
||||
throwbackInfo(pc, output);
|
||||
|
||||
@@ -16,7 +16,6 @@ import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.workthreads.HalfHourlyJobThread;
|
||||
import engine.workthreads.HourlyJobThread;
|
||||
|
||||
/**
|
||||
@@ -42,10 +41,10 @@ public class MineActiveCmd extends AbstractDevCmd {
|
||||
String trigger = args[0];
|
||||
switch (trigger) {
|
||||
case "true":
|
||||
HalfHourlyJobThread.mineWindowOpen(mine);
|
||||
HourlyJobThread.mineWindowOpen(mine);
|
||||
break;
|
||||
case "false":
|
||||
HalfHourlyJobThread.mineWindowClose(mine);
|
||||
HourlyJobThread.mineWindowClose(mine);
|
||||
break;
|
||||
default:
|
||||
this.sendUsage(pcSender);
|
||||
|
||||
@@ -49,8 +49,6 @@ public class PrintSkillsCmd extends AbstractDevCmd {
|
||||
+ skill.getModifiedAmount() + '('
|
||||
+ skill.getTotalSkillPercet() + " )");
|
||||
}
|
||||
//throwbackInfo(pc, "= = = = = NEW CALCULATIONS = = = = =");
|
||||
// PlayerCombatStats.PrintSkillsToClient(pc);
|
||||
} else
|
||||
throwbackInfo(pc, "Skills not found for player");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.objects.*;
|
||||
|
||||
@@ -57,36 +56,23 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
|
||||
public void printStatsPlayer(PlayerCharacter pc, PlayerCharacter tar) {
|
||||
String newline = "\r\n ";
|
||||
|
||||
String newOut = "Server stats for Player " + tar.getFirstName() + newline;
|
||||
newOut += "HEALTH: " + tar.getHealth() + " / " + tar.getHealthMax() + newline;
|
||||
newOut += "MANA: " + tar.getMana() + " / " + tar.getManaMax() + newline;
|
||||
newOut += "STAMINA: " + tar.getStamina() + " / " + tar.getStaminaMax() + newline;
|
||||
newOut += "Unused Stats: " + tar.getUnusedStatPoints() + newline;
|
||||
newOut += "Stats Base (Modified)" + newline;
|
||||
newOut += " Str: " + (int) tar.statStrBase + " (" + tar.getStatStrCurrent() + ')' + ", maxStr: " + tar.getStrMax() + newline;
|
||||
newOut += " Dex: " + (int) tar.statDexBase + " (" + tar.getStatDexCurrent() + ')' + ", maxDex: " + tar.getDexMax() + newline;
|
||||
newOut += " Con: " + (int) tar.statConBase + " (" + tar.getStatConCurrent() + ')' + ", maxCon: " + tar.getConMax() + newline;
|
||||
newOut += " Int: " + (int) tar.statIntBase + " (" + tar.getStatIntCurrent() + ')' + ", maxInt: " + tar.getIntMax() + newline;
|
||||
newOut += " Spi: " + (int) tar.statSpiBase + " (" + tar.getStatSpiCurrent() + ')' + ", maxSpi: " + tar.getSpiMax() + newline;
|
||||
newOut += "Move Speed: " + tar.getSpeed() + newline;
|
||||
newOut += "Health Regen: " + tar.combatStats.healthRegen + newline;
|
||||
newOut += "Mana Regen: " + tar.combatStats.manaRegen + newline;
|
||||
newOut += "Stamina Regen: " + tar.combatStats.staminaRegen + newline;
|
||||
newOut += "DEFENSE: " + tar.combatStats.defense + newline;
|
||||
newOut += "HAND ONE" + newline;
|
||||
newOut += "ATR: " + tar.combatStats.atrHandOne + newline;
|
||||
newOut += "MIN: " + tar.combatStats.minDamageHandOne + newline;
|
||||
newOut += "MAX: " + tar.combatStats.maxDamageHandOne + newline;
|
||||
newOut += "RANGE: " + tar.combatStats.rangeHandOne + newline;
|
||||
newOut += "ATTACK SPEED: " + tar.combatStats.attackSpeedHandOne + newline;
|
||||
newOut += "HAND TWO" + newline;
|
||||
newOut += "ATR: " + tar.combatStats.atrHandTwo + newline;
|
||||
newOut += "MIN: " + tar.combatStats.minDamageHandTwo + newline;
|
||||
newOut += "MAX: " + tar.combatStats.maxDamageHandTwo + newline;
|
||||
newOut += "RANGE: " + tar.combatStats.rangeHandTwo + newline;
|
||||
newOut += "ATTACK SPEED: " + tar.combatStats.attackSpeedHandTwo + newline;
|
||||
throwbackInfo(pc, newOut);
|
||||
String out = "Server stats for Player " + tar.getFirstName() + newline;
|
||||
out += "Unused Stats: " + tar.getUnusedStatPoints() + newline;
|
||||
out += "Stats Base (Modified)" + newline;
|
||||
out += " Str: " + (int) tar.statStrBase + " (" + tar.getStatStrCurrent() + ')' + ", maxStr: " + tar.getStrMax() + newline;
|
||||
out += " Dex: " + (int) tar.statDexBase + " (" + tar.getStatDexCurrent() + ')' + ", maxDex: " + tar.getDexMax() + newline;
|
||||
out += " Con: " + (int) tar.statConBase + " (" + tar.getStatConCurrent() + ')' + ", maxCon: " + tar.getConMax() + newline;
|
||||
out += " Int: " + (int) tar.statIntBase + " (" + tar.getStatIntCurrent() + ')' + ", maxInt: " + tar.getIntMax() + newline;
|
||||
out += " Spi: " + (int) tar.statSpiBase + " (" + tar.getStatSpiCurrent() + ')' + ", maxSpi: " + tar.getSpiMax() + newline;
|
||||
throwbackInfo(pc, out);
|
||||
out = "Health: " + tar.getHealth() + ", maxHealth: " + tar.getHealthMax() + newline;
|
||||
out += "Mana: " + tar.getMana() + ", maxMana: " + tar.getManaMax() + newline;
|
||||
out += "Stamina: " + tar.getStamina() + ", maxStamina: " + tar.getStaminaMax() + newline;
|
||||
out += "Defense: " + tar.getDefenseRating() + newline;
|
||||
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + newline;
|
||||
out += "Off Hand: atr: " + tar.getAtrHandTwo() + ", damage: " + tar.getMinDamageHandTwo() + " to " + tar.getMaxDamageHandTwo() + ", speed: " + tar.getSpeedHandTwo() + newline;
|
||||
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
|
||||
throwbackInfo(pc, out);
|
||||
}
|
||||
|
||||
public void printStatsMob(PlayerCharacter pc, Mob tar) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SetLevelCmd extends AbstractDevCmd {
|
||||
this.sendUsage(pc);
|
||||
return;
|
||||
}
|
||||
if (level < 1 || level > 80) {
|
||||
if (level < 1 || level > 75) {
|
||||
this.sendHelp(pc);
|
||||
return;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class SetLevelCmd extends AbstractDevCmd {
|
||||
|
||||
@Override
|
||||
protected String _getHelpString() {
|
||||
return "Sets your character's level to 'amount'. 'amount' must be between 1-80";
|
||||
return "Sets your character's level to 'amount'. 'amount' must be between 1-75";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.LootManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
@@ -11,8 +10,6 @@ import java.util.ArrayList;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
|
||||
public int simCount = 250;
|
||||
public SimulateBootyCmd() {
|
||||
super("bootysim");
|
||||
}
|
||||
@@ -27,61 +24,8 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
String newline = "\r\n ";
|
||||
|
||||
String output;
|
||||
if(target.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
|
||||
int ATR = Integer.parseInt(words[0]);
|
||||
int DEF = Integer.parseInt(words[1]);
|
||||
int attacks = Integer.parseInt(words[2]);
|
||||
|
||||
int hits = 0;
|
||||
int misses = 0;
|
||||
int defaultHits = 0;
|
||||
int defualtMisses = 0;
|
||||
|
||||
float chance = (ATR-((ATR+DEF) * 0.315f)) / ((DEF-((ATR+DEF) * 0.315f)) + (ATR-((ATR+DEF) * 0.315f)));
|
||||
float convertedChance = chance * 100;
|
||||
output = "" + newline;
|
||||
output += "DEF VS ATR SIMULATION: " + attacks + " ATTACKS SIMULATED" + newline;
|
||||
output += "DEF = " + DEF + newline;
|
||||
output += "ATR = " + ATR + newline;
|
||||
output += "CHANCE TO LAND HIT: " + convertedChance + "%" + newline;
|
||||
if(convertedChance < 5){
|
||||
output += "CHANCE ADJUSTED TO 5.0%" + newline;
|
||||
convertedChance = 5.0f;
|
||||
}
|
||||
if(convertedChance > 95){
|
||||
output += "CHANCE ADJUSTED TO 95.0%" + newline;
|
||||
convertedChance = 95.0f;
|
||||
}
|
||||
for(int i = 0; i < attacks; i++){
|
||||
int roll = ThreadLocalRandom.current().nextInt(101);
|
||||
|
||||
if(roll <= convertedChance){
|
||||
hits += 1;
|
||||
}else{
|
||||
misses += 1;
|
||||
}
|
||||
}
|
||||
|
||||
float totalHits = defaultHits + hits;
|
||||
float totalMisses = defualtMisses + misses;
|
||||
float hitPercent = Math.round(totalHits / attacks * 100);
|
||||
float missPercent = Math.round(totalMisses / attacks * 100);
|
||||
|
||||
output += "HITS LANDED: " + (defaultHits + hits) + "(" + Math.round(hitPercent) + "%)" + newline;
|
||||
output += "HITS MISSED: " + (defualtMisses + misses) + "(" + Math.round(missPercent) + "%)";
|
||||
|
||||
throwbackInfo(playerCharacter,output);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
simCount = Integer.parseInt(words[0]);
|
||||
}catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
output = "Booty Simulation: Rolls:" + simCount + newline;
|
||||
output = "Booty Simulation:" + newline;
|
||||
|
||||
Mob mob = (Mob) target;
|
||||
output += "Name: " + mob.getName() + newline;
|
||||
@@ -100,7 +44,6 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
ArrayList<Item> Resources = new ArrayList<Item>();
|
||||
ArrayList<Item> Runes = new ArrayList<Item>();
|
||||
ArrayList<Item> Contracts = new ArrayList<Item>();
|
||||
ArrayList<Item> GuardContracts = new ArrayList<Item>();
|
||||
ArrayList<Item> Offerings = new ArrayList<Item>();
|
||||
ArrayList<Item> OtherDrops = new ArrayList<Item>();
|
||||
ArrayList<Item> EquipmentDrops = new ArrayList<Item>();
|
||||
@@ -108,17 +51,14 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
int failures = 0;
|
||||
int goldAmount = 0;
|
||||
|
||||
for (int i = 0; i < simCount; ++i) {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
|
||||
try {
|
||||
mob.loadInventory();
|
||||
for (Item lootItem : mob.getCharItemManager().getInventory()) {
|
||||
switch (lootItem.getItemBase().getType()) {
|
||||
case CONTRACT: //CONTRACT
|
||||
if(lootItem.getName().contains("Captain"))
|
||||
GuardContracts.add(lootItem);
|
||||
else
|
||||
Contracts.add(lootItem);
|
||||
Contracts.add(lootItem);
|
||||
break;
|
||||
case OFFERING: //OFFERING
|
||||
Offerings.add(lootItem);
|
||||
@@ -190,17 +130,9 @@ public class SimulateBootyCmd extends AbstractDevCmd {
|
||||
}
|
||||
}
|
||||
|
||||
int baseBound = 100000;
|
||||
int levelPenalty = (int) (Math.max(0, Math.abs(50 - mob.level)) * 0.01 * 100000);
|
||||
int totalRange = baseBound + levelPenalty;
|
||||
if(mob.level >= 50){
|
||||
totalRange = baseBound;
|
||||
}
|
||||
output += "TOTAL ROLL POTENTIAL: " + totalRange + newline;
|
||||
output += "GLASS DROPS: " + GlassItems.size() + newline;
|
||||
output += "RUNE DROPS: " + Runes.size() + newline;
|
||||
output += "CONTRACTS DROPS: " + Contracts.size() + newline;
|
||||
output += "GUARD CONTRACTS DROPS: " + GuardContracts.size() + newline;
|
||||
output += "RESOURCE DROPS: " + Resources.size() + newline;
|
||||
output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
|
||||
output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline;
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class ArenaManager {
|
||||
private static final List<Arena> activeArenas = new ArrayList<>();
|
||||
public static final List<PlayerCharacter> playerQueue = new ArrayList<>();
|
||||
public static Long pulseDelay = 180000L;
|
||||
public static Long lastExecution = 0L;
|
||||
|
||||
public static void pulseArenas() {
|
||||
if(lastExecution == 0L){
|
||||
lastExecution = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if(activeArenas.isEmpty() && playerQueue.isEmpty())
|
||||
return;
|
||||
|
||||
Iterator<Arena> iterator = activeArenas.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Arena arena = iterator.next();
|
||||
if (arena.checkToComplete()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if(lastExecution + pulseDelay > System.currentTimeMillis())
|
||||
return;
|
||||
|
||||
lastExecution = System.currentTimeMillis();
|
||||
|
||||
while (playerQueue.size() > 1) {
|
||||
createArena();
|
||||
}
|
||||
}
|
||||
|
||||
public static void joinQueue(PlayerCharacter player) {
|
||||
if (!playerQueue.contains(player)) {
|
||||
playerQueue.add(player);
|
||||
}
|
||||
for(PlayerCharacter pc : playerQueue){
|
||||
if(pc.equals(player))
|
||||
continue;
|
||||
ChatManager.chatSystemInfo(pc, player.getName() + " has joined the arena que. There are now " + playerQueue.size() + " players queued.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void leaveQueue(PlayerCharacter player) {
|
||||
playerQueue.remove(player);
|
||||
for(PlayerCharacter pc : playerQueue){
|
||||
if(pc.equals(player))
|
||||
continue;
|
||||
ChatManager.chatSystemInfo(pc, player.getName() + " has left the arena que. There are now " + playerQueue.size() + " players queued.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createArena() {
|
||||
if (playerQueue.size() > 1) {
|
||||
|
||||
Collections.shuffle(playerQueue);
|
||||
Arena newArena = new Arena();
|
||||
|
||||
//set starting time
|
||||
newArena.startTime = System.currentTimeMillis();
|
||||
|
||||
//decide an arena location
|
||||
newArena.loc = selectRandomArenaLocation();
|
||||
|
||||
// Assign players to the arena
|
||||
newArena.player1 = playerQueue.remove(0);
|
||||
newArena.player2 = playerQueue.remove(0);
|
||||
|
||||
// Teleport players to the arena location
|
||||
Zone sdr = ZoneManager.getZoneByUUID(656);
|
||||
MovementManager.translocate(newArena.player1, Vector3fImmutable.getRandomPointOnCircle(newArena.loc,75f), null);
|
||||
MovementManager.translocate(newArena.player2, Vector3fImmutable.getRandomPointOnCircle(newArena.loc,75f), null);
|
||||
|
||||
// Add the new arena to the active arenas list
|
||||
activeArenas.add(newArena);
|
||||
}
|
||||
}
|
||||
|
||||
public static void endArena(Arena arena, PlayerCharacter winner, PlayerCharacter loser, String condition){
|
||||
if (winner != null && loser != null) {
|
||||
Logger.info("[ARENA] The fight between {} and {} is concluded. Victor: {}",
|
||||
arena.player1.getName(), arena.player2.getName(), winner.getName());
|
||||
} else {
|
||||
Logger.info("[ARENA] The fight between {} and {} is concluded. No Winner Declared.",
|
||||
arena.player1.getName(), arena.player2.getName());
|
||||
}
|
||||
// Teleport players to the arena location
|
||||
Zone sdr = ZoneManager.getZoneByUUID(656);
|
||||
MovementManager.translocate(arena.player1, Vector3fImmutable.getRandomPointOnCircle(sdr.getLoc(),50f), null);
|
||||
MovementManager.translocate(arena.player2, Vector3fImmutable.getRandomPointOnCircle(sdr.getLoc(),50f), null);
|
||||
|
||||
|
||||
|
||||
activeArenas.remove(arena);
|
||||
|
||||
if(winner != null){
|
||||
ChatManager.chatPVP("[ARENA] " + winner.getName() + " has slain " + loser.getName() + " in the arena!");
|
||||
//handle prize distribution
|
||||
//ItemBase specialLoot = ItemBase.getItemBase(866);
|
||||
//Item promoted = new MobLoot(winner, specialLoot, 1, false).promoteToItem(winner);
|
||||
//promoted.setNumOfItems(21235);
|
||||
//promoted.setName("Special Banker(21235)");
|
||||
//DbManager.ItemQueries.UPDATE_NUM_ITEMS(promoted,21235);
|
||||
//winner.getCharItemManager().addItemToInventory(promoted);
|
||||
//winner.getCharItemManager().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3fImmutable selectRandomArenaLocation() {
|
||||
boolean locSet = false;
|
||||
Vector3fImmutable loc = Vector3fImmutable.ZERO;
|
||||
|
||||
while (!locSet) {
|
||||
try {
|
||||
float x = ThreadLocalRandom.current().nextInt(114300, 123600);
|
||||
float z = ThreadLocalRandom.current().nextInt(82675, 91700);
|
||||
float y = 0; // Y coordinate is always 0
|
||||
|
||||
loc = new Vector3fImmutable(x, y, z * -1);
|
||||
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(loc,500f, MBServerStatics.MASK_PLAYER);
|
||||
if(inRange.isEmpty() && !isUnderWater(loc))
|
||||
locSet = true;
|
||||
//}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public static boolean isUnderWater(Vector3fImmutable loc) {
|
||||
|
||||
try {
|
||||
|
||||
Zone zone = ZoneManager.findSmallestZone(loc);
|
||||
|
||||
if (zone.getSeaLevel() != 0) {
|
||||
|
||||
float localAltitude = loc.y;
|
||||
if (localAltitude < zone.getSeaLevel())
|
||||
return true;
|
||||
} else {
|
||||
if (loc.y < 0)
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -438,18 +438,6 @@ public enum BuildingManager {
|
||||
|
||||
public static boolean IsPlayerHostile(Building building, PlayerCharacter player) {
|
||||
|
||||
if(building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BANESTONE))
|
||||
{
|
||||
Guild playerNation = player.guild.getNation();
|
||||
City banedCity = ZoneManager.getCityAtLocation(building.loc);
|
||||
if(banedCity != null){
|
||||
if(banedCity.getGuild().getNation().equals(playerNation)){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Nation Members and Guild members are not hostile.
|
||||
// if (building.getGuild() != null){
|
||||
// if (pc.getGuild() != null)
|
||||
@@ -532,30 +520,7 @@ public enum BuildingManager {
|
||||
if (building.getBlueprintUUID() == 0)
|
||||
return false;
|
||||
|
||||
if(building.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL)){
|
||||
if(contract.getContractID() == 850) {
|
||||
boolean hasRunemaster = false;
|
||||
for (AbstractCharacter npc : building.getHirelings().keySet()) {
|
||||
|
||||
if (npc.getObjectType() != GameObjectType.NPC)
|
||||
continue;
|
||||
|
||||
if(npc.contractUUID == 850)
|
||||
hasRunemaster = true;
|
||||
}
|
||||
|
||||
if(hasRunemaster)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int maxSlots = building.getBlueprint().getMaxSlots();
|
||||
if(building.getBlueprint().getBuildingGroup() != null) {
|
||||
maxSlots = building.getBlueprint().getSlotsForRank(building.getRank());
|
||||
}
|
||||
|
||||
if (maxSlots == building.getHirelings().size())
|
||||
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
|
||||
return false;
|
||||
|
||||
String pirateName = NPCManager.getPirateName(contract.getMobbaseID());
|
||||
|
||||
@@ -27,7 +27,6 @@ import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.server.world.WorldServer;
|
||||
import engine.session.Session;
|
||||
import engine.util.KeyCloneAudit;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -85,10 +84,6 @@ public enum ChatManager {
|
||||
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
||||
isFlood = true;
|
||||
|
||||
if(KeyCloneAudit.auditChatMsg(pc,msg.getMessage())){
|
||||
return;
|
||||
}
|
||||
|
||||
switch (protocolMsg) {
|
||||
case CHATSAY:
|
||||
ChatManager.chatSay(pc, msg.getMessage(), isFlood);
|
||||
|
||||
@@ -301,17 +301,6 @@ public enum CombatManager {
|
||||
if (target == null)
|
||||
return 0;
|
||||
|
||||
//pet to assist in attacking target
|
||||
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
PlayerCharacter attacker = (PlayerCharacter)abstractCharacter;
|
||||
if(attacker.getPet() != null){
|
||||
Mob pet = attacker.getPet();
|
||||
if(pet.combatTarget == null && pet.assist)
|
||||
pet.setCombatTarget(attacker.combatTarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//target must be valid type
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||
@@ -444,6 +433,11 @@ public enum CombatManager {
|
||||
if (bonus != null && bonus.getBool(ModType.Stunned, SourceType.None))
|
||||
attackFailure = true;
|
||||
|
||||
//see if attacker is feared. If so, stop here
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
attackFailure = true;
|
||||
|
||||
//Get Range of weapon
|
||||
|
||||
float range;
|
||||
@@ -494,24 +488,16 @@ public enum CombatManager {
|
||||
createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon
|
||||
else {
|
||||
int wepSpeed = (int) (wb.getSpeed());
|
||||
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
PlayerCharacter pc = (PlayerCharacter)abstractCharacter;
|
||||
if(slot == 1){
|
||||
wepSpeed = (int) pc.combatStats.attackSpeedHandOne;
|
||||
}else{
|
||||
wepSpeed = (int) pc.combatStats.attackSpeedHandTwo;
|
||||
}
|
||||
}else {
|
||||
|
||||
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus
|
||||
wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.None));
|
||||
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus
|
||||
wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.None));
|
||||
|
||||
if (abstractCharacter.getBonuses() != null && abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None) != 0f) //add effects speed bonus
|
||||
wepSpeed *= (1 + abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None));
|
||||
if (abstractCharacter.getBonuses() != null && abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None) != 0f) //add effects speed bonus
|
||||
wepSpeed *= (1 + abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None));
|
||||
|
||||
if (wepSpeed < 10)
|
||||
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||
|
||||
if (wepSpeed < 10)
|
||||
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||
}
|
||||
createTimer(abstractCharacter, slot, wepSpeed, true);
|
||||
}
|
||||
|
||||
@@ -555,29 +541,15 @@ public enum CombatManager {
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
PlayerCharacter pc = (PlayerCharacter) ac;
|
||||
pc.combatStats.calculateATR(true);
|
||||
pc.combatStats.calculateATR(false);
|
||||
if (mainHand) {
|
||||
atr = pc.combatStats.atrHandOne;
|
||||
minDamage = pc.combatStats.minDamageHandOne;
|
||||
maxDamage = pc.combatStats.maxDamageHandOne;
|
||||
} else {
|
||||
atr = pc.combatStats.atrHandTwo;
|
||||
minDamage = pc.combatStats.minDamageHandTwo;
|
||||
maxDamage = pc.combatStats.maxDamageHandTwo;
|
||||
}
|
||||
}else {
|
||||
if (mainHand) {
|
||||
atr = ac.getAtrHandOne();
|
||||
minDamage = ac.getMinDamageHandOne();
|
||||
maxDamage = ac.getMaxDamageHandOne();
|
||||
} else {
|
||||
atr = ac.getAtrHandTwo();
|
||||
minDamage = ac.getMinDamageHandTwo();
|
||||
maxDamage = ac.getMaxDamageHandTwo();
|
||||
}
|
||||
|
||||
if (mainHand) {
|
||||
atr = ac.getAtrHandOne();
|
||||
minDamage = ac.getMinDamageHandOne();
|
||||
maxDamage = ac.getMaxDamageHandOne();
|
||||
} else {
|
||||
atr = ac.getAtrHandTwo();
|
||||
minDamage = ac.getMinDamageHandTwo();
|
||||
maxDamage = ac.getMaxDamageHandTwo();
|
||||
}
|
||||
|
||||
boolean tarIsRat = false;
|
||||
@@ -671,12 +643,7 @@ public enum CombatManager {
|
||||
}
|
||||
} else {
|
||||
AbstractCharacter tar = (AbstractCharacter) target;
|
||||
if(tar.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
((PlayerCharacter)tar).combatStats.calculateDefense();
|
||||
defense = ((PlayerCharacter)tar).combatStats.defense;
|
||||
}else {
|
||||
defense = tar.getDefenseRating();
|
||||
}
|
||||
defense = tar.getDefenseRating();
|
||||
handleRetaliate(tar, ac); //Handle target attacking back if in combat and has no other target
|
||||
}
|
||||
|
||||
@@ -684,24 +651,24 @@ public enum CombatManager {
|
||||
|
||||
//Get hit chance
|
||||
|
||||
//int chance;
|
||||
//float dif = atr - defense;
|
||||
int chance;
|
||||
float dif = atr - defense;
|
||||
|
||||
//if (dif > 100)
|
||||
// chance = 94;
|
||||
//else if (dif < -100)
|
||||
// chance = 4;
|
||||
//else
|
||||
// chance = (int) ((0.45 * dif) + 49);
|
||||
if (dif > 100)
|
||||
chance = 94;
|
||||
else if (dif < -100)
|
||||
chance = 4;
|
||||
else
|
||||
chance = (int) ((0.45 * dif) + 49);
|
||||
|
||||
errorTrack = 5;
|
||||
|
||||
//calculate hit/miss
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(100);
|
||||
DeferredPowerJob dpj = null;
|
||||
|
||||
boolean hitLanded = LandHit((int)atr,(int)defense);
|
||||
if (hitLanded) {
|
||||
if (roll < chance) {
|
||||
|
||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
updateAttackTimers((PlayerCharacter) ac, target, true);
|
||||
@@ -730,13 +697,7 @@ public enum CombatManager {
|
||||
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
float attackRange = getWeaponRange(wb, bonus);
|
||||
if(specialCaseHitRoll(dpj.getPowerToken())) {
|
||||
if(hitLanded) {
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
}else{
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
dpj.attack(target, attackRange);
|
||||
|
||||
if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518))
|
||||
((PlayerCharacter) ac).setWeaponPower(dpj);
|
||||
@@ -751,13 +712,7 @@ public enum CombatManager {
|
||||
|
||||
if (dpj != null && dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) {
|
||||
float attackRange = getWeaponRange(wb, bonuses);
|
||||
if(specialCaseHitRoll(dpj.getPowerToken())) {
|
||||
if(hitLanded) {
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
}else{
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,22 +819,6 @@ public enum CombatManager {
|
||||
else
|
||||
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
|
||||
|
||||
if(weapon != null && weapon.effects != null){
|
||||
float armorPierce = 0;
|
||||
for(Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(ModType.ArmorPiercing)){
|
||||
armorPierce += mod.minMod * (mod.getRamp() * eff.getTrains());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(armorPierce > 0){
|
||||
damage *= 1 - armorPierce;
|
||||
}
|
||||
}
|
||||
|
||||
//Resists.handleFortitude(tarAc,damageType,damage);
|
||||
|
||||
float d = 0f;
|
||||
|
||||
errorTrack = 12;
|
||||
@@ -932,18 +871,27 @@ public enum CombatManager {
|
||||
|
||||
if (weapon != null && tarAc != null && tarAc.isAlive()) {
|
||||
|
||||
if(weapon.effects != null){
|
||||
for (Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(ModType.WeaponProc)){
|
||||
ConcurrentHashMap<String, Effect> effects = weapon.getEffects();
|
||||
|
||||
for (Effect eff : effects.values()) {
|
||||
if (eff == null)
|
||||
continue;
|
||||
|
||||
HashSet<AbstractEffectModifier> aems = eff.getEffectModifiers();
|
||||
|
||||
if (aems != null) {
|
||||
for (AbstractEffectModifier aem : aems) {
|
||||
|
||||
if (!tarAc.isAlive())
|
||||
break;
|
||||
|
||||
if (aem instanceof WeaponProcEffectModifier) {
|
||||
|
||||
int procChance = ThreadLocalRandom.current().nextInt(100);
|
||||
if (procChance < MBServerStatics.PROC_CHANCE) {
|
||||
try {
|
||||
((WeaponProcEffectModifier) mod).applyProc(ac, target);
|
||||
}catch(Exception e){
|
||||
Logger.error(eff.getName() + " Failed To Cast Proc");
|
||||
}
|
||||
}
|
||||
|
||||
if (procChance < MBServerStatics.PROC_CHANCE)
|
||||
((WeaponProcEffectModifier) aem).applyProc(ac, target);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -972,13 +920,7 @@ public enum CombatManager {
|
||||
if (wp.requiresHitRoll() == false) {
|
||||
PlayerBonuses bonus = ac.getBonuses();
|
||||
float attackRange = getWeaponRange(wb, bonus);
|
||||
if(specialCaseHitRoll(dpj.getPowerToken())) {
|
||||
if(hitLanded) {
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
}else{
|
||||
dpj.attack(target, attackRange);
|
||||
}
|
||||
dpj.attack(target, attackRange);
|
||||
} else
|
||||
((PlayerCharacter) ac).setWeaponPower(null);
|
||||
}
|
||||
@@ -1085,12 +1027,10 @@ public enum CombatManager {
|
||||
|
||||
//calculate resists in if any
|
||||
|
||||
|
||||
|
||||
if (resists != null)
|
||||
damage = resists.getResistedDamage(source, target, damageType, damage, 0);
|
||||
|
||||
return damage;
|
||||
return resists.getResistedDamage(source, target, damageType, damage, 0);
|
||||
else
|
||||
return damage;
|
||||
}
|
||||
|
||||
private static void sendPassiveDefenseMessage(AbstractCharacter source, ItemBase wb, AbstractWorldObject target, int passiveType, DeferredPowerJob dpj, boolean mainHand) {
|
||||
@@ -1119,10 +1059,6 @@ public enum CombatManager {
|
||||
if (eff.getPower() != null && (eff.getPower().getToken() == 429506943 || eff.getPower().getToken() == 429408639 || eff.getPower().getToken() == 429513599 || eff.getPower().getToken() == 429415295))
|
||||
swingAnimation = 0;
|
||||
|
||||
if(source != null && source.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
damage *= ((PlayerCharacter)source).ZergMultiplier;
|
||||
} // Health modifications are modified by the ZergMechanic
|
||||
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(source, target, damage, swingAnimation);
|
||||
DispatchMessage.sendToAllInRange(target, cmm);
|
||||
}
|
||||
@@ -1244,14 +1180,6 @@ public enum CombatManager {
|
||||
|
||||
private static boolean testPassive(AbstractCharacter source, AbstractCharacter target, String type) {
|
||||
|
||||
if(target.getBonuses() != null)
|
||||
if(target.getBonuses().getBool(ModType.Stunned, SourceType.None))
|
||||
return false;
|
||||
|
||||
if(source.getBonuses() != null)
|
||||
if(source.getBonuses().getBool(ModType.IgnorePassiveDefense, SourceType.None))
|
||||
return false;
|
||||
|
||||
float chance = target.getPassiveChance(type, source.getLevel(), true);
|
||||
|
||||
if (chance == 0f)
|
||||
@@ -1262,7 +1190,7 @@ public enum CombatManager {
|
||||
if (chance > 75f)
|
||||
chance = 75f;
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(1,100);
|
||||
int roll = ThreadLocalRandom.current().nextInt(100);
|
||||
|
||||
return roll < chance;
|
||||
|
||||
@@ -1314,17 +1242,14 @@ public enum CombatManager {
|
||||
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
}
|
||||
|
||||
public static void toggleSit(boolean toggle, ClientConnection origin) {
|
||||
private static void toggleSit(boolean toggle, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
if(pc.isFlying())
|
||||
pc.setSit(false);
|
||||
else
|
||||
pc.setSit(toggle);
|
||||
pc.setSit(toggle);
|
||||
|
||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||
rwss.setPlayer(pc);
|
||||
@@ -1402,13 +1327,6 @@ public enum CombatManager {
|
||||
return;
|
||||
|
||||
retaliater.setCombatTarget(ac);
|
||||
if(retaliater.isPlayerGuard && (retaliater.BehaviourType.equals(MobBehaviourType.GuardMinion) || retaliater.BehaviourType.equals(MobBehaviourType.GuardCaptain))){
|
||||
for(Mob guard : retaliater.guardedCity.getParent().zoneMobSet){
|
||||
if(guard.isPlayerGuard && guard.combatTarget == null){
|
||||
guard.setCombatTarget(ac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1440,9 +1358,9 @@ public enum CombatManager {
|
||||
|
||||
Resists resists = ac.getResists();
|
||||
|
||||
if (resists != null) {
|
||||
if (resists != null)
|
||||
amount = resists.getResistedDamage(target, ac, ds.getDamageType(), amount, 0);
|
||||
}
|
||||
|
||||
total += amount;
|
||||
}
|
||||
|
||||
@@ -1525,31 +1443,4 @@ public enum CombatManager {
|
||||
((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1);
|
||||
}
|
||||
|
||||
public static boolean LandHit(int ATR, int DEF){
|
||||
|
||||
//float chance = (ATR-((ATR+DEF) * 0.315f)) / ((DEF-((ATR+DEF) * 0.315f)) + (ATR-((ATR+DEF) * 0.315f)));
|
||||
//float convertedChance = chance * 100;
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(101);
|
||||
|
||||
//if(roll <= 5)//always 5% chance to miss
|
||||
// return false;
|
||||
|
||||
//if(roll >= 95)//always 5% chance to hit
|
||||
// return true;
|
||||
|
||||
float chance = PlayerCombatStats.getHitChance(ATR,DEF);
|
||||
return chance >= roll;
|
||||
}
|
||||
|
||||
public static boolean specialCaseHitRoll(int powerID){
|
||||
switch(powerID) {
|
||||
case 563200808: // Naargal's Bite
|
||||
case 563205337: // Naargal's Dart
|
||||
case 563205930: // Sword of Saint Malorn
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ public enum ConfigManager {
|
||||
MB_WORLD_MAINTENANCE,
|
||||
MB_WORLD_GREETING,
|
||||
MB_WORLD_KEYCLONE_MAX,
|
||||
MB_WORLD_TESTMODE,
|
||||
MB_USE_RUINS,
|
||||
|
||||
// Mobile AI modifiers
|
||||
@@ -98,8 +97,7 @@ public enum ConfigManager {
|
||||
MB_MAGICBOT_FORTOFIX,
|
||||
MB_MAGICBOT_RECRUIT,
|
||||
MB_MAGICBOT_MAGICBOX,
|
||||
MB_MAGICBOT_ADMINLOG,
|
||||
MB_WORLD_BOXLIMIT;
|
||||
MB_MAGICBOT_ADMINLOG;
|
||||
|
||||
// Map to hold our config pulled in from the environment
|
||||
// We also use the config to point to the current message pump
|
||||
|
||||
@@ -79,6 +79,7 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new AddGoldCmd());
|
||||
DevCmdManager.registerDevCmd(new ZoneInfoCmd());
|
||||
DevCmdManager.registerDevCmd(new DebugMeleeSyncCmd());
|
||||
DevCmdManager.registerDevCmd(new HotzoneCmd());
|
||||
DevCmdManager.registerDevCmd(new MineActiveCmd());
|
||||
// Dev
|
||||
DevCmdManager.registerDevCmd(new ApplyStatModCmd());
|
||||
@@ -102,7 +103,6 @@ public enum DevCmdManager {
|
||||
DevCmdManager.registerDevCmd(new SetAdminRuneCmd());
|
||||
DevCmdManager.registerDevCmd(new SetInvulCmd());
|
||||
DevCmdManager.registerDevCmd(new MakeItemCmd());
|
||||
DevCmdManager.registerDevCmd(new GimmeCmd());
|
||||
DevCmdManager.registerDevCmd(new EnchantCmd());
|
||||
DevCmdManager.registerDevCmd(new SetSubRaceCmd());
|
||||
// Admin
|
||||
@@ -177,44 +177,10 @@ public enum DevCmdManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!pcSender.getTimestamps().containsKey("DEVCOMMAND"))
|
||||
pcSender.getTimestamps().put("DEVCOMMAND",System.currentTimeMillis() - 1500L);
|
||||
else if(System.currentTimeMillis() - pcSender.getTimestamps().get("DEVCOMMAND") < 1000L)
|
||||
return false;
|
||||
|
||||
//kill any commands not available to everyone on production server
|
||||
//only admin level can run dev commands on production
|
||||
boolean playerAllowed = false;
|
||||
if(ConfigManager.MB_WORLD_TESTMODE.getValue().equals("true")) {
|
||||
switch (adc.getMainCmdString()) {
|
||||
case "printresists":
|
||||
case "printstats":
|
||||
case "printskills":
|
||||
case "printpowers":
|
||||
case "gimme":
|
||||
case "goto":
|
||||
case "teleportmode":
|
||||
case "printbonuses":
|
||||
playerAllowed = true;
|
||||
if (!a.status.equals(Enum.AccountStatus.ADMIN))
|
||||
target = pcSender;
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
switch (adc.getMainCmdString()) {
|
||||
case "printresists":
|
||||
case "printstats":
|
||||
case "printskills":
|
||||
case "printpowers":
|
||||
case "printbonuses":
|
||||
//case "gimme":
|
||||
playerAllowed = true;
|
||||
if (!a.status.equals(Enum.AccountStatus.ADMIN))
|
||||
target = pcSender;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!playerAllowed && !a.status.equals(Enum.AccountStatus.ADMIN)) {
|
||||
|
||||
if (a.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
||||
Logger.info("Account " + a.getUname() + "attempted to use dev command " + cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
@@ -36,12 +34,6 @@ public enum LootManager {
|
||||
public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>();
|
||||
|
||||
public static final ArrayList<Integer> vorg_ha_uuids = new ArrayList<>(Arrays.asList(27580, 27590, 188500, 188510, 188520, 188530, 188540, 188550, 189510));
|
||||
public static final ArrayList<Integer> vorg_ma_uuids = new ArrayList<>(Arrays.asList(27570,188900,188910,188920,188930,188940,188950,189500));
|
||||
public static final ArrayList<Integer> vorg_la_uuids = new ArrayList<>(Arrays.asList(27550,27560,189100,189110,189120,189130,189140,189150));
|
||||
public static final ArrayList<Integer> vorg_cloth_uuids = new ArrayList<>(Arrays.asList(27600,188700,188720,189550,189560));
|
||||
public static final ArrayList<Integer> racial_guard_uuids = new ArrayList<>(Arrays.asList(841,951,952,1050,1052,1180,1182,1250,1252,1350,1352,1450,1452,1500,1502,1525,1527,1550,1552,1575,1577,1600,1602,1650,1652,1700,980100,980102));
|
||||
|
||||
// Drop Rates
|
||||
|
||||
public static float NORMAL_DROP_RATE;
|
||||
@@ -76,128 +68,49 @@ public enum LootManager {
|
||||
|
||||
public static void GenerateMobLoot(Mob mob) {
|
||||
|
||||
if(mob == null){
|
||||
return;
|
||||
}
|
||||
|
||||
//determine if mob is in hotzone
|
||||
boolean inHotzone = false;
|
||||
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
|
||||
|
||||
//iterate the booty sets
|
||||
|
||||
if(mob.mobBase == null || mob.getMobBaseID() == 253003){
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet))
|
||||
if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true)
|
||||
RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone);
|
||||
|
||||
if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet)) {
|
||||
if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true)
|
||||
RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone);
|
||||
}else if(mob.bootySet != 0 && ItemBase.getItemBase(mob.bootySet) != null){
|
||||
MobLoot specialDrop = null;
|
||||
specialDrop = new MobLoot(mob,ItemBase.getItemBase(mob.bootySet),true);
|
||||
if(specialDrop != null) {
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + specialDrop.getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
mob.getCharItemManager().addItemToInventory(specialDrop);
|
||||
mob.setResists(new Resists("Dropper"));
|
||||
if(!Mob.discDroppers.contains(mob))
|
||||
Mob.AddDiscDropper(mob);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
||||
for (Item it : mob.getInventory()) {
|
||||
for (Item it : mob.getInventory()) {
|
||||
|
||||
ItemBase ib = it.getItemBase();
|
||||
if (ib == null)
|
||||
break;
|
||||
if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) {
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
ItemBase ib = it.getItemBase();
|
||||
if(ib == null)
|
||||
break;
|
||||
if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) {
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?");
|
||||
chatMsg.setMessageType(10);
|
||||
chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID());
|
||||
DispatchMessage.dispatchMsgToAll(chatMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone) {
|
||||
|
||||
boolean hotzoneWasRan = false;
|
||||
float dropRate;
|
||||
|
||||
if (!mob.getSafeZone()) {
|
||||
int contractLow = 1, contractHigh = 400;
|
||||
int runeLow = 401, runeHigh = 800;
|
||||
int resourceLow = 801, resourceHigh = 900;
|
||||
int glassLow = 901, glassHigh = 910;
|
||||
int guardLow = 911, guardHigh = 920;
|
||||
|
||||
// Pre-compute adjusted high values
|
||||
int contractAdjust = 0, runeAdjust = 0, resourceAdjust = 0, glassAdjust = 0, guardAdjust = 0;
|
||||
if (mob.level < 50) {
|
||||
int dif = 50 - mob.level;
|
||||
contractAdjust = (int)(400 * (dif * 0.02f));
|
||||
runeAdjust = (int)(400 * (dif * 0.02f));
|
||||
resourceAdjust = (int)(100 * (dif * 0.02f));
|
||||
glassAdjust = (int)(10 * (dif * 0.02f));
|
||||
guardAdjust = (int)(10 * (dif * 0.02f));
|
||||
}
|
||||
|
||||
// Generate a single random roll
|
||||
int specialCaseRoll = ThreadLocalRandom.current().nextInt(1, 100001);
|
||||
|
||||
// Calculate adjusted high values once
|
||||
int contractHighAdjusted = contractHigh - contractAdjust;
|
||||
int runeHighAdjusted = runeHigh - runeAdjust;
|
||||
int resourceHighAdjusted = resourceHigh - resourceAdjust;
|
||||
int glassHighAdjusted = glassHigh - glassAdjust;
|
||||
int guardHighAdjusted = guardHigh - guardAdjust;
|
||||
|
||||
// Check the roll range and handle accordingly
|
||||
if (specialCaseRoll >= contractLow && specialCaseRoll <= contractHighAdjusted) {
|
||||
SpecialCaseContractDrop(mob, entries);
|
||||
} else if (specialCaseRoll >= runeLow && specialCaseRoll <= runeHighAdjusted) {
|
||||
SpecialCaseRuneDrop(mob, entries);
|
||||
} else if (specialCaseRoll >= resourceLow && specialCaseRoll <= resourceHighAdjusted) {
|
||||
SpecialCaseResourceDrop(mob, entries);
|
||||
} else if (specialCaseRoll >= glassLow && specialCaseRoll <= glassHighAdjusted) {
|
||||
int glassID = rollRandomItem(126);
|
||||
ItemBase glassItem = ItemBase.getItemBase(glassID);
|
||||
if (glassItem != null) {
|
||||
MobLoot toAddGlass = new MobLoot(mob, glassItem, false);
|
||||
mob.getCharItemManager().addItemToInventory(toAddGlass);
|
||||
}
|
||||
} else if (specialCaseRoll >= guardLow && specialCaseRoll <= guardHighAdjusted) {
|
||||
int guardContractID = racial_guard_uuids.get(new java.util.Random().nextInt(racial_guard_uuids.size()));
|
||||
ItemBase guardContract = ItemBase.getItemBase(guardContractID);
|
||||
if (guardContract != null) {
|
||||
MobLoot toAddContract = new MobLoot(mob, guardContract, false);
|
||||
mob.getCharItemManager().addItemToInventory(toAddContract);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float dropRate = 1.0f;
|
||||
|
||||
// Iterate all entries in this bootySet and process accordingly
|
||||
Zone zone = ZoneManager.findSmallestZone(mob.loc);
|
||||
|
||||
for (BootySetEntry bse : entries) {
|
||||
switch (bse.bootyType) {
|
||||
case "GOLD":
|
||||
if (zone != null && zone.getSafeZone() == (byte)1)
|
||||
return; // no loot to drop in safezones
|
||||
GenerateGoldDrop(mob, bse, inHotzone);
|
||||
break;
|
||||
case "LOOT":
|
||||
if (zone != null && zone.getSafeZone() == (byte)1)
|
||||
return; // no loot to drop in safezones
|
||||
|
||||
dropRate = LootManager.NORMAL_DROP_RATE;
|
||||
if (mob.getSafeZone() == false)
|
||||
dropRate = LootManager.NORMAL_DROP_RATE;
|
||||
|
||||
if (inHotzone == true)
|
||||
dropRate = LootManager.HOTZONE_DROP_RATE;
|
||||
@@ -222,109 +135,6 @@ public enum LootManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void SpecialCaseContractDrop(Mob mob,ArrayList<BootySetEntry> entries){
|
||||
|
||||
int lootTableID = 0;
|
||||
for(BootySetEntry entry : entries){
|
||||
if(entry.bootyType.equals("LOOT")){
|
||||
lootTableID = entry.genTable;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(lootTableID == 0)
|
||||
return;
|
||||
|
||||
int ContractTableID = 0;
|
||||
for(GenTableEntry entry : _genTables.get(lootTableID)){
|
||||
try {
|
||||
if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.CONTRACT)) {
|
||||
ContractTableID = entry.itemTableID;
|
||||
break;
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(ContractTableID == 0)
|
||||
return;
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(rollRandomItem(ContractTableID));
|
||||
if(ib != null){
|
||||
MobLoot toAdd = new MobLoot(mob,ib,false);
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SpecialCaseRuneDrop(Mob mob,ArrayList<BootySetEntry> entries){
|
||||
int lootTableID = 0;
|
||||
for(BootySetEntry entry : entries){
|
||||
if(entry.bootyType.equals("LOOT")){
|
||||
lootTableID = entry.genTable;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(lootTableID == 0)
|
||||
return;
|
||||
|
||||
int RuneTableID = 0;
|
||||
for(GenTableEntry entry : _genTables.get(lootTableID)){
|
||||
try {
|
||||
if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.RUNE)) {
|
||||
RuneTableID = entry.itemTableID;
|
||||
break;
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(RuneTableID == 0)
|
||||
return;
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(rollRandomItem(RuneTableID));
|
||||
if(ib != null){
|
||||
MobLoot toAdd = new MobLoot(mob,ib,false);
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SpecialCaseResourceDrop(Mob mob,ArrayList<BootySetEntry> entries){
|
||||
int lootTableID = 0;
|
||||
for(BootySetEntry entry : entries){
|
||||
if(entry.bootyType.equals("LOOT")){
|
||||
lootTableID = entry.genTable;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(lootTableID == 0)
|
||||
return;
|
||||
|
||||
int ResourceTableID = 0;
|
||||
for(GenTableEntry entry : _genTables.get(lootTableID)){
|
||||
try {
|
||||
if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.RESOURCE)) {
|
||||
ResourceTableID = entry.itemTableID;
|
||||
break;
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(ResourceTableID == 0)
|
||||
return;
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(rollRandomItem(ResourceTableID));
|
||||
if(ib != null){
|
||||
MobLoot toAdd = new MobLoot(mob,ib,false);
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) {
|
||||
|
||||
if (mob == null || _genTables.containsKey(genTableID) == false)
|
||||
@@ -346,10 +156,11 @@ public enum LootManager {
|
||||
|
||||
//gets the 1-320 roll for this mob
|
||||
int itemTableRoll = 0;
|
||||
int objectType = mob.getObjectType().ordinal();
|
||||
if(mob.getObjectType().ordinal() == 52) { //52 = player character
|
||||
itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
itemTableRoll = TableRoll(mob.level);
|
||||
itemTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll);
|
||||
if (tableRow == null)
|
||||
@@ -361,23 +172,13 @@ public enum LootManager {
|
||||
return null;
|
||||
|
||||
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
|
||||
if(ThreadLocalRandom.current().nextInt(1,101) < 91)
|
||||
return null; // cut down world drops rates of resources by 90%
|
||||
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
|
||||
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
|
||||
}
|
||||
if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.RUNE)){
|
||||
int randomRune = rollRandomItem(itemTableId);
|
||||
if(randomRune != 0) {
|
||||
itemUUID = randomRune;
|
||||
}
|
||||
} else if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.CONTRACT)){
|
||||
int randomContract = rollRandomItem(itemTableId);
|
||||
if(randomContract != 0) {
|
||||
itemUUID = randomContract;
|
||||
}
|
||||
}
|
||||
|
||||
outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
|
||||
Enum.ItemType outType = outItem.getItemBase().getType();
|
||||
|
||||
|
||||
if(selectedRow.pModTable != 0){
|
||||
try {
|
||||
@@ -395,12 +196,6 @@ public enum LootManager {
|
||||
Logger.error("Failed to GenerateSuffix for item: " + outItem.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if(outItem.getItemBase().getType().equals(Enum.ItemType.CONTRACT) || outItem.getItemBase().getType().equals(Enum.ItemType.RUNE)){
|
||||
if(ThreadLocalRandom.current().nextInt(1,101) < 66)
|
||||
return null; // cut down world drops rates of resources by 65%
|
||||
}
|
||||
|
||||
return outItem;
|
||||
}
|
||||
|
||||
@@ -421,7 +216,7 @@ public enum LootManager {
|
||||
if(mob.getObjectType().ordinal() == 52) {
|
||||
prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
prefixTableRoll = TableRoll(mob.level);
|
||||
prefixTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll);
|
||||
|
||||
@@ -453,7 +248,7 @@ public enum LootManager {
|
||||
if(mob.getObjectType().ordinal() == 52) {
|
||||
suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
|
||||
} else{
|
||||
suffixTableRoll = TableRoll(mob.level);
|
||||
suffixTableRoll = TableRoll(mob.level, inHotzone);
|
||||
}
|
||||
ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll);
|
||||
|
||||
@@ -468,36 +263,23 @@ public enum LootManager {
|
||||
return inItem;
|
||||
}
|
||||
|
||||
public static int TableRoll(int mobLevel) {
|
||||
public static int TableRoll(int mobLevel, Boolean inHotzone) {
|
||||
|
||||
int rank = (int)(mobLevel * 0.1f);
|
||||
int min = 50;
|
||||
int max = 100;
|
||||
switch(rank){
|
||||
case 1:
|
||||
min = 200;
|
||||
max = 250;
|
||||
break;
|
||||
case 2:
|
||||
min = 210;
|
||||
max = 275;
|
||||
break;
|
||||
case 3:
|
||||
min = 220;
|
||||
max = 300;
|
||||
break;
|
||||
case 4:
|
||||
min = 230;
|
||||
max = 320;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
min = 240;
|
||||
max = 320;
|
||||
break;
|
||||
}
|
||||
if (mobLevel > 65)
|
||||
mobLevel = 65;
|
||||
|
||||
int max = (int) (4.882 * mobLevel + 127.0);
|
||||
|
||||
if (max > 319)
|
||||
max = 319;
|
||||
|
||||
int min = (int) (4.469 * mobLevel - 3.469);
|
||||
|
||||
if (min < 70)
|
||||
min = 70;
|
||||
|
||||
if (inHotzone)
|
||||
min += mobLevel;
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(min, max + 1);
|
||||
|
||||
@@ -517,7 +299,12 @@ public enum LootManager {
|
||||
|
||||
int high = bse.highGold;
|
||||
int low = bse.lowGold;
|
||||
int gold = (int) (ThreadLocalRandom.current().nextInt(low, high + 1) * NORMAL_GOLD_RATE);
|
||||
int gold = ThreadLocalRandom.current().nextInt(low, high + 1);
|
||||
|
||||
if (inHotzone == true)
|
||||
gold = (int) (gold * HOTZONE_GOLD_RATE);
|
||||
else
|
||||
gold = (int) (gold * NORMAL_GOLD_RATE);
|
||||
|
||||
if (gold > 0) {
|
||||
MobLoot goldAmount = new MobLoot(mob, gold);
|
||||
@@ -528,63 +315,45 @@ public enum LootManager {
|
||||
|
||||
public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) {
|
||||
|
||||
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
|
||||
if(toAdd != null){
|
||||
ItemBase ib = toAdd.getItemBase();
|
||||
switch(ib.getType()){
|
||||
case CONTRACT:
|
||||
case RUNE:
|
||||
case RESOURCE:
|
||||
return;
|
||||
}
|
||||
toAdd.setIsID(true);
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
try {
|
||||
|
||||
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
|
||||
|
||||
if (toAdd != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO chase down loot generation error, affects roughly 2% of drops
|
||||
int i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void GenerateEquipmentDrop(Mob mob) {
|
||||
|
||||
if (mob == null || mob.getSafeZone())
|
||||
return; // no equipment to drop in safezones
|
||||
|
||||
if(mob.StrongholdGuardian || mob.StrongholdCommander || mob.StrongholdEpic)
|
||||
return; // stronghold mobs don't drop equipment
|
||||
|
||||
//do equipment here
|
||||
if (mob.getEquip() != null) {
|
||||
boolean isVorg = false;
|
||||
int dropCount = 0;
|
||||
if (mob.getEquip() != null)
|
||||
for (MobEquipment me : mob.getEquip().values()) {
|
||||
|
||||
if (me.getDropChance() == 0)
|
||||
continue;
|
||||
|
||||
String name = me.getItemBase().getName().toLowerCase();
|
||||
if (name.contains("vorgrim legionnaire's") || name.contains("vorgrim auxiliary's") ||name.contains("bellugh nuathal") || name.contains("crimson circle"))
|
||||
isVorg = true;
|
||||
|
||||
if(isVorg && !mob.isDropper){
|
||||
continue;
|
||||
}
|
||||
|
||||
float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
float dropChance = me.getDropChance() * 100;
|
||||
ItemBase itemBase = me.getItemBase();
|
||||
if(isVorg) {
|
||||
mob.spawnTime = ThreadLocalRandom.current().nextInt(300, 2700);
|
||||
dropChance = 10;
|
||||
itemBase = getRandomVorg(itemBase);
|
||||
}
|
||||
|
||||
if (equipmentRoll > dropChance)
|
||||
continue;
|
||||
|
||||
MobLoot ml = new MobLoot(mob, itemBase, false);
|
||||
MobLoot ml = new MobLoot(mob, me.getItemBase(), false);
|
||||
|
||||
ml.setIsID(true);
|
||||
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
|
||||
mob.getCharItemManager().addItemToInventory(ml);
|
||||
if (ml != null && dropCount < 1) {
|
||||
ml.setIsID(true);
|
||||
ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1));
|
||||
mob.getCharItemManager().addItemToInventory(ml);
|
||||
dropCount = 1;
|
||||
//break; // Exit on first successful roll.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse) {
|
||||
@@ -598,11 +367,8 @@ public enum LootManager {
|
||||
|
||||
MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
|
||||
|
||||
if (lootItem != null) {
|
||||
if (lootItem != null)
|
||||
mob.getCharItemManager().addItemToInventory(lootItem);
|
||||
if(lootItem.getItemBase().isDiscRune() && !Mob.discDroppers.contains(mob))
|
||||
Mob.AddDiscDropper(mob);
|
||||
}
|
||||
}
|
||||
|
||||
public static void peddleFate(PlayerCharacter playerCharacter, Item gift) {
|
||||
@@ -626,12 +392,12 @@ public enum LootManager {
|
||||
|
||||
//check if player owns the gift he is trying to open
|
||||
|
||||
if (!itemMan.doesCharOwnThisItem(gift.getObjectUUID()))
|
||||
if (itemMan.doesCharOwnThisItem(gift.getObjectUUID()) == false)
|
||||
return;
|
||||
|
||||
//roll 1-100 for the gen table selection
|
||||
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(94, 100) + 1;
|
||||
int genRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
|
||||
GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll, LootManager.NORMAL_DROP_RATE);
|
||||
|
||||
if(selectedRow == null)
|
||||
@@ -647,276 +413,45 @@ public enum LootManager {
|
||||
|
||||
//create the item from the table, quantity is always 1
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(selectedItem.cacheID);
|
||||
if(ib.getUUID() == Warehouse.coalIB.getUUID()){
|
||||
//no more coal, give gold instead
|
||||
if (itemMan.getGoldInventory().getNumOfItems() + 250000 > 10000000) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
||||
return;
|
||||
}
|
||||
itemMan.addGoldToInventory(250000,false);
|
||||
itemMan.updateInventory();
|
||||
}else {
|
||||
MobLoot winnings = new MobLoot(playerCharacter, ib, 1, false);
|
||||
MobLoot winnings = new MobLoot(playerCharacter, ItemBase.getItemBase(selectedItem.cacheID), 1, false);
|
||||
|
||||
if (winnings == null)
|
||||
return;
|
||||
if (winnings == null)
|
||||
return;
|
||||
|
||||
//early exit if the inventory of the player will not hold the item
|
||||
//early exit if the inventory of the player will not old the item
|
||||
|
||||
if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
//determine if the winning item needs a prefix
|
||||
|
||||
if (selectedRow.pModTable != 0) {
|
||||
int prefixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1);
|
||||
ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll);
|
||||
if (prefix != null)
|
||||
winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true);
|
||||
}
|
||||
|
||||
//determine if the winning item needs a suffix
|
||||
|
||||
if (selectedRow.sModTable != 0) {
|
||||
int suffixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1);
|
||||
ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll);
|
||||
if (suffix != null)
|
||||
winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true);
|
||||
}
|
||||
winnings.setIsID(true);
|
||||
|
||||
//remove gift from inventory
|
||||
|
||||
itemMan.consume(gift);
|
||||
|
||||
//add winnings to player inventory
|
||||
|
||||
Item playerWinnings = winnings.promoteToItem(playerCharacter);
|
||||
itemMan.addItemToInventory(playerWinnings);
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public static int rollRandomItem(int itemTable){
|
||||
int returnedID = ItemTableEntry.getRandomItem(itemTable);
|
||||
return returnedID;
|
||||
}
|
||||
|
||||
public static ItemBase getRandomVorg(ItemBase itemBase){
|
||||
int roll = 0;
|
||||
if(vorg_ha_uuids.contains(itemBase.getUUID())) {
|
||||
roll = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
switch (roll) {
|
||||
case 1:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(0));
|
||||
case 2:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(1));
|
||||
case 3:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(2));
|
||||
case 4:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(3));
|
||||
case 5:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(4));
|
||||
case 6:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(5));
|
||||
case 7:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(6));
|
||||
case 8:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(7));
|
||||
default:
|
||||
return ItemBase.getItemBase(vorg_ha_uuids.get(8));
|
||||
}
|
||||
if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
if(vorg_ma_uuids.contains(itemBase.getUUID())) {
|
||||
roll = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
switch (roll) {
|
||||
case 1:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(0));
|
||||
case 2:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(1));
|
||||
case 3:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(2));
|
||||
case 4:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(3));
|
||||
case 5:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(4));
|
||||
case 6:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(5));
|
||||
case 7:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(6));
|
||||
default:
|
||||
return ItemBase.getItemBase(vorg_ma_uuids.get(7));
|
||||
}
|
||||
//determine if the winning item needs a prefix
|
||||
|
||||
if(selectedRow.pModTable != 0){
|
||||
int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1);
|
||||
ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll);
|
||||
if(prefix != null)
|
||||
winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true);
|
||||
}
|
||||
|
||||
if(vorg_la_uuids.contains(itemBase.getUUID())) {
|
||||
roll = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
switch (roll) {
|
||||
case 1:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(0));
|
||||
case 2:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(1));
|
||||
case 3:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(2));
|
||||
case 4:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(3));
|
||||
case 5:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(4));
|
||||
case 6:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(5));
|
||||
case 7:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(6));
|
||||
default:
|
||||
return ItemBase.getItemBase(vorg_la_uuids.get(7));
|
||||
}
|
||||
//determine if the winning item needs a suffix
|
||||
|
||||
if(selectedRow.sModTable != 0){
|
||||
int suffixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1);
|
||||
ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll);
|
||||
if (suffix != null)
|
||||
winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true);
|
||||
}
|
||||
winnings.setIsID(true);
|
||||
|
||||
if(vorg_cloth_uuids.contains(itemBase.getUUID())) {
|
||||
roll = ThreadLocalRandom.current().nextInt(0, 10);
|
||||
switch (roll) {
|
||||
case 1:
|
||||
return ItemBase.getItemBase(vorg_cloth_uuids.get(0));
|
||||
case 2:
|
||||
return ItemBase.getItemBase(vorg_cloth_uuids.get(1));
|
||||
case 3:
|
||||
return ItemBase.getItemBase(vorg_cloth_uuids.get(2));
|
||||
case 4:
|
||||
return ItemBase.getItemBase(vorg_cloth_uuids.get(3));
|
||||
default:
|
||||
return ItemBase.getItemBase(vorg_cloth_uuids.get(4));
|
||||
}
|
||||
}
|
||||
//remove gift from inventory
|
||||
|
||||
return null;
|
||||
}
|
||||
itemMan.consume(gift);
|
||||
|
||||
public static void DropPresent(Mob mob){
|
||||
int random = 971049 + ThreadLocalRandom.current().nextInt(24);
|
||||
if (random > 971071)
|
||||
random = 971071;
|
||||
//add winnings to player inventory
|
||||
|
||||
ItemBase present = ItemBase.getItemBase(random);
|
||||
if (present != null) {
|
||||
MobLoot toAdd = new MobLoot(mob, present, true);
|
||||
|
||||
if (toAdd != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateStrongholdLoot(Mob mob, boolean commander, boolean epic) {
|
||||
|
||||
mob.getCharItemManager().clearInventory();
|
||||
|
||||
int multiplier = 1;
|
||||
if (commander)
|
||||
multiplier = 2;
|
||||
if(epic)
|
||||
multiplier = 10;
|
||||
|
||||
int high = 125000;
|
||||
int low = 50000;
|
||||
int gold = ThreadLocalRandom.current().nextInt(low, high + 1) * multiplier;
|
||||
|
||||
if (gold > 0) {
|
||||
MobLoot goldAmount = new MobLoot(mob, gold);
|
||||
mob.getCharItemManager().addItemToInventory(goldAmount);
|
||||
}
|
||||
|
||||
//present drop chance for all
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 35)
|
||||
DropPresent(mob);
|
||||
|
||||
//random contract drop chance for all
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 40) {
|
||||
int contractTableID = 250;
|
||||
contractTableID += ThreadLocalRandom.current().nextInt(0, 11);
|
||||
if (contractTableID > 259)
|
||||
contractTableID = 659;
|
||||
|
||||
int id = rollRandomItem(contractTableID);
|
||||
ItemBase ib = ItemBase.getItemBase(id);
|
||||
if (ib != null) {
|
||||
MobLoot contract = new MobLoot(mob, ib, true);
|
||||
|
||||
if (contract != null)
|
||||
mob.getCharItemManager().addItemToInventory(contract);
|
||||
}
|
||||
}
|
||||
|
||||
//special commander drop chances
|
||||
if (commander)
|
||||
GenerateCommanderLoot(mob,false);
|
||||
|
||||
//special epic drop chances
|
||||
if (epic) {
|
||||
GenerateCommanderLoot(mob, true);
|
||||
GenerateCommanderLoot(mob,false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateCommanderLoot(Mob mob, boolean epic){
|
||||
//present chance
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 25)
|
||||
DropPresent(mob);
|
||||
|
||||
//present chance
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 25)
|
||||
DropPresent(mob);
|
||||
|
||||
//chance for glass
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 75) {
|
||||
int glassID = rollRandomItem(126);
|
||||
ItemBase glassItem = ItemBase.getItemBase(glassID);
|
||||
if (glassItem != null) {
|
||||
MobLoot toAdd2 = new MobLoot(mob, glassItem, true);
|
||||
|
||||
if (toAdd2 != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd2);
|
||||
}
|
||||
}
|
||||
|
||||
//chance for disc
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 75) {
|
||||
int discID = rollRandomItem(3202);
|
||||
ItemBase discItem = ItemBase.getItemBase(discID);
|
||||
if (discItem != null) {
|
||||
MobLoot toAdd3 = new MobLoot(mob, discItem, true);
|
||||
|
||||
if (toAdd3 != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd3);
|
||||
}
|
||||
}
|
||||
|
||||
//chance for stat rune
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 75) {
|
||||
int runeID = rollRandomItem(3201);
|
||||
ItemBase runeItem = ItemBase.getItemBase(runeID);
|
||||
if (runeItem != null) {
|
||||
MobLoot toAdd4 = new MobLoot(mob, runeItem, true);
|
||||
|
||||
if (toAdd4 != null)
|
||||
mob.getCharItemManager().addItemToInventory(toAdd4);
|
||||
}
|
||||
}
|
||||
if(epic){
|
||||
int contractTableID = 250;
|
||||
contractTableID += ThreadLocalRandom.current().nextInt(0, 11);
|
||||
if (contractTableID > 259)
|
||||
contractTableID = 659;
|
||||
|
||||
int id = rollRandomItem(contractTableID);
|
||||
ItemBase ib = ItemBase.getItemBase(id);
|
||||
if (ib != null) {
|
||||
MobLoot contract = new MobLoot(mob, ib, true);
|
||||
|
||||
if (contract != null)
|
||||
mob.getCharItemManager().addItemToInventory(contract);
|
||||
}
|
||||
}
|
||||
Item playerWinnings = winnings.promoteToItem(playerCharacter);
|
||||
itemMan.addItemToInventory(playerWinnings);
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public enum MaintenanceManager {
|
||||
|
||||
public static void setMaintDateTime(Building building, LocalDateTime maintDate) {
|
||||
|
||||
building.maintDateTime = maintDate.withHour(1).withMinute(0).withSecond(0);
|
||||
building.maintDateTime = maintDate;
|
||||
DbManager.BuildingQueries.updateMaintDate(building);
|
||||
|
||||
}
|
||||
@@ -49,15 +49,19 @@ public enum MaintenanceManager {
|
||||
|
||||
if (chargeUpkeep(building) == false)
|
||||
derankList.add(building);
|
||||
else
|
||||
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
||||
}
|
||||
// Reset maintenance dates for these buildings
|
||||
|
||||
for (Building building : maintList) {
|
||||
setMaintDateTime(building, LocalDateTime.now().plusDays(7));
|
||||
|
||||
for (Building building : derankList) {
|
||||
building.destroyOrDerank(null);
|
||||
if(building.getRank() > 0)
|
||||
setMaintDateTime(building, LocalDateTime.now().plusDays(1));
|
||||
}
|
||||
// Derak or destroy buildings that did not
|
||||
// have funds available.
|
||||
|
||||
for (Building building : derankList)
|
||||
building.destroyOrDerank(null);
|
||||
|
||||
Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size());
|
||||
}
|
||||
|
||||
@@ -94,10 +98,6 @@ public enum MaintenanceManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
//only ToL pays maintenance
|
||||
if(building.getBlueprint().getBuildingGroup() != null && !building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))
|
||||
continue;
|
||||
|
||||
// No maintenance on banestones omfg
|
||||
|
||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE))
|
||||
@@ -122,9 +122,9 @@ public enum MaintenanceManager {
|
||||
|
||||
|
||||
//no maintenance if day of week doesnt match
|
||||
//if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) {
|
||||
// continue;
|
||||
//}
|
||||
if (LocalDateTime.now().getDayOfWeek().ordinal() != building.maintDateTime.getDayOfWeek().ordinal()) {
|
||||
continue;
|
||||
}
|
||||
// Add building to maintenance queue
|
||||
|
||||
maintList.add(building);
|
||||
@@ -186,8 +186,49 @@ public enum MaintenanceManager {
|
||||
// If this is an R8 tree, validate that we can
|
||||
// cover the resources required
|
||||
|
||||
if (building.getRank() == 8) {
|
||||
|
||||
hasResources = true;
|
||||
|
||||
if (warehouse == null)
|
||||
hasResources = false;
|
||||
else {
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
||||
|
||||
if (resourceValue < 1500)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
||||
|
||||
if (resourceValue < 1500)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
||||
|
||||
if (resourceValue < 5)
|
||||
hasResources = false;
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
||||
|
||||
if (resourceValue < 5)
|
||||
hasResources = false;
|
||||
|
||||
}
|
||||
}
|
||||
// Validation completed but has failed. We can derank
|
||||
// the target building and early exit
|
||||
|
||||
if ((hasFunds == false) ||
|
||||
((building.getRank() == 8) && !hasResources)) {
|
||||
|
||||
// Add cash back to strongbox for lost rank if the building isn't being destroyed
|
||||
// and it's not an R8 deranking
|
||||
|
||||
if ((building.getRank() > 1) && (building.getRank() < 8)) {
|
||||
building.setStrongboxValue(building.getStrongboxValue() + building.getBlueprint().getRankCost(Math.min(building.getRank(), 7)));
|
||||
}
|
||||
|
||||
if (hasFunds == false) {
|
||||
return false; // Early exit for having failed to meet maintenance
|
||||
}
|
||||
|
||||
@@ -212,6 +253,58 @@ public enum MaintenanceManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Early exit as we're done if we're not an R8 tree
|
||||
|
||||
if (building.getRank() < 8)
|
||||
return true;
|
||||
|
||||
// Now for the resources if it's an R8 tree
|
||||
|
||||
// Withdraw Stone
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.stoneIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateStone(warehouse, resourceValue - 1500) == true) {
|
||||
warehouse.getResources().put(Warehouse.stoneIB, resourceValue - 1500);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.STONE, 1500);
|
||||
} else {
|
||||
Logger.error("stone update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Withdraw Lumber
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.lumberIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateLumber(warehouse, resourceValue - 1500) == true) {
|
||||
warehouse.getResources().put(Warehouse.lumberIB, resourceValue - 1500);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.LUMBER, 1500);
|
||||
} else {
|
||||
Logger.error("lumber update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Withdraw Galvor
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.galvorIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateGalvor(warehouse, resourceValue - 5) == true) {
|
||||
warehouse.getResources().put(Warehouse.galvorIB, resourceValue - 5);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.GALVOR, 5);
|
||||
} else {
|
||||
Logger.error("galvor update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
resourceValue = warehouse.getResources().get(Warehouse.wormwoodIB);
|
||||
|
||||
if (DbManager.WarehouseQueries.updateWormwood(warehouse, resourceValue - 5) == true) {
|
||||
warehouse.getResources().put(Warehouse.wormwoodIB, resourceValue - 5);
|
||||
warehouse.AddTransactionToWarehouse(Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.WITHDRAWL, Resource.WORMWOOD, 5);
|
||||
} else {
|
||||
Logger.error("wyrmwood update failed for warehouse of UUID:" + warehouse.getObjectUUID());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,10 +67,8 @@ public enum MovementManager {
|
||||
return;
|
||||
|
||||
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
if (((PlayerCharacter) toMove).isCasting()) {
|
||||
((PlayerCharacter) toMove).updateLocation();
|
||||
((PlayerCharacter) toMove).updateMovementState();
|
||||
}
|
||||
if (((PlayerCharacter) toMove).isCasting())
|
||||
((PlayerCharacter) toMove).update();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +79,11 @@ public enum MovementManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// Will this prevent movement at all or only player input for movement?
|
||||
if (toMove.getBonuses().getBool(ModType.Fear, SourceType.None)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.getEndLat() > MBServerStatics.MAX_WORLD_WIDTH)
|
||||
msg.setEndLat((float) MBServerStatics.MAX_WORLD_WIDTH);
|
||||
|
||||
@@ -98,7 +101,7 @@ public enum MovementManager {
|
||||
if (!toMove.isMoving())
|
||||
toMove.resetLastSetLocUpdate();
|
||||
else
|
||||
toMove.update(false);
|
||||
toMove.update();
|
||||
|
||||
// Update movement for the player
|
||||
|
||||
@@ -353,7 +356,7 @@ public enum MovementManager {
|
||||
ChatManager.chatSystemInfo((PlayerCharacter) ac, "Finished Alt change, setting the end location to " + ac.getEndLoc().getX() + ' ' + ac.getEndLoc().getZ() + " moving=" + ac.isMoving() + " and current location is " + curLoc.getX() + ' ' + curLoc.getZ());
|
||||
|
||||
//Send run/walk/sit/stand to tell the client we are flying / landing etc
|
||||
ac.update(false);
|
||||
ac.update();
|
||||
ac.stopMovement(ac.getLoc());
|
||||
if (ac.isAlive())
|
||||
MovementManager.sendRWSSMsg(ac);
|
||||
@@ -409,10 +412,12 @@ public enum MovementManager {
|
||||
PlayerBonuses bonus = member.getBonuses();
|
||||
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
|
||||
continue;
|
||||
|
||||
//don't move if player is feared
|
||||
if (bonus.getBool(ModType.Fear, SourceType.None))
|
||||
continue;
|
||||
|
||||
//member.update(false);
|
||||
member.updateLocation();
|
||||
member.updateMovementState();
|
||||
member.update();
|
||||
|
||||
|
||||
// All checks passed, let's move the player
|
||||
|
||||
@@ -340,8 +340,8 @@ public enum NPCManager {
|
||||
else
|
||||
buildingSlot = BuildingManager.getAvailableSlot(abstractCharacter.building);
|
||||
|
||||
//if (buildingSlot == -1)
|
||||
//Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
|
||||
if (buildingSlot == -1)
|
||||
Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
|
||||
|
||||
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ package engine.gameManager;
|
||||
|
||||
import engine.Enum.*;
|
||||
import engine.InterestManagement.HeightMap;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.db.handlers.dbEffectsBaseHandler;
|
||||
import engine.db.handlers.dbPowerHandler;
|
||||
@@ -164,22 +163,6 @@ public enum PowersManager {
|
||||
public static void usePower(final PerformActionMsg msg, ClientConnection origin,
|
||||
boolean sendCastToSelf) {
|
||||
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if(pc == null)
|
||||
return;
|
||||
|
||||
if(!pc.isFlying() && powersBaseByToken.get(msg.getPowerUsedID()) != null && powersBaseByToken.get(msg.getPowerUsedID()).isSpell) //cant be sitting if flying
|
||||
CombatManager.toggleSit(false,origin);
|
||||
|
||||
if(pc.isMoving())
|
||||
pc.stopMovement(pc.getMovementLoc());
|
||||
|
||||
if(msg.getPowerUsedID() == 429429978){
|
||||
applyPower(origin.getPlayerCharacter(),origin.getPlayerCharacter(),origin.getPlayerCharacter().getLoc(),429429978,msg.getNumTrains(),false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (usePowerA(msg, origin, sendCastToSelf)) {
|
||||
// Cast failed for some reason, reset timer
|
||||
|
||||
@@ -188,10 +171,13 @@ public enum PowersManager {
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
// Send Fail to cast message
|
||||
PlayerCharacter pc = SessionManager
|
||||
.getPlayerCharacter(origin);
|
||||
|
||||
if (pc != null) {
|
||||
sendPowerMsg(pc, 2, msg);
|
||||
if (pc.isCasting()) {
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
}
|
||||
|
||||
pc.setIsCasting(false);
|
||||
@@ -206,8 +192,7 @@ public enum PowersManager {
|
||||
msg.setUnknown04(1);
|
||||
|
||||
if (useMobPowerA(msg, caster)) {
|
||||
if(pb.token == -1994153779)
|
||||
InterestManager.setObjectDirty(caster);
|
||||
//sendMobPowerMsg(caster,2,msg); //Lol wtf was i thinking sending msg's to mobs... ZZZZ
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,48 +205,6 @@ public enum PowersManager {
|
||||
|
||||
boolean CSRCast = false;
|
||||
|
||||
if(msg.getPowerUsedID() == 430628895) {
|
||||
|
||||
boolean failed = false;// group teleport
|
||||
City city = ZoneManager.getCityAtLocation(playerCharacter.loc);
|
||||
if (city == null) {
|
||||
failed = true;
|
||||
}//else{
|
||||
// Bane bane = city.getBane();
|
||||
// if (bane == null) {
|
||||
// failed = true;
|
||||
// }else{
|
||||
// if(!bane.getSiegePhase().equals(SiegePhase.WAR)){
|
||||
// failed = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if(failed){
|
||||
//check to see if we are at an active mine
|
||||
Zone zone = ZoneManager.findSmallestZone(playerCharacter.loc);
|
||||
if(zone != null){
|
||||
Mine mine = null;
|
||||
for(Building building : zone.zoneBuildingSet){
|
||||
if(building.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)){
|
||||
mine = Mine.getMineFromTower(building.getObjectUUID());
|
||||
}
|
||||
}
|
||||
if(mine != null){
|
||||
failed = !mine.isActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(failed) {
|
||||
playerCharacter.setIsCasting(false);
|
||||
|
||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(msg.getPowerUsedID());
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, recyclePowerMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (MBServerStatics.POWERS_DEBUG) {
|
||||
ChatManager.chatSayInfo(
|
||||
@@ -298,7 +241,6 @@ public enum PowersManager {
|
||||
|
||||
// get power
|
||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID());
|
||||
|
||||
if (pb == null) {
|
||||
ChatManager.chatSayInfo(playerCharacter,
|
||||
"This power is not implemented yet.");
|
||||
@@ -310,35 +252,6 @@ public enum PowersManager {
|
||||
// return false;
|
||||
}
|
||||
|
||||
//check for movement buffs while flying
|
||||
if(playerCharacter.isFlying()) {
|
||||
switch(pb.token){
|
||||
case 429005674:
|
||||
case 429505739:
|
||||
case 431054700:
|
||||
case 428005600:
|
||||
case 431610080:
|
||||
case 427935608:
|
||||
case 427857146:
|
||||
case 427988218:
|
||||
case 431854842:
|
||||
case 421074170:
|
||||
case 429611355:
|
||||
case 428955899:
|
||||
case 1794395699:
|
||||
case 429428796:
|
||||
case 1514898036:
|
||||
ChatManager.chatSystemInfo(playerCharacter, "You Cannot Fly While Having A MovementBuff");
|
||||
//resync stamina
|
||||
playerCharacter.setStamina(playerCharacter.getStamina(), playerCharacter);
|
||||
|
||||
// Update all surrounding clients.
|
||||
TargetedActionMsg cmm = new TargetedActionMsg(playerCharacter);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, cmm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerCharacter.getLastPower() != null)
|
||||
return true;
|
||||
|
||||
@@ -346,18 +259,17 @@ public enum PowersManager {
|
||||
|
||||
|
||||
// Check powers for normal users
|
||||
if(msg.getPowerUsedID() != 421084024) {
|
||||
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID()))
|
||||
if (!playerCharacter.isCSR()) {
|
||||
if (!MBServerStatics.POWERS_DEBUG) {
|
||||
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
||||
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID()))
|
||||
if (!playerCharacter.isCSR()) {
|
||||
if (!MBServerStatics.POWERS_DEBUG) {
|
||||
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
||||
|
||||
Logger.info("usePowerA(): Cheat attempted? '" + msg.getPowerUsedID() + "' was not associated with " + playerCharacter.getName());
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
CSRCast = true;
|
||||
|
||||
Logger.info("usePowerA(): Cheat attempted? '" + msg.getPowerUsedID() + "' was not associated with " + playerCharacter.getName());
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
CSRCast = true;
|
||||
}
|
||||
// get numTrains for power
|
||||
int trains = msg.getNumTrains();
|
||||
|
||||
@@ -367,14 +279,6 @@ public enum PowersManager {
|
||||
msg.setNumTrains(trains);
|
||||
}
|
||||
|
||||
//double stack point values for some useless disc spells
|
||||
switch(pb.token){
|
||||
case 429420458: // BH eyes
|
||||
case 429601664: // huntsman skin the beast
|
||||
msg.setNumTrains(msg.getNumTrains() * 2);
|
||||
break;
|
||||
}
|
||||
|
||||
// can't go over total trains by player
|
||||
if (playerCharacter.getPowers() != null && playerCharacter.getPowers().containsKey(msg.getPowerUsedID())) {
|
||||
CharacterPower cp = playerCharacter.getPowers().get(msg.getPowerUsedID());
|
||||
@@ -409,6 +313,9 @@ public enum PowersManager {
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
Vector3fImmutable endLoc = playerCharacter.getEndLoc();
|
||||
|
||||
@@ -466,20 +373,15 @@ public enum PowersManager {
|
||||
float range = pb.getRange();
|
||||
// verify target is in range
|
||||
|
||||
if(pb.token != 429396028) {
|
||||
|
||||
if (verifyInvalidRange(playerCharacter, target, range))
|
||||
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
|
||||
// TODO send message that target is out of range
|
||||
return true;
|
||||
// verify target is valid type
|
||||
if (!validateTarget(target, playerCharacter, pb))
|
||||
return true;
|
||||
}else{
|
||||
pb.isSpell = false;
|
||||
}
|
||||
|
||||
if (verifyInvalidRange(playerCharacter, target, range))
|
||||
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
|
||||
// TODO send message that target is out of range
|
||||
return true;
|
||||
|
||||
// verify target is valid type
|
||||
if (!validateTarget(target, playerCharacter, pb))
|
||||
return true;
|
||||
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
@@ -510,23 +412,6 @@ public enum PowersManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(!passed){
|
||||
if (playerCharacter.getRace().getName().contains("Shade")) {
|
||||
if(playerCharacter.getHidden() > 0){
|
||||
switch(msg.getPowerUsedID()){
|
||||
case -1851459567:
|
||||
case 2094922127:
|
||||
case -355707373:
|
||||
case 246186475:
|
||||
case 666419835:
|
||||
case 1480354319:
|
||||
passed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!passed)
|
||||
return true;
|
||||
}
|
||||
@@ -605,6 +490,7 @@ public enum PowersManager {
|
||||
// Validity checks passed, move on to casting spell
|
||||
//get caster's live counter
|
||||
int casterLiveCounter = playerCharacter.getLiveCounter();
|
||||
|
||||
// run recycle job for when cast is available again, don't bother adding the timer for CSRs
|
||||
if (time > 0) {
|
||||
FinishRecycleTimeJob frtj = new FinishRecycleTimeJob(playerCharacter, msg);
|
||||
@@ -631,7 +517,7 @@ public enum PowersManager {
|
||||
|
||||
// make person casting stand up if spell (unless they're casting a chant which does not make them stand up)
|
||||
if (pb.isSpell() && !pb.isChant() && playerCharacter.isSit()) {
|
||||
playerCharacter.update(false);
|
||||
playerCharacter.update();
|
||||
playerCharacter.setSit(false);
|
||||
UpdateStateMsg updateStateMsg = new UpdateStateMsg(playerCharacter);
|
||||
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
@@ -639,12 +525,10 @@ public enum PowersManager {
|
||||
}
|
||||
|
||||
// update cast (use skill) fail condition
|
||||
if(pb.token != 429396028 && pb.breaksForm) {
|
||||
playerCharacter.cancelOnCast();
|
||||
}
|
||||
playerCharacter.cancelOnCast();
|
||||
|
||||
// update castSpell (use spell) fail condition if spell
|
||||
if (pb.isSpell() && pb.breaksForm)
|
||||
if (pb.isSpell())
|
||||
playerCharacter.cancelOnSpell();
|
||||
|
||||
// get cast time in ms.
|
||||
@@ -654,12 +538,13 @@ public enum PowersManager {
|
||||
|
||||
|
||||
if (time > 100) {
|
||||
playerCharacter.update(false);
|
||||
playerCharacter.update();
|
||||
playerCharacter.setIsCasting(true);
|
||||
}
|
||||
|
||||
|
||||
playerCharacter.setLastMovementState(playerCharacter.getMovementState());
|
||||
|
||||
// run timer job to end cast
|
||||
if (time < 1) // run immediately
|
||||
finishUsePower(copyMsg, playerCharacter, casterLiveCounter, targetLiveCounter);
|
||||
@@ -713,6 +598,9 @@ public enum PowersManager {
|
||||
SourceType sourceType = SourceType.GetSourceType(pb.getCategory());
|
||||
if (bonus != null && (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotCast, SourceType.None) || bonus.getBool(ModType.BlockedPowerType, sourceType)))
|
||||
return true;
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
return true;
|
||||
|
||||
// if moving make sure spell valid for movement
|
||||
// if flying, make sure spell valid for flying.
|
||||
@@ -785,11 +673,10 @@ public enum PowersManager {
|
||||
|
||||
// make person casting stand up if spell (unless they're casting a chant which does not make them stand up)
|
||||
// update cast (use skill) fail condition
|
||||
if(pb.breaksForm)
|
||||
caster.cancelOnCast();
|
||||
caster.cancelOnCast();
|
||||
|
||||
// update castSpell (use spell) fail condition if spell
|
||||
if (pb.isSpell() && pb.breaksForm)
|
||||
if (pb.isSpell())
|
||||
caster.cancelOnSpell();
|
||||
|
||||
// get cast time in ms.
|
||||
@@ -825,38 +712,8 @@ public enum PowersManager {
|
||||
if (playerCharacter == null || msg == null)
|
||||
return;
|
||||
|
||||
|
||||
//handle sprint for bard sprint
|
||||
if(msg.getPowerUsedID() == 429005674){
|
||||
msg.setPowerUsedID(429611355);
|
||||
}
|
||||
|
||||
//handle root and snare break for wildkin's chase
|
||||
if(msg.getPowerUsedID() == 429494441) {
|
||||
playerCharacter.removeEffectBySource(EffectSourceType.Root,40,true);
|
||||
playerCharacter.removeEffectBySource(EffectSourceType.Snare,40,true);
|
||||
}
|
||||
|
||||
//handle power block portion for shade hide
|
||||
if(playerCharacter.getRace().getName().contains("Shade")) {
|
||||
if (msg.getPowerUsedID() == 429407306 || msg.getPowerUsedID() == 429495514) {
|
||||
int trains = msg.getNumTrains() - 1;
|
||||
if (trains < 1)
|
||||
trains = 1;
|
||||
applyPower(playerCharacter, playerCharacter, playerCharacter.loc, 429397210, trains, false);
|
||||
playerCharacter.removeEffectBySource(EffectSourceType.Invisibility,40,true);
|
||||
applyPower(playerCharacter, playerCharacter, playerCharacter.loc, msg.getPowerUsedID(), msg.getNumTrains(), false);
|
||||
}
|
||||
}
|
||||
if(msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()) {
|
||||
PlayerCharacter target = PlayerCharacter.getPlayerCharacter(msg.getTargetID());
|
||||
if (msg.getPowerUsedID() == 429601664)
|
||||
if(target.getPromotionClassID() != 2516)
|
||||
PlayerCharacter.getPlayerCharacter(msg.getTargetID()).removeEffectBySource(EffectSourceType.Transform, msg.getNumTrains(), true);
|
||||
}
|
||||
|
||||
if (playerCharacter.isCasting()) {
|
||||
playerCharacter.update(false);
|
||||
playerCharacter.update();
|
||||
playerCharacter.updateStamRegen(-100);
|
||||
}
|
||||
|
||||
@@ -910,6 +767,11 @@ public enum PowersManager {
|
||||
finishRecycleTime(msg.getPowerUsedID(), playerCharacter, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bonus.getBool(ModType.Fear, SourceType.None)) {
|
||||
finishRecycleTime(msg.getPowerUsedID(), playerCharacter, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// get target loc
|
||||
@@ -958,16 +820,15 @@ public enum PowersManager {
|
||||
}
|
||||
float range = pb.getRange() + speedRange;
|
||||
|
||||
if(pb.token != 429396028) {
|
||||
|
||||
if (verifyInvalidRange(playerCharacter, mainTarget, range)) {
|
||||
if (verifyInvalidRange(playerCharacter, mainTarget, range)) {
|
||||
|
||||
sendPowerMsg(playerCharacter, 8, msg);
|
||||
return;
|
||||
}
|
||||
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
|
||||
// TODO send message that target is out of range
|
||||
sendPowerMsg(playerCharacter, 8, msg);
|
||||
return;
|
||||
}
|
||||
// (pc.getLoc().distance(target.getLoc()) > pb.getRange()) {
|
||||
// TODO send message that target is out of range
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1192,6 +1053,9 @@ public enum PowersManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bonus != null && bonus.getBool(ModType.Fear, SourceType.None))
|
||||
return;
|
||||
|
||||
msg.setNumTrains(9999);
|
||||
msg.setUnknown04(2);
|
||||
DispatchMessage.sendToAllInRange(caster, msg);
|
||||
@@ -1383,7 +1247,7 @@ public enum PowersManager {
|
||||
|
||||
PlayerCharacter target = SessionManager
|
||||
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||
if (target == null || target.equals(pc)) {
|
||||
if (target == null || target.equals(pc) || target.isCombat()) {
|
||||
|
||||
if (target == null) // Player not found. Send not found message
|
||||
ChatManager.chatInfoError(pc,
|
||||
@@ -1487,16 +1351,6 @@ public enum PowersManager {
|
||||
else
|
||||
duration = 45000; // Belgosh Summons, 45 seconds
|
||||
|
||||
boolean enemiesNear = false;
|
||||
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(pc.loc,MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER)){
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter)awo;
|
||||
if(!playerCharacter.guild.getNation().equals(pc.guild.getNation())){
|
||||
enemiesNear = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(enemiesNear && !pc.isInSafeZone())
|
||||
duration += 60000;
|
||||
|
||||
// Teleport to summoners location
|
||||
FinishSummonsJob fsj = new FinishSummonsJob(source, pc);
|
||||
@@ -1622,18 +1476,8 @@ public enum PowersManager {
|
||||
}
|
||||
|
||||
// create list of characters
|
||||
HashSet<AbstractCharacter> trackChars;
|
||||
switch(msg.getPowerToken()){
|
||||
case 431511776:
|
||||
case 429578587:
|
||||
case 429503360:
|
||||
case 44106356:
|
||||
trackChars = getTrackList(playerCharacter);
|
||||
break;
|
||||
default:
|
||||
trackChars = RangeBasedAwo.getTrackList(allTargets, playerCharacter, maxTargets);
|
||||
break;
|
||||
}
|
||||
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
|
||||
allTargets, playerCharacter, maxTargets);
|
||||
|
||||
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
||||
|
||||
@@ -1646,30 +1490,6 @@ public enum PowersManager {
|
||||
|
||||
}
|
||||
|
||||
public static HashSet<AbstractCharacter> getTrackList(PlayerCharacter tracker){
|
||||
HashSet<AbstractCharacter> list = new HashSet<AbstractCharacter>();
|
||||
HashSet<AbstractWorldObject> shortList = WorldGrid.getObjectsInRangePartial(tracker.loc,MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
|
||||
HashSet<AbstractWorldObject> fullList = WorldGrid.getObjectsInRangePartial(tracker.loc,1408, MBServerStatics.MASK_PLAYER);
|
||||
ArrayList<Guild> guildsPresent = new ArrayList<>();
|
||||
for(AbstractWorldObject awo : shortList){
|
||||
PlayerCharacter pc = (PlayerCharacter)awo;
|
||||
if(!guildsPresent.contains(pc.guild.getNation())){
|
||||
guildsPresent.add(pc.guild.getNation());
|
||||
}
|
||||
}
|
||||
for(AbstractWorldObject awo : fullList){
|
||||
if(awo.equals(tracker))
|
||||
continue;
|
||||
PlayerCharacter pc = (PlayerCharacter)awo;
|
||||
if(!pc.isAlive())
|
||||
continue;
|
||||
if(guildsPresent.contains(pc.guild.getNation()))
|
||||
list.add(pc);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void sendRecyclePower(int token, ClientConnection origin) {
|
||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
|
||||
|
||||
@@ -2383,7 +2203,7 @@ public enum PowersManager {
|
||||
|
||||
// set player is not casting for regens
|
||||
if (pc.isCasting()) {
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
}
|
||||
pc.setIsCasting(false);
|
||||
|
||||
@@ -2435,26 +2255,28 @@ public enum PowersManager {
|
||||
defense = 0f;
|
||||
// Get hit chance
|
||||
|
||||
//if (pc.getDebug(16)) {
|
||||
// String smsg = "ATR: " + atr + ", Defense: " + defense;
|
||||
// ChatManager.chatSystemInfo(pc, smsg);
|
||||
//}
|
||||
if (pc.getDebug(16)) {
|
||||
String smsg = "ATR: " + atr + ", Defense: " + defense;
|
||||
ChatManager.chatSystemInfo(pc, smsg);
|
||||
}
|
||||
|
||||
//int chance;
|
||||
int chance;
|
||||
|
||||
//if (atr > defense || defense == 0)
|
||||
// chance = 94;
|
||||
//else {
|
||||
// float dif = atr / defense;
|
||||
// if (dif <= 0.8f)
|
||||
// chance = 4;
|
||||
// else
|
||||
// chance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
//}
|
||||
if (atr > defense || defense == 0)
|
||||
chance = 94;
|
||||
else {
|
||||
float dif = atr / defense;
|
||||
if (dif <= 0.8f)
|
||||
chance = 4;
|
||||
else
|
||||
chance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
}
|
||||
|
||||
// calculate hit/miss
|
||||
int roll = ThreadLocalRandom.current().nextInt(100);
|
||||
|
||||
if (CombatManager.LandHit((int)atr,(int)defense)) {
|
||||
boolean disable = true;
|
||||
if (roll < chance) {
|
||||
// Hit, check if dodge kicked in
|
||||
if (awo instanceof AbstractCharacter) {
|
||||
AbstractCharacter tarAc = (AbstractCharacter) awo;
|
||||
@@ -2466,13 +2288,6 @@ public enum PowersManager {
|
||||
dodgeMsg.setTargetID(awo.getObjectUUID());
|
||||
sendPowerMsg(pc, 4, dodgeMsg);
|
||||
return true;
|
||||
} else if (testPassive(pc, tarAc, "Block")) {
|
||||
// Dodge fired, send dodge message
|
||||
PerformActionMsg dodgeMsg = new PerformActionMsg(msg);
|
||||
dodgeMsg.setTargetType(awo.getObjectType().ordinal());
|
||||
dodgeMsg.setTargetID(awo.getObjectUUID());
|
||||
sendPowerMsg(pc, 4, dodgeMsg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -2520,12 +2335,7 @@ public enum PowersManager {
|
||||
if (AbstractWorldObject.IsAbstractCharacter(awo)) {
|
||||
AbstractCharacter tarAc = (AbstractCharacter) awo;
|
||||
// Handle Dodge passive
|
||||
boolean passiveFired = false;
|
||||
passiveFired = testPassive(caster, tarAc, "Dodge");
|
||||
if(!passiveFired)
|
||||
passiveFired = testPassive(caster, tarAc, "Block");
|
||||
|
||||
return passiveFired;
|
||||
return testPassive(caster, tarAc, "Dodge");
|
||||
}
|
||||
return false;
|
||||
} else
|
||||
@@ -2766,9 +2576,11 @@ public enum PowersManager {
|
||||
}
|
||||
|
||||
public static void cancelOnStun(AbstractCharacter ac) {
|
||||
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
//PlayerCharacter.GroundPlayer((PlayerCharacter)ac);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void cancelOnFear(AbstractCharacter ac) {
|
||||
|
||||
}
|
||||
|
||||
private static PowersBase getLastPower(AbstractCharacter ac) {
|
||||
@@ -2914,126 +2726,6 @@ public enum PowersManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean breakForm(int token) {
|
||||
switch (token) {
|
||||
case 429505865:
|
||||
case 429407561:
|
||||
case 429492073:
|
||||
case 429644123:
|
||||
case 429393769:
|
||||
case 429545819:
|
||||
case 429426537:
|
||||
case 429590377:
|
||||
case 429508425:
|
||||
case 429541193:
|
||||
case 429573961:
|
||||
case 427924330:
|
||||
case 429402918:
|
||||
case 429545688:
|
||||
case 429005674:
|
||||
case 429637823:
|
||||
case 429590426:
|
||||
case 428066972:
|
||||
case 429441862:
|
||||
case 431611756:
|
||||
case 431578988:
|
||||
case 429502506:
|
||||
case 429398191:
|
||||
case 429447384:
|
||||
case 428892191:
|
||||
case 431579167:
|
||||
case 430977067:
|
||||
case 429409100:
|
||||
case 429441868:
|
||||
case 429594877:
|
||||
case 427908971:
|
||||
case 683741153:
|
||||
case 429770569:
|
||||
case 429452379:
|
||||
case 429605055:
|
||||
case 429086971:
|
||||
case 429443230:
|
||||
case 429505400:
|
||||
case 429492122:
|
||||
case 429643992:
|
||||
case 550062236:
|
||||
case 429498252:
|
||||
case 429611224:
|
||||
case 429441834:
|
||||
case 428918940:
|
||||
case 429633739:
|
||||
case 429633579:
|
||||
case 429568043:
|
||||
case 429048646:
|
||||
case 428392639:
|
||||
case 428425407:
|
||||
case 429054168:
|
||||
case 429021400:
|
||||
case 428955864:
|
||||
case 429119704:
|
||||
case 428890328:
|
||||
case 428923096:
|
||||
case 429218008:
|
||||
case 429086936:
|
||||
case 428988632:
|
||||
case 428688204:
|
||||
case 429514603:
|
||||
case 428924959:
|
||||
case 429393818:
|
||||
case 429720966:
|
||||
case 428982463:
|
||||
case 427933887:
|
||||
case 429572287:
|
||||
case 429501222:
|
||||
case 430694431:
|
||||
case 429436131:
|
||||
case 430006124:
|
||||
case 429611355:
|
||||
case 428005600:
|
||||
case 427935608:
|
||||
case 428949695:
|
||||
case 427988218:
|
||||
case 429414616:
|
||||
case 429496495:
|
||||
case 429428796:
|
||||
case 563795754:
|
||||
case 428988217:
|
||||
case 429432716:
|
||||
case 428955899:
|
||||
case 429393286:
|
||||
case 550062220:
|
||||
case 429495557:
|
||||
case 429401278:
|
||||
case 428377478:
|
||||
case 429409094:
|
||||
case 428191947:
|
||||
case 429434474:
|
||||
case 429403363:
|
||||
case 429512920:
|
||||
case 429419611:
|
||||
case 429645676:
|
||||
case 429602895:
|
||||
case 429605071:
|
||||
case 429592428:
|
||||
case 429500010:
|
||||
case 429406602:
|
||||
case 429426586:
|
||||
case 429633898:
|
||||
case 550062212:
|
||||
case 429994027:
|
||||
case 430813227:
|
||||
case 429928491:
|
||||
case 430026795:
|
||||
case 429517915:
|
||||
case 431854842:
|
||||
case 429767544:
|
||||
case 429502507:
|
||||
case 428398816:
|
||||
case 429446315:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.City;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Runegate;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -30,7 +33,7 @@ public enum SimulationManager {
|
||||
SERVERHEARTBEAT;
|
||||
|
||||
private static final long CITY_PULSE = 2000;
|
||||
private static final long RUNEGATE_PULSE = 1000;
|
||||
private static final long RUNEGATE_PULSE = 3000;
|
||||
private static final long UPDATE_PULSE = 1000;
|
||||
private static final long FlIGHT_PULSE = 100;
|
||||
public static Duration executionTime = Duration.ofNanos(1);
|
||||
@@ -93,10 +96,13 @@ public enum SimulationManager {
|
||||
}
|
||||
try {
|
||||
|
||||
if ((_updatePulseTime != 0) && (System.currentTimeMillis() > _updatePulseTime))
|
||||
if ((_updatePulseTime != 0)
|
||||
&& (System.currentTimeMillis() > _updatePulseTime))
|
||||
pulseUpdate();
|
||||
} catch (Exception e) {
|
||||
Logger.error("Fatal error in Update Pulse: DISABLED");
|
||||
Logger.error(
|
||||
"Fatal error in Update Pulse: DISABLED");
|
||||
// _runegatePulseTime = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -110,18 +116,9 @@ public enum SimulationManager {
|
||||
}
|
||||
|
||||
try {
|
||||
if ((_cityPulseTime != 0) && (System.currentTimeMillis() > _cityPulseTime)) {
|
||||
try {
|
||||
pulseCities();
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
try {
|
||||
ArenaManager.pulseArenas();
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
if ((_cityPulseTime != 0)
|
||||
&& (System.currentTimeMillis() > _cityPulseTime))
|
||||
pulseCities();
|
||||
} catch (Exception e) {
|
||||
Logger.error(
|
||||
"Fatal error in City Pulse: DISABLED. Error Message : "
|
||||
@@ -157,11 +154,7 @@ public enum SimulationManager {
|
||||
|
||||
if (player == null)
|
||||
continue;
|
||||
try {
|
||||
player.update(false);
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
player.update();
|
||||
}
|
||||
|
||||
_updatePulseTime = System.currentTimeMillis() + 500;
|
||||
@@ -210,12 +203,8 @@ public enum SimulationManager {
|
||||
city = (City) cityObject;
|
||||
city.onEnter();
|
||||
}
|
||||
for(Mine mine : Mine.getMines()){
|
||||
if(mine != null && mine.isActive)
|
||||
mine.onEnter();
|
||||
}
|
||||
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
|
||||
|
||||
_cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -225,10 +214,6 @@ public enum SimulationManager {
|
||||
private void pulseRunegates() {
|
||||
|
||||
for (Runegate runegate : Runegate._runegates.values()) {
|
||||
for(Portal portal : runegate._portals)
|
||||
if(!portal.isActive())
|
||||
portal.activate(false);
|
||||
|
||||
runegate.collidePortals();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,347 +0,0 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class StrongholdManager {
|
||||
|
||||
public static void processStrongholds() {
|
||||
ArrayList<Mine> mines = Mine.getMines();
|
||||
|
||||
|
||||
//process strongholds selecting 3 randomly to become active
|
||||
int count = 0;
|
||||
while (count < 3) {
|
||||
int random = ThreadLocalRandom.current().nextInt(1, mines.size()) - 1;
|
||||
Mine mine = mines.get(random);
|
||||
if (mine != null) {
|
||||
if (!mine.isActive && !mine.isStronghold) {
|
||||
StartStronghold(mine);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartStronghold(Mine mine){
|
||||
|
||||
//remove buildings
|
||||
Building tower = BuildingManager.getBuilding(mine.getBuildingID());
|
||||
if(tower == null)
|
||||
return;
|
||||
|
||||
mine.isStronghold = true;
|
||||
mine.strongholdMobs = new ArrayList<>();
|
||||
mine.oldBuildings = new HashMap<>();
|
||||
|
||||
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
|
||||
for(Building building : mineZone.zoneBuildingSet){
|
||||
mine.oldBuildings.put(building.getObjectUUID(),building.meshUUID);
|
||||
building.setMeshUUID(407650);
|
||||
building.setMeshScale(new Vector3f(0,0,0));
|
||||
InterestManager.setObjectDirty(building);
|
||||
WorldGrid.updateObject(building);
|
||||
}
|
||||
|
||||
//update tower to become stronghold mesh
|
||||
tower.setMeshUUID(getStrongholdMeshID(mine.getParentZone()));
|
||||
tower.setMeshScale(new Vector3f(1,1,1));
|
||||
InterestManager.setObjectDirty(tower);
|
||||
WorldGrid.updateObject(tower);
|
||||
|
||||
//create elite mobs
|
||||
for(int i = 0; i < mine.capSize * 2; i++){
|
||||
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(tower.loc,30);
|
||||
MobBase guardBase = MobBase.getMobBase(getStrongholdGuardianID(tower.meshUUID));
|
||||
Mob guard = Mob.createStrongholdMob(guardBase.getLoadID(), loc, Guild.getErrantGuild(),true,mineZone,null,0, guardBase.getFirstName(),65);
|
||||
if(guard != null){
|
||||
guard.parentZone = mine.getParentZone();
|
||||
guard.bindLoc = loc;
|
||||
guard.setLoc(loc);
|
||||
guard.StrongholdGuardian = true;
|
||||
guard.equipmentSetID = getStrongholdMobEquipSetID(guard);
|
||||
guard.runAfterLoad();
|
||||
guard.setLevel((short)65);
|
||||
guard.setResists(new Resists("Elite"));
|
||||
guard.spawnTime = 1000000000;
|
||||
guard.BehaviourType = Enum.MobBehaviourType.Aggro;
|
||||
mine.strongholdMobs.add(guard);
|
||||
LootManager.GenerateStrongholdLoot(guard,false,false);
|
||||
guard.healthMax = 12500;
|
||||
guard.setHealth(guard.healthMax);
|
||||
guard.maxDamageHandOne = 1550;
|
||||
guard.minDamageHandOne = 750;
|
||||
guard.atrHandOne = 1800;
|
||||
guard.defenseRating = 2200;
|
||||
guard.setFirstName("Elite Guardian");
|
||||
InterestManager.setObjectDirty(guard);
|
||||
WorldGrid.addObject(guard,loc.x,loc.z);
|
||||
WorldGrid.updateObject(guard);
|
||||
guard.stronghold = mine;
|
||||
guard.mobPowers.clear();
|
||||
guard.mobPowers.put(429399948,20); // find weakness
|
||||
}
|
||||
}
|
||||
//create stronghold commander
|
||||
Vector3fImmutable loc = tower.loc;
|
||||
MobBase commanderBase = MobBase.getMobBase(getStrongholdCommanderID(tower.meshUUID));
|
||||
Mob commander = Mob.createStrongholdMob(commanderBase.getLoadID(), loc,Guild.getErrantGuild(),true,mineZone,null,0, commanderBase.getFirstName(),75);
|
||||
if(commander != null){
|
||||
commander.parentZone = mine.getParentZone();
|
||||
commander.bindLoc = loc;
|
||||
commander.setLoc(loc);
|
||||
commander.StrongholdCommander = true;
|
||||
commander.equipmentSetID = getStrongholdMobEquipSetID(commander);
|
||||
commander.runAfterLoad();
|
||||
commander.setLevel((short)75);
|
||||
commander.setResists(new Resists("Elite"));
|
||||
commander.spawnTime = 1000000000;
|
||||
commander.BehaviourType = Enum.MobBehaviourType.Aggro;
|
||||
commander.mobPowers.clear();
|
||||
commander.mobPowers.put(429032838, 40); // gravechill
|
||||
commander.mobPowers.put(429757701,20); // magebolt
|
||||
commander.mobPowers.put(429121388,20); // blight
|
||||
commander.mobPowers.put(431566891,20); // lightning bolt
|
||||
commander.mobPowers.put(428716075,20); // fire bolt
|
||||
commander.mobPowers.put(429010987,20); // ice bolt
|
||||
mine.strongholdMobs.add(commander);
|
||||
LootManager.GenerateStrongholdLoot(commander,true, false);
|
||||
commander.healthMax = 50000;
|
||||
commander.setHealth(commander.healthMax);
|
||||
commander.maxDamageHandOne = 3500;
|
||||
commander.minDamageHandOne = 1500;
|
||||
commander.atrHandOne = 3500;
|
||||
commander.defenseRating = 3500;
|
||||
commander.setFirstName("Guardian Commander");
|
||||
InterestManager.setObjectDirty(commander);
|
||||
WorldGrid.addObject(commander,loc.x,loc.z);
|
||||
WorldGrid.updateObject(commander);
|
||||
commander.stronghold = mine;
|
||||
}
|
||||
|
||||
mine.isActive = true;
|
||||
tower.setProtectionState(Enum.ProtectionState.PROTECTED);
|
||||
tower.getBounds().setRegions(tower);
|
||||
InterestManager.setObjectDirty(tower);
|
||||
WorldGrid.updateObject(tower);
|
||||
ChatManager.chatSystemChannel(mine.getZoneName() + "'s Stronghold Has Begun!");
|
||||
Logger.info(mine.getZoneName() + "'s Stronghold Has Begun!");
|
||||
}
|
||||
|
||||
public static void EndStronghold(Mine mine){
|
||||
|
||||
//restore the buildings
|
||||
Building tower = BuildingManager.getBuilding(mine.getBuildingID());
|
||||
if(tower == null)
|
||||
return;
|
||||
|
||||
mine.isStronghold = false;
|
||||
|
||||
//get rid of the mobs
|
||||
for(Mob mob : mine.strongholdMobs) {
|
||||
mob.despawn();
|
||||
mob.removeFromCache();
|
||||
DbManager.MobQueries.DELETE_MOB(mob);
|
||||
}
|
||||
|
||||
//restore the buildings
|
||||
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
|
||||
for(Building building : mineZone.zoneBuildingSet){
|
||||
if(mine.oldBuildings.containsKey(building.getObjectUUID())) {
|
||||
building.setMeshUUID(mine.oldBuildings.get(building.getObjectUUID()));
|
||||
building.setMeshScale(new Vector3f(1, 1, 1));
|
||||
InterestManager.setObjectDirty(building);
|
||||
WorldGrid.updateObject(building);
|
||||
}
|
||||
}
|
||||
|
||||
//update tower to become Mine Tower again
|
||||
tower.setMeshUUID(1500100);
|
||||
|
||||
mine.isActive = false;
|
||||
tower.setProtectionState(Enum.ProtectionState.NPC);
|
||||
tower.getBounds().setRegions(tower);
|
||||
InterestManager.setObjectDirty(tower);
|
||||
WorldGrid.updateObject(tower);
|
||||
ChatManager.chatSystemChannel(mine.getZoneName() + "'s Stronghold Has Concluded!");
|
||||
Logger.info(mine.getZoneName() + "'s Stronghold Has Concluded!");
|
||||
}
|
||||
|
||||
public static int getStrongholdMeshID(Zone parent){
|
||||
while(!parent.isMacroZone()){
|
||||
parent = parent.getParent();
|
||||
if(parent.getName().equalsIgnoreCase("seafloor")){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
switch(parent.getObjectUUID()){
|
||||
case 197:
|
||||
case 234:
|
||||
case 178:
|
||||
case 122:
|
||||
return 814000; //Frost Giant Hall (ICE)
|
||||
case 968:
|
||||
case 951:
|
||||
case 313:
|
||||
case 331:
|
||||
return 5001500; // Lich Queens Keep (UNDEAD)
|
||||
case 785:
|
||||
case 761:
|
||||
case 717:
|
||||
case 737:
|
||||
return 1306600; // Temple of the Dragon (DESERT)
|
||||
case 353:
|
||||
case 371:
|
||||
case 388:
|
||||
case 532:
|
||||
return 564600; // Undead Lord's Keep (SWAMP)
|
||||
case 550:
|
||||
case 508:
|
||||
case 475:
|
||||
case 418:
|
||||
return 1326600; // elven hall
|
||||
case 437:
|
||||
case 491:
|
||||
case 590:
|
||||
case 569:
|
||||
return 602400;
|
||||
case 824:
|
||||
case 842:
|
||||
case 632:
|
||||
return 1600000; // chaos temple
|
||||
}
|
||||
return 456100; // small stockade
|
||||
}
|
||||
|
||||
public static int getStrongholdGuardianID(int ID){
|
||||
switch(ID){
|
||||
case 814000:
|
||||
return 253004; // Mountain Giant Raider Axe
|
||||
case 5001500:
|
||||
return 253008; // Vampire Spear Warrior
|
||||
case 1306600:
|
||||
return 253007; // Desert Orc Warrior
|
||||
case 564600:
|
||||
return 253010; // Kolthoss Warrior
|
||||
case 1326600:
|
||||
return 253005; //elven warrior
|
||||
case 602400:
|
||||
return 253009; // templar missionary
|
||||
case 1600000:
|
||||
return 253006; // scourger
|
||||
}
|
||||
return 13434; // human sword and board warrior
|
||||
}
|
||||
|
||||
public static int getStrongholdEpicID(int ID){
|
||||
switch(ID){
|
||||
case 814000:
|
||||
return 253023; // Mountain Giant Raider Axe
|
||||
case 5001500:
|
||||
return 253022; // Vampire Spear Warrior
|
||||
case 1306600:
|
||||
return 253021; // Desert Orc Warrior
|
||||
case 564600:
|
||||
return 253018; // Kolthoss Warrior
|
||||
case 1326600:
|
||||
return 253019; //elven warrior
|
||||
case 602400:
|
||||
return 253024; // templar missionary
|
||||
case 1600000:
|
||||
return 253020; // scourger
|
||||
}
|
||||
return 13434; // human sword and board warrior
|
||||
}
|
||||
|
||||
public static int getStrongholdCommanderID(int ID){
|
||||
switch(ID){
|
||||
case 814000:
|
||||
return 253017;
|
||||
case 5001500:
|
||||
return 253012;
|
||||
case 1306600:
|
||||
return 253016; // Desert Orc Xbow
|
||||
case 564600:
|
||||
return 253011; // xbow kolthoss
|
||||
case 1326600:
|
||||
return 253013; //elven bow warrior
|
||||
case 602400:
|
||||
return 253015; // dune giant with xbow
|
||||
case 1600000:
|
||||
return 253014; // barbator
|
||||
}
|
||||
return 13433;
|
||||
}
|
||||
|
||||
public static int getStrongholdMobEquipSetID(Mob mob) {
|
||||
if(mob.StrongholdGuardian){
|
||||
return 6327;
|
||||
}else{
|
||||
return 10790;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckToEndStronghold(Mine mine) {
|
||||
|
||||
boolean stillAlive = false;
|
||||
for (Mob mob : mine.strongholdMobs)
|
||||
if (mob.isAlive())
|
||||
stillAlive = true;
|
||||
|
||||
if (!stillAlive) {
|
||||
// Epic encounter
|
||||
|
||||
Building tower = BuildingManager.getBuilding(mine.getBuildingID());
|
||||
if (tower == null)
|
||||
return;
|
||||
|
||||
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
|
||||
|
||||
Vector3fImmutable loc = tower.loc;
|
||||
MobBase commanderBase = MobBase.getMobBase(getStrongholdEpicID(tower.meshUUID));
|
||||
Mob commander = Mob.createStrongholdMob(commanderBase.getLoadID(), loc, Guild.getErrantGuild(), true, mineZone, null, 0, commanderBase.getFirstName(), 75);
|
||||
if (commander != null) {
|
||||
commander.parentZone = mine.getParentZone();
|
||||
commander.bindLoc = loc;
|
||||
commander.setLoc(loc);
|
||||
commander.StrongholdEpic = true;
|
||||
commander.equipmentSetID = getStrongholdMobEquipSetID(commander);
|
||||
commander.runAfterLoad();
|
||||
commander.setLevel((short) 85);
|
||||
commander.setResists(new Resists("Elite"));
|
||||
commander.spawnTime = 1000000000;
|
||||
commander.BehaviourType = Enum.MobBehaviourType.Aggro;
|
||||
commander.mobPowers.clear();
|
||||
commander.mobPowers.put(429032838, 40); // gravechill
|
||||
commander.mobPowers.put(429757701,40); // magebolt
|
||||
commander.mobPowers.put(429121388,40); // blight
|
||||
commander.mobPowers.put(431566891,40); // lightning bolt
|
||||
commander.mobPowers.put(428716075,40); // fire bolt
|
||||
commander.mobPowers.put(429010987,40); // ice bolt
|
||||
mine.strongholdMobs.add(commander);
|
||||
LootManager.GenerateStrongholdLoot(commander, true, true);
|
||||
commander.healthMax = 250000;
|
||||
commander.setHealth(commander.healthMax);
|
||||
commander.maxDamageHandOne = 5000;
|
||||
commander.minDamageHandOne = 2500;
|
||||
commander.atrHandOne = 5000;
|
||||
commander.defenseRating = 3500;
|
||||
commander.setFirstName("Defender of " + mine.getParentZone().getParent().getName());
|
||||
InterestManager.setObjectDirty(commander);
|
||||
WorldGrid.addObject(commander,loc.x,loc.z);
|
||||
WorldGrid.updateObject(commander);
|
||||
commander.stronghold = mine;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
package engine.gameManager;
|
||||
import engine.objects.Guild;
|
||||
public class ZergManager {
|
||||
|
||||
public static float getCurrentMultiplier(int count, int maxCount){
|
||||
switch(maxCount) {
|
||||
case 3: return getMultiplier3Man(count);
|
||||
case 5: return getMultiplier5Man(count);
|
||||
case 10: return getMultiplier10Man(count);
|
||||
case 20: return getMultiplier20Man(count);
|
||||
case 30: return getMultiplier30Man(count);
|
||||
case 40: return getMultiplier40Man(count);
|
||||
default: return 1.0f; //unlimited
|
||||
}
|
||||
}
|
||||
public static float getMultiplier3Man(int count) {
|
||||
if(count < 4)
|
||||
return 1.0f;
|
||||
|
||||
if(count > 6)
|
||||
return 0.0f;
|
||||
|
||||
switch(count){
|
||||
case 4: return 0.63f;
|
||||
case 5: return 0.40f;
|
||||
case 6: return 0.25f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
}
|
||||
public static float getMultiplier5Man(int count) {
|
||||
if(count < 6)
|
||||
return 1.0f;
|
||||
|
||||
if(count > 10)
|
||||
return 0.0f;
|
||||
|
||||
switch(count){
|
||||
case 6: return 0.75f;
|
||||
case 7: return 0.57f;
|
||||
case 8: return 0.44f;
|
||||
case 9: return 0.33f;
|
||||
case 10: return 0.25f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
}
|
||||
public static float getMultiplier10Man(int count) {
|
||||
if(count < 11)
|
||||
return 1.0f;
|
||||
|
||||
if(count > 20)
|
||||
return 0.0f;
|
||||
|
||||
switch(count){
|
||||
case 11: return 0.86f;
|
||||
case 12: return 0.75f;
|
||||
case 13: return 0.65f;
|
||||
case 14: return 0.57f;
|
||||
case 15: return 0.50f;
|
||||
case 16: return 0.44f;
|
||||
case 17: return 0.38f;
|
||||
case 18: return 0.33f;
|
||||
case 19: return 0.29f;
|
||||
case 20: return 0.25f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
}
|
||||
public static float getMultiplier20Man(int count) {
|
||||
if(count < 21)
|
||||
return 1.0f;
|
||||
|
||||
if(count > 40)
|
||||
return 0.0f;
|
||||
|
||||
switch (count)
|
||||
{
|
||||
case 21: return 0.93f;
|
||||
case 22: return 0.86f;
|
||||
case 23: return 0.80f;
|
||||
case 24: return 0.75f;
|
||||
case 25: return 0.70f;
|
||||
case 26: return 0.65f;
|
||||
case 27: return 0.61f;
|
||||
case 28: return 0.57f;
|
||||
case 29: return 0.53f;
|
||||
case 30: return 0.50f;
|
||||
case 31: return 0.47f;
|
||||
case 32: return 0.44f;
|
||||
case 33: return 0.41f;
|
||||
case 34: return 0.38f;
|
||||
case 35: return 0.36f;
|
||||
case 36: return 0.33f;
|
||||
case 37: return 0.31f;
|
||||
case 38: return 0.29f;
|
||||
case 39: return 0.27f;
|
||||
case 40: return 0.25f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
public static float getMultiplier30Man(int count) {
|
||||
if(count < 31)
|
||||
return 1.0f;
|
||||
|
||||
if(count > 60)
|
||||
return 0.0f;
|
||||
|
||||
switch (count)
|
||||
{
|
||||
case 31: return 0.95f;
|
||||
case 32: return 0.91f;
|
||||
case 33: return 0.86f;
|
||||
case 34: return 0.82f;
|
||||
case 35: return 0.79f;
|
||||
case 36: return 0.75f;
|
||||
case 37: return 0.72f;
|
||||
case 38: return 0.68f;
|
||||
case 39: return 0.65f;
|
||||
case 40: return 0.63f;
|
||||
case 41: return 0.60f;
|
||||
case 42: return 0.57f;
|
||||
case 43: return 0.55f;
|
||||
case 44: return 0.52f;
|
||||
case 45: return 0.50f;
|
||||
case 46: return 0.48f;
|
||||
case 47: return 0.46f;
|
||||
case 48: return 0.44f;
|
||||
case 49: return 0.42f;
|
||||
case 50: return 0.40f;
|
||||
case 51: return 0.38f;
|
||||
case 52: return 0.37f;
|
||||
case 53: return 0.35f;
|
||||
case 54: return 0.33f;
|
||||
case 55: return 0.32f;
|
||||
case 56: return 0.30f;
|
||||
case 57: return 0.29f;
|
||||
case 58: return 0.28f;
|
||||
case 59: return 0.26f;
|
||||
case 60: return 0.25f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
public static float getMultiplier40Man(int count) {
|
||||
if(count < 41)
|
||||
return 1.0f;
|
||||
|
||||
if(count > 80)
|
||||
return 0.0f;
|
||||
|
||||
switch (count)
|
||||
{
|
||||
case 41: return 0.96f;
|
||||
case 42: return 0.93f;
|
||||
case 43: return 0.90f;
|
||||
case 44: return 0.86f;
|
||||
case 45: return 0.83f;
|
||||
case 46: return 0.80f;
|
||||
case 47: return 0.78f;
|
||||
case 48: return 0.75f;
|
||||
case 49: return 0.72f;
|
||||
case 50: return 0.70f;
|
||||
case 51: return 0.68f;
|
||||
case 52: return 0.65f;
|
||||
case 53: return 0.63f;
|
||||
case 54: return 0.61f;
|
||||
case 55: return 0.59f;
|
||||
case 56: return 0.57f;
|
||||
case 57: return 0.55f;
|
||||
case 58: return 0.53f;
|
||||
case 59: return 0.52f;
|
||||
case 60: return 0.50f;
|
||||
case 61: return 0.48f;
|
||||
case 62: return 0.47f;
|
||||
case 63: return 0.45f;
|
||||
case 64: return 0.44f;
|
||||
case 65: return 0.42f;
|
||||
case 66: return 0.41f;
|
||||
case 67: return 0.40f;
|
||||
case 68: return 0.38f;
|
||||
case 69: return 0.37f;
|
||||
case 70: return 0.36f;
|
||||
case 71: return 0.35f;
|
||||
case 72: return 0.33f;
|
||||
case 73: return 0.32f;
|
||||
case 74: return 0.31f;
|
||||
case 75: return 0.30f;
|
||||
case 76: return 0.29f;
|
||||
case 77: return 0.28f;
|
||||
case 78: return 0.27f;
|
||||
case 79: return 0.26f;
|
||||
case 80: return 0.25f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,14 @@ import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import engine.objects.Zone;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/*
|
||||
* Class contains methods and structures which
|
||||
@@ -107,6 +109,20 @@ public enum ZoneManager {
|
||||
|
||||
}
|
||||
|
||||
// Returns the number of available hotZones
|
||||
// remaining in this cycle (1am)
|
||||
|
||||
public static int availableHotZones() {
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (Zone zone : ZoneManager.macroZones)
|
||||
if (ZoneManager.validHotZone(zone))
|
||||
count = count + 1;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// Resets the availability of hotZones
|
||||
// for this cycle
|
||||
|
||||
@@ -201,6 +217,63 @@ public enum ZoneManager {
|
||||
ZoneManager.playerCityZones.add(zone);
|
||||
}
|
||||
|
||||
public static final void generateAndSetRandomHotzone() {
|
||||
|
||||
Zone hotZone;
|
||||
ArrayList<Integer> zoneArray = new ArrayList<>();
|
||||
|
||||
if (ZoneManager.macroZones.isEmpty())
|
||||
return;
|
||||
|
||||
// Reset hotZone availability if none are left.
|
||||
|
||||
if (ZoneManager.availableHotZones() == 0)
|
||||
ZoneManager.resetHotZones();
|
||||
|
||||
for (Zone zone : ZoneManager.macroZones)
|
||||
if (validHotZone(zone))
|
||||
zoneArray.add(zone.getObjectUUID());
|
||||
|
||||
int entryIndex = ThreadLocalRandom.current().nextInt(zoneArray.size());
|
||||
|
||||
hotZone = ZoneManager.getZoneByUUID(zoneArray.get(entryIndex));
|
||||
|
||||
if (hotZone == null) {
|
||||
Logger.error("Hotzone is null");
|
||||
return;
|
||||
}
|
||||
|
||||
ZoneManager.setHotZone(hotZone);
|
||||
|
||||
}
|
||||
|
||||
public static final boolean validHotZone(Zone zone) {
|
||||
|
||||
if (zone.getSafeZone() == (byte) 1)
|
||||
return false; // no safe zone hotzones// if (this.hotzone == null)
|
||||
|
||||
if (zone.getNodes().isEmpty())
|
||||
return false;
|
||||
|
||||
if (zone.equals(ZoneManager.seaFloor))
|
||||
return false;
|
||||
|
||||
//no duplicate hotZones
|
||||
|
||||
if (zone.hasBeenHotzone == true)
|
||||
return false;
|
||||
|
||||
// Enforce min level
|
||||
|
||||
if (zone.minLvl < Integer.parseInt(ConfigManager.MB_HOTZONE_MIN_LEVEL.getValue()))
|
||||
return false;
|
||||
|
||||
if (ZoneManager.hotZone != null)
|
||||
return ZoneManager.hotZone.getObjectUUID() != zone.getObjectUUID();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Converts world coordinates to coordinates local to a given zone.
|
||||
|
||||
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractJob implements Runnable {
|
||||
this.markStopRunTime();
|
||||
}
|
||||
|
||||
public abstract void doJob();
|
||||
protected abstract void doJob();
|
||||
|
||||
public void executeJob(String threadName) {
|
||||
this.workerID.set(threadName);
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class AbstractScheduleJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void doJob();
|
||||
protected abstract void doJob();
|
||||
|
||||
public void cancelJob() {
|
||||
JobScheduler.getInstance().cancelScheduledJob(this);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class JobContainer implements Comparable<JobContainer> {
|
||||
final long timeOfExecution;
|
||||
final boolean noTimer;
|
||||
|
||||
public JobContainer(AbstractJob job, long timeOfExecution) {
|
||||
JobContainer(AbstractJob job, long timeOfExecution) {
|
||||
if (job == null) {
|
||||
throw new IllegalArgumentException("No 'null' jobs allowed.");
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package engine.job;
|
||||
|
||||
import engine.server.world.WorldServer;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class JobThread implements Runnable {
|
||||
private final AbstractJob currentJob;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
private static Long nextThreadPrint;
|
||||
|
||||
public JobThread(AbstractJob job){
|
||||
this.currentJob = job;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (this.currentJob != null) {
|
||||
if (lock.tryLock(5, TimeUnit.SECONDS)) { // Timeout to prevent deadlock
|
||||
try {
|
||||
this.currentJob.doJob();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
} else {
|
||||
Logger.warn("JobThread could not acquire lock in time, skipping job.");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startJobThread(AbstractJob job){
|
||||
JobThread jobThread = new JobThread(job);
|
||||
Thread thread = new Thread(jobThread);
|
||||
thread.setName("JOB THREAD: " + job.getWorkerID());
|
||||
thread.start();
|
||||
|
||||
if(JobThread.nextThreadPrint == null){
|
||||
JobThread.nextThreadPrint = System.currentTimeMillis();
|
||||
}else{
|
||||
if(JobThread.nextThreadPrint < System.currentTimeMillis()){
|
||||
JobThread.tryPrintThreads();
|
||||
JobThread.nextThreadPrint = System.currentTimeMillis() + 10000L;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void tryPrintThreads(){
|
||||
ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
|
||||
while (rootGroup.getParent() != null) {
|
||||
rootGroup = rootGroup.getParent();
|
||||
}
|
||||
|
||||
// Estimate the number of threads
|
||||
int activeThreads = rootGroup.activeCount();
|
||||
|
||||
// Create an array to hold the threads
|
||||
Thread[] threads = new Thread[activeThreads];
|
||||
|
||||
// Get the active threads
|
||||
rootGroup.enumerate(threads, true);
|
||||
|
||||
int availableThreads = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
// Print the count
|
||||
if(threads.length > 30)
|
||||
Logger.info("Total threads in application: " + threads.length + " / " + availableThreads);
|
||||
}
|
||||
}
|
||||
@@ -58,13 +58,10 @@ public class JobWorker extends ControlledRunnable {
|
||||
} else {
|
||||
|
||||
// execute the new job..
|
||||
//this.currentJob.executeJob(this.getThreadName());
|
||||
if(this.currentJob != null) {
|
||||
JobThread.startJobThread(this.currentJob);
|
||||
this.currentJob = null;
|
||||
}
|
||||
this.currentJob.executeJob(this.getThreadName());
|
||||
this.currentJob = null;
|
||||
}
|
||||
Thread.yield();
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractEffectJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void doJob();
|
||||
protected abstract void doJob();
|
||||
|
||||
@Override
|
||||
protected abstract void _cancelJob();
|
||||
@@ -117,7 +117,7 @@ public abstract class AbstractEffectJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
public void endEffect() {
|
||||
if (this.eb == null || this.power == null)
|
||||
if (this.eb == null)
|
||||
return;
|
||||
this.eb.endEffect(this.source, this.target, this.trains, this.power, this);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ActivateBaneJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
City city;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AttackJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
CombatManager.doCombat(this.source, slot);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BaneDefaultTimeJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
//bane already set.
|
||||
if (this.bane.getLiveDate() != null) {
|
||||
|
||||
@@ -97,7 +97,7 @@ public class BasicScheduledJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (execution == null) {
|
||||
Logger.error("BasicScheduledJob executed with nothing to execute.");
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BonusCalcJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.ac != null) {
|
||||
this.ac.applyBonuses();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CSessionCleanupJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
SessionManager.cSessionCleanup(secKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ChangeAltitudeJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.ac != null)
|
||||
MovementManager.finishChangeAltitude(ac, targetAlt);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ChantJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.aej == null || this.source == null || this.target == null || this.action == null || this.power == null || this.source == null || this.eb == null)
|
||||
return;
|
||||
PlayerBonuses bonuses = null;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CloseGateJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (building == null) {
|
||||
Logger.error("Rungate building was null");
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DamageOverTimeJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.target.getObjectType().equals(GameObjectType.Building)
|
||||
&& ((Building) this.target).isVulnerable() == false) {
|
||||
_cancelJob();
|
||||
@@ -60,8 +60,6 @@ public class DamageOverTimeJob extends AbstractEffectJob {
|
||||
|
||||
if (this.iteration < 0) {
|
||||
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
|
||||
if (AbstractWorldObject.IsAbstractCharacter(source))
|
||||
eb.startEffect((AbstractCharacter) this.source, this.target, this.trains, this);
|
||||
return;
|
||||
}
|
||||
this.skipSendEffect = true;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DatabaseUpdateJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.ago == null)
|
||||
return;
|
||||
ago.removeDatabaseJob(this.type, false);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DebugTimerJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.pc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DeferredPowerJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
//Power ended with no attack, cancel weapon power boost
|
||||
if (this.source != null && this.source instanceof PlayerCharacter) {
|
||||
((PlayerCharacter) this.source).setWeaponPower(null);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class DisconnectJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.origin != null) {
|
||||
this.origin.disconnect();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DoorCloseJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
int doorNumber;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EndFearJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
//cancel fear for mob.
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package engine.jobs;
|
||||
|
||||
import engine.job.AbstractJob;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.server.MBServerStatics;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FearWanderJob extends AbstractJob {
|
||||
private final AbstractCharacter target;
|
||||
private final Random rand = new Random();
|
||||
|
||||
public FearWanderJob(AbstractCharacter target) {
|
||||
super();
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
// Only wander if still feared
|
||||
if (target == null || !target.getBonuses().getBool(engine.Enum.ModType.Fear, engine.Enum.SourceType.None))
|
||||
return;
|
||||
|
||||
// Pick a random direction and distance
|
||||
float angle = rand.nextFloat() * (float)Math.PI * 2f;
|
||||
float distance = 5f + rand.nextFloat() * 10f; // 5-15 units
|
||||
|
||||
Vector3fImmutable current = target.getLoc();
|
||||
float newX = current.x + (float)Math.cos(angle) * distance;
|
||||
float newZ = current.z + (float)Math.sin(angle) * distance;
|
||||
|
||||
// Clamp to world bounds if needed
|
||||
newX = (float) Math.max(0, Math.min(newX, MBServerStatics.MAX_WORLD_WIDTH));
|
||||
newZ = (float) Math.max(0, Math.min(newZ, MBServerStatics.MAX_WORLD_HEIGHT));
|
||||
|
||||
Vector3fImmutable dest = new Vector3fImmutable(newX, current.y, newZ);
|
||||
|
||||
// Issue movement (implement setEndLoc or similar in your AbstractCharacter)
|
||||
target.setEndLoc(dest);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class FinishCooldownTimeJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
PowersManager.finishCooldownTime(this.msg, this.pc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class FinishEffectTimeJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class FinishRecycleTimeJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
PowersManager.finishRecycleTime(this.msg, this.pc, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class FinishSpireEffectJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
PlayerCharacter pc = (PlayerCharacter) target;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class FinishSummonsJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.target == null)
|
||||
return;
|
||||
@@ -47,13 +47,13 @@ public class FinishSummonsJob extends AbstractScheduleJob {
|
||||
return;
|
||||
|
||||
// cannot summon a player in combat
|
||||
//if (this.target.isCombat()) {
|
||||
if (this.target.isCombat()) {
|
||||
|
||||
// ErrorPopupMsg.sendErrorMsg(this.source, "Cannot summon player in combat.");
|
||||
ErrorPopupMsg.sendErrorMsg(this.source, "Cannot summon player in combat.");
|
||||
|
||||
// PowersManager.finishRecycleTime(428523680, this.source, false);
|
||||
// return;
|
||||
//}
|
||||
PowersManager.finishRecycleTime(428523680, this.source, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.target.getBonuses() != null && this.target.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) {
|
||||
ErrorPopupMsg.sendErrorMsg(this.target, "You have been blocked from receiving summons!");
|
||||
|
||||
@@ -28,7 +28,7 @@ public class LoadEffectsJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.originToSend == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class LogoutCharacterJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
server.logoutCharacter(this.pc);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class NoTimeJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PersistentAoeJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.aej == null || this.source == null || this.action == null || this.power == null || this.source == null || this.eb == null)
|
||||
return;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RefreshGroupJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.pc == null || this.origin == null || grp == null) {
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class RemoveCorpseJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.corpse != null)
|
||||
Corpse.removeCorpse(corpse, true);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SiegeSpireWithdrawlJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (spire == null)
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class StuckJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
Vector3fImmutable stuckLoc;
|
||||
Building building = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SummonSendJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.source == null)
|
||||
return;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TeleportJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.pc == null || this.npc == null || this.origin == null)
|
||||
return;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TrackJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.tpa == null || this.target == null || this.action == null || this.source == null || this.eb == null || !(this.source instanceof PlayerCharacter))
|
||||
return;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TransferStatOTJob extends AbstractEffectJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (this.dot == null || this.target == null || this.action == null || this.source == null || this.eb == null || this.action == null || this.power == null)
|
||||
return;
|
||||
if (!this.target.isAlive()) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class UpdateGroupJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.group == null)
|
||||
return;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package engine.jobs;
|
||||
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.job.AbstractScheduleJob;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.City;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
/*
|
||||
@@ -22,7 +20,7 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
|
||||
// Must have a building to rank!
|
||||
@@ -43,18 +41,6 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
|
||||
|
||||
rankingBuilding.setRank(rankingBuilding.getRank() + 1);
|
||||
|
||||
if(rankingBuilding.getBlueprint().isWallPiece()){
|
||||
City cityObject = ZoneManager.getCityAtLocation(rankingBuilding.loc);
|
||||
if(cityObject.getTOL().getRank() == 8) {
|
||||
if (rankingBuilding.getBlueprint() != null && rankingBuilding.getBlueprint().getBuildingGroup() != null && rankingBuilding.getBlueprint().isWallPiece()) {
|
||||
float currentHealthRatio = rankingBuilding.getCurrentHitpoints() / rankingBuilding.healthMax;
|
||||
float newMax = rankingBuilding.healthMax * 1.1f;
|
||||
rankingBuilding.setMaxHitPoints(newMax);
|
||||
rankingBuilding.setHealth(rankingBuilding.healthMax * currentHealthRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reload the object
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class UpgradeNPCJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
int newRank;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UseItemJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
PowersManager.finishApplyPower(ac, target, Vector3fImmutable.ZERO, pb, trains, liveCounter);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class UseMobPowerJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
PowersManager.finishUseMobPower(this.msg, this.caster, casterLiveCounter, targetLiveCounter);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class UsePowerJob extends AbstractScheduleJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
PowersManager.finishUsePower(this.msg, this.pc, casterLiveCounter, targetLiveCounter);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
package engine.loot;
|
||||
|
||||
import engine.gameManager.LootManager;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class ItemTableEntry {
|
||||
public int minRoll;
|
||||
@@ -37,23 +35,11 @@ public class ItemTableEntry {
|
||||
List<ItemTableEntry> itemTableEntryList;
|
||||
|
||||
itemTableEntryList = LootManager._itemTables.get(itemTable);
|
||||
if(itemTableEntryList != null) {
|
||||
for (ItemTableEntry iteration : itemTableEntryList)
|
||||
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
|
||||
itemTableEntry = iteration;
|
||||
}
|
||||
|
||||
for (ItemTableEntry iteration : itemTableEntryList)
|
||||
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
|
||||
itemTableEntry = iteration;
|
||||
|
||||
return itemTableEntry;
|
||||
}
|
||||
|
||||
public static Integer getRandomItem(int itemTable) {
|
||||
int id = 0;
|
||||
List<ItemTableEntry> itemTableEntryList;
|
||||
|
||||
itemTableEntryList = LootManager._itemTables.get(itemTable);
|
||||
|
||||
if(itemTableEntryList != null && itemTableEntryList.size() > 1){
|
||||
id = itemTableEntryList.get(ThreadLocalRandom.current().nextInt(0, itemTableEntryList.size())).cacheID;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ public class ModTableEntry {
|
||||
List<ModTableEntry> itemTableEntryList;
|
||||
|
||||
itemTableEntryList = LootManager._modTables.get(modTablwe);
|
||||
if(itemTableEntryList != null) {
|
||||
for (ModTableEntry iteration : itemTableEntryList)
|
||||
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
|
||||
modTableEntry = iteration;
|
||||
}
|
||||
|
||||
for (ModTableEntry iteration : itemTableEntryList)
|
||||
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
|
||||
modTableEntry = iteration;
|
||||
|
||||
return modTableEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class Bounds {
|
||||
//player is inside building region, skip collision check. we only do collision from the outside.
|
||||
if (player.region != null && player.region.parentBuildingID == building.getObjectUUID())
|
||||
continue;
|
||||
if (building.getBounds() == null || building.getBounds().colliders == null)
|
||||
if (building.getBounds().colliders == null)
|
||||
continue;
|
||||
|
||||
for (Colliders collider : building.getBounds().colliders) {
|
||||
|
||||
+67
-154
@@ -9,7 +9,7 @@
|
||||
package engine.mobileAI;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.InterestManager;
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.InterestManagement.WorldGrid;
|
||||
import engine.gameManager.*;
|
||||
import engine.math.Vector3f;
|
||||
@@ -19,7 +19,7 @@ import engine.mobileAI.utilities.CombatUtilities;
|
||||
import engine.mobileAI.utilities.MovementUtilities;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PerformActionMsg;
|
||||
import engine.net.client.msg.UpdateStateMsg;
|
||||
import engine.net.client.msg.PowerProjectileMsg;
|
||||
import engine.objects.*;
|
||||
import engine.powers.ActionsBase;
|
||||
import engine.powers.PowersBase;
|
||||
@@ -49,19 +49,18 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
//mob casting disabled
|
||||
//if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
|
||||
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
|
||||
|
||||
//if (mob.isPlayerGuard() == false && MobCast(mob)) {
|
||||
// mob.updateLocation();
|
||||
// return;
|
||||
//}
|
||||
if (mob.isPlayerGuard() == false && MobCast(mob)) {
|
||||
mob.updateLocation();
|
||||
return;
|
||||
}
|
||||
|
||||
//if (mob.isPlayerGuard() == true && GuardCast(mob)) {
|
||||
// mob.updateLocation();
|
||||
// return;
|
||||
//}
|
||||
//}
|
||||
if (mob.isPlayerGuard() == true && GuardCast(mob)) {
|
||||
mob.updateLocation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CombatUtilities.inRangeToAttack(mob, target))
|
||||
return;
|
||||
@@ -83,16 +82,6 @@ public class MobAI {
|
||||
|
||||
mob.updateLocation();
|
||||
|
||||
if(mob.StrongholdGuardian || mob.StrongholdEpic){
|
||||
// attempt to ground all players in attack range
|
||||
for(int i : mob.playerAgroMap.keySet()){
|
||||
PlayerCharacter tar = PlayerCharacter.getFromCache(i);
|
||||
if(tar != null && tar.loc.distanceSquared(mob.loc) < 80){
|
||||
PowersManager.applyPower(mob,tar,tar.loc, 111111,40,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
||||
}
|
||||
@@ -107,16 +96,10 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
if(target.getPet() != null && target.getPet().isAlive() && !target.getPet().isSiege()){
|
||||
mob.setCombatTarget(target.getPet());
|
||||
AttackTarget(mob,mob.combatTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mob.BehaviourType.callsForHelp)
|
||||
MobCallForHelp(mob);
|
||||
|
||||
if (MovementUtilities.outOfAggroRange(mob, target)) {
|
||||
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
@@ -163,12 +146,6 @@ public class MobAI {
|
||||
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true)
|
||||
target.getPet().setCombatTarget(mob);
|
||||
|
||||
try{
|
||||
InterestManager.forceLoad(mob);
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
|
||||
}
|
||||
@@ -179,9 +156,6 @@ public class MobAI {
|
||||
|
||||
try {
|
||||
|
||||
if(mob == null || target == null)
|
||||
return;
|
||||
|
||||
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
@@ -191,8 +165,8 @@ public class MobAI {
|
||||
|
||||
if (playercity != null)
|
||||
for (Mob guard : playercity.getParent().zoneMobSet)
|
||||
if (guard.BehaviourType != null && guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
|
||||
if (guard.getCombatTarget() == null && guard.getGuild() != null && mob.getGuild() != null && !guard.getGuild().equals(mob.getGuild()))
|
||||
if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
|
||||
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
|
||||
guard.setCombatTarget(mob);
|
||||
|
||||
if (mob.isSiege())
|
||||
@@ -221,11 +195,11 @@ public class MobAI {
|
||||
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
|
||||
}
|
||||
|
||||
//if (mob.isSiege()) {
|
||||
// PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
|
||||
// ppm.setRange(50);
|
||||
// DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
//}
|
||||
if (mob.isSiege()) {
|
||||
PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
|
||||
ppm.setRange(50);
|
||||
DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding" + " " + e.getMessage());
|
||||
@@ -334,32 +308,28 @@ public class MobAI {
|
||||
if (mob == null)
|
||||
return false;
|
||||
|
||||
if (mob.nextCastTime == 0)
|
||||
mob.nextCastTime = System.currentTimeMillis() - 1000L;
|
||||
if(mob.isPlayerGuard == true){
|
||||
|
||||
if(mob.nextCastTime > System.currentTimeMillis())
|
||||
return false;
|
||||
int contractID;
|
||||
|
||||
if(mob.isPlayerGuard){
|
||||
|
||||
int contractID = 0;
|
||||
|
||||
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion) && mob.npcOwner != null)
|
||||
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion))
|
||||
contractID = mob.npcOwner.contract.getContractID();
|
||||
else if(mob.contract != null)
|
||||
else
|
||||
contractID = mob.contract.getContractID();
|
||||
|
||||
if(Enum.MinionType.ContractToMinionMap.containsKey(contractID) && !Enum.MinionType.ContractToMinionMap.get(contractID).isMage())
|
||||
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mob.mobPowers == null || mob.mobPowers.isEmpty())
|
||||
if (mob.mobPowers.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
|
||||
mob.setCombatTarget(null);
|
||||
return false;
|
||||
}
|
||||
if (mob.nextCastTime == 0)
|
||||
mob.nextCastTime = System.currentTimeMillis();
|
||||
|
||||
return mob.nextCastTime <= System.currentTimeMillis();
|
||||
|
||||
@@ -418,9 +388,6 @@ public class MobAI {
|
||||
|
||||
PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
|
||||
|
||||
if(mobPower.powerCategory.equals(Enum.PowerCategoryType.DEBUFF))
|
||||
return false;
|
||||
|
||||
//check for hit-roll
|
||||
|
||||
if (mobPower.requiresHitRoll)
|
||||
@@ -433,7 +400,7 @@ public class MobAI {
|
||||
|
||||
PerformActionMsg msg;
|
||||
|
||||
if (!mob.StrongholdCommander && !mob.StrongholdEpic && (!mobPower.isHarmful() || mobPower.targetSelf)) {
|
||||
if (!mobPower.isHarmful() || mobPower.targetSelf) {
|
||||
PowersManager.useMobPower(mob, mob, mobPower, powerRank);
|
||||
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob);
|
||||
} else {
|
||||
@@ -444,9 +411,9 @@ public class MobAI {
|
||||
msg.setUnknown04(2);
|
||||
|
||||
PowersManager.finishUseMobPower(msg, mob, 0, 0);
|
||||
long delay = 20000L;
|
||||
mob.nextCastTime = System.currentTimeMillis() + delay;
|
||||
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
|
||||
|
||||
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -569,6 +536,7 @@ public class MobAI {
|
||||
PowersManager.finishUseMobPower(msg, mob, 0, 0);
|
||||
|
||||
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
|
||||
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -620,9 +588,6 @@ public class MobAI {
|
||||
|
||||
if (mob == null)
|
||||
return;
|
||||
if(mob.isAlive())
|
||||
if(!mob.getMovementLoc().equals(Vector3fImmutable.ZERO))
|
||||
mob.setLoc(mob.getMovementLoc());
|
||||
|
||||
if (mob.getTimestamps().containsKey("lastExecution") == false)
|
||||
mob.getTimestamps().put("lastExecution", System.currentTimeMillis());
|
||||
@@ -660,6 +625,9 @@ public class MobAI {
|
||||
|
||||
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting
|
||||
|
||||
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
|
||||
CheckToSendMobHome(mob);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -678,7 +646,7 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
if(mob.isPet() == false && mob.isPlayerGuard == false)
|
||||
if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
|
||||
CheckToSendMobHome(mob);
|
||||
|
||||
if (mob.getCombatTarget() != null) {
|
||||
@@ -889,31 +857,26 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
//No items in inventory.
|
||||
} else if (aiAgent.isHasLoot()) {
|
||||
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
|
||||
aiAgent.despawn();
|
||||
aiAgent.deathTime = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
//Mob never had Loot.
|
||||
} else {
|
||||
//Mob's Loot has been looted.
|
||||
if (aiAgent.isHasLoot()) {
|
||||
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
|
||||
aiAgent.despawn();
|
||||
aiAgent.deathTime = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
//Mob never had Loot.
|
||||
} else {
|
||||
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) {
|
||||
aiAgent.despawn();
|
||||
aiAgent.deathTime = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
|
||||
|
||||
if(Mob.discDroppers.contains(aiAgent))
|
||||
return;
|
||||
|
||||
if(aiAgent.StrongholdGuardian || aiAgent.StrongholdEpic || aiAgent.StrongholdCommander)
|
||||
return;
|
||||
|
||||
if (aiAgent.despawned && System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000L))) {
|
||||
if (!Zone.respawnQue.contains(aiAgent)) {
|
||||
if (Zone.respawnQue.contains(aiAgent) == false) {
|
||||
Zone.respawnQue.add(aiAgent);
|
||||
}
|
||||
}
|
||||
@@ -933,10 +896,8 @@ public class MobAI {
|
||||
if (mob.getCombatTarget() == null)
|
||||
return;
|
||||
|
||||
if(!mob.isCombat())
|
||||
enterCombat(mob);
|
||||
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
|
||||
|
||||
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.outOfAggroRange(mob, (PlayerCharacter) mob.getCombatTarget()) && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
@@ -950,21 +911,7 @@ public class MobAI {
|
||||
|
||||
private static void CheckToSendMobHome(Mob mob) {
|
||||
|
||||
if(mob.isNecroPet())
|
||||
return;
|
||||
|
||||
try {
|
||||
|
||||
//trebs dont recall
|
||||
if(mob.isSiege())
|
||||
return;
|
||||
|
||||
if(mob.BehaviourType.equals(Enum.MobBehaviourType.Pet1)){
|
||||
if(mob.loc.distanceSquared(mob.getOwner().loc) > 60 * 60)
|
||||
mob.teleport(mob.getOwner().loc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mob.BehaviourType.isAgressive) {
|
||||
|
||||
if (mob.isPlayerGuard()) {
|
||||
@@ -975,6 +922,9 @@ public class MobAI {
|
||||
}
|
||||
}
|
||||
|
||||
if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f))
|
||||
return;
|
||||
|
||||
if (mob.isPlayerGuard() && !mob.despawned) {
|
||||
|
||||
City current = ZoneManager.getCityAtLocation(mob.getLoc());
|
||||
@@ -984,6 +934,7 @@ public class MobAI {
|
||||
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
|
||||
PowersManager.useMobPower(mob, mob, recall, 40);
|
||||
mob.setCombatTarget(null);
|
||||
|
||||
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
|
||||
|
||||
//guard captain pulls his minions home with him
|
||||
@@ -994,7 +945,7 @@ public class MobAI {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!MovementUtilities.inRangeOfBindLocation(mob)) {
|
||||
} else if (MovementUtilities.inRangeOfBindLocation(mob) == false) {
|
||||
|
||||
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
|
||||
PowersManager.useMobPower(mob, mob, recall, 40);
|
||||
@@ -1002,7 +953,6 @@ public class MobAI {
|
||||
|
||||
for (Entry playerEntry : mob.playerAgroMap.entrySet())
|
||||
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
|
||||
mob.setCombatTarget(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
|
||||
@@ -1013,11 +963,6 @@ public class MobAI {
|
||||
|
||||
try {
|
||||
|
||||
if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && !mob.canSee((PlayerCharacter)mob.combatTarget)){
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
float rangeSquared = mob.getRange() * mob.getRange();
|
||||
float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());
|
||||
|
||||
@@ -1061,7 +1006,7 @@ public class MobAI {
|
||||
|
||||
//dont scan self.
|
||||
|
||||
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARD)) || (mob.agentType.equals(Enum.AIAgentType.PET)))
|
||||
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARD)) == true)
|
||||
continue;
|
||||
|
||||
Mob aggroMob = (Mob) awoMob;
|
||||
@@ -1084,22 +1029,9 @@ public class MobAI {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkToDropGuardAggro(Mob mob){
|
||||
City city = mob.guardedCity;
|
||||
|
||||
if(city == null)
|
||||
return;
|
||||
if(mob.combatTarget == null)
|
||||
return;
|
||||
|
||||
//if(city._playerMemory.contains(mob.combatTarget.getObjectUUID()) && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
|
||||
// mob.setCombatTarget(null);
|
||||
}
|
||||
|
||||
public static void GuardCaptainLogic(Mob mob) {
|
||||
|
||||
try {
|
||||
checkToDropGuardAggro(mob);
|
||||
if (mob.getCombatTarget() == null)
|
||||
CheckForPlayerGuardAggro(mob);
|
||||
|
||||
@@ -1124,8 +1056,6 @@ public class MobAI {
|
||||
public static void GuardMinionLogic(Mob mob) {
|
||||
|
||||
try {
|
||||
checkToDropGuardAggro(mob);
|
||||
|
||||
boolean isComanded = mob.npcOwner.isAlive();
|
||||
if (!isComanded) {
|
||||
GuardCaptainLogic(mob);
|
||||
@@ -1146,8 +1076,6 @@ public class MobAI {
|
||||
public static void GuardWallArcherLogic(Mob mob) {
|
||||
|
||||
try {
|
||||
checkToDropGuardAggro(mob);
|
||||
|
||||
if (mob.getCombatTarget() == null)
|
||||
CheckForPlayerGuardAggro(mob);
|
||||
else
|
||||
@@ -1165,10 +1093,6 @@ public class MobAI {
|
||||
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
|
||||
mob.killCharacter("no owner");
|
||||
|
||||
if(!mob.isSiege())
|
||||
mob.BehaviourType.canRoam = true;
|
||||
|
||||
|
||||
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
|
||||
CheckMobMovement(mob);
|
||||
|
||||
@@ -1229,7 +1153,6 @@ public class MobAI {
|
||||
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
|
||||
CheckForAttack(mob);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
|
||||
}
|
||||
@@ -1428,31 +1351,21 @@ public class MobAI {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RecoverHealth(Mob mob) {
|
||||
public static void RecoverHealth(Mob mob){
|
||||
//recover health
|
||||
try {
|
||||
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
|
||||
|
||||
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
|
||||
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
|
||||
|
||||
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
|
||||
if (mob.getHealth() < mob.getHealthMax()) {
|
||||
|
||||
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
|
||||
mob.setHealth(mob.getHealth() + recoveredHealth);
|
||||
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
|
||||
|
||||
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
|
||||
if (mob.getHealth() < mob.getHealthMax()) {
|
||||
|
||||
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
|
||||
mob.setHealth(mob.getHealth() + recoveredHealth);
|
||||
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
|
||||
|
||||
if (mob.getHealth() > mob.getHealthMax())
|
||||
mob.setHealth(mob.getHealthMax());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: RecoverHealth" + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void enterCombat(Mob mob){
|
||||
mob.setCombat(true);
|
||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||
rwss.setPlayer(mob);
|
||||
DispatchMessage.sendToAllInRange(mob, rwss);
|
||||
if (mob.getHealth() > mob.getHealthMax())
|
||||
mob.setHealth(mob.getHealthMax());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,26 +28,18 @@ public class MobAIThread implements Runnable{
|
||||
AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
|
||||
while (true) {
|
||||
for (Zone zone : ZoneManager.getAllZones()) {
|
||||
if (zone != null && zone.zoneMobSet != null) {
|
||||
synchronized (zone.zoneMobSet) {
|
||||
for (Mob mob : zone.zoneMobSet) {
|
||||
try {
|
||||
if (mob != null) {
|
||||
MobAI.DetermineAction(mob);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error("Error processing Mob [Name: {}, UUID: {}]", mob.getName(), mob.getObjectUUID(), e);
|
||||
}
|
||||
}
|
||||
|
||||
for (Mob mob : zone.zoneMobSet) {
|
||||
|
||||
try {
|
||||
if (mob != null)
|
||||
MobAI.DetermineAction(mob);
|
||||
} catch (Exception e) {
|
||||
Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
Logger.error("AI Thread interrupted", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void startAIThread() {
|
||||
|
||||
@@ -13,9 +13,6 @@ import engine.objects.Mob;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Thread blocks until MagicBane dispatch messages are
|
||||
* enqueued then processes them in FIFO order. The collection
|
||||
@@ -28,48 +25,41 @@ import java.util.Collection;
|
||||
|
||||
public class MobRespawnThread implements Runnable {
|
||||
|
||||
private volatile boolean running = true;
|
||||
private static final long RESPAWN_INTERVAL = 100; // Configurable interval
|
||||
|
||||
public MobRespawnThread() {
|
||||
Logger.info("MobRespawnThread initialized.");
|
||||
Logger.info(" MobRespawnThread thread has started!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (running) {
|
||||
try {
|
||||
Collection<Zone> zones = ZoneManager.getAllZones();
|
||||
if (zones != null) {
|
||||
for (Zone zone : zones) {
|
||||
synchronized (zone) { // Optional: Synchronize on zone
|
||||
if (!Zone.respawnQue.isEmpty() && Zone.lastRespawn + RESPAWN_INTERVAL < System.currentTimeMillis()) {
|
||||
|
||||
Mob respawner = Zone.respawnQue.iterator().next();
|
||||
if (respawner != null) {
|
||||
respawner.respawn();
|
||||
Zone.respawnQue.remove(respawner);
|
||||
Zone.lastRespawn = System.currentTimeMillis();
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
|
||||
try {
|
||||
for (Zone zone : ZoneManager.getAllZones()) {
|
||||
|
||||
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
|
||||
|
||||
Mob respawner = zone.respawnQue.iterator().next();
|
||||
|
||||
if (respawner == null)
|
||||
continue;
|
||||
|
||||
respawner.respawn();
|
||||
zone.respawnQue.remove(respawner);
|
||||
zone.lastRespawn = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
Thread.sleep(100); // Prevent busy-waiting
|
||||
} catch (Exception e) {
|
||||
Logger.error("Error in MobRespawnThread", e);
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
Logger.info("MobRespawnThread stopped.");
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
public static void startRespawnThread() {
|
||||
Thread respawnThread = new Thread(new MobRespawnThread());
|
||||
Thread respawnThread;
|
||||
respawnThread = new Thread(new MobRespawnThread());
|
||||
respawnThread.setName("respawnThread");
|
||||
respawnThread.start();
|
||||
}
|
||||
|
||||
@@ -101,10 +101,9 @@ public class CombatUtilities {
|
||||
if (!target.isAlive())
|
||||
return;
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||
//damage = Resists.handleFortitude((AbstractCharacter) target,DamageType.Crush,damage);
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
trueDamage = ((AbstractCharacter) target).modifyHealth(-damage, agent, false);
|
||||
}else if (target.getObjectType() == GameObjectType.Building)
|
||||
else if (target.getObjectType() == GameObjectType.Building)
|
||||
trueDamage = ((Building) target).modifyHealth(-damage, agent);
|
||||
|
||||
//Don't send 0 damage kay thanx.
|
||||
@@ -125,7 +124,7 @@ public class CombatUtilities {
|
||||
}
|
||||
|
||||
public static boolean canSwing(Mob agent) {
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None));
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.Fear, SourceType.None));
|
||||
}
|
||||
|
||||
public static void swingIsMiss(Mob agent, AbstractWorldObject target, int animation) {
|
||||
@@ -140,30 +139,37 @@ public class CombatUtilities {
|
||||
}
|
||||
|
||||
public static boolean triggerDefense(Mob agent, AbstractWorldObject target) {
|
||||
int defense = 0;
|
||||
int atr = agent.mobBase.getAtr();
|
||||
if(agent.getBonuses() != null){
|
||||
atr += agent.getBonuses().getFloat(ModType.OCV,SourceType.None);
|
||||
atr *= 1 + agent.getBonuses().getFloatPercentAll(ModType.OCV,SourceType.None);
|
||||
}
|
||||
int defenseScore = 0;
|
||||
int attackScore = agent.getAtrHandOne();
|
||||
switch (target.getObjectType()) {
|
||||
case PlayerCharacter:
|
||||
PlayerCharacter pc = (PlayerCharacter)target;
|
||||
pc.combatStats.calculateDefense();
|
||||
defense = pc.combatStats.defense;
|
||||
defenseScore = ((AbstractCharacter) target).getDefenseRating();
|
||||
break;
|
||||
case Mob:
|
||||
|
||||
Mob mob = (Mob) target;
|
||||
if (mob.isSiege())
|
||||
defense = atr;
|
||||
else
|
||||
defense = ((Mob) target).mobBase.getDefense();
|
||||
defenseScore = attackScore;
|
||||
break;
|
||||
case Building:
|
||||
return false;
|
||||
}
|
||||
return !CombatManager.LandHit(atr,defense);
|
||||
|
||||
int hitChance;
|
||||
if (attackScore > defenseScore || defenseScore == 0)
|
||||
hitChance = 94;
|
||||
else if (attackScore == defenseScore && target.getObjectType() == GameObjectType.Mob)
|
||||
hitChance = 10;
|
||||
else {
|
||||
float dif = attackScore / defenseScore;
|
||||
if (dif <= 0.8f)
|
||||
hitChance = 4;
|
||||
else
|
||||
hitChance = ((int) (450 * (dif - 0.8f)) + 4);
|
||||
if (target.getObjectType() == GameObjectType.Building)
|
||||
hitChance = 100;
|
||||
}
|
||||
return ThreadLocalRandom.current().nextInt(100) > hitChance;
|
||||
}
|
||||
|
||||
public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {
|
||||
@@ -201,10 +207,12 @@ public class CombatUtilities {
|
||||
return;
|
||||
|
||||
int anim = 75;
|
||||
float speed;
|
||||
|
||||
//handle the retaliate here because even if the mob misses you can still retaliate
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
||||
if (mainHand)
|
||||
speed = agent.getSpeedHandOne();
|
||||
else
|
||||
speed = agent.getSpeedHandTwo();
|
||||
|
||||
DamageType dt = DamageType.Crush;
|
||||
|
||||
@@ -259,12 +267,12 @@ public class CombatUtilities {
|
||||
if (agent.getEquip().get(1) != null && agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) {
|
||||
//mob is duel wielding and should conduct an attack for each hand
|
||||
ItemBase weapon1 = agent.getEquip().get(1).getItemBase();
|
||||
double range1 = getMaxDmg(agent) - getMinDmg(agent);
|
||||
double damage1 = getMinDmg(agent) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2;
|
||||
double range1 = getMaxDmg(weapon1.getMinDamage(), agent, weapon1) - getMinDmg(weapon1.getMinDamage(), agent, weapon1);
|
||||
double damage1 = getMinDmg(weapon1.getMinDamage(), agent, weapon1) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2;
|
||||
swingIsDamage(agent, target, (float) damage1, CombatManager.getSwingAnimation(weapon1, null, true));
|
||||
ItemBase weapon2 = agent.getEquip().get(2).getItemBase();
|
||||
double range2 = getMaxDmg(agent) - getMinDmg(agent);
|
||||
double damage2 = getMinDmg(agent) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2;
|
||||
double range2 = getMaxDmg(weapon2.getMinDamage(), agent, weapon2) - getMinDmg(weapon2.getMinDamage(), agent, weapon2);
|
||||
double damage2 = getMinDmg(weapon2.getMinDamage(), agent, weapon2) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2;
|
||||
swingIsDamage(agent, target, (float) damage2, CombatManager.getSwingAnimation(weapon1, null, false));
|
||||
} else {
|
||||
swingIsDamage(agent, target, determineDamage(agent), anim);
|
||||
@@ -286,6 +294,11 @@ public class CombatUtilities {
|
||||
if (((Mob) target).isSiege())
|
||||
return;
|
||||
|
||||
//handle the retaliate
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
|
||||
|
||||
if (target.getObjectType() == GameObjectType.Mob) {
|
||||
Mob targetMob = (Mob) target;
|
||||
if (targetMob.isSiege())
|
||||
@@ -309,9 +322,9 @@ public class CombatUtilities {
|
||||
float damage = 0;
|
||||
|
||||
DamageType dt = getDamageType(agent);
|
||||
if (agent.BehaviourType.equals(MobBehaviourType.Pet1)) {
|
||||
damage = calculateMobDamage(agent);
|
||||
} else if (agent.isPlayerGuard()) {
|
||||
if ((agent.agentType.equals(AIAgentType.PET)) == true || agent.isPet() == true || agent.isNecroPet() == true) {
|
||||
damage = calculatePetDamage(agent);
|
||||
} else if (agent.isPlayerGuard() == true) {
|
||||
//damage = calculateGuardDamage(agent);
|
||||
damage = calculateMobDamage(agent);
|
||||
} else if (agent.getLevel() > 80) {
|
||||
@@ -320,9 +333,9 @@ public class CombatUtilities {
|
||||
damage = calculateMobDamage(agent);
|
||||
}
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target)) {
|
||||
//if (((AbstractCharacter) target).isSit()) {
|
||||
// damage *= 2.5f; //increase damage if sitting
|
||||
//}
|
||||
if (((AbstractCharacter) target).isSit()) {
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
}
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0));
|
||||
}
|
||||
if (target.getObjectType() == GameObjectType.Building) {
|
||||
@@ -351,8 +364,8 @@ public class CombatUtilities {
|
||||
float min = 40;
|
||||
float max = 60;
|
||||
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
|
||||
double minDmg = getMinDmg(agent);
|
||||
double maxDmg = getMaxDmg(agent);
|
||||
double minDmg = getMinDmg(min, agent, null);
|
||||
double maxDmg = getMaxDmg(max, agent, null);
|
||||
dmgMultiplier += agent.getLevel() * 0.1f;
|
||||
range = (float) (maxDmg - minDmg);
|
||||
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
@@ -368,8 +381,8 @@ public class CombatUtilities {
|
||||
|
||||
double minDmg = weapon.getMinDamage();
|
||||
double maxDmg = weapon.getMaxDamage();
|
||||
double min = getMinDmg(agent);
|
||||
double max = getMaxDmg(agent);
|
||||
double min = getMinDmg(minDmg, agent, weapon);
|
||||
double max = getMaxDmg(maxDmg, agent, weapon);
|
||||
|
||||
DamageType dt = weapon.getDamageType();
|
||||
|
||||
@@ -410,48 +423,92 @@ public class CombatUtilities {
|
||||
}
|
||||
|
||||
public static int calculateMobDamage(Mob agent) {
|
||||
double minDmg = getMinDmg(agent);
|
||||
double maxDmg = getMaxDmg(agent);
|
||||
DamageType dt = getDamageType(agent);
|
||||
ItemBase weapon = null;
|
||||
double minDmg;
|
||||
double maxDmg;
|
||||
DamageType dt;
|
||||
|
||||
//main hand or offhand damage
|
||||
|
||||
if (agent.getEquip().get(1) != null)
|
||||
weapon = agent.getEquip().get(1).getItemBase();
|
||||
else if (agent.getEquip().get(2) != null)
|
||||
weapon = agent.getEquip().get(2).getItemBase();
|
||||
|
||||
if (weapon != null) {
|
||||
minDmg = getMinDmg(weapon.getMinDamage(), agent, weapon);
|
||||
maxDmg = getMaxDmg(weapon.getMaxDamage(), agent, weapon);
|
||||
dt = weapon.getDamageType();
|
||||
} else {
|
||||
minDmg = agent.getMobBase().getDamageMin();
|
||||
maxDmg = agent.getMobBase().getDamageMax();
|
||||
dt = DamageType.Crush;
|
||||
}
|
||||
|
||||
AbstractWorldObject target = agent.getCombatTarget();
|
||||
|
||||
double damage = ThreadLocalRandom.current().nextInt((int)minDmg,(int)maxDmg + 1);
|
||||
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
|
||||
double range = maxDmg - minDmg;
|
||||
double damage = minDmg + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
|
||||
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
if (((AbstractCharacter) target).isSit())
|
||||
damage *= 2.5f; //increase damage if sitting
|
||||
if (AbstractWorldObject.IsAbstractCharacter(target))
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0));
|
||||
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double getMinDmg(Mob agent) {
|
||||
if(agent.getEquip() != null){
|
||||
if(agent.getEquip().get(ItemSlotType.RHELD) != null){
|
||||
return agent.minDamageHandOne;
|
||||
}else if(agent.getEquip().get(ItemSlotType.LHELD) != null){
|
||||
return agent.getMinDamageHandTwo();
|
||||
}else{
|
||||
return agent.minDamageHandOne;
|
||||
public static double getMinDmg(double min, Mob agent, ItemBase weapon) {
|
||||
|
||||
int primary = agent.getStatStrCurrent();
|
||||
int secondary = agent.getStatDexCurrent();
|
||||
int focusLevel = 0;
|
||||
int masteryLevel = 0;
|
||||
|
||||
if (weapon != null) {
|
||||
if (weapon.isStrBased() == true) {
|
||||
primary = agent.getStatStrCurrent();
|
||||
secondary = agent.getStatDexCurrent();
|
||||
} else {
|
||||
primary = agent.getStatDexCurrent();
|
||||
secondary = agent.getStatStrCurrent();
|
||||
if (agent.getSkills().containsKey(weapon.getSkillRequired())) {
|
||||
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
|
||||
}
|
||||
if (agent.getSkills().containsKey(weapon.getMastery())) {
|
||||
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
|
||||
}
|
||||
}else{
|
||||
return agent.minDamageHandOne;
|
||||
}
|
||||
}
|
||||
return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel));
|
||||
}
|
||||
|
||||
public static double getMaxDmg(Mob agent) {
|
||||
if(agent.getEquip() != null){
|
||||
if(agent.getEquip().get(ItemSlotType.RHELD) != null){
|
||||
return agent.maxDamageHandOne;
|
||||
}else if(agent.getEquip().get(ItemSlotType.LHELD) != null){
|
||||
return agent.getMaxDamageHandTwo();
|
||||
}else{
|
||||
return agent.maxDamageHandOne;
|
||||
}
|
||||
}else{
|
||||
return agent.maxDamageHandOne;
|
||||
public static double getMaxDmg(double max, Mob agent, ItemBase weapon) {
|
||||
|
||||
int primary = agent.getStatStrCurrent();
|
||||
int secondary = agent.getStatDexCurrent();
|
||||
int focusLevel = 0;
|
||||
int masteryLevel = 0;
|
||||
|
||||
if (weapon != null) {
|
||||
|
||||
if (weapon.isStrBased() == true) {
|
||||
primary = agent.getStatStrCurrent();
|
||||
secondary = agent.getStatDexCurrent();
|
||||
} else {
|
||||
primary = agent.getStatDexCurrent();
|
||||
secondary = agent.getStatStrCurrent();
|
||||
}
|
||||
|
||||
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
|
||||
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
|
||||
|
||||
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
|
||||
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
|
||||
|
||||
}
|
||||
return max * (pow(0.0124 * primary + 0.118 * (primary - 0.75), 0.5) + pow(0.0022 * secondary + 0.028 * (secondary - 0.75), 0.5) + 0.0075 * (focusLevel + masteryLevel));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,24 +98,20 @@ public class MovementUtilities {
|
||||
|
||||
}
|
||||
|
||||
public static boolean outOfAggroRange(Mob agent, AbstractCharacter target) {
|
||||
public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) {
|
||||
|
||||
Vector3fImmutable sl = agent.getLoc();
|
||||
Vector3fImmutable tl = target.getLoc();
|
||||
|
||||
float disSq = sl.distanceSquared(tl);
|
||||
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||
|
||||
float range = agent.getRange() + 150;
|
||||
|
||||
|
||||
//float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
|
||||
|
||||
|
||||
|
||||
if (range > 200)
|
||||
range = 200;
|
||||
|
||||
|
||||
return disSq > (range * range);
|
||||
return distanceSquaredToTarget < sqr(range);
|
||||
|
||||
}
|
||||
|
||||
@@ -173,7 +169,7 @@ public class MovementUtilities {
|
||||
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
|
||||
return false;
|
||||
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.Fear, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
|
||||
}
|
||||
|
||||
public static Vector3fImmutable randomPatrolLocation(Mob agent, Vector3fImmutable center, float radius) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractConnection implements
|
||||
protected final AtomicBoolean execTask = new AtomicBoolean(false);
|
||||
protected final ReentrantLock writeLock = new ReentrantLock();
|
||||
protected final ReentrantLock readLock = new ReentrantLock();
|
||||
public long lastMsgTime = System.currentTimeMillis();
|
||||
protected long lastMsgTime = System.currentTimeMillis();
|
||||
protected long lastKeepAliveTime = System.currentTimeMillis();
|
||||
protected long lastOpcode = -1;
|
||||
protected ConcurrentLinkedQueue<ByteBuffer> outbox = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@@ -87,7 +87,6 @@ public abstract class AbstractConnectionManager extends ControlledRunnable {
|
||||
|
||||
this.processChangeRequests();
|
||||
this.auditSocketChannelToConnectionMap();
|
||||
//this.selector.select();
|
||||
this.selector.select(250L);
|
||||
this.processNewEvents();
|
||||
|
||||
@@ -665,7 +664,7 @@ public abstract class AbstractConnectionManager extends ControlledRunnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (runStatus) {
|
||||
this.ac.connMan.receive(sk);
|
||||
this.ac.execTask.compareAndSet(true, false);
|
||||
@@ -694,7 +693,7 @@ public abstract class AbstractConnectionManager extends ControlledRunnable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
if (runStatus) {
|
||||
this.ac.connMan.sendFinish(sk);
|
||||
this.ac.execTask.compareAndSet(true, false);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CheckNetMsgFactoryJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
NetMsgFactory factory = conn.getFactory();
|
||||
|
||||
// Make any/all msg possible
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ConnectionMonitorJob extends AbstractJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doJob() {
|
||||
protected void doJob() {
|
||||
|
||||
if (this.cnt >= 5) {
|
||||
this.connMan.auditSocketChannelToConnectionMap();
|
||||
|
||||
@@ -13,8 +13,6 @@ import engine.exception.FactoryBuildException;
|
||||
import engine.gameManager.ChatManager;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.Protocol;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -96,9 +94,11 @@ public class NetMsgFactory {
|
||||
if (origin instanceof ClientConnection) {
|
||||
PlayerCharacter player = ((ClientConnection) origin).getPlayerCharacter();
|
||||
if (player != null) {
|
||||
// if (MBServerStatics.worldServerName.equals("Grief"))
|
||||
Logger.error("Invalid protocol msg for player " + player.getFirstName() + " : " + opcode + " lastopcode: " + origin.lastProtocol.name() + " Error Code : " + errorCode);
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "Please Report What You Just Did. Ref Code: " + opcode);
|
||||
}
|
||||
} else
|
||||
Logger.error("Invalid protocol msg : " + opcode + " lastopcode: " + origin.lastProtocol.name() + " Error Code : " + errorCode);
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -44,16 +44,9 @@ public class ClientConnection extends AbstractConnection {
|
||||
public ReentrantLock buyLock = new ReentrantLock();
|
||||
public boolean desyncDebug = false;
|
||||
public byte[] lastByteBuffer;
|
||||
public long lastTargetSwitchTime;
|
||||
protected SessionID sessionID = null;
|
||||
private byte cryptoInitTries = 0;
|
||||
|
||||
public int strikes = 0;
|
||||
public Long lastStrike = 0L;
|
||||
|
||||
public int finalStrikes = 0;
|
||||
public long finalStrikeRefresh = 0L;
|
||||
|
||||
public ClientConnection(ClientConnectionManager connMan,
|
||||
SocketChannel sockChan) {
|
||||
super(connMan, sockChan, true);
|
||||
@@ -234,10 +227,10 @@ public class ClientConnection extends AbstractConnection {
|
||||
SessionManager.remSession(
|
||||
SessionManager.getSession(sessionID));
|
||||
} catch (NullPointerException e) {
|
||||
//Logger
|
||||
//.error(
|
||||
//"Tried to remove improperly initialized session. Skipping." +
|
||||
//e);
|
||||
Logger
|
||||
.error(
|
||||
"Tried to remove improperly initialized session. Skipping." +
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.server.world.WorldServer;
|
||||
import engine.session.Session;
|
||||
import engine.util.KeyCloneAudit;
|
||||
import engine.util.StringUtils;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -86,7 +85,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
if (msg.getSpeed() == 2)
|
||||
pc.setWalkMode(false);
|
||||
else
|
||||
@@ -115,7 +114,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (pc == null)
|
||||
return;
|
||||
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
|
||||
pc.setSit(msg.toggleSitStand());
|
||||
|
||||
@@ -239,11 +238,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pc.getRaceID() == 1999 && msg.getSlotNumber() == MBServerStatics.SLOT_FEET){
|
||||
forceTransferFromEquipToInventory(msg, origin, "Saetors Cannot Wear FEET Slot Items");
|
||||
return;
|
||||
}
|
||||
|
||||
//dupe check
|
||||
if (!i.validForInventory(origin, pc, itemManager))
|
||||
return;
|
||||
@@ -566,30 +560,12 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
if (!itemManager.inventoryContains(i))
|
||||
return;
|
||||
|
||||
//cannot delete gold
|
||||
if(i.getItemBaseID() == 7)
|
||||
return;
|
||||
|
||||
if (i.isCanDestroy()) {
|
||||
int goldValue = i.getBaseValue();
|
||||
if (i.getItemBase().isRune())
|
||||
goldValue = 500000;
|
||||
|
||||
if (i.getItemBaseID() == 980066)
|
||||
goldValue = 0;
|
||||
|
||||
if(itemManager.getGoldInventory().getNumOfItems() + goldValue > 10000000)
|
||||
return;
|
||||
|
||||
if (itemManager.delete(i)) {
|
||||
if (goldValue > 0)
|
||||
itemManager.addGoldToInventory(goldValue, false);
|
||||
|
||||
itemManager.updateInventory();
|
||||
if (i.isCanDestroy())
|
||||
if (itemManager.delete(i) == true) {
|
||||
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
|
||||
@@ -678,8 +654,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
JobScheduler.getInstance().scheduleJob(new RefreshGroupJob(sourcePlayer), MBServerStatics.LOAD_OBJECT_DELAY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void lootWindowRequest(LootWindowRequestMsg msg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
||||
@@ -1269,8 +1243,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
|
||||
cost = sell.getBaseValue();
|
||||
if(sell.getItemBaseID() == 980066)
|
||||
cost = 0;
|
||||
|
||||
//apply damaged value reduction
|
||||
float durabilityCurrent = sell.getDurabilityCurrent();
|
||||
@@ -1375,8 +1347,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
return;
|
||||
|
||||
// test within talking range
|
||||
if(npc.isInSafeZone())
|
||||
npc.sellPercent = 0;
|
||||
|
||||
if (sourcePlayer.getLoc().distanceSquared2D(npc.getLoc()) > MBServerStatics.NPC_TALK_RANGE * MBServerStatics.NPC_TALK_RANGE) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 14);
|
||||
@@ -1388,192 +1358,219 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
}
|
||||
|
||||
private static void buyFromNPC(BuyFromNPCMsg msg, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return;
|
||||
|
||||
if (origin.buyLock.tryLock()) {
|
||||
|
||||
try {
|
||||
CharacterItemManager itemMan = sourcePlayer.getCharItemManager();
|
||||
if (itemMan == null) {
|
||||
|
||||
if (itemMan == null)
|
||||
return;
|
||||
}
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.getNPCID());
|
||||
if (npc == null) {
|
||||
|
||||
if (npc == null)
|
||||
return;
|
||||
}
|
||||
|
||||
Item gold = itemMan.getGoldInventory();
|
||||
if (gold == null) {
|
||||
|
||||
if (gold == null)
|
||||
return;
|
||||
}
|
||||
|
||||
Item buy = null;
|
||||
|
||||
if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) {
|
||||
ArrayList<MobEquipment> sellInventory = npc.getContract().getSellInventory();
|
||||
//if(npc.contract.getObjectUUID() == 890){ // default steward
|
||||
// sellInventory = npc.getSellInventorySteward();
|
||||
//}
|
||||
//if(npc.contract.getObjectUUID() == 889){ // default builder
|
||||
// sellInventory = npc.getSellInventoryBuilder();
|
||||
//}
|
||||
if (sellInventory == null) {
|
||||
if (sellInventory == null)
|
||||
return;
|
||||
}
|
||||
for (MobEquipment me : sellInventory) {
|
||||
if (me.getObjectUUID() == msg.getItemID()) {
|
||||
ItemBase ib = me.getItemBase();
|
||||
if (ib == null) {
|
||||
if (ib == null)
|
||||
return;
|
||||
}
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight())) {
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
||||
return;
|
||||
}
|
||||
|
||||
int cost = me.getMagicValue();
|
||||
|
||||
float bargain = sourcePlayer.getBargain();
|
||||
switch(npc.getContractID()){
|
||||
case 1201:
|
||||
cost = ItemBase.getDiscPrice(ib.getUUID());
|
||||
bargain = 0;
|
||||
break;
|
||||
case 1202:
|
||||
cost = ItemBase.getStatPrice(ib.getUUID());
|
||||
bargain = 0;
|
||||
break;
|
||||
case 900:
|
||||
cost = Warehouse.getCostForResource(ib.getUUID()) * Warehouse.getSellStackSize(ib.getUUID());
|
||||
bargain = 0;
|
||||
break;
|
||||
}
|
||||
float profit;
|
||||
|
||||
if(npc.isInSafeZone())
|
||||
profit = 0;
|
||||
else
|
||||
profit = npc.getSellPercent(sourcePlayer) - bargain;
|
||||
float profit = npc.getSellPercent(sourcePlayer) - bargain;
|
||||
|
||||
if (profit < 1)
|
||||
profit = 1;
|
||||
|
||||
|
||||
if(profit > 0)
|
||||
cost *= profit;
|
||||
cost *= profit;
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
//dont' have enough goldItem exit!
|
||||
// chatMan.chatSystemInfo(pc, "" + "You dont have enough gold.");
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
int buildingDeposit = cost - me.getMagicValue();
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold() && !b.isOwnerIsNPC()) {
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}if(npc.getContractID() == 1502041){
|
||||
me.fromNoob = true;
|
||||
} else if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
// chatMan.chatSystemInfo(pc, "" + "You Failed to buy the item.");
|
||||
ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item");
|
||||
return;
|
||||
}
|
||||
if(me.getItemBase().getType().equals(ItemType.RESOURCE) && npc.getContractID() == 900){
|
||||
handleResourcePurchase(me,itemMan,sourcePlayer,ib);
|
||||
}else {
|
||||
buy = Item.createItemForPlayer(sourcePlayer, ib, me.fromNoob);
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
itemMan.addItemToInventory(buy);
|
||||
if(npc.contractUUID == 900 && buy.getItemBaseID() == 1705032){
|
||||
buy.setNumOfItems(10);
|
||||
DbManager.ItemQueries.UPDATE_NUM_ITEMS(buy,buy.getNumOfItems());
|
||||
}
|
||||
//itemMan.updateInventory();
|
||||
}
|
||||
|
||||
buy = Item.createItemForPlayer(sourcePlayer, ib);
|
||||
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
itemMan.addItemToInventory(buy);
|
||||
//itemMan.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msg.getItemType() == GameObjectType.Item.ordinal()) {
|
||||
|
||||
CharacterItemManager npcCim = npc.getCharItemManager();
|
||||
|
||||
if (npcCim == null)
|
||||
return;
|
||||
|
||||
buy = Item.getFromCache(msg.getItemID());
|
||||
|
||||
if (buy == null)
|
||||
return;
|
||||
|
||||
ItemBase ib = buy.getItemBase();
|
||||
|
||||
if (ib == null)
|
||||
return;
|
||||
|
||||
if (!npcCim.inventoryContains(buy))
|
||||
return;
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
||||
return;
|
||||
|
||||
//TODO test cost and subtract goldItem
|
||||
|
||||
//TODO CHnage this if we ever put NPc city npcs in buildings.
|
||||
int cost = buy.getBaseValue();
|
||||
|
||||
if (buy.isID() || buy.isCustomValue())
|
||||
cost = buy.getMagicValue();
|
||||
|
||||
float bargain = sourcePlayer.getBargain();
|
||||
|
||||
float profit = npc.getSellPercent(sourcePlayer) - bargain;
|
||||
|
||||
if (profit < 1)
|
||||
profit = 1;
|
||||
|
||||
if (!buy.isCustomValue())
|
||||
cost *= profit;
|
||||
else
|
||||
cost = buy.getValue();
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 128); // Insufficient Gold
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null)
|
||||
if (b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
|
||||
int buildingDeposit = cost;
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold() && !b.isOwnerIsNPC()) {
|
||||
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 110);
|
||||
return;
|
||||
}
|
||||
|
||||
if (buy != null)
|
||||
itemMan.buyFromNPC(buy, npc);
|
||||
|
||||
} else if (msg.getItemType() == GameObjectType.MobLoot.ordinal()) {
|
||||
|
||||
CharacterItemManager npcCim = npc.getCharItemManager();
|
||||
|
||||
if (npcCim == null)
|
||||
return;
|
||||
|
||||
buy = MobLoot.getFromCache(msg.getItemID());
|
||||
|
||||
if (buy == null)
|
||||
return;
|
||||
|
||||
ItemBase ib = buy.getItemBase();
|
||||
|
||||
if (ib == null)
|
||||
return;
|
||||
|
||||
if (!npcCim.inventoryContains(buy))
|
||||
return;
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(ib.getWeight()))
|
||||
return;
|
||||
|
||||
//TODO test cost and subtract goldItem
|
||||
|
||||
//TODO CHnage this if we ever put NPc city npcs in buildings.
|
||||
|
||||
int cost = buy.getMagicValue();
|
||||
cost *= npc.getSellPercent(sourcePlayer);
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 128); // Insufficient Gold
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
int buildingDeposit = cost;
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold() && !b.isOwnerIsNPC()) {
|
||||
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit))
|
||||
return;
|
||||
|
||||
if (buy != null)
|
||||
itemMan.buyFromNPC(buy, npc);
|
||||
|
||||
} else
|
||||
return;
|
||||
|
||||
if (buy != null) {
|
||||
|
||||
msg.setItem(buy);
|
||||
//send the buy message back to update player
|
||||
// msg.setItemType(buy.getObjectType().ordinal());
|
||||
@@ -1582,43 +1579,14 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
|
||||
} finally {
|
||||
origin.buyLock.unlock();
|
||||
}
|
||||
} else {
|
||||
ErrorPopupMsg.sendErrorPopup(origin.getPlayerCharacter(), 12); // All production slots taken
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleResourcePurchase(MobEquipment me, CharacterItemManager itemMan, PlayerCharacter sourcePlayer, ItemBase ib){
|
||||
boolean stacked = false;
|
||||
int buystack = Warehouse.getSellStackSize(me.getItemBase().getUUID());
|
||||
for(Item item : itemMan.getInventory()){
|
||||
int itemID = item.getItemBaseID();
|
||||
int meID = me.getItemBase().getUUID();
|
||||
if(itemID == meID){
|
||||
if(Warehouse.maxResources.isEmpty())
|
||||
Warehouse.getMaxResources();
|
||||
int maxStack = Warehouse.maxResources.get(itemID);
|
||||
if(maxStack > item.getNumOfItems() + buystack){
|
||||
item.setNumOfItems(item.getNumOfItems() + buystack);
|
||||
stacked = true;
|
||||
itemMan.updateInventory();
|
||||
DbManager.ItemQueries.UPDATE_NUM_ITEMS(item,item.getNumOfItems());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!stacked){
|
||||
Item buy = Item.createItemForPlayer(sourcePlayer, ib, false);
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
itemMan.addItemToInventory(buy);
|
||||
buy.setNumOfItems(buystack);
|
||||
DbManager.ItemQueries.UPDATE_NUM_ITEMS(buy,buy.getNumOfItems());
|
||||
}
|
||||
}
|
||||
itemMan.updateInventory();
|
||||
}
|
||||
|
||||
private static void Repair(RepairMsg msg, ClientConnection origin) {
|
||||
@@ -1678,21 +1646,14 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
max *= (1 + (durMod * 0.01f));
|
||||
if (dur >= max || dur < 1) {
|
||||
//redundancy message to clear item from window in client
|
||||
if (!DbManager.ItemQueries.SET_DURABILITY(toRepair, dur))
|
||||
return;
|
||||
toRepair.setDurabilityCurrent(max);
|
||||
msg.setupRepairAck(max - dur);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return;
|
||||
}
|
||||
|
||||
int pointsToRepair = max - dur;
|
||||
double damageRatio = (double)1.0d - (toRepair.getDurabilityMax() - toRepair.getDurabilityCurrent()) / toRepair.getDurabilityMax();
|
||||
int modifiedValue = (int)(damageRatio * toRepair.getMagicValue());
|
||||
int costPerPoint = modifiedValue / toRepair.getDurabilityMax();
|
||||
int modifiedRepairCost = (int)(pointsToRepair * costPerPoint)+ npc.getSpecialPrice();
|
||||
int cost = (int)(modifiedRepairCost * 1 + npc.buyPercent) + npc.getSpecialPrice();
|
||||
//TODO get cost to repair
|
||||
int cost = (int) ((max - dur) * 80.1);
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null)
|
||||
@@ -1886,7 +1847,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
|
||||
switch (protocolMsg) {
|
||||
case SETSELECTEDOBECT:
|
||||
KeyCloneAudit.auditTargetMsg(msg);
|
||||
ClientMessagePump.targetObject((TargetObjectMsg) msg, origin);
|
||||
break;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size() && building.getRank() != 8)
|
||||
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
|
||||
return false;
|
||||
|
||||
Item contractItem = Item.getFromCache(msg.getContractItem());
|
||||
|
||||
@@ -11,7 +11,6 @@ import engine.objects.GuildStatusController;
|
||||
import engine.objects.Mine;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.Resource;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
/*
|
||||
* @Author:
|
||||
@@ -36,28 +35,26 @@ public class ArcMineChangeProductionMsgHandler extends AbstractClientMsgHandler
|
||||
|
||||
//TODO verify this against the warehouse?
|
||||
|
||||
if (!GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus())) // is this only GL?
|
||||
if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) // is this only GL?
|
||||
return true;
|
||||
|
||||
Mine mine = Mine.getMine(changeProductionMsg.getMineID());
|
||||
|
||||
if (mine == null) {
|
||||
Logger.error("Player Character: " + playerCharacter.getName() + " Tried To Change Mine: " + changeProductionMsg.getMineID() + " and Mine was Null");
|
||||
if (mine == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
//make sure mine belongs to guild
|
||||
|
||||
if (mine.getOwningGuild().isEmptyGuild() || mine.getOwningGuild().getObjectUUID() != playerCharacter.getGuild().getObjectUUID())
|
||||
if (mine.getOwningGuild().isEmptyGuild() ||
|
||||
mine.getOwningGuild().getObjectUUID() != playerCharacter.getGuild().getObjectUUID())
|
||||
return true;
|
||||
|
||||
//make sure valid resource
|
||||
|
||||
Resource resource = Resource.resourceByHash.get(changeProductionMsg.getResourceHash());
|
||||
|
||||
if (resource == null) {
|
||||
Logger.error("Player Character: " + playerCharacter.getName() + " Tried To Change Mine: " + changeProductionMsg.getMineID() + " and Resource was Null");
|
||||
if (resource == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
//update resource
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.exception.MsgSendException;
|
||||
import engine.net.DispatchMessage;
|
||||
@@ -43,24 +42,18 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
if (!AbstractCharacter.CanFly(pc))
|
||||
return false;
|
||||
|
||||
if(pc.getBonuses().getBool(Enum.ModType.Stunned, Enum.SourceType.None))
|
||||
return false;
|
||||
|
||||
if (pc.isSwimming())
|
||||
return false;
|
||||
if (pc.region != null && !pc.region.isOutside())
|
||||
return false;
|
||||
|
||||
|
||||
// Find out if we already have an altitude timer running and if so
|
||||
// do not process more alt change requests
|
||||
|
||||
pc.updateFlight();
|
||||
|
||||
if (pc.getTakeOffTime() != 0)
|
||||
return false;
|
||||
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
|
||||
|
||||
// remove all movement timers and jobs
|
||||
//TODO: test if they can fly
|
||||
@@ -74,7 +67,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
if (pc.getAltitude() == 0 && !msg.up())
|
||||
return true;
|
||||
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
pc.stopMovement(pc.getLoc());
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
if (msg.up()) {
|
||||
@@ -139,7 +132,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
if (msg.up()) {
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
} else {
|
||||
@@ -165,7 +158,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
} else
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
|
||||
pc.update(false);
|
||||
pc.update();
|
||||
|
||||
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class CityDataHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// If the hotZone has changed then update the client's map accordingly.
|
||||
|
||||
if (playerCharacter.getTimestamps().containsKey("hotzoneupdate") && playerCharacter.getTimeStamp("hotzoneupdate") <= ZoneManager.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) {
|
||||
if (playerCharacter.getTimeStamp("hotzoneupdate") <= ZoneManager.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) {
|
||||
HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID());
|
||||
dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user