New PQ: Boss Rush PQ + Ellin/PiratePQ bug fixes
Introducing Boss Rush PQ. Corrected a few issues regarding rewardings in PiratePQ and EllinPQ and implemented a standardized way to script PQs.
This commit is contained in:
@@ -93,15 +93,15 @@ public class AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public void warp(int map) {
|
||||
getPlayer().changeMap(getWarpMap(map), getWarpMap(map).getPortal(0));
|
||||
getPlayer().changeMap(map, 0);
|
||||
}
|
||||
|
||||
public void warp(int map, int portal) {
|
||||
getPlayer().changeMap(getWarpMap(map), getWarpMap(map).getPortal(portal));
|
||||
getPlayer().changeMap(map, portal);
|
||||
}
|
||||
|
||||
public void warp(int map, String portal) {
|
||||
getPlayer().changeMap(getWarpMap(map), getWarpMap(map).getPortal(portal));
|
||||
getPlayer().changeMap(map, portal);
|
||||
}
|
||||
|
||||
public void warpMap(int map) {
|
||||
@@ -161,6 +161,15 @@ public class AbstractPlayerInteraction {
|
||||
public EventManager getEventManager(String event) {
|
||||
return getClient().getEventManager(event);
|
||||
}
|
||||
|
||||
public void clearPQ(int toMap) {
|
||||
clearPQ(getWarpMap(toMap));
|
||||
}
|
||||
|
||||
public void clearPQ(MapleMap toMap) {
|
||||
if(getPlayer().getEventInstance() != null)
|
||||
getPlayer().getEventInstance().getEm().clearPQ(getPlayer().getEventInstance(), toMap);
|
||||
}
|
||||
|
||||
public MapleInventory getInventory(MapleInventoryType type) {
|
||||
return getPlayer().getInventory(type);
|
||||
@@ -556,14 +565,17 @@ public class AbstractPlayerInteraction {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveCharacterExp(int amount, MapleCharacter chr) {
|
||||
chr.gainExp((amount * chr.getExpRate()), true, true);
|
||||
}
|
||||
|
||||
public void givePartyExp(int amount, List<MapleCharacter> party) {
|
||||
for (MapleCharacter chr : party) {
|
||||
chr.gainExp((amount * chr.getExpRate()), true, true);
|
||||
giveCharacterExp(amount, chr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void givePartyExp(String PQ) {
|
||||
givePartyExp(PQ, true);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,28 @@ public class EventInstanceManager {
|
||||
public EventManager getEm() {
|
||||
return em;
|
||||
}
|
||||
|
||||
public void giveEventPlayersExp(int gain) {
|
||||
giveEventPlayersExp(gain, -1);
|
||||
}
|
||||
|
||||
public void giveEventPlayersExp(int gain, int mapId) {
|
||||
rL.lock();
|
||||
try {
|
||||
if(mapId == -1) {
|
||||
for(MapleCharacter mc: chars) {
|
||||
mc.gainExp(gain * mc.getExpRate(), true, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(MapleCharacter mc: chars) {
|
||||
if(mc.getMapId() == mapId) mc.gainExp(gain * mc.getExpRate(), true, true);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
rL.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPlayer(MapleCharacter chr) {
|
||||
if (chr == null || !chr.isLoggedin()){
|
||||
@@ -141,7 +163,7 @@ public class EventInstanceManager {
|
||||
}
|
||||
|
||||
public void registerParty(MapleParty party, MapleMap map) {
|
||||
for (MaplePartyCharacter pc : party.getMembers()) {
|
||||
for (MaplePartyCharacter pc : party.getEligibleMembers()) {
|
||||
MapleCharacter c = map.getCharacterById(pc.getId());
|
||||
registerPlayer(c);
|
||||
}
|
||||
@@ -197,6 +219,14 @@ public class EventInstanceManager {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void changedMap(MapleCharacter chr, int mapId) {
|
||||
try {
|
||||
em.getIv().invokeFunction("changedMap", this, chr, mapId);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void monsterKilled(MapleMonster mob) {
|
||||
mobs.remove(mob);
|
||||
@@ -418,7 +448,7 @@ public class EventInstanceManager {
|
||||
|
||||
rL.lock();
|
||||
try {
|
||||
if (chars != null && chars.size() <= size) {
|
||||
if (chars != null && chars.size() < size) {
|
||||
for (MapleCharacter chr : chars) {
|
||||
if (chr == null) {
|
||||
continue;
|
||||
|
||||
@@ -35,6 +35,7 @@ import javax.script.ScriptException;
|
||||
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import server.TimerManager;
|
||||
import server.expeditions.MapleExpedition;
|
||||
import server.maps.MapleMap;
|
||||
@@ -42,6 +43,10 @@ import server.life.MapleMonster;
|
||||
import server.life.MapleLifeFactory;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -86,7 +91,8 @@ public class EventManager {
|
||||
}
|
||||
|
||||
public void cancelSchedule() {
|
||||
schedule.cancel(true);
|
||||
if(schedule != null)
|
||||
schedule.cancel(true);
|
||||
}
|
||||
|
||||
public ScheduledFuture<?> scheduleAtTimestamp(final String methodName, long timestamp) {
|
||||
@@ -173,6 +179,7 @@ public class EventManager {
|
||||
try {
|
||||
EventInstanceManager eim = (EventInstanceManager) (iv.invokeFunction("setup", (Object) null));
|
||||
eim.registerParty(party, map);
|
||||
party.setEligibleMembers(null);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -183,6 +190,7 @@ public class EventManager {
|
||||
try {
|
||||
EventInstanceManager eim = (EventInstanceManager) (iv.invokeFunction("setup", difficulty, party.getLeader().getId()));
|
||||
eim.registerParty(party, map);
|
||||
party.setEligibleMembers(null);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -198,6 +206,33 @@ public class EventManager {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MaplePartyCharacter> getEligibleParty(MapleParty party) {
|
||||
if (party == null) {
|
||||
return(new ArrayList<>());
|
||||
}
|
||||
try {
|
||||
Object p = iv.invokeFunction("getEligibleParty", party.getPartyMembers());
|
||||
|
||||
if(p != null) {
|
||||
List<MaplePartyCharacter> lmpc = new ArrayList<>((List<MaplePartyCharacter>) p);
|
||||
party.setEligibleMembers(lmpc);
|
||||
return lmpc;
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return(new ArrayList<>());
|
||||
}
|
||||
|
||||
public void clearPQ(EventInstanceManager eim, MapleMap toMap) {
|
||||
try {
|
||||
iv.invokeFunction("clearPQ", eim, toMap);
|
||||
} catch (ScriptException | NoSuchMethodException ex) {
|
||||
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public MapleMonster getMonster(int mid) {
|
||||
return(MapleLifeFactory.getMonster(mid));
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getMeso() {
|
||||
return getPlayer().getMeso();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
int range = maxMeso - minMeso;
|
||||
int displayDrop = (int) (Math.random() * range) + minMeso;
|
||||
int mesoDrop = (displayDrop * client.getWorldServer().getMesoRate());
|
||||
reactor.getMap().spawnMesoDrop(mesoDrop, dropPos, reactor, client.getPlayer(), false, (byte) 0);
|
||||
reactor.getMap().spawnMesoDrop(mesoDrop, dropPos, reactor, client.getPlayer(), false, (byte) 2);
|
||||
} else {
|
||||
Item drop;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
@@ -129,7 +129,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
|
||||
private void spawnMonster(int id, int qty, Point pos) {
|
||||
for (int i = 0; i < qty; i++) {
|
||||
reactor.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(id), pos);
|
||||
reactor.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(id), pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,23 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
public synchronized static ReactorScriptManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void onHit(MapleClient c, MapleReactor reactor) {
|
||||
try {
|
||||
ReactorActionManager rm = new ReactorActionManager(c, reactor);
|
||||
Invocable iv = getInvocable("reactor/" + reactor.getId() + ".js", c);
|
||||
if (iv == null) {
|
||||
return;
|
||||
}
|
||||
engine.put("rm", rm);
|
||||
iv.invokeFunction("hit");
|
||||
} catch(final NoSuchMethodException e) {
|
||||
//do nothing, hit is OPTIONAL
|
||||
}
|
||||
catch (final ScriptException | NullPointerException e) {
|
||||
FilePrinter.printError(FilePrinter.REACTOR + reactor.getId() + ".txt", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void act(MapleClient c, MapleReactor reactor) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user