Made familiar code more testable

Fixed an issue with the bloated leech "blood drain" ability
This commit is contained in:
Ceikry
2023-07-31 15:08:47 +00:00
parent ee79b0750c
commit 105f7d5b86
6 changed files with 168 additions and 26 deletions
@@ -39,14 +39,18 @@ public class BloatedLeechNPC extends Familiar {
@Override
protected boolean specialMove(FamiliarSpecial special) {
curePoison(owner);
curePoison(owner);
removeTimer(owner, "disease");
for (int i = 0; i < Skills.SKILL_NAME.length; i++) {
if (owner.getSkills().getLevel(i) < owner.getSkills().getStaticLevel(i)) {
owner.getSkills().setLevel(i, owner.getSkills().getStaticLevel(i));
owner.getSkills().updateLevel(
i,
(int) Math.ceil(owner.getSkills().getStaticLevel(i) * 0.2),
owner.getSkills().getStaticLevel(i)
);
}
}
owner.getSkills().rechargePrayerPoints();
getImpactHandler().manualHit(owner, RandomFunction.random(2), HitsplatType.NORMAL);
owner.getImpactHandler().manualHit(owner, RandomFunction.random(1, 5), HitsplatType.NORMAL);
return true;
}
@@ -347,26 +347,26 @@ public abstract class Familiar extends NPC implements Plugin<Object> {
* Checks if the familiar can execute its special move and does so if able.
* @param special The familiar special object.
*/
public void executeSpecialMove(FamiliarSpecial special) {
public boolean executeSpecialMove(FamiliarSpecial special) {
if (special.getNode() == this) {
return;
return false;
}
if (specialCost > specialPoints) {
owner.getPacketDispatch().sendMessage("Your familiar does not have enough special move points left.");
return;
return false;
}
SummoningScroll scroll = SummoningScroll.forPouch(pouchId);
if (scroll == null) {
owner.getPacketDispatch().sendMessage("Invalid scroll for pouch " + pouchId + " - report!");
return;
return false;
}
if (!owner.getInventory().contains(scroll.getItemId(), 1)) {
owner.getPacketDispatch().sendMessage("You do not have enough scrolls left to do this special move.");
return;
return false;
}
if (owner.getLocation().getDistance(getLocation()) > 15) {
owner.getPacketDispatch().sendMessage("Your familiar is too far away to use that scroll, or it cannot see you.");
return;
return false;
}
if (specialMove(special)) {
setAttribute("special-delay", GameWorld.getTicks() + 3);
@@ -376,6 +376,7 @@ public abstract class Familiar extends NPC implements Plugin<Object> {
updateSpecialPoints(specialCost);
owner.getSkills().addExperience(Skills.SUMMONING, scroll.getExperience(), true);
}
return true;
}
/**