59public class NpcAssistant {
65 NpcAssistant(
Npc npc) {
71 Combat<Npc> combat = npc.getCombat();
73 npc.definition = definition;
74 npc.pathfinderProjectiles =
Mob.pathfinderProjectiles(npc);
76 npc.setWidth(definition.getSize());
77 npc.setLength(definition.getSize());
78 npc.setBonuses(definition.getBonuses());
79 npc.mobAnimation.setNpcAnimations(definition);
83 if (listener !=
null) {
84 combat.addListener(listener);
87 npc.setStrategy(
NpcUtility.STRATEGIES.getOrDefault(npc.id, () -> loadStrategy(npc).orElse(NpcMeleeStrategy.get())).get());
91 public void reloadSkills() {
92 for (
int index = 0; index < npc.definition.getSkills().length; index++) {
93 npc.skills.setNpcMaxLevel(index, npc.definition.getSkills()[index]);
97 public static boolean isDragon(
int id) {
98 for (
int dragon : NpcUtility.DRAGONS)
if (
id == dragon)
return true;
102 public static Optional<CombatStrategy<Npc>> loadStrategy(
Npc npc) {
103 if (!npc.definition.getCombatAttackData().isPresent()) {
104 return Optional.empty();
107 NpcDefinition.CombatAttackData data = npc.definition.getCombatAttackData().get();
108 CombatType type = data.type;
112 CombatProjectile definition = data.getDefinition();
113 if (definition ==
null) {
114 throw new AssertionError(
"Could not find ranged projectile for Mob[id=" + npc.id +
", name=" + npc.
getName() +
"]");
116 return Optional.of(
new NpcRangedStrategy(definition));
119 CombatProjectile definition = data.getDefinition();
120 if (definition ==
null) {
121 throw new AssertionError(
"Could not find magic projectile for Mob[id=" + npc.id +
", name=" + npc.
getName() +
"]");
123 return Optional.of(
new NpcMagicStrategy(definition));
126 return Optional.of(NpcMeleeStrategy.get());
128 return Optional.empty();
133 npc.setVisible(
true);
134 npc.skills.restoreAll();
135 npc.getCombat().reset();
139 private void setEvent() {
140 if (NpcForceChatParser.FORCED_MESSAGES.containsKey(npc.spawnPosition)) {
141 NpcForceChatParser.ForcedMessage forcedMessage = NpcForceChatParser.FORCED_MESSAGES.get(npc.spawnPosition);
142 if (forcedMessage.getId() == npc.id) {
143 World.schedule(
new ForceChatEvent(npc, forcedMessage));
148 public boolean isBoss() {
149 for (
int id : NpcUtility.BOSSES) {
156 public boolean isBandos() {
157 for (
int id : NpcUtility.BANDOS) {
164 public boolean isArmadyl() {
165 for (
int id : NpcUtility.ARMADYL) {
172 public boolean isSaradomin() {
173 for (
int id : NpcUtility.SARADOMIN) {
180 public boolean isZamorak() {
181 for (
int id : NpcUtility.ZAMORAK) {