From 509d73ff2c4a1a294adfe7b34da3effe3454d38f Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Sat, 26 Feb 2022 05:32:47 +0000 Subject: [PATCH] Implemented regen brace Fixed timing of stat decrementing Saradomin brews can now lower stats all the way to zero --- .../game/content/consumable/Consumables.java | 4 +- .../consumable/effects/SkillEffect.java | 3 +- .../entity/player/link/prayer/PrayerType.java | 22 +--- .../node/entity/skill/SkillRestoration.java | 105 +++++++----------- .../core/game/node/entity/skill/Skills.java | 10 +- .../skill/prayer/PrayerAltarPlugin.java | 2 - 6 files changed, 45 insertions(+), 101 deletions(-) diff --git a/Server/src/main/java/core/game/content/consumable/Consumables.java b/Server/src/main/java/core/game/content/consumable/Consumables.java index c8d294904..ed80b92f1 100644 --- a/Server/src/main/java/core/game/content/consumable/Consumables.java +++ b/Server/src/main/java/core/game/content/consumable/Consumables.java @@ -324,7 +324,7 @@ public enum Consumables { FISHING(new Potion(new int[] {2438, 151, 153, 155}, new SkillEffect(Skills.FISHING, 3, 0))), PRAYER(new Potion(new int[] {2434, 139, 141, 143}, new PrayerEffect(7, 0.25))), SUPER_RESTO(new Potion(new int[] {3024, 3026, 3028, 3030}, new MultiEffect(new RestoreEffect(8, 0.25), new PrayerEffect(8, 0.25), new SummoningEffect(8, 0.25)))), - ZAMMY_BREW(new Potion(new int[] {2450, 189, 191, 193}, new MultiEffect(new DamageEffect(0.1, true), new SkillEffect(Skills.ATTACK, 0, 0.15), new SkillEffect(Skills.STRENGTH, 0, 0.25), new SkillEffect(Skills.DEFENCE, 0, -0.1), new RandomPrayerEffect(0, 10)))), + ZAMMY_BREW(new Potion(new int[] {2450, 189, 191, 193}, new MultiEffect(new DamageEffect(10, true), new SkillEffect(Skills.ATTACK, 0, 0.15), new SkillEffect(Skills.STRENGTH, 0, 0.25), new SkillEffect(Skills.DEFENCE, 0, -0.1), new RandomPrayerEffect(0, 10)))), ANTIFIRE(new Potion(new int[] {2452, 2454, 2456, 2458}, new SetAttributeEffect("fire:immune", 600, true))), GUTH_REST(new Potion(new int[] {4417, 4419, 4421, 4423}, new MultiEffect(new RemoveStateEffect(EntityState.POISONED.ordinal()), new EnergyEffect(5), new HealingEffect(5)))), MAGIC_ESS(new Potion(new int[] {11491, 11489}, new SkillEffect(Skills.MAGIC,3,0))), @@ -334,7 +334,7 @@ public enum Consumables { /** Barbarian Mixes */ PRAYERMIX(new BarbarianMix(new int[] {11465, 11467}, new MultiEffect(new PrayerEffect(7, 0.25), new HealingEffect(6)))), - ZAMMY_MIX(new BarbarianMix(new int[] {11521, 11523}, new MultiEffect(new SkillEffect(Skills.HITPOINTS, 0, -0.10), new SkillEffect(Skills.ATTACK, 0, 0.15), new SkillEffect(Skills.STRENGTH, 0, 0.25), new SkillEffect(Skills.DEFENCE, 0, -0.1), new RandomPrayerEffect(0, 10)))), + ZAMMY_MIX(new BarbarianMix(new int[] {11521, 11523}, new MultiEffect(new DamageEffect(10, true), new SkillEffect(Skills.ATTACK, 0, 0.15), new SkillEffect(Skills.STRENGTH, 0, 0.25), new SkillEffect(Skills.DEFENCE, 0, -0.1), new RandomPrayerEffect(0, 10)))), ATT_MIX(new BarbarianMix(new int[] {11429, 11431}, new MultiEffect(new SkillEffect(Skills.ATTACK, 3, 0.1), new HealingEffect(3)))), ANTIP_MIX(new BarbarianMix(new int[] {11433, 11435}, new MultiEffect(new RemoveStateEffect(EntityState.POISONED.ordinal()), new SetAttributeEffect("poison:immunity", 143), new HealingEffect(3)))), RELIC_MIX(new BarbarianMix(new int[] {11437, 11439}, new MultiEffect(new RemoveStateEffect("disease"), new SetAttributeEffect("disease:immunity", 300), new HealingEffect(3)))), diff --git a/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java b/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java index 5fae1c422..d6498e222 100644 --- a/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java +++ b/Server/src/main/java/core/game/content/consumable/effects/SkillEffect.java @@ -17,6 +17,7 @@ public class SkillEffect extends ConsumableEffect { public void activate(Player p) { Skills skills = p.getSkills(); int slevel = skills.getStaticLevel(skill_slot); - skills.updateLevel(skill_slot,(int)(base + (bonus * slevel)),slevel + (int)(base + (bonus * slevel))); + int delta = (int)(base + (bonus * slevel)); + skills.updateLevel(skill_slot, delta, delta >= 0 ? slevel + delta : 0); } } diff --git a/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java b/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java index b49a8bef5..8f4e138a3 100644 --- a/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java +++ b/Server/src/main/java/core/game/node/entity/player/link/prayer/PrayerType.java @@ -26,26 +26,8 @@ public enum PrayerType { ROCK_SKIN(10, 6, 86, 15, PrayerCategory.BABY_BLUE, 2684, new SkillBonus(Skills.DEFENCE, 0.1)), SUPERHUMAN_STRENGTH(13, 6, 87, 17, PrayerCategory.GREEN, 2689, new SkillBonus(Skills.STRENGTH, 0.1)), IMPROVED_REFLEXES(16, 6, 88, 19, PrayerCategory.PINK, 2662, new SkillBonus(Skills.ATTACK, 0.1)), - RAPID_RESTORE(19, 26, 89, 21, PrayerCategory.PURPLE, 2679){ - @Override - public boolean toggle(Player player, boolean on) { - for(SkillRestoration restore : player.getSkills().getRestoration()){ - if(restore == null) continue; - restore.restartStat(on); - } - return super.toggle(player, on); - } - }, - RAPID_HEAL(22, 18, 90, 23, PrayerCategory.PURPLE, 2678){ - @Override - public boolean toggle(Player player, boolean on) { - for(SkillRestoration restore : player.getSkills().getRestoration()){ - if(restore == null) continue; - restore.restartHpSummPray(on); - } - return super.toggle(player, on); - } - }, + RAPID_RESTORE(19, 26, 89, 21, PrayerCategory.PURPLE, 2679), + RAPID_HEAL(22, 18, 90, 23, PrayerCategory.PURPLE, 2678), PROTECT_ITEMS(25, 18, 91, 25, PrayerCategory.DARK_GREEN, 1982), HAWK_EYE(26, 6, 864, 27, PrayerCategory.LIME_GREEN, 2666, new SkillBonus(Skills.RANGE, 0.1)), MYSTIC_LORE(27, 6, 865, 29, PrayerCategory.LIME_GREEN, 2668, new SkillBonus(Skills.MAGIC, 0.1)), diff --git a/Server/src/main/java/core/game/node/entity/skill/SkillRestoration.java b/Server/src/main/java/core/game/node/entity/skill/SkillRestoration.java index 460f10b5e..e3f23a294 100644 --- a/Server/src/main/java/core/game/node/entity/skill/SkillRestoration.java +++ b/Server/src/main/java/core/game/node/entity/skill/SkillRestoration.java @@ -1,8 +1,11 @@ package core.game.node.entity.skill; +import core.game.container.impl.EquipmentContainer; import core.game.node.entity.Entity; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.prayer.PrayerType; +import core.game.node.item.Item; +import org.rs09.consts.Items; import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks; import rs09.game.world.GameWorld; @@ -17,21 +20,12 @@ public final class SkillRestoration { */ private final int skillId; - /** - * The current tick. - */ - private int statTick; - - private int hpSummPrayTick; - /** * Constructs a new {@code SkillRestoration} {@code Object}. * @param skillId The skill id. */ public SkillRestoration(int skillId) { this.skillId = skillId; - restartHpSummPray(false); - restartStat(false); } /** @@ -41,47 +35,43 @@ public final class SkillRestoration { public void restore(Entity entity) { Skills skills = entity.getSkills(); int max = skills.getStaticLevel(skillId); - if(skillId == Skills.HITPOINTS && entity instanceof Player && SkillcapePerks.isActive(SkillcapePerks.DAMAGE_SPONG,entity.asPlayer())){ - max = 110; + int tickDivisor = 1; + if(skillId == Skills.HITPOINTS){ + max = skills.getMaximumLifepoints(); + if(entity instanceof Player) { + Player player = entity.asPlayer(); + if(player.getPrayer().getActive().contains(PrayerType.RAPID_HEAL)) { + tickDivisor *= 2; + } + Item gloves = player.getEquipment().get(EquipmentContainer.SLOT_HANDS); + if(gloves != null && gloves.getId() == Items.REGEN_BRACELET_11133) { + tickDivisor *= 2; + } + } } - if(hpSummPrayTick < GameWorld.getTicks()){ - if(skillId == Skills.HITPOINTS || skillId == Skills.SUMMONING || skillId == Skills.PRAYER){ - if(skillId == Skills.HITPOINTS){ - if(skills.getLifepoints() >= max){ - return; - } - skills.heal(1); - } else { - int current = skills.getLevel(skillId); - skills.updateLevel(skillId,current < max ? 1 : -1,max); - } - restartHpSummPray(entity.asPlayer().getPrayer().getActive().contains(PrayerType.RAPID_HEAL)); + if(skillId == Skills.PRAYER) { + return; + } + if(skillId != Skills.HITPOINTS && skillId != Skills.SUMMONING) { + if(entity instanceof Player) { + if(entity.asPlayer().getPrayer().getActive().contains(PrayerType.RAPID_RESTORE)) { + tickDivisor *= 2; + } + } + } + + int ticks = 100 / tickDivisor; + if(GameWorld.getTicks() % ticks == 0){ + if(skillId == Skills.HITPOINTS){ + if(skills.getLifepoints() >= max){ + return; + } + skills.heal(1); + } else { + int current = skills.getLevel(skillId); + skills.updateLevel(skillId,current < max ? 1 : -1,max); } } - if(statTick < GameWorld.getTicks()) { - if (skillId != Skills.HITPOINTS && skillId != Skills.SUMMONING && skillId != Skills.PRAYER) { - int current = skills.getLevel(skillId); - skills.updateLevel(skillId,current < max ? 1 : -1,max); - restartStat(entity.asPlayer().getPrayer().getActive().contains(PrayerType.RAPID_RESTORE)); - } - } - } - - /** - * Gets the tick. - * @return The tick. - */ - public int getTick() { - return hpSummPrayTick; - } - - /** - * Sets the tick. - * @param tick The tick to set. - */ - public void setTick(int tick) { - this.hpSummPrayTick = tick; - this.statTick = tick; } /** @@ -91,23 +81,4 @@ public final class SkillRestoration { public int getSkillId() { return skillId; } - - /** - * Restarts the restoration. - */ - public void restartHpSummPray(boolean half) { - int ticks = 100; - if(half){ - ticks /= 2; - } - this.hpSummPrayTick = GameWorld.getTicks() + ticks; - } - - public void restartStat(boolean half) { - int ticks = 100; - if(half){ - ticks /= 2; - } - this.statTick = GameWorld.getTicks() + ticks; - } -} \ No newline at end of file +} diff --git a/Server/src/main/java/core/game/node/entity/skill/Skills.java b/Server/src/main/java/core/game/node/entity/skill/Skills.java index 6835a1f11..48df8badf 100644 --- a/Server/src/main/java/core/game/node/entity/skill/Skills.java +++ b/Server/src/main/java/core/game/node/entity/skill/Skills.java @@ -604,10 +604,6 @@ public final class Skills { prayerPoints = level; } dynamicLevels[slot] = level; - if (restoration[slot] != null) { - restoration[slot].restartHpSummPray(false); - restoration[slot].restartStat(false); - } if (entity instanceof Player) { PacketRepository.send(SkillLevel.class, new SkillContext((Player) entity, slot)); } @@ -818,10 +814,6 @@ public final class Skills { } else if (amount > 0 && level > maximum) { dynamicLevels[skill] = maximum; } - if (restoration[skill] != null) { - restoration[skill].restartHpSummPray(false); - restoration[skill].restartStat(false); - } if (entity instanceof Player) { PacketRepository.send(SkillLevel.class, new SkillContext((Player) entity, skill)); } @@ -992,4 +984,4 @@ public final class Skills { public int[] getDynamicLevels() { return dynamicLevels; } -} \ No newline at end of file +} diff --git a/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java b/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java index a8a16b454..de54a5a87 100644 --- a/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/prayer/PrayerAltarPlugin.java @@ -58,8 +58,6 @@ public class PrayerAltarPlugin extends OptionHandler { player.getPacketDispatch().sendMessage("You recharge your Prayer points."); if (node.getId() == 2640) { player.getSkills().setLevel(Skills.PRAYER, player.getSkills().getStaticLevel(Skills.PRAYER) + 2); - player.getSkills().getRestoration()[Skills.PRAYER] = new SkillRestoration(Skills.PRAYER); - player.getSkills().getRestoration()[Skills.PRAYER].restartHpSummPray(false); } if (node.getId() == 409 && player.getLocation().withinDistance(new Location(3209, 3495, 1))