CPQ 1 CPQ 2 CASAMENTO

This commit is contained in:
Diego Armando de Freitas Matos
2019-03-06 21:55:47 -03:00
parent 799870df63
commit 90ad58f17f
60 changed files with 17442 additions and 15142 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +1,24 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is 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.
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/>.
*/
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 scripting.event;
import java.util.LinkedHashMap;
@@ -38,8 +38,9 @@ import scripting.AbstractScriptManager;
* @author Matze
*/
public class EventScriptManager extends AbstractScriptManager {
private class EventEntry {
public EventEntry(Invocable iv, EventManager em) {
this.iv = iv;
this.em = em;
@@ -78,10 +79,12 @@ public class EventScriptManager extends AbstractScriptManager {
}
}
}
private void reloadScripts() {
if (events.isEmpty()) return;
if (events.isEmpty()) {
return;
}
Channel cserv = events.values().iterator().next().em.getChannelServer();
for (Entry<String, EventEntry> entry : events.entrySet()) {
String script = entry.getKey();
@@ -89,11 +92,11 @@ public class EventScriptManager extends AbstractScriptManager {
events.put(script, new EventEntry(iv, new EventManager(cserv, iv, script)));
}
}
public void reload() {
cancel();
cancel();
reloadScripts();
init();
init();
}
public void cancel() {
@@ -101,4 +104,4 @@ public class EventScriptManager extends AbstractScriptManager {
entry.em.cancel();
}
}
}
}

View File

