use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class MapleCharacter method changeMap.
public void changeMap(final MapleMap target, final MaplePortal pto) {
canWarpCounter++;
// player can be dropped from an event here, hence the new warping target.
eventChangedMap(target.getId());
MapleMap to = getWarpMap(target.getId());
changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this));
canWarpMap = false;
canWarpCounter--;
if (canWarpCounter == 0)
canWarpMap = true;
eventAfterChangedMap(this.getMapId());
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class MapleCharacter method getWarpMap.
public MapleMap getWarpMap(int map) {
MapleMap target;
EventInstanceManager eim = getEventInstance();
if (eim == null) {
target = client.getChannelServer().getMapFactory().getMap(map);
} else {
target = eim.getMapInstance(map);
}
return target;
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class MapleCharacter method changeMap.
public void changeMap(final MapleMap target, final Point pos) {
canWarpCounter++;
eventChangedMap(target.getId());
MapleMap to = getWarpMap(target.getId());
// Position :O (LEFT)
changeMapInternal(to, pos, MaplePacketCreator.getWarpToMap(to, 0x80, this));
canWarpMap = false;
canWarpCounter--;
if (canWarpCounter == 0)
canWarpMap = true;
eventAfterChangedMap(this.getMapId());
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class MobDamageMobFriendlyHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int attacker = slea.readInt();
slea.readInt();
int damaged = slea.readInt();
MapleMonster monster = c.getPlayer().getMap().getMonsterByOid(damaged);
if (monster == null || c.getPlayer().getMap().getMonsterByOid(attacker) == null) {
return;
}
// Beng's formula.
int damage = Randomizer.nextInt(((monster.getMaxHp() / 13 + monster.getPADamage() * 10)) * 2 + 500) / 10;
if (monster.getHp() - damage < 1) {
// friendly dies
if (monster.getId() == 9300102) {
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "The Watch Hog has been injured by the aliens. Better luck next time..."));
} else if (monster.getId() == 9300061) {
// moon bunny
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny went home because he was sick."));
} else if (monster.getId() == 9300093) {
// tylus
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Tylus has fallen by the overwhelming forces of the ambush."));
} else if (monster.getId() == 9300137) {
// juliet
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Juliet has fainted on the middle of the combat."));
} else if (monster.getId() == 9300138) {
// romeo
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Romeo has fainted on the middle of the combat."));
}
c.getPlayer().getMap().killFriendlies(monster);
} else {
if (monster.getId() == 9300061) {
MapleMap map = c.getPlayer().getEventInstance().getMapInstance(monster.getMap().getId());
map.addBunnyHit();
}
}
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.MobDamageMobFriendly(monster, damage), monster.getPosition());
c.announce(MaplePacketCreator.enableActions());
}
use of server.maps.MapleMap in project HeavenMS by ronancpl.
the class PartyOperationHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int operation = slea.readByte();
MapleCharacter player = c.getPlayer();
World world = c.getWorldServer();
MapleParty party = player.getParty();
MaplePartyCharacter partyplayer = player.getMPC();
switch(operation) {
case 1:
{
// create
if (player.getLevel() < 10 && !ServerConstants.USE_PARTY_FOR_STARTERS) {
c.announce(MaplePacketCreator.partyStatusMessage(10));
return;
}
if (player.getParty() == null) {
partyplayer = new MaplePartyCharacter(player);
party = world.createParty(partyplayer);
player.setParty(party);
player.setMPC(partyplayer);
player.getMap().addPartyMember(player);
player.silentPartyUpdate();
c.announce(MaplePacketCreator.partyCreated(partyplayer));
} else {
c.announce(MaplePacketCreator.serverNotice(5, "You can't create a party as you are already in one."));
}
break;
}
case 2:
{
// leave/disband
leaveParty(party, partyplayer, c);
break;
}
case 3:
{
// join
int partyid = slea.readInt();
if (c.getPlayer().getParty() == null) {
party = world.getParty(partyid);
if (party != null) {
if (party.getMembers().size() < 6) {
partyplayer = new MaplePartyCharacter(player);
player.getMap().addPartyMember(player);
world.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
player.receivePartyMemberHP();
player.updatePartyMemberHP();
} else {
c.announce(MaplePacketCreator.partyStatusMessage(17));
}
} else {
c.announce(MaplePacketCreator.serverNotice(5, "The person you have invited to the party is already in one."));
}
} else {
c.announce(MaplePacketCreator.serverNotice(5, "You can't join the party as you are already in one."));
}
break;
}
case 4:
{
// invite
String name = slea.readMapleAsciiString();
MapleCharacter invited = world.getPlayerStorage().getCharacterByName(name);
if (invited != null) {
if (invited.getLevel() < 10 && (!ServerConstants.USE_PARTY_FOR_STARTERS || player.getLevel() >= 10)) {
// min requirement is level 10
c.announce(MaplePacketCreator.serverNotice(5, "The player you have invited does not meet the requirements."));
return;
}
if (ServerConstants.USE_PARTY_FOR_STARTERS && invited.getLevel() >= 10 && player.getLevel() < 10) {
// trying to invite high level
c.announce(MaplePacketCreator.serverNotice(5, "The player you have invited does not meet the requirements."));
return;
}
if (invited.getParty() == null) {
if (player.getParty() == null) {
if (player.getLevel() < 10 && !ServerConstants.USE_PARTY_FOR_STARTERS) {
c.announce(MaplePacketCreator.partyStatusMessage(10));
return;
}
partyplayer = new MaplePartyCharacter(player);
party = world.createParty(partyplayer);
player.setParty(party);
player.setMPC(partyplayer);
player.getMap().addPartyMember(player);
c.announce(MaplePacketCreator.partyCreated(partyplayer));
}
if (party.getMembers().size() < 6) {
invited.getClient().announce(MaplePacketCreator.partyInvite(player));
} else {
c.announce(MaplePacketCreator.partyStatusMessage(17));
}
} else {
c.announce(MaplePacketCreator.partyStatusMessage(16));
}
} else {
c.announce(MaplePacketCreator.partyStatusMessage(19));
}
break;
}
case 5:
{
// expel
int cid = slea.readInt();
if (partyplayer.equals(party.getLeader())) {
MaplePartyCharacter expelled = party.getMemberById(cid);
if (expelled != null) {
MapleCharacter emc = expelled.getPlayer();
if (emc != null) {
MapleMap map = emc.getMap();
if (map != null)
map.removePartyMember(emc);
EventInstanceManager eim = emc.getEventInstance();
if (eim != null) {
eim.leftParty(emc);
}
emc.setParty(null);
}
world.updateParty(party.getId(), PartyOperation.EXPEL, expelled);
}
}
break;
}
case 6:
{
// change leader
int newLeader = slea.readInt();
MaplePartyCharacter newLeadr = party.getMemberById(newLeader);
world.updateParty(party.getId(), PartyOperation.CHANGE_LEADER, newLeadr);
break;
}
}
}
Aggregations