use of server.life.SpawnPoint in project HeavenMS by ronancpl.
the class MCBattlefield method addSpawn.
public void addSpawn(Player chr, int num) {
if (numMonstersSpawned > wzData.mobGenMax) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(3));
return;
}
MCWZData.MCSummonMob mobToSummon = wzData.summons.get(num);
MCWZData.MCMobGenPos spawnPos = getRandomSpawnPos(chr.getMCPQTeam());
MCField.MCTeam team = chr.getMCPQTeam();
if (spawnPos == null) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(2));
return;
}
int spendCp = mobToSummon.spendCP;
if (spendCp > chr.getAvailableCP()) {
readdSpawn(spawnPos, team);
chr.getClient().announce(CarnivalPackets.CarnivalMessage(1));
return;
}
chr.getMCPQField().loseCP(chr, spendCp);
this.map.broadcastMessage(CarnivalPackets.PlayerSummoned(MonsterCarnival.TAB_SPAWNS, num, chr.getName()));
// TODO: AtomicInteger this
numMonstersSpawned++;
MapleMonster monster = MapleLifeFactory.getMonster(mobToSummon.id);
Point pos = new Point(spawnPos.x, spawnPos.y);
SpawnPoint sp = new SpawnPoint(monster, pos, mobToSummon.mobTime, chr.getTeam());
addedSpawns.add(sp);
updateMonsterBuffs();
}
use of server.life.SpawnPoint in project HeavenMS by ronancpl.
the class MCBattlefield method spawningTask.
public void spawningTask() {
for (SpawnPoint sp : originalSpawns) {
if (sp.shouldSpawn()) {
MapleMonster mob = sp.spawnMonster(this.map);
giveMonsterBuffs(mob);
}
}
for (SpawnPoint sp : addedSpawns) {
if (sp.shouldSpawn()) {
MapleMonster mob = sp.spawnMonster(this.map);
giveMonsterBuffs(mob);
}
}
}
use of server.life.SpawnPoint in project HeavenMS by ronancpl.
the class MapleMap method respawn.
public void respawn() {
if (!allowSummons)
return;
chrRLock.lock();
try {
if (characters.isEmpty()) {
return;
}
} finally {
chrRLock.unlock();
}
/*
System.out.println("----------------------------------");
for (SpawnPoint spawnPoint : monsterSpawn) {
System.out.println("sp " + spawnPoint.getPosition().getX() + ", " + spawnPoint.getPosition().getY() + ": " + spawnPoint.getDenySpawn());
}
System.out.println("try " + monsterSpawn.size() + " - " + spawnedMonstersOnMap.get());
System.out.println("----------------------------------");
*/
// Fking lol'd
short numShouldSpawn = (short) ((monsterSpawn.size() - spawnedMonstersOnMap.get()));
if (numShouldSpawn > 0) {
List<SpawnPoint> randomSpawn = new ArrayList<>(monsterSpawn);
Collections.shuffle(randomSpawn);
short spawned = 0;
for (SpawnPoint spawnPoint : randomSpawn) {
if (spawnPoint.shouldSpawn()) {
spawnMonster(spawnPoint.getMonster());
spawned++;
if (spawned >= numShouldSpawn) {
break;
}
}
}
}
}
use of server.life.SpawnPoint in project HeavenMS by ronancpl.
the class MapleMap method addMonsterSpawn.
/**
* it's threadsafe, gtfo :D
*
* @param monster
* @param mobTime
*/
public void addMonsterSpawn(MapleMonster monster, int mobTime, int team) {
Point newpos = calcPointBelow(monster.getPosition());
newpos.y -= 1;
SpawnPoint sp = new SpawnPoint(monster, newpos, !monster.isMobile(), mobTime, mobInterval, team);
monsterSpawn.add(sp);
if (sp.shouldSpawn() || mobTime == -1) {
// -1 does not respawn and should not either but force ONE spawn
spawnMonster(sp.getMonster());
}
}
use of server.life.SpawnPoint in project HeavenMS by ronancpl.
the class Commands method executeHeavenMsCommandLv5.
public static boolean executeHeavenMsCommandLv5(Channel cserv, Server srv, MapleClient c, String[] sub) {
// Developer
MapleCharacter player = c.getPlayer();
MapleMonster monster;
switch(sub[0]) {
case "debugmonster":
List<MapleMapObject> monsters = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER));
for (MapleMapObject monstermo : monsters) {
monster = (MapleMonster) monstermo;
player.message("Monster ID: " + monster.getId() + " Aggro target: " + ((monster.getController() != null) ? monster.getController().getName() : "<none>"));
}
break;
case "debugpacket":
player.getMap().broadcastMessage(MaplePacketCreator.customPacket(joinStringFrom(sub, 1)));
break;
case "debugportal":
MaplePortal portal = player.getMap().findClosestPortal(player.getPosition());
if (portal != null)
player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + portal.getPortalState() + ".");
else
player.dropMessage(6, "There is no portal on this map.");
break;
case "debugspawnpoint":
SpawnPoint sp = player.getMap().findClosestSpawnpoint(player.getPosition());
if (sp != null)
player.dropMessage(6, "Closest mob spawn point: " + " Position: x " + sp.getPosition().getX() + " y " + sp.getPosition().getY() + " Spawns mobid: '" + sp.getMonsterId() + "' --> canSpawn: " + !sp.getDenySpawn() + " canSpawnRightNow: " + sp.shouldSpawn() + ".");
else
player.dropMessage(6, "There is no mob spawn point on this map.");
break;
case "debugpos":
player.dropMessage(6, "Current map position: (" + player.getPosition().getX() + ", " + player.getPosition().getY() + ").");
break;
case "debugmap":
player.dropMessage(6, "Current map id " + player.getMap().getId() + ", event: '" + ((player.getMap().getEventInstance() != null) ? player.getMap().getEventInstance().getName() : "null") + "'; Players: " + player.getMap().getAllPlayers().size() + ", Mobs: " + player.getMap().countMonsters() + ", Reactors: " + player.getMap().countReactors() + ", Items: " + player.getMap().countItems() + ", Objects: " + player.getMap().getMapObjects().size() + ".");
break;
case "debugmobsp":
player.getMap().reportMonsterSpawnPoints(player);
break;
case "debugevent":
if (player.getEventInstance() == null)
player.dropMessage(6, "Player currently not in an event.");
else
player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
break;
case "debugareas":
player.dropMessage(6, "Configured areas on map " + player.getMapId() + ":");
byte index = 0;
for (Rectangle rect : player.getMap().getAreas()) {
player.dropMessage(6, "Id: " + index + " -> posX: " + rect.getX() + " posY: '" + rect.getY() + "' dX: " + rect.getWidth() + " dY: " + rect.getHeight() + ".");
index++;
}
break;
case "debugreactors":
player.dropMessage(6, "Current reactor states on map " + player.getMapId() + ":");
for (MapleMapObject mmo : player.getMap().getReactors()) {
MapleReactor mr = (MapleReactor) mmo;
player.dropMessage(6, "Id: " + mr.getId() + " Oid: " + mr.getObjectId() + " name: '" + mr.getName() + "' -> Type: " + mr.getReactorType() + " State: " + mr.getState() + " Event State: " + mr.getEventState() + " Position: x " + mr.getPosition().getX() + " y " + mr.getPosition().getY() + ".");
}
break;
case "debugservercoupons":
case "debugcoupons":
String s = "Currently active SERVER coupons: ";
for (Integer i : Server.getInstance().getActiveCoupons()) {
s += (i + " ");
}
player.dropMessage(6, s);
break;
case "debugplayercoupons":
String st = "Currently active PLAYER coupons: ";
for (Integer i : player.getActiveCoupons()) {
st += (i + " ");
}
player.dropMessage(6, st);
break;
case "debugtimer":
TimerManager tMan = TimerManager.getInstance();
player.dropMessage(6, "Total Task: " + tMan.getTaskCount() + " Current Task: " + tMan.getQueuedTasks() + " Active Task: " + tMan.getActiveCount() + " Completed Task: " + tMan.getCompletedTaskCount());
break;
default:
return false;
}
return true;
}
Aggregations