Beispiel #1
0
        /// <summary>
        /// Occurs when you click on a object.
        /// Mapobject, Character doesn't matter.
        /// </summary>
        /// <param name="cpkt"></param>
        private void CM_GETATTRIBUTE(CMSG_ATTRIBUTE cpkt)
        {
            MapObject Target;

            if (Regiontree.TryFind(cpkt.ActorID, this.character, out Target))
            {
                Target.OnClick(this.character);
            }


            //Reset the stance if we're not moving
            if (this.character.stance != 4 && this.character.stance != 5)
            {
                Regiontree tree = this.character.currentzone.Regiontree;
                foreach (Character current in tree.SearchActors(this.character, SearchFlags.Characters))
                {
                    if (current.id == this.character.id || current.client.isloaded == false || !Point.IsInSightRangeByRadius(current.Position, this.character.Position))
                    {
                        continue;
                    }
                    SMSG_ACTORCHANGESTATE spkt2 = new SMSG_ACTORCHANGESTATE();
                    spkt2.ActorID     = character.id;
                    spkt2.State       = (byte)((character.ISONBATTLE) ? 1 : 0);
                    spkt2.Stance      = character.stance;
                    spkt2.TargetActor = character._targetid;
                    spkt2.SessionId   = current.id;
                    current.client.Send((byte[])spkt2);
                }
            }
        }
Beispiel #2
0
        public void ChangeStance(byte stance)
        {
            this.stance = stance;
            SMSG_ACTORCHANGESTATE spkt = new SMSG_ACTORCHANGESTATE();

            spkt.ActorID     = this.id;
            spkt.TargetActor = (this._target != null) ? this._target.id : 0;
            spkt.State       = 1;
            spkt.Stance      = stance;
            ForwardToAll(spkt);
        }
Beispiel #3
0
 public static void UpdateStance(Character target, Actor actor)
 {
     if (actor != null)
     {
         Console.WriteLine("Updating stance: {0} {1}", actor.stance, actor.ModelId);
         SMSG_ACTORCHANGESTATE spkt = new SMSG_ACTORCHANGESTATE();
         spkt.Stance      = actor.stance;
         spkt.State       = 0;
         spkt.SessionId   = target.id;
         spkt.ActorID     = actor.id;
         spkt.TargetActor = actor._targetid;
         target.client.Send((byte[])spkt);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Occurs when releasing the attributes e.d. selection window.
        /// We reset the _targetid to 0 and let everybody see that don't
        /// look at this character anymore.
        /// </summary>
        private void CM_RELEASEATTRIBUTE()
        {
            this.character._targetid = 0;

            //Reset the stance
            foreach (Character current in this.character.currentzone.GetCharactersInSightRange(this.character))
            {
                if (current.id == this.character.id || current.client.isloaded == false)
                {
                    continue;
                }
                SMSG_ACTORCHANGESTATE spkt2 = new SMSG_ACTORCHANGESTATE();
                spkt2.ActorID     = character.id;
                spkt2.State       = (byte)((character.ISONBATTLE) ? 1 : 0);
                spkt2.Stance      = character.stance;
                spkt2.TargetActor = character._targetid;
                spkt2.SessionId   = current.id;
                current.client.Send((byte[])spkt2);
            }
        }
Beispiel #5
0
        public static void UpdateStance(Actor actor)
        {
            if (actor == null)
            {
                return;
            }
            Regiontree tree = actor.currentzone.Regiontree;

            foreach (Character target in tree.SearchActors(actor, SearchFlags.Characters))
            {
                if (Point.IsInSightRangeByRadius(target.Position, actor.Position))
                {
                    SMSG_ACTORCHANGESTATE spkt = new SMSG_ACTORCHANGESTATE();
                    spkt.Stance      = actor.stance;
                    spkt.State       = 0;
                    spkt.SessionId   = target.id;
                    spkt.ActorID     = actor.id;
                    spkt.TargetActor = actor._targetid;
                    target.client.Send((byte[])spkt);
                }
            }
        }
    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);
        }
    }