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!

Check for party size in custom PQ

Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Code:
importPackage(net.sf.odinms.world);

var exitMap;
var instanceId;
var minPlayers = 3

function init() {
	instanceId = 1;
        em.setProperty("shuffleReactors","true");
}

function monsterValue(eim, mobId) {
	return 1;
}

function setup() {
	exitMap = em.getChannelServer().getMapFactory().getMap(280090000); //room of tragedy
	var instanceName = "YWPQ" + instanceId;
	
	//YWPQ maps increasing gradually
	//var instanceMaps = new Array(230020101, 910010100, 221030501, 100000001, 924000002, 109040002, 109040003, 109040004, 109050000, 
	//	108000202, 922010600, 923010000, 280020000, 280020001);
	var eim = em.newInstance(instanceName);
	
	var mf = eim.getMapFactory();
	
	instanceId++;
	
	var map = mf.getMap(230020101);
	map.shuffleReactors();
	
	//no time limit yet until clock can be visible in all maps
	//em.schedule("timeOut", 60 * 60000);
	
	return eim;
}

function playerEntry(eim, player) {
	var map = eim.getMapInstance(230020101);
	player.changeMap(map, map.getPortal(0));
	
	//TODO: hold time across map changes
	//player.getClient().getSession().write(net.sf.odinms.tools.MaplePacketCreator.getClock(1800));

}

function playerDead(eim, player) {
	if (player.isAlive()) { //don't trigger on death, trigger on manual revive
		if (eim.isLeader(player)) { //check for party leader
			//boot whole party and end
			var party = eim.getPlayers();
			for (var i = 0; i < party.size(); i++) {
				playerExit(eim, party.get(i));
			}
			eim.dispose();
		}
		else { //boot dead player
			// If only 1 player is left, uncompletable:
			var party = eim.getPlayers();
			if (party.size() < minPlayers) { 
				for (var i = 0; i < party.size(); i++) {
					playerExit(eim,party.get(i));
				}
				eim.dispose();
			}
			else
				playerExit(eim, player);
		}
	}
}

function playerRevive(eim, player) {
	if (eim.isLeader(player)) { //check for party leader
		//boot whole party and end
		var party = eim.getPlayers();
		for (var i = 0; i < party.size(); i++) {
			playerExit(eim, party.get(i));
		}
		eim.dispose();
	}
	else { //boot dead player
		// If only 2 players are left, uncompletable:
		var party = eim.getPlayers();
		if (party.size() <= minPlayers) {
			for (var i = 0; i < party.size(); i++) {
				playerExit(eim,party.get(i));
			}
			eim.dispose();
		}
		else
			playerExit(eim, player);
	}
}

function playerDisconnected(eim, player) {
	if (eim.isLeader(player)) { //check for party leader
		//boot whole party and end
		var party = eim.getPlayers();
		for (var i = 0; i < party.size(); i++) {
			if (party.get(i).equals(player)) {
				removePlayer(eim, player);
			}			
			else {
				playerExit(eim, party.get(i));
			}
		}
		eim.dispose();
	}
	else { //boot d/ced player
		// If only 2 players are left, uncompletable:
		var party = eim.getPlayers();
		if (party.size() < minPlayers) {
			for (var i = 0; i < party.size(); i++) {
				playerExit(eim,party.get(i));
			}
			eim.dispose();
		}
		else
			playerExit(eim, player);
	}
}

function leftParty(eim, player) {
	// If only 2 players are left, uncompletable:
	var party = eim.getPlayers();
	if (party.size() < minPlayers) {
		for (var i = 0; i < party.size(); i++) {
			playerExit(eim,party.get(i));
		}
		eim.dispose();
	}
	else
		playerExit(eim, player);
}

function disbandParty(eim) {
	//boot whole party and end
	var party = eim.getPlayers();
	for (var i = 0; i < party.size(); i++) {
		playerExit(eim, party.get(i));
	}
	eim.dispose();
}

function playerExit(eim, player) {
	eim.unregisterPlayer(player);
	player.changeMap(exitMap, exitMap.getPortal(0));
}

//for offline players
function removePlayer(eim, player) {
	eim.unregisterPlayer(player);
	player.getMap().removePlayer(player);
	player.setMap(exitMap);
}

function clearPQ(eim) {
	//YWPQ does nothing special with winners
	var party = eim.getPlayers();
	for (var i = 0; i < party.size(); i++) {
		playerExit(eim, party.get(i));
	}
	eim.dispose();
}

