예제 #1
0
        public void SendStart()
        {
            SMSG_SENDSTART spkt = new SMSG_SENDSTART();

            spkt.Channel   = 1;
            spkt.MapId     = this.character.map;
            spkt.SessionId = this.character.id;
            spkt.X         = this.character.Position.x;
            spkt.Y         = this.character.Position.y;
            spkt.Z         = this.character.Position.z;
            spkt.Unknown   = (byte)(this.character.map + 0x65);
            this.Send((byte[])spkt);
        }
예제 #2
0
    public static bool Warp(Character target, Point destination, Zone NewZoneInstance)
    {
        if (target.client.isloaded == true)
        {
            if (target.map > 0 && NewZoneInstance.Map > 0)
            {
                if (target.map != NewZoneInstance.Map)
                {
                    #region Not the same Zone

                    if (target.currentzone.Type != ZoneType.Dungeon)
                    {
                        WorldCoordinate worldcoord;
                        worldcoord.coords   = target.Position;
                        worldcoord.map      = target.currentzone.Map;
                        target.lastlocation = worldcoord;
                    }

                    //Start loading
                    target.client.isloaded = false;
                    Zone currentZone = target.currentzone;
                    target.currentzone.OnLeave(target);

                    lock (target)
                    {
                        //Unregister
                        currentZone.Regiontree.Unsubscribe(target);

                        //Set position to the new location
                        target.map = NewZoneInstance.Map;

                        //Set new position
                        target.Position = new Point(
                            destination.x,
                            destination.y,
                            destination.z
                            );
                    }

                    //Update party members
                    if (target.sessionParty != null)
                    {
                        foreach (Character partyTarget in target.sessionParty)
                        {
                            //switch the map
                            SMSG_PARTYMEMBERMAPCHANGE spkt4 = new SMSG_PARTYMEMBERMAPCHANGE();
                            spkt4.Index     = 1;
                            spkt4.ActorId   = target.id;
                            spkt4.Unknown   = (byte)(target.map + 0x065);
                            spkt4.Zone      = target.map;
                            spkt4.SessionId = partyTarget.id;
                            partyTarget.client.Send((byte[])spkt4);
                        }
                    }

                    //Set zone instance
                    target.currentzone = NewZoneInstance;

                    //Send over load packet
                    SMSG_SENDSTART spkt = new SMSG_SENDSTART();
                    spkt.SessionId = target.id;
                    spkt.X         = destination.x;
                    spkt.Y         = destination.y;
                    spkt.Z         = destination.z;
                    spkt.MapId     = NewZoneInstance.Map;
                    spkt.Unknown   = (byte)(target.map + 0x65);
                    spkt.Channel   = 1;
                    target.client.Send((byte[])spkt);
                    return(true);

                    #endregion Not the same Zone
                }
                else
                {
                    #region Notify People That Actor Disapears

                    Point origin = target.Position;

                    Regiontree tree;
                    tree = target.currentzone.Regiontree;
                    foreach (MapObject c in tree.SearchActors(target, SearchFlags.DynamicObjects))
                    {
                        bool insightrangeold = Point.IsInSightRangeByRadius(origin, c.Position);
                        bool insightrangenew = Point.IsInSightRangeByRadius(destination, c.Position);
                        if (c.id == target.id)
                        {
                            continue;
                        }

                        //If vible from old postion but not from new position hide
                        if (insightrangeold && !insightrangenew)
                        {
                            double distance = Point.GetDistance3D(destination, c.Position);
                            //CROSS NOTIFY PLAYERS ACTORS DISAPPPEARS
                            if (MapObject.IsPlayer(c))
                            {
                                Character targetChar = c as Character;
                                targetChar.HideObject(target);
                            }

                            c.HideObject(target);
                            c.Disappear(target);
                        }
                    }

                    #endregion Notify People That Actor Disapears

                    #region Update Region

                    target.Position = new Point(destination.x, destination.y, destination.z);
                    Regiontree.UpdateRegion(target);

                    #endregion Update Region

                    #region Teleport

                    SMSG_ACTORTELEPORT spkt = new SMSG_ACTORTELEPORT();
                    spkt.SessionId = target.id;
                    spkt.x         = destination.x;
                    spkt.y         = destination.y;
                    spkt.Z         = destination.z;
                    target.client.Send((byte[])spkt);

                    #endregion Teleport

                    #region Reset State

                    target.ISONBATTLE = false;
                    target.stance     = (byte)StancePosition.Reborn;
                    target._targetid  = 0;

                    SMSG_ACTORCHANGESTATE spkt4 = new SMSG_ACTORCHANGESTATE();
                    spkt4.SessionId   = target.id;
                    spkt4.Stance      = target.stance;
                    spkt4.TargetActor = target._targetid;
                    spkt4.State       = (target.ISONBATTLE == true) ? (byte)1 : (byte)0;
                    spkt4.ActorID     = target.id;
                    target.client.Send((byte[])spkt4);

                    #endregion Reset State

                    #region Notify People That the Actor Appears

                    tree = target.currentzone.Regiontree;
                    foreach (MapObject myObject in tree.SearchActors(target, SearchFlags.DynamicObjects))
                    {
                        bool insightrangeold = Point.IsInSightRangeByRadius(origin, myObject.Position);
                        bool insightrangenew = Point.IsInSightRangeByRadius(destination, myObject.Position);

                        double distance = Point.GetDistance3D(destination, myObject.Position);

                        //If visible from new postion but not from old postion
                        if (insightrangenew && !insightrangeold)
                        {
                            myObject.ShowObject(target);
                            myObject.Appears(target);

                            if (MapObject.IsPlayer(myObject))
                            {
                                Character current = (Character)myObject;
                                if (current.client.isloaded == false)
                                {
                                    continue;
                                }
                                target.ShowObject(current);
                            }
                        }
                    }

                    #endregion Notify People That the Actor Appears

                    #region Notify Party Members

                    if (target.sessionParty != null)
                    {
                        foreach (Character partyTarget in target.sessionParty)
                        {
                            if (partyTarget.id == target.id)
                            {
                                continue;
                            }
                            SMSG_PARTYMEMBERLOCATION spkt3 = new SMSG_PARTYMEMBERLOCATION();
                            spkt3.Index     = 1;
                            spkt3.ActorId   = target.id;
                            spkt3.SessionId = partyTarget.id;
                            spkt3.X         = (destination.x / 1000);
                            spkt3.Y         = (destination.y / 1000);
                            partyTarget.client.Send((byte[])spkt3);
                        }
                    }

                    #endregion Notify Party Members

                    return(true);
                }
            }
            else
            {
                Trace.TraceError("Warping player {0} to unsupported map {1}", target.Name, 0);
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }