Source for my MapleSolaxiaV2 (v83 MapleStory).
This commit is contained in:
ronancpl
2015-11-02 23:17:21 -02:00
parent 324982e94f
commit 972517e7b2
1675 changed files with 261831 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public abstract class AbstractAnimatedMapleMapObject extends AbstractMapleMapObject implements AnimatedMapleMapObject {
private int stance;
public int getStance() {
return stance;
}
public void setStance(int stance) {
this.stance = stance;
}
public boolean isFacingLeft() {
return Math.abs(stance) % 2 == 1;
}
}

View File

@@ -0,0 +1,58 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
public abstract class AbstractMapleMapObject implements MapleMapObject {
private Point position = new Point();
private int objectId;
@Override
public abstract MapleMapObjectType getType();
@Override
public Point getPosition() {
return new Point(position);
}
@Override
public void setPosition(Point position) {
this.position.x = position.x;
this.position.y = position.y;
}
@Override
public int getObjectId() {
return objectId;
}
@Override
public void setObjectId(int id) {
this.objectId = id;
}
@Override
public void nullifyPosition() {
this.position = null;
}
}

View File

@@ -0,0 +1,28 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public interface AnimatedMapleMapObject extends MapleMapObject {
int getStance();
void setStance(int stance);
boolean isFacingLeft();
}

View File

@@ -0,0 +1,69 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
/**
*
* @author AngelSL
*/
public enum FieldLimit {
JUMP(0x01),
MOVEMENTSKILLS(0x02),
SUMMON(0x04),
DOOR(0x08),
CHANGECHANNEL(0x10),
//NO_NOTES(0x20),
CANNOTVIPROCK(0x40),
CANNOTMINIGAME(0x80),
//SPECIFIC_PORTAL_SCROLL_LIMIT(0x100), // APQ and a couple quest maps have this
CANNOTUSEMOUNTS(0x200),
//STAT_CHANGE_ITEM_CONSUME_LIMIT(0x400), // Monster carnival?
//PARTY_BOSS_CHANGE_LIMIT(0x800), // Monster carnival?
CANNOTUSEPOTION(0x1000),
//WEDDING_INVITATION_LIMIT(0x2000), // No notes
//CASH_WEATHER_CONSUME_LIMIT(0x4000),
//NO_PET(0x8000), // Ariant colosseum-related?
//ANTI_MACRO_LIMIT(0x10000), // No notes
CANNOTJUMPDOWN(0x20000);
//SUMMON_NPC_LIMIT(0x40000); // Seems to .. disable Rush if 0x2 is set
//......... EVEN MORE LIMITS ............
//SUMMON_NPC_LIMIT(0x40000),
//NO_EXP_DECREASE(0x80000),
//NO_DAMAGE_ON_FALLING(0x100000),
//PARCEL_OPEN_LIMIT(0x200000),
//DROP_LIMIT(0x400000),
//ROCKETBOOSTER_LIMIT(0x800000) //lol we don't even have mechanics <3
private long i;
private FieldLimit(long i) {
this.i = i;
}
public long getValue() {
return i;
}
public boolean check(int fieldlimit) {
return (fieldlimit & i) == i;
}
}

View File

@@ -0,0 +1,459 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleCharacter;
import client.MapleClient;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.MapleInventoryType;
import com.mysql.jdbc.Statement;
import constants.ItemConstants;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
import net.server.Server;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.MaplePlayerShopItem;
import server.TimerManager;
import tools.DatabaseConnection;
import tools.MaplePacketCreator;
import tools.Pair;
/**
*
* @author XoticStory
*/
public class HiredMerchant extends AbstractMapleMapObject {
private int ownerId, itemId, mesos = 0;
private int channel, world;
private long start;
private String ownerName = "";
private String description = "";
private MapleCharacter[] visitors = new MapleCharacter[3];
private List<MaplePlayerShopItem> items = new LinkedList<>();
private List<Pair<String, Byte>> messages = new LinkedList<>();
private List<SoldItem> sold = new LinkedList<>();
private boolean open;
public ScheduledFuture<?> schedule = null;
private MapleMap map;
public HiredMerchant(final MapleCharacter owner, int itemId, String desc) {
this.setPosition(owner.getPosition());
this.start = System.currentTimeMillis();
this.ownerId = owner.getId();
this.channel = owner.getClient().getChannel();
this.world = owner.getWorld();
this.itemId = itemId;
this.ownerName = owner.getName();
this.description = desc;
this.map = owner.getMap();
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
HiredMerchant.this.forceClose();
Server.getInstance().getChannel(world, channel).removeHiredMerchant(ownerId);
}
}, 1000 * 60 * 60 * 24);
}
public void broadcastToVisitors(final byte[] packet) {
for (MapleCharacter visitor : visitors) {
if (visitor != null) {
visitor.getClient().announce(packet);
}
}
}
public void addVisitor(MapleCharacter visitor) {
int i = this.getFreeSlot();
if (i > -1) {
visitors[i] = visitor;
broadcastToVisitors(MaplePacketCreator.hiredMerchantVisitorAdd(visitor, i + 1));
}
}
public void removeVisitor(MapleCharacter visitor) {
int slot = getVisitorSlot(visitor);
if (slot < 0){ //Not found
return;
}
if (visitors[slot] != null && visitors[slot].getId() == visitor.getId()) {
visitors[slot] = null;
if (slot != -1) {
broadcastToVisitors(MaplePacketCreator.hiredMerchantVisitorLeave(slot + 1));
}
}
}
public int getVisitorSlot(MapleCharacter visitor) {
for (int i = 0; i < 3; i++) {
if (visitors[i] != null && visitors[i].getId() == visitor.getId()){
return i;
}
}
return -1; //Actually 0 because of the +1's.
}
public void removeAllVisitors(String message) {
for (int i = 0; i < 3; i++) {
if (visitors[i] != null) {
visitors[i].setHiredMerchant(null);
visitors[i].getClient().announce(MaplePacketCreator.leaveHiredMerchant(i + 1, 0x11));
if (message.length() > 0) {
visitors[i].dropMessage(1, message);
}
visitors[i] = null;
}
}
}
public void buy(MapleClient c, int item, short quantity) {
MaplePlayerShopItem pItem = items.get(item);
synchronized (items) {
Item newItem = pItem.getItem().copy();
newItem.setQuantity((short) ((pItem.getItem().getQuantity() * quantity)));
if ((newItem.getFlag() & ItemConstants.KARMA) == ItemConstants.KARMA) {
newItem.setFlag((byte) (newItem.getFlag() ^ ItemConstants.KARMA));
}
if (newItem.getType() == 2 && (newItem.getFlag() & ItemConstants.SPIKES) == ItemConstants.SPIKES) {
newItem.setFlag((byte) (newItem.getFlag() ^ ItemConstants.SPIKES));
}
if (quantity < 1 || pItem.getBundles() < 1 || !pItem.isExist() || pItem.getBundles() < quantity) {
c.announce(MaplePacketCreator.enableActions());
return;
} else if (newItem.getType() == 1 && newItem.getQuantity() > 1) {
c.announce(MaplePacketCreator.enableActions());
return;
} else if (!pItem.isExist()) {
c.announce(MaplePacketCreator.enableActions());
return;
}
int price = pItem.getPrice() * quantity;
if (c.getPlayer().getMeso() >= price) {
if (MapleInventoryManipulator.addFromDrop(c, newItem, true)) {
c.getPlayer().gainMeso(-price, false);
sold.add(new SoldItem(c.getPlayer().getName(), pItem.getItem().getItemId(), quantity, price));
pItem.setBundles((short) (pItem.getBundles() - quantity));
if (pItem.getBundles() < 1) {
pItem.setDoesExist(false);
}
MapleCharacter owner = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterByName(ownerName);
if (owner != null) {
owner.addMerchantMesos(price);
} else {
try {
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = MerchantMesos + " + price + " WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ownerId);
ps.executeUpdate();
}
} catch (Exception e) {
}
}
} else {
c.getPlayer().dropMessage(1, "Your inventory is full. Please clean a slot before buying this item.");
}
} else {
c.getPlayer().dropMessage(1, "You do not have enough mesos.");
}
try {
this.saveItems(false);
} catch (Exception e) {
}
}
}
public void forceClose() {
if (schedule != null) {
schedule.cancel(false);
}
try {
saveItems(true);
items.clear();
} catch (SQLException ex) {
}
//Server.getInstance().getChannel(world, channel).removeHiredMerchant(ownerId);
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(getOwnerId()));
map.removeMapObject(this);
MapleCharacter player = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterById(ownerId);
if(player != null) {
player.setHasMerchant(false);
} else {
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ownerId);
ps.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
map = null;
schedule = null;
}
public void closeShop(MapleClient c, boolean timeout) {
map.removeMapObject(this);
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId));
c.getChannelServer().removeHiredMerchant(ownerId);
try {
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(ownerId);
if(player != null) {
player.setHasMerchant(false);
} else {
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ownerId);
ps.executeUpdate();
}
}
if (check(c.getPlayer(), getItems()) && !timeout) {
for (MaplePlayerShopItem mpsi : getItems()) {
if (mpsi.isExist() && (mpsi.getItem().getType() == MapleInventoryType.EQUIP.getType())) {
MapleInventoryManipulator.addFromDrop(c, mpsi.getItem(), false);
} else if (mpsi.isExist()) {
MapleInventoryManipulator.addById(c, mpsi.getItem().getItemId(), (short) (mpsi.getBundles() * mpsi.getItem().getQuantity()), null, -1, mpsi.getItem().getFlag(), mpsi.getItem().getExpiration());
}
}
items.clear();
}
try {
this.saveItems(timeout);
} catch (Exception e) {
}
items.clear();
} catch (Exception e) {
}
schedule.cancel(false);
}
public String getOwner() {
return ownerName;
}
public void clearItems() {
items.clear();
}
public int getOwnerId() {
return ownerId;
}
public String getDescription() {
return description;
}
public MapleCharacter[] getVisitors() {
return visitors;
}
public List<MaplePlayerShopItem> getItems() {
return Collections.unmodifiableList(items);
}
public void addItem(MaplePlayerShopItem item) {
items.add(item);
try {
this.saveItems(false);
} catch (SQLException ex) {
}
}
public void removeFromSlot(int slot) {
items.remove(slot);
try {
this.saveItems(false);
} catch (SQLException ex) {
}
}
public int getFreeSlot() {
for (int i = 0; i < 3; i++) {
if (visitors[i] == null) {
return i;
}
}
return -1;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean set) {
this.open = set;
}
public int getItemId() {
return itemId;
}
public boolean isOwner(MapleCharacter chr) {
return chr.getId() == ownerId;
}
public void saveItems(boolean shutdown) throws SQLException {
List<Pair<Item, MapleInventoryType>> itemsWithType = new ArrayList<>();
for (MaplePlayerShopItem pItems : items) {
Item newItem = pItems.getItem();
if (shutdown) {
newItem.setQuantity((short) (pItems.getItem().getQuantity() * pItems.getBundles()));
} else {
newItem.setQuantity(pItems.getItem().getQuantity());
}
if (pItems.getBundles() > 0) {
itemsWithType.add(new Pair<>(newItem, MapleInventoryType.getByType(newItem.getType())));
}
}
ItemFactory.MERCHANT.saveItems(itemsWithType, this.ownerId, DatabaseConnection.getConnection());
}
private static boolean check(MapleCharacter chr, List<MaplePlayerShopItem> items) {
byte eq = 0, use = 0, setup = 0, etc = 0, cash = 0;
List<MapleInventoryType> li = new LinkedList<>();
for (MaplePlayerShopItem item : items) {
final MapleInventoryType invtype = MapleItemInformationProvider.getInstance().getInventoryType(item.getItem().getItemId());
if (!li.contains(invtype)) {
li.add(invtype);
}
if (invtype == MapleInventoryType.EQUIP) {
eq++;
} else if (invtype == MapleInventoryType.USE) {
use++;
} else if (invtype == MapleInventoryType.SETUP) {
setup++;
} else if (invtype == MapleInventoryType.ETC) {
etc++;
} else if (invtype == MapleInventoryType.CASH) {
cash++;
}
}
for (MapleInventoryType mit : li) {
if (mit == MapleInventoryType.EQUIP) {
if (chr.getInventory(MapleInventoryType.EQUIP).getNumFreeSlot() <= eq) {
return false;
}
} else if (mit == MapleInventoryType.USE) {
if (chr.getInventory(MapleInventoryType.USE).getNumFreeSlot() <= use) {
return false;
}
} else if (mit == MapleInventoryType.SETUP) {
if (chr.getInventory(MapleInventoryType.SETUP).getNumFreeSlot() <= setup) {
return false;
}
} else if (mit == MapleInventoryType.ETC) {
if (chr.getInventory(MapleInventoryType.ETC).getNumFreeSlot() <= etc) {
return false;
}
} else if (mit == MapleInventoryType.CASH) {
if (chr.getInventory(MapleInventoryType.CASH).getNumFreeSlot() <= cash) {
return false;
}
}
}
return true;
}
public int getChannel() {
return channel;
}
public int getTimeLeft() {
return (int) ((System.currentTimeMillis() - start) / 1000);
}
public List<Pair<String, Byte>> getMessages() {
return messages;
}
public int getMapId() {
return map.getId();
}
public List<SoldItem> getSold() {
return sold;
}
public int getMesos() {
return mesos;
}
@Override
public void sendDestroyData(MapleClient client) {
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.HIRED_MERCHANT;
}
@Override
public void sendSpawnData(MapleClient client) {
client.announce(MaplePacketCreator.spawnHiredMerchant(this));
}
public class SoldItem {
int itemid, mesos;
short quantity;
String buyer;
public SoldItem(String buyer, int itemid, short quantity, int mesos) {
this.buyer = buyer;
this.itemid = itemid;
this.quantity = quantity;
this.mesos = mesos;
}
public String getBuyer() {
return buyer;
}
public int getItemId() {
return itemid;
}
public short getQuantity() {
return quantity;
}
public int getMesos() {
return mesos;
}
}
}

View File

@@ -0,0 +1,55 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.util.concurrent.ScheduledFuture;
import server.MaplePortal;
import server.TimerManager;
public class MapMonitor {
private ScheduledFuture<?> monitorSchedule;
private MapleMap map;
private MaplePortal portal;
public MapMonitor(final MapleMap map, String portal) {
this.map = map;
this.portal = map.getPortal(portal);
this.monitorSchedule = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
if (map.getCharacters().size() < 1) {
cancelAction();
}
}
}, 5000);
}
private void cancelAction() {
monitorSchedule.cancel(false);
map.killAllMonsters();
map.clearDrops();
if (portal != null) {
portal.setPortalStatus(MaplePortal.OPEN);
}
map.resetReactors();
}
}

View File

@@ -0,0 +1,157 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import server.MaplePortal;
import tools.MaplePacketCreator;
import client.MapleCharacter;
import client.MapleClient;
/**
*
* @author Matze
*/
public class MapleDoor extends AbstractMapleMapObject {
private MapleCharacter owner;
private MapleMap town;
private MaplePortal townPortal;
private MapleMap target;
private Point targetPosition;
public MapleDoor(MapleCharacter owner, Point targetPosition) {
super();
this.owner = owner;
this.target = owner.getMap();
this.targetPosition = targetPosition;
setPosition(this.targetPosition);
this.town = this.target.getReturnMap();
this.townPortal = getFreePortal();
}
public MapleDoor(MapleDoor origDoor) {
super();
this.owner = origDoor.owner;
this.town = origDoor.town;
this.townPortal = origDoor.townPortal;
this.target = origDoor.target;
this.targetPosition = origDoor.targetPosition;
this.townPortal = origDoor.townPortal;
setPosition(this.townPortal.getPosition());
}
private MaplePortal getFreePortal() {
List<MaplePortal> freePortals = new ArrayList<MaplePortal>();
for (MaplePortal port : town.getPortals()) {
if (port.getType() == 6) {
freePortals.add(port);
}
}
Collections.sort(freePortals, new Comparator<MaplePortal>() {
public int compare(MaplePortal o1, MaplePortal o2) {
if (o1.getId() < o2.getId()) {
return -1;
} else if (o1.getId() == o2.getId()) {
return 0;
} else {
return 1;
}
}
});
for (MapleMapObject obj : town.getMapObjects()) {
if (obj instanceof MapleDoor) {
MapleDoor door = (MapleDoor) obj;
if (door.getOwner().getParty() != null && door.getOwner().getParty().containsMembers(door.getOwner().getMPC())) {
freePortals.remove(door.getTownPortal());
}
}
}
return freePortals.iterator().next();
}
@Override
public void sendSpawnData(MapleClient client) {
if (target.getId() == client.getPlayer().getMapId() || owner == client.getPlayer() && owner.getParty() == null) {
client.announce(MaplePacketCreator.spawnDoor(owner.getId(), town.getId() == client.getPlayer().getMapId() ? townPortal.getPosition() : targetPosition, true));
if (owner.getParty() != null && (owner == client.getPlayer() || owner.getParty().containsMembers(client.getPlayer().getMPC()))) {
client.announce(MaplePacketCreator.partyPortal(town.getId(), target.getId(), targetPosition));
}
}
if (owner.getId() != client.getPlayer().getId()) {
client.announce(MaplePacketCreator.spawnPortal(town.getId(), target.getId(), targetPosition));
}
}
@Override
public void sendDestroyData(MapleClient client) {
if (target.getId() == client.getPlayer().getMapId() || owner == client.getPlayer() || owner.getParty() != null && owner.getParty().containsMembers(client.getPlayer().getMPC())) {
if (owner.getParty() != null && (owner == client.getPlayer() || owner.getParty().containsMembers(client.getPlayer().getMPC()))) {
client.announce(MaplePacketCreator.partyPortal(999999999, 999999999, new Point(-1, -1)));
}
client.announce(MaplePacketCreator.removeDoor(owner.getId(), false));
client.announce(MaplePacketCreator.removeDoor(owner.getId(), true));
}
}
public void warp(MapleCharacter chr, boolean toTown) {
if (chr == owner || owner.getParty() != null && owner.getParty().containsMembers(chr.getMPC())) {
if (!toTown) {
chr.changeMap(target, targetPosition);
} else {
chr.changeMap(town, townPortal);
}
} else {
chr.getClient().announce(MaplePacketCreator.enableActions());
}
}
public MapleCharacter getOwner() {
return owner;
}
public MapleMap getTown() {
return town;
}
public MaplePortal getTownPortal() {
return townPortal;
}
public MapleMap getTarget() {
return target;
}
public Point getTargetPosition() {
return targetPosition;
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.DOOR;
}
}

View File

@@ -0,0 +1,65 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import tools.MaplePacketCreator;
import client.MapleCharacter;
import client.MapleClient;
public class MapleDragon extends AbstractAnimatedMapleMapObject {
private MapleCharacter owner;
public MapleDragon(MapleCharacter chr) {
super();
this.owner = chr;
this.setPosition(chr.getPosition());
this.setStance(chr.getStance());
sendSpawnData(chr.getClient());
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.DRAGON;
}
@Override
public void sendSpawnData(MapleClient c) {
c.announce(MaplePacketCreator.spawnDragon(this));
}
@Override
public int getObjectId() {
return owner.getId();
}
@Override
public void sendDestroyData(MapleClient c) {
c.announce(MaplePacketCreator.removeDragon(owner.getId()));
}
public MapleCharacter getOwner() {
return owner;
}
}

View File

@@ -0,0 +1,102 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
/**
*
* @author Matze
*/
public class MapleFoothold implements Comparable<MapleFoothold> {
private Point p1;
private Point p2;
private int id;
private int next, prev;
public MapleFoothold(Point p1, Point p2, int id) {
this.p1 = p1;
this.p2 = p2;
this.id = id;
}
public boolean isWall() {
return p1.x == p2.x;
}
public int getX1() {
return p1.x;
}
public int getX2() {
return p2.x;
}
public int getY1() {
return p1.y;
}
public int getY2() {
return p2.y;
}
// XXX may need more precision
public int calculateFooting(int x) {
if (p1.y == p2.y) {
return p2.y; // y at both ends is the same
}
int slope = (p1.y - p2.y) / (p1.x - p2.x);
int intercept = p1.y - (slope * p1.x);
return (slope * x) + intercept;
}
public int compareTo(MapleFoothold o) {
MapleFoothold other = o;
if (p2.y < other.getY1()) {
return -1;
} else if (p1.y > other.getY2()) {
return 1;
} else {
return 0;
}
}
public int getId() {
return id;
}
public int getNext() {
return next;
}
public void setNext(int next) {
this.next = next;
}
public int getPrev() {
return prev;
}
public void setPrev(int prev) {
this.prev = prev;
}
}

View File

@@ -0,0 +1,220 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
*
* @author Matze
*/
public class MapleFootholdTree {
private MapleFootholdTree nw = null;
private MapleFootholdTree ne = null;
private MapleFootholdTree sw = null;
private MapleFootholdTree se = null;
private List<MapleFoothold> footholds = new LinkedList<MapleFoothold>();
private Point p1;
private Point p2;
private Point center;
private int depth = 0;
private static int maxDepth = 8;
private int maxDropX;
private int minDropX;
public MapleFootholdTree(Point p1, Point p2) {
this.p1 = p1;
this.p2 = p2;
center = new Point((p2.x - p1.x) / 2, (p2.y - p1.y) / 2);
}
public MapleFootholdTree(Point p1, Point p2, int depth) {
this.p1 = p1;
this.p2 = p2;
this.depth = depth;
center = new Point((p2.x - p1.x) / 2, (p2.y - p1.y) / 2);
}
public void insert(MapleFoothold f) {
if (depth == 0) {
if (f.getX1() > maxDropX) {
maxDropX = f.getX1();
}
if (f.getX1() < minDropX) {
minDropX = f.getX1();
}
if (f.getX2() > maxDropX) {
maxDropX = f.getX2();
}
if (f.getX2() < minDropX) {
minDropX = f.getX2();
}
}
if (depth == maxDepth ||
(f.getX1() >= p1.x && f.getX2() <= p2.x &&
f.getY1() >= p1.y && f.getY2() <= p2.y)) {
footholds.add(f);
} else {
if (nw == null) {
nw = new MapleFootholdTree(p1, center, depth + 1);
ne = new MapleFootholdTree(new Point(center.x, p1.y), new Point(p2.x, center.y), depth + 1);
sw = new MapleFootholdTree(new Point(p1.x, center.y), new Point(center.x, p2.y), depth + 1);
se = new MapleFootholdTree(center, p2, depth + 1);
}
if (f.getX2() <= center.x && f.getY2() <= center.y) {
nw.insert(f);
} else if (f.getX1() > center.x && f.getY2() <= center.y) {
ne.insert(f);
} else if (f.getX2() <= center.x && f.getY1() > center.y) {
sw.insert(f);
} else {
se.insert(f);
}
}
}
private List<MapleFoothold> getRelevants(Point p) {
return getRelevants(p, new LinkedList<MapleFoothold>());
}
private List<MapleFoothold> getRelevants(Point p, List<MapleFoothold> list) {
list.addAll(footholds);
if (nw != null) {
if (p.x <= center.x && p.y <= center.y) {
nw.getRelevants(p, list);
} else if (p.x > center.x && p.y <= center.y) {
ne.getRelevants(p, list);
} else if (p.x <= center.x && p.y > center.y) {
sw.getRelevants(p, list);
} else {
se.getRelevants(p, list);
}
}
return list;
}
private MapleFoothold findWallR(Point p1, Point p2) {
MapleFoothold ret;
for (MapleFoothold f : footholds) {
if (f.isWall() && f.getX1() >= p1.x && f.getX1() <= p2.x &&
f.getY1() >= p1.y && f.getY2() <= p1.y) {
return f;
}
}
if (nw != null) {
if (p1.x <= center.x && p1.y <= center.y) {
ret = nw.findWallR(p1, p2);
if (ret != null) {
return ret;
}
}
if ((p1.x > center.x || p2.x > center.x) && p1.y <= center.y) {
ret = ne.findWallR(p1, p2);
if (ret != null) {
return ret;
}
}
if (p1.x <= center.x && p1.y > center.y) {
ret = sw.findWallR(p1, p2);
if (ret != null) {
return ret;
}
}
if ((p1.x > center.x || p2.x > center.x) && p1.y > center.y) {
ret = se.findWallR(p1, p2);
if (ret != null) {
return ret;
}
}
}
return null;
}
public MapleFoothold findWall(Point p1, Point p2) {
if (p1.y != p2.y) {
throw new IllegalArgumentException();
}
return findWallR(p1, p2);
}
public MapleFoothold findBelow(Point p) {
List<MapleFoothold> relevants = getRelevants(p);
List<MapleFoothold> xMatches = new LinkedList<MapleFoothold>();
for (MapleFoothold fh : relevants) {
if (fh.getX1() <= p.x && fh.getX2() >= p.x) {
xMatches.add(fh);
}
}
Collections.sort(xMatches);
for (MapleFoothold fh : xMatches) {
if (!fh.isWall() && fh.getY1() != fh.getY2()) {
int calcY;
double s1 = Math.abs(fh.getY2() - fh.getY1());
double s2 = Math.abs(fh.getX2() - fh.getX1());
double s4 = Math.abs(p.x - fh.getX1());
double alpha = Math.atan(s2 / s1);
double beta = Math.atan(s1 / s2);
double s5 = Math.cos(alpha) * (s4 / Math.cos(beta));
if (fh.getY2() < fh.getY1()) {
calcY = fh.getY1() - (int) s5;
} else {
calcY = fh.getY1() + (int) s5;
}
if (calcY >= p.y) {
return fh;
}
} else if (!fh.isWall()) {
if (fh.getY1() >= p.y) {
return fh;
}
}
}
return null;
}
public int getX1() {
return p1.x;
}
public int getX2() {
return p2.x;
}
public int getY1() {
return p1.y;
}
public int getY2() {
return p2.y;
}
public int getMaxDropX() {
return maxDropX;
}
public int getMinDropX() {
return minDropX;
}
}

