Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Pyramid PQ #221

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions database/sql/2-db_drops.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ USE `cosmic`;

INSERT IGNORE INTO temp_data (`dropperid`, `itemid`, `minimum_quantity`, `maximum_quantity`, `questid`, `chance`) VALUES
#-- copy+paste inside here as many drop data as possible from the spider (drop generator) files --
(9700019, 2022613, 1, 1, 0, 1000000),
(9700029, 2022618, 1, 1, 0, 1000000),
(5100004, 2383034, 1, 1, 0, 10000),
(2100108, 2381030, 1, 1, 0, 10000),
(3230300, 2382021, 1, 1, 0, 10000),
Expand Down
7 changes: 7 additions & 0 deletions scripts/map/onFirstUserEnter/killing_BonusSetting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function start(ms) {
const PacketCreator = Java.type('tools.PacketCreator');
ms.getPlayer().resetEnteredScript();
ms.getPlayer().sendPacket(PacketCreator.getClock(60));
ms.getPlayer().sendPacket(PacketCreator.mapEffect("killing/bonus/bonus"));
ms.getPlayer().sendPacket(PacketCreator.mapEffect("killing/bonus/stage"));
}
3 changes: 3 additions & 0 deletions scripts/map/onFirstUserEnter/killing_MapSetting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function start(ms) {
// Purposefully empty
}
5 changes: 1 addition & 4 deletions scripts/map/onUserEnter/Massacre_result.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
function start(ms) {
var py = ms.getPyramid();
if (py != null) {
py.sendScore(ms.getPlayer());
}
ms.getPlayer().sendPyramidResults();
}
439 changes: 293 additions & 146 deletions scripts/npc/2103013.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions scripts/npc/9010022.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
var status;
/* Dimensional Mirror
Located in various towns.
Handles warping the player to various locations like; CarnivalPQ, Nett's Pyramid, Mu Lung Dojo, etc...
*/

var status = -1;
var sel;

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

