コード例 #1
0
        public bool MonsterCheck()
        {
            // Logger.Debug($"Monster HP [{_monster.GetHP()}]");
            if (_monster.Hp.current <= 0)
            {
                foreach (uint instanceId in _monster.GetAgroInstanceList())
                {
                    _monster.MonsterHate(_server, false, instanceId);
                }

                Logger.Debug($"Monster is dead InstanceId [{_monster.InstanceId}]");
                //Death Animation
                List <PacketResponse>       brList  = new List <PacketResponse>();
                RecvBattleReportStartNotify brStart = new RecvBattleReportStartNotify(_monster.InstanceId);
                RecvBattleReportEndNotify   brEnd   = new RecvBattleReportEndNotify();
                RecvBattleReportNoactDead   brDead  = new RecvBattleReportNoactDead(_monster.InstanceId, 1);
                brList.Add(brStart);
                brList.Add(brDead);
                brList.Add(brEnd);
                _server.Router.Send(Map, brList);

                //Make the monster a lootable state
                IBuffer res10 = BufferProvider.Provide();
                res10.WriteUInt32(_monster.InstanceId);
                res10.WriteInt32(2); //Toggles state between Alive(attackable),  Dead(lootable), or Inactive(nothing).
                _server.Router.Send(Map, (ushort)AreaPacketId.recv_monster_state_update_notify, res10,
                                    ServerType.Area);

                Thread.Sleep(_monster.RespawnTime);
                //decompose the body
                IBuffer res7 = BufferProvider.Provide();
                res7.WriteUInt32(_monster.InstanceId);
                res7.WriteInt32(
                    5); //4 here causes a cloud and the model to disappear, 5 causes a mist to happen and disappear
                res7.WriteInt32(1);
                _server.Router.Send(Map, (ushort)AreaPacketId.recv_charabody_notify_deadstate, res7, ServerType.Area);
                Thread.Sleep(2000);
                RecvObjectDisappearNotify objectDisappearData = new RecvObjectDisappearNotify(_monster.InstanceId);
                _server.Router.Send(Map, objectDisappearData);
                _monster.MonsterVisible = false;

                spawnMonster = true;
                return(true);
            }

            return(false);
        }
コード例 #2
0
        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());
        }
コード例 #3
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);
                    }
                }
            }
                );
        }
コード例 #4
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());
                }
                    );
            }
        }
コード例 #5
0
        public bool MonsterCheck()
        {
            // Logger.Debug($"Monster HP [{_monster.GetHP()}]");
            if (monster.hp.current <= 0)
            {
                foreach (uint instanceId in monster.GetAgroInstanceList())
                {
                    monster.MonsterHate(server, false, instanceId);

                    NecClient client = server.clients.GetByCharacterInstanceId(instanceId);
                    client.character.experienceCurrent += monster.loot.experience;

                    IBuffer res = BufferProvider.Provide();
                    res.WriteUInt64(client.character.experienceCurrent);
                    res.WriteByte(0);                                                                            //bool
                    server.router.Send(client, (ushort)AreaPacketId.recv_self_exp_notify, res, ServerType.Area); //This should go to the party of whomever did the most damage.  TODO

                    //To-Do,  make a variable to track union gold
                    client.character.adventureBagGold += monster.loot.gold; //Updates your Character.AdventureBagGold
                    server.database.UpdateCharacter(client.character);

                    res = BufferProvider.Provide();
                    res.WriteUInt64(client.character.adventureBagGold); // Sets your Adventure Bag Gold
                    server.router.Send(client, (ushort)AreaPacketId.recv_self_money_notify, res, ServerType.Area);
                }

                _Logger.Debug($"Monster is dead InstanceId [{monster.instanceId}]");
                //Death Animation
                List <PacketResponse>       brList  = new List <PacketResponse>();
                RecvBattleReportStartNotify brStart = new RecvBattleReportStartNotify(monster.instanceId);
                RecvBattleReportEndNotify   brEnd   = new RecvBattleReportEndNotify();
                RecvBattleReportNoactDead   brDead  = new RecvBattleReportNoactDead(monster.instanceId, 1);
                brList.Add(brStart);
                brList.Add(brDead);
                brList.Add(brEnd);
                server.router.Send(_map, brList);

                //Make the monster a lootable state
                IBuffer res10 = BufferProvider.Provide();
                res10.WriteUInt32(monster.instanceId);
                res10.WriteInt32(2); //Toggles state between Alive(attackable),  Dead(lootable), or Inactive(nothing).
                server.router.Send(_map, (ushort)AreaPacketId.recv_monster_state_update_notify, res10,
                                   ServerType.Area);

                Thread.Sleep(monster.respawnTime);
                //decompose the body
                IBuffer res7 = BufferProvider.Provide();
                res7.WriteUInt32(monster.instanceId);
                res7.WriteInt32(Util.GetRandomNumber(1, 5)); //4 here causes a cloud and the model to disappear, 5 causes a mist to happen and disappear
                res7.WriteInt32(1);
                server.router.Send(_map, (ushort)AreaPacketId.recv_charabody_notify_deadstate, res7, ServerType.Area);
                Thread.Sleep(2000);
                RecvObjectDisappearNotify objectDisappearData = new RecvObjectDisappearNotify(monster.instanceId);
                server.router.Send(_map, objectDisappearData);
                monster.monsterVisible = false;

                _spawnMonster = true;
                return(true);
            }

            return(false);
        }