public static Packet SpawnNPC(Life pNPC)
        {
            Packet p = new Packet();

            p.WriteShort((short)SendOpcodes.NPC_Spawn);
            p.WriteUInt(pNPC.SpawnID);
            p.WriteInt(pNPC.ID);
            p.WriteShort(pNPC.X);
            p.WriteShort(pNPC.Cy);
            p.WriteByte((byte)(pNPC.FacesLeft ? 0 : 1));
            p.WriteUShort(pNPC.Foothold);
            p.WriteShort(pNPC.Rx0);
            p.WriteShort(pNPC.Rx1);
            p.WriteByte((byte)(pNPC.Hide == 0 ? 1 : 0));

            return p;
        }
Exemple #2
0
 public void SetSpawnData(Life sd)
 {
     SpawnData = sd;
 }
Exemple #3
0
 public int spawnMob(int spawnid, Life life)
 {
     int id = ObjectIDs.NextValue();
     Mob mob = new Mob(id, ID, life.ID, new Pos((short)life.X, (short)life.Y), (short)life.Foothold, MobControlStatus.ControlNormal);
     mob.SetSpawnData(life);
     _Mobs.Add(mob);
     SendPacket(MobPacket.SpawnMonster(mob, 0, 0, false));
     UpdateMobControl(mob, true, null);
     return id;
 }
        public void LoadMaps()
        {
            if (MapNX == null)
            {
                Logger.WriteLog(Logger.LogTypes.Error, "Unable to load Map NX file.");
                return;
            }

            foreach (NXNode baseNode in MapNX.BaseNode)
            {
                if (baseNode.Name == "Map")
                {
                    foreach (NXNode Map in baseNode)
                    {
                        if (Map.Name.Contains("Map"))
                        {
                            foreach (NXNode MapNode in Map)
                            {
                                NXNode info = MapNode["info"];

                                Map map = new Map(int.Parse(MapNode.Name.Replace(".img", "")));
                                if (info.ContainsChild("fly"))
                                    map.Fly = info["fly"].ValueOrDefault<int>(0) > 0;
                                if (info.ContainsChild("forcedReturn"))
                                    map.ForcedReturn = info["forcedReturn"].ValueOrDefault<int>(999999999);
                                if (info.ContainsChild("onFirstUserEnter"))
                                    map.OnFirstUserEnter = info["onFirstUserEnter"].ValueOrDefault<string>(null);
                                if (info.ContainsChild("onUserEnter"))
                                    map.OnUserEnter = info["onUserEnter"].ValueOrDefault<string>(null);
                                if (info.ContainsChild("swim"))
                                    map.Swim = info["swim"].ValueOrDefault<int>(0) > 0;

                                if (MapNode.ContainsChild("life"))
                                {
                                    foreach (NXNode LifeNode in MapNode["life"])
                                    {
                                        Life lf = new Life();
                                        if (LifeNode.ContainsChild("id"))
                                            lf.ID = int.Parse(LifeNode["id"].ValueOrDefault<string>(null));
                                        if (LifeNode.ContainsChild("x"))
                                            lf.X = (Int16)LifeNode["x"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("y"))
                                            lf.Y = (Int16)LifeNode["y"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("cy"))
                                            lf.Cy = (Int16)LifeNode["cy"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("fh"))
                                            lf.Foothold = (UInt16)LifeNode["fh"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("rx0"))
                                            lf.Rx0 = (Int16)LifeNode["rx0"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("rx1"))
                                            lf.Rx0 = (Int16)LifeNode["rx1"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("type"))
                                            lf.Type = (LifeNode["type"].ValueOrDefault<string>(null));
                                        if (LifeNode.ContainsChild("f"))
                                            lf.FacesLeft = Convert.ToBoolean(LifeNode["f"].ValueOrDefault<Int64>(0));
                                        if (LifeNode.ContainsChild("mobTime"))
                                            lf.RespawnTime = (int)LifeNode["mobTime"].ValueOrDefault<Int64>(0);
                                        if (LifeNode.ContainsChild("hide"))
                                            lf.Hide = Convert.ToByte(LifeNode["hide"].ValueOrDefault<Int64>(0));

                                        if (lf.ID != 0)
                                            map.AddLife(lf);
                                    }
                                }

                                if (MapNode.ContainsChild("portal"))
                                {
                                    foreach (NXNode PortalNode in MapNode["portal"])
                                    {
                                        Portal pt = new Portal();
                                        pt.ID = byte.Parse(PortalNode.Name);
                                        pt.Name = PortalNode["pn"].ValueOrDefault<string>(null);
                                        pt.ToMapID = (int)PortalNode["tm"].ValueOrDefault<Int64>(999999999);
                                        pt.ToName = PortalNode["tn"].ValueOrDefault<string>(null);
                                        pt.X = (short)PortalNode["x"].ValueOrDefault<Int64>(0);
                                        pt.Y = (short)PortalNode["y"].ValueOrDefault<Int64>(0);

                                        map.AddPortal(pt);
                                    }
                                }

                                Maps.Add(map.ID, map);
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        public void AddLife(Life LF)
        {
            _Life[LF.Type].Add(LF);
            if (LF.Type == "n") LF.SpawnID = makeNPCID();
            else if (LF.Type == "r") LF.SpawnID = makeReactorID();
            else LF.SpawnID = (uint)(_Life[LF.Type].Count + 2);

            if (LF.Type == "m")
            {
                spawnMob((int)LF.SpawnID, LF);
            }
        }