View File

@@ -0,0 +1,144 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleClient;
import java.awt.Point;
import scripting.portal.PortalScriptManager;
import server.MaplePortal;
import tools.MaplePacketCreator;
public class MapleGenericPortal implements MaplePortal {
private String name;
private String target;
private Point position;
private int targetmap;
private int type;
private boolean status = true;
private int id;
private String scriptName;
private boolean portalState;
public MapleGenericPortal(int type) {
this.type = type;
}
@Override
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public String getName() {
return name;
}
@Override
public Point getPosition() {
return position;
}
@Override
public String getTarget() {
return target;
}
@Override
public void setPortalStatus(boolean newStatus) {
this.status = newStatus;
}
@Override
public boolean getPortalStatus() {
return status;
}
@Override
public int getTargetMapId() {
return targetmap;
}
@Override
public int getType() {
return type;
}
@Override
public String getScriptName() {
return scriptName;
}
public void setName(String name) {
this.name = name;
}
public void setPosition(Point position) {
this.position = position;
}
public void setTarget(String target) {
this.target = target;
}
public void setTargetMapId(int targetmapid) {
this.targetmap = targetmapid;
}
@Override
public void setScriptName(String scriptName) {
this.scriptName = scriptName;
}
@Override
public void enterPortal(MapleClient c) {
boolean changed = false;
if (getScriptName() != null) {
changed = PortalScriptManager.getInstance().executePortalScript(this, c);
} else if (getTargetMapId() != 999999999) {
MapleMap to = c.getPlayer().getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : c.getPlayer().getEventInstance().getMapInstance(getTargetMapId());
MaplePortal pto = to.getPortal(getTarget());
if (pto == null) {// fallback for missing portals - no real life case anymore - intresting for not implemented areas
pto = to.getPortal(0);
}
c.getPlayer().changeMap(to, pto); //late resolving makes this harder but prevents us from loading the whole world at once
changed = true;
}
if (!changed) {
c.announce(MaplePacketCreator.enableActions());
}
}
@Override
public void setPortalState(boolean state) {
this.portalState = state;
}
@Override
public boolean getPortalState() {
return portalState;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleClient;
import tools.MaplePacketCreator;
public class MapleMapEffect {
private String msg;
private int itemId;
private boolean active = true;
public MapleMapEffect(String msg, int itemId) {
this.msg = msg;
this.itemId = itemId;
}
public final byte[] makeDestroyData() {
return MaplePacketCreator.removeMapEffect();
}
public final byte[] makeStartData() {
return MaplePacketCreator.startMapEffect(msg, itemId, active);
}
public void sendStartData(MapleClient client) {
client.announce(makeStartData());
}
}

View File

@@ -0,0 +1,301 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import java.awt.Rectangle;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import provider.MapleData;
import provider.MapleDataProvider;
import provider.MapleDataTool;
import server.PortalFactory;
import server.life.AbstractLoadedMapleLife;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import tools.DatabaseConnection;
import tools.StringUtil;
public class MapleMapFactory {
private MapleDataProvider source;
private MapleData nameData;
private Map<Integer, MapleMap> maps = new HashMap<>();
private int channel, world;
public MapleMapFactory(MapleDataProvider source, MapleDataProvider stringSource, int world, int channel) {
this.source = source;
this.nameData = stringSource.getData("Map.img");
this.world = world;
this.channel = channel;
}
public MapleMap getMap(int mapid) {
Integer omapid = Integer.valueOf(mapid);
MapleMap map = maps.get(omapid);
if (map == null) {
synchronized (this) {
map = maps.get(omapid);
if (map != null) {
return map;
}
String mapName = getMapName(mapid);
MapleData mapData = source.getData(mapName);
String link = MapleDataTool.getString(mapData.getChildByPath("info/link"), "");
if (!link.equals("")) { //nexon made hundreds of dojo maps so to reduce the size they added links.
mapName = getMapName(Integer.parseInt(link));
mapData = source.getData(mapName);
}
float monsterRate = 0;
MapleData mobRate = mapData.getChildByPath("info/mobRate");
if (mobRate != null) {
monsterRate = ((Float) mobRate.getData()).floatValue();
}
map = new MapleMap(mapid, world, channel, MapleDataTool.getInt("info/returnMap", mapData), monsterRate);
String onFirstEnter = MapleDataTool.getString(mapData.getChildByPath("info/onFirstUserEnter"), String.valueOf(mapid));
map.setOnFirstUserEnter(onFirstEnter.equals("") ? String.valueOf(mapid) : onFirstEnter);
String onEnter = MapleDataTool.getString(mapData.getChildByPath("info/onUserEnter"), String.valueOf(mapid));
map.setOnUserEnter(onEnter.equals("") ? String.valueOf(mapid) : onEnter);
map.setFieldLimit(MapleDataTool.getInt(mapData.getChildByPath("info/fieldLimit"), 0));
map.setMobInterval((short) MapleDataTool.getInt(mapData.getChildByPath("info/createMobInterval"), 5000));
PortalFactory portalFactory = new PortalFactory();
for (MapleData portal : mapData.getChildByPath("portal")) {
map.addPortal(portalFactory.makePortal(MapleDataTool.getInt(portal.getChildByPath("pt")), portal));
}
MapleData timeMob = mapData.getChildByPath("info/timeMob");
if (timeMob != null) {
map.timeMob(MapleDataTool.getInt(timeMob.getChildByPath("id")),
MapleDataTool.getString(timeMob.getChildByPath("message")));
}
List<MapleFoothold> allFootholds = new LinkedList<>();
Point lBound = new Point();
Point uBound = new Point();
for (MapleData footRoot : mapData.getChildByPath("foothold")) {
for (MapleData footCat : footRoot) {
for (MapleData footHold : footCat) {
int x1 = MapleDataTool.getInt(footHold.getChildByPath("x1"));
int y1 = MapleDataTool.getInt(footHold.getChildByPath("y1"));
int x2 = MapleDataTool.getInt(footHold.getChildByPath("x2"));
int y2 = MapleDataTool.getInt(footHold.getChildByPath("y2"));
MapleFoothold fh = new MapleFoothold(new Point(x1, y1), new Point(x2, y2), Integer.parseInt(footHold.getName()));
fh.setPrev(MapleDataTool.getInt(footHold.getChildByPath("prev")));
fh.setNext(MapleDataTool.getInt(footHold.getChildByPath("next")));
if (fh.getX1() < lBound.x) {
lBound.x = fh.getX1();
}
if (fh.getX2() > uBound.x) {
uBound.x = fh.getX2();
}
if (fh.getY1() < lBound.y) {
lBound.y = fh.getY1();
}
if (fh.getY2() > uBound.y) {
uBound.y = fh.getY2();
}
allFootholds.add(fh);
}
}
}
MapleFootholdTree fTree = new MapleFootholdTree(lBound, uBound);
for (MapleFoothold fh : allFootholds) {
fTree.insert(fh);
}
map.setFootholds(fTree);
if (mapData.getChildByPath("area") != null) {
for (MapleData area : mapData.getChildByPath("area")) {
int x1 = MapleDataTool.getInt(area.getChildByPath("x1"));
int y1 = MapleDataTool.getInt(area.getChildByPath("y1"));
int x2 = MapleDataTool.getInt(area.getChildByPath("x2"));
int y2 = MapleDataTool.getInt(area.getChildByPath("y2"));
map.addMapleArea(new Rectangle(x1, y1, (x2 - x1), (y2 - y1)));
}
}
try { try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM playernpcs WHERE map = ?")) {
ps.setInt(1, omapid);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
map.addMapObject(new PlayerNPCs(rs));
}
}
}
} catch (Exception e) {
}
for (MapleData life : mapData.getChildByPath("life")) {
String id = MapleDataTool.getString(life.getChildByPath("id"));
String type = MapleDataTool.getString(life.getChildByPath("type"));
if (id.equals("9001105")) {
id = "9001108";//soz
}
AbstractLoadedMapleLife myLife = loadLife(life, id, type);
if (myLife instanceof MapleMonster) {
MapleMonster monster = (MapleMonster) myLife;
int mobTime = MapleDataTool.getInt("mobTime", life, 0);
int team = MapleDataTool.getInt("team", life, -1);
if (mobTime == -1) { //does not respawn, force spawn once
map.spawnMonster(monster);
} else {
map.addMonsterSpawn(monster, mobTime, team);
}
} else {
map.addMapObject(myLife);
}
}
if (mapData.getChildByPath("reactor") != null) {
for (MapleData reactor : mapData.getChildByPath("reactor")) {
String id = MapleDataTool.getString(reactor.getChildByPath("id"));
if (id != null) {
MapleReactor newReactor = loadReactor(reactor, id);
map.spawnReactor(newReactor);
}
}
}
try {
map.setMapName(MapleDataTool.getString("mapName", nameData.getChildByPath(getMapStringName(omapid)), ""));
map.setStreetName(MapleDataTool.getString("streetName", nameData.getChildByPath(getMapStringName(omapid)), ""));
} catch (Exception e) {
map.setMapName("");
map.setStreetName("");
}
map.setClock(mapData.getChildByPath("clock") != null);
map.setEverlast(mapData.getChildByPath("everlast") != null);
map.setTown(mapData.getChildByPath("info/town") != null);
map.setHPDec(MapleDataTool.getIntConvert("info/decHP", mapData, 0));
map.setHPDecProtect(MapleDataTool.getIntConvert("info/protectItem", mapData, 0));
map.setForcedReturnMap(MapleDataTool.getInt(mapData.getChildByPath("info/forcedReturn"), 999999999));
map.setBoat(mapData.getChildByPath("shipObj") != null);
map.setTimeLimit(MapleDataTool.getIntConvert("timeLimit", mapData.getChildByPath("info"), -1));
map.setFieldType(MapleDataTool.getIntConvert("info/fieldType", mapData, 0));
map.setMobCapacity(MapleDataTool.getIntConvert("fixedMobCapacity", mapData.getChildByPath("info"), 500));//Is there a map that contains more than 500 mobs?
HashMap<Integer, Integer> backTypes = new HashMap<>();
try {
for (MapleData layer : mapData.getChildByPath("back")) { // yolo
int layerNum = Integer.parseInt(layer.getName());
int type = MapleDataTool.getInt(layer.getChildByPath("type"), 0);
backTypes.put(layerNum, type);
}
} catch (Exception e) {
e.printStackTrace();
// swallow cause I'm cool
}
map.setBackgroundTypes(backTypes);
maps.put(omapid, map);
}
}
return map;
}
public boolean isMapLoaded(int mapId) {
return maps.containsKey(mapId);
}
private AbstractLoadedMapleLife loadLife(MapleData life, String id, String type) {
AbstractLoadedMapleLife myLife = MapleLifeFactory.getLife(Integer.parseInt(id), type);
myLife.setCy(MapleDataTool.getInt(life.getChildByPath("cy")));
MapleData dF = life.getChildByPath("f");
if (dF != null) {
myLife.setF(MapleDataTool.getInt(dF));
}
myLife.setFh(MapleDataTool.getInt(life.getChildByPath("fh")));
myLife.setRx0(MapleDataTool.getInt(life.getChildByPath("rx0")));
myLife.setRx1(MapleDataTool.getInt(life.getChildByPath("rx1")));
int x = MapleDataTool.getInt(life.getChildByPath("x"));
int y = MapleDataTool.getInt(life.getChildByPath("y"));
myLife.setPosition(new Point(x, y));
int hide = MapleDataTool.getInt("hide", life, 0);
if (hide == 1) {
myLife.setHide(true);
}
return myLife;
}
private MapleReactor loadReactor(MapleData reactor, String id) {
MapleReactor myReactor = new MapleReactor(MapleReactorFactory.getReactor(Integer.parseInt(id)), Integer.parseInt(id));
int x = MapleDataTool.getInt(reactor.getChildByPath("x"));
int y = MapleDataTool.getInt(reactor.getChildByPath("y"));
myReactor.setPosition(new Point(x, y));
myReactor.setDelay(MapleDataTool.getInt(reactor.getChildByPath("reactorTime")) * 1000);
myReactor.setState((byte) 0);
myReactor.setName(MapleDataTool.getString(reactor.getChildByPath("name"), ""));
return myReactor;
}
private String getMapName(int mapid) {
String mapName = StringUtil.getLeftPaddedStr(Integer.toString(mapid), '0', 9);
StringBuilder builder = new StringBuilder("Map/Map");
int area = mapid / 100000000;
builder.append(area);
builder.append("/");
builder.append(mapName);
builder.append(".img");
mapName = builder.toString();
return mapName;
}
private String getMapStringName(int mapid) {
StringBuilder builder = new StringBuilder();
if (mapid < 100000000) {
builder.append("maple");
} else if (mapid >= 100000000 && mapid < 200000000) {
builder.append("victoria");
} else if (mapid >= 200000000 && mapid < 300000000) {
builder.append("ossyria");
} else if (mapid >= 540000000 && mapid < 551030200) {
builder.append("singapore");
} else if (mapid >= 600000000 && mapid < 620000000) {
builder.append("MasteriaGL");
} else if (mapid >= 670000000 && mapid < 682000000) {
builder.append("weddingGL");
} else if (mapid >= 682000000 && mapid < 683000000) {
builder.append("HalloweenGL");
} else if (mapid >= 800000000 && mapid < 900000000) {
builder.append("jp");
} else {
builder.append("etc");
}
builder.append("/").append(mapid);
return builder.toString();
}
public void setChannel(int channel) {
this.channel = channel;
}
public void setWorld(int world) {
this.channel = world;
}
public Map<Integer, MapleMap> getMaps() {
return maps;
}
}

