Exemple #1
0
        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.");
        }
Exemple #2
0
 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);
 }