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."); }
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); }
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 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); }
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); } }