@@ -1,22 +1,22 @@
/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2018 RonanLana
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 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 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.
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/>.
*/
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 scripting.event.worker;
import constants.ServerConstants;
@@ -39,63 +39,64 @@ import server.ThreadManager;
* @author Ronan
*/
public class EventScriptScheduler {
private boolean disposed = false;
private int idleProcs = 0;
private Map<Runnable, Long> registeredEntries = new HashMap<>();
private ScheduledFuture<?> schedulerTask = null;
private MonitoredReentrantLock schedulerLock;
private Runnable monitorTask = new Runnable() {
@Override
public void run() {
runBaseSchedule();
}
};
@Override
public void run() {
runBaseSchedule();
}
};
public EventScriptScheduler() {
schedulerLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.EM_SCHDL, true);
}
private void runBaseSchedule() {
List<Runnable> toRemove;
Map<Runnable, Long> registeredEntriesCopy;
schedulerLock.lock();
try {
if(registeredEntries.isEmpty()) {
if (registeredEntries.isEmpty()) {
idleProcs++;
if(idleProcs >= ServerConstants.MOB_STATUS_MONITOR_LIFE) {
if(schedulerTask != null) {
if (idleProcs >= ServerConstants.MOB_STATUS_MONITOR_LIFE) {
if (schedulerTask != null) {
schedulerTask.cancel(false);
schedulerTask = null;
}
}
return;
}
idleProcs = 0;
registeredEntriesCopy = new HashMap<>(registeredEntries);
} finally {
schedulerLock.unlock();
}
long timeNow = Server.getInstance().getCurrentTime();
toRemove = new LinkedList<>();
for(Entry<Runnable, Long> rmd : registeredEntriesCopy.entrySet()) {
if(rmd.getValue() < timeNow) {
for (Entry<Runnable, Long> rmd : registeredEntriesCopy.entrySet()) {
if (rmd.getValue() < timeNow) {
Runnable r = rmd.getKey();
r.run(); // runs the scheduled action
toRemove.add(r);
}
}
if(!toRemove.isEmpty()) {
if (!toRemove.isEmpty()) {
schedulerLock.lock();
try {
for(Runnable r : toRemove) {
for (Runnable r : toRemove) {
registeredEntries.remove(r);
}
} finally {
@@ -103,17 +104,19 @@ public class EventScriptScheduler {
}
}
}
public void registerEntry(final Runnable scheduledAction, final long duration) {
ThreadManager.getInstance().newTask(new Runnable() {
@Override
public void run() {
schedulerLock.lock();
try {
idleProcs = 0;
if(schedulerTask == null) {
if(disposed) return;
if (schedulerTask == null) {
if (disposed) {
return;
}
schedulerTask = TimerManager.getInstance().register(monitorTask, ServerConstants.MOB_STATUS_MONITOR_PROC, ServerConstants.MOB_STATUS_MONITOR_PROC);
}
@@ -125,9 +128,9 @@ public class EventScriptScheduler {
}
});
}
public void cancelEntry(final Runnable scheduledAction) {
ThreadManager.getInstance().newTask(new Runnable() {
@Override
public void run() {
@@ -140,15 +143,15 @@ public class EventScriptScheduler {
}
});
}
public void dispose() {
ThreadManager.getInstance().newTask(new Runnable() {
@Override
public void run() {
schedulerLock.lock();
try {
if(schedulerTask != null) {
if (schedulerTask != null) {
schedulerTask.cancel(false);
schedulerTask = null;
}
@@ -163,7 +166,7 @@ public class EventScriptScheduler {
}
});
}
private void disposeLocks() {
LockCollector.getInstance().registerDisposeAction(new Runnable() {
@Override
@@ -172,7 +175,7 @@ public class EventScriptScheduler {
}
});
}
private void emptyLocks() {
schedulerLock = schedulerLock.dispose();
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -26,10 +26,12 @@ import client.MapleClient;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.script.Invocable;
import javax.script.ScriptException;
import net.server.world.MaplePartyCharacter;
import scripting.AbstractScriptManager;
import server.MapleItemInformationProvider.ScriptedItem;
@@ -43,43 +45,86 @@ import tools.MaplePacketCreator;
public class NPCScriptManager extends AbstractScriptManager {
private static NPCScriptManager instance = new NPCScriptManager();
public static NPCScriptManager getInstance() {
return instance;
}
private Map<MapleClient, NPCConversationManager> cms = new HashMap<>();
private Map<MapleClient, Invocable> scripts = new HashMap<>();
public boolean isNpcScriptAvailable(MapleClient c, String fileName) {
Invocable iv = null;
if (fileName != null) {
iv = getInvocable("npc/" + fileName + ".js", c);
}
return iv != null;
}
public boolean start(MapleClient c, int npc, MapleCharacter chr) {
return start(c, npc, -1, chr);
}
public boolean start(MapleClient c, int npc, int oid, MapleCharacter chr) {
return start(c, npc, oid, null, chr);
}
public boolean start(MapleClient c, int npc, String fileName, MapleCharacter chr) {
return start(c, npc, -1, fileName, chr);
}
public boolean start(MapleClient c, int npc, int oid, String fileName, MapleCharacter chr) {
return start(c, npc, oid, fileName, chr, false, "cm");
}
public boolean start(MapleClient c, ScriptedItem scriptItem, MapleCharacter chr) {
return start(c, scriptItem.getNpc(), -1, scriptItem.getScript(), chr, true, "im");
}
public void start(String filename, MapleClient c, int npc, List<MaplePartyCharacter> chrs) {
try {
NPCConversationManager cm = new NPCConversationManager(c, npc, chrs, true);
cm.dispose();
if (cms.containsKey(c)) {
return;
}
cms.put(c, cm);
Invocable iv = null;
iv = getInvocable("npc/" + filename + ".js", c);
NPCScriptManager npcsm = NPCScriptManager.getInstance();
if (iv == null || NPCScriptManager.getInstance() == null) {
c.getPlayer().dropMessage(1, npc + "");
cm.dispose();
return;
}
if (iv == null || npcsm == null) {
c.getPlayer().dropMessage(1, npc + "");
cm.dispose();
return;
}
engine.put("cm", cm);
scripts.put(c, iv);
try {
iv.invokeFunction("start", chrs);
} catch (final NoSuchMethodException nsme) {
try {
iv.invokeFunction("start", chrs);
} catch (final NoSuchMethodException nsma) {
nsma.printStackTrace();
}
}
} catch (final UndeclaredThrowableException ute) {
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", ute);
dispose(c);
} catch (final Exception e) {
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", e);
dispose(c);
}
}
private boolean start(MapleClient c, int npc, int oid, String fileName, MapleCharacter chr, boolean itemScript, String engineName) {
try {
NPCConversationManager cm = new NPCConversationManager(c, npc, oid, fileName, itemScript);
@@ -121,17 +166,17 @@ public class NPCScriptManager extends AbstractScriptManager {
} else {
c.announce(MaplePacketCreator.enableActions());
}
return true;
} catch (final UndeclaredThrowableException | ScriptException ute) {
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", ute);
dispose(c);
return false;
} catch (final Exception e) {
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", e);
dispose(c);
return false;
}
}
@@ -157,9 +202,9 @@ public class NPCScriptManager extends AbstractScriptManager {
c.getPlayer().setNpcCooldown(System.currentTimeMillis());
cms.remove(c);
scripts.remove(c);
String scriptFolder = (cm.isItemScript() ? "item" : "npc");
if(cm.getScriptName() != null) {
if (cm.getScriptName() != null) {
resetContext(scriptFolder + "/" + cm.getScriptName() + ".js", c);
} else {
resetContext(scriptFolder + "/" + cm.getNpc() + ".js", c);

View File

@@ -47,6 +47,8 @@ import server.maps.MapMonitor;
import server.maps.MapleMap;
import server.maps.MapleReactor;
import server.maps.ReactorDropEntry;
import server.partyquest.MapleCarnivalFactory;
import server.partyquest.MapleCarnivalFactory.MCSkill;
import tools.MaplePacketCreator;
/**
@@ -311,4 +313,20 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
}
}, timestamp);
}
public void dispelAllMonsters(int num, int team) { //dispels all mobs, cpq
final MCSkill skil = MapleCarnivalFactory.getInstance().getGuardian(num);
if (skil != null) {
for (MapleMonster mons : getMap().getMonsters()) {
if(mons.getTeam() == team) {
mons.dispelSkill(skil.getSkill());
}
}
}
if (team == 0) {
getPlayer().getMap().getRedTeamBuffs().remove(skil);
} else {
getPlayer().getMap().getBlueTeamBuffs().remove(skil);
}
}
}