Good morning!
I've been trying to add combat against farmer npc's. He hits 11's constantly and 11 is my max amount of hitpoints. (One hit should kill me but it doesn't). And when the farmer hits me it shows my health go down and I do eventually die, but it doesn't update the hits on my health stats as shown in the photo below. Stays on 11/11
Loving what I currently have with the server and looking forward to learning more about combat.
Here is the Farmer.java which I placed in com>rs>game>npc>combat>impl (Matrix 592)
Code:
package com.rs.game.npc.combat.impl;
import com.rs.game.Animation;
import com.rs.game.Entity;
import com.rs.game.Graphics;
import com.rs.game.npc.NPC;
import com.rs.game.npc.combat.CombatScript;
import com.rs.game.npc.combat.NPCCombatDefinitions;
import com.rs.game.player.Player;
import com.rs.game.player.content.Slayer;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;
import com.rs.utils.Utils;
public class Farmer extends CombatScript {
@Override
public Object[] getKeys() {
return new Object[] { "Farmer" };
}
@Override
public int attack(NPC npc, final Entity target) {
NPCCombatDefinitions def = npc.getCombatDefinitions();
if (!Slayer.hasReflectiveEquipment(target)) {
Player targetPlayer = (Player) target;
delayHit(npc, 0, target, getMeleeHit(npc, targetPlayer.getMaxHitpoints() / 10));
WorldTasksManager.schedule(new WorldTask() {
@Override
public void run() {
target.setNextGraphics(new Graphics(747));
}
});
// TODO player emote hands on ears
} else
delayHit(npc, 0, target, getMeleeHit(npc, getRandomMaxHit(npc, npc.getMaxHit(), def.getAttackStyle(), target)));
npc.setNextAnimation(new Animation(def.getAttackEmote()));
return def.getAttackDelay();
}
}