Orbis PQ
Implemented Orbis PQ.
This commit is contained in:
@@ -743,7 +743,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
this.loggedIn = true;
|
||||
c.setAccountName(this.client.getAccountName());//No null's for accountName
|
||||
this.client = c;
|
||||
MaplePortal portal = map.findClosestSpawnpoint(getPosition());
|
||||
MaplePortal portal = map.findClosestPlayerSpawnpoint(getPosition());
|
||||
if (portal == null) {
|
||||
portal = map.getPortal(0);
|
||||
}
|
||||
@@ -4814,7 +4814,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
if (map == null || map.getId() == 610020000 || map.getId() == 610020001) {
|
||||
ps.setInt(24, 0);
|
||||
} else {
|
||||
MaplePortal closest = map.findClosestSpawnpoint(getPosition());
|
||||
MaplePortal closest = map.findClosestPlayerSpawnpoint(getPosition());
|
||||
if (closest != null) {
|
||||
ps.setInt(24, closest.getId());
|
||||
} else {
|
||||
|
||||
@@ -72,6 +72,7 @@ import server.maps.MapleMap;
|
||||
import server.maps.MapleMapItem;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.MapleMapObjectType;
|
||||
import server.maps.MapleReactor;
|
||||
import server.quest.MapleQuest;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
@@ -104,7 +105,10 @@ import constants.skills.Cleric;
|
||||
import constants.skills.Priest;
|
||||
import constants.skills.Spearman;
|
||||
import java.util.ArrayList;
|
||||
import server.life.SpawnPoint;
|
||||
import server.maps.FieldLimit;
|
||||
import server.movement.LifeMovementFragment;
|
||||
import server.movement.TeleportMovement;
|
||||
|
||||
public class Commands {
|
||||
private static HashMap<String, Integer> gotomaps = new HashMap<String, Integer>();
|
||||
@@ -328,6 +332,10 @@ public class Commands {
|
||||
equip.setMdef(stat);
|
||||
equip.setHp(stat);
|
||||
equip.setMp(stat);
|
||||
|
||||
byte flag = equip.getFlag();
|
||||
flag |= ItemConstants.UNTRADEABLE;
|
||||
equip.setFlag(flag);
|
||||
}
|
||||
|
||||
public static boolean executePlayerCommand(MapleClient c, String[] sub, char heading) {
|
||||
@@ -673,6 +681,22 @@ public class Commands {
|
||||
break;
|
||||
|
||||
//debug only
|
||||
case "debugnearestportal":
|
||||
if(ServerConstants.USE_DEBUG) {
|
||||
MaplePortal portal = player.getMap().findClosestPortal(player.getPosition());
|
||||
if(portal != null) player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + portal.getPortalState() + ".");
|
||||
else player.dropMessage(6, "There is no portal on this map.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "debugnearestspawnpoint":
|
||||
if(ServerConstants.USE_DEBUG) {
|
||||
SpawnPoint sp = player.getMap().findClosestSpawnpoint(player.getPosition());
|
||||
if(sp != null) player.dropMessage(6, "Closest spawn point: " + " Position: x " + sp.getPosition().getX() + " y " + sp.getPosition().getY() + " Spawns mobid: '" + ((sp.getMonster() != null) ? sp.getMonster().getId() : "null") + "' --> canSpawn: " + !sp.getDenySpawn() + " canSpawnRightNow: " + sp.shouldSpawn() + ".");
|
||||
else player.dropMessage(6, "There is no mob spawn point on this map.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "debugpos":
|
||||
if(ServerConstants.USE_DEBUG) {
|
||||
player.dropMessage(6, "Current map position: (" + player.getPosition().getX() + ", " + player.getPosition().getY() + ").");
|
||||
@@ -681,7 +705,7 @@ public class Commands {
|
||||
|
||||
case "debugmap":
|
||||
if(ServerConstants.USE_DEBUG) {
|
||||
player.dropMessage(6, "Current map id " + player.getMap().getId() + ", event: '" + ((player.getMap().getEventInstance() != null) ? player.getMap().getEventInstance().getName() : "null") + "'; Players: " + player.getMap().getAllPlayers().size() + ", Mobs: " + player.getMap().countMonsters() + ", Reactors: " + player.getMap().countReactors() + ".");
|
||||
player.dropMessage(6, "Current map id " + player.getMap().getId() + ", event: '" + ((player.getMap().getEventInstance() != null) ? player.getMap().getEventInstance().getName() : "null") + "'; Players: " + player.getMap().getAllPlayers().size() + ", Mobs: " + player.getMap().countMonsters() + ", Reactors: " + player.getMap().countReactors() + ", Items: " + player.getMap().countItems() + ".");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -695,8 +719,10 @@ public class Commands {
|
||||
case "debugreactors":
|
||||
if(ServerConstants.USE_DEBUG) {
|
||||
player.dropMessage(6, "Current reactor states on map " + player.getMapId() + ":");
|
||||
for(Pair p: player.getMap().reportReactorStates()) {
|
||||
player.dropMessage(6, "Reactor id: " + p.getLeft() + " -> State: " + p.getRight() + ".");
|
||||
|
||||
for(MapleMapObject mmo: player.getMap().getReactors()) {
|
||||
MapleReactor mr = (MapleReactor) mmo;
|
||||
player.dropMessage(6, "Reactor id: " + mr.getId() + " name: '" + mr.getName() + "' -> Type: " + mr.getReactorType() + " State: " + mr.getState() + " Event State: " + mr.getEventState() + " Position: x " + mr.getPosition().getX() + " y " + mr.getPosition().getY() + ".");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -863,6 +889,11 @@ public class Commands {
|
||||
eu.setInt(incval);
|
||||
eu.setStr(incval);
|
||||
eu.setLuk(incval);
|
||||
|
||||
byte flag = eu.getFlag();
|
||||
flag |= ItemConstants.UNTRADEABLE;
|
||||
eu.setFlag(flag);
|
||||
|
||||
player.forceUpdateItem(eu);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -904,7 +935,7 @@ public class Commands {
|
||||
player.getMap().setMuted(true);
|
||||
player.dropMessage(5, "The map you are in has been muted.");
|
||||
}
|
||||
} else if (sub[0].equals("checkdmg")) {
|
||||
} else if (sub[0].equals("checkdmg")) {
|
||||
MapleCharacter victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
|
||||
int maxBase = victim.calculateMaxBaseDamage(victim.getTotalWatk());
|
||||
Integer watkBuff = victim.getBuffedValue(MapleBuffStat.WATK);
|
||||
|
||||
@@ -460,6 +460,10 @@ public class Equip extends Item {
|
||||
}
|
||||
|
||||
private double normalizedMasteryExp(int reqLevel) {
|
||||
// Trivia: at equips requiring level 200, one gaining MAX INTEGER exp points will have their equip
|
||||
// exp gain normalized to roughly 5.752 points (1/3 of the needed to pass the equipment to lvl 2)!
|
||||
// Good thing there is not much lvl 140+ equipments in the game!
|
||||
|
||||
return Math.max((2622.71 * Math.exp(reqLevel * 0.0733649)) - 6000.0, 15);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ public abstract class AbstractMovementPacketHandler extends AbstractMaplePacketH
|
||||
case 12:
|
||||
case 13: // Shot-jump-back thing
|
||||
case 16: // Float
|
||||
case 18:
|
||||
case 19: // Springs on maps
|
||||
case 18:
|
||||
case 19: // Springs on maps
|
||||
case 20: // Aran Combat Step
|
||||
case 22: {
|
||||
case 22: {
|
||||
short xpos = lea.readShort();
|
||||
short ypos = lea.readShort();
|
||||
byte newstate = lea.readByte();
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractMovementPacketHandler extends AbstractMaplePacketH
|
||||
case 7: // assaulter
|
||||
case 8: // assassinate
|
||||
case 9: // rush
|
||||
case 11: //chair
|
||||
case 11: //chair
|
||||
{
|
||||
// case 14: {
|
||||
short xpos = lea.readShort();
|
||||
@@ -138,7 +138,7 @@ public abstract class AbstractMovementPacketHandler extends AbstractMaplePacketH
|
||||
break;
|
||||
}
|
||||
default:
|
||||
System.out.println("Unhandled Case:" + command);
|
||||
System.out.println("Unhandled Case:" + command);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class GeneralChatHandler extends net.AbstractMaplePacketHandler {
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
||||
FilePrinter.print(FilePrinter.USED_COMMANDS + ".txt", c.getPlayer().getName() + " used: " + heading + command + "on " + sdf.format(Calendar.getInstance().getTime()) + "\r\n");
|
||||
FilePrinter.print(FilePrinter.USED_COMMANDS, c.getPlayer().getName() + " used: " + heading + command + "on " + sdf.format(Calendar.getInstance().getTime()) + "\r\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -411,7 +411,7 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
|
||||
if (c.getChannelServer().getMapFactory().getMap(victim.getMapId()).getForcedReturnId() == 999999999 || victim.getMapId() < 100000000) {
|
||||
if (victim.gmLevel() <= player.gmLevel()) {
|
||||
if (itemId == 5041000 || victim.getMapId() / player.getMapId() == 1) { //viprock & same continent
|
||||
player.changeMap(target, target.findClosestSpawnpoint(victim.getPosition()));
|
||||
player.changeMap(target, target.findClosestPlayerSpawnpoint(victim.getPosition()));
|
||||
success = true;
|
||||
} else {
|
||||
player.dropMessage(1, "You cannot teleport between continents with this teleport rock.");
|
||||
|
||||
@@ -88,9 +88,10 @@ public class AbstractPlayerInteraction {
|
||||
public MapleMap getMap() {
|
||||
return c.getPlayer().getMap();
|
||||
}
|
||||
|
||||
public void warp(int map) {
|
||||
getPlayer().changeMap(map, 0);
|
||||
|
||||
public void warp(int mapid) {
|
||||
MapleMap map = getWarpMap(mapid);
|
||||
getPlayer().changeMap(map, map.getRandomPlayerSpawnpoint());
|
||||
}
|
||||
|
||||
public void warp(int map, int portal) {
|
||||
|
||||
@@ -43,12 +43,15 @@ import net.server.world.MaplePartyCharacter;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import server.MaplePortal;
|
||||
import server.TimerManager;
|
||||
import server.MapleStatEffect;
|
||||
import server.expeditions.MapleExpedition;
|
||||
import server.life.MapleMonster;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleMapFactory;
|
||||
import tools.DatabaseConnection;
|
||||
import client.MapleCharacter;
|
||||
import client.SkillFactory;
|
||||
import client.Skill;
|
||||
import constants.ItemConstants;
|
||||
import constants.ServerConstants;
|
||||
import java.awt.Point;
|
||||
@@ -56,6 +59,7 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.life.MapleLifeFactory;
|
||||
import server.life.MapleNPC;
|
||||
import tools.MaplePacketCreator;
|
||||
@@ -113,6 +117,35 @@ public class EventInstanceManager {
|
||||
return em;
|
||||
}
|
||||
|
||||
public void applyEventPlayersItemBuff(int itemId) {
|
||||
List<MapleCharacter> players = getPlayerList();
|
||||
MapleStatEffect mse = MapleItemInformationProvider.getInstance().getItemEffect(itemId);
|
||||
|
||||
if(mse != null) {
|
||||
for (MapleCharacter player: players) {
|
||||
mse.applyTo(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEventPlayersSkillBuff(int skillId) {
|
||||
applyEventPlayersSkillBuff(skillId, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void applyEventPlayersSkillBuff(int skillId, int skillLv) {
|
||||
List<MapleCharacter> players = getPlayerList();
|
||||
Skill skill = SkillFactory.getSkill(skillId);
|
||||
|
||||
if(skill != null) {
|
||||
MapleStatEffect mse = skill.getEffect(Math.min(skillLv, skill.getMaxLevel()));
|
||||
if(mse != null) {
|
||||
for (MapleCharacter player: players) {
|
||||
mse.applyTo(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveEventPlayersExp(int gain) {
|
||||
giveEventPlayersExp(gain, -1);
|
||||
}
|
||||
@@ -193,6 +226,7 @@ public class EventInstanceManager {
|
||||
timeStarted = System.currentTimeMillis();
|
||||
eventTime = time;
|
||||
|
||||
for(MapleCharacter chr: getPlayers()) chr.announce(MaplePacketCreator.getClock((int) (time / 1000)));
|
||||
event_schedule = TimerManager.getInstance().schedule(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@@ -496,6 +530,14 @@ public class EventInstanceManager {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setIntProperty(String key, Integer value) {
|
||||
setProperty(key, value);
|
||||
}
|
||||
|
||||
public void setProperty(String key, Integer value) {
|
||||
setProperty(key, "" + value);
|
||||
}
|
||||
|
||||
public void setProperty(String key, String value) {
|
||||
props.setProperty(key, value);
|
||||
}
|
||||
@@ -512,8 +554,12 @@ public class EventInstanceManager {
|
||||
return props;
|
||||
}
|
||||
|
||||
public int getIntProperty(String key) {
|
||||
return Integer.parseInt(props.getProperty(key));
|
||||
public Integer getIntProperty(String key) {
|
||||
try {
|
||||
return Integer.parseInt(props.getProperty(key));
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void leftParty(MapleCharacter chr) {
|
||||
@@ -811,6 +857,23 @@ public class EventInstanceManager {
|
||||
}
|
||||
}
|
||||
|
||||
public final void warpEventTeamToMapSpawnPoint(int warpFrom, int warpTo, int toSp) {
|
||||
List<MapleCharacter> players = getPlayerList();
|
||||
|
||||
for (MapleCharacter chr : players) {
|
||||
if(chr.getMapId() == warpFrom)
|
||||
chr.changeMap(warpTo, toSp);
|
||||
}
|
||||
}
|
||||
|
||||
public final void warpEventTeamToMapSpawnPoint(int warpTo, int toSp) {
|
||||
List<MapleCharacter> players = getPlayerList();
|
||||
|
||||
for (MapleCharacter chr : players) {
|
||||
chr.changeMap(warpTo, toSp);
|
||||
}
|
||||
}
|
||||
|
||||
public final MapleCharacter getLeader() {
|
||||
rL.lock();
|
||||
try {
|
||||
|
||||
@@ -272,6 +272,7 @@ public class EventManager {
|
||||
|
||||
eim.registerExpedition(exped);
|
||||
exped.start();
|
||||
iv.invokeFunction("afterSetup", eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -303,6 +304,7 @@ public class EventManager {
|
||||
instanceLocks.put(eim.getName(), lobbyId);
|
||||
|
||||
eim.registerPlayer(chr);
|
||||
iv.invokeFunction("afterSetup", eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -335,6 +337,7 @@ public class EventManager {
|
||||
|
||||
eim.registerParty(party, map);
|
||||
party.setEligibleMembers(null);
|
||||
iv.invokeFunction("afterSetup", eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -367,6 +370,7 @@ public class EventManager {
|
||||
|
||||
eim.registerParty(party, map);
|
||||
party.setEligibleMembers(null);
|
||||
iv.invokeFunction("afterSetup", eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -398,6 +402,7 @@ public class EventManager {
|
||||
|
||||
iv.invokeFunction("setup", eim);
|
||||
eim.setProperty("leader", leader);
|
||||
iv.invokeFunction("afterSetup", eim);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
} else {
|
||||
drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
|
||||
}
|
||||
reactor.getMap().spawnItemDrop(reactor, getPlayer(), drop, reactor.getMap().calcDropPos(dropPos, reactor.getPosition()), false, false);
|
||||
reactor.getMap().spawnItemDrop(reactor, getPlayer(), drop, reactor.getMap().calcDropPos(dropPos, reactor.getPosition()), (byte)(getPlayer().getParty() != null ? 1 : 0), false);
|
||||
}
|
||||
dropPos.x += 25;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
spawnMonster(id, qty, new Point(x, y));
|
||||
}
|
||||
|
||||
private void spawnMonster(int id, int qty, Point pos) {
|
||||
public void spawnMonster(int id, int qty, Point pos) {
|
||||
for (int i = 0; i < qty; i++) {
|
||||
reactor.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(id), pos);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class MapleGenericPortal implements MaplePortal {
|
||||
} 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
|
||||
if (pto == null) {// fallback for missing portals - no real life case anymore - interesting 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
|
||||
|
||||
+103
-55
@@ -45,6 +45,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
@@ -530,16 +531,6 @@ public class MapleMap {
|
||||
return count;
|
||||
}
|
||||
|
||||
public List<Pair> reportReactorStates() {
|
||||
List<Pair> list = new LinkedList<>();
|
||||
|
||||
for (MapleMapObject m : getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.REACTOR))) {
|
||||
MapleReactor mr = (MapleReactor) m;
|
||||
list.add(new Pair(mr.getId(), mr.getState()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public int countMonsters() {
|
||||
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER)).size();
|
||||
}
|
||||
@@ -551,6 +542,14 @@ public class MapleMap {
|
||||
public final List<MapleMapObject> getReactors() {
|
||||
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.REACTOR));
|
||||
}
|
||||
|
||||
public int countItems() {
|
||||
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM)).size();
|
||||
}
|
||||
|
||||
public final List<MapleMapObject> getItems() {
|
||||
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
|
||||
}
|
||||
|
||||
public boolean damageMonster(final MapleCharacter chr, final MapleMonster monster, final int damage) {
|
||||
if (monster.getId() == 8800000) {
|
||||
@@ -886,22 +885,6 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public MapleReactor getReactorById(int Id) {
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapleMapObject obj : mapobjects.values()) {
|
||||
if (obj.getType() == MapleMapObjectType.REACTOR) {
|
||||
if (((MapleReactor) obj).getId() == Id) {
|
||||
return (MapleReactor) obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
objectRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automagically finds a new controller for the given monster from the chars
|
||||
* on the map...
|
||||
@@ -1002,6 +985,22 @@ public class MapleMap {
|
||||
MapleMapObject mmo = getMapObject(oid);
|
||||
return (mmo != null && mmo.getType() == MapleMapObjectType.REACTOR) ? (MapleReactor) mmo : null;
|
||||
}
|
||||
|
||||
public MapleReactor getReactorById(int Id) {
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapleMapObject obj : mapobjects.values()) {
|
||||
if (obj.getType() == MapleMapObjectType.REACTOR) {
|
||||
if (((MapleReactor) obj).getId() == Id) {
|
||||
return (MapleReactor) obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
objectRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public MapleReactor getReactorByName(String name) {
|
||||
objectRLock.lock();
|
||||
@@ -1327,10 +1326,14 @@ public class MapleMap {
|
||||
}
|
||||
}, duration);
|
||||
}
|
||||
|
||||
|
||||
public final void spawnItemDrop(final MapleMapObject dropper, final MapleCharacter owner, final Item item, Point pos, final boolean ffaDrop, final boolean playerDrop) {
|
||||
spawnItemDrop(dropper, owner, item, pos, (byte)(ffaDrop ? 2 : 0), playerDrop);
|
||||
}
|
||||
|
||||
public final void spawnItemDrop(final MapleMapObject dropper, final MapleCharacter owner, final Item item, Point pos, final byte dropType, final boolean playerDrop) {
|
||||
final Point droppos = calcDropPos(pos, pos);
|
||||
final MapleMapItem drop = new MapleMapItem(item, droppos, dropper, owner, (byte) (ffaDrop ? 2 : 0), playerDrop);
|
||||
final MapleMapItem drop = new MapleMapItem(item, droppos, dropper, owner, dropType, playerDrop);
|
||||
drop.setDropTime(System.currentTimeMillis());
|
||||
|
||||
spawnAndAddRangedMapObject(drop, new DelayedPacketCreation() {
|
||||
@@ -1396,7 +1399,7 @@ public class MapleMap {
|
||||
final MapleReactor react = (MapleReactor) o;
|
||||
|
||||
if (react.getReactorType() == 100) {
|
||||
if (react.getReactItem((byte) 0).getLeft() == item.getItemId() && react.getReactItem((byte) 0).getRight() == item.getQuantity()) {
|
||||
if (react.getReactItem(react.getEventState()).getLeft() == item.getItemId() && react.getReactItem(react.getEventState()).getRight() == item.getQuantity()) {
|
||||
|
||||
if (react.getArea().contains(drop.getPosition())) {
|
||||
TimerManager.getInstance().schedule(new ActivateItemReactor(drop, react, c), 5000);
|
||||
@@ -1634,6 +1637,30 @@ public class MapleMap {
|
||||
chr.receivePartyMemberHP();
|
||||
}
|
||||
|
||||
public MaplePortal getRandomPlayerSpawnpoint() {
|
||||
List<MaplePortal> spawnPoints = new ArrayList<>();
|
||||
for (MaplePortal portal : portals.values()) {
|
||||
if (portal.getType() >= 0 && portal.getType() <= 2) {
|
||||
spawnPoints.add(portal);
|
||||
}
|
||||
}
|
||||
MaplePortal portal = spawnPoints.get(new Random().nextInt(spawnPoints.size()));
|
||||
return portal != null ? portal : getPortal(0);
|
||||
}
|
||||
|
||||
public MaplePortal findClosestPlayerSpawnpoint(Point from) {
|
||||
MaplePortal closest = null;
|
||||
double shortestDistance = Double.POSITIVE_INFINITY;
|
||||
for (MaplePortal portal : portals.values()) {
|
||||
double distance = portal.getPosition().distanceSq(from);
|
||||
if (portal.getType() >= 0 && portal.getType() <= 2 && distance < shortestDistance && portal.getTargetMapId() == 999999999) {
|
||||
closest = portal;
|
||||
shortestDistance = distance;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
public MaplePortal findClosestPortal(Point from) {
|
||||
MaplePortal closest = null;
|
||||
double shortestDistance = Double.POSITIVE_INFINITY;
|
||||
@@ -1647,15 +1674,8 @@ public class MapleMap {
|
||||
return closest;
|
||||
}
|
||||
|
||||
public MaplePortal getRandomSpawnpoint() {
|
||||
List<MaplePortal> spawnPoints = new ArrayList<>();
|
||||
for (MaplePortal portal : portals.values()) {
|
||||
if (portal.getType() >= 0 && portal.getType() <= 2) {
|
||||
spawnPoints.add(portal);
|
||||
}
|
||||
}
|
||||
MaplePortal portal = spawnPoints.get(new Random().nextInt(spawnPoints.size()));
|
||||
return portal != null ? portal : getPortal(0);
|
||||
public Collection<MaplePortal> getPortals() {
|
||||
return Collections.unmodifiableCollection(portals.values());
|
||||
}
|
||||
|
||||
public void removePlayer(MapleCharacter chr) {
|
||||
@@ -2003,23 +2023,6 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public MaplePortal findClosestSpawnpoint(Point from) {
|
||||
MaplePortal closest = null;
|
||||
double shortestDistance = Double.POSITIVE_INFINITY;
|
||||
for (MaplePortal portal : portals.values()) {
|
||||
double distance = portal.getPosition().distanceSq(from);
|
||||
if (portal.getType() >= 0 && portal.getType() <= 2 && distance < shortestDistance && portal.getTargetMapId() == 999999999) {
|
||||
closest = portal;
|
||||
shortestDistance = distance;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
public Collection<MaplePortal> getPortals() {
|
||||
return Collections.unmodifiableCollection(portals.values());
|
||||
}
|
||||
|
||||
public String getMapName() {
|
||||
return mapName;
|
||||
}
|
||||
@@ -2244,6 +2247,19 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SpawnPoint findClosestSpawnpoint(Point from) {
|
||||
SpawnPoint closest = null;
|
||||
double shortestDistance = Double.POSITIVE_INFINITY;
|
||||
for (SpawnPoint sp : monsterSpawn) {
|
||||
double distance = sp.getPosition().distanceSq(from);
|
||||
if (distance < shortestDistance) {
|
||||
closest = sp;
|
||||
shortestDistance = distance;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
public void respawn() {
|
||||
if(!allowSummons) return;
|
||||
@@ -2284,6 +2300,38 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final int getNumPlayersInArea(final int index) {
|
||||
return getNumPlayersInRect(getArea(index));
|
||||
}
|
||||
|
||||
public final int getNumPlayersInRect(final Rectangle rect) {
|
||||
int ret = 0;
|
||||
|
||||
chrRLock.lock();
|
||||
try {
|
||||
final Iterator<MapleCharacter> ltr = characters.iterator();
|
||||
while (ltr.hasNext()) {
|
||||
if (rect.contains(ltr.next().getPosition())) {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
chrRLock.unlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final int getNumPlayersItemsInArea(final int index) {
|
||||
return getNumPlayersItemsInRect(getArea(index));
|
||||
}
|
||||
|
||||
public final int getNumPlayersItemsInRect(final Rectangle rect) {
|
||||
int retP = getNumPlayersInRect(rect);
|
||||
int retI = getMapObjectsInBox(rect, Arrays.asList(MapleMapObjectType.ITEM)).size();
|
||||
|
||||
return retP + retI;
|
||||
}
|
||||
|
||||
private static interface DelayedPacketCreation {
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class MapleReactor extends AbstractMapleMapObject {
|
||||
private int rid;
|
||||
private MapleReactorStats stats;
|
||||
private byte state;
|
||||
private byte evstate;
|
||||
private int delay;
|
||||
private MapleMap map;
|
||||
private String name;
|
||||
@@ -51,6 +52,7 @@ public class MapleReactor extends AbstractMapleMapObject {
|
||||
private Lock reactorLock = new ReentrantLock(true);
|
||||
|
||||
public MapleReactor(MapleReactorStats stats, int rid) {
|
||||
this.evstate = (byte)0;
|
||||
this.stats = stats;
|
||||
this.rid = rid;
|
||||
alive = true;
|
||||
@@ -75,11 +77,19 @@ public class MapleReactor extends AbstractMapleMapObject {
|
||||
public void setState(byte state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
public byte getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setEventState(byte substate) {
|
||||
this.evstate = substate;
|
||||
}
|
||||
|
||||
public byte getEventState() {
|
||||
return evstate;
|
||||
}
|
||||
|
||||
public MapleReactorStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user