use of server.maps.MapleSummon in project HeavenMS by ronancpl.
the class MapleCharacter method Hide.
public void Hide(boolean hide, boolean login) {
if (isGM() && hide != this.hidden) {
if (!hide) {
this.hidden = false;
announce(MaplePacketCreator.getGMEffect(0x10, (byte) 0));
List<MapleBuffStat> dsstat = Collections.singletonList(MapleBuffStat.DARKSIGHT);
getMap().broadcastGMMessage(this, MaplePacketCreator.cancelForeignBuff(id, dsstat), false);
getMap().broadcastMessage(this, MaplePacketCreator.spawnPlayerMapObject(this), false);
for (MapleSummon ms : this.getSummonsValues()) {
getMap().broadcastNONGMMessage(this, MaplePacketCreator.spawnSummon(ms, false), false);
}
updatePartyMemberHP();
} else {
this.hidden = true;
announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
if (!login) {
getMap().broadcastMessage(this, MaplePacketCreator.removePlayerFromMap(getId()), false);
}
getMap().broadcastGMMessage(this, MaplePacketCreator.spawnPlayerMapObject(this), false);
List<Pair<MapleBuffStat, Integer>> ldsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
getMap().broadcastGMMessage(this, MaplePacketCreator.giveForeignBuff(id, ldsstat), false);
for (MapleMonster mon : this.getControlledMonsters()) {
mon.setController(null);
mon.setControllerHasAggro(false);
mon.setControllerKnowsAboutAggro(false);
mon.getMap().updateMonsterController(mon);
}
}
announce(MaplePacketCreator.enableActions());
}
}
use of server.maps.MapleSummon in project HeavenMS by ronancpl.
the class BeholderHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
// System.out.println(slea.toString());
Collection<MapleSummon> summons = c.getPlayer().getSummonsValues();
int oid = slea.readInt();
MapleSummon summon = null;
for (MapleSummon sum : summons) {
if (sum.getObjectId() == oid) {
summon = sum;
}
}
if (summon != null) {
int skillId = slea.readInt();
if (skillId == DarkKnight.AURA_OF_BEHOLDER) {
// Not sure.
slea.readShort();
} else if (skillId == DarkKnight.HEX_OF_BEHOLDER) {
// Not sure.
slea.readByte();
}
// show to others here
} else {
c.getPlayer().clearSummons();
}
}
use of server.maps.MapleSummon in project HeavenMS by ronancpl.
the class MapleStatEffect method silentApplyBuff.
public void silentApplyBuff(MapleCharacter chr, long localStartTime) {
int localDuration = duration;
localDuration = alchemistModifyVal(chr, localDuration, false);
// CancelEffectAction cancelAction = new CancelEffectAction(chr, this, starttime);
// ScheduledFuture<?> schedule = TimerManager.getInstance().schedule(cancelAction, ((starttime + localDuration) - System.currentTimeMillis()));
chr.registerEffect(this, localStartTime, localStartTime + localDuration, true);
SummonMovementType summonMovementType = getSummonMovementType();
if (summonMovementType != null) {
final MapleSummon tosummon = new MapleSummon(chr, sourceid, chr.getPosition(), summonMovementType);
if (!tosummon.isStationary()) {
chr.addSummon(sourceid, tosummon);
tosummon.addHP(x);
}
}
if (sourceid == Corsair.BATTLE_SHIP) {
chr.announce(MaplePacketCreator.skillCooldown(5221999, chr.getBattleshipHp()));
}
}
use of server.maps.MapleSummon 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;
}
use of server.maps.MapleSummon in project HeavenMS by ronancpl.
the class MapleCharacter method deregisterBuffStats.
private List<Pair<MapleBuffStat, MapleBuffStatValueHolder>> deregisterBuffStats(Map<MapleBuffStat, MapleBuffStatValueHolder> stats) {
chrLock.lock();
try {
List<Pair<MapleBuffStat, MapleBuffStatValueHolder>> effectsToCancel = new ArrayList<>(stats.size());
for (Entry<MapleBuffStat, MapleBuffStatValueHolder> stat : stats.entrySet()) {
int sourceid = stat.getValue().effect.getBuffSourceId();
if (!buffEffects.containsKey(sourceid)) {
buffExpires.remove(sourceid);
}
MapleBuffStat mbs = stat.getKey();
effectsToCancel.add(new Pair<>(mbs, stat.getValue()));
MapleBuffStatValueHolder mbsvh = effects.get(mbs);
if (mbsvh != null && mbsvh.effect.getBuffSourceId() == sourceid) {
mbsvh.bestApplied = true;
effects.remove(mbs);
if (mbs == MapleBuffStat.RECOVERY) {
if (recoveryTask != null) {
recoveryTask.cancel(false);
recoveryTask = null;
}
} else if (mbs == MapleBuffStat.SUMMON || mbs == MapleBuffStat.PUPPET) {
int summonId = mbsvh.effect.getSourceId();
MapleSummon summon = summons.get(summonId);
if (summon != null) {
getMap().broadcastMessage(MaplePacketCreator.removeSummon(summon, true), summon.getPosition());
getMap().removeMapObject(summon);
removeVisibleMapObject(summon);
summons.remove(summonId);
if (summon.getSkill() == DarkKnight.BEHOLDER) {
if (beholderHealingSchedule != null) {
beholderHealingSchedule.cancel(false);
beholderHealingSchedule = null;
}
if (beholderBuffSchedule != null) {
beholderBuffSchedule.cancel(false);
beholderBuffSchedule = null;
}
}
}
} else if (mbs == MapleBuffStat.DRAGONBLOOD) {
dragonBloodSchedule.cancel(false);
dragonBloodSchedule = null;
} else if (mbs == MapleBuffStat.HPREC || mbs == MapleBuffStat.MPREC) {
if (mbs == MapleBuffStat.HPREC) {
extraHpRec = 0;
} else {
extraMpRec = 0;
}
if (extraRecoveryTask != null) {
extraRecoveryTask.cancel(false);
extraRecoveryTask = null;
}
if (extraHpRec != 0 || extraMpRec != 0) {
startExtraTaskInternal(extraHpRec, extraMpRec, extraRecInterval);
}
}
}
}
return effectsToCancel;
} finally {
chrLock.unlock();
}
}
Aggregations