function action(mode, type, selection) {
if (mode == -1) {
if (mode === -1) {
cm.dispose();
} else {
if (mode == 0) {
if (mode === 0) {
cm.dispose();
return;
}
Expand Down Expand Up @@ -41,15 +45,13 @@ function action(mode, type, selection) {
selStr += "#3# Monster Carnival 2";
}

/*
if (cm.getLevel() >= 40) { NOT IMPLEMENTED
selStr += "#5# Nett's Pyramid";
}
if (cm.getLevel() >= 40) {
selStr += "#5# Nett's Pyramid";
}

if (cm.getLevel() >= 25 && cm.getLevel() <= 30) { NOT IMPLEMENTED
selStr += "#6# Construction Site";
}
*/
// if (cm.getLevel() >= 25 && cm.getLevel() <= 30) { NOT IMPLEMENTED
// selStr += "#6# Construction Site";
// }

cm.sendDimensionalMirror(selStr);
}
Expand Down
4 changes: 4 additions & 0 deletions scripts/portal/piramid_Chat00.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function enter(pi) {
pi.showIntro("Effect/Direction2.img/piramid/anubis");
return false;
}
4 changes: 4 additions & 0 deletions scripts/portal/piramid_in00.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function enter(pi) {
pi.openNpc(2103013);
return false;
}
96 changes: 96 additions & 0 deletions src/main/java/client/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
import server.partyquest.MonsterCarnival;
import server.partyquest.MonsterCarnivalParty;
import server.partyquest.PartyQuest;
import server.partyquest.pyramid.PyramidCharacterStats;
import server.partyquest.pyramid.PyramidDifficulty;
import server.partyquest.pyramid.PyramidProcessor;
import server.quest.Quest;
import tools.DatabaseConnection;
import tools.LongTool;
Expand Down Expand Up @@ -360,6 +363,10 @@ public class Character extends AbstractCharacterObject {
private long loginTime;
private boolean chasing = false;

// Pyramid PQ
PyramidCharacterStats pyramidCharacterStats = null;


private Character() {
super.setListener(new AbstractCharacterListener() {
@Override
Expand Down Expand Up @@ -1331,6 +1338,8 @@ public MapleMap getWarpMap(int map) {
warpMap = eim.getMapInstance(map);
} else if (this.getMonsterCarnival() != null && this.getMonsterCarnival().getEventMap().getId() == map) {
warpMap = this.getMonsterCarnival().getEventMap();
} else if (PyramidProcessor.getPyramidForCharacter(this.id) != null) {
warpMap = PyramidProcessor.getPyramidForCharacter(this.id).getMap(map);
} else {
warpMap = client.getChannelServer().getMapFactory().getMap(map);
}
Expand Down Expand Up @@ -7504,6 +7513,9 @@ private void playerDead() {
if (eim != null) {
eim.playerKilled(this);
}
if (PyramidProcessor.getPyramidForCharacter(this.getId()) != null) {
PyramidProcessor.getPyramidForCharacter(this.getId()).playerDead(this);
}
int[] charmID = {ItemId.SAFETY_CHARM, ItemId.EASTER_BASKET, ItemId.EASTER_CHARM};
int possesed = 0;
int i;
Expand Down Expand Up @@ -11247,4 +11259,88 @@ public boolean isChasing() {
public void setChasing(boolean chasing) {
this.chasing = chasing;
}

public void setPyramidCharacterStats(PyramidCharacterStats stats) {
this.pyramidCharacterStats = stats;
}

public PyramidCharacterStats getPyramidCharacterStats() {
return this.pyramidCharacterStats;
}

public void sendPyramidResults() {
if (getPyramidCharacterStats() == null) {
return;
}

byte rank = getPyramidCharacterStats().getRank().getCode();
int pyramidExp = getPyramidCharacterStats().calculateExp();

if (rank == 4) {
sendPacket(PacketCreator.mapEffect("killing/fail"));
}
sendPacket(PacketCreator.pyramidScore(rank, pyramidExp));
gainExp(pyramidExp, true, true);
}

public void clearPyramidResults() {
setPyramidCharacterStats(null);
}

public boolean startPyramidBonus(int difficultyCode) {
return startPyramidBonus(PyramidDifficulty.getById(difficultyCode));
}

public boolean startPyramidBonus(PyramidDifficulty difficulty) {
int monsterId = difficulty.equals(PyramidDifficulty.HELL) ? 9700029 : 9700019;

if (LifeFactory.getMonster(monsterId) == null) {
log.warn("Error while attempting to start Pyramid Bonus. Mob ID " + monsterId + " is invalid.");
return false;
}

int mapId = 926010010;
MapleMap map = getClient().getChannelServer().getMapFactory().getDisposableMap(mapId);
if (map == null) {
log.warn("Error while attempting to start Pyramid Bonus. Map ID " + mapId + " is invalid.");
return false;
}

int numberOfMonsters = switch (difficulty) {
case EASY -> 30;
case NORMAL -> 40;
case HARD, HELL -> 50;
};

Point topLeft = new Point(-361, -115);
Point topRight = new Point(352, -115);
Point bottomMiddle = new Point(4, 125);


for (int i = 0; i < (numberOfMonsters / 3); i++) {
map.spawnMonsterOnGroundBelow(LifeFactory.getMonster(monsterId), topLeft);
}
for (int i = 0; i < (numberOfMonsters / 3); i++) {
map.spawnMonsterOnGroundBelow(LifeFactory.getMonster(monsterId), topRight);
}
for (int i = 0; i < (numberOfMonsters / 3); i++) {
map.spawnMonsterOnGroundBelow(LifeFactory.getMonster(monsterId), bottomMiddle);
}
if (numberOfMonsters % 3 != 0) {
for (int i = 0; i < (numberOfMonsters % 3); i++) {
map.spawnMonsterOnGroundBelow(LifeFactory.getMonster(monsterId), bottomMiddle);
}
}

// Have to use changeMapInternal.. because we need our own instance of the map
changeMapInternal(map, map.getPortal(0).getPosition(), PacketCreator.getWarpToMap(map, 0, this));
setPyramidCharacterStats(null);

TimerManager.getInstance().schedule(() -> {
if (getMap().getId() == mapId) {
changeMap(926010000);
}
}, SECONDS.toMillis(60));
return true;
}
}
5 changes: 5 additions & 0 deletions src/main/java/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import server.maps.FieldLimit;
import server.maps.MapleMap;
import server.maps.MiniDungeonInfo;
import server.partyquest.pyramid.PyramidProcessor;
import tools.BCrypt;
import tools.DatabaseConnection;
import tools.HexTool;
Expand Down Expand Up @@ -942,6 +943,10 @@ private void removePlayer(World wserv, boolean serverTransition) {
player.getMonsterCarnival().playerDisconnected(getPlayer().getId());
}

if (PyramidProcessor.getPyramidForCharacter(player.getId()) != null) {
PyramidProcessor.getPyramidForCharacter(player.getId()).playerDisconnected(player);
}

if (player.getAriantColiseum() != null) {
player.getAriantColiseum().playerDisconnected(getPlayer());
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/constants/skills/Beginner.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ public class Beginner {
public static final int YETI_MOUNT1 = 1017;
public static final int YETI_MOUNT2 = 1018;
public static final int WITCH_BROOMSTICK = 1019;
public static final int RAGE_OF_PHARAOH = 1020;
public static final int BALROG_MOUNT = 1031;
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
import server.maps.MapObject;
import server.maps.MapObjectType;
import server.maps.MapleMap;
import server.partyquest.pyramid.Pyramid;
import server.partyquest.pyramid.PyramidProcessor;
import tools.PacketCreator;
import tools.Randomizer;

Expand Down Expand Up @@ -159,6 +161,12 @@ protected void applyAttack(AttackInfo attack, final Character player, int attack
if (player.isBanned()) {
return;
}
if (attack.skill == Beginner.RAGE_OF_PHARAOH) {
Pyramid pyramid = PyramidProcessor.getPyramidForCharacter(player.getId());
if (pyramid != null) {
pyramid.useSkill(player);
}
}
if (attack.skill != 0) {
theSkill = SkillFactory.getSkill(attack.skill); // thanks Conrad for noticing some Aran skills not consuming MP
attackEffect = attack.getAttackEffect(player, theSkill); //returns back the player's attack effect so we are gucci
Expand Down Expand Up @@ -277,6 +285,8 @@ protected void applyAttack(AttackInfo attack, final Character player, int attack
distanceToDetect += 250000;
} else if (attack.skill == Shadower.BOOMERANG_STEP) {
distanceToDetect += 60000;
} else if (attack.skill == Beginner.RAGE_OF_PHARAOH) {
distanceToDetect += 400000; // TODO: Find the true range of the skill
}

if (distance > distanceToDetect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import server.Trade;
import server.maps.MapleMap;
import server.maps.Portal;
import server.partyquest.pyramid.PyramidProcessor;
import tools.PacketCreator;

import java.awt.*;
Expand Down Expand Up @@ -101,6 +102,9 @@ public void handlePacket(InPacket p, Client c) {
if (chr.getEventInstance() != null) {
executeStandardPath = chr.getEventInstance().revivePlayer(chr);
}
if (PyramidProcessor.getPyramidForCharacter(chr.getId()) != null) {
executeStandardPath = PyramidProcessor.getPyramidForCharacter(chr.getId()).revivePlayer(chr);
}
if (executeStandardPath) {
chr.respawn(map.getReturnMapId());
}
Expand Down
30 changes: 22 additions & 8 deletions src/main/java/net/server/channel/handlers/ItemRewardHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,37 @@ public final void handlePacket(InPacket p, Client c) {

ItemInformationProvider ii = ItemInformationProvider.getInstance();
Pair<Integer, List<RewardItem>> rewards = ii.getItemReward(itemId);
for (RewardItem reward : rewards.getRight()) {
if (!InventoryManipulator.checkSpace(c, reward.itemid, reward.quantity, "")) {
c.sendPacket(PacketCreator.getShowInventoryFull());
break;

// Check that ALL inventories have at least 1 free slot.. otherwise this can be exploited
for (byte i = 1; i <= 4; i++) {
if (c.getPlayer().getInventory(InventoryType.getByType(i)).isFull()) {
c.getPlayer().dropMessage(1, "Please make sure you have a enough space in your inventory.");
c.sendPacket(PacketCreator.enableActions());
return;
}
if (Randomizer.nextInt(rewards.getLeft()) < reward.prob) {//Is it even possible to get an item with prob 1?
}

int randomNumber = Randomizer.nextInt(rewards.getLeft());
int runningProb = 0;

for (RewardItem reward : rewards.getRight()) {
runningProb += reward.prob;
if (randomNumber < runningProb) {//Is it even possible to get an item with prob 1?
Item item;
if (ItemConstants.getInventoryType(reward.itemid) == InventoryType.EQUIP) {
final Item item = ii.getEquipById(reward.itemid);
item = ii.getEquipById(reward.itemid);
if (reward.period != -1) {
// TODO is this a bug, meant to be 60 * 60 * 1000?
item.setExpiration(currentServerTime() + reward.period * 60 * 60 * 10);
}
InventoryManipulator.addFromDrop(c, item, false);
} else {
InventoryManipulator.addById(c, reward.itemid, reward.quantity, "", -1);
item = new Item(reward.itemid, (short) 0, reward.quantity, -1);
}

InventoryManipulator.addFromDrop(c, item, false);
InventoryManipulator.removeById(c, InventoryType.USE, itemId, 1, false, false);
c.sendPacket(PacketCreator.getShowItemGain(reward.itemid, reward.quantity, true));

if (reward.worldmsg != null) {
String msg = reward.worldmsg;
msg.replaceAll("/name", c.getPlayer().getName());
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/server/world/Party.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import server.maps.Door;
import server.maps.MapleMap;
import server.partyquest.MonsterCarnival;
import server.partyquest.pyramid.PyramidProcessor;
import tools.PacketCreator;

import java.util.Collection;
Expand Down Expand Up @@ -407,6 +408,10 @@ public static void leaveParty(Party party, Client c) {
if (eim != null) {
eim.disbandParty();
}

if (PyramidProcessor.getPyramidForCharacter(player.getId()) != null) {
PyramidProcessor.getPyramidForCharacter(player.getId()).disbandParty();
}
} else {
MapleMap map = player.getMap();
if (map != null) {
Expand All @@ -424,6 +429,10 @@ public static void leaveParty(Party party, Client c) {
if (eim != null) {
eim.leftParty(player);
}

if (PyramidProcessor.getPyramidForCharacter(player.getId()) != null) {
PyramidProcessor.getPyramidForCharacter(player.getId()).leaveParty(player);
}
}

player.setParty(null);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/scripting/AbstractPlayerInteraction.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import server.maps.MapObjectType;
import server.maps.MapleMap;
import server.partyquest.PartyQuest;
import server.partyquest.Pyramid;
import server.quest.Quest;
import tools.PacketCreator;
import tools.Pair;
Expand Down Expand Up @@ -1071,10 +1070,6 @@ public String numberWithCommas(int number) {
return GameConstants.numberWithCommas(number);
}

public Pyramid getPyramid() {
return (Pyramid) getPlayer().getPartyQuest();
}

public int createExpedition(ExpeditionType type) {
return createExpedition(type, false, 0, 0);
}
Expand Down
Loading
Loading