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!

[Tut] How to make your custom PQ check for party size

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
 
Newbie Spellweaver
Joined
Apr 12, 2008
Messages
10
Reaction score
0
Re: [Guide] How to make your custom PQ check for party size

lol nicee idk if this is a nooby question but is there a tut on how to create your own pq?
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

lol nicee idk if this is a nooby question but is there a tut on how to create your own pq?

Well, its actually very simple. First you have to think of what do you want? Basic kill and grap, jump quests, hit boxes to get items and so on?

Once you have decided, its time to add in appropriate npcs and also "seal" the map. You can also view other npcs such as kerning PQ npcs etc and just edit the texts/functions/rewards to whatever you want

One good example would be this
http://forum.ragezone.com/showthread.php?t=449586
 
Newbie Spellweaver
Joined
Apr 12, 2008
Messages
10
Reaction score
0
Re: [Guide] How to make your custom PQ check for party size

thanks for the link
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

Np :)
 
Newbie Spellweaver
Joined
Apr 12, 2008
Messages
10
Reaction score
0
Re: [Guide] How to make your custom PQ check for party size

hey did you set up ur server using pc.maple repack?
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

hey did you set up ur server using pc.maple repack?

Nope using sean's repack. I did nearly everything from scratch
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

and to IFLON Stop your Ducking nonsense
 
Newbie Spellweaver
Joined
Apr 12, 2008
Messages
10
Reaction score
0
Re: [Guide] How to make your custom PQ check for party size

oo hey im wondering if you know about port fowarding and if you can tell me if i did this correct?

and also i was wondering if you know why my cmd is refusing to the ip?
 

Attachments

You must be registered for see attachments list
Last edited:
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

oo hey im wondering if you know about port fowarding and if you can tell me if i did this correct?

and also i was wondering if you know why my cmd is refusing to the ip?

sorry. I just managed to see your images. Your using hamachi rite? why do i see the ip 5.242.185.180? If you are using hamachi, no need port forward.

2nd your 1st picture port 7575 to 7575 will only open up 1 channel when there are 2 channels in a normal repack. Edit that to the number of channels you have, 7575,7576 etc
 
Last edited:
Newbie Spellweaver
Joined
Apr 12, 2008
Messages
10
Reaction score
0
Re: [Guide] How to make your custom PQ check for party size

lol thanks , but just wondering do you know any solution to do the world cmd being blank?
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

Hmms, make sure ur db properties file and the other 3 properties file(world, channel, log in) details are correct. For db properties, make sure the user and pass are correct
 
Junior Spellweaver
Joined
Aug 4, 2008
Messages
181
Reaction score
0
Re: [Guide] How to make your custom PQ check for party size

Sick nice guide...
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Re: [Guide] How to make your custom PQ check for party size

Thanks ^^
 
Newbie Spellweaver
Joined
Mar 4, 2009
Messages
11
Reaction score
0
lol look at the date.. Its around 6 months old >.>
 
Back
Top