Elvarg improvements

Elvarg fight is now authentic
Max hit up to 60 w/o shield, with anti-dragonfire shield up to 12, and max combat damage based on defense level
Separated potion and shield effects to not stack
Fixed quest log typo
Fixed dragon-fire message to show correct text based on the player's protection
This commit is contained in:
Skal Fate
2023-02-22 07:59:27 +00:00
committed by Ryan
parent f9dbfe9a77
commit 06632a6918
3 changed files with 57 additions and 45 deletions
@@ -171,7 +171,7 @@ public final class DragonSlayer extends Quest {
line(player, "<str>Maze.", 15+ 7); line(player, "<str>Maze.", 15+ 7);
} }
if (!player.getInventory().containsItem(MAGIC_PIECE) && !player.getBank().containsItem(MAGIC_PIECE)) { if (!player.getInventory().containsItem(MAGIC_PIECE) && !player.getBank().containsItem(MAGIC_PIECE)) {
line(player, BLUE + "One)2third of the map is hidden and only the " + RED + "Oracle " + BLUE + "on " + RED + "Ice", 16+ 7); line(player, BLUE + "One-third of the map is hidden and only the " + RED + "Oracle " + BLUE + "on " + RED + "Ice", 16+ 7);
line(player, RED + "Mountain" + BLUE + " will know where it is.", 17+ 7); line(player, RED + "Mountain" + BLUE + " will know where it is.", 17+ 7);
} else { } else {
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 16+ 7); line(player, "<str>I found the piece of the map that was hidden beneath Ice", 16+ 7);
@@ -21,13 +21,17 @@ import core.game.world.map.Location;
import core.game.world.map.RegionManager; import core.game.world.map.RegionManager;
import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics; import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
import core.tools.RandomFunction; import core.tools.RandomFunction;
import content.global.handlers.item.equipment.special.DragonfireSwingHandler;
/** /**
* Represents the elvarg npc. * Represents the Elvarg npc.
* @author 'Vexia * @author 'Vexia
* @version 1.0 * @version 1.0
*/ */
@Initializable
public final class ElvargNPC extends AbstractNPC { public final class ElvargNPC extends AbstractNPC {
/** /**
@@ -46,14 +50,14 @@ public final class ElvargNPC extends AbstractNPC {
private final CombatSwingHandler combatHandler = new ElvargCombatSwingHandler(); private final CombatSwingHandler combatHandler = new ElvargCombatSwingHandler();
/** /**
* Constructs a new {@code MeldarMadNPC} {@code Object}. * Constructs a new {@code ElvargNPC} {@code Object}.
*/ */
public ElvargNPC() { public ElvargNPC() {
super(0, null); super(0, null);
} }
/** /**
* Constructs a new {@code MeldarMadNPC} {@code Object}. * Constructs a new {@code ElvargNPC} {@code Object}.
* @param id The NPC id. * @param id The NPC id.
* @param location The location. * @param location The location.
*/ */
@@ -170,7 +174,7 @@ public final class ElvargNPC extends AbstractNPC {
} }
/** /**
* Handles the elvarg combat swing handler. * Handles the Elvarg combat swing handler.
* @author Emperor * @author Emperor
*/ */
static class ElvargCombatSwingHandler extends CombatSwingHandler { static class ElvargCombatSwingHandler extends CombatSwingHandler {
@@ -191,8 +195,12 @@ public final class ElvargNPC extends AbstractNPC {
private final FireType fireType = FireType.FIERY_BREATH; private final FireType fireType = FireType.FIERY_BREATH;
/** /**
* Constructs a new {@code KBDCombatSwingHandler} {@Code Object}. * The DragonFire Attack */
* The combat style. private static final DragonfireSwingHandler DRAGONFIRE = new DragonfireSwingHandler(false, 60, null, true);
/**
* Constructs a new {@Code ElvargCombatSwingHandler} {@Code CombatStyle}.
* The Combat style.
*/ */
public ElvargCombatSwingHandler() { public ElvargCombatSwingHandler() {
super(CombatStyle.RANGE); super(CombatStyle.RANGE);
@@ -202,10 +210,9 @@ public final class ElvargNPC extends AbstractNPC {
public void adjustBattleState(Entity entity, Entity victim, BattleState state) { public void adjustBattleState(Entity entity, Entity victim, BattleState state) {
if (style == CombatStyle.RANGE) { if (style == CombatStyle.RANGE) {
fireType.getTask().exec(victim, entity); fireType.getTask().exec(victim, entity);
if (victim.hasProtectionPrayer(CombatStyle.MAGIC)) { state.setStyle(null);
state.setEstimatedHit((int) (state.getEstimatedHit() * 0.6)); DRAGONFIRE.adjustBattleState(entity, victim, state);
} state.setStyle(CombatStyle.RANGE);
state.setEstimatedHit(formatHit(victim, state.getEstimatedHit()));
return; return;
} }
style.getSwingHandler().adjustBattleState(entity, victim, state); style.getSwingHandler().adjustBattleState(entity, victim, state);
@@ -213,43 +220,47 @@ public final class ElvargNPC extends AbstractNPC {
@Override @Override
public int calculateAccuracy(Entity entity) { public int calculateAccuracy(Entity entity) {
// If in melee combat, calculate attackers accuracy level.
if (style == CombatStyle.MELEE) { if (style == CombatStyle.MELEE) {
return style.getSwingHandler().calculateAccuracy(entity); return style.getSwingHandler().calculateAccuracy(entity);
} }
return 600; // Else calculate attackers accuracy based on their magic level.
return CombatStyle.MAGIC.getSwingHandler().calculateAccuracy(entity);
} }
@Override @Override
public int calculateDefence(Entity victim, Entity attacker) { public int calculateDefence(Entity victim, Entity attacker) {
// If in melee combat, calculate players defense level.
if (style == CombatStyle.MELEE) {
return style.getSwingHandler().calculateDefence(victim, attacker); return style.getSwingHandler().calculateDefence(victim, attacker);
} }
// Else calculate players defense against attack based on their magic level.
return CombatStyle.MAGIC.getSwingHandler().calculateDefence(victim, attacker);
}
@Override @Override
public int calculateHit(Entity entity, Entity victim, double modifier) { public int calculateHit(Entity entity, Entity victim, double modifier) {
if (style == CombatStyle.MELEE) { if (style == CombatStyle.MELEE) {
return style.getSwingHandler().calculateHit(entity, victim, modifier); return style.getSwingHandler().calculateHit(entity, victim, modifier);
} }
int max = 56; int maxDamage = 60; // Max Possible hit without shield protection
int damage = max; int finalDamage = maxDamage;
if (victim instanceof Player) { if (victim instanceof Player) {
int val = victim.getDragonfireProtection(true); int val = victim.getDragonfireProtection(true); // DragonFireShield Protection
if ((val & 0x2) != 0) {
damage *= 0.5; if ((val & 0x2) != 0) { // 0x2 - Anti Fire potion used?
finalDamage -= 0.22 * maxDamage; // = 20% protection
} }
if ((val & 0x4) != 0) { if ((val & 0x4) != 0) { // 0x4 - Anti Dragon Fire Shield equipped?
damage -= (int) (damage * 0.85); finalDamage -= 0.78 * maxDamage; // Should always equal 13 as that is the max hit possible with the shield equipped, 80% protection
} }
if ((val & 0x6) != 0) { if ( (val & 0x2) == 0 && (val & 0x4) == 0 && (val & 0x8) != 0) { // 0x8 - Magic Prayer Protection, should not stack with the others
damage *= 0.6; finalDamage -= 0.6 * maxDamage; // = 36
}
if (damage < 3) {
damage = 3;
} }
} }
if (fireType != FireType.FIERY_BREATH) {
damage += 11; return finalDamage;
}
return damage;
} }
@Override @Override
@@ -284,12 +295,17 @@ public final class ElvargNPC extends AbstractNPC {
style = CombatStyle.RANGE; style = CombatStyle.RANGE;
int hit = 0; int hit = 0;
int ticks = 1; int ticks = 1;
if (victim.getCenterLocation().withinDistance(entity.getCenterLocation(), getCombatDistance(entity, victim, 1)) && RandomFunction.random(10) < 7) {
if (victim.getCenterLocation().withinDistance(entity.getCenterLocation(), getCombatDistance(entity, victim, 1)) ) {
if ( RandomFunction.random(10) < 7 ){
style = CombatStyle.MELEE; style = CombatStyle.MELEE;
}
} else { } else {
ticks += (int) Math.ceil(entity.getLocation().getDistance(victim.getLocation()) * 0.3); ticks += (int) Math.ceil(entity.getLocation().getDistance(victim.getLocation()) * 0.3);
} }
state.setStyle(style); state.setStyle(style);
if (isAccurateImpact(entity, victim)) { if (isAccurateImpact(entity, victim)) {
int max = calculateHit(entity, victim, 1.0); int max = calculateHit(entity, victim, 1.0);
state.setMaximumHit(max); state.setMaximumHit(max);
@@ -316,11 +332,10 @@ public final class ElvargNPC extends AbstractNPC {
@Override @Override
public void visualizeImpact(Entity entity, Entity victim, BattleState state) { public void visualizeImpact(Entity entity, Entity victim, BattleState state) {
if (style != CombatStyle.MELEE) {
DRAGONFIRE.visualizeImpact(entity, victim, state);
} else {
style.getSwingHandler().visualizeImpact(entity, victim, state); style.getSwingHandler().visualizeImpact(entity, victim, state);
if (style != CombatStyle.MELEE && victim instanceof Player) {
Player p = (Player) victim;
p.getPacketDispatch().sendMessage(getDragonfireMessage(victim.getAttribute("fire_resistance", 0), fireType.name().toLowerCase().replaceAll("_", " ")));
p.graphics(new Graphics(346, 100, 1));
} }
} }
@@ -323,18 +323,15 @@ abstract class CombatSwingHandler(var type: CombatStyle?) {
if (protection and 0x2 != 0) { if (protection and 0x2 != 0) {
return "Your potion and shield fully protects you from the dragon's $fireName." return "Your potion and shield fully protects you from the dragon's $fireName."
} }
return if (protection and 0x8 != 0) { return "Your shield absorbs most of the dragon's $fireName."
"Your prayer and shield absorbs most of the dragon's $fireName."
} else "Your shield absorbs most of the dragon's $fireName."
} }
if (protection and 0x2 != 0) { if (protection and 0x2 != 0) {
return if (protection and 0x8 != 0) { return "Your antifire potion helps you defend the against the dragon's $fireName."
"Your prayer and potion absorbs most of the dragon's $fireName."
} else "Your antifire potion helps you defend the against the dragon's $fireName."
} }
return if (protection and 0x8 != 0) { if (protection and 0x8 != 0) {
"Your magic prayer absorbs some of the dragon's $fireName." return "Your magic prayer absorbs some of the dragon's $fireName."
} else "You are horribly burnt by the dragon's $fireName." }
return "You are horribly burnt by the dragon's $fireName."
} }
/** /**