GuildPQ Queue system + revamped Warp mechanic

Added a queue system for waiting guilds outside the GPQ area. Changed
the way players are transported through maps on non-portal passing
cases: if not defined, a spawn point is chosen randomly for each player.
This commit is contained in:
ronancpl
2017-06-13 20:47:58 -03:00
parent 7a8bba98ca
commit 81f9226286
82 changed files with 669 additions and 375 deletions

View File

@@ -1,122 +1,106 @@
/*
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/>.
*/
/*
* @Author Lerk
*
* Shuang, Victoria Road: Excavation Site<Camp> (101030104)
*
* Start of Guild Quest
/**
* @author: Ronan
* @npc: Shuang
* @map: Victoria Road: Excavation Site<Camp> (101030104)
* @func: Start Guild PQ
*/
var status = 0;
var GQItems = new Array(1032033, 4001024, 4001025, 4001026, 4001027, 4001028, 4001029, 4001030, 4001031, 4001032, 4001033, 4001034, 4001035, 4001037);
var sel;
var em = null;
function findLobby(guild) {
for (var iterator = em.getInstances().iterator(); iterator.hasNext();) {
var lobby = iterator.next();
if(lobby.getIntProperty("guild") == guild) {
if(lobby.getIntProperty("canJoin") == 1) return lobby;
else return null;
}
}
return null;
}
function start() {
cm.sendSimple("The path to Sharenian starts here. What would you like to do? #b\r\n#L0#Start a Guild Quest#l\r\n#L1#Join your guild's Guild Quest#l");
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 == 1) {
if (selection == 0) { //Start
if (cm.getPlayer().getGuildId() == 0 || cm.getPlayer().getGuildRank() >= 3) { //no guild or not guild master/jr. master
cm.sendNext("Only a Master or Jr. Master of the guild can start an instance.");
cm.dispose();
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
else {
var em = cm.getEventManager("GuildQuest");
if (em == null)
cm.sendOk("This trial is currently under construction.");
else {
if(em.getProperty("gpqOpen").equals("false")) {
cm.sendOk("Another guild has already registered for the quest. Please try again later.");
} else if (getEimForGuild(em, cm.getPlayer().getGuildId()) != null)
cm.sendOk("Your guild already is already registered.");
else {
var guildId = cm.getPlayer().getGuildId();
var eim = em.newInstance(guildId);
em.startInstance(eim, cm.getPlayer().getName());
em.setProperty("gpqOpen", "false");
var map = eim.getMapInstance(990000000);
map.getPortal(5).setScriptName("guildwaitingenter");
map.getPortal(4).setScriptName("guildwaitingexit");
eim.registerPlayer(cm.getPlayer());
cm.guildMessage(5, "The guild has been entered into the Guild Quest. Please report to Shuang at the Excavation Camp on channel " + cm.getClient().getChannel() + ".");
for (var i = 0; i < GQItems.length; i++)
cm.removeAll(GQItems[i]);
if (mode == 1)
status++;
else
status--;
if (status == 0) {
em = cm.getEventManager("GuildQuest");
if(em == null) {
cm.sendOk("The Guild Quest has encountered an error.");
cm.dispose();
return;
}
}
cm.dispose();
}
}
else if (selection == 1) { //entering existing GQ
if (cm.getPlayer().getGuildId() == 0) { //no guild or not guild master/jr. master
cm.sendNext("You must be in a guild to join an instance.");
cm.dispose();
}
else {
var em = cm.getEventManager("GuildQuest");
if (em == null)
cm.sendOk("This trial is currently under construction.");
else {
var eim = getEimForGuild(em, cm.getPlayer().getGuildId());
if (eim == null)
cm.sendOk("Your guild is currently not registered for the Guild Quest.");
else {
if ("true".equals(eim.getProperty("canEnter"))) {
eim.registerPlayer(cm.getPlayer());
for (var i = 0; i < GQItems.length; i++)
cm.removeAll(GQItems[i]);
}
else
cm.sendOk("I'm sorry, but the guild has gone on without you. Try again later.");
cm.sendSimple("#e#b<Guild Quest: Sharenian Ruins>\r\n#k#n" + em.getProperty("party") + "\r\n\r\nThe path to Sharenian starts here. What would you like to do? #b\r\n#L0#Register your guild for Guild Quest#l\r\n#L1#Join your guild's Guild Quest#l\r\n#L2#I would like to hear more details.#l");
} else if (status == 1) {
sel = selection;
if (selection == 0) {
if(!cm.isGuildLeader()) {
cm.sendOk("Your guild master/jr.master must talk to me to register this guild quest.");
cm.dispose();
} else {
if(em.isQueueFull()) {
cm.sendOk("The queue on this channel is already full. Please be patient and try again after a while, or try on another channel.");
cm.dispose();
} else {
var qsize = em.getQueueSize();
cm.sendYesNo(((qsize > 0) ? "There is currently #r" + qsize + "#k guilds queued on. " : "") + "Do you wish for your guild to join this queue?");
}
}
} else if (selection == 1) {
if(cm.getPlayer().getGuildId() > 0) {
var eim = findLobby(cm.getPlayer().getGuildId());
if(eim == null) {
cm.sendOk("You don't have a guild registered and currently on strategy time to assist on this channel.");
} else {
if(cm.isLeader()) {
em.getEligibleParty(cm.getParty());
eim.registerParty(cm.getPlayer());
} else {
eim.registerPlayer(cm.getPlayer());
}
}
} else {
cm.sendOk("You can't participate in the guild quest if you don't pertain on a guild yourself!");
}
cm.dispose();
} else {
cm.sendOk("#e#b<Guild Quest: Sharenian Ruins>#k#n\r\n Team up with your guild members in an auspicious attempt to recover the Rubian from the skeleton's grasp, with teamwork overcoming many puzzles and challenges awaiting inside the Sharenian tombs. Great rewards can be obtained upon the instance completion, and Guild Points can be racked up for your Guild.");
cm.dispose();
}
}
cm.dispose();
} else if (status == 2) {
if (sel == 0) {
var entry = em.addGuildToQueue(cm.getPlayer().getGuildId(), cm.getPlayer().getId());
if(entry > 0) {
if(entry == 1) {
cm.sendOk("Your guild has been registered successfully. A message will pop on your chat keeping your guild aware about the registration status. Now, #rimportant#k: as the leader of this instance, #ryou must already be present on this channel#k the right moment your guild is called for the strategy time. #bThe missubmission of this action will void#k your guild registration as a whole, and the next guild will be called immediately. Must be noted also, that if you become absent from the end of the strategy time to any point on the duration of the instance, it will render the instance interrupted, and your guild will be moved out instantly, moving again the queue.");
}
} else if(entry == 0) {
cm.sendOk("The queue on this channel is already full. Please be patient and try again after a while, or try on another channel.");
} else {
cm.sendOk("Your guild is already queued on a channel. Please wait for your guild's turn.");
}
}
cm.dispose();
}
}
}
}
}
function getEimForGuild(em, id) {
var stringId = "" + id;
return em.getInstance(stringId);
}
function isGuildQuestOwner(em, id) {
var stringId = "" + id;
if(em.getProperty("curGuild").equals(stringId))
return true;
return false;
}