Browse Source
# Conflicts: # src/engine/gameManager/CombatManager.java # src/engine/gameManager/PowersManager.java # src/engine/mobileAI/MobAI.java # src/engine/objects/Experience.java # src/engine/objects/PlayerCharacter.java # src/engine/objects/PlayerCombatStats.java # src/engine/util/KeyCloneAudit.java # src/engine/workthreads/UpdateThread.javalakebane
49 changed files with 1886 additions and 604 deletions
@ -0,0 +1,150 @@
@@ -0,0 +1,150 @@
|
||||
package engine.Dungeons; |
||||
|
||||
import engine.Enum; |
||||
import engine.InterestManagement.WorldGrid; |
||||
import engine.gameManager.BuildingManager; |
||||
import engine.gameManager.PowersManager; |
||||
import engine.gameManager.ZoneManager; |
||||
import engine.math.Vector3fImmutable; |
||||
import engine.net.ByteBufferWriter; |
||||
import engine.objects.*; |
||||
import engine.powers.EffectsBase; |
||||
import engine.server.MBServerStatics; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
|
||||
public class Dungeon { |
||||
|
||||
public static int NoFlyEffectID = -1733819072; |
||||
public static int NoTeleportEffectID = -1971545187; |
||||
public static int NoSummonEffectID = 2122002462; |
||||
public ArrayList<PlayerCharacter> participants; |
||||
public int maxPerGuild; |
||||
public Vector3fImmutable entrance; |
||||
public ArrayList<Mob> dungeon_mobs; |
||||
public Long respawnTime = 0L; |
||||
|
||||
public Dungeon(Vector3fImmutable entrance, int maxCount){ |
||||
this.participants = new ArrayList<>(); |
||||
this.entrance = entrance; |
||||
this.dungeon_mobs = new ArrayList<>(); |
||||
this.maxPerGuild = maxCount; |
||||
} |
||||
public void applyDungeonEffects(PlayerCharacter player){ |
||||
EffectsBase noFly = PowersManager.getEffectByToken(NoFlyEffectID); |
||||
EffectsBase noTele = PowersManager.getEffectByToken(NoTeleportEffectID); |
||||
EffectsBase noSum = PowersManager.getEffectByToken(NoSummonEffectID); |
||||
|
||||
if(noFly != null) |
||||
player.addEffectNoTimer(noFly.getName(),noFly,40,true); |
||||
|
||||
if(noTele != null) |
||||
player.addEffectNoTimer(noTele.getName(),noTele,40,true); |
||||
|
||||
if(noSum != null) |
||||
player.addEffectNoTimer(noSum.getName(),noSum,40,true); |
||||
} |
||||
|
||||
public void removeDungeonEffects(PlayerCharacter player) { |
||||
EffectsBase noFly = PowersManager.getEffectByToken(NoFlyEffectID); |
||||
EffectsBase noTele = PowersManager.getEffectByToken(NoTeleportEffectID); |
||||
EffectsBase noSum = PowersManager.getEffectByToken(NoSummonEffectID); |
||||
for (Effect eff : player.effects.values()) { |
||||
if (noFly != null && eff.getEffectsBase().equals(noFly)) |
||||
eff.endEffect(); |
||||
|
||||
if (noTele != null && eff.getEffectsBase().equals(noTele)) |
||||
eff.endEffect(); |
||||
|
||||
if (noSum != null && eff.getEffectsBase().equals(noSum)) |
||||
eff.endEffect(); |
||||
} |
||||
} |
||||
|
||||
public static void serializeForClientMsgTeleport(ByteBufferWriter writer) { |
||||
Guild rulingGuild = Guild.getErrantGuild(); |
||||
Guild rulingNation = Guild.getErrantGuild(); |
||||
|
||||
Zone zone = ZoneManager.getZoneByUUID(994); |
||||
// Begin Serialzing soverign guild data
|
||||
writer.putInt(Enum.GameObjectType.Zone.ordinal()); |
||||
writer.putInt(994); |
||||
writer.putString("Whitehorn Citadel"); |
||||
writer.putInt(rulingGuild.getObjectType().ordinal()); |
||||
writer.putInt(rulingGuild.getObjectUUID()); |
||||
|
||||
writer.putString("Whitehorn Militants"); // guild name
|
||||
writer.putString("In the Citadel, We Fight!"); // motto
|
||||
writer.putString(rulingGuild.getLeadershipType()); |
||||
|
||||
// Serialize guild ruler's name
|
||||
// If tree is abandoned blank out the name
|
||||
// to allow them a rename.
|
||||
|
||||
writer.putString("Kol'roth The Destroyer");//sovreign
|
||||
|
||||
writer.putInt(rulingGuild.getCharter()); |
||||
writer.putInt(0); // always 00000000
|
||||
|
||||
writer.put((byte)0); |
||||
|
||||
writer.put((byte) 1); |
||||
writer.put((byte) 1); // *** Refactor: What are these flags?
|
||||
writer.put((byte) 1); |
||||
writer.put((byte) 1); |
||||
writer.put((byte) 1); |
||||
|
||||
GuildTag._serializeForDisplay(rulingGuild.getGuildTag(), writer); |
||||
GuildTag._serializeForDisplay(rulingNation.getGuildTag(), writer); |
||||
|
||||
writer.putInt(0);// TODO Implement description text
|
||||
|
||||
writer.put((byte) 1); |
||||
writer.put((byte) 0); |
||||
writer.put((byte) 1); |
||||
|
||||
// Begin serializing nation guild info
|
||||
|
||||
if (rulingNation.isEmptyGuild()) { |
||||
writer.putInt(rulingGuild.getObjectType().ordinal()); |
||||
writer.putInt(rulingGuild.getObjectUUID()); |
||||
} else { |
||||
writer.putInt(rulingNation.getObjectType().ordinal()); |
||||
writer.putInt(rulingNation.getObjectUUID()); |
||||
} |
||||
|
||||
|
||||
// Serialize nation name
|
||||
|
||||
writer.putString("Whitehorn Militants"); //nation name
|
||||
|
||||
writer.putInt(-1);//city rank, -1 puts it at top of list always
|
||||
|
||||
writer.putInt(0xFFFFFFFF); |
||||
|
||||
writer.putInt(0); |
||||
|
||||
writer.putString("Kol'roth The Destroyer");//nation ruler
|
||||
|
||||
writer.putLocalDateTime(LocalDateTime.now()); |
||||
|
||||
//location
|
||||
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(BuildingManager.getBuilding(2827951).loc,30f); |
||||
|
||||
writer.putFloat(loc.x); |
||||
writer.putFloat(loc.y); |
||||
writer.putFloat(loc.z); |
||||
|
||||
writer.putInt(0); |
||||
|
||||
writer.put((byte) 1); |
||||
writer.put((byte) 0); |
||||
writer.putInt(0x64); |
||||
writer.put((byte) 0); |
||||
writer.put((byte) 0); |
||||
writer.put((byte) 0); |
||||
} |
||||
} |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
package engine.Dungeons; |
||||
|
||||
import engine.Enum; |
||||
import engine.InterestManagement.WorldGrid; |
||||
import engine.gameManager.DbManager; |
||||
import engine.gameManager.ZoneManager; |
||||
import engine.math.Vector3fImmutable; |
||||
import engine.objects.*; |
||||
import engine.powers.EffectsBase; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
|
||||
public class DungeonManager { |
||||
public static ArrayList<Dungeon> dungeons; |
||||
|
||||
private static final float dungeonAiRange = 64f; |
||||
private static final float maxTravel = 64f; |
||||
|
||||
public static void joinDungeon(PlayerCharacter pc, Dungeon dungeon){ |
||||
if(requestEnter(pc,dungeon)) { |
||||
dungeon.participants.add(pc); |
||||
dungeon.applyDungeonEffects(pc); |
||||
translocateToDungeon(pc, dungeon); |
||||
} |
||||
} |
||||
|
||||
public static void leaveDungeon(PlayerCharacter pc, Dungeon dungeon){ |
||||
dungeon.participants.remove(pc); |
||||
dungeon.removeDungeonEffects(pc); |
||||
translocateOutOfDungeon(pc); |
||||
} |
||||
|
||||
public static boolean requestEnter(PlayerCharacter pc, Dungeon dungeon){ |
||||
int current = 0; |
||||
Guild nation = pc.guild.getNation(); |
||||
|
||||
if(nation == null) |
||||
return false; |
||||
|
||||
for(PlayerCharacter participant : dungeon.participants){ |
||||
if(participant.guild.getNation().equals(nation)){ |
||||
current ++; |
||||
} |
||||
} |
||||
|
||||
if(current >= dungeon.maxPerGuild) |
||||
return false; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
public static void translocateToDungeon(PlayerCharacter pc, Dungeon dungeon){ |
||||
pc.teleport(dungeon.entrance); |
||||
pc.setSafeMode(); |
||||
} |
||||
|
||||
public static void translocateOutOfDungeon(PlayerCharacter pc){ |
||||
pc.teleport(pc.bindLoc); |
||||
pc.setSafeMode(); |
||||
} |
||||
|
||||
public static void pulse_dungeons(){ |
||||
for(Dungeon dungeon : dungeons){ |
||||
|
||||
//early exit, if no players present don't waste resources
|
||||
if(dungeon.participants.isEmpty()) |
||||
continue; |
||||
|
||||
if(dungeon.respawnTime > 0 && System.currentTimeMillis() > dungeon.respawnTime){ |
||||
respawnMobs(dungeon); |
||||
} |
||||
|
||||
//remove any players that have left
|
||||
HashSet<AbstractWorldObject> obj = WorldGrid.getObjectsInRangePartial(dungeon.entrance,4096f,MBServerStatics.MASK_PLAYER); |
||||
for(PlayerCharacter player : dungeon.participants) |
||||
if(!obj.contains(player)) |
||||
leaveDungeon(player,dungeon); |
||||
|
||||
//cycle dungeon mob AI
|
||||
for(Mob mob : dungeon.dungeon_mobs) |
||||
dungeonMobAI(mob); |
||||
} |
||||
} |
||||
|
||||
public static void dungeonMobAI(Mob mob){ |
||||
|
||||
} |
||||
|
||||
public static void respawnMobs(Dungeon dungeon){ |
||||
for(Mob mob : dungeon.dungeon_mobs){ |
||||
|
||||
if(!mob.isAlive() && mob.despawned) |
||||
mob.respawn(); |
||||
|
||||
if(!mob.isAlive() && !mob.despawned){ |
||||
mob.despawn(); |
||||
mob.respawn(); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
package engine.ZergMehcanics; |
||||
|
||||
import engine.InterestManagement.WorldGrid; |
||||
import engine.gameManager.BuildingManager; |
||||
import engine.gameManager.ZergManager; |
||||
import engine.objects.*; |
||||
import engine.server.MBServerStatics; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.HashSet; |
||||
|
||||
public class MineAntiZerg { |
||||
|
||||
public static HashMap<Mine,HashMap<PlayerCharacter,Long>> leaveTimers = new HashMap<>(); |
||||
public static HashMap<Mine,ArrayList<PlayerCharacter>> currentPlayers = new HashMap<>(); |
||||
|
||||
public static void runMines(){ |
||||
for(Mine mine : Mine.getMines()){ |
||||
|
||||
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); |
||||
|
||||
if(tower == null) |
||||
continue; |
||||
|
||||
if(!mine.isActive) |
||||
continue; |
||||
|
||||
logPlayersPresent(tower,mine); |
||||
|
||||
auditPlayersPresent(tower,mine); |
||||
|
||||
auditPlayers(mine); |
||||
} |
||||
} |
||||
|
||||
public static void logPlayersPresent(Building tower, Mine mine){ |
||||
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, MBServerStatics.CHARACTER_LOAD_RANGE * 3,MBServerStatics.MASK_PLAYER); |
||||
|
||||
ArrayList<PlayerCharacter> playersPresent = new ArrayList<>(); |
||||
for(AbstractWorldObject player : loadedPlayers){ |
||||
playersPresent.add((PlayerCharacter)player); |
||||
} |
||||
|
||||
currentPlayers.put(mine,playersPresent); |
||||
} |
||||
|
||||
public static void auditPlayersPresent(Building tower, Mine mine){ |
||||
HashSet<AbstractWorldObject> loadedPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, MBServerStatics.CHARACTER_LOAD_RANGE * 3,MBServerStatics.MASK_PLAYER); |
||||
|
||||
ArrayList<PlayerCharacter> toRemove = new ArrayList<>(); |
||||
|
||||
for(PlayerCharacter player : currentPlayers.get(mine)){ |
||||
if(!loadedPlayers.contains(player)){ |
||||
toRemove.add(player); |
||||
} |
||||
} |
||||
|
||||
currentPlayers.get(mine).removeAll(toRemove); |
||||
|
||||
for(PlayerCharacter player : toRemove){ |
||||
if(leaveTimers.containsKey(mine)){ |
||||
leaveTimers.get(mine).put(player,System.currentTimeMillis()); |
||||
}else{ |
||||
HashMap<PlayerCharacter,Long> leaveTime = new HashMap<>(); |
||||
leaveTime.put(player,System.currentTimeMillis()); |
||||
leaveTimers.put(mine,leaveTime); |
||||
} |
||||
} |
||||
|
||||
toRemove.clear(); |
||||
|
||||
for(PlayerCharacter player : leaveTimers.get(mine).keySet()){ |
||||
long timeGone = System.currentTimeMillis() - leaveTimers.get(mine).get(player); |
||||
if(timeGone > 180000L) {//3 minutes
|
||||
toRemove.add(player); |
||||
player.ZergMultiplier = 1.0f; |
||||
} |
||||
} |
||||
|
||||
for(PlayerCharacter player : toRemove) { |
||||
leaveTimers.get(mine).remove(player); |
||||
} |
||||
} |
||||
|
||||
public static void auditPlayers(Mine mine){ |
||||
|
||||
HashMap<Guild,ArrayList<PlayerCharacter>> playersByNation = new HashMap<>(); |
||||
|
||||
for(PlayerCharacter player : currentPlayers.get(mine)){ |
||||
if(playersByNation.containsKey(player.guild.getNation())){ |
||||
playersByNation.get(player.guild.getNation()).add(player); |
||||
}else{ |
||||
ArrayList<PlayerCharacter> players = new ArrayList<>(); |
||||
players.add(player); |
||||
playersByNation.put(player.guild.getNation(),players); |
||||
} |
||||
} |
||||
|
||||
for(PlayerCharacter player : leaveTimers.get(mine).keySet()){ |
||||
if(playersByNation.containsKey(player.guild.getNation())){ |
||||
playersByNation.get(player.guild.getNation()).add(player); |
||||
}else{ |
||||
ArrayList<PlayerCharacter> players = new ArrayList<>(); |
||||
players.add(player); |
||||
playersByNation.put(player.guild.getNation(),players); |
||||
} |
||||
} |
||||
|
||||
for(Guild nation : playersByNation.keySet()){ |
||||
for(PlayerCharacter player : playersByNation.get(nation)){ |
||||
player.ZergMultiplier = ZergManager.getCurrentMultiplier(playersByNation.get(nation).size(), mine.capSize); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.devcmd.cmds; |
||||
|
||||
import engine.Dungeons.DungeonManager; |
||||
import engine.Enum.GameObjectType; |
||||
import engine.devcmd.AbstractDevCmd; |
||||
import engine.gameManager.BuildingManager; |
||||
import engine.gameManager.ChatManager; |
||||
import engine.gameManager.DbManager; |
||||
import engine.gameManager.ZoneManager; |
||||
import engine.math.Vector3fImmutable; |
||||
import engine.objects.*; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
/** |
||||
* @author Eighty |
||||
*/ |
||||
public class DungenonCmd extends AbstractDevCmd { |
||||
|
||||
public DungenonCmd() { |
||||
super("dungeon"); |
||||
} |
||||
|
||||
@Override |
||||
protected void _doCmd(PlayerCharacter pc, String[] words, |
||||
AbstractGameObject target) { |
||||
|
||||
Zone parent = ZoneManager.findSmallestZone(pc.loc); |
||||
if(parent == null) |
||||
return; |
||||
|
||||
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(BuildingManager.getBuilding(2827951).loc,30f); |
||||
pc.teleport(loc); |
||||
} |
||||
|
||||
@Override |
||||
protected String _getHelpString() { |
||||
return "indicate mob or building followed by an id and a level"; |
||||
} |
||||
|
||||
@Override |
||||
protected String _getUsageString() { |
||||
return "'/dungeon mob 2001 10'"; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue