Rename and clean up MapleReactor
This commit is contained in:
@@ -32,8 +32,8 @@ import server.life.Monster;
|
|||||||
import server.life.SpawnPoint;
|
import server.life.SpawnPoint;
|
||||||
import server.maps.MapObject;
|
import server.maps.MapObject;
|
||||||
import server.maps.MapObjectType;
|
import server.maps.MapObjectType;
|
||||||
import server.maps.MapleReactor;
|
|
||||||
import server.maps.Portal;
|
import server.maps.Portal;
|
||||||
|
import server.maps.Reactor;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -124,7 +124,7 @@ public class DebugCommand extends Command {
|
|||||||
player.dropMessage(6, "Current reactor states on map " + player.getMapId() + ":");
|
player.dropMessage(6, "Current reactor states on map " + player.getMapId() + ":");
|
||||||
|
|
||||||
for (MapObject mmo : player.getMap().getReactors()) {
|
for (MapObject mmo : player.getMap().getReactors()) {
|
||||||
MapleReactor mr = (MapleReactor) mmo;
|
Reactor mr = (Reactor) mmo;
|
||||||
player.dropMessage(6, "Id: " + mr.getId() + " Oid: " + mr.getObjectId() + " name: '" + mr.getName() + "' -> Type: " + mr.getReactorType() + " State: " + mr.getState() + " Event State: " + mr.getEventState() + " Position: x " + mr.getPosition().getX() + " y " + mr.getPosition().getY() + ".");
|
player.dropMessage(6, "Id: " + mr.getId() + " Oid: " + mr.getObjectId() + " name: '" + mr.getName() + "' -> Type: " + mr.getReactorType() + " State: " + mr.getState() + " Event State: " + mr.getEventState() + " Position: x " + mr.getPosition().getX() + " y " + mr.getPosition().getY() + ".");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package net.server.channel.handlers;
|
|||||||
import client.Client;
|
import client.Client;
|
||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapleReactor;
|
import server.maps.Reactor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lerk
|
* @author Lerk
|
||||||
@@ -40,7 +40,7 @@ public final class ReactorHitHandler extends AbstractPacketHandler {
|
|||||||
short stance = p.readShort();
|
short stance = p.readShort();
|
||||||
p.skip(4);
|
p.skip(4);
|
||||||
int skillid = p.readInt();
|
int skillid = p.readInt();
|
||||||
MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
Reactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
||||||
if (reactor != null) {
|
if (reactor != null) {
|
||||||
reactor.hitReactor(true, charPos, stance, skillid, c);
|
reactor.hitReactor(true, charPos, stance, skillid, c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import client.Client;
|
|||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import scripting.reactor.ReactorScriptManager;
|
import scripting.reactor.ReactorScriptManager;
|
||||||
import server.maps.MapleReactor;
|
import server.maps.Reactor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -36,7 +36,7 @@ public final class TouchReactorHandler extends AbstractPacketHandler {
|
|||||||
@Override
|
@Override
|
||||||
public final void handlePacket(InPacket p, Client c) {
|
public final void handlePacket(InPacket p, Client c) {
|
||||||
int oid = p.readInt();
|
int oid = p.readInt();
|
||||||
MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
Reactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
||||||
if (reactor != null) {
|
if (reactor != null) {
|
||||||
if (p.readByte() != 0) {
|
if (p.readByte() != 0) {
|
||||||
ReactorScriptManager.getInstance().touch(c, reactor);
|
ReactorScriptManager.getInstance().touch(c, reactor);
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ import server.life.Monster;
|
|||||||
import server.life.NPC;
|
import server.life.NPC;
|
||||||
import server.maps.MapManager;
|
import server.maps.MapManager;
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
import server.maps.MapleReactor;
|
|
||||||
import server.maps.Portal;
|
import server.maps.Portal;
|
||||||
|
import server.maps.Reactor;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
|
|
||||||
@@ -1350,7 +1350,7 @@ public class EventInstanceManager {
|
|||||||
public boolean activatedAllReactorsOnMap(MapleMap map, int minReactorId, int maxReactorId) {
|
public boolean activatedAllReactorsOnMap(MapleMap map, int minReactorId, int maxReactorId) {
|
||||||
if(map == null) return true;
|
if(map == null) return true;
|
||||||
|
|
||||||
for(MapleReactor mr : map.getReactorsByIdRange(minReactorId, maxReactorId)) {
|
for(Reactor mr : map.getReactorsByIdRange(minReactorId, maxReactorId)) {
|
||||||
if(mr.getReactorType() != -1) {
|
if(mr.getReactorType() != -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import server.life.LifeFactory;
|
|||||||
import server.life.Monster;
|
import server.life.Monster;
|
||||||
import server.maps.MapMonitor;
|
import server.maps.MapMonitor;
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
import server.maps.MapleReactor;
|
import server.maps.Reactor;
|
||||||
import server.maps.ReactorDropEntry;
|
import server.maps.ReactorDropEntry;
|
||||||
import server.partyquest.MapleCarnivalFactory;
|
import server.partyquest.MapleCarnivalFactory;
|
||||||
import server.partyquest.MapleCarnivalFactory.MCSkill;
|
import server.partyquest.MapleCarnivalFactory.MCSkill;
|
||||||
@@ -53,11 +53,11 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class ReactorActionManager extends AbstractPlayerInteraction {
|
public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||||
private final MapleReactor reactor;
|
private final Reactor reactor;
|
||||||
private final Invocable iv;
|
private final Invocable iv;
|
||||||
private ScheduledFuture<?> sprayTask = null;
|
private ScheduledFuture<?> sprayTask = null;
|
||||||
|
|
||||||
public ReactorActionManager(Client c, MapleReactor reactor, Invocable iv) {
|
public ReactorActionManager(Client c, Reactor reactor, Invocable iv) {
|
||||||
super(c);
|
super(c);
|
||||||
this.reactor = reactor;
|
this.reactor = reactor;
|
||||||
this.iv = iv;
|
this.iv = iv;
|
||||||
@@ -185,7 +185,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final MapleReactor r = reactor;
|
final Reactor r = reactor;
|
||||||
final List<ReactorDropEntry> dropItems = items;
|
final List<ReactorDropEntry> dropItems = items;
|
||||||
final int worldMesoRate = c.getWorldServer().getMesoRate();
|
final int worldMesoRate = c.getWorldServer().getMesoRate();
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleReactor getReactor() {
|
public Reactor getReactor() {
|
||||||
return reactor;
|
return reactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ package scripting.reactor;
|
|||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import scripting.AbstractScriptManager;
|
import scripting.AbstractScriptManager;
|
||||||
import server.maps.MapleReactor;
|
import server.maps.Reactor;
|
||||||
import server.maps.ReactorDropEntry;
|
import server.maps.ReactorDropEntry;
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
import tools.FilePrinter;
|
import tools.FilePrinter;
|
||||||
@@ -51,7 +51,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onHit(Client c, MapleReactor reactor) {
|
public void onHit(Client c, Reactor reactor) {
|
||||||
try {
|
try {
|
||||||
Invocable iv = initializeInvocable(c, reactor);
|
Invocable iv = initializeInvocable(c, reactor);
|
||||||
if (iv == null) {
|
if (iv == null) {
|
||||||
@@ -66,7 +66,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void act(Client c, MapleReactor reactor) {
|
public void act(Client c, Reactor reactor) {
|
||||||
try {
|
try {
|
||||||
Invocable iv = initializeInvocable(c, reactor);
|
Invocable iv = initializeInvocable(c, reactor);
|
||||||
if (iv == null) {
|
if (iv == null) {
|
||||||
@@ -104,15 +104,15 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
|||||||
drops.clear();
|
drops.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void touch(Client c, MapleReactor reactor) {
|
public void touch(Client c, Reactor reactor) {
|
||||||
touching(c, reactor, true);
|
touching(c, reactor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void untouch(Client c, MapleReactor reactor) {
|
public void untouch(Client c, Reactor reactor) {
|
||||||
touching(c, reactor, false);
|
touching(c, reactor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void touching(Client c, MapleReactor reactor, boolean touching) {
|
private void touching(Client c, Reactor reactor, boolean touching) {
|
||||||
try {
|
try {
|
||||||
Invocable iv = initializeInvocable(c, reactor);
|
Invocable iv = initializeInvocable(c, reactor);
|
||||||
if (iv == null) {
|
if (iv == null) {
|
||||||
@@ -129,7 +129,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Invocable initializeInvocable(Client c, MapleReactor reactor) {
|
private Invocable initializeInvocable(Client c, Reactor reactor) {
|
||||||
ScriptEngine engine = getInvocableScriptEngine("reactor/" + reactor.getId() + ".js", c);
|
ScriptEngine engine = getInvocableScriptEngine("reactor/" + reactor.getId() + ".js", c);
|
||||||
if (engine == null) {
|
if (engine == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ public class MapFactory {
|
|||||||
for (Data reactor : mapData.getChildByPath("reactor")) {
|
for (Data reactor : mapData.getChildByPath("reactor")) {
|
||||||
String id = DataTool.getString(reactor.getChildByPath("id"));
|
String id = DataTool.getString(reactor.getChildByPath("id"));
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
MapleReactor newReactor = loadReactor(reactor, id, (byte) DataTool.getInt(reactor.getChildByPath("f"), 0));
|
Reactor newReactor = loadReactor(reactor, id, (byte) DataTool.getInt(reactor.getChildByPath("f"), 0));
|
||||||
map.spawnReactor(newReactor);
|
map.spawnReactor(newReactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,8 +351,8 @@ public class MapFactory {
|
|||||||
return myLife;
|
return myLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MapleReactor loadReactor(Data reactor, String id, final byte FacingDirection) {
|
private static Reactor loadReactor(Data reactor, String id, final byte FacingDirection) {
|
||||||
MapleReactor myReactor = new MapleReactor(MapleReactorFactory.getReactor(Integer.parseInt(id)), Integer.parseInt(id));
|
Reactor myReactor = new Reactor(MapleReactorFactory.getReactor(Integer.parseInt(id)), Integer.parseInt(id));
|
||||||
int x = DataTool.getInt(reactor.getChildByPath("x"));
|
int x = DataTool.getInt(reactor.getChildByPath("x"));
|
||||||
int y = DataTool.getInt(reactor.getChildByPath("y"));
|
int y = DataTool.getInt(reactor.getChildByPath("y"));
|
||||||
myReactor.setFacingDirection(FacingDirection);
|
myReactor.setFacingDirection(FacingDirection);
|
||||||
|
|||||||
@@ -297,12 +297,12 @@ public class MapleMap {
|
|||||||
public void setReactorState() {
|
public void setReactorState() {
|
||||||
for (MapObject o : getMapObjects()) {
|
for (MapObject o : getMapObjects()) {
|
||||||
if (o.getType() == MapObjectType.REACTOR) {
|
if (o.getType() == MapObjectType.REACTOR) {
|
||||||
if (((MapleReactor) o).getState() < 1) {
|
if (((Reactor) o).getState() < 1) {
|
||||||
MapleReactor mr = (MapleReactor) o;
|
Reactor mr = (Reactor) o;
|
||||||
mr.lockReactor();
|
mr.lockReactor();
|
||||||
try {
|
try {
|
||||||
mr.resetReactorActions(1);
|
mr.resetReactorActions(1);
|
||||||
broadcastMessage(PacketCreator.triggerReactor((MapleReactor) o, 1));
|
broadcastMessage(PacketCreator.triggerReactor((Reactor) o, 1));
|
||||||
} finally {
|
} finally {
|
||||||
mr.unlockReactor();
|
mr.unlockReactor();
|
||||||
}
|
}
|
||||||
@@ -312,11 +312,11 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void limitReactor(final int rid, final int num) {
|
public final void limitReactor(final int rid, final int num) {
|
||||||
List<MapleReactor> toDestroy = new ArrayList<>();
|
List<Reactor> toDestroy = new ArrayList<>();
|
||||||
Map<Integer, Integer> contained = new LinkedHashMap<>();
|
Map<Integer, Integer> contained = new LinkedHashMap<>();
|
||||||
|
|
||||||
for (MapObject obj : getReactors()) {
|
for (MapObject obj : getReactors()) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
if (contained.containsKey(mr.getId())) {
|
if (contained.containsKey(mr.getId())) {
|
||||||
if (contained.get(mr.getId()) >= num) {
|
if (contained.get(mr.getId()) >= num) {
|
||||||
toDestroy.add(mr);
|
toDestroy.add(mr);
|
||||||
@@ -328,14 +328,14 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MapleReactor mr : toDestroy) {
|
for (Reactor mr : toDestroy) {
|
||||||
destroyReactor(mr.getObjectId());
|
destroyReactor(mr.getObjectId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllReactorState(final int reactorId, final int state) {
|
public boolean isAllReactorState(final int reactorId, final int state) {
|
||||||
for (MapObject mo : getReactors()) {
|
for (MapObject mo : getReactors()) {
|
||||||
MapleReactor r = (MapleReactor) mo;
|
Reactor r = (Reactor) mo;
|
||||||
|
|
||||||
if (r.getId() == reactorId && r.getState() != state) {
|
if (r.getId() == reactorId && r.getState() != state) {
|
||||||
return false;
|
return false;
|
||||||
@@ -757,7 +757,7 @@ public class MapleMap {
|
|||||||
dropFromMonster(chr, mob, true);
|
dropFromMonster(chr, mob, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropFromReactor(final Character chr, final MapleReactor reactor, Item drop, Point dropPos, short questid) {
|
public void dropFromReactor(final Character chr, final Reactor reactor, Item drop, Point dropPos, short questid) {
|
||||||
spawnDrop(drop, this.calcDropPos(dropPos, reactor.getPosition()), reactor, chr, (byte) (chr.getParty() != null ? 1 : 0), questid);
|
spawnDrop(drop, this.calcDropPos(dropPos, reactor.getPosition()), reactor, chr, (byte) (chr.getParty() != null ? 1 : 0), questid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1202,10 +1202,10 @@ public class MapleMap {
|
|||||||
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapObjectType.MONSTER));
|
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapObjectType.MONSTER));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<MapleReactor> getAllReactors() {
|
public final List<Reactor> getAllReactors() {
|
||||||
List<MapleReactor> list = new LinkedList<>();
|
List<Reactor> list = new LinkedList<>();
|
||||||
for (MapObject mmo : getReactors()) {
|
for (MapObject mmo : getReactors()) {
|
||||||
list.add((MapleReactor) mmo);
|
list.add((Reactor) mmo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -1535,23 +1535,23 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void destroyReactors(final int first, final int last) {
|
public final void destroyReactors(final int first, final int last) {
|
||||||
List<MapleReactor> toDestroy = new ArrayList<>();
|
List<Reactor> toDestroy = new ArrayList<>();
|
||||||
List<MapObject> reactors = getReactors();
|
List<MapObject> reactors = getReactors();
|
||||||
|
|
||||||
for (MapObject obj : reactors) {
|
for (MapObject obj : reactors) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
if (mr.getId() >= first && mr.getId() <= last) {
|
if (mr.getId() >= first && mr.getId() <= last) {
|
||||||
toDestroy.add(mr);
|
toDestroy.add(mr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MapleReactor mr : toDestroy) {
|
for (Reactor mr : toDestroy) {
|
||||||
destroyReactor(mr.getObjectId());
|
destroyReactor(mr.getObjectId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroyReactor(int oid) {
|
public void destroyReactor(int oid) {
|
||||||
final MapleReactor reactor = getReactorByOid(oid);
|
final Reactor reactor = getReactorByOid(oid);
|
||||||
|
|
||||||
if (reactor != null) {
|
if (reactor != null) {
|
||||||
if (reactor.destroy()) {
|
if (reactor.destroy()) {
|
||||||
@@ -1561,13 +1561,13 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetReactors() {
|
public void resetReactors() {
|
||||||
List<MapleReactor> list = new ArrayList<>();
|
List<Reactor> list = new ArrayList<>();
|
||||||
|
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
for (MapObject o : mapobjects.values()) {
|
for (MapObject o : mapobjects.values()) {
|
||||||
if (o.getType() == MapObjectType.REACTOR) {
|
if (o.getType() == MapObjectType.REACTOR) {
|
||||||
final MapleReactor r = ((MapleReactor) o);
|
final Reactor r = ((Reactor) o);
|
||||||
list.add(r);
|
list.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1578,8 +1578,8 @@ public class MapleMap {
|
|||||||
resetReactors(list);
|
resetReactors(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void resetReactors(List<MapleReactor> list) {
|
public final void resetReactors(List<Reactor> list) {
|
||||||
for (MapleReactor r : list) {
|
for (Reactor r : list) {
|
||||||
if (r.forceDelayedRespawn()) { // thanks Conrad for suggesting reactor with delay respawning immediately
|
if (r.forceDelayedRespawn()) { // thanks Conrad for suggesting reactor with delay respawning immediately
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1621,7 +1621,7 @@ public class MapleMap {
|
|||||||
List<MapObject> targets = new LinkedList<>();
|
List<MapObject> targets = new LinkedList<>();
|
||||||
|
|
||||||
for (MapObject obj : reactors) {
|
for (MapObject obj : reactors) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
if (mr.getId() >= first && mr.getId() <= last) {
|
if (mr.getId() >= first && mr.getId() <= last) {
|
||||||
points.add(mr.getPosition());
|
points.add(mr.getPosition());
|
||||||
targets.add(obj);
|
targets.add(obj);
|
||||||
@@ -1629,7 +1629,7 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
Collections.shuffle(points);
|
Collections.shuffle(points);
|
||||||
for (MapObject obj : targets) {
|
for (MapObject obj : targets) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
mr.setPosition(points.remove(points.size() - 1));
|
mr.setPosition(points.remove(points.size() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1655,14 +1655,14 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MapObject obj : listObjects) {
|
for (MapObject obj : listObjects) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
|
|
||||||
points.add(mr.getPosition());
|
points.add(mr.getPosition());
|
||||||
targets.add(obj);
|
targets.add(obj);
|
||||||
}
|
}
|
||||||
Collections.shuffle(points);
|
Collections.shuffle(points);
|
||||||
for (MapObject obj : targets) {
|
for (MapObject obj : targets) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
mr.setPosition(points.remove(points.size() - 1));
|
mr.setPosition(points.remove(points.size() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1755,18 +1755,18 @@ public class MapleMap {
|
|||||||
return (mmo != null && mmo.getType() == MapObjectType.MONSTER) ? (Monster) mmo : null;
|
return (mmo != null && mmo.getType() == MapObjectType.MONSTER) ? (Monster) mmo : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleReactor getReactorByOid(int oid) {
|
public Reactor getReactorByOid(int oid) {
|
||||||
MapObject mmo = getMapObject(oid);
|
MapObject mmo = getMapObject(oid);
|
||||||
return (mmo != null && mmo.getType() == MapObjectType.REACTOR) ? (MapleReactor) mmo : null;
|
return (mmo != null && mmo.getType() == MapObjectType.REACTOR) ? (Reactor) mmo : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleReactor getReactorById(int Id) {
|
public Reactor getReactorById(int Id) {
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
for (MapObject obj : mapobjects.values()) {
|
for (MapObject obj : mapobjects.values()) {
|
||||||
if (obj.getType() == MapObjectType.REACTOR) {
|
if (obj.getType() == MapObjectType.REACTOR) {
|
||||||
if (((MapleReactor) obj).getId() == Id) {
|
if (((Reactor) obj).getId() == Id) {
|
||||||
return (MapleReactor) obj;
|
return (Reactor) obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1776,14 +1776,14 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MapleReactor> getReactorsByIdRange(final int first, final int last) {
|
public List<Reactor> getReactorsByIdRange(final int first, final int last) {
|
||||||
List<MapleReactor> list = new LinkedList<>();
|
List<Reactor> list = new LinkedList<>();
|
||||||
|
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
for (MapObject obj : mapobjects.values()) {
|
for (MapObject obj : mapobjects.values()) {
|
||||||
if (obj.getType() == MapObjectType.REACTOR) {
|
if (obj.getType() == MapObjectType.REACTOR) {
|
||||||
MapleReactor mr = (MapleReactor) obj;
|
Reactor mr = (Reactor) obj;
|
||||||
|
|
||||||
if (mr.getId() >= first && mr.getId() <= last) {
|
if (mr.getId() >= first && mr.getId() <= last) {
|
||||||
list.add(mr);
|
list.add(mr);
|
||||||
@@ -1797,13 +1797,13 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleReactor getReactorByName(String name) {
|
public Reactor getReactorByName(String name) {
|
||||||
objectRLock.lock();
|
objectRLock.lock();
|
||||||
try {
|
try {
|
||||||
for (MapObject obj : mapobjects.values()) {
|
for (MapObject obj : mapobjects.values()) {
|
||||||
if (obj.getType() == MapObjectType.REACTOR) {
|
if (obj.getType() == MapObjectType.REACTOR) {
|
||||||
if (((MapleReactor) obj).getName().equals(name)) {
|
if (((Reactor) obj).getName().equals(name)) {
|
||||||
return (MapleReactor) obj;
|
return (Reactor) obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2036,7 +2036,7 @@ public class MapleMap {
|
|||||||
updateBossSpawn(monster);
|
updateBossSpawn(monster);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnReactor(final MapleReactor reactor) {
|
public void spawnReactor(final Reactor reactor) {
|
||||||
reactor.setMap(this);
|
reactor.setMap(this);
|
||||||
spawnAndAddRangedMapObject(reactor, c -> c.sendPacket(reactor.makeSpawnData()));
|
spawnAndAddRangedMapObject(reactor, c -> c.sendPacket(reactor.makeSpawnData()));
|
||||||
}
|
}
|
||||||
@@ -2212,7 +2212,7 @@ public class MapleMap {
|
|||||||
final Item item = drop.getItem();
|
final Item item = drop.getItem();
|
||||||
|
|
||||||
for (final MapObject o : getReactors()) {
|
for (final MapObject o : getReactors()) {
|
||||||
final MapleReactor react = (MapleReactor) o;
|
final Reactor react = (Reactor) o;
|
||||||
|
|
||||||
if (react.getReactorType() == 100) {
|
if (react.getReactorType() == 100) {
|
||||||
if (react.getReactItem(react.getEventState()).getLeft() == item.getItemId() && react.getReactItem(react.getEventState()).getRight() == item.getQuantity()) {
|
if (react.getReactItem(react.getEventState()).getLeft() == item.getItemId() && react.getReactItem(react.getEventState()).getRight() == item.getQuantity()) {
|
||||||
@@ -2226,7 +2226,7 @@ public class MapleMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void searchItemReactors(final MapleReactor react) {
|
public void searchItemReactors(final Reactor react) {
|
||||||
if (react.getReactorType() == 100) {
|
if (react.getReactorType() == 100) {
|
||||||
Pair<Integer, Integer> reactProp = react.getReactItem(react.getEventState());
|
Pair<Integer, Integer> reactProp = react.getReactItem(react.getEventState());
|
||||||
int reactItem = reactProp.getLeft(), reactQty = reactProp.getRight();
|
int reactItem = reactProp.getLeft(), reactQty = reactProp.getRight();
|
||||||
@@ -2958,7 +2958,7 @@ public class MapleMap {
|
|||||||
if (chr != null) {
|
if (chr != null) {
|
||||||
for (MapObject o : getMapObjectsInRange(chr.getPosition(), getRangedDistance(), rangedMapobjectTypes)) {
|
for (MapObject o : getMapObjectsInRange(chr.getPosition(), getRangedDistance(), rangedMapobjectTypes)) {
|
||||||
if (o.getType() == MapObjectType.REACTOR) {
|
if (o.getType() == MapObjectType.REACTOR) {
|
||||||
if (((MapleReactor) o).isAlive()) {
|
if (((Reactor) o).isAlive()) {
|
||||||
o.sendSpawnData(chr.getClient());
|
o.sendSpawnData(chr.getClient());
|
||||||
chr.addVisibleMapObject(o);
|
chr.addVisibleMapObject(o);
|
||||||
}
|
}
|
||||||
@@ -3413,10 +3413,10 @@ public class MapleMap {
|
|||||||
private class ActivateItemReactor implements Runnable {
|
private class ActivateItemReactor implements Runnable {
|
||||||
|
|
||||||
private final MapItem mapitem;
|
private final MapItem mapitem;
|
||||||
private final MapleReactor reactor;
|
private final Reactor reactor;
|
||||||
private final Client c;
|
private final Client c;
|
||||||
|
|
||||||
public ActivateItemReactor(MapItem mapitem, MapleReactor reactor, Client c) {
|
public ActivateItemReactor(MapItem mapitem, Reactor reactor, Client c) {
|
||||||
this.mapitem = mapitem;
|
this.mapitem = mapitem;
|
||||||
this.reactor = reactor;
|
this.reactor = reactor;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
@@ -4299,7 +4299,7 @@ public class MapleMap {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int reactorID = 9980000 + team;
|
int reactorID = 9980000 + team;
|
||||||
MapleReactor reactor = new MapleReactor(MapleReactorFactory.getReactorS(reactorID), reactorID);
|
Reactor reactor = new Reactor(MapleReactorFactory.getReactorS(reactorID), reactorID);
|
||||||
pt.setTaken(true);
|
pt.setTaken(true);
|
||||||
reactor.setPosition(pt.getPosition());
|
reactor.setPosition(pt.getPosition());
|
||||||
reactor.setName(team + "" + num); //lol
|
reactor.setName(team + "" + num); //lol
|
||||||
|
|||||||
@@ -40,14 +40,12 @@ import java.util.concurrent.ScheduledFuture;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Lerk
|
* @author Lerk
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class MapleReactor extends AbstractMapObject {
|
public class Reactor extends AbstractMapObject {
|
||||||
|
private final int rid;
|
||||||
private int rid;
|
private final MapleReactorStats stats;
|
||||||
private MapleReactorStats stats;
|
|
||||||
private byte state;
|
private byte state;
|
||||||
private byte evstate;
|
private byte evstate;
|
||||||
private int delay;
|
private int delay;
|
||||||
@@ -60,10 +58,10 @@ public class MapleReactor extends AbstractMapObject {
|
|||||||
private Runnable delayedRespawnRun = null;
|
private Runnable delayedRespawnRun = null;
|
||||||
private GuardianSpawnPoint guardian = null;
|
private GuardianSpawnPoint guardian = null;
|
||||||
private byte facingDirection = 0;
|
private byte facingDirection = 0;
|
||||||
private Lock reactorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR, true);
|
private final Lock reactorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR, true);
|
||||||
private Lock hitLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR_HIT, true);
|
private final Lock hitLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR_HIT, true);
|
||||||
|
|
||||||
public MapleReactor(MapleReactorStats stats, int rid) {
|
public Reactor(MapleReactorStats stats, int rid) {
|
||||||
this.evstate = (byte) 0;
|
this.evstate = (byte) 0;
|
||||||
this.stats = stats;
|
this.stats = stats;
|
||||||
this.rid = rid;
|
this.rid = rid;
|
||||||
@@ -328,6 +326,7 @@ public class MapleReactor extends AbstractMapObject {
|
|||||||
if (reactorLock.tryLock()) {
|
if (reactorLock.tryLock()) {
|
||||||
try {
|
try {
|
||||||
boolean alive = this.isAlive();
|
boolean alive = this.isAlive();
|
||||||
|
// reactor neither alive nor in delayed respawn, remove map object allowed
|
||||||
if (alive) {
|
if (alive) {
|
||||||
this.setAlive(false);
|
this.setAlive(false);
|
||||||
this.cancelReactorTimeout();
|
this.cancelReactorTimeout();
|
||||||
@@ -335,11 +334,7 @@ public class MapleReactor extends AbstractMapObject {
|
|||||||
if (this.getDelay() > 0) {
|
if (this.getDelay() > 0) {
|
||||||
this.delayedRespawn();
|
this.delayedRespawn();
|
||||||
}
|
}
|
||||||
} else if (this.inDelayedRespawn()) {
|
} else return !this.inDelayedRespawn();
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true; // reactor neither alive nor in delayed respawn, remove map object allowed
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
reactorLock.unlock();
|
reactorLock.unlock();
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import net.server.world.Party;
|
|||||||
import net.server.world.PartyCharacter;
|
import net.server.world.PartyCharacter;
|
||||||
import server.TimerManager;
|
import server.TimerManager;
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
import server.maps.MapleReactor;
|
import server.maps.Reactor;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
@@ -170,7 +170,7 @@ public class MonsterCarnival {
|
|||||||
|
|
||||||
public boolean canGuardianR() {
|
public boolean canGuardianR() {
|
||||||
int teamReactors = 0;
|
int teamReactors = 0;
|
||||||
for (MapleReactor react : map.getAllReactors()) {
|
for (Reactor react : map.getAllReactors()) {
|
||||||
if (react.getName().substring(0, 1).contentEquals("0")) {
|
if (react.getName().substring(0, 1).contentEquals("0")) {
|
||||||
teamReactors += 1;
|
teamReactors += 1;
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ public class MonsterCarnival {
|
|||||||
|
|
||||||
public boolean canGuardianB() {
|
public boolean canGuardianB() {
|
||||||
int teamReactors = 0;
|
int teamReactors = 0;
|
||||||
for (MapleReactor react : map.getAllReactors()) {
|
for (Reactor react : map.getAllReactors()) {
|
||||||
if (react.getName().substring(0, 1).contentEquals("1")) {
|
if (react.getName().substring(0, 1).contentEquals("1")) {
|
||||||
teamReactors += 1;
|
teamReactors += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4117,7 +4117,7 @@ public class PacketCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is there a way to spawn reactors non-animated?
|
// is there a way to spawn reactors non-animated?
|
||||||
public static Packet spawnReactor(MapleReactor reactor) {
|
public static Packet spawnReactor(Reactor reactor) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.REACTOR_SPAWN);
|
OutPacket p = OutPacket.create(SendOpcode.REACTOR_SPAWN);
|
||||||
p.writeInt(reactor.getObjectId());
|
p.writeInt(reactor.getObjectId());
|
||||||
p.writeInt(reactor.getId());
|
p.writeInt(reactor.getId());
|
||||||
@@ -4129,7 +4129,7 @@ public class PacketCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is there a way to trigger reactors without performing the hit animation?
|
// is there a way to trigger reactors without performing the hit animation?
|
||||||
public static Packet triggerReactor(MapleReactor reactor, int stance) {
|
public static Packet triggerReactor(Reactor reactor, int stance) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.REACTOR_HIT);
|
OutPacket p = OutPacket.create(SendOpcode.REACTOR_HIT);
|
||||||
p.writeInt(reactor.getObjectId());
|
p.writeInt(reactor.getObjectId());
|
||||||
p.writeByte(reactor.getState());
|
p.writeByte(reactor.getState());
|
||||||
@@ -4140,7 +4140,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet destroyReactor(MapleReactor reactor) {
|
public static Packet destroyReactor(Reactor reactor) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.REACTOR_DESTROY);
|
OutPacket p = OutPacket.create(SendOpcode.REACTOR_DESTROY);
|
||||||
p.writeInt(reactor.getObjectId());
|
p.writeInt(reactor.getObjectId());
|
||||||
p.writeByte(reactor.getState());
|
p.writeByte(reactor.getState());
|
||||||
|
|||||||
Reference in New Issue
Block a user