示例#1
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            uint targetId = packet.data.ReadUInt32();

            client.bodyCollection.TryGetValue(targetId, out NecClient necClient);
            client.bodyCollection.Remove(targetId);
            DeadBody deadBody = server.instances.GetInstance(targetId) as DeadBody;

            RecvCharaBodySelfSalvageEnd recvCharaBodySelfSalvageEnd = new RecvCharaBodySelfSalvageEnd(0);

            router.Send(necClient, recvCharaBodySelfSalvageEnd.ToPacket());


            deadBody.x            = client.character.x;
            deadBody.y            = client.character.y;
            deadBody.z            = client.character.z;
            necClient.character.x = client.character.x;
            necClient.character.y = client.character.y;
            necClient.character.z = client.character.z;

            deadBody.mapId = client.character.mapId;
            client.map.deadBodies.Add(deadBody.instanceId, deadBody);
            RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody);

            if (client.map.id.ToString()[0] != "1"[0]) //Don't Render dead bodies in town.  Town map ids all start with 1
            {
                server.router.Send(client.map, cBodyData.ToPacket());
            }

            //must occur after the charaBody notify.
            RecvCharaBodySalvageEnd recvCharaBodySalvageEnd = new RecvCharaBodySalvageEnd(deadBody.instanceId, 1);

            router.Send(client, recvCharaBodySalvageEnd.ToPacket());

            //send your soul to all the other souls runnin around
            RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(necClient.character, necClient.soul.name);

            foreach (NecClient soulStateClient in client.map.clientLookup.GetAll())
            {
                if (soulStateClient.character.state == CharacterState.SoulForm)
                {
                    server.router.Send(soulStateClient, cData.ToPacket());
                }
            }
        }
示例#2
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            NecClient necClient = server.clients.GetByCharacterInstanceId((uint)client.character.eventSelectExecCode);

            necClient.bodyCollection.Remove(client.character.deadBodyInstanceId);
            DeadBody deadBody = server.instances.GetInstance(client.character.deadBodyInstanceId) as DeadBody;

            RecvCharaBodySelfSalvageEnd recvCharaBodySelfSalvageEnd = new RecvCharaBodySelfSalvageEnd(0);

            router.Send(client, recvCharaBodySelfSalvageEnd.ToPacket());

            deadBody.x         = necClient.character.x;
            deadBody.y         = necClient.character.y;
            deadBody.z         = necClient.character.z;
            client.character.x = necClient.character.x;
            client.character.y = necClient.character.y;
            client.character.z = necClient.character.z;

            deadBody.mapId = necClient.character.mapId;
            client.map.deadBodies.Add(deadBody.instanceId, deadBody);
            RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody);

            if (client.map.id.ToString()[0] != "1"[0]) //Don't Render dead bodies in town.  Town map ids all start with 1
            {
                server.router.Send(client.map, cBodyData.ToPacket());
            }

            RecvCharaBodySalvageEnd recvCharaBodySalvageEnd = new RecvCharaBodySalvageEnd(client.character.deadBodyInstanceId, 0);

            router.Send(necClient, recvCharaBodySalvageEnd.ToPacket());

            //send your soul to all the other souls runnin around
            RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(client.character, client.soul.name);

            foreach (NecClient soulStateClient in client.map.clientLookup.GetAll())
            {
                if (soulStateClient.character.state == CharacterState.SoulForm)
                {
                    server.router.Send(soulStateClient, cData.ToPacket());
                }
            }
        }
        private void PlayerDead()
        {
            playerDied = true;
            List <PacketResponse>       brList  = new List <PacketResponse>();
            RecvBattleReportStartNotify brStart = new RecvBattleReportStartNotify(_client.Character.killerInstanceId);
            RecvBattleReportNoactDead   cDead1  = new RecvBattleReportNoactDead(_client.Character.InstanceId, 1);
            RecvBattleReportNoactDead   cDead2  = new RecvBattleReportNoactDead(_client.Character.InstanceId, 2);
            RecvBattleReportEndNotify   brEnd   = new RecvBattleReportEndNotify();

            brList.Add(brStart);
            brList.Add(cDead1);                                //animate the death of your living body
            brList.Add(brEnd);
            _server.Router.Send(_client.Map, brList, _client); // send death animation to other players


            brList[1] = cDead2;
            _server.Router.Send(_client, brList); // send death animaton to player 1

            DeadBody deadBody = _server.Instances.GetInstance((uint)_client.Character.DeadBodyInstanceId) as DeadBody;

            deadBody.X                   = _client.Character.X;
            deadBody.Y                   = _client.Character.Y;
            deadBody.Z                   = _client.Character.Z;
            deadBody.Heading             = _client.Character.Heading;
            _client.Character.movementId = _client.Character.DeadBodyInstanceId;

            Thread.Sleep(5000);
            _client.Character.hadDied = false; // quick switch to living state so your dead body loads with your gear
            //load your dead body on to the map for you to see in soul form.
            RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody, _client);

            _server.Router.Send(_client, cBodyData.ToPacket());

            _client.Character.hadDied = true; // back to dead so your soul appears with-out gear.

            Thread.Sleep(100);

            //reload your living body with no gear
            RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(_client.Character, _client.Soul.Name);

            _server.Router.Send(_client.Map, cData.ToPacket());
        }
