Refactor prayer changes into a more organized location
This commit is contained in:
@@ -355,8 +355,6 @@ public class Player extends Entity {
|
||||
|
||||
private int archeryTotal = 0;
|
||||
|
||||
private int prayerActiveTicks = 0;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Player} {@code Object}.
|
||||
* @param details The player's details.
|
||||
@@ -500,24 +498,9 @@ public class Player extends Entity {
|
||||
details.getSession().disconnect();
|
||||
getSession().setLastPing(Long.MAX_VALUE);
|
||||
}
|
||||
//Decrements prayer points
|
||||
if(!prayer.getActive().isEmpty() && prayerActiveTicks % 2 == 0){
|
||||
double amountDrain = 0;
|
||||
for(PrayerType type : prayer.getActive()){
|
||||
double drain = type.getDrain();
|
||||
double bonus = (1/30f) * prayer.getPlayer().getProperties().getBonuses()[12];
|
||||
drain = drain * (1 + bonus);
|
||||
drain = 0.6 / drain;
|
||||
amountDrain += drain;
|
||||
}
|
||||
if(SkillcapePerks.isActive(SkillcapePerks.DIVINE_FAVOR,prayer.getPlayer()) && RandomFunction.random(100) <= 10){
|
||||
amountDrain = 0;
|
||||
}
|
||||
|
||||
getSkills().decrementPrayerPoints(amountDrain);
|
||||
} else {
|
||||
prayerActiveTicks = 0;
|
||||
}
|
||||
//Decrements prayer points
|
||||
getPrayer().tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import core.game.world.map.Location;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
import core.tools.RandomFunction;
|
||||
import rs09.game.node.entity.skill.skillcapeperks.SkillcapePerks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -33,6 +34,8 @@ public final class Prayer {
|
||||
*/
|
||||
private final Player player;
|
||||
|
||||
private int prayerActiveTicks = 0;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Prayer} {@code Object}.
|
||||
*/
|
||||
@@ -110,6 +113,26 @@ public final class Prayer {
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if(!getActive().isEmpty() && prayerActiveTicks % 2 == 0){
|
||||
double amountDrain = 0;
|
||||
for(PrayerType type : getActive()){
|
||||
double drain = type.getDrain();
|
||||
double bonus = (1/30f) * getPlayer().getProperties().getBonuses()[12];
|
||||
drain = drain * (1 + bonus);
|
||||
drain = 0.6 / drain;
|
||||
amountDrain += drain;
|
||||
}
|
||||
if(SkillcapePerks.isActive(SkillcapePerks.DIVINE_FAVOR, getPlayer()) && RandomFunction.random(100) <= 10){
|
||||
amountDrain = 0;
|
||||
}
|
||||
|
||||
getPlayer().getSkills().decrementPrayerPoints(amountDrain);
|
||||
} else {
|
||||
prayerActiveTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skill bonus for the given skill id.
|
||||
* @param skillId The skill id.
|
||||
|
||||
Reference in New Issue
Block a user