EXP system & Mob buffs/diseases optimization
Solved a problem within EXP distribution system that would hand out less overall EXP than the expected when the amount to be earned is low. Optimized mob buffs and diseases, now using a dedicated thread to process all status expirations on a batch. Refactored MonitoredLockTypes names to something more easily identificable. Added a delay on mob effect applications, to be registered in after the cast animation time. Fixed Flame Thrower acting passively when a attacking skill is used by the player.
This commit is contained in:
@@ -273,10 +273,10 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
private ScheduledFuture<?> extraRecoveryTask = null;
|
||||
private ScheduledFuture<?> chairRecoveryTask = null;
|
||||
private ScheduledFuture<?> pendantOfSpirit = null; //1122017
|
||||
private Lock chrLock = new MonitoredReentrantLock(MonitoredLockType.CHR, true);
|
||||
private Lock effLock = new MonitoredReentrantLock(MonitoredLockType.EFF, true);
|
||||
private Lock petLock = new MonitoredReentrantLock(MonitoredLockType.PET, true); // for quest tasks as well
|
||||
private Lock prtLock = new MonitoredReentrantLock(MonitoredLockType.PRT);
|
||||
private Lock chrLock = new MonitoredReentrantLock(MonitoredLockType.CHARACTER_CHR, true);
|
||||
private Lock effLock = new MonitoredReentrantLock(MonitoredLockType.CHARACTER_EFF, true);
|
||||
private Lock petLock = new MonitoredReentrantLock(MonitoredLockType.CHARACTER_PET, true); // for quest tasks as well
|
||||
private Lock prtLock = new MonitoredReentrantLock(MonitoredLockType.CHARACTER_PRT);
|
||||
private Map<Integer, Set<Integer>> excluded = new LinkedHashMap<>();
|
||||
private Set<Integer> excludedItems = new LinkedHashSet<>();
|
||||
private static String[] ariantroomleader = new String[3];
|
||||
|
||||
@@ -107,8 +107,8 @@ public class MapleClient {
|
||||
private byte gender = -1;
|
||||
private boolean disconnecting = false;
|
||||
private final Lock lock = new MonitoredReentrantLock(MonitoredLockType.CLIENT, true);
|
||||
private final Lock encoderLock = new MonitoredReentrantLock(MonitoredLockType.CLIENT, true);
|
||||
private static final Lock loginLock = new MonitoredReentrantLock(MonitoredLockType.CLIENT, true);
|
||||
private final Lock encoderLock = new MonitoredReentrantLock(MonitoredLockType.CLIENT_ENCODER, true);
|
||||
private static final Lock loginLock = new MonitoredReentrantLock(MonitoredLockType.CLIENT_LOGIN, true);
|
||||
private int votePoints;
|
||||
private int voteTime = -1;
|
||||
private long lastNpcClick;
|
||||
|
||||
@@ -23,7 +23,6 @@ package client.status;
|
||||
|
||||
import client.Skill;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import server.life.MobSkill;
|
||||
import tools.ArrayMap;
|
||||
|
||||
@@ -33,9 +32,7 @@ public class MonsterStatusEffect {
|
||||
private Skill skill;
|
||||
private MobSkill mobskill;
|
||||
private boolean monsterSkill;
|
||||
private ScheduledFuture<?> cancelTask;
|
||||
private ScheduledFuture<?> damageSchedule;
|
||||
|
||||
|
||||
public MonsterStatusEffect(Map<MonsterStatus, Integer> stati, Skill skillId, MobSkill mobskill, boolean monsterSkill) {
|
||||
this.stati = new ArrayMap<>(stati);
|
||||
this.skill = skillId;
|
||||
@@ -59,35 +56,10 @@ public class MonsterStatusEffect {
|
||||
return monsterSkill;
|
||||
}
|
||||
|
||||
public final void cancelTask() {
|
||||
if (cancelTask != null) {
|
||||
cancelTask.cancel(false);
|
||||
}
|
||||
cancelTask = null;
|
||||
}
|
||||
|
||||
public ScheduledFuture<?> getCancelTask() {
|
||||
return cancelTask;
|
||||
}
|
||||
|
||||
public void setCancelTask(ScheduledFuture<?> cancelTask) {
|
||||
this.cancelTask = cancelTask;
|
||||
}
|
||||
|
||||
public void removeActiveStatus(MonsterStatus stat) {
|
||||
stati.remove(stat);
|
||||
}
|
||||
|
||||
public void setDamageSchedule(ScheduledFuture<?> damageSchedule) {
|
||||
this.damageSchedule = damageSchedule;
|
||||
}
|
||||
|
||||
public void cancelDamageSchedule() {
|
||||
if (damageSchedule != null) {
|
||||
damageSchedule.cancel(false);
|
||||
}
|
||||
}
|
||||
|
||||
public MobSkill getMobSkill() {
|
||||
return mobskill;
|
||||
}
|
||||
|
||||
@@ -123,6 +123,10 @@ public class ServerConstants {
|
||||
public static final int ITEM_LIMIT_ON_MAP = 200; //Max number of items allowed on a map.
|
||||
public static final int MAP_VISITED_SIZE = 5; //Max length for last mapids visited by a player. This is used to recover and update drops on these maps accordingly with player actions.
|
||||
|
||||
//Channel Mob Disease Monitor Configuration
|
||||
public static final int MOB_STATUS_MONITOR_PROC = 200; //Frequency in milliseconds between each proc on the mob disease monitor schedule.
|
||||
public static final int MOB_STATUS_MONITOR_LIFE = 84; //Idle proc count the mob disease monitor is allowed to be there before closing it due to inactivity.
|
||||
|
||||
//Some Gameplay Enhancing Configurations
|
||||
//Scroll Configuration
|
||||
public static final boolean USE_PERFECT_GM_SCROLL = true; //Scrolls from GMs never uses up slots nor fails.
|
||||
|
||||
@@ -96,8 +96,8 @@ public class Server {
|
||||
private final Map<Integer, MapleGuild> guilds = new HashMap<>(100);
|
||||
private final Map<MapleClient, Long> inLoginState = new HashMap<>(100);
|
||||
private final Lock srvLock = new MonitoredReentrantLock(MonitoredLockType.SERVER);
|
||||
private final Lock lgnLock = new MonitoredReentrantLock(MonitoredLockType.SERVER);
|
||||
private final Lock disLock = new MonitoredReentrantLock(MonitoredLockType.SERVER);
|
||||
private final Lock lgnLock = new MonitoredReentrantLock(MonitoredLockType.SERVER_LOGIN);
|
||||
private final Lock disLock = new MonitoredReentrantLock(MonitoredLockType.SERVER_DISEASES);
|
||||
private final PlayerBuffStorage buffStorage = new PlayerBuffStorage();
|
||||
private final Map<Integer, MapleAlliance> alliances = new HashMap<>(100);
|
||||
private final Map<Integer, NewYearCardRecord> newyears = new HashMap<>();
|
||||
|
||||
@@ -233,7 +233,7 @@ public class ThreadTracker {
|
||||
|
||||
List<MonitoredLockType> list = threadTracker.get(tid);
|
||||
for(int i = list.size() - 1; i >= 0; i--) {
|
||||
if(lockId.getValue() == list.get(i).getValue()) {
|
||||
if(lockId.equals(list.get(i))) {
|
||||
list.remove(i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.channel;
|
||||
|
||||
import net.server.channel.worker.MobStatusScheduler;
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
@@ -70,6 +71,7 @@ import server.maps.MapleMiniDungeon;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
import client.MapleCharacter;
|
||||
import client.status.MonsterStatusEffect;
|
||||
import constants.ServerConstants;
|
||||
import server.maps.MapleMiniDungeonInfo;
|
||||
import tools.locks.MonitoredLockType;
|
||||
@@ -83,6 +85,7 @@ public final class Channel {
|
||||
private String ip, serverMessage;
|
||||
private MapleMapFactory mapFactory;
|
||||
private EventScriptManager eventSM;
|
||||
private MobStatusScheduler mobStatusSchedulers[] = new MobStatusScheduler[4];
|
||||
private Map<Integer, MapleHiredMerchant> hiredMerchants = new HashMap<>();
|
||||
private final Map<Integer, Integer> storedVars = new HashMap<>();
|
||||
private List<MapleExpedition> expeditions = new ArrayList<>();
|
||||
@@ -149,6 +152,10 @@ public final class Channel {
|
||||
dojoTask[i] = null;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
mobStatusSchedulers[i] = new MobStatusScheduler();
|
||||
}
|
||||
|
||||
System.out.println(" Channel " + getId() + ": Listening on port " + port);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -817,6 +824,34 @@ public final class Channel {
|
||||
}
|
||||
}
|
||||
|
||||
private static int getMobStatusSchedulerIndex(int mapid) {
|
||||
if(mapid >= 250000000) {
|
||||
if(mapid >= 900000000) {
|
||||
return 3;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
} else {
|
||||
if(mapid >= 200000000) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMobStatus(int mapid, MonsterStatusEffect mse, Runnable cancelAction, long duration) {
|
||||
registerMobStatus(mapid, mse, cancelAction, duration, null, -1);
|
||||
}
|
||||
|
||||
public void registerMobStatus(int mapid, MonsterStatusEffect mse, Runnable cancelAction, long duration, Runnable overtimeAction, int overtimeDelay) {
|
||||
mobStatusSchedulers[getMobStatusSchedulerIndex(mapid)].registerMobStatus(mse, cancelAction, duration, overtimeAction, overtimeDelay);
|
||||
}
|
||||
|
||||
public void interruptMobStatus(int mapid, MonsterStatusEffect mse) {
|
||||
mobStatusSchedulers[getMobStatusSchedulerIndex(mapid)].interruptMobStatus(mse);
|
||||
}
|
||||
|
||||
public void debugMarriageStatus() {
|
||||
System.out.println(" ----- WORLD DATA -----");
|
||||
Server.getInstance().getWorld(world).debugMarriageStatus();
|
||||
|
||||
@@ -326,6 +326,15 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
|
||||
} else if (attack.skill == Outlaw.HOMING_BEACON || attack.skill == Corsair.BULLSEYE) {
|
||||
player.setMarkedMonster(monster.getObjectId());
|
||||
player.announce(MaplePacketCreator.giveBuff(1, attack.skill, Collections.singletonList(new Pair<>(MapleBuffStat.HOMING_BEACON, monster.getObjectId()))));
|
||||
} else if (attack.skill == Outlaw.FLAME_THROWER) {
|
||||
if (!monster.isBoss()) {
|
||||
Skill type = SkillFactory.getSkill(Outlaw.FLAME_THROWER);
|
||||
if (player.getSkillLevel(type) > 0) {
|
||||
MapleStatEffect DoT = type.getEffect(player.getSkillLevel(type));
|
||||
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), type, null, false);
|
||||
monster.applyStatus(player, monsterStatusEffect, true, DoT.getDuration(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (job == 2111 || job == 2112) {
|
||||
@@ -406,15 +415,6 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (job == 521 || job == 522) { // from what I can gather this is how it should work
|
||||
if (!monster.isBoss()) {
|
||||
Skill type = SkillFactory.getSkill(Outlaw.FLAME_THROWER);
|
||||
if (player.getSkillLevel(type) > 0) {
|
||||
MapleStatEffect DoT = type.getEffect(player.getSkillLevel(type));
|
||||
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), type, null, false);
|
||||
monster.applyStatus(player, monsterStatusEffect, true, DoT.getDuration(), false);
|
||||
}
|
||||
}
|
||||
} else if (job >= 311 && job <= 322) {
|
||||
if (!monster.isBoss()) {
|
||||
Skill mortalBlow;
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import server.life.MapleMonster;
|
||||
import server.life.MapleMonsterInformationProvider;
|
||||
//import server.life.MobAttackInfo;
|
||||
//import server.life.MobAttackInfoFactory;
|
||||
import server.life.MobSkill;
|
||||
@@ -94,20 +95,27 @@ public final class MoveLifeHandler extends AbstractMovementPacketHandler {
|
||||
} else if (toUse.getHP() < percHpLeft) {
|
||||
toUse = null;
|
||||
} else if (monster.canUseSkill(toUse)) {
|
||||
toUse.applyEffect(c.getPlayer(), monster, true, banishPlayers);
|
||||
int animationTime = MapleMonsterInformationProvider.getInstance().getMobSkillAnimationTime(monster.getId(), Random);
|
||||
if(animationTime > 0) {
|
||||
toUse.applyDelayedEffect(c.getPlayer(), monster, true, banishPlayers, animationTime);
|
||||
} else {
|
||||
toUse.applyEffect(c.getPlayer(), monster, true, banishPlayers);
|
||||
}
|
||||
} else {
|
||||
toUse = null;
|
||||
}
|
||||
} else {
|
||||
toUse = null; // paliative measure for suspicious mob movement
|
||||
|
||||
/*
|
||||
long curtime = System.currentTimeMillis();
|
||||
if(curtime >= monster.getNextBasicSkillTime()) { // dont use the special attack too often, chase the player f3
|
||||
//MobAttackInfo mobAttack = MobAttackInfoFactory.getMobAttackInfo(monster, attackId);
|
||||
//monster.setNextBasicSkillTime(curtime);
|
||||
|
||||
toUse = null; // paliative measure for suspicious mob movement
|
||||
MobAttackInfo mobAttack = MobAttackInfoFactory.getMobAttackInfo(monster, attackId);
|
||||
monster.setNextBasicSkillTime(curtime);
|
||||
} else {
|
||||
toUse = null;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft 2016 - 2018 RonanLana
|
||||
|
||||
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 net.server.channel.worker;
|
||||
|
||||
import client.status.MonsterStatusEffect;
|
||||
import constants.ServerConstants;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import server.TimerManager;
|
||||
import tools.Pair;
|
||||
import tools.locks.MonitoredLockType;
|
||||
import tools.locks.MonitoredReentrantLock;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MobStatusScheduler {
|
||||
private int idleProcs = 0;
|
||||
private Map<MonsterStatusEffect, Pair<Runnable, Long>> registeredMobStatus = new HashMap<>();
|
||||
private Map<MonsterStatusEffect, MobStatusOvertimeEntry> registeredMobStatusOvertime = new HashMap<>();
|
||||
|
||||
private class MobStatusOvertimeEntry {
|
||||
private int procCount;
|
||||
private int procLimit;
|
||||
private Runnable r;
|
||||
|
||||
protected MobStatusOvertimeEntry(int delay, Runnable run) {
|
||||
procCount = 0;
|
||||
procLimit = (int)Math.ceil((float) delay / ServerConstants.MOB_STATUS_MONITOR_PROC);
|
||||
r = run;
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
procCount++;
|
||||
if(procCount >= procLimit) {
|
||||
procCount = 0;
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ScheduledFuture<?> mobStatusSchedule = null;
|
||||
private Lock mobStatusLock = new MonitoredReentrantLock(MonitoredLockType.CHANNEL_MOBSTATUS, true);
|
||||
private Runnable monitorTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runMobStatusSchedule();
|
||||
}
|
||||
};
|
||||
|
||||
private void runMobStatusSchedule() {
|
||||
mobStatusLock.lock();
|
||||
try {
|
||||
if(registeredMobStatus.isEmpty()) {
|
||||
idleProcs++;
|
||||
|
||||
if(idleProcs >= ServerConstants.MOB_STATUS_MONITOR_LIFE) {
|
||||
if(mobStatusSchedule != null) {
|
||||
mobStatusSchedule.cancel(false);
|
||||
mobStatusSchedule = null;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
idleProcs = 0;
|
||||
|
||||
long timeNow = System.currentTimeMillis();
|
||||
List<MonsterStatusEffect> toRemove = new LinkedList<>();
|
||||
for(Entry<MonsterStatusEffect, Pair<Runnable, Long>> rmd : registeredMobStatus.entrySet()) {
|
||||
Pair<Runnable, Long> r = rmd.getValue();
|
||||
|
||||
if(r.getRight() < timeNow) {
|
||||
r.getLeft().run(); // runs the cancel action
|
||||
toRemove.add(rmd.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for(MonsterStatusEffect mse : toRemove) {
|
||||
registeredMobStatus.remove(mse);
|
||||
registeredMobStatusOvertime.remove(mse);
|
||||
}
|
||||
|
||||
// it's probably ok to use one thread for both management & overtime actions
|
||||
List<MobStatusOvertimeEntry> mdoeList = new ArrayList<>(registeredMobStatusOvertime.values());
|
||||
for(MobStatusOvertimeEntry mdoe : mdoeList) {
|
||||
mdoe.update();
|
||||
}
|
||||
} finally {
|
||||
mobStatusLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMobStatus(MonsterStatusEffect mse, Runnable cancelStatus, long duration, Runnable overtimeStatus, int overtimeDelay) {
|
||||
mobStatusLock.lock();
|
||||
try {
|
||||
idleProcs = 0;
|
||||
if(mobStatusSchedule == null) {
|
||||
mobStatusSchedule = TimerManager.getInstance().register(monitorTask, ServerConstants.MOB_STATUS_MONITOR_PROC, ServerConstants.MOB_STATUS_MONITOR_PROC);
|
||||
}
|
||||
|
||||
registeredMobStatus.put(mse, new Pair<>(cancelStatus, System.currentTimeMillis() + duration));
|
||||
|
||||
if(overtimeStatus != null) {
|
||||
MobStatusOvertimeEntry mdoe = new MobStatusOvertimeEntry(overtimeDelay, overtimeStatus);
|
||||
registeredMobStatusOvertime.put(mse, mdoe);
|
||||
}
|
||||
} finally {
|
||||
mobStatusLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void interruptMobStatus(MonsterStatusEffect mse) {
|
||||
mobStatusLock.lock();
|
||||
try {
|
||||
Pair<Runnable, Long> rmd = registeredMobStatus.remove(mse);
|
||||
if(rmd != null) rmd.getLeft().run();
|
||||
|
||||
registeredMobStatusOvertime.remove(mse);
|
||||
} finally {
|
||||
mobStatusLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import net.server.world.World;
|
||||
/**
|
||||
* @author Ronan
|
||||
*/
|
||||
public class BaseWorker implements Runnable {
|
||||
public abstract class BaseWorker implements Runnable {
|
||||
protected World wserv;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,7 +124,7 @@ public class World {
|
||||
|
||||
private Map<Runnable, Long> registeredTimedMapObjects = new LinkedHashMap<>();
|
||||
private ScheduledFuture<?> timedMapObjectsSchedule;
|
||||
private Lock timedMapObjectLock = new MonitoredReentrantLock(MonitoredLockType.MAP_OBJS, true);
|
||||
private Lock timedMapObjectLock = new MonitoredReentrantLock(MonitoredLockType.WORLD_MAPOBJS, true);
|
||||
|
||||
private ScheduledFuture<?> charactersSchedule;
|
||||
private ScheduledFuture<?> marriagesSchedule;
|
||||
|
||||
@@ -978,4 +978,23 @@ public class AbstractPlayerInteraction {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFirstJobStatRequirement(int jobType) {
|
||||
switch(jobType) {
|
||||
case 1:
|
||||
return "STR " + 35;
|
||||
|
||||
case 2:
|
||||
return "INT " + 20;
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
return "DEX " + 25;
|
||||
|
||||
case 5:
|
||||
return "DEX " + 20;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class AbstractScriptManager {
|
||||
}
|
||||
try (FileReader fr = new FileReader(scriptFile)) {
|
||||
if (ServerConstants.JAVA_8){
|
||||
engine.eval("load('nashorn:mozilla_compat.js');");
|
||||
engine.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
|
||||
}
|
||||
engine.eval(fr);
|
||||
} catch (final ScriptException | IOException t) {
|
||||
|
||||
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.item;
|
||||
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -29,7 +30,6 @@ import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.script.Compilable;
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
@@ -76,8 +76,13 @@ public class ItemScriptManager {
|
||||
ScriptEngine portal = sef.getScriptEngine();
|
||||
try {
|
||||
fr = new FileReader(scriptFile);
|
||||
CompiledScript compiled = ((Compilable) portal).compile(fr);
|
||||
compiled.eval();
|
||||
|
||||
// java 8 support here thanks to Arufonsu
|
||||
if (ServerConstants.JAVA_8){
|
||||
portal.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
|
||||
}
|
||||
|
||||
((Compilable) portal).compile(fr).eval();
|
||||
|
||||
final Invocable script = ((Invocable) portal);
|
||||
scripts.put(scriptName, script);
|
||||
|
||||
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.map;
|
||||
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -29,7 +30,6 @@ import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.script.Compilable;
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
@@ -80,8 +80,14 @@ public class MapScriptManager {
|
||||
ScriptEngine portal = sef.getScriptEngine();
|
||||
try {
|
||||
fr = new FileReader(scriptFile);
|
||||
CompiledScript compiled = ((Compilable) portal).compile(fr);
|
||||
compiled.eval();
|
||||
|
||||
// java 8 support here thanks to Arufonsu
|
||||
if (ServerConstants.JAVA_8){
|
||||
portal.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
|
||||
}
|
||||
|
||||
((Compilable) portal).compile(fr).eval();
|
||||
|
||||
final Invocable script = ((Invocable) portal);
|
||||
scripts.put(scriptName, script);
|
||||
script.invokeFunction("start", new MapScriptMethods(c));
|
||||
|
||||
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.portal;
|
||||
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -65,6 +66,12 @@ public class PortalScriptManager {
|
||||
ScriptEngine portal = sef.getScriptEngine();
|
||||
try {
|
||||
fr = new FileReader(scriptFile);
|
||||
|
||||
// java 8 support here thanks to Arufonsu
|
||||
if (ServerConstants.JAVA_8){
|
||||
portal.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
|
||||
}
|
||||
|
||||
((Compilable) portal).compile(fr).eval();
|
||||
} catch (ScriptException | IOException | UndeclaredThrowableException e) {
|
||||
FilePrinter.printError(FilePrinter.PORTAL + scriptName + ".txt", e);
|
||||
|
||||
@@ -132,12 +132,23 @@ public class MapleLifeFactory {
|
||||
stats.setRevives(revives);
|
||||
}
|
||||
decodeElementalString(stats, MapleDataTool.getString("elemAttr", monsterInfoData, ""));
|
||||
MapleData monsterSkillData = monsterInfoData.getChildByPath("skill");
|
||||
if (monsterSkillData != null) {
|
||||
MapleData monsterSkillInfoData = monsterInfoData.getChildByPath("skill");
|
||||
if (monsterSkillInfoData != null) {
|
||||
int i = 0;
|
||||
List<Pair<Integer, Integer>> skills = new ArrayList<>();
|
||||
while (monsterSkillData.getChildByPath(Integer.toString(i)) != null) {
|
||||
skills.add(new Pair<>(Integer.valueOf(MapleDataTool.getInt(i + "/skill", monsterSkillData, 0)), Integer.valueOf(MapleDataTool.getInt(i + "/level", monsterSkillData, 0))));
|
||||
while (monsterSkillInfoData.getChildByPath(Integer.toString(i)) != null) {
|
||||
skills.add(new Pair<>(Integer.valueOf(MapleDataTool.getInt(i + "/skill", monsterSkillInfoData, 0)), Integer.valueOf(MapleDataTool.getInt(i + "/level", monsterSkillInfoData, 0))));
|
||||
|
||||
MapleData monsterSkillData = monsterData.getChildByPath("skill" + i);
|
||||
if(monsterSkillData != null) {
|
||||
int animationTime = 0;
|
||||
for(MapleData effectEntry : monsterSkillData.getChildren()) {
|
||||
animationTime += MapleDataTool.getIntConvert("delay", effectEntry, 0);
|
||||
}
|
||||
|
||||
MapleMonsterInformationProvider.getInstance().setMobSkillAnimationTime(mid, i, animationTime);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
stats.setSkills(skills);
|
||||
|
||||
@@ -56,6 +56,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import tools.locks.MonitoredReentrantLock;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import server.TimerManager;
|
||||
@@ -320,7 +321,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
return takenDamage.containsKey(chr.getId());
|
||||
}
|
||||
|
||||
private void distributeExperienceToParty(int pid, int exp, int killer, Set<MapleCharacter> underleveled, int minThresholdLevel) {
|
||||
private void distributeExperienceToParty(int pid, float exp, int killer, Set<MapleCharacter> underleveled, int minThresholdLevel) {
|
||||
List<MapleCharacter> members = new LinkedList<>();
|
||||
MapleCharacter pchar = getMap().getAnyCharacterFromParty(pid);
|
||||
if(pchar != null) {
|
||||
@@ -353,7 +354,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
if (level >= minThresholdLevel) {
|
||||
boolean isKiller = killer == id;
|
||||
boolean mostDamage = mostDamageCid == id;
|
||||
int xp = (int) ((0.80f * exp * level) / partyLevel);
|
||||
float xp = ((0.80f * exp * level) / partyLevel);
|
||||
if (mostDamage) {
|
||||
xp += (0.20f * exp);
|
||||
}
|
||||
@@ -378,14 +379,14 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
int minThresholdLevel = calcThresholdLevel(this.getMap().getEventInstance() != null);
|
||||
int exp = getExp();
|
||||
long totalHealth = maxHpPlusHeal.get();
|
||||
Map<Integer, Integer> expDist = new HashMap<>();
|
||||
Map<Integer, Integer> partyExp = new HashMap<>();
|
||||
Map<Integer, Float> expDist = new HashMap<>();
|
||||
Map<Integer, Float> partyExp = new HashMap<>();
|
||||
|
||||
float exp8perHp = (0.8f * exp) / totalHealth; // 80% of pool is split amongst all the damagers
|
||||
float exp2 = (0.2f * exp); // 20% of pool goes to the killer or his/her party
|
||||
|
||||
for (Entry<Integer, AtomicInteger> damage : takenDamage.entrySet()) {
|
||||
expDist.put(damage.getKey(), (int) (Math.min((exp8perHp * damage.getValue().get()), Integer.MAX_VALUE)));
|
||||
expDist.put(damage.getKey(), exp8perHp * damage.getValue().get());
|
||||
}
|
||||
|
||||
Collection<MapleCharacter> chrs = map.getCharacters();
|
||||
@@ -393,15 +394,16 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
for (MapleCharacter mc : chrs) {
|
||||
if (expDist.containsKey(mc.getId())) {
|
||||
boolean isKiller = (mc.getId() == killerId);
|
||||
int xp = expDist.get(mc.getId());
|
||||
float xp = expDist.get(mc.getId());
|
||||
if (isKiller) {
|
||||
xp = (int)Math.min(exp2 + xp, Integer.MAX_VALUE);
|
||||
xp += exp2;
|
||||
}
|
||||
|
||||
MapleParty p = mc.getParty();
|
||||
if (p != null) {
|
||||
int pID = p.getId();
|
||||
long pXP = (long) xp + (partyExp.containsKey(pID) ? partyExp.get(pID) : 0);
|
||||
partyExp.put(pID, (int)Math.min(pXP, Integer.MAX_VALUE));
|
||||
float pXP = xp + (partyExp.containsKey(pID) ? partyExp.get(pID) : 0);
|
||||
partyExp.put(pID, pXP);
|
||||
} else {
|
||||
if(mc.getLevel() >= minThresholdLevel) {
|
||||
//NO EXP WILL BE GIVEN for those who are underleveled!
|
||||
@@ -413,7 +415,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<Integer, Integer> party : partyExp.entrySet()) {
|
||||
for (Entry<Integer, Float> party : partyExp.entrySet()) {
|
||||
distributeExperienceToParty(party.getKey(), party.getValue(), killerId, underleveled, minThresholdLevel);
|
||||
}
|
||||
|
||||
@@ -422,7 +424,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
}
|
||||
|
||||
public void giveExpToCharacter(MapleCharacter attacker, int exp, boolean isKiller, int numExpSharers) {
|
||||
public void giveExpToCharacter(MapleCharacter attacker, float exp, boolean isKiller, int numExpSharers) {
|
||||
if (isKiller) {
|
||||
if (getMap().getEventInstance() != null) {
|
||||
getMap().getEventInstance().monsterKilled(attacker, this);
|
||||
@@ -434,9 +436,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
|
||||
int partyExp = 0;
|
||||
if (attacker.getHp() > 0) {
|
||||
int personalExp = exp * attacker.getExpRate();
|
||||
exp *= attacker.getExpRate();
|
||||
int personalExp = (int) exp;
|
||||
|
||||
if (exp > 0) {
|
||||
if (exp <= Integer.MAX_VALUE) { // assuming no negative xp here
|
||||
if (partyModifier > 0.0f) {
|
||||
partyExp = (int) (personalExp * partyModifier * ServerConstants.PARTY_BONUS_EXP_RATE);
|
||||
}
|
||||
@@ -444,7 +447,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
if (holySymbol != null) {
|
||||
personalExp *= 1.0 + (holySymbol.doubleValue() / 100.0);
|
||||
}
|
||||
|
||||
|
||||
statiLock.lock();
|
||||
try {
|
||||
if (stati.containsKey(MonsterStatus.SHOWDOWN)) {
|
||||
@@ -453,6 +456,8 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
} finally {
|
||||
statiLock.unlock();
|
||||
}
|
||||
} else {
|
||||
personalExp = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
attacker.gainExp(personalExp, partyExp, true, false, isKiller);
|
||||
@@ -777,9 +782,9 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
byte[] packet = MaplePacketCreator.applyMonsterStatus(getObjectId(), status, null);
|
||||
map.broadcastMessage(packet, getPosition());
|
||||
|
||||
MapleCharacter controller = getController();
|
||||
if (controller != null && !controller.isMapObjectVisible(this)) {
|
||||
controller.getClient().announce(packet);
|
||||
MapleCharacter chrController = getController();
|
||||
if (chrController != null && !chrController.isMapObjectVisible(this)) {
|
||||
chrController.getClient().announce(packet);
|
||||
}
|
||||
|
||||
return animationTime;
|
||||
@@ -832,6 +837,8 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
}
|
||||
|
||||
final Channel ch = map.getChannelServer();
|
||||
final int mapid = map.getId();
|
||||
if(statis.size() > 0) {
|
||||
statiLock.lock();
|
||||
try {
|
||||
@@ -840,8 +847,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
if (oldEffect != null) {
|
||||
oldEffect.removeActiveStatus(stat);
|
||||
if (oldEffect.getStati().isEmpty()) {
|
||||
oldEffect.cancelTask();
|
||||
oldEffect.cancelDamageSchedule();
|
||||
ch.interruptMobStatus(mapid, oldEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -850,7 +856,6 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
}
|
||||
|
||||
TimerManager timerManager = TimerManager.getInstance();
|
||||
final Runnable cancelTask = new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -875,17 +880,21 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
|
||||
setVenomMulti(0);
|
||||
status.cancelDamageSchedule();
|
||||
}
|
||||
};
|
||||
|
||||
Runnable overtimeAction = null;
|
||||
int overtimeDelay = -1;
|
||||
|
||||
int animationTime;
|
||||
if (poison) {
|
||||
int poisonLevel = from.getSkillLevel(status.getSkill());
|
||||
int poisonDamage = Math.min(Short.MAX_VALUE, (int) (getMaxHp() / (70.0 - poisonLevel) + 0.999));
|
||||
status.setValue(MonsterStatus.POISON, Integer.valueOf(poisonDamage));
|
||||
animationTime = broadcastStatusEffect(status);
|
||||
status.setDamageSchedule(timerManager.register(new DamageTask(poisonDamage, from, status, cancelTask, 0), 1000, 1000));
|
||||
|
||||
overtimeAction = new DamageTask(poisonDamage, from, status, 0);
|
||||
overtimeDelay = 1000;
|
||||
} else if (venom) {
|
||||
if (from.getJob() == MapleJob.NIGHTLORD || from.getJob() == MapleJob.SHADOWER || from.getJob().isA(MapleJob.NIGHTWALKER3)) {
|
||||
int poisonLevel, matk, jobid = from.getJob().getId();
|
||||
@@ -910,7 +919,9 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
status.setValue(MonsterStatus.VENOMOUS_WEAPON, Integer.valueOf(poisonDamage));
|
||||
status.setValue(MonsterStatus.POISON, Integer.valueOf(poisonDamage));
|
||||
animationTime = broadcastStatusEffect(status);
|
||||
status.setDamageSchedule(timerManager.register(new DamageTask(poisonDamage, from, status, cancelTask, 0), 1000, 1000));
|
||||
|
||||
overtimeAction = new DamageTask(poisonDamage, from, status, 0);
|
||||
overtimeDelay = 1000;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -919,7 +930,9 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
int webDamage = (int) (getMaxHp() / 50.0 + 0.999);
|
||||
status.setValue(MonsterStatus.SHADOW_WEB, Integer.valueOf(webDamage));
|
||||
animationTime = broadcastStatusEffect(status);
|
||||
status.setDamageSchedule(timerManager.schedule(new DamageTask(webDamage, from, status, cancelTask, 1), 3500));
|
||||
|
||||
overtimeAction = new DamageTask(webDamage, from, status, 1);
|
||||
overtimeDelay = 3500;
|
||||
*/
|
||||
} else if (status.getSkill().getId() == 4121004 || status.getSkill().getId() == 4221004) { // Ninja Ambush
|
||||
final Skill skill = SkillFactory.getSkill(status.getSkill().getId());
|
||||
@@ -928,7 +941,9 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
|
||||
status.setValue(MonsterStatus.NINJA_AMBUSH, Integer.valueOf(damage));
|
||||
animationTime = broadcastStatusEffect(status);
|
||||
status.setDamageSchedule(timerManager.register(new DamageTask(damage, from, status, cancelTask, 2), 1000, 1000));
|
||||
|
||||
overtimeAction = new DamageTask(damage, from, status, 2);
|
||||
overtimeDelay = 1000;
|
||||
} else {
|
||||
animationTime = broadcastStatusEffect(status);
|
||||
}
|
||||
@@ -943,12 +958,11 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
statiLock.unlock();
|
||||
}
|
||||
|
||||
status.setCancelTask(timerManager.schedule(cancelTask, duration + animationTime - 100));
|
||||
ch.registerMobStatus(mapid, status, cancelTask, duration + animationTime - 100, overtimeAction, overtimeDelay);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void applyMonsterBuff(final Map<MonsterStatus, Integer> stats, final int x, int skillId, long duration, MobSkill skill, final List<Integer> reflection) {
|
||||
TimerManager timerManager = TimerManager.getInstance();
|
||||
final Runnable cancelTask = new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -991,7 +1005,8 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
if (controller != null && !controller.isMapObjectVisible(this)) {
|
||||
controller.getClient().announce(packet);
|
||||
}
|
||||
effect.setCancelTask(timerManager.schedule(cancelTask, duration));
|
||||
|
||||
map.getChannelServer().registerMobStatus(map.getId(), effect, cancelTask, duration);
|
||||
}
|
||||
|
||||
private void debuffMobStat(MonsterStatus stat) {
|
||||
@@ -1191,15 +1206,13 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
private final int dealDamage;
|
||||
private final MapleCharacter chr;
|
||||
private final MonsterStatusEffect status;
|
||||
private final Runnable cancelTask;
|
||||
private final int type;
|
||||
private final MapleMap map;
|
||||
|
||||
private DamageTask(int dealDamage, MapleCharacter chr, MonsterStatusEffect status, Runnable cancelTask, int type) {
|
||||
private DamageTask(int dealDamage, MapleCharacter chr, MonsterStatusEffect status, int type) {
|
||||
this.dealDamage = dealDamage;
|
||||
this.chr = chr;
|
||||
this.status = status;
|
||||
this.cancelTask = cancelTask;
|
||||
this.type = type;
|
||||
this.map = chr.getMap();
|
||||
}
|
||||
@@ -1207,20 +1220,26 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
@Override
|
||||
public void run() {
|
||||
int curHp = hp.get();
|
||||
if(curHp <= 1) return;
|
||||
if(curHp <= 1) {
|
||||
map.getChannelServer().interruptMobStatus(map.getId(), status);
|
||||
return;
|
||||
}
|
||||
|
||||
int damage = dealDamage;
|
||||
if (damage >= curHp) {
|
||||
damage = curHp - 1;
|
||||
if (type == 1 || type == 2) {
|
||||
cancelTask.run();
|
||||
status.getCancelTask().cancel(false);
|
||||
map.getChannelServer().interruptMobStatus(map.getId(), status);
|
||||
}
|
||||
}
|
||||
if (damage > 0) {
|
||||
damage(chr, damage, true);
|
||||
if (type == 1) { // ninja ambush (type 2) is already displaying DOT
|
||||
if (type == 1) {
|
||||
map.broadcastMessage(MaplePacketCreator.damageMonster(getObjectId(), damage), getPosition());
|
||||
} else if (type == 2) {
|
||||
if(damage < dealDamage) { // ninja ambush (type 2) is already displaying DOT to the caster
|
||||
map.broadcastMessage(MaplePacketCreator.damageMonster(getObjectId(), damage), getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public class MapleMonsterInformationProvider {
|
||||
private final Map<Integer, List<Integer>> dropsChancePool = new HashMap<>(); // thanks to ronan
|
||||
private final Set<Integer> hasNoMultiEquipDrops = new HashSet<>();
|
||||
private final Map<Integer, List<MonsterDropEntry>> extraMultiEquipDrops = new HashMap<>();
|
||||
|
||||
private final Map<Pair<Integer, Integer>, Integer> mobSkillAnimationTime = new HashMap<>();
|
||||
|
||||
protected MapleMonsterInformationProvider() {
|
||||
retrieveGlobal();
|
||||
@@ -223,9 +225,17 @@ public class MapleMonsterInformationProvider {
|
||||
dropsChancePool.put(monsterId, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final void setMobSkillAnimationTime(int monsterId, int skillPos, int animationTime) {
|
||||
mobSkillAnimationTime.put(new Pair<>(monsterId, skillPos), animationTime);
|
||||
}
|
||||
|
||||
public final Integer getMobSkillAnimationTime(int monsterId, int skillPos) {
|
||||
Integer time = mobSkillAnimationTime.get(new Pair<>(monsterId, skillPos));
|
||||
return time == null ? 0 : time;
|
||||
}
|
||||
|
||||
public static ArrayList<Pair<Integer, String>> getMobsIDsFromName(String search)
|
||||
{
|
||||
public static ArrayList<Pair<Integer, String>> getMobsIDsFromName(String search) {
|
||||
MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File("wz/String.wz"));
|
||||
ArrayList<Pair<Integer, String>> retMobs = new ArrayList<Pair<Integer, String>>();
|
||||
MapleData data = dataProvider.getData("Mob.img");
|
||||
@@ -243,8 +253,7 @@ public class MapleMonsterInformationProvider {
|
||||
return retMobs;
|
||||
}
|
||||
|
||||
public static String getMobNameFromId(int id)
|
||||
{
|
||||
public static String getMobNameFromId(int id) {
|
||||
try
|
||||
{
|
||||
return MapleLifeFactory.getMonster(id).getName();
|
||||
@@ -261,8 +270,7 @@ public class MapleMonsterInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMobNameFromID(int id)
|
||||
{
|
||||
public static String getMobNameFromID(int id) {
|
||||
try
|
||||
{
|
||||
return MapleLifeFactory.getMonster(id).getName();
|
||||
|
||||
@@ -32,6 +32,7 @@ import client.status.MonsterStatus;
|
||||
import constants.GameConstants;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import server.TimerManager;
|
||||
import tools.Randomizer;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.MapleMapObjectType;
|
||||
@@ -103,6 +104,17 @@ public class MobSkill {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public void applyDelayedEffect(final MapleCharacter player, final MapleMonster monster, final boolean skill, final List<MapleCharacter> banishPlayers, int animationTime) {
|
||||
TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(monster.isAlive()) {
|
||||
applyEffect(player, monster, skill, banishPlayers);
|
||||
}
|
||||
}
|
||||
}, animationTime);
|
||||
}
|
||||
|
||||
public void applyEffect(MapleCharacter player, MapleMonster monster, boolean skill, List<MapleCharacter> banishPlayers) {
|
||||
MapleDisease disease = null;
|
||||
Map<MonsterStatus, Integer> stats = new ArrayMap<MonsterStatus, Integer>();
|
||||
@@ -282,15 +294,15 @@ public class MobSkill {
|
||||
System.out.println("Unhandled Mob skill: " + skillId);
|
||||
break;
|
||||
}
|
||||
if (stats.size() > 0) {
|
||||
if (lt != null && rb != null && skill) {
|
||||
for (MapleMapObject mons : getObjectsInRange(monster, MapleMapObjectType.MONSTER)) {
|
||||
((MapleMonster) mons).applyMonsterBuff(stats, getX(), getSkillId(), getDuration(), this, reflection);
|
||||
}
|
||||
} else {
|
||||
monster.applyMonsterBuff(stats, getX(), getSkillId(), getDuration(), this, reflection);
|
||||
}
|
||||
}
|
||||
if (stats.size() > 0) {
|
||||
if (lt != null && rb != null && skill) {
|
||||
for (MapleMapObject mons : getObjectsInRange(monster, MapleMapObjectType.MONSTER)) {
|
||||
((MapleMonster) mons).applyMonsterBuff(stats, getX(), getSkillId(), getDuration(), this, reflection);
|
||||
}
|
||||
} else {
|
||||
monster.applyMonsterBuff(stats, getX(), getSkillId(), getDuration(), this, reflection);
|
||||
}
|
||||
}
|
||||
if (disease != null) {
|
||||
if (lt != null && rb != null && skill) {
|
||||
int i = 0;
|
||||
|
||||
@@ -59,7 +59,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Comparator;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import scripting.map.MapScriptManager;
|
||||
@@ -255,15 +254,43 @@ public class MapleMap {
|
||||
public int getId() {
|
||||
return mapid;
|
||||
}
|
||||
|
||||
public Channel getChannelServer() {
|
||||
return Server.getInstance().getWorld(world).getChannel(channel);
|
||||
}
|
||||
|
||||
public MapleMap getReturnMap() {
|
||||
if(returnMapId == 999999999) return this;
|
||||
return Server.getInstance().getWorld(world).getChannel(channel).getMapFactory().getMap(returnMapId);
|
||||
return getChannelServer().getMapFactory().getMap(returnMapId);
|
||||
}
|
||||
|
||||
public int getReturnMapId() {
|
||||
return returnMapId;
|
||||
}
|
||||
|
||||
public MapleMap getForcedReturnMap() {
|
||||
return getChannelServer().getMapFactory().getMap(forcedReturnMap);
|
||||
}
|
||||
|
||||
public int getForcedReturnId() {
|
||||
return forcedReturnMap;
|
||||
}
|
||||
|
||||
public void setForcedReturnMap(int map) {
|
||||
this.forcedReturnMap = map;
|
||||
}
|
||||
|
||||
public long getTimeLimit() {
|
||||
return timeLimit;
|
||||
}
|
||||
|
||||
public void setTimeLimit(int timeLimit) {
|
||||
this.timeLimit = timeLimit;
|
||||
}
|
||||
|
||||
public int getTimeLeft() {
|
||||
return (int) ((timeLimit - System.currentTimeMillis()) / 1000);
|
||||
}
|
||||
|
||||
public void setReactorState() {
|
||||
chrRLock.lock();
|
||||
@@ -322,30 +349,6 @@ public class MapleMap {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getForcedReturnId() {
|
||||
return forcedReturnMap;
|
||||
}
|
||||
|
||||
public MapleMap getForcedReturnMap() {
|
||||
return Server.getInstance().getWorld(world).getChannel(channel).getMapFactory().getMap(forcedReturnMap);
|
||||
}
|
||||
|
||||
public void setForcedReturnMap(int map) {
|
||||
this.forcedReturnMap = map;
|
||||
}
|
||||
|
||||
public long getTimeLimit() {
|
||||
return timeLimit;
|
||||
}
|
||||
|
||||
public void setTimeLimit(int timeLimit) {
|
||||
this.timeLimit = timeLimit;
|
||||
}
|
||||
|
||||
public int getTimeLeft() {
|
||||
return (int) ((timeLimit - System.currentTimeMillis()) / 1000);
|
||||
}
|
||||
|
||||
public int getCurrentPartyId() {
|
||||
for (MapleCharacter chr : this.getCharacters()) {
|
||||
if (chr.getPartyId() != -1) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MapleReactor extends AbstractMapleMapObject {
|
||||
private boolean attackHit;
|
||||
private ScheduledFuture<?> timeoutTask = null;
|
||||
private Lock reactorLock = new MonitoredReentrantLock(MonitoredLockType.REACTOR, true);
|
||||
private Lock hitLock = new MonitoredReentrantLock(MonitoredLockType.REACTOR, true);
|
||||
private Lock hitLock = new MonitoredReentrantLock(MonitoredLockType.REACTOR_HIT, true);
|
||||
|
||||
public MapleReactor(MapleReactorStats stats, int rid) {
|
||||
this.evstate = (byte)0;
|
||||
|
||||
@@ -3877,12 +3877,13 @@ public class MaplePacketCreator {
|
||||
}
|
||||
|
||||
public static byte[] applyMonsterStatus(final int oid, final MonsterStatusEffect mse, final List<Integer> reflection) {
|
||||
Map<MonsterStatus, Integer> stati = mse.getStati();
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.APPLY_MONSTER_STATUS.getValue());
|
||||
mplew.writeInt(oid);
|
||||
mplew.writeLong(0);
|
||||
writeIntMask(mplew, mse.getStati());
|
||||
for (Map.Entry<MonsterStatus, Integer> stat : mse.getStati().entrySet()) {
|
||||
writeIntMask(mplew, stati);
|
||||
for (Map.Entry<MonsterStatus, Integer> stat : stati.entrySet()) {
|
||||
mplew.writeShort(stat.getValue());
|
||||
if (mse.isMonsterSkill()) {
|
||||
mplew.writeShort(mse.getMobSkill().getSkillId());
|
||||
@@ -3892,7 +3893,7 @@ public class MaplePacketCreator {
|
||||
}
|
||||
mplew.writeShort(-1); // might actually be the buffTime but it's not displayed anywhere
|
||||
}
|
||||
int size = mse.getStati().size(); // size
|
||||
int size = stati.size(); // size
|
||||
if (reflection != null) {
|
||||
for (Integer ref : reflection) {
|
||||
mplew.writeInt(ref);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
Copyleft 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
@@ -25,59 +25,56 @@ package tools.locks;
|
||||
*/
|
||||
|
||||
public enum MonitoredLockType {
|
||||
UNDEFINED(-1),
|
||||
CHR(0),
|
||||
EFF(1),
|
||||
PET(2),
|
||||
PRT(3),
|
||||
CLIENT(4),
|
||||
BOOK(5),
|
||||
ITEM(6),
|
||||
INVENTORY(7),
|
||||
SRVHANDLER_IDLE(8),
|
||||
SRVHANDLER_TEMP(9),
|
||||
BUFF_STORAGE(10),
|
||||
PLAYER_STORAGE(11),
|
||||
SERVER(12),
|
||||
MERCHANT(13),
|
||||
CHANNEL(14),
|
||||
GUILD(15),
|
||||
PARTY(16),
|
||||
WORLD_PARTY(17),
|
||||
WORLD_OWL(18),
|
||||
WORLD_PETS(19),
|
||||
WORLD_MOUNTS(20),
|
||||
WORLD_PSHOPS(21),
|
||||
WORLD_MERCHS(21),
|
||||
EIM(22),
|
||||
EIM_PARTY(23),
|
||||
EIM_SCRIPT(24),
|
||||
EM_LOBBY(25),
|
||||
EM_QUEUE(26),
|
||||
CASHSHOP(27),
|
||||
VISITOR_PSHOP(28),
|
||||
STORAGE(29),
|
||||
MOB_EXT(30),
|
||||
MOB(31),
|
||||
MOB_STATI(32),
|
||||
MOBSKILL_FACTORY(33),
|
||||
PORTAL(34),
|
||||
VISITOR_MERCH(35),
|
||||
MAP_CHRS(36),
|
||||
MAP_OBJS(37),
|
||||
MAP_FACTORY(38),
|
||||
MAP_ITEM(39),
|
||||
MAP_BOUNDS(40),
|
||||
MINIDUNGEON(41),
|
||||
REACTOR(42);
|
||||
|
||||
private final int i;
|
||||
|
||||
private MonitoredLockType(int val) {
|
||||
this.i = val;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return i;
|
||||
}
|
||||
UNDEFINED,
|
||||
CHARACTER_CHR,
|
||||
CHARACTER_EFF,
|
||||
CHARACTER_PET,
|
||||
CHARACTER_PRT,
|
||||
CLIENT,
|
||||
CLIENT_ENCODER,
|
||||
CLIENT_LOGIN,
|
||||
BOOK,
|
||||
ITEM,
|
||||
INVENTORY,
|
||||
SRVHANDLER_IDLE,
|
||||
SRVHANDLER_TEMP,
|
||||
BUFF_STORAGE,
|
||||
PLAYER_STORAGE,
|
||||
SERVER,
|
||||
SERVER_LOGIN,
|
||||
SERVER_DISEASES,
|
||||
MERCHANT,
|
||||
CHANNEL,
|
||||
CHANNEL_MOBSTATUS,
|
||||
GUILD,
|
||||
PARTY,
|
||||
WORLD_PARTY,
|
||||
WORLD_OWL,
|
||||
WORLD_PETS,
|
||||
WORLD_MOUNTS,
|
||||
WORLD_PSHOPS,
|
||||
WORLD_MERCHS,
|
||||
WORLD_MAPOBJS,
|
||||
EIM,
|
||||
EIM_PARTY,
|
||||
EIM_SCRIPT,
|
||||
EM_LOBBY,
|
||||
EM_QUEUE,
|
||||
CASHSHOP,
|
||||
VISITOR_PSHOP,
|
||||
STORAGE,
|
||||
MOB_EXT,
|
||||
MOB,
|
||||
MOB_STATI,
|
||||
MOBSKILL_FACTORY,
|
||||
PORTAL,
|
||||
VISITOR_MERCH,
|
||||
MAP_CHRS,
|
||||
MAP_OBJS,
|
||||
MAP_FACTORY,
|
||||
MAP_ITEM,
|
||||
MAP_BOUNDS,
|
||||
MINIDUNGEON,
|
||||
REACTOR,
|
||||
REACTOR_HIT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user