public static void load()
        {

            if (!File.Exists(misc.getServerPath() + @"\data\npcs.xml"))
            {
                misc.WriteError(@"Missing data\npcs.xml");
                return;
            }
            try {
                //Deserialize text file to a new object.
                StreamReader objStreamReader = new StreamReader(misc.getServerPath() + @"\data\npcs.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(List<NpcSpawn>));
                List<NpcSpawn> spawns = (List<NpcSpawn>)serializer.Deserialize(objStreamReader);

                foreach (NpcSpawn ns in spawns)
                {
                    Npc n = new Npc(ns.id, ns.location);
                    n.setMinimumCoords(ns.minimumCoords);
                    n.setMaximumCoords(ns.maximumCoords);
                    n.setWalkType(ns.walkType);
                    n.setFaceDirection(ns.faceDirection);
			        Server.getNpcList().Add(n);
		        }
            }
            catch (Exception e)
            {
                misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString()));
            }
            Console.WriteLine("Spawned " + Server.getNpcList().Count + " npcs.");
        }
	    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;
	    }
 private static bool canThieveNpc(Player p, Npc npc, int index)
 {
     if (p == null || npc == null || npc.isDead() || !npc.isVisible() || npc.isDestroyed() || p.isDead() || p.isDestroyed()) {
         return false;
     }
     if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
         return false;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.THIEVING) < NPC_LVL[index]) {
         p.getPackets().sendMessage("You need a Thieving level of " + NPC_LVL[index] + " to rob this Npc.");
         p.setFaceLocation(npc.getLocation());
         return false;
     }
     if (p.getInventory().findFreeSlot() == -1) {
         p.getPackets().sendMessage("You need a free inventory space for any potential loot.");
         return false;
     }
     if (p.getTemporaryAttribute("stunned") != null) {
         return false;
     }
     if (p.getTemporaryAttribute("lastPickPocket") != null) {
         if (Environment.TickCount - (int)p.getTemporaryAttribute("lastPickPocket") < 1500) {
             return false;
         }
     }
     return true;
 }
	    public static bool npcAttack(Npc npc, Entity target) {
		    if (npcHasAttack(npc)) {
			    doNpcAttack(npc, target);
			    return true;
		    }
		    return false;
	    }
	    private static bool npcHasAttack(Npc npc) {
		    for (int i = 0; i < NPCS.Length; i++) {
			    if (npc.getId() == NPCS[i]) {
				    return true;
			    }
		    }
		    return false;
	    }
	    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);
	    }
	    public static void interactWithAliMorissaae(Player p, Npc n) {
		    p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithAliMorissaaeAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithAliMorissaaeAreaEvent.setAction(() => {
				n.setFaceLocation(p.getLocation());
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				showAliDialogue(p, 205);
		    });
            Server.registerCoordinateEvent(interactWithAliMorissaaeAreaEvent);
	    }
 public AppearanceUpdateFlags(Npc npc)
 {
     this.npc = npc;
     animationUpdateRequired = false;
     entityFocusUpdateRequired = false;
     forceTextUpdateRequired = false;
     graphicsUpdateRequired = false;
     hitUpdateRequired = false;
     hit2UpdateRequired = false;
     faceLocationUpdateRequired = false;
 }
 public NpcSkills(Npc npc)
 {
     this.npc = npc;
     for (int i = 0; i < SKILL_COUNT-1; i++)
     {
         curLevel[i] = 1;
         maxLevel[i] = 1;
     }
     curLevel[(int)SKILL.HITPOINTS] = 10;
     maxLevel[(int)SKILL.HITPOINTS] = 10;
 }
 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;
 }
示例#11
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;
        }
示例#12
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;
             }
         }
     }
 }
	    private void startGame() {
            Event startFightCaveGameEvent = new Event(3000);
            startFightCaveGameEvent.setAction(() => {
				if (completed) {
					startFightCaveGameEvent.stop();
					return;
				}
				if (mobAmount > 0 || currentWave > 63) {
					return;
				}
				if (gamePaused && currentWave != 63) {
					startFightCaveGameEvent.stop();
					p.getPackets().forceLogout();
					return;
				}
				if (currentWave == 62) {
					startFightCaveGameEvent.setTick(8000);
					currentWave++;
					showJadMessage();
					return;
				} else if (currentWave < 62){
					currentWave++;
				}
				int[] mobs = decryptWave(currentWave);
				int amount = 0;
				for (int i = 0; i < mobs.Length; i++) {
					if (mobs[i] > 0) {
						Npc npc = new Npc(mobs[i]);
						Location minCoords = new Location(((20000 + 2363) + (200 * p.getIndex())), 25051, 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(p.getClientIndex());
						npc.setOwner(p);
						npc.setTarget(p);
						npc.getFollow().setFollowing(p);
						Server.getNpcList().Add(npc);
						amount++;
					}
				}
				mobAmount = (byte)amount;
		    });
            Server.registerEvent(startFightCaveGameEvent);
	    }
	    public static void talkToBob(Player p, Npc npc, int item, int option) {
		    p.setEntityFocus(npc.getClientIndex());
            AreaEvent talkToBobAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
            talkToBobAreaEvent.setAction(() => {
				npc.setFaceLocation(p.getLocation());
				p.setFaceLocation(npc.getLocation());
				p.setEntityFocus(65535);
				if (option == 0) { // use item on bob
					if (item > 0) {
						p.setTemporaryAttribute("bobsAxesBarrowItem", item);
						showBobDialogue(p, 101);
					}
				} else if (option == 1) { // talk
					showBobDialogue(p, 107);
				} else if (option == 2) { // trade
					p.setShopSession(new ShopSession(p, 4));
				}
		    });
            Server.registerCoordinateEvent(talkToBobAreaEvent);
	    }
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[SpawnNpc command]: ::npc npc_id");
                return;
            }

            int npcId = 0;
            if (!int.TryParse(arguments[0], out npcId))
            {
                player.getPackets().sendMessage("[SpawnNpc command]: ::npc npc_id");
                return;
            }

            Npc npc = new Npc(npcId, player.getLocation());
            npc.setMinimumCoords(new Location(player.getLocation().getX() - 5, player.getLocation().getY() - 5, player.getLocation().getZ()));
            npc.setMaximumCoords(new Location(player.getLocation().getX() + 5, player.getLocation().getY() + 5, player.getLocation().getZ()));
            Server.getNpcList().Add(npc);
        }
	    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;
	    }
	    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 void interactWithAubury(Player p, Npc n, int option) {
		    p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithAuburyAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithAuburyAreaEvent.setAction(() => {
				n.setFaceLocation(p.getLocation());
				p.setFaceLocation(n.getLocation());
				p.setEntityFocus(65535);
				switch(option) {
					case 1: // talk to
						
						break;
						
					case 2: // trade
						p.setShopSession(new ShopSession(p, 3));
						break;
						
					case 3: // teleport
						RuneCraft.teleportToEssMine(p, n);
						break;
				}
		    });
            Server.registerCoordinateEvent(interactWithAuburyAreaEvent);
	    }
示例#19
0
	    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);
	    }
示例#20
0
 private static void startFishing(Player p, int i, Npc npc, bool newFish, bool secondOption)
 {
     if (!newFish && p.getTemporaryAttribute("fishingSpot") == null) {
         return;
     }
     if (newFish) {
         int j = secondOption ? 1 : 0;
         int[] fish = secondOption ? SECOND_SPOT_FISH[i] : FIRST_SPOT_FISH[i];
         int[] level = secondOption ? SECOND_SPOT_LEVEL[i] : FIRST_SPOT_LEVEL[i];
         double[] xp = secondOption ? SECOND_SPOT_XP[i] : FIRST_SPOT_XP[i];
         p.setTemporaryAttribute("fishingSpot", new Spot(fish, level, i, SPOT_IDS[i], xp, npc.getLocation(), PRIMARY_ITEM[i][j], SECONDARY_ITEM[i][j], PRIMARY_NAME[i][j], SECONDARY_NAME[i][j], secondOption));
     }
     Spot fishingSpot = (Spot) p.getTemporaryAttribute("fishingSpot");
     int k = fishingSpot.isSecondOption() ? 1 : 0;
     int index =  getFishToAdd(p, fishingSpot);
     if (!canFish (p, fishingSpot, null, index)){
         resetFishing(p);
         p.setLastAnimation(new Animation(65535));
         return;
     }
     if (newFish) {
         p.getPackets().sendMessage("You attempt to catch a fish...");
         p.setLastAnimation(new Animation(FISHING_ANIMATION[i][k]));
     }
     string name = fishingSpot.isSecondOption() ? SECOND_CATCH_NAME[fishingSpot.getSpotindex()][index] : FIRST_CATCH_NAME[fishingSpot.getSpotindex()][index];
     string s = fishingSpot.getSpotindex() == 1 && !fishingSpot.isSecondOption() ? "some" : "a";
     Event doFishingEvent = new Event(getFishingDelay(p, fishingSpot));
     doFishingEvent.setAction(() => {
         doFishingEvent.stop();
         if (p.getTemporaryAttribute("fishingSpot") == null) {
             resetFishing(p);
             p.setLastAnimation(new Animation(65535));
             return;
         }
         Spot fishingSpot2 = (Spot) p.getTemporaryAttribute("fishingSpot");
         if (!canFish(p, fishingSpot, fishingSpot2, index)) {
             resetFishing(p);
             p.setLastAnimation(new Animation(65535));
             return;
         }
         p.getPackets().closeInterfaces();
         p.getInventory().deleteItem(fishingSpot2.getSecondaryItem());
         p.setLastAnimation(new Animation(FISHING_ANIMATION2[fishingSpot2.getSpotindex()][k]));
         p.getPackets().sendMessage("You catch " + s + " " + name + ".");
         if (p.getInventory().addItem(fishingSpot2.getFish()[index])) {
             p.getSkills().addXp(Skills.SKILL.FISHING, fishingSpot2.getFishingXp()[index]);
         }
         startFishing(p, i, null, false, secondOption);
     });
     Server.registerEvent(doFishingEvent);
 }
 private static void appendEntityFocusUdate(Npc Npc, PacketBuilder updateBlock)
 {
     int entityFocus = Npc.getEntityFocus();
     if (entityFocus != -1)
         updateBlock.addShortA(entityFocus);
 }
示例#22
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 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;
	    }
 private static void appendForceTextUpdate(Npc Npc, PacketBuilder updateBlock)
 {
     object forceText = Npc.getTemporaryAttribute("forceText");
     if (forceText != null)
     {
         updateBlock.addString((string)forceText);
     }
 }
        protected bool checkHitTarget()
        {
            int cannonX = fakeCannonLocation.getX();
            int cannonY = fakeCannonLocation.getY();
            Npc[] npcsToAttack = new Npc[npcsInArea.Count];
            bool hit = false;
            foreach(Npc n in Server.getNpcList()) {
                hit = false;
                Location l = n.getLocation();
                if (n == null || !n.isVisible() || n.isDead() || !n.getLocation().withinDistance(fakeCannonLocation, 8)) {
                    continue;
                }
                switch(direction) {
                    case 0: // North
                        hit = l.inArea(cannonX-1, cannonY, cannonX+1, cannonY+8);
                        break;

                    case 1: // North east
                        break;

                    case 2: // East:
                        hit = l.inArea(cannonX, cannonY-1, cannonX+8, cannonY+1);
                        break;

                    case 3: // South east
                        break;

                    case 4: // South
                        hit = l.inArea(cannonX-1, cannonY-8, cannonX+1, cannonY);
                        break;

                    case 5: // South west
                        break;

                    case 6: // West
                        hit = l.inArea(cannonX-8, cannonY-1, cannonX, cannonY+1);
                        break;

                    case 7: // North west
                        break;
                }
                if (hit) {
                    Npc npc = n;
                    p.getPackets().sendProjectile(fakeCannonLocation, n.getLocation(), 30, 53, 50, 38, 38, 40, n);
                    Event doCannonHitEvent = new Event(1000);
                    doCannonHitEvent.setAction(() => {
                        doCannonHitEvent.stop();
                        double damage = misc.randomDouble(30);
                        p.getSkills().addXp(Skills.SKILL.RANGE, damage * 2);
                        npc.hit(damage);
                        npc.setLastAnimation(new Animation(npc.getDefenceAnimation()));
                    });
                    Server.registerEvent(doCannonHitEvent);
                    return true;
                }
            }
            return false;
        }
示例#26
0
	    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;
	    }
示例#27
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;
 }
示例#28
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;
	    }
 private static void appendGraphicsUpdate(Npc Npc, PacketBuilder updateBlock)
 {
     Graphics gfx = Npc.getLastGraphics();
     if (gfx != null)
     {
         updateBlock.addShortA(gfx.getId());
         updateBlock.addLEInt(gfx.getHeight() << 16 + gfx.getDelay());
     }
 }