View File

@@ -0,0 +1,138 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleCharacter;
import client.MapleClient;
import client.inventory.Item;
import java.awt.Point;
import java.util.concurrent.locks.ReentrantLock;
import tools.MaplePacketCreator;
public class MapleMapItem extends AbstractMapleMapObject {
protected Item item;
protected MapleMapObject dropper;
protected int character_ownerid, meso, questid = -1;
protected byte type;
protected boolean pickedUp = false, playerDrop;
protected long dropTime;
public ReentrantLock itemLock = new ReentrantLock();
public MapleMapItem(Item item, Point position, MapleMapObject dropper, MapleCharacter owner, byte type, boolean playerDrop) {
setPosition(position);
this.item = item;
this.dropper = dropper;
this.character_ownerid = owner.getId();
this.meso = 0;
this.type = type;
this.playerDrop = playerDrop;
}
public MapleMapItem(Item item, Point position, MapleMapObject dropper, MapleCharacter owner, byte type, boolean playerDrop, int questid) {
setPosition(position);
this.item = item;
this.dropper = dropper;
this.character_ownerid = owner.getParty() == null ? owner.getId() : owner.getPartyId();
this.meso = 0;
this.type = type;
this.playerDrop = playerDrop;
this.questid = questid;
}
public MapleMapItem(int meso, Point position, MapleMapObject dropper, MapleCharacter owner, byte type, boolean playerDrop) {
setPosition(position);
this.item = null;
this.dropper = dropper;
this.character_ownerid = owner.getParty() == null ? owner.getId() : owner.getPartyId();
this.meso = meso;
this.type = type;
this.playerDrop = playerDrop;
}
public final Item getItem() {
return item;
}
public final int getQuest() {
return questid;
}
public final int getItemId() {
if (getMeso() > 0) {
return meso;
}
return item.getItemId();
}
public final MapleMapObject getDropper() {
return dropper;
}
public final int getOwner() {
return character_ownerid;
}
public final int getMeso() {
return meso;
}
public final boolean isPlayerDrop() {
return playerDrop;
}
public final boolean isPickedUp() {
return pickedUp;
}
public void setPickedUp(final boolean pickedUp) {
this.pickedUp = pickedUp;
}
public long getDropTime() {
return dropTime;
}
public void setDropTime(long time) {
this.dropTime = time;
}
public byte getDropType() {
return type;
}
@Override
public final MapleMapObjectType getType() {
return MapleMapObjectType.ITEM;
}
@Override
public void sendSpawnData(final MapleClient client) {
if (questid <= 0 || (client.getPlayer().getQuestStatus(questid) == 1 && client.getPlayer().needQuestItem(questid, item.getItemId()))) {
client.announce(MaplePacketCreator.dropItemFromMapObject(this, null, getPosition(), (byte) 2));
}
}
@Override
public void sendDestroyData(final MapleClient client) {
client.announce(MaplePacketCreator.removeItemFromMap(getObjectId(), 1, 0));
}
}

