Code:
package org.dementhium.model.combat.impl.npc;
import java.util.Random;
import org.dementhium.model.Projectile;
import org.dementhium.model.World;
import org.dementhium.model.combat.CombatAction;
import org.dementhium.model.combat.CombatMovement;
import org.dementhium.model.combat.CombatTask;
import org.dementhium.model.combat.CombatType;
import org.dementhium.model.combat.Damage;
import org.dementhium.model.combat.Interaction;
import org.dementhium.model.combat.MeleeFormulae;
import org.dementhium.model.mask.Animation;
import org.dementhium.model.mask.Graphic;
import org.dementhium.model.misc.ProjectileManager;
import org.dementhium.model.misc.DamageManager.DamageType;
import org.dementhium.util.Misc;
import org.dementhium.model.npc.impl.Guthix;
/**
* @author obamayolo
*/
public class GuthixAction extends CombatAction {
private final Guthix guthix;
private static Random RANDOM = new Random();
private static enum Attack {
MELEE(Animation.create(402),
Graphic.create(-1, 96 << 16),
Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11),
Graphic.create(-1, 96 << 16), new CombatTask() {
@Override
public boolean execute(Interaction interaction) {
if (RANDOM.nextInt(15) > 12) {
interaction.getVictim().getPoisonManager().poison(interaction.getSource(), 80);
}
return true;
}
}
),
ICE(Animation.create(1979),
Graphic.create(-1, 96 << 16),
Projectile.create(null, null, 368, 30, 32, 52, 75, 3, 11),
Graphic.create(369), new CombatTask() {
@Override
public boolean execute(Interaction interaction) {
if (interaction.getVictim().getAttribute("freezeImmunity", -1) < World.getTicks()) {
interaction.getVictim().setAttribute("freezeTime", World.getTicks() + 24);
interaction.getVictim().setAttribute("freezeImmunity", World.getTicks() + 28);
int VictimX = interaction.getVictim().getLocation().getX();
int VictimY = interaction.getVictim().getLocation().getY();
int VictimZ = interaction.getVictim().getLocation().getZ();
interaction.getSource().teleportWithExtra(VictimX + Misc.random(-4, 4), VictimY + Misc.random(-4, 4), VictimZ);
} else {
interaction.getVictim().graphics(1677, 96 << 16);
}
return true;
}
}
),
BLOOD(Animation.create(1979),
Graphic.create(-1, 96 << 16),
Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11),
Graphic.create(377), new CombatTask() {
@Override
public boolean execute(Interaction interaction) {
interaction.getSource().heal(Misc.random(1, 300) / 3);
return true;
}
}
),
EAT(Animation.create(829),
Graphic.create(-1, 96 << 16),
Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11),
Graphic.create(-1), new CombatTask() {
@Override
public boolean execute(Interaction interaction) {
int i = Misc.random(1, 6);
if (i == 6)
interaction.getSource().heal(400); //Baked potato
else {
interaction.getSource().heal(230);
}
interaction.getSource().setFood(interaction.getSource().getFood() - 1);
return true;
}
}
),
SPECIAL(Animation.create(1062),
Graphic.create(252, 96 << 16),
Projectile.create(null, null, -1, 30, 32, 52, 75, 3, 11),
Graphic.create(-1, 96 << 16), new CombatTask() {
@Override
public boolean execute(Interaction interaction) {
interaction.getVictim().getDamageManager().miscDamage(Misc.random(1, 350), DamageType.MELEE);
if (RANDOM.nextInt(15) > 12) {
interaction.getVictim().getPoisonManager().poison(interaction.getSource(), 80);
}
return true;
}
}
);
private final Animation anim;
private final Graphic start;
private final Projectile projectile;
private final Graphic end;
private final CombatTask task;
private Attack(Animation anim, Graphic start, Projectile projectile, Graphic end, CombatTask task) {
this.anim = anim;
this.start = start;
this.projectile = projectile;
this.end = end;
this.task = task;
}
}
/**
* The current combat type used.
*/
private CombatType type = CombatType.MAGIC;
/**
* The current attack used.
*/
private Attack attack;
/**
* Constructs a new {@code GuthixAction} {@code Object}.
*/
public GuthixAction(Guthix guthix) {
super(false);
this.guthix = guthix;
}
@Override
public boolean commenceSession() {
int arg = Misc.random(1, 8);
int hit;
interaction.getSource().getCombatExecutor().setTicks(5);
if (CombatMovement.canMelee(guthix, interaction.getVictim()) && arg > 4) {
type = CombatType.MELEE;
} else {
type = CombatType.values()[1 + guthix.getRandom().nextInt(2)];
}
if (interaction.getSource().getRandom().nextInt(10) < 5) {
attack = Attack.values()[interaction.getSource().getRandom().nextInt(Attack.values().length)];
}
if (CombatMovement.canMelee(interaction.getSource(), interaction.getVictim()) && arg > 4) {
if (RANDOM.nextInt(15) > 4) {
attack = Attack.MELEE;
} else {
attack = Attack.SPECIAL;
}
type = CombatType.MELEE;
hit = MeleeFormulae.getDamage(interaction.getSource(), interaction.getVictim());
interaction.setDamage(Damage.getDamage(interaction.getSource(), interaction.getVictim(), type, hit));
interaction.getDamage().setMaximum(350);
} else if (interaction.getSource().getHitPoints() < 1000 && interaction.getSource().getFood() > 0) {
attack = Attack.EAT;
} else {
if (RANDOM.nextInt(10) >= 5) {
attack = Attack.ICE;
} else {
attack = Attack.BLOOD;
}
type = CombatType.MAGIC;
hit = MeleeFormulae.getDamage(interaction.getSource(), interaction.getVictim());
interaction.setDamage(Damage.getDamage(interaction.getSource(), interaction.getVictim(), type, hit));
interaction.getDamage().setMaximum(320);
}
ProjectileManager.sendProjectile(attack.projectile.transform(interaction.getSource(), interaction.getVictim()));
interaction.getSource().animate(attack.anim);
interaction.getSource().graphics(attack.start);
int ticks = (int) Math.floor(attack.projectile.getSourceLocation().distance(interaction.getVictim().getLocation()) * 0.3);
interaction.setTicks(ticks);
return true;
}
@Override
public boolean executeSession() {
if (interaction.getTicks() < 2) {
if (interaction.isDeflected()) {
interaction.getVictim().graphics(2230 - type.ordinal());
}
interaction.getVictim().animate(interaction.isDeflected() ? 12573 : interaction.getVictim().getDefenceAnimation());
}
interaction.setTicks(interaction.getTicks() - 1);
return interaction.getTicks() < 1;
}
@Override
public boolean endSession() {
interaction.getVictim().graphics(attack.end);
if (attack.task.execute(interaction) && interaction.getDamage() != null) {
if (interaction.getDamage().getHit() > -1) {
interaction.getVictim().getDamageManager().damage(
interaction.getSource(), interaction.getDamage(), type.getDamageType());
} else {
interaction.getVictim().graphics(85, 96 << 16);
}
if (interaction.getDamage().getVenged() > 0) {
interaction.getVictim().submitVengeance(interaction.getSource(), interaction.getDamage().getVenged());
}
if (interaction.getDamage().getDeflected() > 0) {
interaction.getSource().getDamageManager().damage(interaction.getVictim(),
interaction.getDamage().getDeflected(),
interaction.getDamage().getDeflected(), DamageType.DEFLECT);
}
if (interaction.getDamage().getRecoiled() > 0) {
interaction.getSource().getDamageManager().damage(interaction.getVictim(),
interaction.getDamage().getRecoiled(),
interaction.getDamage().getRecoiled(), DamageType.DEFLECT);
}
interaction.getVictim().retaliate(interaction.getSource());
}
return true;
}
@Override
public CombatType getCombatType() {
return CombatType.MAGIC;
}
}
Trying to get people to be original, so this basically is a bridding NPC (: This npc will Barrage, move different spot, blood barrage, and dds spec, it's all in these folders (: