예제 #1
0
	    private static bool npcHasAttack(Npc npc) {
		    for (int i = 0; i < NPCS.Length; i++) {
			    if (npc.getId() == NPCS[i]) {
				    return true;
			    }
		    }
		    return false;
	    }
예제 #2
0
	    public static bool interactTzhaarNPC(Player p, Npc n, int option) {
		    if (n.getId() != 2622 && n.getId() != 2620 && n.getId() != 2623 && n.getId() != 2619 && n.getId() != 2617 && n.getId() != 2618) {
			    return false;
		    }
		    p.setEntityFocus(n.getClientIndex());
		    int npcX = n.getLocation().getX();
		    int npcY = n.getLocation().getY();
            AreaEvent interactTzhaarNpcAreaEvent = new AreaEvent(p, npcX-1, npcY-1, npcX+1, npcY+1);
            interactTzhaarNpcAreaEvent.setAction(() => {
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(n.getId()) {
					case 2619: // Bankers
						if (option == 1) { // Talk
							
						} else if (option == 2) { // Bank
							p.getBank().openBank();
						} else if (option == 3) { // Collect
							
						}
						break;
				
						//TODO tzhaar stores
					case 2622: // Ore shop
						if (option == 1) { // Speak
							
						} else if (option == 2) { // Trade
							p.setShopSession(new ShopSession(p, 3));
						}
						break;
				}
		    });
            Server.registerCoordinateEvent(interactTzhaarNpcAreaEvent);
		    return true;
	    }
	    public static bool interactWithBoatNPC(Player p, Npc n) {
		    int id = n.getId();
		    if (id != 4540 && id != 1304 && id != 2436 && id != 3781 && id != 1361 && id != 4962) {
			    return false;
		    }
		    p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithBoatNPCAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithBoatNPCAreaEvent.setAction(() => {
				n.setFaceLocation(p.getLocation());
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(n.getId()) {
					case 4540: // Home boat
						showBentleyDialogue(p, 240);
						break;
						
					case 1304: // Canifis sailor
						showCanifisSailorDialogue(p, 280);
						break;
						
					case 2436: // Waterbirth isle
						showJarvaldDialogue(p, 300);
						break;
						
					case 3781: // Pest control squire
						showSquireDialogue(p, 340);
						break;
						
					case 1361: // Warrior guild
						showArnorDialogue(p, 370);
						break;
					
					case 4962: // fremmenik shore
						showCaptainBarnabyDialogue(p, 410);
						break;
				}
		    });
            Server.registerCoordinateEvent(interactWithBoatNPCAreaEvent);
		    return true;
	    }
예제 #4
0
 public static bool wantToThieveNpc(Player p, Npc npc)
 {
     for (int i = 0; i < NPCS.Length; i++) {
         for (int j = 0; j < NPCS[i].Length; j++)
         {
             if (npc.getId() == NPCS[i][j]) {
                 thieveNpc(p, npc , i);
                 return true;
             }
         }
     }
     return false;
 }
예제 #5
0
        public static bool wantToFish(Player p, Npc npc, bool secondOption)
        {
            for (int i = 0; i < SPOT_IDS.Length; i++) {
                if (npc.getId() == SPOT_IDS[i]){
                    p.setFaceLocation(npc.getLocation());

                    AreaEvent startFishingAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
                    startFishingAreaEvent.setAction(() => {
                        startFishing(p, i, npc, true, secondOption);
                    });
                    Server.registerCoordinateEvent(startFishingAreaEvent);
                    return true;
                }
            }
            return false;
        }
예제 #6
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;
             }
         }
     }
 }
예제 #7
0
	    private static void doNpcAttack(Npc npc, Entity target) {
		    switch(npc.getId()) {
			    case DHAROK:
			    case AHRIM:
			    case TORAG:
			    case VERAC:
			    case KARIL:
			    case GUTHAN:
				    BarrowNPCAttacks.attack(npc, target);
				    break;
				
			    case 6263:
			    case 6260:
			    case 6265:
			    case 6247:
			    case 6250:
			    case 6252:
			    case 6203:
			    case 6208:
			    case 6206:
			    case 6222:
			    case 6223:
			    case 6225:
				    GodwarsAttacks.attack(npc, target);
				    break;
				
			    case 2734:
			    case 2735:
			    case 2739:
			    case 2740:
			    case 2741:
			    case 2742:
			    case 2743:
			    case 2744:
			    case 2745:
				    FightCave.fightCaveAttacks(npc, ((Player)target));
				    break;
		    }
	    }
	    public static bool talkToWarriorGuildNPC(Player p, Npc n, int slot) {
		    if (n.getId() != 4289) {
			    return false;
		    }
		    p.setEntityFocus(n.getClientIndex());
		    int npcX = n.getLocation().getX();
		    int npcY = n.getLocation().getY();
            AreaEvent talkToWarriorGuildNPCAreaEvent = new AreaEvent(p, npcX-1, npcY-1, npcX+1, npcY+1);
            talkToWarriorGuildNPCAreaEvent.setAction(() => {
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(n.getId()) {
					case 4289: // Kamfreena
						Dialogue.doDialogue(p, 77);
						break;
				}
		    });
            Server.registerCoordinateEvent(talkToWarriorGuildNPCAreaEvent);
		    return true;
	    }
	    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();
		    });
	    }
