Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[help] This NPC is not working properly, please report it

Initiate Mage
Joined
Aug 18, 2012
Messages
19
Reaction score
0
This NPC is not working properly, please report it
V0.97 XeonMsv97
xkaPk - [help] This NPC is not working properly, please report it - RaGEZONE Forums


NPCScriptManager.java
/*
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.npc;

import java.util.HashMap;
import java.util.Map;
import javax.script.Invocable;
import client.MapleClient;
import client.MapleCharacter;
import java.lang.reflect.UndeclaredThrowableException;
import scripting.AbstractScriptManager;

/**
*
* @author Matze
*/
public class NPCScriptManager extends AbstractScriptManager {
private Map<MapleClient, NPCConversationManager> cms = new HashMap<MapleClient, NPCConversationManager>();
private Map<MapleClient, NPCScript> scripts = new HashMap<MapleClient, NPCScript>();
private static NPCScriptManager instance = new NPCScriptManager();

public synchronized static NPCScriptManager getInstance() {
return instance;
}

public void start(MapleClient c, int npc, String filename, MapleCharacter chr) {
try {
NPCConversationManager cm = new NPCConversationManager(c, npc);
if (npc == 1202000) {
action(c, (byte) 1, (byte) 0, 0);
}
if (cms.containsKey(c)) {
dispose(c);
return;
}
cms.put(c, cm);
Invocable iv = null;
if (filename != null) {
iv = getInvocable("npc/" + filename + ".js", c);
}
if (iv == null) {
iv = getInvocable("npc/" + npc + ".js", c);
}
if (iv == null || NPCScriptManager.getInstance() == null) {
dispose(c);
return;
}
engine.put("cm", cm);
NPCScript ns = iv.getInterface(NPCScript.class);
scripts.put(c, ns);
if (chr == null) {
ns.start();
} else {
ns.start(chr);
}
} catch (UndeclaredThrowableException ute) {
ute.printStackTrace();
System.out.println("Error: NPC " + npc + ". UndeclaredThrowableException.");
dispose(c);
cms.remove(c);
notice(c);
} catch (Exception e) {
e.printStackTrace();
dispose(c);
cms.remove(c);
notice(c);
}
}

public void action(MapleClient c, byte mode, byte type, int selection) {
NPCScript ns = scripts.get(c);
if (ns != null) {
try {
ns.action(mode, type, selection);
} catch (UndeclaredThrowableException ute) {
ute.printStackTrace();
System.out.println("Error: NPC " + getCM(c).getNpc() + ". UndeclaredThrowableException.");
dispose(c);
notice(c);
} catch (Exception e) {
e.printStackTrace();
dispose(c);
notice(c);
}
}
}

public void dispose(NPCConversationManager cm) {
cms.remove(cm.getClient());
if(scripts.containsKey(cm.getClient())){
scripts.remove(cm.getClient());
}
resetContext("npc/" + cm.getNpc() + ".js", cm.getClient());
}

public void dispose(MapleClient c) {
if (cms.get(c) != null) {
dispose(cms.get(c));
}
}

public NPCConversationManager getCM(MapleClient c) {
return cms.get(c);
}

private void notice(MapleClient c) {
c.getPlayer().dropMessage(1, "This NPC is not working properly. Please report it.");
}
}
 

Attachments

You must be registered for see attachments list
Last edited:
Elite Diviner
Joined
May 4, 2011
Messages
491
Reaction score
105
First off I recommend you don't use that source it's loaded with bugs.. So is every source but this one is just.. wow

Ok that error is caused by something in the NPC's script cause it to "Not work properly"
either re-code the script or mess around till it works?
 
Upvote 0
Mythic Archon
Joined
Dec 25, 2011
Messages
723
Reaction score
97
We don't require your NPCScriptManager for a NPC script that doesn't work. Give us the NPC script.

I can't help you until you post the NPC Script. so...
 
Upvote 0
Back
Top