fatboy
7 months ago
4 changed files with 161 additions and 130 deletions
@ -0,0 +1,145 @@ |
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
|
package engine.workthreads; |
||||||
|
|
||||||
|
import engine.Enum; |
||||||
|
import engine.InterestManagement.WorldGrid; |
||||||
|
import engine.db.archive.DataWarehouse; |
||||||
|
import engine.db.archive.MineRecord; |
||||||
|
import engine.gameManager.*; |
||||||
|
import engine.net.DispatchMessage; |
||||||
|
import engine.net.MessageDispatcher; |
||||||
|
import engine.net.client.msg.chat.ChatSystemMsg; |
||||||
|
import engine.objects.*; |
||||||
|
import engine.server.MBServerStatics; |
||||||
|
import engine.server.world.WorldServer; |
||||||
|
import org.pmw.tinylog.Logger; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
|
||||||
|
import static engine.server.MBServerStatics.MINE_LATE_WINDOW; |
||||||
|
|
||||||
|
public class ZergMechanicThread implements Runnable { |
||||||
|
public Bane bane = null; |
||||||
|
public Mine mine = null; |
||||||
|
public boolean isMine = false; |
||||||
|
|
||||||
|
public ZergMechanicThread(Bane b, Mine m) { |
||||||
|
if(b != null){ |
||||||
|
this.isMine = false; |
||||||
|
} |
||||||
|
if(m != null){ |
||||||
|
this.isMine = true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
|
||||||
|
if(mine != null) |
||||||
|
while(mine.isActive) |
||||||
|
RunMineMechanic(); |
||||||
|
|
||||||
|
if(bane != null) |
||||||
|
while(bane.getSiegePhase().equals(Enum.SiegePhase.WAR)) |
||||||
|
RunBaneMechanic(); |
||||||
|
} |
||||||
|
|
||||||
|
public void RunMineMechanic(){ |
||||||
|
|
||||||
|
HashSet<AbstractWorldObject> currentPlayers; |
||||||
|
PlayerCharacter player; |
||||||
|
|
||||||
|
// Gather current list of players within the zone bounds
|
||||||
|
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); |
||||||
|
currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents * 0.5f, MBServerStatics.MASK_PLAYER); |
||||||
|
|
||||||
|
for (AbstractWorldObject playerObject : currentPlayers) { |
||||||
|
|
||||||
|
if (playerObject == null) |
||||||
|
continue; |
||||||
|
|
||||||
|
player = (PlayerCharacter) playerObject; |
||||||
|
|
||||||
|
if (mine._recentMemory.containsKey(player.getObjectUUID())) |
||||||
|
mine._recentMemory.remove(player.getObjectUUID()); |
||||||
|
|
||||||
|
if (mine._playerMemory.contains(player.getObjectUUID())) |
||||||
|
continue; |
||||||
|
|
||||||
|
mine._playerMemory.add(player.getObjectUUID()); |
||||||
|
} |
||||||
|
boolean updated = false; |
||||||
|
try { |
||||||
|
mine.onExit(currentPlayers); |
||||||
|
} catch (Exception e) { |
||||||
|
Logger.error(e.getMessage()); |
||||||
|
} |
||||||
|
mine.dividedPlayers = new HashMap<>(); |
||||||
|
for(Integer playerID : mine._playerMemory){ |
||||||
|
player = PlayerCharacter.getFromCache(playerID); |
||||||
|
Guild nation = player.getGuild().getNation(); Guild entry; |
||||||
|
if(mine.dividedPlayers.containsKey(nation)){ |
||||||
|
mine.dividedPlayers.get(nation).add(playerID); |
||||||
|
}else{ |
||||||
|
ArrayList<Integer> newEntry = new ArrayList<>(); |
||||||
|
newEntry.add(playerID); |
||||||
|
mine.dividedPlayers.put(nation,newEntry); |
||||||
|
} |
||||||
|
} |
||||||
|
for(Integer playerID : mine._playerMemory){ |
||||||
|
player = PlayerCharacter.getFromCache(playerID); |
||||||
|
if(mine.dividedPlayers.containsKey(player.getGuild().getNation())){ |
||||||
|
int count = mine.dividedPlayers.get(player.getGuild().getNation()).size(); |
||||||
|
switch(mine.capSize){ |
||||||
|
case 5: |
||||||
|
player.ZergMultiplier = ZergManager.getMultiplier5Man(count,player); |
||||||
|
break; |
||||||
|
case 10: |
||||||
|
player.ZergMultiplier = ZergManager.getMultiplier10Man(count,player); |
||||||
|
break; |
||||||
|
case 20: |
||||||
|
player.ZergMultiplier = ZergManager.getMultiplier20Man(count,player); |
||||||
|
break; |
||||||
|
} |
||||||
|
player.mineAppliedID = mine.getObjectUUID(); |
||||||
|
} else{ |
||||||
|
player.ZergMultiplier = 1.0f; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void RunBaneMechanic(){ |
||||||
|
HashSet<AbstractWorldObject> currentPlayers; |
||||||
|
PlayerCharacter player; |
||||||
|
|
||||||
|
currentPlayers = WorldGrid.getObjectsInRangePartial(bane.getCity().loc, Enum.CityBoundsType.GRID.extents * 2.0f, MBServerStatics.MASK_PLAYER); |
||||||
|
Guild attacker = bane.getStone().getGuild().getNation(); |
||||||
|
Guild defender = bane.getCity().getGuild().getNation(); |
||||||
|
int attackers = 0; |
||||||
|
int defenders = 0; |
||||||
|
for(AbstractWorldObject awo : currentPlayers){ |
||||||
|
PlayerCharacter pc = (PlayerCharacter) awo; |
||||||
|
if(pc.getGuild().getNation().equals(attacker) == false && pc.getGuild().getNation().equals(defender) == false) |
||||||
|
pc.teleport(pc.bindLoc); |
||||||
|
|
||||||
|
if(pc.getGuild().getNation().equals(attacker)) |
||||||
|
attackers++; |
||||||
|
|
||||||
|
if(pc.getGuild().getNation().equals(defender)) |
||||||
|
defenders++; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue