Ejemplo n.º 1
0
 public static byte[] NpcLeaveField(Npc npc)
 {
     var packet = new PacketWriter();
     packet.WriteOpcode(SendOps.NpcLeaveField);
     packet.WriteInt(npc.mObjectID);
     return packet.ToArray();
 }
Ejemplo n.º 2
0
        public static int CacheFieldData()
        {
            int ret = 0;
            foreach (NXNode mapnode in Map.BaseNode.GetChild("Map"))
            {
                if (!mapnode.Name.StartsWith("Map"))
                    continue;
                foreach (NXNode mapimg in mapnode)
                {
                    CField field = new CField();
                    field.FieldID = int.Parse(mapimg.Name.Replace(".img", ""));
                    NXNode node = mapimg.GetChild("info");
                    foreach (NXNode childnode in node)
                        switch (childnode.Name)
                        {
                            case "bgm":
                                field.WzData.bgm = GetStringFromChild(node, childnode.Name);
                                break;
                            case "cloud":
                                field.WzData.cloud = GetIntFromChild(node, childnode.Name);
                                break;
                            case "swim":
                                field.WzData.swim = GetIntFromChild(node, childnode.Name);
                                break;
                            case "forcedReturn":
                                field.WzData.forcedReturn = GetIntFromChild(node, childnode.Name);
                                break;
                            case "hideMinimap":
                                field.WzData.hideMinimap = GetIntFromChild(node, childnode.Name);
                                break;
                            case "mapDesc":
                                field.WzData.mapDesc = GetStringFromChild(node, childnode.Name);
                                break;
                            case "mapMark":
                                field.WzData.MapMark = GetStringFromChild(node, childnode.Name);
                                break;
                            case "mobRate":
                                field.WzData.mobRate = GetFloatFromChild(node, childnode.Name);
                                break;
                            case "moveLimit":
                                field.WzData.moveLimit = GetIntFromChild(node, childnode.Name);
                                break;
                            case "returnMap":
                                field.WzData.returnMap = GetIntFromChild(node, childnode.Name);
                                break;
                            case "town":
                                field.WzData.town = GetIntFromChild(node, childnode.Name);
                                break;
                            case "fieldLimit":
                                int fl = GetIntFromChild(node, childnode.Name);
                                if (fl >= (int) Math.Pow(2, 23))
                                    fl = fl & ((int) Math.Pow(2, 23) - 1);
                                field.WzData.fieldLimit = (FieldLimit) fl;
                                break;
                            case "VRTop":
                            case "VRBottom":
                            case "VRLeft":
                            case "VRRight":
                                break;
                            case "timeLimit":
                                field.WzData.timeLimit = GetIntFromChild(node, childnode.Name);
                                break;
                            case "lvLimit":
                                field.WzData.lvLimit = GetIntFromChild(node, childnode.Name);
                                break;
                            case "onFirstUserEnter":
                                field.WzData.onFirstUserEnter = GetStringFromChild(node, childnode.Name);
                                break;
                            case "onUserEnter":
                                field.WzData.onUserEnter = GetStringFromChild(node, childnode.Name);
                                break;
                            case "fly":
                                field.WzData.fly = GetIntFromChild(node, childnode.Name);
                                break;
                            case "noMapCmd":
                                field.WzData.noMapCmd = GetIntFromChild(node, childnode.Name);
                                break;
                            case "partyOnly":
                                field.WzData.partyOnly = GetIntFromChild(node, childnode.Name);
                                break;
                            case "fieldType":
                                int ft = GetIntFromChild(node, childnode.Name);
                                if (!Enum.IsDefined(typeof (FieldType), ft))
                                    ft = 0;
                                field.WzData.fieldType = (FieldType) ft;
                                break;
                            case "miniMapOnOff":
                                field.WzData.miniMapOnOff = GetIntFromChild(node, childnode.Name);
                                break;
                            case "reactorShuffle":
                                field.WzData.reactorShuffle = GetIntFromChild(node, childnode.Name);
                                break;
                            case "reactorShuffleName":
                                field.WzData.reactorShuffleName = GetStringFromChild(node, childnode.Name);
                                break;
                            case "personalShop":
                                field.WzData.personalShop = GetIntFromChild(node, childnode.Name);
                                break;
                            case "entrustedShop":
                                field.WzData.entrustedShop = GetIntFromChild(node, childnode.Name);
                                break;
                            case "effect":
                                field.WzData.effect = GetStringFromChild(node, childnode.Name);
                                break;
                            case "lvForceMove":
                                field.WzData.lvForceMove = GetIntFromChild(node, childnode.Name);
                                break;
                            case "timeMob":
                                field.WzData.startHour = GetIntFromChild(node, "startHour");
                                field.WzData.endHour = GetIntFromChild(node, "endHour");
                                int? id = GetIntFromChild(node, "id");
                                string message = GetStringFromChild(node, "message");
                                if (id == null || message == null ||
                                    (field.WzData.startHour == null ^ field.WzData.endHour == null))
                                    break;
                                else
                                    field.WzData.timeMob = new FieldWzData.TimeMob(field.WzData.startHour,
                                                                                   field.WzData.endHour, (int) id,
                                                                                   message);
                                break;
                            case "help":
                                field.WzData.help = GetStringFromChild(node, childnode.Name);
                                break;
                            case "snow":
                                field.WzData.snow = GetIntFromChild(node, childnode.Name);
                                break;
                            case "rain":
                                field.WzData.rain = GetIntFromChild(node, childnode.Name);
                                break;
                            case "dropExpire":
                                field.WzData.dropExpire = GetIntFromChild(node, childnode.Name);
                                break;
                            case "decHP":
                                field.WzData.decHP = GetIntFromChild(node, childnode.Name);
                                break;
                            case "decInterval":
                                field.WzData.decInterval = GetIntFromChild(node, childnode.Name);
                                break;
                            case "autoLieDetector":
                                field.WzData.startHour = GetIntFromChild(node, "startHour");
                                field.WzData.endHour = GetIntFromChild(node, "endHour");
                                int? interval = GetIntFromChild(node, "interval");
                                int? propInt = GetIntFromChild(node, "prop");
                                if (field.WzData.startHour == null || field.WzData.endHour == null || interval == null ||
                                    propInt == null)
                                {
                                    break;
                                }
                                else
                                    field.WzData.autoLieDetector =
                                        new FieldWzData.AutoLieDetector((int) field.WzData.startHour,
                                                                        (int) field.WzData.endHour, (int) interval,
                                                                        (int) propInt);
                                break;
                            case "expeditionOnly":
                                field.WzData.expeditionOnly = GetIntFromChild(node, childnode.Name);
                                break;
                            case "fs":
                                field.WzData.fs = GetFloatFromChild(node, childnode.Name);
                                break;
                            case "protectItem":
                                field.WzData.protectItem = GetIntFromChild(node, childnode.Name);
                                break;
                            case "createMobInterval":
                                field.WzData.createMobInterval = GetIntFromChild(node, childnode.Name);
                                break;
                            case "fixedMobCapacity":
                                field.WzData.fixedMobCapacity = GetIntFromChild(node, childnode.Name);
                                break;
                            case "streetName":
                                field.WzData.streetName = GetStringFromChild(node, childnode.Name);
                                break;
                            case "mapName":
                                field.WzData.mapName = GetStringFromChild(node, childnode.Name);
                                break;
                            case "noRegenMap":
                                field.WzData.noRegenMap = GetIntFromChild(node, childnode.Name);
                                break;
                            case "recovery":
                                field.WzData.recovery = GetFloatFromChild(node, childnode.Name);
                                break;
                            case "blockPBossChange":
                                field.WzData.blockPBossChange = GetIntFromChild(node, childnode.Name);
                                break;
                            case "everlast":
                                field.WzData.everlast = GetIntFromChild(node, childnode.Name);
                                break;
                            case "damageCheckFree":
                                field.WzData.damageCheckFree = GetIntFromChild(node, childnode.Name);
                                break;
                            case "dropRate":
                                field.WzData.dropRate = GetFloatFromChild(node, childnode.Name);
                                break;
                            case "scrollDisable":
                                field.WzData.scrollDisable = GetIntFromChild(node, childnode.Name);
                                break;
                            case "needSkillForFly":
                                field.WzData.needSkillForFly = GetIntFromChild(node, childnode.Name);
                                break;
                            case "zakum2Hack":
                                field.WzData.zakum2Hack = GetIntFromChild(node, childnode.Name);
                                break;
                            case "allMoveCheck":
                                field.WzData.allMoveCheck = GetIntFromChild(node, childnode.Name);
                                break;
                            case "VRLimit":
                                field.WzData.VRLimit = GetIntFromChild(node, childnode.Name);
                                break;
                            case "consumeItemCoolTime":
                                field.WzData.consumeItemCoolTime = GetIntFromChild(node, childnode.Name);
                                break;
                        }
                    if (mapimg.ContainsChild("life"))
                    {
                        node = mapimg.GetChild("life");
                        foreach (NXNode childnode in node)
                        {
                            string type = GetStringFromChild(childnode, "type");
                            if (type == "m")
                            {
                                var monster = new Monster();
                                monster.mID = GetIntFromChild(childnode, "id");
                                monster.mX = GetIntFromChild(childnode, "x");
                                monster.mY = GetIntFromChild(childnode, "y");
                                monster.mMobTime = GetIntFromChild(childnode, "mobTime");
                                monster.mF = GetIntFromChild(childnode, "f");
                                monster.mHide = GetIntFromChild(childnode, "hide");
                                monster.mFh = GetIntFromChild(childnode, "fh");
                                monster.mCy = GetIntFromChild(childnode, "cy");
                                monster.mRx0 = GetIntFromChild(childnode, "rx0");
                                monster.mRx1 = GetIntFromChild(childnode, "rx1");
                                field.AddFieldObject(monster);
                            }
                            else if (type == "n")
                            {
                                var npc = new Npc();
                                npc.mID = GetIntFromChild(childnode, "id");
                                npc.mX = GetIntFromChild(childnode, "x");
                                npc.mY = GetIntFromChild(childnode, "y");
                                npc.mF = GetIntFromChild(childnode, "f");
                                npc.mFh = GetIntFromChild(childnode, "fh");
                                npc.mCy = GetIntFromChild(childnode, "cy");
                                npc.mRx0 = GetIntFromChild(childnode, "rx0");
                                npc.mRx1 = GetIntFromChild(childnode, "rx1");
                                field.AddFieldObject(npc);
                            }
                        }
                    }
                    /*if (mapimg.ContainsChild("reactor"))
                    {
                        node = mapimg.GetChild("reactor");
                        foreach (NXNode childnode in node)
                            switch (childnode.Name)
                            {
                            }
                    }
                    if (mapimg.ContainsChild("foothold"))
                    {
                        node = mapimg.GetChild("foothold");
                        foreach (NXNode childnode in node)
                            switch (childnode.Name)
                            {
                            }
                    }
                    if (mapimg.ContainsChild("ladderRope"))
                    {
                        node = mapimg.GetChild("ladderRope");
                        foreach (NXNode childnode in node)
                            switch (childnode.Name)
                            {
                            }
                    }*/
                    if (mapimg.ContainsChild("foothold"))
                    {
                        node = mapimg.GetChild("foothold");
                        field.mFootholdTree.mField = field;
                        foreach (NXNode layernode in node)
                        {
                            foreach (NXNode groupnode in node)
                            {
                                foreach (NXNode footholdnode in node)
                                {
                                    Foothold foothold = new Foothold();
                                    foothold.mFootholdTree = field.mFootholdTree;
                                    foothold.mLayerID = int.Parse(layernode.Name);
                                    foothold.mGroupID = int.Parse(groupnode.Name);
                                    foothold.mID = int.Parse(footholdnode.Name);
                                    foothold.mStart = new Point(GetIntFromChild(footholdnode, "x1"), GetIntFromChild(footholdnode, "y1"));
                                    foothold.mEnd = new Point(GetIntFromChild(footholdnode, "x2"), GetIntFromChild(footholdnode, "y2"));
                                    foothold.mPrevious = GetIntFromChild(footholdnode, "prev");
                                    foothold.mNext = GetIntFromChild(footholdnode, "next");
                                    foothold.mForce = GetIntFromChild(footholdnode, "force");
                                    foothold.mForbidFallDown = GetIntFromChild(footholdnode, "forbidFallDown");
                                    foothold.mPiece = GetIntFromChild(footholdnode, "piece");
                                    field.mFootholdTree.mFootholds.Add(foothold);
                                }
                            }
                        }
                    }
                    if (mapimg.ContainsChild("seat"))
                    {
                        node = mapimg.GetChild("seat");
                        foreach (NXNode childnode in node)
                        {
                            Seat seat = new Seat();
                            int id = int.Parse(childnode.Name);
                            seat.mID = id;
                            seat.mPosition = GetPointFromChild(node, childnode.Name);
                            field.AddFieldObject(seat);
                        }
                    }
                    if (mapimg.ContainsChild("portal"))
                    {
                        node = mapimg.GetChild("portal");
                        foreach (NXNode childnode in node)
                        {
                            Portal portal = new Portal();
                            portal.mPortalID = int.Parse(childnode.Name);
                            portal.mName = GetStringFromChild(childnode, "pn");
                            portal.mPosition = new Point(GetIntFromChild(childnode, "x"), GetIntFromChild(childnode, "y"));
                            portal.mDestinationMapID = GetIntFromChild(childnode, "tm");
                            portal.mDestinationName = GetStringFromChild(childnode, "tn");
                            portal.mOnce = GetIntFromChild(childnode, "onlyOnce");

                            switch (portal.mName)
                            {
                                case "sp":
                                    portal.mType = PortalType.Startpoint;
                                    break;
                                case "pi":
                                    portal.mType = PortalType.Invisible;
                                    break;
                                case "pv":
                                    portal.mType = PortalType.Visible;
                                    break;
                                case "pc":
                                    portal.mType = PortalType.Collision;
                                    break;
                                case "pg":
                                    portal.mType = PortalType.Changable;
                                    break;
                                case "pgi":
                                    portal.mType = PortalType.ChangableInvisible;
                                    break;
                                case "tp":
                                    portal.mType = PortalType.TownportalPoint;
                                    break;
                                case "ps":
                                    portal.mType = PortalType.Script;
                                    break;
                                case "psi":
                                    portal.mType = PortalType.ScriptInvisible;
                                    break;
                                case "pcs":
                                    portal.mType = PortalType.CollisionScript;
                                    break;
                                case "ph":
                                    portal.mType = PortalType.Hidden;
                                    break;
                                case "psh":
                                    portal.mType = PortalType.ScriptHidden;
                                    break;
                                case "pcj":
                                    portal.mType = PortalType.CollisionVerticalJump;
                                    break;
                                case "pci":
                                    portal.mType = PortalType.CollisionCustomImpact;
                                    break;
                                case "pcig":
                                    portal.mType = PortalType.CollisionUnknownPcig;
                                    break;
                            }
                            field.AddFieldObject(portal);
                        }
                    }
                    NXDataCache.Field.Add(field.FieldID, field);
                    ret++;
                }
            }
            return ret;
        }
Ejemplo n.º 3
0
 public static byte[] NpcEnterField(Npc npc, bool show = true)
 {
     var packet = new PacketWriter();
     packet.WriteOpcode(SendOps.NpcEnterField);
     packet.WriteInt(npc.mObjectID);
     packet.WriteInt(npc.mID);
     packet.WriteShort(npc.mX);
     packet.WriteShort(npc.mCy);
     packet.WriteByte(Math.Abs(npc.mF - 1));
     packet.WriteShort(npc.mFh);
     packet.WriteShort(npc.mRx0);
     packet.WriteShort(npc.mRx1);
     packet.WriteBool(show); // visible
     return packet.ToArray();
 }