Ejemplo n.º 1
0
	    public static void fightCaveAttacks(Npc npc, Player p) {
		    if (npc.isDead() || npc.isDestroyed() || p.isDead() || p.isDestroyed() || p.isDead() || !Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
			    return;
		    }
		    double damage = misc.randomDouble(npc.getMaxHit());
            PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon();
		    int hitDelay = npc.getHitDelay();
		    int animation = npc.getAttackAnimation();
		    switch(npc.getId()) {
			    case 2734: // Tz-Kih (lvl 22)
			    case 2735:
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                    {
					    damage = 0;
				    }
				    break;
				
			    case 2739: // Tz-Xil (lvl 90)
			    case 2740:
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.RANGE)
                    {
					    damage = 0;
				    }
				    p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1616, 50, 40, 34, 50, p);
				    break;
				
			    case 2741: // Yt-MejKot (lvl 180)
			    case 2742:
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                    {
					    damage = 0;
				    }
				    // TODO healing
				    break;
				
			    case 2743: // Ket-Zek (lvl 360)
			    case 2744:
				    if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
					    hitDelay = 1600;
					    animation = 9266;
					    npc.setLastGraphics(new Graphics(1622));
					    damage = misc.randomDouble(49);
                        if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MAGIC)
                        {
						    damage = 0;
					    }
                        Event sendProjectileToNpc = new Event(300);
                        sendProjectileToNpc.setAction(() => {
							sendProjectileToNpc.stop();
							p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1623, 50, 40, 34, 80, p);
					    });
                        Server.registerEvent(sendProjectileToNpc);
				    } else {
					    damage = misc.randomDouble(64);
                        if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                        {
						    damage = 0;
					    }
				    }
				    break;
				
			    case 2745: // TzTok Jad (lvl 702)
				    doJadAttacks(p, npc);
				    break;
		    }
		    if (npc.getId() == 2745){
			    return;
		    }
		    if (animation != 65535) {
			    npc.setLastAnimation(new Animation(animation));
		    }
            p.setLastAttacked(Environment.TickCount);
            npc.setLastAttack(Environment.TickCount);
		    p.setAttacker(npc);
		    npc.resetCombatTurns();
		    if (damage > p.getHp()) {
			    damage = p.getHp();
		    }
		    int npcId = npc.getId();

            Event losePrayerFightingEvent = new Event(hitDelay);
            losePrayerFightingEvent.setAction(() => {
				losePrayerFightingEvent.stop();
				if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
					return;
				}
				if (npcId == 2734 || npcId == 2735) {
                    int prayerLevel = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                    int newPrayerLevel = prayerLevel -= (int)(damage + 1);
					if (newPrayerLevel <= 0) {
						newPrayerLevel = 0;
					}
					p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayerLevel);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
				} else if (npcId == 2743 || npcId == 2744) {
					if (misc.random(1) == 0) {
						p.setLastGraphics(new Graphics(1624, 0));
					}
				}
				if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) {
					p.setLastAnimation(new Animation(p.getDefenceAnimation()));
				}
                p.hit(damage);
		    });
            Server.registerEvent(losePrayerFightingEvent);
	    }
Ejemplo n.º 2
0
	    private static void summonJadHealers(Player p,  Npc jad) {
		    for (int i = 0; i < 4; i++) {
			    Npc npc = new Npc(2746);
			    Location minCoords = new Location((20000 + 2363) + (200 * p.getIndex()), 25502, 0);
			    Location maxCoords = new Location((20000 + 2430) + (200 * p.getIndex()), 25123, 0);
			    npc.setMinimumCoords(minCoords);
			    npc.setMaximumCoords(maxCoords);
			    npc.setLocation(new Location((20000 + 2387) + (200 * p.getIndex()) + misc.random(22), 20000 + 5069 + misc.random(33), 0));
			    npc.setEntityFocus(jad.getClientIndex());
			    npc.setOwner(p);
			    npc.getFollow().setFollowing(jad);
			    npc.setTarget(null);
			    Server.getNpcList().Add(npc);

                Event jadHealerEvent = new Event(2000);
                jadHealerEvent.setAction(() => {
					if (npc.isDead() || !npc.isVisible() || npc.isDestroyed()) {
						jadHealerEvent.stop();
						return;
					}
					if (npc.getLocation().withinDistance(jad.getLocation(), 2) && !npc.inCombat()) {
						if (misc.random(7) == 0) {
							jad.setLastGraphics(new Graphics(444));
							npc.setLastAnimation(new Animation(9254));
							int jadMaxHp = jad.getMaxHp();
							jad.heal((int) (jadMaxHp * 0.5));
						}
					}
			    });
                Server.registerEvent(jadHealerEvent);
		    }
	    }
	    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);
	    }