示例#4
0
        private void PlayerDead()
        {
            _playerDied = true;
            _client.character.hasDied  = true;
            _client.character.state    = CharacterState.SoulForm;
            _client.character.deadType = (short)Util.GetRandomNumber(1, 4);
            _Logger.Debug($"Death Animation Number : {_client.character.deadType}");

            List <PacketResponse>       brList  = new List <PacketResponse>();
            RecvBattleReportStartNotify brStart = new RecvBattleReportStartNotify(_client.character.instanceId);
            RecvBattleReportNoactDead   cDead1  = new RecvBattleReportNoactDead(_client.character.instanceId, _client.character.deadType);
            RecvBattleReportEndNotify   brEnd   = new RecvBattleReportEndNotify();

            brList.Add(brStart);
            brList.Add(cDead1);                       //animate the death of your living body
            brList.Add(brEnd);
            _server.router.Send(_client.map, brList); // send death animation to all players

            DeadBody deadBody = _server.instances.GetInstance(_client.character.deadBodyInstanceId) as DeadBody;

            deadBody.x                  = _client.character.x;
            deadBody.y                  = _client.character.y;
            deadBody.z                  = _client.character.z;
            deadBody.heading            = _client.character.heading;
            deadBody.beginnerProtection = (byte)_client.character.beginnerProtection;
            deadBody.charaName          = _client.character.name;
            deadBody.soulName           = _client.soul.name;
            deadBody.equippedItems      = _client.character.equippedItems;
            deadBody.raceId             = _client.character.raceId;
            deadBody.sexId              = _client.character.sexId;
            deadBody.hairId             = _client.character.hairId;
            deadBody.hairColorId        = _client.character.hairColorId;
            deadBody.faceId             = _client.character.faceId;
            deadBody.faceArrangeId      = _client.character.faceArrangeId;
            deadBody.voiceId            = _client.character.voiceId;
            deadBody.level              = _client.character.level;
            deadBody.classId            = _client.character.classId;
            deadBody.equippedItems      = _client.character.equippedItems;
            deadBody.criminalStatus     = _client.character.criminalState;
            deadBody.connectionState    = 1;
            _clients = _client.map.clientLookup.GetAll();
            _client.map.deadBodies.Add(deadBody.instanceId, deadBody);
            List <NecClient> soulStateClients = new List <NecClient>();

            //Disappear .. all the monsters, NPCs, and characters.  welcome to death! it's lonely
            foreach (NpcSpawn npcSpawn in _client.map.npcSpawns.Values)
            {
                RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(npcSpawn.instanceId);
                _server.router.Send(_client, recvObjectDisappearNotify.ToPacket());
            }

            foreach (MonsterSpawn monsterSpawn in _client.map.monsterSpawns.Values)
            {
                RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(monsterSpawn.instanceId);
                _server.router.Send(_client, recvObjectDisappearNotify.ToPacket());
            }

            foreach (NecClient client in _clients)
            {
                if (client == _client)
                {
                    continue;                    //Don't dissapear yourself ! that'd be bad news bears.
                }
                RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(client.character.instanceId);
                _server.router.Send(_client, recvObjectDisappearNotify.ToPacket());
            }

            //load your dead body on the map for looting.  disappear your character model for everyone else besides you
            Task.Delay(TimeSpan.FromSeconds(5)).ContinueWith
                (t1 =>
            {
                RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody);
                if (_client.map.id.ToString()[0] != "1"[0])     //Don't Render dead bodies in town.  Town map ids all start with 1
                {
                    _server.router.Send(_client.map, cBodyData.ToPacket(), _client);
                }
                _server.router.Send(_client, cBodyData.ToPacket());
                RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(_client.character.instanceId);
                _server.router.Send(_client.map, recvObjectDisappearNotify.ToPacket(), _client);
                //send your soul to all the other souls runnin around
                foreach (NecClient client in _clients)
                {
                    if (client.character.state == CharacterState.SoulForm)
                    {
                        soulStateClients.Add(client);
                    }
                }
                //re-render your soulstate character to your client with out gear on it, and any other soul state clients on map.
                RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(_client.character, _client.soul.name);
                _server.router.Send(soulStateClients, cData.ToPacket());
            }
                );
            //Re-render all the NPCs and Monsters, and character objects
            Task.Delay(TimeSpan.FromSeconds(6)).ContinueWith
                (t1 =>
            {
                foreach (NecClient otherClient in _clients)
                {
                    if (otherClient == _client)
                    {
                        // skip myself
                        continue;
                    }
                    //Render all the souls if you are in soul form yourself
                    if (otherClient.character.state == CharacterState.SoulForm)
                    {
                        RecvDataNotifyCharaData otherCharacterData = new RecvDataNotifyCharaData(otherClient.character, otherClient.soul.name);
                        _server.router.Send(otherCharacterData, _client);
                    }

                    if (otherClient.union != null)
                    {
                        RecvDataNotifyUnionData otherUnionData = new RecvDataNotifyUnionData(otherClient.character, otherClient.union.name);
                        _server.router.Send(otherUnionData, _client);
                    }
                }

                foreach (NpcSpawn npcSpawn in _client.map.npcSpawns.Values)
                {
                    if (npcSpawn.visibility == 2)     //2 is the magic number for soul state only.  make it an Enum some day
                    {
                        RecvDataNotifyNpcData npcData = new RecvDataNotifyNpcData(npcSpawn);
                        _server.router.Send(npcData, _client);
                    }
                }
            }
                );
        }
示例#5
0
        private void AreaClientDisconnected(NecConnection connection)
        {
            NecClient client = connection.client;

            if (client == null)
            {
                return;
            }
            //Try to update the character stats.
            if (!database.UpdateCharacter(client.character))
            {
                _Logger.Error("Could not update the database with character details before disconnect");
            }
            if (!database.UpdateSoul(client.soul))
            {
                _Logger.Error("Could not update the database with soul details before disconnect");
            }
            clients.Remove(client);

            //I disconnected while my dead body was being carried around by another player
            if (client.character.hasDied)
            {
                DeadBody deadBody = instances.GetInstance(client.character.deadBodyInstanceId) as DeadBody;
                if (deadBody.salvagerId != 0)
                {
                    NecClient mySalvager = clients.GetByCharacterInstanceId(deadBody.salvagerId);
                    if (mySalvager != null)
                    {
                        deadBody.x               = mySalvager.character.x;
                        deadBody.y               = mySalvager.character.y;
                        deadBody.z               = mySalvager.character.z;
                        deadBody.mapId           = mySalvager.character.mapId;
                        deadBody.connectionState = 0;
                        mySalvager.bodyCollection.Remove(deadBody.instanceId);

                        mySalvager.map.deadBodies.Add(deadBody.instanceId, deadBody);
                        RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody);
                        if (client.map.id.ToString()[0] != "1"[0]) //Don't Render dead bodies in town.  Town map ids all start with 1
                        {
                            router.Send(mySalvager.map, cBodyData.ToPacket(), client);
                        }

                        //must occur after the charaBody notify.
                        RecvCharaBodySalvageEnd recvCharaBodySalvageEnd = new RecvCharaBodySalvageEnd(deadBody.instanceId, 5);
                        router.Send(mySalvager, recvCharaBodySalvageEnd.ToPacket());
                    }
                }
            }

            //while i was dead and being carried around, the player carrying me disconnected
            foreach (NecClient collectedBody in client.bodyCollection.Values)
            {
                DeadBody deadBody = instances.GetInstance(collectedBody.character.deadBodyInstanceId) as DeadBody;

                RecvCharaBodySelfSalvageEnd recvCharaBodySelfSalvageEnd = new RecvCharaBodySelfSalvageEnd(3);
                router.Send(collectedBody, recvCharaBodySelfSalvageEnd.ToPacket());


                deadBody.x = client.character.x;
                deadBody.y = client.character.y;
                deadBody.z = client.character.z;
                collectedBody.character.x = client.character.x;
                collectedBody.character.y = client.character.y;
                collectedBody.character.z = client.character.z;
                //ToDo  add Town checking.  if map.ID.toString()[0]==1 skip deadbody rendering
                deadBody.mapId = client.character.mapId;

                client.map.deadBodies.Add(deadBody.instanceId, deadBody);
                RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody);
                if (client.map.id.ToString()[0] != "1"[0]) //Don't Render dead bodies in town.  Town map ids all start with 1
                {
                    router.Send(client.map, cBodyData.ToPacket());
                }

                //send your soul to all the other souls runnin around
                RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(collectedBody.character, collectedBody.soul.name);
                foreach (NecClient soulStateClient in client.map.clientLookup.GetAll())
                {
                    if (soulStateClient.character.state == CharacterState.SoulForm)
                    {
                        router.Send(soulStateClient, cData.ToPacket());
                    }
                }
            }

            Map map = client.map;

            //If i was dead, toggle my deadBody to a Rucksack
            if (map != null)
            {
                if (map.deadBodies.ContainsKey(client.character.deadBodyInstanceId))
                {
                    map.deadBodies.TryGetValue(client.character.deadBodyInstanceId, out DeadBody deadBody);
                    deadBody.connectionState = 0;
                    RecvCharaBodyNotifySpirit recvCharaBodyNotifySpirit = new RecvCharaBodyNotifySpirit(client.character.deadBodyInstanceId, (byte)RecvCharaBodyNotifySpirit.ValidSpirit.DisconnectedClient);
                    router.Send(map, recvCharaBodyNotifySpirit.ToPacket());

                    Task.Delay(TimeSpan.FromSeconds(600)).ContinueWith
                        (t1 =>
                    {
                        if (map.deadBodies.ContainsKey(client.character.deadBodyInstanceId))
                        {
                            RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(client.character.deadBodyInstanceId);
                            router.Send(client.map, recvObjectDisappearNotify.ToPacket(), client);
                            map.deadBodies.Remove(client.character.deadBodyInstanceId);
                        }
                    }
                        );
                }
            }

            if (map != null)
            {
                map.Leave(client);
            }

            Union union = client.union;

            if (union != null)
            {
                union.Leave(client);
            }

            Character character = client.character;

            if (character != null)
            {
                instances.FreeInstance(character);
                character.characterActive = false;
            }
        }
示例#6
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            //you are dead here.  only getting soul form characters and NPCs.  sorry bro.
            if (client.character.state.HasFlag(CharacterState.SoulForm))
            {
                _Logger.Debug("Rendering Dead stuff");
                foreach (NecClient otherClient in client.map.clientLookup.GetAll())
                {
                    if (otherClient == client)
                    {
                        // skip myself
                        continue;
                    }
                    //Render all the souls if you are in soul form yourself
                    if (otherClient.character.state.HasFlag(CharacterState.SoulForm))
                    {
                        RecvDataNotifyCharaData otherCharacterData = new RecvDataNotifyCharaData(otherClient.character, otherClient.soul.name);
                        router.Send(otherCharacterData, client);
                    }

                    if (otherClient.union != null)
                    {
                        RecvDataNotifyUnionData otherUnionData = new RecvDataNotifyUnionData(otherClient.character, otherClient.union.name);
                        router.Send(otherUnionData, client);
                    }
                }

                foreach (NpcSpawn npcSpawn in client.map.npcSpawns.Values)
                {
                    if (npcSpawn.visibility == 2 | npcSpawn.visibility == 3) //2 is the magic number for soul state only.  make it an Enum some day
                    {
                        RecvDataNotifyNpcData npcData = new RecvDataNotifyNpcData(npcSpawn);
                        router.Send(npcData, client);
                    }
                }
            }
            else //if you are not dead, do normal stuff.  else...  do dead person stuff
            {
                _Logger.Debug($"Not dead.  rendering living stuff.  CharacterState:{client.character.state}");
                foreach (NecClient otherClient in client.map.clientLookup.GetAll())
                {
                    if (otherClient == client)
                    {
                        continue;
                    }
                    if (!otherClient.character.state.HasFlag(CharacterState.SoulForm))
                    {
                        RecvDataNotifyCharaData otherCharacterData = new RecvDataNotifyCharaData(otherClient.character, otherClient.soul.name);
                        router.Send(otherCharacterData, client);
                    }

                    if (otherClient.union != null)
                    {
                        RecvDataNotifyUnionData otherUnionData = new RecvDataNotifyUnionData(otherClient.character, otherClient.union.name);
                        router.Send(otherUnionData, client);
                    }
                }

                foreach (MonsterSpawn monsterSpawn in client.map.monsterSpawns.Values)
                {
                    RecvDataNotifyMonsterData monsterData = new RecvDataNotifyMonsterData(monsterSpawn);
                    _Logger.Debug($"Monster Id {monsterSpawn.id} with model {monsterSpawn.modelId} is loading");
                    router.Send(monsterData, client);
                }

                foreach (NpcSpawn npcSpawn in client.map.npcSpawns.Values)
                {
                    if (npcSpawn.visibility == 1 | npcSpawn.visibility == 3) //2 is the magic number for soul state only.  make it an Enum some day
                    {
                        RecvDataNotifyNpcData npcData = new RecvDataNotifyNpcData(npcSpawn);
                        router.Send(npcData, client);
                    }
                }
            }

            //Allways render the stuff below this line.
            if (client.map.id.ToString()[0] != "1"[0]) //Don't Render dead bodies in town.  Town map ids all start with 1
            {
                foreach (DeadBody deadBody in client.map.deadBodies.Values)
                {
                    RecvDataNotifyCharaBodyData deadBodyData = new RecvDataNotifyCharaBodyData(deadBody);
                    router.Send(deadBodyData, client);
                }
            }

            foreach (Gimmick gimmickSpawn in client.map.gimmickSpawns.Values)
            {
                RecvDataNotifyGimmickData gimmickData = new RecvDataNotifyGimmickData(gimmickSpawn);
                router.Send(gimmickData, client);
            }

            foreach (GGateSpawn gGateSpawn in client.map.gGateSpawns.Values)
            {
                RecvDataNotifyGGateStoneData gGateSpawnData = new RecvDataNotifyGGateStoneData(gGateSpawn);
                router.Send(gGateSpawnData, client);
            }

            foreach (MapTransition mapTran in client.map.mapTransitions.Values)
            {
                RecvDataNotifyMapLink mapLink = new RecvDataNotifyMapLink(mapTran.instanceId, mapTran.referencePos, mapTran.maplinkOffset, mapTran.maplinkWidth, mapTran.maplinkColor, mapTran.maplinkHeading);
                router.Send(mapLink, client);

                //un-comment for debugging maplinks to visualize the left and right Reference Positions

                /*
                 * GGateSpawn gGateSpawn = new GGateSpawn();
                 * Server.Instances.AssignInstance(gGateSpawn);
                 * gGateSpawn.X = mapTran.LeftPos.X;
                 * gGateSpawn.Y = mapTran.LeftPos.Y;
                 * gGateSpawn.Z = mapTran.LeftPos.Z;
                 * gGateSpawn.Heading = mapTran.MaplinkHeading;
                 * gGateSpawn.Name = $"This is the Left Side of the transition";
                 * gGateSpawn.Title = $"X: {mapTran.LeftPos.X}  Y:{mapTran.LeftPos.Y} ";
                 * gGateSpawn.MapId = mapTran.MapId;
                 * gGateSpawn.ModelId = 1805000;
                 * gGateSpawn.Active = 0;
                 * gGateSpawn.SerialId = 1900001;
                 *
                 * RecvDataNotifyGGateData gGateData = new RecvDataNotifyGGateData(gGateSpawn);
                 * Router.Send(gGateData, client);
                 *
                 * gGateSpawn = new GGateSpawn();
                 * Server.Instances.AssignInstance(gGateSpawn);
                 * gGateSpawn.X = mapTran.RightPos.X;
                 * gGateSpawn.Y = mapTran.RightPos.Y;
                 * gGateSpawn.Z = mapTran.RightPos.Z;
                 * gGateSpawn.Heading = mapTran.MaplinkHeading;
                 * gGateSpawn.Name = $"This is the Right Side of the transition";
                 * gGateSpawn.Title = $"X: {mapTran.RightPos.X}  Y:{mapTran.RightPos.Y} ";
                 * gGateSpawn.MapId = mapTran.MapId;
                 * gGateSpawn.ModelId = 1805000;
                 * gGateSpawn.Active = 0;
                 * gGateSpawn.SerialId = 1900002;
                 *
                 * gGateData = new RecvDataNotifyGGateData(gGateSpawn);
                 * Router.Send(gGateData, client);
                 */
            }

            // ToDo this should be a database lookup
            RecvMapFragmentFlag mapFragments = new RecvMapFragmentFlag(client.map.id, 0xff);

            router.Send(mapFragments, client);


            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);
            router.Send(client, (ushort)AreaPacketId.recv_map_get_info_r, res, ServerType.Area);
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            _necClients = client.map.clientLookup.GetAll();
            //if (client.Character.soulFormState == 1)
            {
                client.character.state       = CharacterState.InvulnerableForm;
                client.character.hasDied     = false;
                client.character.hp.depleted = false;
                client.character.deadType    = 0;
                client.character.hp.ToMax();


                IBuffer res1 = BufferProvider.Provide();
                res1.WriteInt32(0); //Has to be 0 or else you DC
                res1.WriteUInt32(client.character.deadBodyInstanceId);
                res1.WriteUInt32(client.character.instanceId);
                router.Send(client, (ushort)AreaPacketId.recv_revive_init_r, res1, ServerType.Area);

                IBuffer res3 = BufferProvider.Provide();
                res3.WriteUInt32(client.character.deadBodyInstanceId);
                router.Send(client.map, (ushort)AreaPacketId.recv_object_disappear_notify, res3, ServerType.Area);

                res3 = BufferProvider.Provide();
                res3.WriteUInt32(client.character.instanceId);
                router.Send(client.map, (ushort)AreaPacketId.recv_object_disappear_notify, res3, ServerType.Area, client);


                RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(client.character, client.soul.name);
                router.Send(client.map, cData.ToPacket());


                //Disappear .. all the monsters, NPCs, and characters.  welcome to Life! it's less lonely
                foreach (NpcSpawn npcSpawn in client.map.npcSpawns.Values)
                {
                    RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(npcSpawn.instanceId);
                    router.Send(client, recvObjectDisappearNotify.ToPacket());
                }

                foreach (MonsterSpawn monsterSpawn in client.map.monsterSpawns.Values)
                {
                    RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(monsterSpawn.instanceId);
                    router.Send(client, recvObjectDisappearNotify.ToPacket());
                }

                foreach (NecClient client2 in _necClients)
                {
                    if (client2 == client)
                    {
                        continue;                    //Don't dissapear yourself ! that'd be bad news bears.
                    }
                    RecvObjectDisappearNotify recvObjectDisappearNotify = new RecvObjectDisappearNotify(client2.character.instanceId);
                    router.Send(client, recvObjectDisappearNotify.ToPacket());
                }

                List <PacketResponse>       brList  = new List <PacketResponse>();
                RecvBattleReportStartNotify brStart = new RecvBattleReportStartNotify(client.character.instanceId);
                RecvBattleReportNotifyRaise recvBattleReportNotifyRaise = new RecvBattleReportNotifyRaise(client.character.instanceId);
                RecvBattleReportEndNotify   brEnd = new RecvBattleReportEndNotify();

                brList.Add(brStart);
                brList.Add(recvBattleReportNotifyRaise);
                brList.Add(brEnd);
                router.Send(client.map, brList);
                RecvCharaUpdateMaxHp recvCharaUpdateMaxHp1 = new RecvCharaUpdateMaxHp(client.character.hp.max);
                router.Send(client, recvCharaUpdateMaxHp1.ToPacket());


                Task.Delay(TimeSpan.FromSeconds(3)).ContinueWith
                    (t1 =>
                {
                    RecvCharaUpdateHp cHpUpdate = new RecvCharaUpdateHp(client.character.hp.max);
                    router.Send(client, cHpUpdate.ToPacket());

                    //if you are not dead, do normal stuff.  else...  do dead person stuff
                    if (client.character.state != CharacterState.SoulForm)
                    {
                        foreach (NecClient otherClient in _necClients)
                        {
                            if (otherClient == client)
                            {
                                // skip myself
                                continue;
                            }
                            if (otherClient.character.state != CharacterState.SoulForm)
                            {
                                RecvDataNotifyCharaData otherCharacterData = new RecvDataNotifyCharaData(otherClient.character, otherClient.soul.name);
                                router.Send(otherCharacterData, client);
                            }

                            if (otherClient.union != null)
                            {
                                RecvDataNotifyUnionData otherUnionData = new RecvDataNotifyUnionData(otherClient.character, otherClient.union.name);
                                router.Send(otherUnionData, client);
                            }
                        }

                        foreach (MonsterSpawn monsterSpawn in client.map.monsterSpawns.Values)
                        {
                            RecvDataNotifyMonsterData monsterData = new RecvDataNotifyMonsterData(monsterSpawn);
                            router.Send(monsterData, client);
                        }

                        foreach (NpcSpawn npcSpawn in client.map.npcSpawns.Values)
                        {
                            if (npcSpawn.visibility != 2)     //2 is the magic number for soul state only.  make it an Enum some day
                            {
                                RecvDataNotifyNpcData npcData = new RecvDataNotifyNpcData(npcSpawn);
                                router.Send(npcData, client);
                            }
                        }

                        foreach (DeadBody deadBody in client.map.deadBodies.Values)
                        {
                            if (client.map.id.ToString()[0] != "1"[0])     //Don't Render dead bodies in town.  Town map ids all start with 1
                            {
                                RecvDataNotifyCharaBodyData deadBodyData = new RecvDataNotifyCharaBodyData(deadBody);
                                router.Send(deadBodyData, client);
                            }
                        }
                    }
                }
                    );
                Task.Delay(TimeSpan.FromSeconds(10)).ContinueWith
                    (t1 =>
                {
                    client.character.ClearStateBit(CharacterState.InvulnerableForm);
                    RecvCharaNotifyStateflag recvCharaNotifyStateflag = new RecvCharaNotifyStateflag(client.character.instanceId, (ulong)client.character.state);
                    router.Send(client.map, recvCharaNotifyStateflag.ToPacket());
                }
                    );
            }

            /*else if (client.Character.soulFormState == 0)
             * {
             *  IBuffer res1 = BufferProvider.Provide();
             *  res1.WriteInt32(client.Character.InstanceId); // ID
             *  res1.WriteInt32(100101); //100101, its the id to get the tombstone
             *  Router.Send(client, (ushort) AreaPacketId.recv_chara_notify_stateflag, res1, ServerType.Area);
             *
             *  IBuffer res = BufferProvider.Provide();
             *  res.WriteInt32(1); // 0 = sucess to revive, 1 = failed to revive
             *  Router.Send(client, (ushort) AreaPacketId.recv_raisescale_request_revive_r, res, ServerType.Area);
             *
             *  IBuffer res5 = BufferProvider.Provide();
             *  Router.Send(client, (ushort) AreaPacketId.recv_self_lost_notify, res5, ServerType.Area);
             * }*/

            if (client.map.deadBodies.ContainsKey(client.character.deadBodyInstanceId))
            {
                client.map.deadBodies.Remove(client.character.deadBodyInstanceId);
            }

            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);                                                                                // 0 = sucess to revive, 1 = failed to revive
            router.Send(client, (ushort)AreaPacketId.recv_raisescale_request_revive_r, res, ServerType.Area); //responsible for camera movement

            IBuffer res7 = BufferProvider.Provide();

            res7.WriteByte(0);
            //router.Send(client, (ushort)AreaPacketId.recv_event_end, res7, ServerType.Area); //why is this needed? the script play ends the event
        }
