Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a0e8782af | |||
| 63fa98486b | |||
| 2ca54f3cfa | |||
| dad615db2b | |||
| 134838072d | |||
| 6484e7eb93 | |||
| 32d71d72d1 | |||
| db015f7007 | |||
| a0066bce20 | |||
| 8c2adb760c | |||
| 8aca1a1810 | |||
| 2d4a604709 | |||
| 7b3741fc60 | |||
| 903470e7ae | |||
| 0e190b21e1 | |||
| b6be8815a3 | |||
| d8235954d2 | |||
| 37ca8c90e2 | |||
| b70a076cb2 |
@@ -0,0 +1,67 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.gameManager;
|
||||||
|
|
||||||
|
import engine.loot.WorkOrder;
|
||||||
|
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.DelayQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public enum ForgeManager implements Runnable {
|
||||||
|
|
||||||
|
FORGE_MANAGER;
|
||||||
|
|
||||||
|
private final BlockingQueue<WorkOrder> workQueue = new DelayQueue();
|
||||||
|
public static final AtomicInteger workOrder = new AtomicInteger(0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
WorkOrder workOrder = workQueue.take();
|
||||||
|
|
||||||
|
// Fulfill workOrder
|
||||||
|
|
||||||
|
for (int i = 0; i < workOrder.slotCount; ++i) {
|
||||||
|
|
||||||
|
// Create workOrder items; one for each slot
|
||||||
|
// assigned to this workOrder.
|
||||||
|
|
||||||
|
// if Prefix and suffix are null random roll item
|
||||||
|
// otherwise roll what was asked for
|
||||||
|
|
||||||
|
workOrder.itemCount = workOrder.itemCount - 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workOrder.itemCount == 0) {
|
||||||
|
|
||||||
|
workOrder.runCompleted = true;
|
||||||
|
|
||||||
|
// Remove this workOrder from any slots on vendor
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resubmit workOrder
|
||||||
|
|
||||||
|
workOrder.completionTime = System.currentTimeMillis() + 10000;
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.loot;
|
||||||
|
|
||||||
|
import engine.gameManager.ForgeManager;
|
||||||
|
import engine.objects.NPC;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.Delayed;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static java.lang.Math.toIntExact;
|
||||||
|
|
||||||
|
public class WorkOrder implements Delayed {
|
||||||
|
|
||||||
|
public int workOrder;
|
||||||
|
public NPC vendor;
|
||||||
|
public int slotCount;
|
||||||
|
public int itemCount;
|
||||||
|
public int itemBase;
|
||||||
|
public String itemName;
|
||||||
|
public int prefixToken;
|
||||||
|
public int suffixToken;
|
||||||
|
public boolean isRandom;
|
||||||
|
public long completionTime;
|
||||||
|
public boolean runCompleted;
|
||||||
|
|
||||||
|
public WorkOrder() {
|
||||||
|
|
||||||
|
this.workOrder = ForgeManager.workOrder.incrementAndGet();
|
||||||
|
this.completionTime = System.currentTimeMillis() + 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDelay(TimeUnit unit) {
|
||||||
|
|
||||||
|
long timeRemaining = completionTime - System.currentTimeMillis();
|
||||||
|
return unit.convert(timeRemaining, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull Delayed o) {
|
||||||
|
return toIntExact(this.completionTime - ((WorkOrder) o).completionTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -814,8 +814,8 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnDelay * 1000))) {
|
} else if (System.currentTimeMillis() > aiAgent.deathTime + (aiAgent.spawnDelay * 1000L)) {
|
||||||
aiAgent.respawnTime = aiAgent.deathTime + (aiAgent.spawnDelay * 1000);
|
aiAgent.respawnTime = aiAgent.deathTime + (aiAgent.spawnDelay * 1000L);
|
||||||
Respawner.respawnQueue.put(aiAgent);
|
Respawner.respawnQueue.put(aiAgent);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
package engine.mobileAI.Threads;
|
package engine.mobileAI.Threads;
|
||||||
|
|
||||||
import engine.gameManager.ConfigManager;
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.mobileAI.MobAI;
|
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
|
import engine.mobileAI.MobAI;
|
||||||
import engine.objects.Mob;
|
import engine.objects.Mob;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import engine.server.MBServerStatics;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
public class MobAIThread implements Runnable{
|
public class MobAIThread implements Runnable{
|
||||||
@@ -14,23 +21,27 @@ public class MobAIThread implements Runnable{
|
|||||||
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
public static int AI_PULSE_MOB_THRESHOLD = 200;
|
||||||
public static int AI_PATROL_DIVISOR = 15;
|
public static int AI_PATROL_DIVISOR = 15;
|
||||||
public static float AI_CAST_FREQUENCY;
|
public static float AI_CAST_FREQUENCY;
|
||||||
|
|
||||||
// Thread constructor
|
// Thread constructor
|
||||||
|
|
||||||
public MobAIThread() {
|
public MobAIThread() {
|
||||||
Logger.info(" MobAIThread thread has started!");
|
|
||||||
|
//cache config value for mobile casting delay
|
||||||
|
|
||||||
|
AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue());
|
||||||
|
AI_BASE_AGGRO_RANGE = (int) (60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//cache config value for mobile casting delay
|
|
||||||
AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue());
|
Logger.info(" MobAIThread thread has started!");
|
||||||
AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
|
|
||||||
while (true) {
|
while (true) {
|
||||||
for (Zone zone : ZoneManager.getAllZones()) {
|
|
||||||
|
|
||||||
for (Mob mob : zone.zoneMobSet) {
|
|
||||||
|
|
||||||
|
for (Zone zone : ZoneManager.getAllZones())
|
||||||
|
for (Mob mob : zone.zoneMobSet)
|
||||||
try {
|
try {
|
||||||
if (mob != null)
|
if (mob != null)
|
||||||
MobAI.DetermineAction(mob);
|
MobAI.DetermineAction(mob);
|
||||||
@@ -39,9 +50,9 @@ public class MobAIThread implements Runnable{
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void startAIThread() {
|
public static void startAIThread() {
|
||||||
Thread aiThread;
|
Thread aiThread;
|
||||||
aiThread = new Thread(new MobAIThread());
|
aiThread = new Thread(new MobAIThread());
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import engine.Enum.ItemType;
|
|||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.loot.WorkOrder;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
@@ -455,9 +456,18 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
|||||||
switch (msg.getActionType()) {
|
switch (msg.getActionType()) {
|
||||||
|
|
||||||
case ACTION_PRODUCE:
|
case ACTION_PRODUCE:
|
||||||
boolean isRandom = false;
|
|
||||||
if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0)
|
boolean isRandom = msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0;
|
||||||
isRandom = true;
|
|
||||||
|
WorkOrder workOrder = new WorkOrder();
|
||||||
|
workOrder.vendor = vendorNPC;
|
||||||
|
workOrder.isRandom = isRandom;
|
||||||
|
workOrder.itemBase = msg.getItemUUID();
|
||||||
|
workOrder.itemCount = msg.getTotalProduction();
|
||||||
|
workOrder.prefixToken = msg.getpToken();
|
||||||
|
workOrder.suffixToken = msg.getsToken();
|
||||||
|
workOrder.itemName = msg.getName();
|
||||||
|
|
||||||
//Create Multiple Item Function.. Fill all empty slots
|
//Create Multiple Item Function.. Fill all empty slots
|
||||||
if (msg.isMultiple()) {
|
if (msg.isMultiple()) {
|
||||||
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size();
|
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size();
|
||||||
|
|||||||
@@ -287,30 +287,7 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
public final City getCity() {
|
public final City getCity() {
|
||||||
|
|
||||||
if (this.parentZone == null)
|
return ZoneManager.getCityAtLocation(this.getLoc());
|
||||||
return null;
|
|
||||||
|
|
||||||
if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)) {
|
|
||||||
if (this.getGuild() != null) {
|
|
||||||
if (this.getGuild().getOwnedCity() != null) {
|
|
||||||
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.halfExtents))
|
|
||||||
return this.getGuild().getOwnedCity();
|
|
||||||
} else {
|
|
||||||
Bane bane = Bane.getBaneByAttackerGuild(this.getGuild());
|
|
||||||
|
|
||||||
if (bane != null) {
|
|
||||||
if (bane.getCity() != null) {
|
|
||||||
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.halfExtents))
|
|
||||||
return bane.getCity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.parentZone.guild_zone == false)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return City.getCity(this.parentZone.playerCityUUID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import engine.gameManager.*;
|
|||||||
import engine.job.JobContainer;
|
import engine.job.JobContainer;
|
||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.UpgradeNPCJob;
|
import engine.jobs.UpgradeNPCJob;
|
||||||
|
import engine.loot.WorkOrder;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
@@ -37,6 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
||||||
@@ -52,6 +54,8 @@ public class NPC extends AbstractCharacter {
|
|||||||
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||||
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
||||||
|
|
||||||
|
public CopyOnWriteArrayList<WorkOrder> workOrders = new CopyOnWriteArrayList();
|
||||||
public HashMap<Integer, MobEquipment> equip = null;
|
public HashMap<Integer, MobEquipment> equip = null;
|
||||||
public int runeSetID = 0;
|
public int runeSetID = 0;
|
||||||
public int extraRune2 = 0;
|
public int extraRune2 = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user