Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rs.game.player;
- import com.rs.cache.loaders.ClientScriptMap;
- import com.rs.cache.loaders.GeneralRequirementMap;
- public class PrayerManager {
- /**
- * Enumeration containing the normal prayer structs.
- */
- private static final ClientScriptMap GR_MAP_ORDER;
- static {
- GR_MAP_ORDER = ClientScriptMap.getMap(6759);
- }
- /**
- * Tree Struct Keys
- */
- private static final int FIRST_TIER_LEVEL = 2963, FIRST_TIER_MAP = 2964, SECOND_TIER_LEVEL = 2965, SECOND_TIER_MAP = 2966, THIRD_TIER_LEVEL = 2967, THIRD_TIER_MAP = 2968;
- /**
- * Branch Struct Keys
- */
- private static final int LEVEL_REQUIREMENT = 2945, TREE_STRUCT_KEY = 2962, NAME = 2794, DESCRIPTION = 2795, REQUIREMENT_MESSAGE = 2808;
- private transient Player player;
- /**
- * Prayers currently active.
- */
- private transient boolean[] active;
- /**
- * Whether or not the player is using ancients.
- */
- private boolean ancient;
- /**
- * The amount of prayer points a player currently has.
- */
- private int points;
- private static final int[][] VARBITS = {
- {},
- {}
- };
- public void setPoints(int points, boolean boost) {
- int replaced = boost ? this.points + points : this.points - points;
- this.points = replaced = boost ? Math.max(max(), replaced) : Math.min(0, replaced);
- if (!player.getVarsManager().sendVarBit(16736, points))
- return;
- player.updateBuffs();
- }
- public void drain(int points) {
- setPoints(points, false);
- }
- public void boost(int points) {
- setPoints(points, true);
- }
- public void boost() {
- boost(max());
- }
- public int max() {
- return player.getSkills().getLevelForXp(Skills.PRAYER) * 10;
- }
- public int getPoints() {
- return points;
- }
- public void activate(int slot) {
- if (!active[slot]) {
- if (getLevelRequirement(slot) > player.getSkills().getLevel(Skills.PRAYER)) {
- player.getPackets().sendGameMessage(getRequirementMessage(slot));
- return;
- }
- }
- active[slot] = !active[slot];
- player.getVarsManager().sendVarBit(VARBITS[ancient ? 1 : 0][slot], active[slot] ? 1 : 0);
- }
- private GeneralRequirementMap getStruct(int slot) {
- GeneralRequirementMap tierMap = GeneralRequirementMap.getMap(GR_MAP_ORDER.getIntValue(slot));
- int level = player.getSkills().getLevel(Skills.PRAYER);
- if (level >= tierMap.getIntValue(THIRD_TIER_LEVEL))
- return GeneralRequirementMap.getMap(THIRD_TIER_MAP);
- else if (level >= tierMap.getIntValue(SECOND_TIER_LEVEL))
- return GeneralRequirementMap.getMap(SECOND_TIER_MAP);
- else if (level >= tierMap.getIntValue(FIRST_TIER_LEVEL))
- return GeneralRequirementMap.getMap(FIRST_TIER_MAP);
- return null;
- }
- private int getLevelRequirement(int slot) {
- return getStruct(slot).getIntValue(LEVEL_REQUIREMENT);
- }
- private String getRequirementMessage(int slot) {
- return getStruct(slot).getStringValue(REQUIREMENT_MESSAGE);
- }
- public String getDescription(int slot) {
- return getStruct(slot).getStringValue(DESCRIPTION);
- }
- public String getName(int slot) {
- return getStruct(slot).getStringValue(NAME);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement