protected static void createdAnimatedArmour(Player p, int index) { if (p.getTemporaryAttribute("warriorGuildAnimator") == null) { return; } p.setLastAnimation(new Animation(827)); p.setTemporaryAttribute("unmovable", true); for (int i = 0; i < ARMOUR_SETS[index].Length; i++) { p.getInventory().deleteItem(ARMOUR_SETS[index][i]); } p.getPackets().sendChatboxInterface(211); p.getPackets().modifyText("You place the armour onto the platform where it", 211, 1); p.getPackets().modifyText("dissapears...", 211, 2); int animatorIndex = (int)p.getTemporaryAttribute("warriorGuildAnimator"); Event createAnimatedArmourEvent = new Event(1500); int createAnimatedArmourCounter = 0; Npc npc = null; createAnimatedArmourEvent.setAction(() => { if (createAnimatedArmourCounter == 0) { p.getPackets().sendChatboxInterface(211); p.getPackets().modifyText("The animator hums, something appears to be working.", 211, 1); p.getPackets().modifyText("You stand back.", 211, 2); createAnimatedArmourEvent.setTick(500); } else if (createAnimatedArmourCounter == 1) { p.getWalkingQueue().forceWalk(0, +3); createAnimatedArmourEvent.setTick(2000); } else if (createAnimatedArmourCounter == 2) { createAnimatedArmourEvent.setTick(500); Location minCoords = new Location(2849, 3534, 0); Location maxCoords = new Location(2861, 3545, 0); npc = new Npc(ANIMATED_ARMOUR[index]); npc.setMinimumCoords(minCoords); npc.setMaximumCoords(maxCoords); npc.setLocation(new Location(ANIMATOR_LOCATIONS[animatorIndex][0], ANIMATOR_LOCATIONS[animatorIndex][1], 0)); npc.setWalkType(WalkType.STATIC); npc.setForceText("I'm ALIVE!"); npc.setLastAnimation(new Animation(4166)); npc.setEntityFocus(p.getClientIndex()); npc.setOwner(p); npc.setTarget(p); p.getPackets().setArrowOnEntity(1, npc.getClientIndex()); Server.getNpcList().Add(npc); } else { p.setEntityFocus(npc.getClientIndex()); p.getPackets().softCloseInterfaces(); createAnimatedArmourEvent.stop(); p.removeTemporaryAttribute("unmovable"); npc.getFollow().setFollowing(p); } createAnimatedArmourCounter++; }); Server.registerEvent(createAnimatedArmourEvent); }
private static void thieveNpc(Player p, Npc npc, int index) { AreaEvent thieveNpcAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1); thieveNpcAreaEvent.setAction(() => { if (!canThieveNpc(p, npc, index)) { return; } p.setFaceLocation(npc.getLocation()); p.setLastAnimation(new Animation(881)); p.getPackets().sendMessage("You attempt to pick the " + NPC_NAMES[index] + " pocket..."); p.setTemporaryAttribute("lastPickPocket", Environment.TickCount); Event thieveNpcEvent = new Event(1000); thieveNpcEvent.setAction(() => { thieveNpcEvent.stop(); if (!p.getLocation().withinDistance(npc.getLocation(), 2)) { return; } if (successfulThieve(p, index, false)) { int rewardIndex = Misc.random(NPC_REWARD[index].Length - 1); int reward = NPC_REWARD[index][rewardIndex]; int rewardAmount = NPC_REWARD_AMOUNT[index][rewardIndex]; if (index == 7) { // Master farmer. if (Misc.random(15) == 0) { reward = HERB_SEEDS[Misc.random(HERB_SEEDS.Length - 1)]; } } p.getSkills().addXp(Skills.SKILL.THIEVING, NPC_XP[index]); p.getInventory().addItem(reward, rewardAmount); p.getPackets().sendMessage("You pick the " + NPC_NAMES[index] + " pocket."); } else { p.getWalkingQueue().resetWalkingQueue(); p.getPackets().sendMessage("You fail to pick the " + NPC_NAMES[index] + " pocket."); p.getPackets().sendMessage("You've been stunned!"); npc.setForceText("What do you think you're doing?"); p.setTemporaryAttribute("unmovable", true); p.setTemporaryAttribute("stunned", true); p.setLastGraphics(new Graphics(80, 0, 100)); p.setLastAnimation(new Animation(p.getDefenceAnimation())); p.hit(1); npc.setFaceLocation(p.getLocation()); Event removeStunEvent = new Event(5000); removeStunEvent.setAction(() => { removeStunEvent.stop(); p.removeTemporaryAttribute("unmovable"); p.removeTemporaryAttribute("stunned"); p.setLastGraphics(new Graphics(65535)); }); Server.registerEvent(removeStunEvent); } }); Server.registerEvent(thieveNpcEvent); }); Server.registerCoordinateEvent(thieveNpcAreaEvent); }
private static void randomMessage(Npc boss, string[] shouts) { if (Misc.random(4) != 0) { return; } string message = shouts[Misc.random(shouts.Length - 1)]; boss.setForceText(message); }
public static void attack(Npc npc, Entity target) { if (npc.isDead() || npc.isDestroyed() || target.isDead() || target.isDestroyed() || target.isDead()) { return; } int damage = Misc.random(npc.getMaxHit()); int prayer = ((Player)target).getPrayers().getHeadIcon(); int hitDelay = npc.getHitDelay(); int animation = npc.getAttackAnimation(); bool special = false; switch (npc.getId()) { case 6263: // Steelwill (bandos mage) hitDelay = 1000; animation = 65535; if (prayer == PrayerData.MAGIC) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1203, 50, 40, 34, 50, target); //npc.graphics(1201); break; case 6260: // Graardor (bandos) randomMessage(npc, BANDOS_SHOUTS); if (Misc.random(3) == 0) { special = true; hitDelay = 1000; animation = 7063; ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1200, 50, 40, 34, 50, target); if (prayer == PrayerData.RANGE) { damage = 0; } else { damage = Misc.random(35); } } else { if (prayer == PrayerData.MELEE) { damage = 0; } } break; case 6265: // Grimspike (bandos range) hitDelay = 1000; animation = 65535; if (prayer == PrayerData.RANGE) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1206, 50, 40, 34, 50, target); //npc.graphics(1201); break; case 6247: // Zilyana (sara boss) randomMessage(npc, SARADOMIN_SHOUTS); if (Misc.random(3) == 0) { animation = 6967; special = true; if (prayer == PrayerData.MAGIC) { damage = 0; } } else { if (prayer == PrayerData.MELEE) { damage = 0; } } break; case 6250: // Growler (sara mage) hitDelay = 1000; if (prayer == PrayerData.MAGIC) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1227, 50, 20, 27, 50, target); break; case 6252: // Bree (sara range) hitDelay = 1000; if (prayer == PrayerData.RANGE) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1227, 50, 20, 27, 50, target); //TODO all anims break; case 6203: // K'ril Tsutsaroth (zammy boss) randomMessage(npc, ZAMORAK_SHOUTS); if (prayer == PrayerData.MELEE) { damage = 0; } if (Misc.random(3) == 0) { animation = 6947; damage = Misc.random(49); if (prayer != 0 && damage < (49 / 2)) { damage = (49 / 2) + Misc.random(49 / 2); } } if (Misc.random(4) == 0) { if (!target.isPoisoned()) { if (damage > 0) { Server.registerEvent(new PoisonEvent(target, 16)); } } } break; case 6208: // Balfrug Kreeyath (zammy mage) hitDelay = 1200; if (prayer == PrayerData.MAGIC) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1213, 50, 20, 27, 70, target); // TODO attack anim break; case 6206: // Zakl'n Gritch (zammy range) hitDelay = 1200; if (prayer == PrayerData.RANGE) { damage = 0; } npc.setLastGraphics(new Graphics(1208)); ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1209, 50, 20, 27, 70, target); break; case 6222: // Kree'arra (armadyl boss) if (Misc.random(4) == 0) { npc.setForceText("Kraaaaw!"); } hitDelay = 1200; if (Misc.random(2) == 0 && npc.getAttacker() != null && npc.getAttacker().Equals(npc.getTarget())) { special = true; // Magic attack damage = Misc.random(21); if (prayer == PrayerData.MAGIC) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1198, 50, 20, 27, 70, target); } else if (npc.getAttacker() != null && npc.getAttacker().Equals(npc.getTarget())) { //range attack if (prayer == PrayerData.RANGE) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1197, 50, 20, 27, 70, target); } else { // do melee attack because they arent attacking kree arra damage = Misc.random(25); if (prayer == PrayerData.MELEE) { damage = 0; } animation = 6977; } break; case 6223: // Armadyl mage hitDelay = 1200; if (prayer == PrayerData.MAGIC) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1199, 50, 20, 27, 70, target); break; case 6225: // Armadyl range hitDelay = 1200; if (prayer == PrayerData.RANGE) { damage = 0; } ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 1190, 50, 20, 27, 70, target); break; } if (animation != 65535) { npc.setLastAnimation(new Animation(animation)); } target.setLastAttacked(Environment.TickCount); npc.setLastAttack(Environment.TickCount); target.setAttacker(npc); npc.resetCombatTurns(); if (damage > target.getHp()) { damage = target.getHp(); } int hit = damage; Event attackEvent = new Event(hitDelay); attackEvent.setAction(() => { attackEvent.stop(); if (npc.getId() == 6263) { target.setLastGraphics(new Graphics(hit > 0 ? 166 : 85, 0, 100)); } else if (npc.getId() == 6260) { if (special) { target.setLastGraphics(new Graphics(hit > 0 ? 160 : 65535, 0, 100)); } } else if (npc.getId() == 6247) { if (special) { if (hit < 1) { return; } else { target.setLastGraphics(new Graphics(1207, 0, 100)); npc.setCombatTurns(npc.getAttackSpeed() * 2); } } } else if (npc.getId() == 6208) { if (hit == 0) { target.setLastGraphics(new Graphics(85, 0, 100)); } } else if (npc.getId() == 6222) { if (special) { target.setLastGraphics(new Graphics(hit == 0 ? 85 : 65535, 0, 100)); } } if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0)) { target.setLastAnimation(new Animation(target.getDefenceAnimation())); } target.hit(hit); }); Server.registerEvent(attackEvent); }
public static void teleportToEssMine(Player p, Npc n) { if (p.getTemporaryAttribute("unmovable") != null) { return; } p.setTemporaryAttribute("unmovable", true); n.setLastGraphics(new Graphics(108)); Event teleportToEssMineEvent = new Event(600); teleportToEssMineEvent.setAction(() => { int i = 0; i++; if (i == 1) { p.setLastGraphics(new Graphics(110)); n.setForceText("Senventior disthine molenko!"); } else if (i == 2) { teleportToEssMineEvent.stop(); Event doTeleportToEssMineEvent = new Event(300); doTeleportToEssMineEvent.setAction(() => { p.teleport(getRandomMineLocation()); p.removeTemporaryAttribute("unmovable"); doTeleportToEssMineEvent.stop(); }); } }); Server.registerEvent(teleportToEssMineEvent); }