Source for my MapleSolaxiaV2 (v83 MapleStory).
This commit is contained in:
ronancpl
2015-11-02 23:17:21 -02:00
parent 324982e94f
commit 972517e7b2
1675 changed files with 261831 additions and 0 deletions
+172
View File
@@ -0,0 +1,172 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <[email protected]>
Matthias Butz <[email protected]>
Jan Christian Meyer <[email protected]>
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.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.ScheduledFuture;
import server.TimerManager;
import server.maps.MapleMap;
import tools.DatabaseConnection;
import tools.MaplePacketCreator;
/**
*
* @author kevintjuh93 - LOST MOTIVATION >=(
*/
public class MonsterCarnival {
private MonsterCarnivalParty red, blue;
private MapleMap map;
private int room;
private long time = 0;
private long timeStarted = 0;
private ScheduledFuture<?> schedule = null;
public MonsterCarnival(int room, byte channel, MonsterCarnivalParty red1, MonsterCarnivalParty blue1) {
//this.map = Channel.getInstance(channel).getMapFactory().getMap(980000001 + (room * 100));
this.room = room;
this.red = red1;
this.blue = blue1;
this.timeStarted = System.currentTimeMillis();
this.time = 600000;
map.broadcastMessage(MaplePacketCreator.getClock((int) (time / 1000)));
for (MapleCharacter chr : red.getMembers())
chr.setCarnival(this);
for (MapleCharacter chr : blue.getMembers())
chr.setCarnival(this);
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (red.getTotalCP() > blue.getTotalCP()) {
red.setWinner(true);
blue.setWinner(false);
red.displayMatchResult();
blue.displayMatchResult();
} else if (blue.getTotalCP() > red.getTotalCP()) {
red.setWinner(false);
blue.setWinner(true);
red.displayMatchResult();
blue.displayMatchResult();
} else {
red.setWinner(false);
blue.setWinner(false);
red.displayMatchResult();
blue.displayMatchResult();
}
saveResults();
warpOut();
}
}, time);
/* if (room == 0) {
MapleData data = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Map.wz")).getData("Map/Map9" + (980000001 + (room * 100)) + ".img").getChildByPath("monsterCarnival");
if (data != null) {
for (MapleData p : data.getChildByPath("mobGenPos").getChildren()) {
MapleData team = p.getChildByPath("team");
if (team != null) {
if (team.getData().equals(0))
redmonsterpoints.add(new Point(MapleDataTool.getInt(p.getChildByPath("x")), MapleDataTool.getInt(p.getChildByPath("y"))));
else
bluemonsterpoints.add(new Point(MapleDataTool.getInt(p.getChildByPath("x")), MapleDataTool.getInt(p.getChildByPath("y"))));
} else
monsterpoints.add(new Point(MapleDataTool.getInt(p.getChildByPath("x")), MapleDataTool.getInt(p.getChildByPath("y"))));
}
for (MapleData p : data.getChildByPath("guardianGenPos").getChildren()) {
MapleData team = p.getChildByPath("team");
if (team != null) {
if (team.getData().equals(0))
redreactorpoints.add(new Point(MapleDataTool.getInt(p.getChildByPath("x")), MapleDataTool.getInt(p.getChildByPath("y"))));
else
bluereactorpoints.add(new Point(MapleDataTool.getInt(p.getChildByPath("x")), MapleDataTool.getInt(p.getChildByPath("y"))));
} else
reactorpoints.add(new Point(MapleDataTool.getInt(p.getChildByPath("x")), MapleDataTool.getInt(p.getChildByPath("y"))));
}
}
} */
}
public long getTimeLeft() {
return time - (System.currentTimeMillis() - timeStarted);
}
public MonsterCarnivalParty getPartyRed() {
return red;
}
public MonsterCarnivalParty getPartyBlue() {
return blue;
}
public MonsterCarnivalParty oppositeTeam(MonsterCarnivalParty team) {
if (team == red)
return blue;
else
return red;
}
public void playerLeft(MapleCharacter chr) {
map.broadcastMessage(chr, MaplePacketCreator.leaveCPQ(chr));
}
private void warpOut() {
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
red.warpOut();
blue.warpOut();
}
}, 12000);
}
public int getRoom() {
return room;
}
public void saveResults() {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("INSERT INTO carnivalresults VALUES (?,?,?,?)");
for (MapleCharacter chr : red.getMembers()) {
ps.setInt(1, chr.getId());
ps.setInt(2, chr.getCP());
ps.setInt(3, red.getTotalCP());
ps.setInt(4, red.isWinner() ? 1 : 0);
ps.execute();
}
for (MapleCharacter chr : blue.getMembers()) {
ps.setInt(1, chr.getId());
ps.setInt(2, chr.getCP());
ps.setInt(3, blue.getTotalCP());
ps.setInt(4, blue.isWinner() ? 1 : 0);
ps.execute();
}
ps.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
@@ -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 //Thanks :3 - LOST MOTIVATION >=(
*/
public class MonsterCarnivalParty {
private List<MapleCharacter> members = new LinkedList<>();
private MapleCharacter leader;
private byte team;
private short availableCP = 0, totalCP = 0;
private int summons = 7;
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.setCarnivalParty(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.setCarnivalParty(null);
chr.setCarnival(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.getCarnival().getRoom() * 100));
else
warpOut(980000004 + (leader.getCarnival().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.setCarnivalParty(null);
chr.setCarnival(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
View File
@@ -0,0 +1,113 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <[email protected]>
Matthias Butz <[email protected]>
Jan Christian Meyer <[email protected]>
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.print(FilePrinter.NPC, "Unhandled PartyQuest: " + PQ);
return 0;
}
}
+242
View File
@@ -0,0 +1,242 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <[email protected]>
Matthias Butz <[email protected]>
Jan Christian Meyer <[email protected]>
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);
}
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);
}
}