Switch to Maven file structure
This commit is contained in:
302
src/main/java/server/partyquest/AriantColiseum.java
Normal file
302
src/main/java/server/partyquest/AriantColiseum.java
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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 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 server.partyquest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import client.MapleCharacter;
|
||||
import constants.game.GameConstants;
|
||||
import server.TimerManager;
|
||||
import server.expeditions.MapleExpedition;
|
||||
import server.expeditions.MapleExpeditionType;
|
||||
import server.maps.MapleMap;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class AriantColiseum {
|
||||
|
||||
private MapleExpedition exped;
|
||||
private MapleMap map;
|
||||
|
||||
private Map<MapleCharacter, Integer> score;
|
||||
private Map<MapleCharacter, Integer> rewardTier;
|
||||
private boolean scoreDirty = false;
|
||||
|
||||
private ScheduledFuture<?> ariantUpdate;
|
||||
private ScheduledFuture<?> ariantFinish;
|
||||
private ScheduledFuture<?> ariantScoreboard;
|
||||
|
||||
private int lostShards = 0;
|
||||
|
||||
private boolean eventClear = false;
|
||||
|
||||
public AriantColiseum(MapleMap eventMap, MapleExpedition expedition) {
|
||||
exped = expedition;
|
||||
exped.finishRegistration();
|
||||
|
||||
map = eventMap;
|
||||
map.resetFully();
|
||||
|
||||
int pqTimer = 10 * 60 * 1000;
|
||||
int pqTimerBoard = (9 * 60 * 1000) + 50 * 1000;
|
||||
|
||||
List<MapleCharacter> players = exped.getActiveMembers();
|
||||
score = new HashMap<>();
|
||||
rewardTier = new HashMap<>();
|
||||
for (MapleCharacter mc : players) {
|
||||
mc.changeMap(map, 0);
|
||||
mc.setAriantColiseum(this);
|
||||
mc.updateAriantScore();
|
||||
rewardTier.put(mc, 0);
|
||||
}
|
||||
|
||||
for (MapleCharacter mc : players) {
|
||||
mc.announce(MaplePacketCreator.updateAriantPQRanking(score));
|
||||
}
|
||||
|
||||
setAriantScoreBoard(TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showArenaResults();
|
||||
}
|
||||
}, pqTimerBoard));
|
||||
|
||||
setArenaFinish(TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
enterKingsRoom();
|
||||
}
|
||||
}, pqTimer));
|
||||
|
||||
setArenaUpdate(TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
broadcastAriantScoreUpdate();
|
||||
}
|
||||
}, 500, 500));
|
||||
}
|
||||
|
||||
private void setArenaUpdate(ScheduledFuture<?> ariantUpdate) {
|
||||
this.ariantUpdate = ariantUpdate;
|
||||
}
|
||||
|
||||
private void setArenaFinish(ScheduledFuture<?> arenaFinish) {
|
||||
this.ariantFinish = arenaFinish;
|
||||
}
|
||||
|
||||
private void setAriantScoreBoard(ScheduledFuture<?> ariantScore) {
|
||||
this.ariantScoreboard = ariantScore;
|
||||
}
|
||||
|
||||
private void cancelArenaUpdate() {
|
||||
if (ariantUpdate != null) {
|
||||
ariantUpdate.cancel(true);
|
||||
ariantUpdate = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelArenaFinish() {
|
||||
if (ariantFinish != null) {
|
||||
ariantFinish.cancel(true);
|
||||
ariantFinish = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelAriantScoreBoard() {
|
||||
if (ariantScoreboard != null) {
|
||||
ariantScoreboard.cancel(true);
|
||||
ariantScoreboard = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelAriantSchedules() {
|
||||
cancelArenaUpdate();
|
||||
cancelArenaFinish();
|
||||
cancelAriantScoreBoard();
|
||||
}
|
||||
|
||||
public int getAriantScore(MapleCharacter chr) {
|
||||
Integer chrScore = score.get(chr);
|
||||
return chrScore != null ? chrScore : 0;
|
||||
}
|
||||
|
||||
public void clearAriantScore(MapleCharacter chr) {
|
||||
score.remove(chr);
|
||||
}
|
||||
|
||||
public void updateAriantScore(MapleCharacter chr, int points) {
|
||||
if (map != null) {
|
||||
score.put(chr, points);
|
||||
scoreDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastAriantScoreUpdate() {
|
||||
if (scoreDirty) {
|
||||
for (MapleCharacter chr : score.keySet()) {
|
||||
chr.announce(MaplePacketCreator.updateAriantPQRanking(score));
|
||||
}
|
||||
scoreDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getAriantRewardTier(MapleCharacter chr) {
|
||||
Integer reward = rewardTier.get(chr);
|
||||
return reward != null ? reward : 0;
|
||||
}
|
||||
|
||||
public void clearAriantRewardTier(MapleCharacter chr) {
|
||||
rewardTier.remove(chr);
|
||||
}
|
||||
|
||||
public void addLostShards(int quantity) {
|
||||
lostShards += quantity;
|
||||
}
|
||||
|
||||
public void leaveArena(MapleCharacter chr) {
|
||||
if (!(eventClear && GameConstants.isAriantColiseumArena(chr.getMapId()))) {
|
||||
leaveArenaInternal(chr);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void leaveArenaInternal(MapleCharacter chr) {
|
||||
if (exped != null) {
|
||||
if (exped.removeMember(chr)) {
|
||||
int minSize = eventClear ? 1 : 2;
|
||||
if (exped.getActiveMembers().size() < minSize) {
|
||||
dispose();
|
||||
}
|
||||
chr.setAriantColiseum(null);
|
||||
|
||||
int shards = chr.countItem(4031868);
|
||||
chr.getAbstractPlayerInteraction().removeAll(4031868);
|
||||
chr.updateAriantScore(shards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playerDisconnected(MapleCharacter chr) {
|
||||
leaveArenaInternal(chr);
|
||||
}
|
||||
|
||||
private void showArenaResults() {
|
||||
eventClear = true;
|
||||
|
||||
if (map != null) {
|
||||
map.broadcastMessage(MaplePacketCreator.showAriantScoreBoard());
|
||||
map.killAllMonsters();
|
||||
|
||||
distributeAriantPoints();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isUnfairMatch(Integer winnerScore, Integer secondScore, Integer lostShardsScore, List<Integer> runnerupsScore) {
|
||||
if (winnerScore <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double runnerupsScoreCount = 0;
|
||||
for (Integer i : runnerupsScore) {
|
||||
runnerupsScoreCount += i;
|
||||
}
|
||||
|
||||
runnerupsScoreCount += lostShardsScore;
|
||||
secondScore += lostShardsScore;
|
||||
|
||||
double matchRes = runnerupsScoreCount / winnerScore;
|
||||
double runnerupRes = ((double) secondScore) / winnerScore;
|
||||
|
||||
return matchRes < 0.81770726891980117713114871015349 && (runnerupsScoreCount < 7 || runnerupRes < 0.5929);
|
||||
}
|
||||
|
||||
public void distributeAriantPoints() {
|
||||
Integer firstTop = -1, secondTop = -1;
|
||||
MapleCharacter winner = null;
|
||||
List<Integer> runnerups = new ArrayList<>();
|
||||
|
||||
for (Entry<MapleCharacter, Integer> e : score.entrySet()) {
|
||||
Integer s = e.getValue();
|
||||
if (s > firstTop) {
|
||||
secondTop = firstTop;
|
||||
firstTop = s;
|
||||
winner = e.getKey();
|
||||
} else if (s > secondTop) {
|
||||
secondTop = s;
|
||||
}
|
||||
|
||||
runnerups.add(s);
|
||||
rewardTier.put(e.getKey(), (int) Math.floor(s / 10));
|
||||
}
|
||||
|
||||
runnerups.remove(firstTop);
|
||||
if (isUnfairMatch(firstTop, secondTop, map.getDroppedItemsCountById(4031868) + lostShards, runnerups)) {
|
||||
rewardTier.put(winner, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private MapleExpeditionType getExpeditionType() {
|
||||
MapleExpeditionType type;
|
||||
if (map.getId() == 980010101) {
|
||||
type = MapleExpeditionType.ARIANT;
|
||||
} else if (map.getId() == 980010201) {
|
||||
type = MapleExpeditionType.ARIANT1;
|
||||
} else {
|
||||
type = MapleExpeditionType.ARIANT2;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
private void enterKingsRoom() {
|
||||
exped.removeChannelExpedition(map.getChannelServer());
|
||||
cancelAriantSchedules();
|
||||
|
||||
for (MapleCharacter chr : map.getAllPlayers()) {
|
||||
chr.changeMap(980010010, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void dispose() {
|
||||
if (exped != null) {
|
||||
exped.dispose(false);
|
||||
|
||||
for (MapleCharacter chr : exped.getActiveMembers()) {
|
||||
chr.setAriantColiseum(null);
|
||||
chr.changeMap(980010000, 0);
|
||||
}
|
||||
|
||||
map.getWorldServer().registerTimedMapObject(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
score.clear();
|
||||
exped = null;
|
||||
map = null;
|
||||
}
|
||||
}, 5 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/main/java/server/partyquest/GuardianSpawnPoint.java
Normal file
43
src/main/java/server/partyquest/GuardianSpawnPoint.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package server.partyquest;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author David
|
||||
*/
|
||||
public class GuardianSpawnPoint {
|
||||
|
||||
private Point position;
|
||||
private boolean taken;
|
||||
private int team = -1;
|
||||
|
||||
public GuardianSpawnPoint(Point a) {
|
||||
this.position = a;
|
||||
this.taken = true;
|
||||
}
|
||||
|
||||
public Point getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Point position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public boolean isTaken() {
|
||||
return taken;
|
||||
}
|
||||
|
||||
public void setTaken(boolean taken) {
|
||||
this.taken = taken;
|
||||
}
|
||||
|
||||
public int getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void setTeam(int team) {
|
||||
this.team = team;
|
||||
}
|
||||
}
|
||||
103
src/main/java/server/partyquest/MapleCarnivalFactory.java
Normal file
103
src/main/java/server/partyquest/MapleCarnivalFactory.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package server.partyquest;
|
||||
|
||||
import client.MapleDisease;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import server.life.MobSkillFactory;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.life.MobSkill;
|
||||
|
||||
/**
|
||||
*@author Drago (Dragohe4rt)
|
||||
*/
|
||||
public class MapleCarnivalFactory {
|
||||
|
||||
private final static MapleCarnivalFactory instance = new MapleCarnivalFactory();
|
||||
private final Map<Integer, MCSkill> skills = new HashMap<Integer, MCSkill>();
|
||||
private final Map<Integer, MCSkill> guardians = new HashMap<Integer, MCSkill>();
|
||||
private final MapleDataProvider dataRoot = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Skill.wz"));
|
||||
|
||||
private final List<Integer> singleTargetedSkills = new ArrayList<>();
|
||||
private final List<Integer> multiTargetedSkills = new ArrayList<>();
|
||||
|
||||
public MapleCarnivalFactory() {
|
||||
//whoosh
|
||||
initialize();
|
||||
}
|
||||
|
||||
public static final MapleCarnivalFactory getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
if (skills.size() != 0) {
|
||||
return;
|
||||
}
|
||||
for (MapleData z : dataRoot.getData("MCSkill.img")) {
|
||||
Integer id = Integer.parseInt(z.getName());
|
||||
MCSkill ms = new MCSkill(MapleDataTool.getInt("spendCP", z, 0), MapleDataTool.getInt("mobSkillID", z, 0), MapleDataTool.getInt("level", z, 0), MapleDataTool.getInt("target", z, 1) > 1);
|
||||
|
||||
skills.put(id, ms);
|
||||
if (ms.targetsAll) {
|
||||
multiTargetedSkills.add(id);
|
||||
} else {
|
||||
singleTargetedSkills.add(id);
|
||||
}
|
||||
}
|
||||
for (MapleData z : dataRoot.getData("MCGuardian.img")) {
|
||||
guardians.put(Integer.parseInt(z.getName()), new MCSkill(MapleDataTool.getInt("spendCP", z, 0), MapleDataTool.getInt("mobSkillID", z, 0), MapleDataTool.getInt("level", z, 0), true));
|
||||
}
|
||||
}
|
||||
|
||||
private MCSkill randomizeSkill(boolean multi) {
|
||||
if (multi) {
|
||||
return skills.get(multiTargetedSkills.get((int) (Math.random() * multiTargetedSkills.size())));
|
||||
} else {
|
||||
return skills.get(singleTargetedSkills.get((int) (Math.random() * singleTargetedSkills.size())));
|
||||
}
|
||||
}
|
||||
|
||||
public MCSkill getSkill(final int id) {
|
||||
MCSkill skill = skills.get(id);
|
||||
if (skill != null && skill.skillid <= 0) {
|
||||
return randomizeSkill(skill.targetsAll);
|
||||
} else {
|
||||
return skill;
|
||||
}
|
||||
}
|
||||
|
||||
public MCSkill getGuardian(final int id) {
|
||||
return guardians.get(id);
|
||||
}
|
||||
|
||||
public static class MCSkill {
|
||||
|
||||
public int cpLoss, skillid, level;
|
||||
public boolean targetsAll;
|
||||
|
||||
public MCSkill(int _cpLoss, int _skillid, int _level, boolean _targetsAll) {
|
||||
cpLoss = _cpLoss;
|
||||
skillid = _skillid;
|
||||
level = _level;
|
||||
targetsAll = _targetsAll;
|
||||
}
|
||||
|
||||
public MobSkill getSkill() {
|
||||
return getMobSkill(skillid, level);
|
||||
}
|
||||
|
||||
public static MobSkill getMobSkill(int skillid, int level) {
|
||||
return MobSkillFactory.getMobSkill(skillid, level);
|
||||
}
|
||||
|
||||
public MapleDisease getDisease() {
|
||||
return MapleDisease.getBySkill(skillid);
|
||||
}
|
||||
}
|
||||
}
|
||||
545
src/main/java/server/partyquest/MonsterCarnival.java
Normal file
545
src/main/java/server/partyquest/MonsterCarnival.java
Normal file
@@ -0,0 +1,545 @@
|
||||
package server.partyquest;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import client.MapleCharacter;
|
||||
import config.YamlConfig;
|
||||
import constants.string.LanguageConstants;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import server.TimerManager;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleReactor;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
* @author Drago (Dragohe4rt)
|
||||
*/
|
||||
public class MonsterCarnival {
|
||||
|
||||
public static int D = 3;
|
||||
public static int C = 2;
|
||||
public static int B = 1;
|
||||
public static int A = 0;
|
||||
|
||||
private MapleParty p1, p2;
|
||||
private MapleMap map;
|
||||
private ScheduledFuture<?> timer, effectTimer, respawnTask;
|
||||
private long startTime = 0;
|
||||
private int summonsR = 0, summonsB = 0, room = 0;
|
||||
private MapleCharacter leader1, leader2, team1, team2;
|
||||
private int redCP, blueCP, redTotalCP, blueTotalCP, redTimeupCP, blueTimeupCP;
|
||||
private boolean cpq1;
|
||||
|
||||
public MonsterCarnival(MapleParty p1, MapleParty p2, int mapid, boolean cpq1, int room) {
|
||||
try {
|
||||
this.cpq1 = cpq1;
|
||||
this.room = room;
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
Channel cs = Server.getInstance().getWorld(p2.getLeader().getWorld()).getChannel(p2.getLeader().getChannel());
|
||||
p1.setEnemy(p2);
|
||||
p2.setEnemy(p1);
|
||||
map = cs.getMapFactory().getDisposableMap(mapid);
|
||||
startTime = System.currentTimeMillis() + 10 * 60 * 1000;
|
||||
int redPortal = 0;
|
||||
int bluePortal = 0;
|
||||
if (map.isPurpleCPQMap()) {
|
||||
redPortal = 2;
|
||||
bluePortal = 1;
|
||||
}
|
||||
for (MaplePartyCharacter mpc : p1.getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setMonsterCarnival(this);
|
||||
mc.setTeam(0);
|
||||
mc.setFestivalPoints(0);
|
||||
mc.forceChangeMap(map, map.getPortal(redPortal));
|
||||
mc.dropMessage(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntry));
|
||||
if (p1.getLeader().getId() == mc.getId()) {
|
||||
leader1 = mc;
|
||||
}
|
||||
team1 = mc;
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : p2.getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setMonsterCarnival(this);
|
||||
mc.setTeam(1);
|
||||
mc.setFestivalPoints(0);
|
||||
mc.forceChangeMap(map, map.getPortal(bluePortal));
|
||||
mc.dropMessage(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntry));
|
||||
if (p2.getLeader().getId() == mc.getId()) {
|
||||
leader2 = mc;
|
||||
}
|
||||
team2 = mc;
|
||||
}
|
||||
}
|
||||
if (team1 == null || team2 == null) {
|
||||
for (MaplePartyCharacter mpc : p1.getMembers()) {
|
||||
MapleCharacter chr = mpc.getPlayer();
|
||||
if (chr != null) {
|
||||
chr.dropMessage(5, LanguageConstants.getMessage(chr, LanguageConstants.CPQError));
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : p2.getMembers()) {
|
||||
MapleCharacter chr = mpc.getPlayer();
|
||||
if (chr != null) {
|
||||
chr.dropMessage(5, LanguageConstants.getMessage(chr, LanguageConstants.CPQError));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// thanks Atoot, Vcoc for noting double CPQ functional being sent to players in CPQ start
|
||||
|
||||
timer = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
timeUp();
|
||||
}
|
||||
}, map.getTimeDefault() * 1000); // thanks Atoot for noticing an irregular "event extended" issue here
|
||||
effectTimer = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
complete();
|
||||
}
|
||||
}, map.getTimeDefault() * 1000 - 10 * 1000);
|
||||
respawnTask = TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
respawn();
|
||||
}
|
||||
}, YamlConfig.config.server.RESPAWN_INTERVAL);
|
||||
|
||||
cs.initMonsterCarnival(cpq1, room);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void respawn() {
|
||||
map.respawn();
|
||||
}
|
||||
|
||||
public void playerDisconnected(int charid) {
|
||||
int team = -1;
|
||||
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
|
||||
if (mpc.getId() == charid) {
|
||||
team = 0;
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
|
||||
if (mpc.getId() == charid) {
|
||||
team = 1;
|
||||
}
|
||||
}
|
||||
for (MapleCharacter chrMap : map.getAllPlayers()) {
|
||||
if (team == -1) {
|
||||
team = 1;
|
||||
}
|
||||
String teamS = "";
|
||||
switch (team) {
|
||||
case 0:
|
||||
teamS = LanguageConstants.getMessage(chrMap, LanguageConstants.CPQRed);
|
||||
break;
|
||||
case 1:
|
||||
teamS = LanguageConstants.getMessage(chrMap, LanguageConstants.CPQBlue);
|
||||
break;
|
||||
}
|
||||
chrMap.dropMessage(5, teamS + LanguageConstants.getMessage(chrMap, LanguageConstants.CPQPlayerExit));
|
||||
}
|
||||
earlyFinish();
|
||||
}
|
||||
|
||||
private void earlyFinish() {
|
||||
dispose(true);
|
||||
}
|
||||
|
||||
public void leftParty(int charid) {
|
||||
playerDisconnected(charid);
|
||||
}
|
||||
|
||||
protected void dispose() {
|
||||
dispose(false);
|
||||
}
|
||||
|
||||
public boolean canSummonR() {
|
||||
return summonsR < map.getMaxMobs();
|
||||
}
|
||||
|
||||
public void summonR() {
|
||||
summonsR++;
|
||||
}
|
||||
|
||||
public boolean canSummonB() {
|
||||
return summonsB < map.getMaxMobs();
|
||||
}
|
||||
|
||||
public void summonB() {
|
||||
summonsB++;
|
||||
}
|
||||
|
||||
public boolean canGuardianR() {
|
||||
int teamReactors = 0;
|
||||
for (MapleReactor react : map.getAllReactors()) {
|
||||
if (react.getName().substring(0, 1).contentEquals("0")) {
|
||||
teamReactors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return teamReactors < map.getMaxReactors();
|
||||
}
|
||||
|
||||
public boolean canGuardianB() {
|
||||
int teamReactors = 0;
|
||||
for (MapleReactor react : map.getAllReactors()) {
|
||||
if (react.getName().substring(0, 1).contentEquals("1")) {
|
||||
teamReactors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return teamReactors < map.getMaxReactors();
|
||||
}
|
||||
|
||||
protected void dispose(boolean warpout) {
|
||||
Channel cs = map.getChannelServer();
|
||||
MapleMap out;
|
||||
if (!cpq1) { // cpq2
|
||||
out = cs.getMapFactory().getMap(980030010);
|
||||
} else {
|
||||
out = cs.getMapFactory().getMap(980000010);
|
||||
}
|
||||
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.resetCP();
|
||||
mc.setTeam(-1);
|
||||
mc.setMonsterCarnival(null);
|
||||
if (warpout) {
|
||||
mc.changeMap(out, out.getPortal(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.resetCP();
|
||||
mc.setTeam(-1);
|
||||
mc.setMonsterCarnival(null);
|
||||
if (warpout) {
|
||||
mc.changeMap(out, out.getPortal(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.timer != null) {
|
||||
this.timer.cancel(true);
|
||||
this.timer = null;
|
||||
}
|
||||
if (this.effectTimer != null) {
|
||||
this.effectTimer.cancel(true);
|
||||
this.effectTimer = null;
|
||||
}
|
||||
if (this.respawnTask != null) {
|
||||
this.respawnTask.cancel(true);
|
||||
this.respawnTask = null;
|
||||
}
|
||||
redTotalCP = 0;
|
||||
blueTotalCP = 0;
|
||||
leader1.getParty().setEnemy(null);
|
||||
leader2.getParty().setEnemy(null);
|
||||
map.dispose();
|
||||
map = null;
|
||||
|
||||
cs.finishMonsterCarnival(cpq1, room);
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
public ScheduledFuture<?> getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
|
||||
private void finish(int winningTeam) {
|
||||
try {
|
||||
Channel cs = map.getChannelServer();
|
||||
if (winningTeam == 0) {
|
||||
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.gainFestivalPoints(this.redTotalCP);
|
||||
mc.setMonsterCarnival(null);
|
||||
if (cpq1) {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 2), cs.getMapFactory().getMap(map.getId() + 2).getPortal(0));
|
||||
} else {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 200), cs.getMapFactory().getMap(map.getId() + 200).getPortal(0));
|
||||
}
|
||||
mc.setTeam(-1);
|
||||
mc.dispelDebuffs();
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.gainFestivalPoints(this.blueTotalCP);
|
||||
mc.setMonsterCarnival(null);
|
||||
if (cpq1) {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 3), cs.getMapFactory().getMap(map.getId() + 3).getPortal(0));
|
||||
} else {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 300), cs.getMapFactory().getMap(map.getId() + 300).getPortal(0));
|
||||
}
|
||||
mc.setTeam(-1);
|
||||
mc.dispelDebuffs();
|
||||
}
|
||||
}
|
||||
} else if (winningTeam == 1) {
|
||||
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.gainFestivalPoints(this.blueTotalCP);
|
||||
mc.setMonsterCarnival(null);
|
||||
if (cpq1) {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 2), cs.getMapFactory().getMap(map.getId() + 2).getPortal(0));
|
||||
} else {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 200), cs.getMapFactory().getMap(map.getId() + 200).getPortal(0));
|
||||
}
|
||||
mc.setTeam(-1);
|
||||
mc.dispelDebuffs();
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.gainFestivalPoints(this.redTotalCP);
|
||||
mc.setMonsterCarnival(null);
|
||||
if (cpq1) {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 3), cs.getMapFactory().getMap(map.getId() + 3).getPortal(0));
|
||||
} else {
|
||||
mc.changeMap(cs.getMapFactory().getMap(map.getId() + 300), cs.getMapFactory().getMap(map.getId() + 300).getPortal(0));
|
||||
}
|
||||
mc.setTeam(-1);
|
||||
mc.dispelDebuffs();
|
||||
}
|
||||
}
|
||||
}
|
||||
dispose();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void timeUp() {
|
||||
int cp1 = this.redTimeupCP;
|
||||
int cp2 = this.blueTimeupCP;
|
||||
if (cp1 == cp2) {
|
||||
extendTime();
|
||||
return;
|
||||
}
|
||||
if (cp1 > cp2) {
|
||||
finish(0);
|
||||
} else {
|
||||
finish(1);
|
||||
}
|
||||
}
|
||||
|
||||
public long getTimeLeft() {
|
||||
return (startTime - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public int getTimeLeftSeconds() {
|
||||
return (int) (getTimeLeft() / 1000);
|
||||
}
|
||||
|
||||
private void extendTime() {
|
||||
for (MapleCharacter chrMap : map.getAllPlayers()) {
|
||||
chrMap.dropMessage(5, LanguageConstants.getMessage(chrMap, LanguageConstants.CPQExtendTime));
|
||||
}
|
||||
startTime = System.currentTimeMillis() + 3 * 60 * 1000;
|
||||
|
||||
map.broadcastMessage(MaplePacketCreator.getClock(3 * 60));
|
||||
|
||||
timer = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
timeUp();
|
||||
}
|
||||
}, map.getTimeExpand() * 1000);
|
||||
effectTimer = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
complete();
|
||||
}
|
||||
|
||||
}, map.getTimeExpand() * 1000 - 10 * 1000); // thanks Vcoc for noticing a time set issue here
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
int cp1 = this.redTotalCP;
|
||||
int cp2 = this.blueTotalCP;
|
||||
|
||||
this.redTimeupCP = cp1;
|
||||
this.blueTimeupCP = cp2;
|
||||
|
||||
if (cp1 == cp2) {
|
||||
return;
|
||||
}
|
||||
boolean redWin = cp1 > cp2;
|
||||
int chnl = leader1.getClient().getChannel();
|
||||
int chnl1 = leader2.getClient().getChannel();
|
||||
if (chnl != chnl1) {
|
||||
throw new RuntimeException("Os lideres estao em canais diferentes.");
|
||||
}
|
||||
|
||||
map.killAllMonsters();
|
||||
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
if (redWin) {
|
||||
mc.getClient().announce(MaplePacketCreator.showEffect("quest/carnival/win"));
|
||||
mc.getClient().announce(MaplePacketCreator.playSound("MobCarnival/Win"));
|
||||
mc.dispelDebuffs();
|
||||
} else {
|
||||
mc.getClient().announce(MaplePacketCreator.showEffect("quest/carnival/lose"));
|
||||
mc.getClient().announce(MaplePacketCreator.playSound("MobCarnival/Lose"));
|
||||
mc.dispelDebuffs();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
if (!redWin) {
|
||||
mc.getClient().announce(MaplePacketCreator.showEffect("quest/carnival/win"));
|
||||
mc.getClient().announce(MaplePacketCreator.playSound("MobCarnival/Win"));
|
||||
mc.dispelDebuffs();
|
||||
} else {
|
||||
mc.getClient().announce(MaplePacketCreator.showEffect("quest/carnival/lose"));
|
||||
mc.getClient().announce(MaplePacketCreator.playSound("MobCarnival/Lose"));
|
||||
mc.dispelDebuffs();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MapleParty getRed() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
public void setRed(MapleParty p1) {
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
public MapleParty getBlue() {
|
||||
return p2;
|
||||
}
|
||||
|
||||
public void setBlue(MapleParty p2) {
|
||||
this.p2 = p2;
|
||||
}
|
||||
|
||||
public MapleCharacter getLeader1() {
|
||||
return leader1;
|
||||
}
|
||||
|
||||
public void setLeader1(MapleCharacter leader1) {
|
||||
this.leader1 = leader1;
|
||||
}
|
||||
|
||||
public MapleCharacter getLeader2() {
|
||||
return leader2;
|
||||
}
|
||||
|
||||
public void setLeader2(MapleCharacter leader2) {
|
||||
this.leader2 = leader2;
|
||||
}
|
||||
|
||||
public MapleCharacter getEnemyLeader(int team) {
|
||||
switch (team) {
|
||||
case 0:
|
||||
return leader2;
|
||||
case 1:
|
||||
return leader1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getBlueCP() {
|
||||
return blueCP;
|
||||
}
|
||||
|
||||
public void setBlueCP(int blueCP) {
|
||||
this.blueCP = blueCP;
|
||||
}
|
||||
|
||||
public int getBlueTotalCP() {
|
||||
return blueTotalCP;
|
||||
}
|
||||
|
||||
public void setBlueTotalCP(int blueTotalCP) {
|
||||
this.blueTotalCP = blueTotalCP;
|
||||
}
|
||||
|
||||
public int getRedCP() {
|
||||
return redCP;
|
||||
}
|
||||
|
||||
public void setRedCP(int redCP) {
|
||||
this.redCP = redCP;
|
||||
}
|
||||
|
||||
public int getRedTotalCP() {
|
||||
return redTotalCP;
|
||||
}
|
||||
|
||||
public void setRedTotalCP(int redTotalCP) {
|
||||
this.redTotalCP = redTotalCP;
|
||||
}
|
||||
|
||||
public int getTotalCP(int team) {
|
||||
if (team == 0) {
|
||||
return redTotalCP;
|
||||
} else if (team == 1) {
|
||||
return blueTotalCP;
|
||||
} else {
|
||||
throw new RuntimeException("Equipe desconhecida");
|
||||
}
|
||||
}
|
||||
|
||||
public void setTotalCP(int totalCP, int team) {
|
||||
if (team == 0) {
|
||||
this.redTotalCP = totalCP;
|
||||
} else if (team == 1) {
|
||||
this.blueTotalCP = totalCP;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCP(int team) {
|
||||
if (team == 0) {
|
||||
return redCP;
|
||||
} else if (team == 1) {
|
||||
return blueCP;
|
||||
} else {
|
||||
throw new RuntimeException("Equipe desconhecida" + team);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCP(int CP, int team) {
|
||||
if (team == 0) {
|
||||
this.redCP = CP;
|
||||
} else if (team == 1) {
|
||||
this.blueCP = CP;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRoom() {
|
||||
return this.room;
|
||||
}
|
||||
|
||||
public MapleMap getEventMap() {
|
||||
return this.map;
|
||||
}
|
||||
}
|
||||
125
src/main/java/server/partyquest/MonsterCarnivalParty.java
Normal file
125
src/main/java/server/partyquest/MonsterCarnivalParty.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package server.partyquest;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import server.maps.MapleMap;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
* @author Rob
|
||||
*/
|
||||
public class MonsterCarnivalParty {
|
||||
|
||||
private List<MapleCharacter> members = new LinkedList<>();
|
||||
private MapleCharacter leader;
|
||||
private byte team;
|
||||
private short availableCP = 0, totalCP = 0;
|
||||
private int summons = 8;
|
||||
private boolean winner = false;
|
||||
|
||||
public MonsterCarnivalParty(final MapleCharacter owner, final List<MapleCharacter> members1, final byte team1) {
|
||||
leader = owner;
|
||||
members = members1;
|
||||
team = team1;
|
||||
|
||||
for (final MapleCharacter chr : members) {
|
||||
chr.setMonsterCarnivalParty(this);
|
||||
chr.setTeam(team);
|
||||
}
|
||||
}
|
||||
|
||||
public final MapleCharacter getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
public void addCP(MapleCharacter player, int ammount) {
|
||||
totalCP += ammount;
|
||||
availableCP += ammount;
|
||||
player.addCP(ammount);
|
||||
}
|
||||
|
||||
public int getTotalCP() {
|
||||
return totalCP;
|
||||
}
|
||||
|
||||
public int getAvailableCP() {
|
||||
return availableCP;
|
||||
}
|
||||
|
||||
public void useCP(MapleCharacter player, int ammount) {
|
||||
availableCP -= ammount;
|
||||
player.useCP(ammount);
|
||||
}
|
||||
|
||||
public List<MapleCharacter> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
public int getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void warpOut(final int map) {
|
||||
for (MapleCharacter chr : members) {
|
||||
chr.changeMap(map, 0);
|
||||
chr.setMonsterCarnivalParty(null);
|
||||
chr.setMonsterCarnival(null);
|
||||
}
|
||||
members.clear();
|
||||
}
|
||||
|
||||
public void warp(final MapleMap map, final int portalid) {
|
||||
for (MapleCharacter chr : members) {
|
||||
chr.changeMap(map, map.getPortal(portalid));
|
||||
}
|
||||
}
|
||||
|
||||
public void warpOut() {
|
||||
if (winner == true)
|
||||
warpOut(980000003 + (leader.getMonsterCarnival().getRoom() * 100));
|
||||
else
|
||||
warpOut(980000004 + (leader.getMonsterCarnival().getRoom() * 100));
|
||||
}
|
||||
|
||||
public boolean allInMap(MapleMap map) {
|
||||
boolean status = true;
|
||||
for (MapleCharacter chr : members) {
|
||||
if (chr.getMap() != map) {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public void removeMember(MapleCharacter chr) {
|
||||
members.remove(chr);
|
||||
chr.changeMap(980000010);
|
||||
chr.setMonsterCarnivalParty(null);
|
||||
chr.setMonsterCarnival(null);
|
||||
}
|
||||
|
||||
public boolean isWinner() {
|
||||
return winner;
|
||||
}
|
||||
|
||||
public void setWinner(boolean status) {
|
||||
winner = status;
|
||||
}
|
||||
|
||||
public void displayMatchResult() {
|
||||
final String effect = winner ? "quest/carnival/win" : "quest/carnival/lose";
|
||||
|
||||
for (final MapleCharacter chr : members) {
|
||||
chr.announce(MaplePacketCreator.showEffect(effect));
|
||||
}
|
||||
}
|
||||
|
||||
public void summon() {
|
||||
this.summons--;
|
||||
}
|
||||
|
||||
public boolean canSummon() {
|
||||
return this.summons > 0;
|
||||
}
|
||||
}
|
||||
113
src/main/java/server/partyquest/PartyQuest.java
Normal file
113
src/main/java/server/partyquest/PartyQuest.java
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
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 server.partyquest;
|
||||
|
||||
import client.MapleCharacter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import tools.FilePrinter;
|
||||
import net.server.Server;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public class PartyQuest {
|
||||
int channel, world;
|
||||
MapleParty party;
|
||||
List<MapleCharacter> participants = new ArrayList<>();
|
||||
|
||||
public PartyQuest(MapleParty party) {
|
||||
this.party = party;
|
||||
MaplePartyCharacter leader = party.getLeader();
|
||||
channel = leader.getChannel();
|
||||
world = leader.getWorld();
|
||||
int mapid = leader.getMapId();
|
||||
for (MaplePartyCharacter pchr : party.getMembers()) {
|
||||
if (pchr.getChannel() == channel && pchr.getMapId() == mapid) {
|
||||
MapleCharacter chr = Server.getInstance().getWorld(world).getChannel(channel).getPlayerStorage().getCharacterById(pchr.getId());
|
||||
if (chr != null)
|
||||
this.participants.add(chr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MapleParty getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public List<MapleCharacter> getParticipants() {
|
||||
return participants;
|
||||
}
|
||||
|
||||
public void removeParticipant(MapleCharacter chr) throws Throwable {
|
||||
synchronized (participants) {
|
||||
participants.remove(chr);
|
||||
chr.setPartyQuest(null);
|
||||
if (participants.isEmpty()) super.finalize();
|
||||
//System.gc();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getExp(String PQ, int level) {
|
||||
if (PQ.equals("HenesysPQ")){
|
||||
return 1250 * level / 5;
|
||||
} else if(PQ.equals("KerningPQFinal")){
|
||||
return 500 * level / 5;
|
||||
} else if(PQ.equals("KerningPQ4th")){
|
||||
return 400 * level / 5;
|
||||
} else if(PQ.equals("KerningPQ3rd")){
|
||||
return 300 * level / 5;
|
||||
} else if(PQ.equals("KerningPQ2nd")){
|
||||
return 200 * level / 5;
|
||||
} else if(PQ.equals("KerningPQ1st")){
|
||||
return 100 * level / 5;
|
||||
} else if(PQ.equals("LudiMazePQ")){
|
||||
return 2000 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ1st")) {
|
||||
return 100 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ2nd")) {
|
||||
return 250 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ3rd")) {
|
||||
return 350 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ4th")) {
|
||||
return 350 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ5th")) {
|
||||
return 400 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ6th")) {
|
||||
return 450 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ7th")) {
|
||||
return 500 * level / 5;
|
||||
} else if(PQ.equals("LudiPQ8th")) {
|
||||
return 650 * level / 5;
|
||||
} else if(PQ.equals("LudiPQLast")) {
|
||||
return 800 * level / 5;
|
||||
}
|
||||
FilePrinter.printError(FilePrinter.NPC, "Unhandled PartyQuest: " + PQ);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
242
src/main/java/server/partyquest/Pyramid.java
Normal file
242
src/main/java/server/partyquest/Pyramid.java
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
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 server.partyquest;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import net.server.world.MapleParty;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.TimerManager;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public class Pyramid extends PartyQuest {
|
||||
public enum PyramidMode {
|
||||
EASY(0), NORMAL(1), HARD(2), HELL(3);
|
||||
int mode;
|
||||
|
||||
PyramidMode(int mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
int kill = 0, miss = 0, cool = 0, exp = 0, map, count;
|
||||
byte coolAdd = 5, missSub = 4, decrease = 1;//hmmm
|
||||
short gauge;
|
||||
byte rank, skill = 0, stage = 0, buffcount = 0;//buffcount includes buffs + skills
|
||||
PyramidMode mode;
|
||||
|
||||
ScheduledFuture<?> timer = null;
|
||||
ScheduledFuture<?> gaugeSchedule = null;
|
||||
|
||||
public Pyramid(MapleParty party, PyramidMode mode, int mapid) {
|
||||
super(party);
|
||||
this.mode = mode;
|
||||
this.map = mapid;
|
||||
|
||||
byte plus = (byte) mode.getMode();
|
||||
coolAdd += plus;
|
||||
missSub += plus;
|
||||
switch (plus) {
|
||||
case 0:
|
||||
decrease = 1;
|
||||
case 1:
|
||||
case 2:
|
||||
decrease = 2;
|
||||
case 3:
|
||||
decrease = 3;
|
||||
}
|
||||
}
|
||||
|
||||
public void startGaugeSchedule() {
|
||||
if (gaugeSchedule == null) {
|
||||
gauge = 100;
|
||||
count = 0;
|
||||
gaugeSchedule = TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gauge -= decrease;
|
||||
if (gauge <= 0) warp(926010001);
|
||||
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
kill++;
|
||||
if (gauge < 100) count++;
|
||||
gauge++;
|
||||
broadcastInfo("hit", kill);
|
||||
if (gauge >= 100) gauge = 100;
|
||||
checkBuffs();
|
||||
}
|
||||
|
||||
public void cool() {
|
||||
cool++;
|
||||
int plus = coolAdd;
|
||||
if ((gauge + coolAdd) > 100) plus -= ((gauge + coolAdd) - 100);
|
||||
gauge += plus;
|
||||
count += plus;
|
||||
if (gauge >= 100) gauge = 100;
|
||||
broadcastInfo("cool", cool);
|
||||
checkBuffs();
|
||||
|
||||
}
|
||||
|
||||
public void miss() {
|
||||
miss++;
|
||||
count -= missSub;
|
||||
gauge -= missSub;
|
||||
broadcastInfo("miss", miss);
|
||||
}
|
||||
|
||||
public int timer() {
|
||||
int value;
|
||||
if (stage > 0)
|
||||
value = 180;
|
||||
else
|
||||
value = 120;
|
||||
|
||||
timer = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stage++;
|
||||
warp(map + (stage * 100));//Should work :D
|
||||
}
|
||||
}, value * 1000);//, 4000
|
||||
broadcastInfo("party", getParticipants().size() > 1 ? 1 : 0);
|
||||
broadcastInfo("hit", kill);
|
||||
broadcastInfo("miss", miss);
|
||||
broadcastInfo("cool", cool);
|
||||
broadcastInfo("skill", skill);
|
||||
broadcastInfo("laststage", stage);
|
||||
startGaugeSchedule();
|
||||
return value;
|
||||
}
|
||||
|
||||
public void warp(int mapid) {
|
||||
for (MapleCharacter chr : getParticipants()) {
|
||||
chr.changeMap(mapid, 0);
|
||||
}
|
||||
if (stage > -1) {
|
||||
gaugeSchedule.cancel(false);
|
||||
gaugeSchedule = null;
|
||||
timer.cancel(false);
|
||||
timer = null;
|
||||
} else stage = 0;
|
||||
}
|
||||
|
||||
public void broadcastInfo(String info, int amount) {
|
||||
for (MapleCharacter chr : getParticipants()) {
|
||||
chr.announce(MaplePacketCreator.getEnergy("massacre_" + info, amount));
|
||||
chr.announce(MaplePacketCreator.pyramidGauge(count));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean useSkill() {
|
||||
if (skill < 1) return false;
|
||||
|
||||
skill--;
|
||||
broadcastInfo("skill", skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkBuffs() {
|
||||
int total = (kill + cool);
|
||||
if (buffcount == 0 && total >= 250) {
|
||||
buffcount++;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
for (MapleCharacter chr : getParticipants())
|
||||
ii.getItemEffect(2022585).applyTo(chr);
|
||||
|
||||
} else if (buffcount == 1 && total >= 500) {
|
||||
buffcount++;
|
||||
skill++;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
for (MapleCharacter chr : getParticipants()) {
|
||||
chr.announce(MaplePacketCreator.getEnergy("massacre_skill", skill));
|
||||
ii.getItemEffect(2022586).applyTo(chr);
|
||||
}
|
||||
} else if (buffcount == 2 && total >= 1000) {
|
||||
buffcount++;
|
||||
skill++;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
for (MapleCharacter chr : getParticipants()) {
|
||||
chr.announce(MaplePacketCreator.getEnergy("massacre_skill", skill));
|
||||
ii.getItemEffect(2022587).applyTo(chr);
|
||||
}
|
||||
} else if (buffcount == 3 && total >= 1500) {
|
||||
skill++;
|
||||
broadcastInfo("skill", skill);
|
||||
} else if (buffcount == 4 && total >= 2000) {
|
||||
buffcount++;
|
||||
skill++;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
for (MapleCharacter chr : getParticipants()) {
|
||||
chr.announce(MaplePacketCreator.getEnergy("massacre_skill", skill));
|
||||
ii.getItemEffect(2022588).applyTo(chr);
|
||||
}
|
||||
} else if (buffcount == 5 && total >= 2500) {
|
||||
skill++;
|
||||
broadcastInfo("skill", skill);
|
||||
} else if (buffcount == 6 && total >= 3000) {
|
||||
skill++;
|
||||
broadcastInfo("skill", skill);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendScore(MapleCharacter chr) {
|
||||
if (exp == 0) {
|
||||
int totalkills = (kill + cool);
|
||||
if (stage == 5) {
|
||||
if (totalkills >= 3000) rank = 0;
|
||||
else if (totalkills >= 2000) rank = 1;
|
||||
else if (totalkills >= 1500) rank = 2;
|
||||
else if(totalkills >= 500) rank = 3;
|
||||
else rank = 4;
|
||||
} else {
|
||||
if (totalkills >= 2000) rank = 3;
|
||||
else rank = 4;
|
||||
}
|
||||
|
||||
if (rank == 0) exp = (60500 + (5500 * mode.getMode()));
|
||||
else if(rank == 1) exp = (55000 + (5000 * mode.getMode()));
|
||||
else if (rank == 2) exp = (46750 + (4250 * mode.getMode()));
|
||||
else if (rank == 3) exp = (22000 + (2000 * mode.getMode()));
|
||||
|
||||
exp += ((kill * 2) + (cool * 10));
|
||||
}
|
||||
chr.announce(MaplePacketCreator.pyramidScore(rank, exp));
|
||||
chr.gainExp(exp, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user