View File

@@ -0,0 +1,36 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import client.MapleClient;
public interface MapleMapObject {
public int getObjectId();
public void setObjectId(int id);
public MapleMapObjectType getType();
public Point getPosition();
public void setPosition(Point position);
public void sendSpawnData(MapleClient client);
public void sendDestroyData(MapleClient client);
public void nullifyPosition();
}

View File

@@ -0,0 +1,26 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public enum MapleMapObjectType {
NPC, MONSTER, ITEM, PLAYER, DOOR, SUMMON, SHOP, MINI_GAME, MIST, REACTOR, HIRED_MERCHANT, PLAYER_NPC, DRAGON;
}

View File

@@ -0,0 +1,30 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import server.MaplePortal;
public class MapleMapPortal extends MapleGenericPortal {
public MapleMapPortal() {
super(MaplePortal.MAP_PORTAL);
}
}

View File

@@ -0,0 +1,86 @@
package server.maps;
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
* @author SharpAceX(Alan)
*/
public enum MapleMiniDungeon {
//http://bbb.hidden-street.net/search_finder/mini%20dungeon
CAVE_OF_MUSHROOMS(105050100, 105050101, 30),
GOLEM_CASTLE_RUINS(105040304, 105040320, 34),
HILL_OF_SANDSTORMS(260020600, 260020630, 30),
HENESYS_PIG_FARM(100020000, 100020100, 30),
DRAKES_BLUE_CAVE(105090311, 105090320, 30),
DRUMMER_BUNNYS_LAIR(221023400, 221023401, 30),
THE_ROUND_TABLE_OF_KENTARUS(240020500, 240020512, 30),
THE_RESTORING_MEMORY(240040511, 240040800, 19),
NEWT_SECURED_ZONE(240040520, 240040900, 19),
PILLAGE_OF_TREASURE_ISLAND(251010402, 251010410, 30),
;
private int baseId;
private int dungeonId;
private int dungeons;
private MapleMiniDungeon(int baseId, int dungeonId, int dungeons) {
this.baseId = baseId;
this.dungeonId = dungeonId;
this.dungeons = dungeons;
}
public int getBase() {
return baseId;
}
public int getDungeonId() {
return dungeonId;
}
public int getDungeons() {
return dungeons;
}
public static boolean isDungeonMap(int map){
for (MapleMiniDungeon dungeon : MapleMiniDungeon.values()){
if (map >= dungeon.getDungeonId() && map <= dungeon.getDungeonId() + dungeon.getDungeons()){
return true;
}
}
return false;
}
public static MapleMiniDungeon getDungeon(int map){
for (MapleMiniDungeon dungeon : MapleMiniDungeon.values()){
if (map >= dungeon.getDungeonId() && map <= dungeon.getDungeonId() + dungeon.getDungeons()){
return dungeon;
}
}
return null;
}
}

View File

@@ -0,0 +1,166 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleCharacter;
import client.MapleClient;
import client.Skill;
import client.SkillFactory;
import java.awt.Point;
import java.awt.Rectangle;
import constants.skills.BlazeWizard;
import constants.skills.Evan;
import constants.skills.FPMage;
import constants.skills.NightWalker;
import constants.skills.Shadower;
import server.MapleStatEffect;
import server.life.MapleMonster;
import server.life.MobSkill;
import tools.MaplePacketCreator;
/**
*
* @author LaiLaiNoob
*/
public class MapleMist extends AbstractMapleMapObject {
private Rectangle mistPosition;
private MapleCharacter owner = null;
private MapleMonster mob = null;
private MapleStatEffect source;
private MobSkill skill;
private boolean isMobMist, isPoisonMist, isRecoveryMist;
private int skillDelay;
public MapleMist(Rectangle mistPosition, MapleMonster mob, MobSkill skill) {
this.mistPosition = mistPosition;
this.mob = mob;
this.skill = skill;
isMobMist = true;
isPoisonMist = true;
isRecoveryMist = false;
skillDelay = 0;
}
public MapleMist(Rectangle mistPosition, MapleCharacter owner, MapleStatEffect source) {
this.mistPosition = mistPosition;
this.owner = owner;
this.source = source;
this.skillDelay = 8;
this.isMobMist = false;
this.isRecoveryMist = false;
this.isPoisonMist = false;
switch (source.getSourceId()) {
case Evan.RECOVERY_AURA:
isRecoveryMist = true;
break;
case Shadower.SMOKE_SCREEN: // Smoke Screen
isPoisonMist = false;
break;
case FPMage.POISON_MIST: // FP mist
case BlazeWizard.FLAME_GEAR: // Flame Gear
case NightWalker.POISON_BOMB: // Poison Bomb
isPoisonMist = true;
break;
}
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.MIST;
}
@Override
public Point getPosition() {
return mistPosition.getLocation();
}
public Skill getSourceSkill() {
return SkillFactory.getSkill(source.getSourceId());
}
public boolean isMobMist() {
return isMobMist;
}
public boolean isPoisonMist() {
return isPoisonMist;
}
public boolean isRecoveryMist() {
return isRecoveryMist;
}
public int getSkillDelay() {
return skillDelay;
}
public MapleMonster getMobOwner() {
return mob;
}
public MapleCharacter getOwner() {
return owner;
}
public Rectangle getBox() {
return mistPosition;
}
@Override
public void setPosition(Point position) {
throw new UnsupportedOperationException();
}
public final byte[] makeDestroyData() {
return MaplePacketCreator.removeMist(getObjectId());
}
public final byte[] makeSpawnData() {
if (owner != null) {
return MaplePacketCreator.spawnMist(getObjectId(), owner.getId(), getSourceSkill().getId(), owner.getSkillLevel(SkillFactory.getSkill(source.getSourceId())), this);
}
return MaplePacketCreator.spawnMist(getObjectId(), mob.getId(), skill.getSkillId(), skill.getSkillLevel(), this);
}
public final byte[] makeFakeSpawnData(int level) {
if (owner != null) {
return MaplePacketCreator.spawnMist(getObjectId(), owner.getId(), getSourceSkill().getId(), level, this);
}
return MaplePacketCreator.spawnMist(getObjectId(), mob.getId(), skill.getSkillId(), skill.getSkillLevel(), this);
}
@Override
public void sendSpawnData(MapleClient client) {
client.announce(makeSpawnData());
}
@Override
public void sendDestroyData(MapleClient client) {
client.announce(makeDestroyData());
}
public boolean makeChanceResult() {
return source.makeChanceResult();
}
}