示例#8
0
        public override void Execute(string[] command, NecClient client, ChatMessage message,
                                     List <ChatResponse> responses)
        {
            if (client.Character.hadDied == true)
            {
                IBuffer res4 = BufferProvider.Provide();
                Router.Send(client.Map, (ushort)AreaPacketId.recv_self_lost_notify, res4, ServerType.Area);
            }

            if (client.Character.hadDied == false)
            {
                client.Character.hadDied =
                    true; // setting before the Sleep so other monsters can't "kill you" while you're dieing
                client.Character.Hp.Modify(-client.Character.Hp.current);
                client.Character.state = 0b00000001;
                List <PacketResponse>       brList  = new List <PacketResponse>();
                RecvBattleReportStartNotify brStart = new RecvBattleReportStartNotify(client.Character.InstanceId);
                RecvBattleReportNoactDead   cDead1  = new RecvBattleReportNoactDead(client.Character.InstanceId, 1);
                RecvBattleReportNoactDead   cDead2  = new RecvBattleReportNoactDead(client.Character.InstanceId, 2);
                RecvBattleReportEndNotify   brEnd   = new RecvBattleReportEndNotify();

                brList.Add(brStart);
                brList.Add(cDead1);                             //animate the death of your living body
                brList.Add(brEnd);
                Server.Router.Send(client.Map, brList, client); // send death animation to other players


                brList[1] = cDead2;
                Router.Send(client, brList); // send death animaton to player 1

                DeadBody deadBody =
                    Server.Instances.GetInstance((uint)client.Character.DeadBodyInstanceId) as DeadBody;

                deadBody.X                  = client.Character.X;
                deadBody.Y                  = client.Character.Y;
                deadBody.Z                  = client.Character.Z;
                deadBody.Heading            = client.Character.Heading;
                client.Character.movementId = client.Character.DeadBodyInstanceId;

                Task.Delay(TimeSpan.FromMilliseconds((int)(5 * 1000))).ContinueWith
                    (t1 =>
                {
                    client.Character.hadDied =
                        false;     // quick switch to living state so your dead body loads with your gear
                    //load your dead body on to the map for you to see in soul form.
                    RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody, client);
                    Server.Router.Send(client, cBodyData.ToPacket());

                    client.Character.hadDied = true;     // back to dead so your soul appears with-out gear.
                }
                    );

                Task.Delay(TimeSpan.FromMilliseconds((int)(15 * 1000))).ContinueWith
                    (t1 =>
                {
                    //reload your living body with no gear
                    RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(client.Character, client.Soul.Name);
                    Server.Router.Send(client, cData.ToPacket());
                }
                    );
            }
        }
