Ejemplo n.º 1
0
 public static void checkSlayerKill(Player p, Npc npc)
 {
     if (p.getSlayerTask() == null) {
         return;
     }
     SlayerTask task = p.getSlayerTask();
     object[][] data = getMasterData(task.getMasterIndex());
     for (int i = 1; i < data[task.getMonsterIndex()].Length; i++) {
         if (npc.getId() == (int) data[task.getMonsterIndex()][i]) {
             if (npc.getKiller().Equals(p)) {
                 p.getSkills().addXp(Skills.SKILL.SLAYER, npc.getMaxHp());//(double) data[task.getMonsterIndex()][1]);
                 checkIfCompleteTask(p, task);
                 break;
             }
         }
     }
 }
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.getOwner() == null || npc.isDestroyed() || target.isDead() || target.isDestroyed()) {
			    return;
		    }
		    double damage = misc.randomDouble(npc.getMaxHit());
            PrayerData.PrayerHeadIcon prayerHeadIcon = ((Player)target).getPrayers().getHeadIcon();
		    int hitDelay = npc.getHitDelay();
		    bool special = false;
		    switch(npc.getId()) {
			    case 2026: // Dharok
				    int healthHit = (npc.getMaxHp() - npc.getHp()) / 2;
				    damage = misc.randomDouble(damage + healthHit);
				    if (misc.random(1) == 0) {
					    if (damage < (npc.getMaxHp() / 3)) {
                            damage = (npc.getMaxHp() / 4) + misc.randomDouble(damage + healthHit) - (npc.getMaxHp() / 4);
					    }
				    }
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                    {
					    damage = 0;
				    }
				    break;
				
			    case 2025: // Ahrim
				    hitDelay = 1000;
				    ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 156, 50, 40, 34, 60, target);
				    if (misc.random(3) == 0) {
					    special = true;
                        Skills.SKILL[] weakenableSkills = (Skills.SKILL[])Enum.GetValues(typeof(Skills.SKILL));
                        Skills.SKILL weakenedSkill = weakenableSkills[misc.random(0,2)];
                        int currentLevel = ((Player)target).getSkills().getCurLevel(weakenedSkill);
                        int newLevel = currentLevel - misc.random(((Player)target).getSkills().getMaxLevel(weakenedSkill) / 12);
                        newLevel = Math.Max(0, newLevel);
                        ((Player)target).getSkills().setCurLevel(weakenedSkill, newLevel);
                        ((Player)target).getPackets().sendSkillLevel(weakenedSkill);
				    }
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MAGIC)
                    {
					    damage = 0;
				    }
				    break;
				
			    case 2027: // Guthan
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                    {
					    damage = 0;
				    }
				    if (misc.random(3) == 0) {
					    special = true;
					    target.setLastGraphics(new Graphics(398));
					    npc.heal(misc.random((int)damage));
				    }
				    break;
				
			    case 2030: // Verac
                    if (misc.random(1) == 0 && prayerHeadIcon != PrayerData.PrayerHeadIcon.MELEE)
                    {
					    if (damage <= npc.getMaxHit() / 2) {
						    damage += npc.getMaxHit() / 2;
						    if (damage > npc.getMaxHit()) {
							    damage = npc.getMaxHit();
						    }
					    }
				    }
				    break;
				
			    case 2029: // Torag
				    if (misc.random(3) == 0) {
					    special = true;
				    }
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.MELEE)
                    {
					    damage = 0;
				    }
				    break;
				
			    case 2028: // Karil
				    hitDelay = 700;
				    ((Player)target).getPackets().sendProjectile(npc.getLocation(), target.getLocation(), 32, 27, 50, 40, 34, 40, target);
				    if (misc.random(10) == 0) {
					    special = true;
                        int agility = ((Player)target).getSkills().getCurLevel(Skills.SKILL.AGILITY);
					    int newAgility = agility / 4;
					    if (newAgility <= 1)
						    newAgility = 1;
					    ((Player)target).getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
                        ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.AGILITY);
				    }
				    if (misc.random(1) == 0) {
					    damage = damage > 0 ? damage : misc.randomDouble(npc.getMaxHit());
				    }
                    if (prayerHeadIcon == PrayerData.PrayerHeadIcon.RANGE)
                    {
					    damage = 0;
				    }
				    break;
		    }
		    npc.setLastAnimation(new Animation(npc.getAttackAnimation()));
		    target.setLastAttacked(Environment.TickCount);
		    npc.setLastAttack(Environment.TickCount);
		    npc.resetCombatTurns();
		    target.setAttacker(npc);
		    if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0)) {
			    target.setLastAnimation(new Animation(target.getDefenceAnimation()));
		    }
		    if (damage > target.getHp()) {
			    damage = target.getHp();
		    }
            Event doHitEvent = new Event(hitDelay);
            doHitEvent.setAction(() => {
				if (npc.getId() == 2025) {
					if (special) {
						target.setLastGraphics(new Graphics(400, 0, 100));
						((Player)target).getPackets().sendMessage("You feel weakened.");
						
					}
					target.setLastGraphics(new Graphics(damage == 0 ? 85 : 157, 0, 100));
				} else if (npc.getId() == 2027) {
                    if (special)
                    {
						if (!npc.isDead()) {
                            int newHp = npc.getHp() + (int)damage;
							if (newHp > npc.getMaxHp()) {
								newHp = npc.getMaxHp();
							}
							npc.setHp(newHp);
						}
					}
				} else if (npc.getId() == 2029) {
                    if (special)
                    {
						target.setLastGraphics(new Graphics(399, 0, 100));
						int energy = ((Player)target).getRunEnergy();
						int newEnergy = energy - (int) (energy * 0.50);
						if (newEnergy < 0) {
							newEnergy = 0;
						}
                        ((Player)target).getPackets().sendMessage("You feel drained of energy.");
						((Player)target).setRunEnergy(newEnergy);
                        ((Player)target).getPackets().sendEnergy();
					}
				} else if (npc.getId() == 2028) {
                    if (special)
                    {
						target.setLastGraphics(new Graphics(399));
                        ((Player)target).getPackets().sendMessage("You feel less agile.");
					}
				}
                target.hit(damage);
                doHitEvent.stop();
		    });
	    }
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;
		    }
	    }