View File

@@ -0,0 +1,204 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleClient;
import constants.ServerConstants;
import java.awt.Rectangle;
import java.util.List;
import scripting.reactor.ReactorScriptManager;
import server.TimerManager;
import tools.MaplePacketCreator;
import tools.Pair;
/**
*
* @author Lerk
*/
public class MapleReactor extends AbstractMapleMapObject {
private int rid;
private MapleReactorStats stats;
private byte state;
private int delay;
private MapleMap map;
private String name;
private boolean timerActive;
private boolean alive;
public MapleReactor(MapleReactorStats stats, int rid) {
this.stats = stats;
this.rid = rid;
alive = true;
}
public void setTimerActive(boolean active) {
this.timerActive = active;
}
public boolean isTimerActive() {
return timerActive;
}
public void setState(byte state) {
this.state = state;
}
public byte getState() {
return state;
}
public int getId() {
return rid;
}
public void setDelay(int delay) {
this.delay = delay;
}
public int getDelay() {
return delay;
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.REACTOR;
}
public int getReactorType() {
return stats.getType(state);
}
public void setMap(MapleMap map) {
this.map = map;
}
public MapleMap getMap() {
return map;
}
public Pair<Integer, Integer> getReactItem(byte index) {
return stats.getReactItem(state, index);
}
public boolean isAlive() {
return alive;
}
public void setAlive(boolean alive) {
this.alive = alive;
}
@Override
public void sendDestroyData(MapleClient client) {
client.announce(makeDestroyData());
}
public final byte[] makeDestroyData() {
return MaplePacketCreator.destroyReactor(this);
}
@Override
public void sendSpawnData(MapleClient client) {
client.announce(makeSpawnData());
}
public final byte[] makeSpawnData() {
return MaplePacketCreator.spawnReactor(this);
}
public void forceHitReactor(final byte newState) {
setState((byte) newState);
setTimerActive(false);
map.broadcastMessage(MaplePacketCreator.triggerReactor(this, (short) 0));
}
public void delayedHitReactor(final MapleClient c, long delay) {
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
hitReactor(c);
}
}, delay);
}
public void hitReactor(MapleClient c) {
hitReactor(0, (short) 0, 0, c);
}
public synchronized void hitReactor(int charPos, short stance, int skillid, MapleClient c) {
try {
if(!this.isAlive()) {
return;
}
if(ServerConstants.USE_DEBUG == true) c.getPlayer().dropMessage(5, "Hitted REACTOR " + this.getId());
if (stats.getType(state) < 999 && stats.getType(state) != -1) {//type 2 = only hit from right (kerning swamp plants), 00 is air left 02 is ground left
if (!(stats.getType(state) == 2 && (charPos == 0 || charPos == 2))) { //get next state
for (byte b = 0; b < stats.getStateSize(state); b++) {//YAY?
List<Integer> activeSkills = stats.getActiveSkills(state, b);
if (activeSkills != null) {
if (!activeSkills.contains(skillid)) continue;
}
state = stats.getNextState(state, b);
if (stats.getNextState(state, b) == -1) {//end of reactor
if (stats.getType(state) < 100) {//reactor broken
if (delay > 0) {
map.destroyReactor(getObjectId());
} else {//trigger as normal
map.broadcastMessage(MaplePacketCreator.triggerReactor(this, stance));
}
} else {//item-triggered on final step
map.broadcastMessage(MaplePacketCreator.triggerReactor(this, stance));
}
ReactorScriptManager.getInstance().act(c, this);
} else { //reactor not broken yet
map.broadcastMessage(MaplePacketCreator.triggerReactor(this, stance));
if (state == stats.getNextState(state, b)) {//current state = next state, looping reactor
ReactorScriptManager.getInstance().act(c, this);
}
}
break;
}
}
} else {
state++;
map.broadcastMessage(MaplePacketCreator.triggerReactor(this, stance));
ReactorScriptManager.getInstance().act(c, this);
}
} catch(Exception e) {
e.printStackTrace();
}
}
public Rectangle getArea() {
return new Rectangle(getPosition().x + stats.getTL().x, getPosition().y + stats.getTL().y, stats.getBR().x - stats.getTL().x, stats.getBR().y - stats.getTL().y);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,112 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import provider.MapleData;
import provider.MapleDataProvider;
import provider.MapleDataProviderFactory;
import provider.MapleDataTool;
import server.maps.MapleReactorStats.StateData;
import tools.Pair;
import tools.StringUtil;
public class MapleReactorFactory {
private static MapleDataProvider data = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Reactor.wz"));
private static Map<Integer, MapleReactorStats> reactorStats = new HashMap<Integer, MapleReactorStats>();
public static MapleReactorStats getReactor(int rid) {
MapleReactorStats stats = reactorStats.get(Integer.valueOf(rid));
if (stats == null) {
int infoId = rid;
MapleData reactorData = data.getData(StringUtil.getLeftPaddedStr(Integer.toString(infoId) + ".img", '0', 11));
MapleData link = reactorData.getChildByPath("info/link");
if (link != null) {
infoId = MapleDataTool.getIntConvert("info/link", reactorData);
stats = reactorStats.get(Integer.valueOf(infoId));
}
MapleData activateOnTouch = reactorData.getChildByPath("info/activateByTouch");
boolean loadArea = false;
if (activateOnTouch != null) {
loadArea = MapleDataTool.getInt("info/activateByTouch", reactorData, 0) != 0;
}
if (stats == null) {
reactorData = data.getData(StringUtil.getLeftPaddedStr(Integer.toString(infoId) + ".img", '0', 11));
MapleData reactorInfoData = reactorData.getChildByPath("0");
stats = new MapleReactorStats();
List<StateData> statedatas = new ArrayList<StateData>();
if (reactorInfoData != null) {
boolean areaSet = false;
byte i = 0;
while (reactorInfoData != null) {
MapleData eventData = reactorInfoData.getChildByPath("event");
if (eventData != null) {
for (MapleData fknexon : eventData.getChildren()) {
if (fknexon.getName().equals("timeOut")) continue;
Pair<Integer, Integer> reactItem = null;
int type = MapleDataTool.getIntConvert("type", fknexon);
if (type == 100) { //reactor waits for item
reactItem = new Pair<Integer, Integer>(MapleDataTool.getIntConvert("0", fknexon), MapleDataTool.getIntConvert("1", fknexon));
if (!areaSet || loadArea) { //only set area of effect for item-triggered reactors once
stats.setTL(MapleDataTool.getPoint("lt", fknexon));
stats.setBR(MapleDataTool.getPoint("rb", fknexon));
areaSet = true;
}
}
MapleData activeSkillID = fknexon.getChildByPath("activeSkillID");
List<Integer> skillids = null;
if (activeSkillID != null) {
skillids = new ArrayList<Integer>();
for (MapleData skill : activeSkillID.getChildren()) {
skillids.add(MapleDataTool.getInt(skill));
}
}
byte nextState = (byte) MapleDataTool.getIntConvert("state", fknexon);
statedatas.add(new StateData(type, reactItem, skillids, nextState));
}
stats.addState(i, statedatas);
}
i++;
reactorInfoData = reactorData.getChildByPath(Byte.toString(i));
statedatas = new ArrayList<StateData>();
}
} else //sit there and look pretty; likely a reactor such as Zakum/Papulatus doors that shows if player can enter
{
statedatas.add(new StateData(999, null, null, (byte) 0));
stats.addState((byte) 0, statedatas);
}
reactorStats.put(Integer.valueOf(infoId), stats);
if (rid != infoId) {
reactorStats.put(Integer.valueOf(rid), stats);
}
} else // stats exist at infoId but not rid; add to map
{
reactorStats.put(Integer.valueOf(rid), stats);
}
}
return stats;
}
}

View File

@@ -0,0 +1,129 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import tools.Pair;
/**
* @author Lerk
*/
public class MapleReactorStats {
private Point tl;
private Point br;
private Map<Byte, List<StateData>> stateInfo = new HashMap<Byte, List<StateData>>();
public void setTL(Point tl) {
this.tl = tl;
}
public void setBR(Point br) {
this.br = br;
}
public Point getTL() {
return tl;
}
public Point getBR() {
return br;
}
public void addState(byte state, List<StateData> data) {
stateInfo.put(state, data);
}
public byte getStateSize(byte state) {
return (byte) stateInfo.get(state).size();
}
public byte getNextState(byte state, byte index) {
if (stateInfo.get(state) == null || stateInfo.get(state).size() < (index + 1)) return -1;
StateData nextState = stateInfo.get(state).get(index);
if (nextState != null) {
return nextState.getNextState();
} else {
return -1;
}
}
public List<Integer> getActiveSkills(byte state, byte index) {
StateData nextState = stateInfo.get(state).get(index);
if (nextState != null) {
return nextState.getActiveSkills();
} else {
return null;
}
}
public int getType(byte state) {
List<StateData> list = stateInfo.get(state);
if (list != null) {
return list.get(0).getType();
} else {
return -1;
}
}
public Pair<Integer, Integer> getReactItem(byte state, byte index) {
StateData nextState = stateInfo.get(state).get(index);
if (nextState != null) {
return nextState.getReactItem();
} else {
return null;
}
}
public static class StateData {
private int type;
private Pair<Integer, Integer> reactItem;
private List<Integer> activeSkills;
private byte nextState;
public StateData(int type, Pair<Integer, Integer> reactItem, List<Integer> activeSkills, byte nextState) {
this.type = type;
this.reactItem = reactItem;
this.activeSkills = activeSkills;
this.nextState = nextState;
}
private int getType() {
return type;
}
private byte getNextState() {
return nextState;
}
private Pair<Integer, Integer> getReactItem() {
return reactItem;
}
private List<Integer> getActiveSkills() {
return activeSkills;
}
}
}

View File

@@ -0,0 +1,101 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import client.MapleCharacter;
import client.MapleClient;
import client.SkillFactory;
import tools.MaplePacketCreator;
/**
*
* @author Jan
*/
public class MapleSummon extends AbstractAnimatedMapleMapObject {
private MapleCharacter owner;
private byte skillLevel;
private int skill, hp;
private SummonMovementType movementType;
public MapleSummon(MapleCharacter owner, int skill, Point pos, SummonMovementType movementType) {
this.owner = owner;
this.skill = skill;
this.skillLevel = owner.getSkillLevel(SkillFactory.getSkill(skill));
if (skillLevel == 0) throw new RuntimeException();
this.movementType = movementType;
setPosition(pos);
}
public void sendSpawnData(MapleClient client) {
if (this != null) client.announce(MaplePacketCreator.spawnSummon(this, false));
}
public void sendDestroyData(MapleClient client) {
client.announce(MaplePacketCreator.removeSummon(this, true));
}
public MapleCharacter getOwner() {
return owner;
}
public int getSkill() {
return skill;
}
public int getHP() {
return hp;
}
public void addHP(int delta) {
this.hp += delta;
}
public SummonMovementType getMovementType() {
return movementType;
}
public boolean isStationary() {
return (skill == 3111002 || skill == 3211002 || skill == 5211001 || skill == 13111004);
}
public byte getSkillLevel() {
return skillLevel;
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.SUMMON;
}
public final boolean isPuppet() {
switch (skill) {
case 3111002:
case 3211002:
case 13111004:
return true;
}
return false;
}
}

View File

@@ -0,0 +1,78 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import client.MapleCharacter;
import java.util.ArrayList;
import java.util.List;
import net.server.Server;
import server.TimerManager;
import tools.MaplePacketCreator;
/*
* MapleTVEffect
* @author MrXotic
*/
public class MapleTVEffect {
private static boolean ACTIVE;
private List<String> message = new ArrayList<>(5);
private MapleCharacter user;
private int type;
private MapleCharacter partner;
public MapleTVEffect(MapleCharacter u, MapleCharacter p, List<String> msg, int t) {
this.message = msg;
this.user = u;
this.type = t;
this.partner = p;
broadcastTV(true);
}
public static boolean isActive(){
return ACTIVE;
}
private void broadcastTV(boolean activity) {
Server server = Server.getInstance();
ACTIVE = activity;
if (ACTIVE) {
server.broadcastMessage(MaplePacketCreator.enableTV());
server.broadcastMessage(MaplePacketCreator.sendTV(user, message, type <= 2 ? type : type - 3, partner));
int delay = 15000;
if (type == 4) {
delay = 30000;
} else if (type == 5) {
delay = 60000;
}
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
broadcastTV(false);
}
}, delay);
} else {
server.broadcastMessage(MaplePacketCreator.removeTV());
}
}
}