Ejemplo n.º 4
0
	    private static void doJadAttacks(Player p, Npc npc) {
		    if (npc.getHp() <= (npc.getMaxHp() * 0.50)) {
			    if (p.getFightCave() != null) {
                    if (!p.getFightCave().isHealersSpawned())
                    {
					    summonJadHealers(p, npc);
					    p.getFightCave().setHealersSpawned(true);
				    }
			    }
		    }
		    npc.resetCombatTurns();
		    npc.setEntityFocus(p.getClientIndex());
		    switch(misc.random(1)) {
			    case 0: // Range
				    npc.setLastAnimation(new Animation(9276));
				    npc.setLastGraphics(new Graphics(1625));
                    Event jadRangeAttackEvent = new Event(1600);
                    int jadRangeAttackStatus = 0;
                    jadRangeAttackEvent.setAction(() => {
					    double hit = 0;
                        PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon();
                        if (jadRangeAttackStatus == 0)
                        {
                            jadRangeAttackStatus++;
							jadRangeAttackEvent.setTick(1500);
							p.setLastGraphics(new Graphics(451));
                            if (prayerHeadIcon == PrayerData.PrayerHeadIcon.RANGE)
								hit = 0;
							else
								hit = misc.randomDouble(96);
						} else {
                            if (prayerHeadIcon != PrayerData.PrayerHeadIcon.RANGE)
								hit = misc.randomDouble(96);
							jadRangeAttackEvent.stop();
                            p.setLastAttacked(Environment.TickCount);
                            npc.setLastAttack(Environment.TickCount);
							p.setAttacker(npc);
							if (hit > p.getHp()) {
								hit = p.getHp();
							}
							if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
								return;
							}
							if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) {
								p.setLastAnimation(new Animation(p.getDefenceAnimation()));
							}
							p.hit(hit);
                            Event animationEvent = new Event(100);
                            animationEvent.setAction(() => {
								animationEvent.stop();
								p.setLastGraphics(new Graphics(157, 0, 100));
							});
                            Server.registerEvent(animationEvent);
						}
				    });
                    Server.registerEvent(jadRangeAttackEvent);
				    break;
	
			    case 1: // Magic
				    npc.setLastGraphics(new Graphics(1626));
                    Event jadMagicAttackEvent = new Event(300);
                    int jadMagicAttackStatus = 0;
                    jadMagicAttackEvent.setAction(() => {
					    double hit = 0;
						PrayerData.PrayerHeadIcon prayerHeadIcon = p.getPrayers().getHeadIcon();
						npc.setLastAnimation(new Animation(9278));
                        if (jadMagicAttackStatus == 0)
                        {
                            jadMagicAttackStatus++;
							jadMagicAttackEvent.setTick(1600);
							p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1627, 50, 40, 34, 90, p);
						} else {
							jadMagicAttackEvent.stop();
                            if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MAGIC)
                            {
								hit = 0;
							} else {
								hit = misc.randomDouble(96);
							}
                            p.setLastAttacked(Environment.TickCount);
                            npc.setLastAttack(Environment.TickCount);
							p.setAttacker(npc);
							if (hit > p.getHp()) {
								hit = p.getHp();
							}
							if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null) {
								return;
							}
							if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0)) {
								p.setLastAnimation(new Animation(p.getDefenceAnimation()));
							}
							p.hit(hit);
                            Event animationEvent = new Event(100);
                            animationEvent.setAction(() => {
								animationEvent.stop();
								p.setLastGraphics(new Graphics(157, 0, 100));
							});
                            Server.registerEvent(animationEvent);
						}
				    });
                    Server.registerEvent(jadMagicAttackEvent);
				    break;
		    }
	    }
Ejemplo n.º 5
0
 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);
 }