public static bool openCoffin(Player p, int objectId) { if (objectId != 6823 && objectId != 6771 && objectId != 6821 && objectId != 6773 && objectId != 6822 && objectId != 6772) { return false; } int cryptIndex = getCryptIndex(p); if (cryptIndex == -1) { return false; } if (p.getBarrowBrothersKilled(cryptIndex)) { p.getPackets().sendMessage("You don't find anything."); return true; } if (p.getBarrowTunnel() == cryptIndex){ p.getPackets().modifyText("You find a hidden tunnel, do you want to enter?", 210, 1); p.getPackets().sendChatboxInterface(210); p.setTemporaryAttribute("barrowTunnel", 1); return true; } foreach(Npc n in Server.getNpcList()) { if (n.getId() == BROTHER_ID[cryptIndex]) { if (n.getOwner().Equals(p)) { p.getPackets().sendMessage("You don't find anything."); return true; } } } Npc npc = new Npc(BROTHER_ID[cryptIndex]); npc.setLocation(p.getLocation()); npc.setEntityFocus(p.getClientIndex()); npc.setOwner(p); npc.setTarget(p); npc.setCombatTurns(npc.getAttackSpeed()); Server.getNpcList().Add(npc); p.getPackets().setArrowOnEntity(1, npc.getClientIndex()); return true; }
public static void openChest(Player player) { Player p = player; if (p.getLocation().getZ() != 0 || p.getTemporaryAttribute("lootedBarrowChest") != null) { return; } if (!p.getLocation().inArea(3551, 9694, 3552, 9694)) { AreaEvent openChestAreaEvent = new AreaEvent(p, 3551, 9694, 3552, 9694); openChestAreaEvent.setAction(() => { openChest(p); }); Server.registerCoordinateEvent(openChestAreaEvent); return; } for (int i = 0; i < 6; i++) { if (!p.getBarrowBrothersKilled(i)) { foreach(Npc n in Server.getNpcList()) { if (n != null) { if (n.getId() == BROTHER_ID[i]) { if (n.getOwner().Equals(p)) { return; } } } } Npc npc = new Npc(BROTHER_ID[i]); npc.setLocation(p.getLocation()); npc.setEntityFocus(p.getClientIndex()); npc.setOwner(p); npc.setTarget(p); npc.setCombatTurns(npc.getAttackSpeed()); Server.getNpcList().Add(npc); p.getPackets().setArrowOnEntity(1, npc.getClientIndex()); return; } } p.getPackets().sendMessage("You begin to lift open the massive chest..."); p.setLastAnimation(new Animation(833)); Event rewardEarthQuakeEvent = new Event(1000); rewardEarthQuakeEvent.setAction(() => { rewardEarthQuakeEvent.stop(); p.getPackets().sendMessage("..You loot the chest and the tomb begins to shake!"); p.getPackets().createObject(6775, new Location(3551, 9695, 0), 0, 10); getBarrowReward(p); startEarthQuake(p); }); Server.registerEvent(rewardEarthQuakeEvent); }
public static void attack(Npc npc, Entity target) { if (npc.isDead() || npc.isDestroyed() || target.isDead() || target.isDestroyed() || target.isDead()) { return; } double damage = misc.randomDouble(npc.getMaxHit()); PrayerData.PrayerHeadIcon prayerHeadIcon = ((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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.RANGE) damage = 0; else damage = misc.randomDouble(35); } else { if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE) damage = 0; } break; case 6265: // Grimspike (bandos range) hitDelay = 1000; animation = 65535; if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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); //One out of 3 chance if (misc.random(3) == 0) { animation = 6967; special = true; if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MAGIC) damage = 0; } else { if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE) damage = 0; } break; case 6250: // Growler (sara mage) hitDelay = 1000; if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE) damage = 0; //One out of 3 chance. if (misc.random(3) == 0) { animation = 6947; damage = misc.randomDouble(49); if (prayerHeadIcon != PrayerData.PrayerHeadIcon.MELEE && damage < (49 / 2)) damage = (49 / 2) + misc.randomDouble(49/2); } //One out of 4 chance. 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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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) //One out of 4 chance npc talking will display. if (misc.random(4) == 0) npc.setForceText("Kraaaaw!"); hitDelay = 1200; //50% chance if (misc.random(2) == 0 && npc.getAttacker() != null && npc.getAttacker().Equals(npc.getTarget())) { special = true; // Magic attack damage = misc.randomDouble(21); if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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.randomDouble(25); if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE) damage = 0; animation = 6977; } break; case 6223: // Armadyl mage hitDelay = 1200; if (prayerHeadIcon == PrayerData.PrayerHeadIcon.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 (prayerHeadIcon == PrayerData.PrayerHeadIcon.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(); } double hit = damage; Event attackEvent = new Event(hitDelay); attackEvent.setAction(() => { attackEvent.stop(); if (npc.getId() == 6263) { target.setLastGraphics(new Graphics(((hit > 0.10) ? 166 : 85), 0, 100)); } else if (npc.getId() == 6260) { if (special) { target.setLastGraphics(new Graphics(((hit > 0.10) ? 160 : 65535), 0, 100)); } } else if (npc.getId() == 6247) { if (special) { if (hit < 0.10) { //No damage. return; } else { target.setLastGraphics(new Graphics(1207, 0, 100)); npc.setCombatTurns(npc.getAttackSpeed() * 2); } } } else if (npc.getId() == 6208) { if (hit < 0.10) //No damage. target.setLastGraphics(new Graphics(85, 0, 100)); } else if (npc.getId() == 6222) { if (special) { target.setLastGraphics(new Graphics(((hit > 0.10) ? 85 : 65535), 0, 100)); } } if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0)) { target.setLastAnimation(new Animation(target.getDefenceAnimation())); } target.hit(hit); }); Server.registerEvent(attackEvent); }