예제 #10
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);
	    }
예제 #11
0
 public static bool talkToMaster(Player p, Npc npc)
 {
     for (int i = 0; i < SLAYER_MASTERS.Length; i++) {
         if (npc.getId() == (int)SLAYER_MASTERS[i][0]) {
             int j = i;
             p.setEntityFocus(npc.getClientIndex());
             AreaEvent talkToMasterAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
             talkToMasterAreaEvent.setAction(() => {
                 p.setTemporaryAttribute("slayerMaster", j);
                 npc.setFaceLocation(p.getLocation());
                 p.setFaceLocation(npc.getLocation());
                 p.setEntityFocus(65535);
                 doDialogue(p, 1000);
             });
             Server.registerCoordinateEvent(talkToMasterAreaEvent);
             return true;
         }
     }
     return false;
 }
	    public static bool dialogue(Player p, Npc npc, bool rightClickPay) {
		    if ((npc.getId() != 1055 && npc.getId() != 437) || (rightClickPay && npc.getId() != 437)) {
			    return false;
		    }
		    p.setEntityFocus(npc.getClientIndex());
            AreaEvent dialogueAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
            dialogueAreaEvent.setAction(() => {
				npc.setFaceLocation(p.getLocation());
				int status = npc.getId() == 1055 ? 43 : 1;
				if (rightClickPay) {
					if (!p.getInventory().hasItemAmount(995, AGILITY_ARENA_PRICE)) {
						p.getPackets().sendMessage("You don't have enough money to pay the entrance fee.");
						return;
					}
					status = 29;
				}
				doDialogue(p, status);
		    });
            Server.registerCoordinateEvent(dialogueAreaEvent);
		    return true;
	    }
예제 #13
0
 public static bool openSlayerShop(Player p, Npc npc)
 {
     int id = npc.getId();
     if (id != 8273 && id != 1597 && id != 8274 && id != 1598 && id != 8275 || p.isDead()) {
         return false;
     }
     p.setEntityFocus(npc.getClientIndex());
     AreaEvent openSlayerShopAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
     openSlayerShopAreaEvent.setAction(() => {
         p.setFaceLocation(npc.getLocation());
         npc.setFaceLocation(p.getLocation());
         p.setShopSession(new ShopSession(p, 2));
     });
     Server.registerCoordinateEvent(openSlayerShopAreaEvent);
     return true;
 }
예제 #14
0
 public static bool openPointsInterface(Player p, Npc npc)
 {
     int id = npc.getId();
     if (id != 8273 && id != 1597 && id != 8274 && id != 1598 && id != 8275 || p.isDead()) {
         return false;
     }
     p.setEntityFocus(npc.getClientIndex());
     AreaEvent openPointsInterfaceAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
     openPointsInterfaceAreaEvent.setAction(() => {
         p.setEntityFocus(65535);
         npc.setFaceLocation(p.getLocation());
         displayPoints(p, 1);
     });
     Server.registerCoordinateEvent(openPointsInterfaceAreaEvent);
     return true;
 }
	    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);
	    }
	    public static double getNPCMeleeDefence(Npc npc) {
		    double power = 0.600;
		    double amount = 0.900;

            NpcData npcDef = NpcData.forId(npc.getId());
            int combatLevel = 3;
            if (npcDef == null)
            { //Level 3 if npcDef doesn't exist
                power *= (amount * combatLevel) * power;
                misc.WriteError("Missing npcDef for npcId: " + npc.getId());
            }
            else
            {
                combatLevel = NpcData.forId(npc.getId()).getCombat();
                power *= (amount * combatLevel) * power;
                if (npcDef.isBoss())
                {
                    power *= 1.4; //40% increase.
                }
            }
		    return power;
	    }
예제 #17
0
 private static void appendHitUpdate(Npc Npc, PacketBuilder updateBlock)
 {
     NpcData npcDef = NpcData.forId(Npc.getId());
     int ratio = 1;
     if (npcDef != null)
         ratio = Npc.getHp() * 255 / npcDef.getHitpoints();
     else
         misc.WriteError("Missing npcDef npcId: " + Npc.getId());
     updateBlock.addByte((byte)Npc.getHits().getHitDamage1());
     updateBlock.addByteC((int)Npc.getHits().getHitType1());
     updateBlock.addByteS((byte)ratio);
 }