use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class EventInstanceManager method disposeIfPlayerBelow.
public final boolean disposeIfPlayerBelow(final byte size, final int towarp) {
if (disposed) {
return true;
}
if (chars == null) {
return false;
}
MapleMap map = null;
if (towarp > 0) {
map = this.getMapFactory().getMap(towarp);
}
List<MapleCharacter> players = getPlayerList();
try {
if (players.size() < size) {
for (MapleCharacter chr : players) {
if (chr == null) {
continue;
}
unregisterPlayer(chr);
if (towarp > 0) {
chr.changeMap(map, map.getPortal(0));
}
}
dispose();
return true;
}
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class EventInstanceManager method linkToNextStage.
public final void linkToNextStage(int thisStage, String eventFamily, int thisMapId) {
giveEventPlayersStageReward(thisStage);
// stages counts from ONE, scripts from ZERO
thisStage--;
MapleMap nextStage = getMapInstance(thisMapId);
MaplePortal portal = nextStage.getPortal("next00");
if (portal != null) {
portal.setScriptName(eventFamily + thisStage);
}
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class EventInstanceManager method getMapInstance.
public MapleMap getMapInstance(int mapId) {
MapleMap map = mapFactory.getMap(mapId);
map.setEventInstance(this);
if (!mapFactory.isMapLoaded(mapId)) {
sL.lock();
try {
if (em.getProperty("shuffleReactors") != null && em.getProperty("shuffleReactors").equals("true")) {
map.shuffleReactors();
}
} finally {
sL.unlock();
}
}
return map;
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class EventInstanceManager method showWrongEffect.
public final void showWrongEffect(int mapId) {
MapleMap map = getMapInstance(mapId);
map.broadcastMessage(MaplePacketCreator.showEffect("quest/party/wrong_kor"));
map.broadcastMessage(MaplePacketCreator.playSound("Party1/Failed"));
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class MapleStatEffect method applyTo.
// primary: the player caster of the buff
private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos, boolean useMaxRange) {
if (skill && (sourceid == GM.HIDE || sourceid == SuperGM.HIDE)) {
applyto.toggleHide(false);
return true;
}
int hpchange = calcHPChange(applyfrom, primary);
int mpchange = calcMPChange(applyfrom, primary);
if (primary) {
if (itemConNo != 0) {
if (!applyto.getClient().getAbstractPlayerInteraction().hasItem(itemCon, itemConNo)) {
applyto.getClient().announce(MaplePacketCreator.enableActions());
return false;
}
MapleInventoryManipulator.removeById(applyto.getClient(), ItemConstants.getInventoryType(itemCon), itemCon, itemConNo, false, true);
}
}
List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
if (!primary) {
if (isResurrection()) {
hpchange = applyto.getMaxHp();
applyto.setStance(0);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
}
}
if (isDispel() && makeChanceResult()) {
applyto.dispelDebuffs();
} else if (isCureAllAbnormalStatus()) {
applyto.dispelDebuff(MapleDisease.SEDUCE);
applyto.dispelDebuff(MapleDisease.ZOMBIFY);
applyto.dispelDebuffs();
} else if (isComboReset()) {
applyto.setCombo((short) 0);
}
/*if (applyfrom.getMp() < getMpCon()) {
AutobanFactory.MPCON.addPoint(applyfrom.getAutobanManager(), "mpCon hack for skill:" + sourceid + "; Player MP: " + applyto.getMp() + " MP Needed: " + getMpCon());
} */
if (hpchange != 0) {
if (hpchange < 0 && (-hpchange) >= applyto.getHp() && (!applyto.hasDisease(MapleDisease.ZOMBIFY) || hpCon > 0)) {
if (!applyto.isGM()) {
applyto.getClient().announce(MaplePacketCreator.enableActions());
return false;
}
}
int newHp = applyto.getHp() + hpchange;
if (newHp < 1) {
newHp = 1;
}
applyto.setHp(newHp);
hpmpupdate.add(new Pair<>(MapleStat.HP, Integer.valueOf(applyto.getHp())));
}
int newMp = applyto.getMp() + mpchange;
if (mpchange != 0) {
if (mpchange < 0 && -mpchange > applyto.getMp()) {
if (!applyto.isGM()) {
applyto.getClient().announce(MaplePacketCreator.enableActions());
return false;
} else {
newMp = 0;
}
}
applyto.setMp(newMp);
hpmpupdate.add(new Pair<>(MapleStat.MP, Integer.valueOf(applyto.getMp())));
}
applyto.getClient().announce(MaplePacketCreator.updatePlayerStats(hpmpupdate, true, applyto));
if (moveTo != -1) {
if (moveTo != applyto.getMapId()) {
MapleMap target;
MaplePortal pt;
if (moveTo == 999999999) {
if (sourceid != 2030100) {
target = applyto.getMap().getReturnMap();
pt = target.getRandomPlayerSpawnpoint();
} else {
if (!applyto.canRecoverLastBanish())
return false;
Pair<Integer, Integer> lastBanishInfo = applyto.getLastBanishData();
target = applyto.getWarpMap(lastBanishInfo.getLeft());
pt = target.getPortal(lastBanishInfo.getRight());
}
} else {
target = applyto.getClient().getWorldServer().getChannel(applyto.getClient().getChannel()).getMapFactory().getMap(moveTo);
int targetid = target.getId() / 10000000;
if (targetid != 60 && applyto.getMapId() / 10000000 != 61 && targetid != applyto.getMapId() / 10000000 && targetid != 21 && targetid != 20 && targetid != 12 && (applyto.getMapId() / 10000000 != 10 && applyto.getMapId() / 10000000 != 12)) {
return false;
}
pt = target.getRandomPlayerSpawnpoint();
}
applyto.changeMap(target, pt);
} else {
return false;
}
}
if (isShadowClaw()) {
int projectile = 0;
MapleInventory use = applyto.getInventory(MapleInventoryType.USE);
for (int i = 1; i <= use.getSlotLimit(); i++) {
// impose order...
Item item = use.getItem((short) i);
if (item != null) {
if (ItemConstants.isThrowingStar(item.getItemId()) && item.getQuantity() >= 200) {
projectile = item.getItemId();
break;
}
}
}
if (projectile == 0) {
return false;
} else {
MapleInventoryManipulator.removeById(applyto.getClient(), MapleInventoryType.USE, projectile, 200, false, true);
}
}
SummonMovementType summonMovementType = getSummonMovementType();
if (overTime || isCygnusFA() || summonMovementType != null) {
if (summonMovementType != null && pos != null) {
if (summonMovementType.getValue() == summonMovementType.STATIONARY.getValue())
applyto.cancelBuffStats(MapleBuffStat.PUPPET);
else
applyto.cancelBuffStats(MapleBuffStat.SUMMON);
}
applyBuffEffect(applyfrom, applyto, primary);
}
if (primary && (overTime || isHeal())) {
applyBuff(applyfrom, useMaxRange);
}
if (primary && isMonsterBuff()) {
applyMonsterBuff(applyfrom);
}
if (this.getFatigue() != 0) {
applyto.getMount().setTiredness(applyto.getMount().getTiredness() + this.getFatigue());
}
if (summonMovementType != null && pos != null) {
final MapleSummon tosummon = new MapleSummon(applyfrom, sourceid, pos, summonMovementType);
applyfrom.getMap().spawnSummon(tosummon);
applyfrom.addSummon(sourceid, tosummon);
tosummon.addHP(x);
if (isBeholder()) {
tosummon.addHP(1);
}
}
if (isMagicDoor() && !FieldLimit.DOOR.check(applyto.getMap().getFieldLimit())) {
// Magic Door
int y = applyto.getFh();
if (y == 0) {
y = applyto.getPosition().y;
}
Point doorPosition = new Point(applyto.getPosition().x, y);
MapleDoor door = new MapleDoor(applyto, doorPosition);
if (door.getOwnerId() >= 0) {
if (applyto.getParty() != null) {
for (MaplePartyCharacter partyMember : applyto.getParty().getMembers()) {
partyMember.getPlayer().addDoor(door.getOwnerId(), door);
partyMember.addDoor(door.getOwnerId(), door);
}
applyto.silentPartyUpdate();
} else {
applyto.addDoor(door.getOwnerId(), door);
}
door.getTarget().spawnDoor(door.getAreaDoor());
door.getTown().spawnDoor(door.getTownDoor());
applyto.disableDoorSpawn();
} else {
MapleInventoryManipulator.addFromDrop(applyto.getClient(), new Item(4006000, (short) 0, (short) 1), false);
if (door.getOwnerId() == -3)
applyto.dropMessage(5, "Mystic Door cannot be cast far from a spawn point. Nearest one is at " + door.getDoorStatus().getRight() + "pts " + door.getDoorStatus().getLeft());
else if (door.getOwnerId() == -2)
applyto.dropMessage(5, "Mystic Door cannot be cast on a slope, try elsewhere.");
else
applyto.dropMessage(5, "There are no door portals available for the town at this moment. Try again later.");
// cancel door buff
applyto.cancelBuffStats(MapleBuffStat.SOULARROW);
}
} else if (isMist()) {
Rectangle bounds = calculateBoundingBox(sourceid == NightWalker.POISON_BOMB ? pos : applyfrom.getPosition(), applyfrom.isFacingLeft());
MapleMist mist = new MapleMist(bounds, applyfrom, this);
applyfrom.getMap().spawnMist(mist, getDuration(), mist.isPoisonMist(), false, mist.isRecoveryMist());
} else if (isTimeLeap()) {
applyto.removeAllCooldownsExcept(Buccaneer.TIME_LEAP, true);
} else if (isHyperBody() && !primary) {
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
}
return true;
}
Aggregations