View File

@@ -0,0 +1,124 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
import java.awt.Point;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
import client.MapleClient;
import java.sql.SQLException;
import tools.DatabaseConnection;
import tools.MaplePacketCreator;
/**
*
* @author XoticStory
*/
public class PlayerNPCs extends AbstractMapleMapObject {
private Map<Short, Integer> equips = new HashMap<Short, Integer>();
private int npcId, face, hair;
private byte skin;
private String name = "";
private int FH, RX0, RX1, CY;
public PlayerNPCs(ResultSet rs) {
try {
CY = rs.getInt("cy");
name = rs.getString("name");
hair = rs.getInt("hair");
face = rs.getInt("face");
skin = rs.getByte("skin");
FH = rs.getInt("Foothold");
RX0 = rs.getInt("rx0");
RX1 = rs.getInt("rx1");
npcId = rs.getInt("ScriptId");
setPosition(new Point(rs.getInt("x"), CY));
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT equippos, equipid FROM playernpcs_equip WHERE NpcId = ?");
ps.setInt(1, rs.getInt("id"));
ResultSet rs2 = ps.executeQuery();
while (rs2.next()) {
equips.put(rs2.getShort("equippos"), rs2.getInt("equipid"));
}
rs2.close();
ps.close();
} catch (SQLException e) {
}
}
public Map<Short, Integer> getEquips() {
return equips;
}
public int getId() {
return npcId;
}
public int getFH() {
return FH;
}
public int getRX0() {
return RX0;
}
public int getRX1() {
return RX1;
}
public int getCY() {
return CY;
}
public byte getSkin() {
return skin;
}
public String getName() {
return name;
}
public int getFace() {
return face;
}
public int getHair() {
return hair;
}
@Override
public void sendDestroyData(MapleClient client) {
return;
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.PLAYER_NPC;
}
@Override
public void sendSpawnData(MapleClient client) {
client.announce(MaplePacketCreator.spawnPlayerNPC(this));
client.announce(MaplePacketCreator.getPlayerNPC(this));
}
}

View File

@@ -0,0 +1,32 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 ~ 2010 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public class ReactorDropEntry {
public ReactorDropEntry(int itemId, int chance, int questId) {
this.itemId = itemId;
this.chance = chance;
this.questid = questId;
}
public int itemId, chance, questid;
public int assignedRangeStart, assignedRangeLength;
}

View File

@@ -0,0 +1,39 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public class SavedLocation {
private int mapid = 102000000, portal;
public SavedLocation(int mapid, int portal) {
this.mapid = mapid;
this.portal = portal;
}
public int getMapId() {
return mapid;
}
public int getPortal() {
return portal;
}
}

View File

@@ -0,0 +1,37 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public enum SavedLocationType {
FREE_MARKET,
EVENT,
WORLDTOUR,
FLORINA,
INTRO,
SUNDAY_MARKET,
MIRROR,
DOJO;
public static SavedLocationType fromString(String Str) {
return valueOf(Str);
}
}

View File

@@ -0,0 +1,35 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.maps;
public enum SummonMovementType {
STATIONARY(0), FOLLOW(1), CIRCLE_FOLLOW(3);
private final int val;
private SummonMovementType(int val) {
this.val = val;
}
public int getValue() {
return val;
}
}