function allMonstersDead(eim) {
        //do nothing; YWPQ has nothing to do with monster killing
}

function cancelSchedule() {
}

function timeOut() {
	var iter = em.getInstances().iterator();
	while (iter.hasNext()) {
		var eim = iter.next();
		if (eim.getPlayerCount() > 0) {
			var pIter = eim.getPlayers().iterator();
			while (pIter.hasNext()) {
				playerExit(eim, pIter.next());
			}
		}
		eim.dispose();
	}
}

This is to be placed in the event folder. Feel free to change the maps id to your PQ (var instanceMaps = new Array(230020101,...... and em.getChannelServer().getMapFactory().getMap(280090000);
Change var minPlayers = 3 to your preference. In this case, it will kick you out of the PQ if your party size is less than 3.
Change var instanceName = "YWPQ" to whatever name you want.
In world.properties, add YWPQ(change to whatever you want, must be same as above)
Example: net.sf.odinms.channel.events= lolcastle,3rdjob,ZakumPQ,KerningPQ,LudiPQ,GuildQuest,DollHouse,YWPQ(change this)

Code:
var status = 0;
var minLevel = 80;
var maxLevel = 200;
var minPlayers = 2;
var maxPlayers = 4;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			// Malady has no preamble, directly checks if you're in a party
			if (cm.getParty() == null) { // no party
				cm.sendOk("How about you and your party members collectively beating a quest? Here you'll find obstacles and problems where you won't be able to beat it without great teamwork.  If you want to try it, please tell the #bleader of your party#k to talk to me.");
				cm.dispose();
                                return;
			}
			if (!cm.isLeader()) { // not party leader
				cm.sendOk("If you want to try the quest, please tell the #bleader of your party#k to talk to me.");
				cm.dispose();
                        }
			else {
				// check if all party members are within 80-200 range, etc.
				var party = cm.getParty().getMembers();
				var mapId = cm.getChar().getMapId();
				var next = true;
				var levelValid = 0;
				var inMap = 0;
				// Temp removal for testing
				if (party.size() < minPlayers || party.size() > maxPlayers) 
					next = false;
				else {
					for (var i = 0; i < party.size() && next; i++) {
						if ((party.get(i).getLevel() >= minLevel) && (party.get(i).getLevel() <= maxLevel))
							levelValid += 1;
						if (party.get(i).getMapid() == mapId)
							inMap += 1;
					}
					if (levelValid < minPlayers || inMap < minPlayers)
						next = false;
				}
				if (next) {
					// Kick it into action.  Malady says nothing here, just warps you in.
					var em = cm.getEventManager("YWPQ");
					if (em == null) {
						cm.sendOk("This PQ is not currently available.");
					}
					else {
						// Begin the PQ.
						em.startInstance(cm.getParty(),cm.getChar().getMap());
						// Remove pass/coupons
						party = cm.getChar().getEventInstance().getPlayers();
						cm.removeFromParty(4001008, party);
						cm.removeFromParty(4001007, party);
					}
					cm.dispose();
				}
				else {
					cm.sendOk("Your party is not a party of four. Please make sure all your members are present and qualified to participate in this quest.  I see #b" + levelValid.toString() + " #kmembers are in the right level range, and #b" + inMap.toString() + "#k are here. If this seems wrong, #blog out and log back in,#k or reform the party.");
					cm.dispose();
				}
			}
		}
		else {
			cm.sendOk("Dialog is broken.");
			cm.dispose();
		}
	}
}

For me i used Malady as my NPC haha. Basically copied from kerning PQ and changed some stuff.
Change the min/max level and players to whatever you want.Edit the maps in the events.js .
1st map would be stage 1 of your PQ.

Don't flame me as its my 1st guide/release XD.
Please remove if its in the wrong section as i dunno where to place this. I place in guides as well as here anyway.
 
Junior Spellweaver
Joined
Jul 28, 2008
Messages
154
Reaction score
1
Re: [Release/Guide] Check for party size in custom PQ

Nice.

It's really easy if peeps know how to look in KPQ script..
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Release/Guide] Check for party size in custom PQ

Yeap i totally agree. This is just a little help for them to make life easier haha.
 
Junior Spellweaver
Joined
Jun 30, 2008
Messages
132
Reaction score
0
Re: [Release/Guide] Check for party size in custom PQ

Nice guide
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Re: [Release/Guide] Check for party size in custom PQ

Awesome :)
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Re: [Release/Guide] Check for party size in custom PQ

lol @ iflon
ignore ftw :D
 
Back
Top