Files
2009scape/Server/src/main/content/data/GodBook.java
T
Ceikry cb630e7043 Requirements Audit
Added a new quest requirement system
Ensured that all implemented rewards are obtainable, even if all requirements are not implemented
Rewards that should have higher requirements than what is currently obtainable will have those requirements automatically increase as more quests are added
The requirements for any quest can be viewed at any time by clicking it in the quest list
Things that were previously locked/unavailable but are now available (with prereqs) are:
- It is now possible to obtain and equip Barrow's Gloves with the Recipe for Disaster prereqs
- It is now possible to obtain and equip an Ancient Staff with the Desert Treasure prereqs
- It is now possible to enchant your secateurs into Magic Secateurs with the Fairy Tale I - Growing Pains prereqs and 40k gold
- It is now possible to equip the Ancient Mace with the Another Slice of H.A.M prereqs
- It is now possible to get Suqahs as a task from Duradel with the Lunar Diplomacy prereqs
- It is now possible to obtain a Seal of Passage by speaking with Chieftan Brundt after meeting the Lunar Diplomacy prereqs
- It is now possible to obtain Ancient Staves by killing the level 96 and 103 mummies in the Ancient Pyramid (1/500)
Things that were freely available but are now locked include:
- Sophanem now requires/requires the prereqs of Icthlarin's Little Helper
- Pharaoh's Sceptre requires the same^
- Equipping god books now requires Horror from the Deep/its prereqs
- Neitiznot helmet now requires the Fremennik Isles prereqs rather than just Fremennik Trials
- Cape of Legends now correctly requires the full possible prereqs for Legend's Quest rather than just 55 QP
- Dragon Scimitar now correctly requires the Monkey Madness prereqs
- Ape Atoll teleport now correctly requires the Monkey Madness prereqs
- Slayer Helmet and the Slayer Rewards Shop in general now correctly require the Smoking Kills prereqs (not high)
- Dragon Halberd now requires the Regicide prereqs
- Climbing Boots now require the Death Plateau prereqs
- Dragon SQ Shield now requires the Legend's Quest prereqs to equip (source available in sourcecode)
- Initiate Armour now requires the Recruitment Drive prereqs
- Proselyte Armour now requires the Slug Menace prereqs
- Access to Piscatoris now requires the Swan Song prereqs (effectively Quest Cape here.)
- The disease-free herb patch in Trollheim now requires the My Arm's Big Adventure prereqs.
- Ardougne Teleport now requires the Plague City prereqs
- Watchtower Teleport now requires the Watchtower prereqs
- Trollheim Teleport now requires the Eadgar's Ruse prereqs
- The Lunar spellbook now requires the Lunar Diplomacy prereqs
- The Ancient spellbook now requires the Desert Treasure prereqs
- Crafting Astral Runes now requires the Lunar Diplomacy prereqs
- Crafting Death Runes now requires the Mourning's End Part II prereqs
- Crafting Blood Runes now requires the Legacy of Seergaze prereqs
- Access to Cave Horrors now requires the Cabin Fever prereqs
- Sorceress' Garden now requires Prince Ali Rescue
- Access to the Heroes' Guild now requires the Heroes' Quest prereqs
- Access to GWD now requires the Troll Stronghold prereqs
- Access to Neitiznot and Jatizso now requires Fremennik Trials
- Access to Shilo Villa now requires the Shilo Village prereqs
- The Keldagrim cart system now requires The Giant Dwarf prereqs
- Fairy Rings now require the full Fairy Tale I - Growing Pains prereqs
- Ectophial now requires the Ghosts Ahoy prereqs
- Access to Tormented Demons now requires the While Guthix Sleeps prereqs
- Access to the Halberd Shop and the ability to equip Dragon Halberds now requires the Regicide prereqs
- Access to Lletya now requires the Mourning's End Part I prereqs
- Access to Corporeal Beast now requires the Summer's End prereqs
- Chivalry and Piety prayers now require the King's Ransom prereqs
- Ali Morrisane's rune shop now requires the The Feud prereqs
- Armoured Zombies now require the Defender of Varrock prereqs
- Experiments now require the Creature of Fenkenstrain prereqs
- The carpet to Sophanem now requires the Icthlarin's Little Helper prereqs
- The carpet to Uzer now requires The Golem
- The carpet to Bedabin Camp now requires The Tourist Trap
- The bank in Sophanem now requires the Contact! prereqs
- The Dragon Battleaxe now requires the prereqs of Heroes' Quest to equip.
- The Dragon Mace now requires the prereqs of Heroes' Quest to equip.
- Spirit shields of all varieties (improved, blessed, unblessed) now require the prereqs of Summer's End to equip.
- Bork access now requires What Lies Below
2023-05-30 09:03:05 +00:00

248 lines
5.9 KiB
Java