示例#9
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            foreach (NecClient otherClient in client.Map.ClientLookup.GetAll())
            {
                if (otherClient == client)
                {
                    // skip myself
                    continue;
                }

                RecvDataNotifyCharaData otherCharacterData =
                    new RecvDataNotifyCharaData(otherClient.Character, otherClient.Soul.Name);
                Router.Send(otherCharacterData, client);

                if (otherClient.Union != null)
                {
                    RecvDataNotifyUnionData otherUnionData =
                        new RecvDataNotifyUnionData(otherClient.Character, otherClient.Union.Name);
                    Router.Send(otherUnionData, client);
                }
            }

            foreach (MonsterSpawn monsterSpawn in client.Map.MonsterSpawns.Values)
            {
                if (monsterSpawn.Active == false)
                {
                    RecvDataNotifyMonsterData monsterData = new RecvDataNotifyMonsterData(monsterSpawn);
                    Logger.Debug($"Monster Id {monsterSpawn.Id} with model {monsterSpawn.ModelId} is loading");
                    Router.Send(monsterData, client);
                }
            }

            foreach (NpcSpawn npcSpawn in client.Map.NpcSpawns.Values)
            {
                // This requires database changes to add the GGates to the Npc database!!!!!
                if (npcSpawn.Name == "GGate")
                {
                    GGateSpawn gGate = new GGateSpawn();
                    gGate.X       = npcSpawn.X;
                    gGate.Y       = npcSpawn.Y;
                    gGate.Z       = npcSpawn.Z;
                    gGate.Heading = npcSpawn.Heading;
                    gGate.MapId   = npcSpawn.MapId;
                    gGate.Name    = npcSpawn.Name;
                    gGate.Title   = npcSpawn.Title;

                    RecvDataNotifyGGateData gGateData = new RecvDataNotifyGGateData(gGate);
                    Router.Send(gGateData, client);
                }
                else
                {
                    RecvDataNotifyNpcData npcData = new RecvDataNotifyNpcData(npcSpawn);
                    Router.Send(npcData, client);
                }
            }

            foreach (Gimmick gimmickSpawn in client.Map.GimmickSpawns.Values)
            {
                RecvDataNotifyGimmickData gimmickData = new RecvDataNotifyGimmickData(gimmickSpawn);
                Router.Send(gimmickData, client);
                GGateSpawn gGateSpawn = new GGateSpawn();
                Server.Instances.AssignInstance(gGateSpawn);
                gGateSpawn.X        = gimmickSpawn.X;
                gGateSpawn.Y        = gimmickSpawn.Y;
                gGateSpawn.Z        = gimmickSpawn.Z + 300;
                gGateSpawn.Heading  = gimmickSpawn.Heading;
                gGateSpawn.Name     = $"gGateSpawn to your current position. ID {gimmickSpawn.ModelId}";
                gGateSpawn.Title    = $"type '/gimmick move {gimmickSpawn.InstanceId} to move this ";
                gGateSpawn.MapId    = gimmickSpawn.MapId;
                gGateSpawn.ModelId  = 1900001;
                gGateSpawn.Active   = 0;
                gGateSpawn.SerialId = 1900001;

                RecvDataNotifyGGateData gGateData = new RecvDataNotifyGGateData(gGateSpawn);
                Router.Send(gGateData, client);
            }

            foreach (GGateSpawn gGateSpawn in client.Map.GGateSpawns.Values)
            {
                RecvDataNotifyGGateData gGateSpawnData = new RecvDataNotifyGGateData(gGateSpawn);
                Router.Send(gGateSpawnData, client);
            }

            foreach (DeadBody deadBody in client.Map.DeadBodies.Values)
            {
                RecvDataNotifyCharaBodyData deadBodyData = new RecvDataNotifyCharaBodyData(deadBody, client);
                Router.Send(deadBodyData, client);
            }

            foreach (MapTransition mapTran in client.Map.MapTransitions.Values)
            {
                MapPosition mapPos = new MapPosition(mapTran.ReferencePos.X, mapTran.ReferencePos.Y,
                                                     mapTran.ReferencePos.Z, mapTran.MaplinkHeading);
                RecvDataNotifyMapLink mapLink = new RecvDataNotifyMapLink(client, this.Id, mapPos,
                                                                          mapTran.MaplinkOffset, mapTran.MaplinkWidth, mapTran.MaplinkColor);
                Router.Send(mapLink, client);
            }

            // ToDo this should be a database lookup
            RecvMapFragmentFlag mapFragments = new RecvMapFragmentFlag(client.Map.Id, 0xff);

            Router.Send(mapFragments, client);


            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(client.Map.Id);
            Router.Send(client, (ushort)AreaPacketId.recv_map_get_info_r, res, ServerType.Area);
        }
示例#10
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); //error check. must be 0
            res.WriteByte(0);  //Bool - play cutscene. 1 yes, 0 no?  //to-do,  play a cutscene on first time map entry
            router.Send(client, (ushort)AreaPacketId.recv_map_enter_r, res, ServerType.Area);

            if (client.map.deadBodies.ContainsKey(client.character.deadBodyInstanceId))
            {
                _Logger.Debug($"found dead body of {client.character.name} already on map.  Hope you didn't lose your loot!");
                DeadBody deadBody = server.instances.GetInstance(client.character.deadBodyInstanceId) as DeadBody;
                deadBody.connectionState = 1;

                RecvCharaBodyNotifySpirit recvCharaBodyNotifySpirit = new RecvCharaBodyNotifySpirit(client.character.deadBodyInstanceId, (byte)RecvCharaBodyNotifySpirit.ValidSpirit.ConnectedClient);
                router.Send(client.map, recvCharaBodyNotifySpirit.ToPacket());
            }
            else if (client.character.state.HasFlag(CharacterState.SoulForm))
            {
                DeadBody deadBody = server.instances.GetInstance(client.character.deadBodyInstanceId) as DeadBody;
                deadBody.x                  = client.character.x;
                deadBody.y                  = client.character.y;
                deadBody.z                  = client.character.z;
                deadBody.heading            = client.character.heading;
                deadBody.beginnerProtection = (byte)client.character.beginnerProtection;
                deadBody.charaName          = client.character.name;
                deadBody.soulName           = client.soul.name;
                deadBody.equippedItems      = client.character.equippedItems;
                deadBody.raceId             = client.character.raceId;
                deadBody.sexId              = client.character.sexId;
                deadBody.hairId             = client.character.hairId;
                deadBody.hairColorId        = client.character.hairColorId;
                deadBody.faceId             = client.character.faceId;
                deadBody.faceArrangeId      = client.character.faceArrangeId;
                deadBody.voiceId            = client.character.voiceId;
                deadBody.level              = client.character.level;
                deadBody.classId            = client.character.classId;
                deadBody.equippedItems      = client.character.equippedItems;
                deadBody.connectionState    = 1;
                client.map.deadBodies.Add(deadBody.instanceId, deadBody);
                RecvDataNotifyCharaBodyData cBodyData = new RecvDataNotifyCharaBodyData(deadBody);
                if (client.map.id.ToString()[0] != "1"[0]) //Don't Render dead bodies in town.  Town map ids all start with 1
                {
                    router.Send(client.map, cBodyData.ToPacket(), client);
                }
                router.Send(client, cBodyData.ToPacket());
            }

            //Re-do all your stats
            ItemService itemService = new ItemService(client.character);

            router.Send(client, itemService.CalculateBattleStats(client));


            //added delay to prevent crash on map entry.
            Task.Delay(TimeSpan.FromSeconds(10)).ContinueWith
                (t1 =>
            {
                client.character.ClearStateBit(CharacterState.InvulnerableForm);

                RecvCharaNotifyStateflag recvCharaNotifyStateflag = new RecvCharaNotifyStateflag(client.character.instanceId, (ulong)client.character.state);
                router.Send(client.map, recvCharaNotifyStateflag.ToPacket());
            }
                );
        }