Compare commits

..
Author SHA1 Message Date
MagicBotandClaude Opus 5.5 40799f96f6 Mark summoned pets with MASK_PET
Summoned pets (not necro pets) now carry MASK_PET, so pet-targeted
AOE powers can find them. The checkForAggro pet scan is held off with
PET_AGGRO_ENABLED until it checks rune enemy lists, filters targets
and keeps pet targets (plan-mask-pet.md steps 2-4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 09:19:36 -04:00
MagicBotandClaude Opus 5.5 5262a602da Keep siege engine target when a new player loads it
InterestManager cleared the combat target of every live mob loaded for
a new player, so a siege engine firing at a wall dropped its target
whenever someone entered load range. Siege engines now keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 09:05:24 -04:00
MagicBotandClaude Opus 5.5 5b80614376 Restore regular mob MASK_PET aggro scan
The scan was removed as dead code, but creature runes list Pet in
rune_enemy_monster_types, so monsters are meant to aggro summoned pets.
Restored unchanged; it stays inactive until MASK_PET is set from the
rune data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 09:00:27 -04:00
MagicBotandClaude Opus 5.5 b60f2754f1 Remove siege and pet auto-aggro scans
Guard MASK_SIEGE and regular mob MASK_PET scans were dead code: no mob
ever carries either mask. Removed so they cannot start auto-aggroing
siege engines if the masks are wired up later. Safehold guards no
longer aggro siege engines. Guards still respond to a siege engine
damaging a city building.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:53:57 -04:00
MagicBotandClaude Opus 5.5 89cdf5655d Flag players hostile for damaging siege engines on a city grid
Damaging a siege engine on a city grid adds the attacker (or the owning
player, for pets) to that city's outlaw list, unless they are in the
city's nation or an allied nation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:53:24 -04:00
MagicBotandClaude Opus 5.5 c9208000bb Pull siege engine aggro on damage only
A siege engine switches to whoever damages it, player or pet, even when
it already has a target. Pre-roll melee retaliation, harmful-power
direct aggro (which also fires on misses) and Taunt no longer change a
siege engine's target. The attack timer is untouched, so a switched
engine still waits for its next cycle before firing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:52:56 -04:00
MagicBotandClaude Opus 5.5 531a2d028b Drop siege engine targets only on death or attack range
Siege engines dropped player targets at 100 units, at the 200 unit
drop-aggro range, or when the player was missing from playerAgroMap,
all well inside their 350 attack range. They now hold a character
target until it dies, can't be seen, or leaves getRange().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:52:09 -04:00
MagicBotandClaude Opus 5.5 ca33c5a14c Keep siege engines alive and targeting when released
Owner death, logout or invisibility dismissed a commanded siege engine
by clearing its target and marking it dead. Released engines now revert
to MOBILE in place, stay alive and keep their current target so any
nation member can re-command them with a Rod of Command. Commanding an
engine no longer clears the target of the old or new engine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:51:38 -04:00
MagicBot 5868530414 mobai aligned with rune data and client. 2026-10-15 07:31:30 -04:00
MagicBotandClaude Opus 5.5 66a731005e Use race rune natural attack damage for unarmed players
Unarmed base damage was a hardcoded 1-3 (TODO). Read it from the race
rune natural attack for the swinging hand (1-4 for all races), then
scale it with the existing formula, matching the client (0x46D200).
Falls back to 1-3 if the rune has no natural attack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:24:33 -04:00
MagicBotandClaude Opus 5.5 330db50985 Use rune ATTACK for regular mob ATR
The client (0x466570) gives mobiles their ATR straight from the rune
ATTACK. Read rune_attack from the rune template, falling back to the
mobbase atr when the rune has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:15:26 -04:00
MagicBotandClaude Opus 5.5 12c08c940a Use rune MINDAMAGE/MAXDAMAGE for regular mob damage
The client (ArcMobile, 0x46D200) takes mob damage straight from the rune
MINDAMAGE/MAXDAMAGE with no stat scaling; natural attack damage is only
scaled for non-mobile characters. Read rune_min_damage/rune_max_damage
from the rune template, falling back to the mobbase row when the rune
has none. 2689 of 2770 mobbase rows already match the rune.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:13:52 -04:00
MagicBotandClaude Opus 5.5 b21ccdbb4c Use rune natural attack range for unarmed mobs
Unarmed mobs now add their rune natural attack range in processAttack
and use it in getRange. Most melee runes have 0, so they are unchanged;
ranged plant mobs (Gasser, Spitter, Needler, ...) get 150, Shuggra 50.
Natural range is not subject to the unverified 80 clamp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:05:25 -04:00
MagicBotandClaude Opus 5.5 a708a1f0b2 Use rune natural attack range for siege engines
Siege engine range was hardcoded to 300. Read it from the rune natural
attack instead (350 for Trebuchet, Mangonel and Ballista), matching the
client's RecalcMinWeaponRange. Falls back to 300 if the rune has none.
getNaturalAttack now returns the whole entry so speed and range share
the lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:04:11 -04:00
MagicBotandClaude Opus 5.5 b525a7a3ab Document verified rune natural attack layout
Field layout of rune_naturalattacks confirmed in the client (IDA): it is
the same attack info struct as a weapon, so [0] is WEPSPEED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:01:57 -04:00
MagicBotandClaude Opus 5.5 b690195233 Use race rune natural attack speed for unarmed players
Extend getNaturalAttackSpeed to resolve the rune from the attacker type:
mobbase rune for mobs, race rune for players. Unarmed players now swing
at their race rune speed (20 = 2.0 s per hand) instead of a flat 5000 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 06:56:21 -04:00
MagicBotandClaude Opus 5.5 9aa44d4e9a Use rune natural attack speed for unarmed mobs
Unarmed mobs used a flat 5000 ms swing delay. Parse rune_naturalattacks
from the rune template and use its speed (x100 ms) instead, with the
AttackDelay modifier and 1.0 s floor applied as for weapons. Siege
engines now fire every 17.5 s (speed 175); most creatures swing every 3.5 s.
Falls back to 5000 ms when the rune has no natural attack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 06:53:50 -04:00
MagicBot ab1c3f12d3 mobai null resolution 2026-10-14 15:22:38 -04:00
MagicBot 6017641896 mobai null resolution 2026-10-14 14:36:07 -04:00
38 changed files with 506 additions and 262 deletions

No files matched your search

@@ -468,7 +468,12 @@ public enum InterestManager implements Runnable {
continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
((Mob) awonpc).setCombatTarget(null);
// siege engines keep firing at their target when a new player loads them
if (!awonpc.isSiege())
((Mob) awonpc).setCombatTarget(null);
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
} else if ((awo.getObjectTypeMask() & MBServerStatics.MASK_NPC) != 0) {
+11 -10
View File
@@ -14,6 +14,7 @@ import engine.mbEnums;
import engine.objects.Bane;
import engine.objects.City;
import engine.workthreads.WarehousePushThread;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.*;
@@ -33,8 +34,8 @@ public class BaneRecord extends DataRecord {
private String baneDropperHash;
private String baneGuildHash;
private String baneNationHash;
private LocalDateTime baneLiveTime;
private LocalDateTime baneDropTime;
private DateTime baneLiveTime;
private DateTime baneDropTime;
private BaneRecord(Bane bane) {
this.recordType = mbEnums.DataRecordType.BANE;
@@ -128,9 +129,9 @@ public class BaneRecord extends DataRecord {
return outStatement;
}
public static LocalDateTime getLastBaneDateTime(City city) {
public static DateTime getLastBaneDateTime(City city) {
LocalDateTime outDateTime = null;
DateTime outDateTime = null;
try (Connection connection = DbManager.getConnection();
PreparedStatement statement = buildDateTimeQueryStatement(connection, city);
@@ -138,7 +139,7 @@ public class BaneRecord extends DataRecord {
while (rs.next()) {
outDateTime = rs.getTimestamp("endDatetime").toLocalDateTime();
outDateTime = new DateTime(rs.getTimestamp("endDatetime"));
}
@@ -159,7 +160,7 @@ public class BaneRecord extends DataRecord {
}
public static void updateLiveDate(Bane bane, LocalDateTime dateTime) {
public static void updateLiveDate(Bane bane, DateTime dateTime) {
if (bane == null)
return;
@@ -174,13 +175,13 @@ public class BaneRecord extends DataRecord {
}
}
private static PreparedStatement buildUpdateLiveDateStatement(Connection connection, Bane bane, LocalDateTime dateTime) throws SQLException {
private static PreparedStatement buildUpdateLiveDateStatement(Connection connection, Bane bane, DateTime dateTime) throws SQLException {
PreparedStatement outStatement = null;
String queryString = "UPDATE `warehouse_banehistory` SET `liveDatetime` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
outStatement = connection.prepareStatement(queryString);
outStatement.setTimestamp(1, Timestamp.valueOf(dateTime));
outStatement.setTimestamp(1, new java.sql.Timestamp(dateTime.getMillis()));
outStatement.setString(2, bane.getCity().getHash());
return outStatement;
@@ -365,12 +366,12 @@ public class BaneRecord extends DataRecord {
if (this.baneDropTime == null)
outStatement.setNull(8, java.sql.Types.DATE);
else
outStatement.setTimestamp(8, Timestamp.valueOf(this.baneDropTime));
outStatement.setTimestamp(8, new java.sql.Timestamp(this.baneDropTime.getMillis()));
if (this.baneLiveTime == null)
outStatement.setNull(9, java.sql.Types.DATE);
else
outStatement.setTimestamp(9, Timestamp.valueOf(this.baneLiveTime));
outStatement.setTimestamp(9, new java.sql.Timestamp(this.baneLiveTime.getMillis()));
outStatement.setString(10, this.eventType.name());
+3 -3
View File
@@ -14,7 +14,7 @@ import engine.objects.Bane;
import engine.objects.Building;
import engine.objects.City;
import engine.objects.PlayerCharacter;
import java.time.LocalDateTime;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@@ -71,12 +71,12 @@ public class dbBaneHandler extends dbHandlerBase {
}
public boolean SET_BANE_TIME(LocalDateTime toSet, int cityUUID) {
public boolean SET_BANE_TIME(DateTime toSet, int cityUUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_banes` SET `liveDate`=? WHERE `cityUUID`=?")) {
preparedStatement.setTimestamp(1, java.sql.Timestamp.valueOf(toSet));
preparedStatement.setTimestamp(1, new java.sql.Timestamp(toSet.getMillis()));
preparedStatement.setLong(2, cityUUID);
preparedStatement.execute();
@@ -17,9 +17,7 @@ import engine.mbEnums.DbObjectType;
import engine.mbEnums.ProtectionState;
import engine.mbEnums.TaxType;
import engine.objects.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@@ -42,7 +40,7 @@ public class dbBuildingHandler extends dbHandlerBase {
public Building CREATE_BUILDING(int parentZoneID, int OwnerUUID, String name, int meshUUID,
Vector3fImmutable location, float meshScale, int currentHP,
ProtectionState protectionState, int currentGold, int rank,
Instant upgradeDate, int blueprintUUID, float w, float rotY) {
DateTime upgradeDate, int blueprintUUID, float w, float rotY) {
Building building = null;
@@ -63,7 +61,7 @@ public class dbBuildingHandler extends dbHandlerBase {
preparedStatement.setInt(12, rank);
if (upgradeDate != null)
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.toEpochMilli()));
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
else
preparedStatement.setNull(13, java.sql.Types.DATE);
@@ -751,7 +749,7 @@ public class dbBuildingHandler extends dbHandlerBase {
return false;
}
public boolean updateBuildingUpgradeTime(Instant upgradeDateTime, Building toUpgrade, int costToUpgrade) {
public boolean updateBuildingUpgradeTime(LocalDateTime upgradeDateTime, Building toUpgrade, int costToUpgrade) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET upgradeDate=?, currentGold=? "
@@ -760,7 +758,8 @@ public class dbBuildingHandler extends dbHandlerBase {
if (upgradeDateTime == null)
preparedStatement.setNull(1, java.sql.Types.DATE);
else
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.toEpochMilli()));
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault())
.toInstant().toEpochMilli()));
preparedStatement.setInt(2, toUpgrade.getStrongboxValue() - costToUpgrade);
preparedStatement.setInt(3, toUpgrade.getObjectUUID());
@@ -839,7 +838,7 @@ public class dbBuildingHandler extends dbHandlerBase {
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxDate=? "
+ "WHERE UID = ?")) {
preparedStatement.setTimestamp(1, new java.sql.Timestamp(Instant.now().plus(7, java.time.temporal.ChronoUnit.DAYS).toEpochMilli()));
preparedStatement.setTimestamp(1, new java.sql.Timestamp(DateTime.now().plusDays(7).getMillis()));
preparedStatement.setInt(2, building.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
+3 -3
View File
@@ -14,7 +14,7 @@ import engine.mbEnums;
import engine.mbEnums.GuildHistoryType;
import engine.objects.*;
import engine.server.world.WorldServer;
import java.time.Instant;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.*;
@@ -125,7 +125,7 @@ public class dbGuildHandler extends dbHandlerBase {
return false;
}
public boolean ADD_TO_GUILDHISTORY(int target, PlayerCharacter playerCharacter, Instant historyDate, GuildHistoryType historyType) {
public boolean ADD_TO_GUILDHISTORY(int target, PlayerCharacter playerCharacter, DateTime historyDate, GuildHistoryType historyType) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_guildhistory` (`GuildID`, `CharacterID`, `historyDate`, `historyType`) VALUES (?,?,?,?)")) {
@@ -136,7 +136,7 @@ public class dbGuildHandler extends dbHandlerBase {
if (historyDate == null)
preparedStatement.setNull(3, java.sql.Types.DATE);
else
preparedStatement.setTimestamp(3, java.sql.Timestamp.from(historyDate));
preparedStatement.setTimestamp(3, new Timestamp(historyDate.getMillis()));
preparedStatement.setString(4, historyType.name());
+3 -4
View File
@@ -12,8 +12,7 @@ package engine.db.handlers;
import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.objects.Mob;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@@ -83,7 +82,7 @@ public class dbMobHandler extends dbHandlerBase {
return mobileList;
}
public boolean updateUpgradeTime(Mob mob, LocalDateTime upgradeDateTime) {
public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_mob SET upgradeDate=? "
@@ -92,7 +91,7 @@ public class dbMobHandler extends dbHandlerBase {
if (upgradeDateTime == null)
preparedStatement.setNull(1, java.sql.Types.DATE);
else
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.getMillis()));
preparedStatement.setInt(2, mob.getObjectUUID());
+3 -4
View File
@@ -15,8 +15,7 @@ import engine.mbEnums;
import engine.mbEnums.ProfitType;
import engine.objects.NPC;
import engine.objects.NPCProfits;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@@ -241,7 +240,7 @@ public class dbNPCHandler extends dbHandlerBase {
}
}
public boolean updateUpgradeTime(NPC npc, LocalDateTime upgradeDateTime) {
public boolean updateUpgradeTime(NPC npc, DateTime upgradeDateTime) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET upgradeDate=? "
@@ -250,7 +249,7 @@ public class dbNPCHandler extends dbHandlerBase {
if (upgradeDateTime == null)
preparedStatement.setNull(1, java.sql.Types.DATE);
else
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.getMillis()));
preparedStatement.setInt(2, npc.getObjectUUID());
+3 -3
View File
@@ -16,7 +16,7 @@ import engine.mbEnums.ProtectionState;
import engine.objects.AbstractGameObject;
import engine.objects.Building;
import engine.objects.Shrine;
import java.time.Instant;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
@@ -53,7 +53,7 @@ public class dbShrineHandler extends dbHandlerBase {
public ArrayList<AbstractGameObject> CREATE_SHRINE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
Vector3fImmutable location, float meshScale, int currentHP,
ProtectionState protectionState, int currentGold, int rank,
Instant upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
DateTime upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
ArrayList<AbstractGameObject> shrineList = new ArrayList<>();
@@ -74,7 +74,7 @@ public class dbShrineHandler extends dbHandlerBase {
preparedStatement.setInt(12, rank);
if (upgradeDate != null)
preparedStatement.setTimestamp(13, java.sql.Timestamp.from(upgradeDate));
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
else
preparedStatement.setNull(13, java.sql.Types.DATE);
@@ -20,7 +20,7 @@ import engine.objects.City;
import engine.objects.Transaction;
import engine.objects.Warehouse;
import engine.server.MBServerStatics;
import java.time.Instant;
import org.joda.time.DateTime;
import org.json.JSONArray;
import org.json.JSONObject;
import org.pmw.tinylog.Logger;
@@ -40,7 +40,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
}
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, mbEnums.ResourceType resource, int amount, Instant date) {
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, mbEnums.ResourceType resource, int amount, DateTime date) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse_transactions` (`warehouseUID`, `targetType`,`targetUID`, `type`,`resource`,`amount`,`date` ) VALUES (?,?,?,?,?,?,?)")) {
@@ -51,7 +51,7 @@ public class dbWarehouseHandler extends dbHandlerBase {
preparedStatement.setString(4, transactionType.name());
preparedStatement.setString(5, resource.name());
preparedStatement.setInt(6, amount);
preparedStatement.setTimestamp(7, new java.sql.Timestamp(date.toEpochMilli()));
preparedStatement.setTimestamp(7, new java.sql.Timestamp(date.getMillis()));
return (preparedStatement.executeUpdate() > 0);
+1 -3
View File
@@ -25,7 +25,6 @@ import engine.objects.*;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
@@ -275,8 +274,7 @@ public enum BuildingManager {
if (building == null)
return;
Instant instant = (upgradeDateTime == null) ? null : upgradeDateTime.atZone(ZoneId.systemDefault()).toInstant();
if (!DbManager.BuildingQueries.updateBuildingUpgradeTime(instant, building, rankCost)) {
if (!DbManager.BuildingQueries.updateBuildingUpgradeTime(upgradeDateTime, building, rankCost)) {
Logger.error("Failed to set upgradeTime for building " + building.getObjectUUID());
return;
}
+110 -5
View File
@@ -14,6 +14,7 @@ import engine.jobs.AttackJob;
import engine.jobs.DeferredPowerJob;
import engine.mbEnums;
import engine.net.client.ClientConnection;
import engine.net.client.msg.PowerProjectileMsg;
import engine.net.client.msg.TargetedActionMsg;
import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*;
@@ -146,11 +147,19 @@ public enum CombatManager {
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
attackRange += weapon.template.item_weapon_max_range * rangeMod;
} else if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) {
//unarmed mob, add the natural attack range from its rune (0 for most melee mobs)
if (bonus != null)
rangeMod += bonus.getFloatPercentAll(mbEnums.ModType.WeaponRange, mbEnums.SourceType.None);
attackRange += getNaturalAttackRange(attacker, slot) * rangeMod;
}
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
if (((Mob) attacker).isSiege())
attackRange = 300;
attackRange = getSiegeRange((Mob) attacker);
float distanceSquared = attacker.loc.distanceSquared(target.loc);
@@ -214,6 +223,22 @@ public enum CombatManager {
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
delay = (long)wepSpeed * 100L;
} else {
//unarmed, use the natural attack speed from the mob or race rune
float naturalSpeed = getNaturalAttackSpeed(attacker, slot);
if (naturalSpeed > 0) {
if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus
naturalSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None));
if (naturalSpeed < 10)
naturalSpeed = 10;
delay = (long) naturalSpeed * 100L;
}
}
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob))
@@ -232,7 +257,8 @@ public enum CombatManager {
//handle retaliate
if (AbstractCharacter.IsAbstractCharacter(target)) {
//siege engines only retaliate on damage, see AbstractCharacter.modifyHealth
if (AbstractCharacter.IsAbstractCharacter(target) && !(target.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) target).isSiege())) {
if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) {
((AbstractCharacter) target).combatTarget = attacker;
if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat())
@@ -319,7 +345,7 @@ public enum CombatManager {
DispatchManager.sendToAllInRange(attacker, msg);
//we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon == null ? null : weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm);
//set auto attack job
@@ -359,7 +385,7 @@ public enum CombatManager {
DispatchManager.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
//we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon == null ? null : weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm);
//set auto attack job
setAutoAttackJob(attacker, slot, delay);
@@ -447,7 +473,7 @@ public enum CombatManager {
if (resists.immuneTo(damageType)) {
//set auto attack job
//we need to send the animation even if the attacker misses
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon.template, null, slot));
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) 0, getSwingAnimation(weapon == null ? null : weapon.template, null, slot));
DispatchManager.sendToAllInRange(target, cmm);
setAutoAttackJob(attacker, slot, delay);
return;
@@ -479,6 +505,15 @@ public enum CombatManager {
}
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
DispatchManager.sendToAllInRange(target, cmm);
//siege projectile is sent once per hit, not per AI pulse
if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob) && ((Mob) attacker).isSiege()
&& target.getObjectType().equals(mbEnums.GameObjectType.Building)) {
PowerProjectileMsg ppm = new PowerProjectileMsg(attacker, target);
ppm.setRange(50);
DispatchManager.dispatchMsgToInterestArea(attacker, ppm, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
}
}
}
@@ -636,6 +671,76 @@ public enum CombatManager {
}
public static float getNaturalAttackSpeed(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
// Returns the rune natural attack speed (x100 ms) for this hand, or 0 if the rune has none.
float[] attack = getNaturalAttack(attacker, slot);
if (attack == null || attack.length < 1)
return 0;
return attack[0];
}
public static float getNaturalAttackRange(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
// Returns the rune natural attack range for this hand, or 0 if the rune has none.
float[] attack = getNaturalAttack(attacker, slot);
if (attack == null || attack.length < 2)
return 0;
return attack[1];
}
public static float getSiegeRange(Mob siegeEngine) {
// Siege engines use the range from their rune natural attack (350 for all three), 300 if the rune has none.
float range = getNaturalAttackRange(siegeEngine, mbEnums.EquipSlotType.RHELD);
if (range <= 0)
return 300;
return range;
}
public static float[] getNaturalAttack(AbstractCharacter attacker, mbEnums.EquipSlotType slot) {
// Returns the rune natural attack entry for this hand, or null if the rune has none.
// Mobs use their mobbase rune, players use their race rune.
int runeID;
ItemTemplate rune;
int hand = slot.equals(mbEnums.EquipSlotType.LHELD) ? 2 : 1;
switch (attacker.getObjectType()) {
case Mob:
runeID = ((Mob) attacker).loadID;
break;
case PlayerCharacter:
runeID = ((PlayerCharacter) attacker).getRaceID();
break;
default:
return null;
}
rune = ItemTemplate.templates.get(runeID);
if (rune == null || rune.rune_natural_attacks.isEmpty())
return null;
for (float[] attack : rune.rune_natural_attacks)
if (attack.length > 3 && (int) attack[3] == hand)
return attack;
// No entry for this hand, fall back to the first natural attack
return rune.rune_natural_attacks.get(0);
}
public static int calculatePetDamage(AbstractCharacter agent) {
//damage calc for pet
float range;
+5 -5
View File
@@ -16,7 +16,7 @@ import engine.net.client.ClientConnection;
import engine.net.client.msg.guild.AcceptInviteToGuildMsg;
import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.*;
import java.time.Instant;
import org.joda.time.DateTime;
public enum GuildManager {
@@ -67,8 +67,8 @@ public enum GuildManager {
return false;
if (playerCharacter.getGuild() != null && !playerCharacter.getGuild().isEmptyGuild()) {
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, Instant.now(), GuildHistoryType.LEAVE)) {
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), Instant.now(), GuildHistoryType.LEAVE);
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(playerCharacter.getGuildUUID(), playerCharacter, DateTime.now(), GuildHistoryType.LEAVE)) {
GuildHistory guildHistory = new GuildHistory(playerCharacter.getGuildUUID(), playerCharacter.getGuild().getName(), DateTime.now(), GuildHistoryType.LEAVE);
playerCharacter.getGuildHistory().add(guildHistory);
}
}
@@ -90,8 +90,8 @@ public enum GuildManager {
dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
}
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, Instant.now(), historyType)) {
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), Instant.now(), historyType);
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), playerCharacter, DateTime.now(), historyType)) {
GuildHistory guildHistory = new GuildHistory(guild.getObjectUUID(), guild.getName(), DateTime.now(), historyType);
playerCharacter.getGuildHistory().add(guildHistory);
}
+6 -3
View File
@@ -11,7 +11,7 @@ package engine.jobs;
import engine.job.AbstractScheduleJob;
import engine.objects.Bane;
import java.time.LocalDateTime;
import org.joda.time.DateTime;
public class BaneDefaultTimeJob extends AbstractScheduleJob {
@@ -31,8 +31,11 @@ public class BaneDefaultTimeJob extends AbstractScheduleJob {
return;
}
LocalDateTime defaultTime = this.bane.getPlacementDate()
.plusDays(2).withHour(22).withMinute(0).withSecond(0).withNano(0);
DateTime defaultTime = new DateTime(this.bane.getPlacementDate());
defaultTime = defaultTime.plusDays(2);
defaultTime = defaultTime.hourOfDay().setCopy(22);
defaultTime = defaultTime.minuteOfHour().setCopy(0);
defaultTime = defaultTime.secondOfMinute().setCopy(0);
this.bane.setLiveDate(defaultTime);
}
+50 -56
View File
@@ -14,12 +14,10 @@ import engine.gameManager.*;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.mbEnums;
import engine.mbEnums.DispatchChannel;
import engine.mobileAI.Threads.MobAIThread;
import engine.mobileAI.Threads.ReSpawner;
import engine.mobileAI.utilities.MovementUtilities;
import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.PowerProjectileMsg;
import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
@@ -46,6 +44,11 @@ public class MobAI {
//
// CombatManager.class implements shared combat routines for all avatars.
// Pet aggro scan in checkForAggro stays off until it checks rune enemy lists,
// filters its targets and keeps pet targets (MBDATA/docs/plan-mask-pet.md steps 2-4).
private static final boolean PET_AGGRO_ENABLED = false;
private static void attackTarget(Mob mob, AbstractWorldObject target) {
try {
@@ -93,7 +96,7 @@ public class MobAI {
mob.updateLocation();
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget");
}
}
@@ -112,7 +115,9 @@ public class MobAI {
if (mob.behaviourType.callsForHelp)
mobCallForHelp(mob);
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
// siege engines drop targets on their own attack range in determineAction
if (!mob.isSiege() && !MovementUtilities.inRangeDropAggro(mob, target)) {
mob.setCombatTarget(null);
return;
}
@@ -133,7 +138,7 @@ public class MobAI {
target.getPet().setCombatTarget(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer");
}
}
@@ -155,20 +160,10 @@ public class MobAI {
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob);
if (mob.isSiege())
MovementManager.sendRWSSMsg(mob);
CombatManager.combatCycle(mob, target);
if (mob.isSiege()) {
PowerProjectileMsg ppm = new PowerProjectileMsg(mob, target);
ppm.setRange(50);
DispatchManager.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());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackBuilding");
}
}
@@ -186,7 +181,7 @@ public class MobAI {
CombatManager.combatCycle(mob, target);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob");
}
}
@@ -248,7 +243,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: Patrol");
}
}
@@ -290,7 +285,7 @@ public class MobAI {
return mob.nextCastTime <= System.currentTimeMillis();
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: canCast");
}
return false;
}
@@ -387,7 +382,7 @@ public class MobAI {
return true;
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast");
}
return false;
}
@@ -452,7 +447,7 @@ public class MobAI {
mob.nextCallForHelp = System.currentTimeMillis() + 60000;
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCallForHelp");
}
}
@@ -518,7 +513,16 @@ public class MobAI {
boolean bypassLoadedPlayerCheck = false;
if (mob.isPlayerGuard() || mob.isSiege()) {
bypassLoadedPlayerCheck = true;
if (mob.combatTarget != null && mob.combatTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
if (mob.isSiege()) {
// siege engines hold a character target until it dies or leaves their attack range
if (mob.combatTarget != null && AbstractCharacter.IsAbstractCharacter(mob.combatTarget))
if (mob.combatTarget.loc.distanceSquared(mob.loc) > mob.getRange() * mob.getRange())
mob.setCombatTarget(null);
} else if (mob.combatTarget != null && mob.combatTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter))
if (mob.combatTarget.loc.distanceSquared(mob.loc) > 10000)
mob.setCombatTarget(null);
}
@@ -544,7 +548,7 @@ public class MobAI {
PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget();
if (!mob.playerAgroMap.containsKey(target.getObjectUUID())) {
if (!mob.isSiege() && !mob.playerAgroMap.containsKey(target.getObjectUUID())) {
mob.setCombatTarget(null);
return;
}
@@ -575,7 +579,7 @@ public class MobAI {
break;
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction");
}
}
@@ -630,7 +634,7 @@ public class MobAI {
}
}
if (aiAgent.getCombatTarget() == null) {
if (PET_AGGRO_ENABLED && aiAgent.getCombatTarget() == null) {
//look for pets to aggro if no players found to aggro
@@ -649,7 +653,7 @@ public class MobAI {
}
}
} catch (Exception e) {
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro" + " " + e.getMessage());
Logger.error(e, aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForAggro");
}
}
@@ -702,7 +706,7 @@ public class MobAI {
}
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement");
}
}
@@ -746,7 +750,7 @@ public class MobAI {
ReSpawner.respawnQueue.put(aiAgent);
}
} catch (Exception e) {
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage());
Logger.error(e, aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn");
}
}
@@ -761,7 +765,7 @@ public class MobAI {
if (mob.getCombatTarget() == null)
return;
if (mob.getCombatTarget().getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && !MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) && !mob.agentType.equals(mbEnums.AIAgentType.PET)) {
if (mob.getCombatTarget().getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && !MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) && !mob.agentType.equals(mbEnums.AIAgentType.PET) && !mob.isSiege()) {
mob.setCombatTarget(null);
return;
@@ -769,7 +773,7 @@ public class MobAI {
attackTarget(mob, mob.getCombatTarget());
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack");
}
}
@@ -812,7 +816,7 @@ public class MobAI {
mob.playerAgroMap.replaceAll((e, v) -> 0f);
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome");
}
}
@@ -851,7 +855,7 @@ public class MobAI {
mob.updateMovementState();
mob.updateLocation();
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget");
}
}
@@ -877,13 +881,17 @@ public class MobAI {
if (aggroMob.agentType.equals(mbEnums.AIAgentType.PET))
continue;
//don't attack siege engines
if (aggroMob.isSiege())
continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
continue;
mob.setCombatTarget(aggroMob);
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: SafeGuardAggro");
}
}
@@ -913,7 +921,7 @@ public class MobAI {
checkForAttack(mob); //only check to attack if combat target is not null
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic");
}
}
@@ -946,7 +954,7 @@ public class MobAI {
mob.setHealth(mob.getHealthMax());
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic");
}
}
@@ -970,7 +978,7 @@ public class MobAI {
}
checkForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic");
}
}
@@ -1043,7 +1051,7 @@ public class MobAI {
checkForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic");
}
}
@@ -1099,25 +1107,11 @@ public class MobAI {
return;
}
}
if (mob.getCombatTarget() == null) {
//look for siege equipment to aggro if no players found to aggro
// guards never auto-aggro siege engines; they only respond when one damages a city building
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_SIEGE);
for (AbstractWorldObject awoMob : awoList) {
Mob aggroMob = (Mob) awoMob;
if (guardCanAggro(mob, aggroMob)) {
mob.setCombatTarget(aggroMob);
return;
}
}
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro" + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForPlayerGuardAggro");
}
}
@@ -1180,7 +1174,7 @@ public class MobAI {
}
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCanAggro");
}
return false;
}
@@ -1232,7 +1226,7 @@ public class MobAI {
}
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e);
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints");
}
}
@@ -1267,7 +1261,7 @@ public class MobAI {
}
return mostHatedTarget;
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated" + " " + e.getMessage());
Logger.error(e, mob.getObjectUUID() + " " + mob.getName() + " Failed At: ChangeTargetFromMostHated");
}
return null;
}
+8 -9
View File
@@ -12,8 +12,7 @@ package engine.net;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.util.ByteBufferUtils;
import java.time.Instant;
import java.time.ZoneId;
import org.joda.time.DateTime;
import java.nio.ByteBuffer;
import java.time.LocalDateTime;
@@ -58,13 +57,13 @@ public class ByteBufferWriter {
this.bb.putLong(x);
}
public synchronized void putDateTime(Instant dateTime) {
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalDate().getDayOfMonth());
this.put((byte) ((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalDate().getMonthValue() - 1));
this.putInt(dateTime.atZone(ZoneId.systemDefault()).toLocalDate().getYear() - 1900);
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalTime().getHour());
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalTime().getMinute());
this.put((byte) dateTime.atZone(ZoneId.systemDefault()).toLocalTime().getSecond());
public synchronized void putDateTime(DateTime dateTime) {
this.put((byte) dateTime.getDayOfMonth());
this.put((byte) ((byte) dateTime.getMonthOfYear() - 1));
this.putInt(dateTime.getYear() - 1900);
this.put((byte) dateTime.getHourOfDay());
this.put((byte) dateTime.getMinuteOfHour());
this.put((byte) dateTime.getSecondOfDay());
}
public synchronized void putLocalDateTime(LocalDateTime dateTime) {
+2 -2
View File
@@ -14,7 +14,7 @@ import engine.gameManager.ChatManager;
import engine.net.client.ClientConnection;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import java.time.Instant;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.lang.reflect.Constructor;
@@ -85,7 +85,7 @@ public class NetMsgFactory {
if (protocolMsg == Protocol.NONE) {
String errorString = Instant.now().toString() + origin.lastProtocol.name();
String errorString = DateTime.now().toString() + origin.lastProtocol.name();
int errorCode = errorString.hashCode();
@@ -22,7 +22,7 @@ import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.Guild;
import engine.objects.GuildHistory;
import engine.objects.PlayerCharacter;
import java.time.Instant;
import org.joda.time.DateTime;
public class AcceptInviteToGuildHandler extends AbstractClientMsgHandler {
@@ -90,8 +90,8 @@ public class AcceptInviteToGuildHandler extends AbstractClientMsgHandler {
//Add to guild History
if (player.getGuild() != null) {
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(player.getGuildUUID(), player, Instant.now(), GuildHistoryType.JOIN)) {
GuildHistory guildHistory = new GuildHistory(player.getGuildUUID(), player.getGuild().getName(), Instant.now(), GuildHistoryType.JOIN);
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(player.getGuildUUID(), player, DateTime.now(), GuildHistoryType.JOIN)) {
GuildHistory guildHistory = new GuildHistory(player.getGuildUUID(), player.getGuild().getName(), DateTime.now(), GuildHistoryType.JOIN);
player.getGuildHistory().add(guildHistory);
}
}
@@ -25,7 +25,7 @@ import engine.objects.Guild;
import engine.objects.GuildHistory;
import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter;
import java.time.Instant;
import org.joda.time.DateTime;
public class BanishUnbanishHandler extends AbstractClientMsgHandler {
@@ -95,8 +95,8 @@ public class BanishUnbanishHandler extends AbstractClientMsgHandler {
//Set guild history
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), toBanish, Instant.now(), GuildHistoryType.BANISHED)) {
GuildHistory guildHistory = new GuildHistory(toBanish.getGuildUUID(), toBanish.getGuild().getName(), Instant.now(), GuildHistoryType.BANISHED);
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), toBanish, DateTime.now(), GuildHistoryType.BANISHED)) {
GuildHistory guildHistory = new GuildHistory(toBanish.getGuildUUID(), toBanish.getGuild().getName(), DateTime.now(), GuildHistoryType.BANISHED);
toBanish.getGuildHistory().add(guildHistory);
}
}
@@ -15,7 +15,7 @@ import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.ManageCityAssetsMsg;
import engine.net.client.msg.PlaceAssetMsg;
import engine.objects.*;
import java.time.LocalDateTime;
import org.joda.time.DateTime;
/*
* @Author:
@@ -251,10 +251,11 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
return true;
}
LocalDateTime baneLive = bane.getPlacementDate();
DateTime baneLive = new DateTime(bane.getPlacementDate());
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2);
baneLive = baneHour == 24 ? baneLive.withHour(0) : baneLive.withHour(baneHour);
baneLive = baneLive.withMinute(0).withSecond(1).withNano(0);
baneLive = baneHour == 24 ? baneLive.hourOfDay().setCopy(0) : baneLive.hourOfDay().setCopy(baneHour);
baneLive = baneLive.minuteOfHour().setCopy(0);
baneLive = baneLive.secondOfMinute().setCopy(1);
bane.setLiveDate(baneLive);
outMsg.actionType = 18;
@@ -19,7 +19,7 @@ import engine.net.client.msg.PlaceAssetMsg;
import engine.net.client.msg.PlaceAssetMsg.PlacementInfo;
import engine.objects.*;
import engine.server.MBServerStatics;
import java.time.Instant;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
@@ -1142,7 +1142,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
Blueprint blueprint;
Building newMesh;
Instant completionDate;
DateTime completionDate;
float vendorRotation;
float buildingRotation;
@@ -1157,9 +1157,9 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if ((blueprint.getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|| (blueprint.getBuildingGroup().equals(BuildingGroup.BULWARK)))
completionDate = Instant.now().plusSeconds(15 * 60);
completionDate = DateTime.now().plusMinutes(15);
else
completionDate = Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600);
completionDate = DateTime.now().plusHours(blueprint.getRankTime(1));
Vector3fImmutable localLoc = new Vector3fImmutable(ZoneManager.worldToLocal(buildingInfo.getLoc(), currentZone));
@@ -1228,7 +1228,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
ArrayList<AbstractGameObject> shrineObjects = DbManager.ShrineQueries.CREATE_SHRINE(
currentZone.getObjectUUID(), player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.PROTECTED, 0, 0,
Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600), blueprint.getMeshForRank(0), vendorRotation, buildingRotation, shrineType.name());
DateTime.now().plusHours(blueprint.getRankTime(1)), blueprint.getMeshForRank(0), vendorRotation, buildingRotation, shrineType.name());
if (shrineObjects == null) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
@@ -1288,7 +1288,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
float buildingRotation = buildingInfo.getRot().y;
float vendorRotation = buildingInfo.getW();
Instant completionDate = Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600);
DateTime completionDate = DateTime.now().plusHours(blueprint.getRankTime(1));
newMesh = DbManager.BuildingQueries.CREATE_BUILDING(
@@ -1333,7 +1333,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
warehouseBuilding = DbManager.BuildingQueries.CREATE_BUILDING(
currentZone.getObjectUUID(), player.getObjectUUID(), blueprint.getName(), blueprint.getMeshForRank(0),
localLoc, 1.0f, blueprint.getMaxHealth(0), ProtectionState.NONE, 0, 0,
Instant.now().plusSeconds(blueprint.getRankTime(1) * 3600), blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
DateTime.now().plusHours(blueprint.getRankTime(1)), blueprint.getMeshForRank(0), vendorRotation, buildingRotation);
if (warehouseBuilding == null) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
@@ -17,8 +17,8 @@ import engine.net.Protocol;
import engine.objects.Building;
import engine.objects.Guild;
import engine.server.MBServerStatics;
import java.time.LocalDateTime;
import java.time.Duration;
import org.joda.time.DateTime;
import org.joda.time.Seconds;
public class ArcMineWindowAvailableTimeMsg extends ClientNetMsg {
@@ -26,8 +26,8 @@ public class ArcMineWindowAvailableTimeMsg extends ClientNetMsg {
private Building treeOfLife;
private int currentMineHour;
private Duration secondsLeft;
private LocalDateTime lateTime;
private Seconds secondsLeft;
private DateTime lateTime;
private int late;
/**
@@ -72,15 +72,15 @@ public class ArcMineWindowAvailableTimeMsg extends ClientNetMsg {
currentMineHour = guild.getMineTime();
late = MBServerStatics.MINE_LATE_WINDOW;
lateTime = LocalDateTime.now();
lateTime = DateTime.now();
if (late == 0)
lateTime = lateTime.plusDays(1);
lateTime = lateTime.withHour(late);
lateTime = lateTime.hourOfDay().setCopy(late);
late = ((late > 23) ? (late - 24) : late);
secondsLeft = Duration.between(LocalDateTime.now(), lateTime);
secondsLeft = Seconds.secondsBetween(DateTime.now(), lateTime);
}
/**
@@ -106,4 +106,4 @@ public class ArcMineWindowAvailableTimeMsg extends ClientNetMsg {
public void setBuildingUUID(int buildingUUID) {
this.buildingUUID = buildingUUID;
}
}
}
@@ -18,6 +18,9 @@ import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.Protocol;
import engine.objects.*;
import org.joda.time.DateTime;
import org.joda.time.Period;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Set;
@@ -394,33 +397,37 @@ public class ManageCityAssetsMsg extends ClientNetMsg {
else
writer.put((byte) 0);
LocalDateTime placedOn = bane.getLiveDate();
DateTime placedOn = bane.getLiveDate();
if (placedOn == null)
placedOn = LocalDateTime.now();
placedOn = new DateTime(DateTime.now());
//set Calander to date of bane live.
LocalDateTime now = LocalDateTime.now();
LocalDateTime defaultTime = bane.getPlacementDate();
LocalDateTime playerEnterWorldTime = LocalDateTime.ofInstant(java.time.Instant.ofEpochMilli(this.assetManager.getTimeStamp("EnterWorld")), ZoneId.systemDefault());
int hoursLoggedIn = (int) java.time.Duration.between(playerEnterWorldTime, now).toHours();
DateTime now = DateTime.now();
DateTime defaultTime = new DateTime(bane.getPlacementDate());
DateTime playerEnterWorldTime = new DateTime(this.assetManager.getTimeStamp("EnterWorld"));
Period period = new Period(playerEnterWorldTime.getMillis(), now.getMillis());
int hoursLoggedIn = period.getHours();
hoursLoggedIn = hoursLoggedIn < 0 ? 0 : hoursLoggedIn;
defaultTime = defaultTime.plusDays(2).withHour(22).withMinute(0).withSecond(0).withNano(0);
defaultTime = defaultTime.plusDays(2);
defaultTime = defaultTime.hourOfDay().setCopy(22);
defaultTime = defaultTime.minuteOfHour().setCopy(0);
defaultTime = defaultTime.secondOfMinute().setCopy(0);
long curTime = now.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long curTime = now.getMillis();
long timeLeft = 0;
if (bane.getLiveDate() != null)
timeLeft = bane.getLiveDate().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - curTime;
timeLeft = bane.getLiveDate().getMillis() - curTime;
else
timeLeft = defaultTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - curTime + 1000;
timeLeft = defaultTime.getMillis() - curTime + 1000;
//DO not touch these. They are static formula's until i get the correct converter for SB Time.
writer.put((byte) placedOn.getDayOfMonth());
writer.put((byte) placedOn.getMonthValue());
writer.putInt(placedOn.getYear() - 1900);
writer.put((byte) placedOn.dayOfMonth().get());
writer.put((byte) placedOn.monthOfYear().get());
writer.putInt(placedOn.year().get() - 1900);
writer.put((byte) 0);
writer.put((byte) 0);
writer.put((byte) 0);
+24 -20
View File
@@ -19,8 +19,9 @@ import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.Protocol;
import engine.objects.*;
import java.time.Duration;
import java.time.LocalDateTime;
import org.joda.time.DateTime;
import org.joda.time.Period;
import org.joda.time.Seconds;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
@@ -136,6 +137,7 @@ public class ManageNPCMsg extends ClientNetMsg {
@Override
protected void _serialize(ByteBufferWriter writer) {
Period upgradePeriod;
int upgradePeriodInSeconds;
try {
@@ -197,20 +199,21 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(npc.getUpgradeCost());
long upgradeTotalSecs = 0;
if (npc.isRanking() && npc.getUpgradeDateTime().isAfter(LocalDateTime.now()))
upgradeTotalSecs = Duration.between(LocalDateTime.now(), npc.getUpgradeDateTime()).getSeconds();
if (npc.isRanking() && npc.getUpgradeDateTime().isAfter(DateTime.now()))
upgradePeriod = new Period(DateTime.now(), npc.getUpgradeDateTime());
else
upgradePeriod = new Period(0);
writer.put((byte) (int) (upgradeTotalSecs / 86400)); //for timer
writer.put((byte) upgradePeriod.getDays()); //for timer
writer.put((byte) unknown26);//unknown
writer.putInt(100); //unknown
writer.put((byte) (int) ((upgradeTotalSecs % 86400) / 3600)); //for timer
writer.put((byte) (int) ((upgradeTotalSecs % 3600) / 60)); //for timer
writer.put((byte) (int) (upgradeTotalSecs % 60)); //for timer
writer.put((byte) upgradePeriod.getHours()); //for timer
writer.put((byte) upgradePeriod.getMinutes()); //for timer
writer.put((byte) upgradePeriod.getSeconds()); //for timer
if (npc.isRanking() && npc.getUpgradeDateTime().isAfter(LocalDateTime.now()))
upgradePeriodInSeconds = (int) upgradeTotalSecs;
if (npc.isRanking() && npc.getUpgradeDateTime().isAfter(DateTime.now()))
upgradePeriodInSeconds = Seconds.secondsBetween(DateTime.now(), npc.getUpgradeDateTime()).getSeconds();
else
upgradePeriodInSeconds = 0;
@@ -586,20 +589,21 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(Mob.getUpgradeCost(mobA));
long upgradeTotalSecs = 0;
if (mobA.isRanking() && mobA.getUpgradeDateTime().isAfter(LocalDateTime.now()))
upgradeTotalSecs = Duration.between(LocalDateTime.now(), mobA.getUpgradeDateTime()).getSeconds();
if (mobA.isRanking() && mobA.getUpgradeDateTime().isAfter(DateTime.now()))
upgradePeriod = new Period(DateTime.now(), mobA.getUpgradeDateTime());
else
upgradePeriod = new Period(0);
writer.put((byte) (int) (upgradeTotalSecs / 86400)); //for timer
writer.put((byte) upgradePeriod.getDays()); //for timer
writer.put((byte) unknown26);//unknown
writer.putInt(100); //unknown
writer.put((byte) (int) ((upgradeTotalSecs % 86400) / 3600)); //for timer
writer.put((byte) (int) ((upgradeTotalSecs % 3600) / 60)); //for timer
writer.put((byte) (int) (upgradeTotalSecs % 60)); //for timer
writer.put((byte) upgradePeriod.getHours()); //for timer
writer.put((byte) upgradePeriod.getMinutes()); //for timer
writer.put((byte) upgradePeriod.getSeconds()); //for timer
if (mobA.isRanking() && mobA.getUpgradeDateTime().isAfter(LocalDateTime.now()))
upgradePeriodInSeconds = (int) upgradeTotalSecs;
if (mobA.isRanking() && mobA.getUpgradeDateTime().isAfter(DateTime.now()))
upgradePeriodInSeconds = Seconds.secondsBetween(DateTime.now(), mobA.getUpgradeDateTime()).getSeconds();
else
upgradePeriodInSeconds = 0;
@@ -17,7 +17,7 @@ import engine.net.ByteBufferWriter;
import engine.net.Protocol;
import engine.net.client.msg.ClientNetMsg;
import engine.objects.*;
import java.time.Instant;
import org.joda.time.DateTime;
public class GuildInfoMsg extends ClientNetMsg {
@@ -306,7 +306,7 @@ class GuildInfoMessageType4 extends GuildInfoMessageType {
writer.putString(guildLeaderName);
writer.putString(pc.getName());
writer.putDateTime(Instant.now());
writer.putDateTime(DateTime.now());
writer.put((byte) 1);
writer.put((byte) 1);
writer.put((byte) 1);
@@ -401,7 +401,7 @@ class GuildInfoMessageType5 extends GuildInfoMessageType {
writer.putString("Guild Leader");
writer.putString(""); //Nation Leader - I believe
Instant now = Instant.now();
DateTime now = DateTime.now();
writer.putDateTime(now);
writer.put((byte) 1);
+90 -10
View File
@@ -656,12 +656,30 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
AssignDamageAtrForPlayers(abstractCharacter, equipped.get(EquipSlotType.LHELD), false, equipped.get(EquipSlotType.LHELD));
if (abstractCharacter.getObjectType().equals(GameObjectType.Mob)) {
Mob mob = (Mob) abstractCharacter;
abstractCharacter.minDamageHandOne = (int) mob.mobBase.getDamageMin();
abstractCharacter.minDamageHandTwo = (int) mob.mobBase.getDamageMin();
abstractCharacter.maxDamageHandOne = (int) mob.mobBase.getDamageMax();
abstractCharacter.maxDamageHandTwo = (int) mob.mobBase.getDamageMax();
abstractCharacter.atrHandOne = mob.mobBase.getAttackRating();
abstractCharacter.atrHandTwo = mob.mobBase.getAttackRating();
ItemTemplate rune = ItemTemplate.templates.get(mob.loadID);
float minDamage = mob.mobBase.getDamageMin();
float maxDamage = mob.mobBase.getDamageMax();
int attackRating = mob.mobBase.getAttackRating();
// The client (ArcMobile, 0x46D200) takes mob damage straight from the rune MINDAMAGE/MAXDAMAGE,
// with no stat scaling. Use the rune when it has damage, otherwise keep the mobbase value.
if (rune != null && rune.rune_max_damage > 0) {
minDamage = rune.rune_min_damage;
maxDamage = rune.rune_max_damage;
}
// Likewise ATR comes straight from the rune ATTACK for mobiles (0x466570).
if (rune != null && rune.rune_attack > 0)
attackRating = rune.rune_attack;
abstractCharacter.minDamageHandOne = (int) minDamage;
abstractCharacter.minDamageHandTwo = (int) minDamage;
abstractCharacter.maxDamageHandOne = (int) maxDamage;
abstractCharacter.maxDamageHandTwo = (int) maxDamage;
abstractCharacter.atrHandOne = attackRating;
abstractCharacter.atrHandTwo = attackRating;
abstractCharacter.defenseRating = mob.mobBase.getDefenseRating();
}
}
@@ -717,9 +735,18 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
mastDam = CharacterSkill.getQuickMastery(abstractCharacter, "Unarmed Combat Mastery");
else
mastDam = masteryPercentage;
// TODO Correct these
min = 1;
max = 3;
// Base fist damage from the race rune natural attack (1-4 for all races), scaled below like a weapon.
// Matches the client's unarmed damage calc (0x46D200).
float[] naturalAttack = CombatManager.getNaturalAttack(abstractCharacter, mainHand ? EquipSlotType.RHELD : EquipSlotType.LHELD);
if (naturalAttack != null && naturalAttack.length > 9) {
min = (int) naturalAttack[8];
max = (int) naturalAttack[9];
} else {
min = 1;
max = 3;
}
} else {
if (mainHand)
@@ -1476,13 +1503,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
Mob mob = (Mob) this;
if (mob.isSiege()) {
return 300;
return CombatManager.getSiegeRange(mob);
}
float range = 8;
if ((this).charItemManager.equipped.get(EquipSlotType.RHELD) != null) {
range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.RHELD).template.item_weapon_max_range;
} else if (((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD) != null) {
range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD).template.item_weapon_max_range;
} else {
// Unarmed: use the rune natural attack range when it has one (e.g. Gasser 150), not clamped.
// Most melee runes have 0, so they keep the default of 8.
float naturalRange = CombatManager.getNaturalAttackRange(mob, EquipSlotType.RHELD);
if (naturalRange > 0)
return naturalRange;
}
// TODO Is this clamp from live?
@@ -1827,6 +1863,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if (this.getObjectType().equals(GameObjectType.Mob)) {
//handle hate value addition
Mob target = (Mob) this;
// Siege engines switch to whoever damages them, players and pets alike.
// Misses and non-damaging powers do not pull them.
if (target.isSiege() && value < 0f && attacker != null && !attacker.equals(target)) {
target.setCombatTarget(attacker);
flagSiegeAttackerHostile(target, attacker);
}
if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if (target.playerAgroMap.containsKey(attacker.getObjectUUID()))
@@ -1860,6 +1905,41 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
return 0;
}
private static void flagSiegeAttackerHostile(Mob siegeEngine, AbstractCharacter attacker) {
// Damaging a siege engine on a city grid flags the player hostile to that
// city, unless they belong to the city's nation or an allied nation.
// Pets flag their owner.
City city;
AbstractCharacter flagged;
Guild cityNation;
city = ZoneManager.getCityAtLocation(siegeEngine.loc);
if (city == null)
return;
flagged = attacker;
if (attacker.getObjectType().equals(GameObjectType.Mob))
flagged = ((Mob) attacker).guardCaptain;
if (flagged == null || !flagged.getObjectType().equals(GameObjectType.PlayerCharacter))
return;
cityNation = city.getGuild().getNation();
if (flagged.getGuild().getNation().equals(cityNation))
return;
if (cityNation.getAllyList().contains(flagged.getGuild().getNation()))
return;
if (!city.cityOutlaws.contains(flagged.getObjectUUID()))
city.cityOutlaws.add(flagged.getObjectUUID());
}
public float getCurrentHitpoints() {
return this.health.get();
}
@@ -148,9 +148,20 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
public void dismiss() {
boolean isSiegeEngine;
isSiegeEngine = this.getObjectType() == GameObjectType.Mob && ((Mob) this).isSiege();
if (this.isPet()) {
if ((this.agentType.equals(mbEnums.AIAgentType.PET))) { //delete summoned pet
if (isSiegeEngine) {
// Released siege engines stay in place, alive, and keep firing at
// their current target until a Rod of Command takes them again.
this.agentType = mbEnums.AIAgentType.MOBILE;
} else if ((this.agentType.equals(mbEnums.AIAgentType.PET))) { //delete summoned pet
WorldGrid.RemoveWorldObject(this);
@@ -167,7 +178,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
// clear owner and set not alive
this.isAlive.set(false);
if (!isSiegeEngine)
this.isAlive.set(false);
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
@@ -188,6 +200,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
this.guardCaptain = null;
}
if (isSiegeEngine && this.isAlive())
WorldGrid.updateObject(this);
}
}
+22 -18
View File
@@ -25,8 +25,7 @@ import engine.net.client.ClientConnection;
import engine.net.client.msg.PlaceAssetMsg;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.server.MBServerStatics;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@@ -41,8 +40,8 @@ public final class Bane {
private final int cityUUID;
private final int stoneUUID;
private int ownerUUID;
private LocalDateTime placementDate = null;
private LocalDateTime liveDate = null;
private DateTime placementDate = null;
private DateTime liveDate = null;
private BaneDefaultTimeJob defaultTimeJob;
// Internal cache for banes
@@ -63,12 +62,12 @@ public final class Bane {
sqlDateTime = rs.getTimestamp("placementDate");
if (sqlDateTime != null)
this.placementDate = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
this.placementDate = new DateTime(sqlDateTime);
sqlDateTime = rs.getTimestamp("liveDate");
if (sqlDateTime != null)
this.liveDate = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
this.liveDate = new DateTime(sqlDateTime);
switch (this.getSiegePhase()) {
@@ -82,7 +81,7 @@ public final class Bane {
this.activateBaneJob.cancelJob();
abtj = new ActivateBaneJob(cityUUID);
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.getMillis());
this.activateBaneJob = abtj;
break;
@@ -94,7 +93,7 @@ public final class Bane {
this.activateBaneJob.cancelJob();
abtj = new ActivateBaneJob(cityUUID);
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.getMillis());
this.activateBaneJob = abtj;
break;
@@ -354,7 +353,7 @@ public final class Bane {
return phase;
}
if (LocalDateTime.now().isAfter(this.liveDate)) {
if (DateTime.now().isAfter(this.liveDate)) {
phase = SiegePhase.WAR; //war
return phase;
}
@@ -369,10 +368,15 @@ public final class Bane {
private void setDefaultTime() {
LocalDateTime timeToSetDefault = this.placementDate.plusDays(1);
DateTime timeToSetDefault = new DateTime(this.placementDate);
timeToSetDefault = timeToSetDefault.plusDays(1);
LocalDateTime currentTime = LocalDateTime.now();
LocalDateTime defaultTime = this.placementDate.plusDays(2).withHour(22).withMinute(0).withSecond(0);
DateTime currentTime = DateTime.now();
DateTime defaultTime = new DateTime(this.placementDate);
defaultTime = defaultTime.plusDays(2);
defaultTime = defaultTime.hourOfDay().setCopy(22);
defaultTime = defaultTime.minuteOfHour().setCopy(0);
defaultTime = defaultTime.secondOfMinute().setCopy(0);
if (currentTime.isAfter(timeToSetDefault))
this.setLiveDate(defaultTime);
@@ -382,7 +386,7 @@ public final class Bane {
this.defaultTimeJob.cancelJob();
BaneDefaultTimeJob bdtj = new BaneDefaultTimeJob(this);
JobScheduler.getInstance().scheduleJob(bdtj, timeToSetDefault.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
JobScheduler.getInstance().scheduleJob(bdtj, timeToSetDefault.getMillis());
this.defaultTimeJob = bdtj;
}
}
@@ -449,7 +453,7 @@ public final class Bane {
return true;
}
public final LocalDateTime getPlacementDate() {
public final DateTime getPlacementDate() {
return placementDate;
}
@@ -458,14 +462,14 @@ public final class Bane {
return (this.getSiegePhase() != SiegePhase.CHALLENGE);
}
public final LocalDateTime getLiveDate() {
public final DateTime getLiveDate() {
return liveDate;
}
public void setLiveDate(LocalDateTime baneTime) {
public void setLiveDate(DateTime baneTime) {
if (DbManager.BaneQueries.SET_BANE_TIME(baneTime, this.getCity().getObjectUUID())) {
this.liveDate = baneTime;
this.liveDate = new DateTime(baneTime);
// Push event to warehouse
@@ -507,7 +511,7 @@ public final class Bane {
ActivateBaneJob abtj = new ActivateBaneJob(cityUUID);
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
JobScheduler.getInstance().scheduleJob(abtj, this.liveDate.getMillis());
this.activateBaneJob = abtj;
} else {
Logger.debug("error with city " + this.getCity().getName());
+3 -1
View File
@@ -395,8 +395,10 @@ public class Building extends AbstractWorldObject {
//friendly building has been attacked, add attacker to city outlaw list
if (!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
playerCity.cityOutlaws.add(attacker.getObjectUUID());
//only city guards respond; siege engines and pets in the zone are left alone
for (Mob guard : playerCity.getParent().zoneMobSet)
if (guard.combatTarget == null)
if (guard.isPlayerGuard() && guard.combatTarget == null)
guard.setCombatTarget(attacker);
}
}
+3 -3
View File
@@ -22,7 +22,7 @@ import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.UpdateClientAlliancesMsg;
import engine.net.client.msg.guild.GuildInfoMsg;
import engine.server.world.WorldServer;
import java.time.Instant;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@@ -612,8 +612,8 @@ public class Guild extends AbstractWorldObject {
//Add to Guild History
if (pc.getGuild() != null) {
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, Instant.now(), historyType)) {
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name, Instant.now(), historyType);
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, DateTime.now(), historyType)) {
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name, DateTime.now(), historyType);
pc.getGuildHistory().add(guildHistory);
}
}
+7 -8
View File
@@ -13,11 +13,10 @@ package engine.objects;
import engine.mbEnums.GameObjectType;
import engine.mbEnums.GuildHistoryType;
import engine.net.ByteBufferWriter;
import org.joda.time.DateTime;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
public class GuildHistory {
@@ -25,12 +24,12 @@ public class GuildHistory {
private int guildID;
private String guildName;
private Instant time;
private DateTime time;
private GuildHistoryType historyType;
public GuildHistory(int guildID, String guildName,
Instant dateTime, GuildHistoryType historyType) {
DateTime dateTime, GuildHistoryType historyType) {
super();
this.guildID = guildID;
this.guildName = guildName;
@@ -50,9 +49,9 @@ public class GuildHistory {
sqlDateTime = rs.getTimestamp("historyDate");
if (sqlDateTime != null)
this.time = sqlDateTime.toInstant();
this.time = new DateTime(sqlDateTime);
else
this.time = Instant.now().minus(1, ChronoUnit.YEARS);
this.time = DateTime.now().minusYears(1);
this.historyType = GuildHistoryType.valueOf(rs.getString("historyType"));
}
@@ -78,11 +77,11 @@ public class GuildHistory {
writer.putDateTime(this.time);
}
public Instant getTime() {
public DateTime getTime() {
return time;
}
public void setTime(Instant time) {
public void setTime(DateTime time) {
this.time = time;
}
+20
View File
@@ -138,6 +138,11 @@ public class ItemTemplate {
public final EnumSet<mbEnums.MobBehaviourType> rune_group_role_set = EnumSet.noneOf(mbEnums.MobBehaviourType.class);
public boolean rune_renderable = false;
public int rune_natural_power_attack;
// One float[] per rune_naturalattacks entry. Same "attack info" struct as a weapon (verified in IDA, see
// MBDATA/docs/client-map.md): [0] attack speed (WEPSPEED), [1] range (MAXRANGE), [2] unknown int,
// [3] equip slot (1 = RHELD, 2 = LHELD), [4] projectile template id, [5] projectile speed, [6] swing anim,
// [7] damage type, [8] min damage, [9] max damage
public final ArrayList<float[]> rune_natural_attacks = new ArrayList<>();
public final HashMap<String, String> rune_sparse_data = new HashMap<>();
public final HashMap<String, int[]> rune_skill_adj = new HashMap<>();
public final EnumSet<mbEnums.MonsterType> rune_enemy_monster_types = EnumSet.noneOf(mbEnums.MonsterType.class);
@@ -554,6 +559,21 @@ public class ItemTemplate {
rune_renderable = jsonObject.getBoolean("rune_renderable");
rune_natural_power_attack = jsonObject.getInt("rune_natural_power_attack");
if (jsonObject.has("rune_naturalattacks")) {
JSONArray natural_attacks_json = jsonObject.getJSONArray("rune_naturalattacks");
for (Object attackEntry : natural_attacks_json) {
JSONArray attackArray = (JSONArray) attackEntry;
float[] attack = new float[attackArray.length()];
for (int i = 0; i < attackArray.length(); i++)
attack[i] = attackArray.getFloat(i);
rune_natural_attacks.add(attack);
}
}
JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data");
for (String sparseType : rune_sparse_json.keySet()) {
+19 -9
View File
@@ -24,8 +24,7 @@ import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg;
import engine.server.MBServerStatics;
import org.jetbrains.annotations.NotNull;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@@ -72,7 +71,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
public long nextAttackTime = System.currentTimeMillis();
private int lastMobPowerToken = 0;
private DeferredPowerJob weaponPower;
private LocalDateTime upgradeDateTime = null;
private DateTime upgradeDateTime = null;
private boolean lootSync = false;
// New Mobile constructor. Fill in the blanks and then call
@@ -127,7 +126,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
sqlDateTime = rs.getTimestamp("upgradeDate");
if (sqlDateTime != null)
upgradeDateTime = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
upgradeDateTime = new DateTime(sqlDateTime);
else
upgradeDateTime = null;
@@ -553,6 +552,12 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
petMinion.despawned = false;
petMinion.runAfterLoad();
// Summoned pets carry MASK_PET. Necro pets keep their own NecroPet handling.
if (!petMinion.isNecroPet())
petMinion.setObjectTypeMask(petMinion.getObjectTypeMask() | MBServerStatics.MASK_PET);
DbManager.addToCache(petMinion);
petMinion.setLoc(petMinion.bindLoc);
@@ -594,8 +599,8 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
// Submit upgrade job for future date or current instant
if (mob.getUpgradeDateTime().isAfter(LocalDateTime.now()))
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), mob.getUpgradeDateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
if (mob.getUpgradeDateTime().isAfter(DateTime.now()))
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), mob.getUpgradeDateTime().getMillis());
else
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(mob), 0);
@@ -621,7 +626,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
return upgradeCost;
}
public static void setUpgradeDateTime(Mob mob, LocalDateTime upgradeDateTime) {
public static void setUpgradeDateTime(Mob mob, DateTime upgradeDateTime) {
if (!DbManager.MobQueries.updateUpgradeTime(mob, upgradeDateTime)) {
Logger.error("Failed to set upgradeTime for building " + mob.currentID);
@@ -1319,6 +1324,11 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
if (!ac.getObjectType().equals(GameObjectType.PlayerCharacter))
return;
// siege engines only switch targets on damage, see AbstractCharacter.modifyHealth
if (this.isSiege())
return;
if (this.getCombatTarget() == null)
this.setCombatTarget(ac);
@@ -1354,7 +1364,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
this.weaponPower = weaponPower;
}
public LocalDateTime getUpgradeDateTime() {
public DateTime getUpgradeDateTime() {
lock.readLock().lock();
@@ -1434,7 +1444,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
if (!building.transferGold(-rankCost, false))
return;
LocalDateTime dateToUpgrade = LocalDateTime.now().plusHours(Mob.getUpgradeTime(this));
DateTime dateToUpgrade = DateTime.now().plusHours(Mob.getUpgradeTime(this));
Mob.setUpgradeDateTime(this, dateToUpgrade);
// Schedule upgrade job
+9 -10
View File
@@ -24,8 +24,7 @@ import engine.net.Dispatch;
import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg;
import engine.server.MBServerStatics;
import java.time.LocalDateTime;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@@ -68,7 +67,7 @@ public class NPC extends AbstractCharacter {
protected int symbol;
// Variables NOT to be stored in db
protected boolean isStatic = false;
private LocalDateTime upgradeDateTime = null;
private DateTime upgradeDateTime = null;
private HashSet<Integer> canRoll = null;
public int parentZoneUUID;
public int equipmentSetID = 0;
@@ -132,7 +131,7 @@ public class NPC extends AbstractCharacter {
sqlDateTime = rs.getTimestamp("upgradeDate");
if (sqlDateTime != null)
upgradeDateTime = LocalDateTime.ofInstant(sqlDateTime.toInstant(), ZoneId.systemDefault());
upgradeDateTime = new DateTime(sqlDateTime);
else
upgradeDateTime = null;
@@ -528,9 +527,9 @@ public class NPC extends AbstractCharacter {
// Submit upgrade job for future date or current instant
if (this.getUpgradeDateTime().isAfter(LocalDateTime.now()))
if (this.getUpgradeDateTime().isAfter(DateTime.now()))
jc = JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(this),
this.getUpgradeDateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
this.getUpgradeDateTime().getMillis());
else
JobScheduler.getInstance().scheduleJob(new UpgradeNPCJob(this), 0);
@@ -908,7 +907,7 @@ public class NPC extends AbstractCharacter {
return new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
}
public LocalDateTime getUpgradeDateTime() {
public DateTime getUpgradeDateTime() {
lock.readLock().lock();
try {
return upgradeDateTime;
@@ -917,7 +916,7 @@ public class NPC extends AbstractCharacter {
}
}
public void setUpgradeDateTime(LocalDateTime upgradeDateTime) {
public void setUpgradeDateTime(DateTime upgradeDateTime) {
if (!DbManager.NPCQueries.updateUpgradeTime(this, upgradeDateTime)) {
Logger.error("Failed to set upgradeTime for building " + currentID);
@@ -1060,7 +1059,7 @@ public class NPC extends AbstractCharacter {
int rankCost;
Building building;
LocalDateTime dateToUpgrade;
DateTime dateToUpgrade;
this.lock.writeLock().lock();
@@ -1103,7 +1102,7 @@ public class NPC extends AbstractCharacter {
if (!building.transferGold(-rankCost, false))
return;
dateToUpgrade = LocalDateTime.now().plusHours(this.getUpgradeTime());
dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime());
this.setUpgradeDateTime(dateToUpgrade);
+6 -7
View File
@@ -37,8 +37,7 @@ import engine.server.MBServerStatics;
import engine.server.login.LoginServer;
import engine.server.world.WorldServer;
import engine.util.MiscUtils;
import java.time.Instant;
import java.time.ZoneId;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
@@ -703,11 +702,11 @@ public class PlayerCharacter extends AbstractCharacter {
writer.putInt(token);
writer.putInt((int) timeLeft / 1000);
}
Instant enterWorld = Instant.ofEpochMilli(playerCharacter.timestamps.get("EnterWorld"));
DateTime enterWorld = new DateTime(playerCharacter.timestamps.get("EnterWorld"));
writer.putDateTime(enterWorld);
writer.putInt(0x49EF1E98); //DUnno what playerCharacter is.
writer.putFloat(Instant.now().atZone(ZoneId.systemDefault()).toLocalTime().getHour()); //daylight in float.
writer.putFloat(DateTime.now().hourOfDay().get()); //daylight in float.
writer.putFloat(6); //interval of light to change per game hour //float
//writer.putInt(1637194901); //playerCharacter is actually an opcode taht is in recordings, no clue what it is, dumped it and it changes nothing
} else {
@@ -4185,8 +4184,9 @@ public class PlayerCharacter extends AbstractCharacter {
} else if (currentPet.isSiege()) {
currentPet.agentType = AIAgentType.MOBILE;
// released siege engine keeps its current target
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
WorldGrid.updateObject(currentPet);
}
@@ -4194,7 +4194,6 @@ public class PlayerCharacter extends AbstractCharacter {
toCommand.setPet(this, false);
this.setPet(toCommand);
toCommand.setCombatTarget(null);
PetMsg petMsg = new PetMsg(6, toCommand);
Dispatch dispatch = Dispatch.borrow(this, petMsg);
DispatchManager.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
@@ -4365,7 +4364,7 @@ public class PlayerCharacter extends AbstractCharacter {
}
if (count > 0) {
this.timestamps.put("RealmClaim", Instant.now().plusSeconds(180).toEpochMilli());
this.timestamps.put("RealmClaim", DateTime.now().plusMinutes(3).getMillis());
for (PlayerCharacter toSend : SessionManager.getAllActivePlayerCharacters()) {
ChatManager.chatSystemInfo(toSend, this.getCombinedName() + " is seeking to claim a realm and already has " + count + " blessngs!");
}
+6 -6
View File
@@ -12,7 +12,7 @@ package engine.objects;
import engine.mbEnums;
import engine.mbEnums.GameObjectType;
import engine.mbEnums.TransactionType;
import java.time.Instant;
import org.joda.time.DateTime;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -24,7 +24,7 @@ public class Transaction implements Comparable<Transaction> {
private final int warehouseUUID;
private final int targetUUID;
private final mbEnums.ResourceType resource;
private final Instant date;
private final DateTime date;
private final int amount;
private final TransactionType transactionType;
private GameObjectType targetType;
@@ -41,15 +41,15 @@ public class Transaction implements Comparable<Transaction> {
Date sqlDateTime = rs.getTimestamp("date");
if (sqlDateTime != null)
this.date = sqlDateTime.toInstant();
this.date = new DateTime(sqlDateTime);
else
this.date = Instant.now();
this.date = DateTime.now();
}
public Transaction(int warehouseUUID, GameObjectType targetType, int targetUUID, TransactionType transactionType, mbEnums.ResourceType resource, int amount,
Instant date) {
DateTime date) {
this.warehouseUUID = warehouseUUID;
this.targetUUID = targetUUID;
this.resource = resource;
@@ -75,7 +75,7 @@ public class Transaction implements Comparable<Transaction> {
}
public Instant getDate() {
public DateTime getDate() {
return date;
}
+3 -3
View File
@@ -18,7 +18,7 @@ import engine.net.Dispatch;
import engine.net.client.ClientConnection;
import engine.net.client.msg.*;
import engine.server.MBServerStatics;
import java.time.Instant;
import org.joda.time.DateTime;
import org.json.JSONArray;
import org.json.JSONObject;
import org.pmw.tinylog.Logger;
@@ -576,10 +576,10 @@ public class Warehouse {
public static void AddTransactionToWarehouse(Warehouse warehouse, mbEnums.GameObjectType targetType, int targetUUID, mbEnums.TransactionType transactionType, mbEnums.ResourceType resource, int amount) {
if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, Instant.now()))
if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now()))
return;
Transaction transaction = new Transaction(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, Instant.now());
Transaction transaction = new Transaction(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now());
warehouse.transactions.add(transaction);
}
@@ -246,7 +246,9 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
if (this.effectID.equals("TAUNT")) {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
// siege engines only switch targets on damage, see AbstractCharacter.modifyHealth
if (awo != null && awo.getObjectType() == GameObjectType.Mob && !((Mob) awo).isSiege()) {
((Mob) awo).setCombatTarget(source);
ChatSystemMsg msg = ChatManager.CombatInfo(source, awo);
DispatchManager.sendToAllInRange(source, msg);
+2 -1
View File
@@ -18,6 +18,7 @@ import engine.net.MessageDispatcher;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.*;
import engine.server.world.WorldServer;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
@@ -291,7 +292,7 @@ public class HourlyJobThread implements Runnable {
public static void processBanes() {
//handle banes
for (Bane bane : Bane.banes.values()) {
if (bane.getLiveDate() != null && LocalDateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false)
if (bane.getLiveDate() != null && DateTime.now().isAfter(bane.getLiveDate().minusMinutes(1)) && bane.isStarted == false)
bane.startBane();
}
}