package content.data;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import static core.api.ContentAPIKt.hasRequirement;
/**
* A god book.
* @author Vexia
*/
public enum GodBook {
HOLY_BOOK("Holy Book of Saradomin", new Item(3840), new Item(3839), new Item[] { new Item(1718) }, new Item(3827), new Item(3828), new Item(3829), new Item(3830)), BOOK_OF_BALANCE("Guthix's Book of Balance", new Item(3844), new Item(3843), new Item[] { new Item(1718), new Item(1724) }, new Item(3835), new Item(3836), new Item(3837), new Item(3838)), UNHOLY_BOOK("Unholy Book of Zamorak", new Item(3842), new Item(3841), new Item[] { new Item(1724) }, new Item(3831), new Item(3832), new Item(3833), new Item(3834));
/**
* The books name.
*/
private final String name;
/**
* The god book.
*/
private final Item book;
/**
* The damaged book.
*/
private final Item damagedBook;
/**
* The items the book can bless.
*/
private final Item[] blessItems;
/**
* The pages of items.
*/
private final Item[] pages;
/**
* Constructs a new {@code GodBook} {@code Object}
* @param book the book.
* @param damagedBook the damged book.
* @param name the name of the book.
* @param pages the pages.
*/
private GodBook(String name, Item book, Item damagedBook, Item[] blessedItems, Item... pages) {
this.book = book;
this.damagedBook = damagedBook;
this.name = name;
this.blessItems = blessedItems;
this.pages = pages;
}
/**
* Gets the god book for the item.
* @param item the item.
* @param damaged Flagged for the damaged book.
* @return {@code GodBook} the god book.
*/
public static GodBook forItem(Item item, boolean damaged) {
for (GodBook book : values()) {
if ((!damaged ? book.getBook().getId() : book.getDamagedBook().getId()) == item.getId()) {
return book;
}
}
return null;
}
/**
* Checks if the player has this god book.
* @param player the player.
* @param both if we are checking for the damaged/good.
* @return {@code True} if so.
*/
public boolean hasGodBook(Player player, boolean both) {
return player.getInventory().containsItems(both ? new Item[] { book, damagedBook } : new Item[] { book });
}
/**
* Gets a good book based on the page id.
* @param page the page.
* @return the respective god book.
*/
public static GodBook forPage(Item page) {
for (GodBook book : values()) {
for (Item i : book.getPages()) {
if (i.getId() == page.getId()) {
return book;
}
}
}
return null;
}
/**
* Inserts a page into the book.
* @param player the player.
* @param book the book.
* @param page the page.
*/
public void insertPage(Player player, Item book, Item page) {
if (!hasRequirement(player, "Horror from the Deep"))
return;
if (hasPage(player, book, page)) {
player.sendMessage("The book already has that page.");
return;
}
if (player.getInventory().remove(new Item(page.getId(), 1))) {
setPageHash(player, book, getPageIndex(page));
player.sendMessage("You add the page to the book...");
if (isComplete(player, book)) {
player.getSavedData().getGlobalData().setGodPages(new boolean[4]);
player.getSavedData().getGlobalData().setGodBook(-1);
player.getInventory().replace(this.book, book.getSlot());
player.getSavedData().getGlobalData().setGodBook(this);
player.sendMessage("The book is now complete!");
String message = this == UNHOLY_BOOK ? "unholy symbols" : this == HOLY_BOOK ? "holy symbols" : "unblessed holy symbols";
player.sendMessage("You can now use it to bless " + (message) + "!");
}
}
}
/**
* Checks if this item is a page of the book.
* @param asItem the item.
* @return {@code True} if so.
*/
public boolean isPage(Item asItem) {
for (Item item : pages) {
if (item.getId() == asItem.getId()) {
return true;
}
}
return false;
}
/**
* Checks if a book is complete.
* @param book the book.
* @return {@code True} if so.
*/
public boolean isComplete(Player player, Item book) {
for (int i = 0; i < 4; i++) {
if (!hasPage(player, book, i + 1)) {
return false;
}
}
return true;
}
/**
* Checks if there is a page in a book.
* @param book the book.
* @param page the page.
* @return {@code True} if so.
*/
public boolean hasPage(Player player, Item book, Item page) {
return hasPage(player, book, getPageIndex(page));
}
/**
* Sets a page hash.
* @param book the book.
* @param pageId the page Id.
*/
public void setPageHash(Player player, Item book, int pageId) {
// int hash = getHash(book);
// hash |= hash | (1 << pageId);
// book.setCharge(1000 + hash);
player.getSavedData().getGlobalData().getGodPages()[pageId - 1] = true;
}
/**
* Checks if the book has a page.
* @param book the book.
* @param pageId the id of the page.
* @return {@code True} if so.
*/
public boolean hasPage(Player player, Item book, int pageId) {
// return (getHash(book) & (1 << pageId)) != 0;
return player.getSavedData().getGlobalData().getGodPages()[pageId - 1];
}
/**
* Gets the hash.
* @param book the book.
* @return the hash.
*/
public int getHash(Item book) {
return book.getCharge() - 1000;
}
/**
* Gets the page index.
* @param page the page.
* @return the index.
*/
public int getPageIndex(Item page) {
for (int i = 0; i < pages.length; i++) {
if (pages[i].getId() == page.getId()) {
return i + 1;
}
}
return -1;
}
/**
* Gets the name of the god book.
* @return the name.
*/
public String getName() {
return name;
}
/**
* Gets the book.
* @return the book
*/
public Item getBook() {
return book;
}
/**
* Gets the damagedBook.
* @return the damagedBook
*/
public Item getDamagedBook() {
return damagedBook;
}
/**
* Gets the pages.
* @return the pages
*/
public Item[] getPages() {
return pages;
}
/**
* Gets the blessItem.
* @return the blessItem
*/
public Item[] getBlessItem() {
return blessItems;
}
}