private void PlayerDamage()
        {
            int       damage        = monster.level * Util.GetRandomNumber(1, 5); //ToDo  make a legitimate damage calculation.
            Character currentTarget = monster.GetCurrentTarget();

            currentTarget.hp.Modify(-damage, monster.instanceId);

            _Logger.Debug($"Monster {monster.instanceId} is attacking {currentTarget.name}");
            List <PacketResponse>           brList  = new List <PacketResponse>();
            RecvBattleReportStartNotify     brStart = new RecvBattleReportStartNotify(currentTarget.instanceId);
            RecvBattleReportEndNotify       brEnd   = new RecvBattleReportEndNotify();
            RecvBattleReportNotifyHitEffect brHit   = new RecvBattleReportNotifyHitEffect(currentTarget.instanceId);
            RecvBattleReportDamageHp        brHp    = new RecvBattleReportDamageHp(currentTarget.instanceId, damage);
            RecvCharaUpdateHp cHpUpdate             = new RecvCharaUpdateHp(currentTarget.hp.current);

            brList.Add(brStart);
            brList.Add(brHit);
            brList.Add(brHp);
            brList.Add(brEnd);
            server.router.Send(_map, brList);
            server.router.Send(_map.clientLookup.GetByCharacterInstanceId(currentTarget.instanceId),
                               cHpUpdate.ToPacket());

            if (currentTarget.hp.depleted)
            {
                monster.SetAgro(false);
                monster.monsterAgroList.Remove(currentTarget.instanceId);
            }

            //PlayerDeadCheck(currentTarget);
        }
Пример #2
0
        private void PlayerDamage()
        {
            int       damage        = (int)Util.GetRandomNumber(8, 43);
            Character currentTarget = _monster.GetCurrentTarget();

            currentTarget.Hp.Modify(-damage, _monster.InstanceId);

            Logger.Debug($"Monster {_monster.InstanceId} is attacking {currentTarget.Name}");
            List <PacketResponse>           brList  = new List <PacketResponse>();
            RecvBattleReportStartNotify     brStart = new RecvBattleReportStartNotify(currentTarget.InstanceId);
            RecvBattleReportEndNotify       brEnd   = new RecvBattleReportEndNotify();
            RecvBattleReportNotifyHitEffect brHit   = new RecvBattleReportNotifyHitEffect(currentTarget.InstanceId);
            RecvBattleReportDamageHp        brHp    = new RecvBattleReportDamageHp(currentTarget.InstanceId, damage);
            RecvCharaUpdateHp cHpUpdate             = new RecvCharaUpdateHp(currentTarget.Hp.current);

            brList.Add(brStart);
            brList.Add(brHit);
            brList.Add(brHp);
            brList.Add(brEnd);
            _server.Router.Send(Map, brList);
            _server.Router.Send(Map.ClientLookup.GetByCharacterInstanceId(currentTarget.InstanceId),
                                cHpUpdate.ToPacket());

            if (currentTarget.Hp.depleted)
            {
                _monster.SetAgro(false);
                _monster.MonsterAgroList.Remove(currentTarget.InstanceId);
            }

            //PlayerDeadCheck(currentTarget);
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);
            Router.Send(client, (ushort)AreaPacketId.recv_raisescale_request_revive_r, res, ServerType.Area);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            RecvCharaUpdateHp cHpUpdate = new RecvCharaUpdateHp(client.Character.Hp.current);

            Router.Send(client, cHpUpdate.ToPacket());

            IBuffer res4 = BufferProvider.Provide();

            res4.WriteUInt32(client.Character.InstanceId);
            Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_start_notify, res4, ServerType.Area);

            IBuffer res5 = BufferProvider.Provide();

            res5.WriteUInt32(client.Character.InstanceId);
            Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_notify_raise, res5, ServerType.Area);

            IBuffer res6 = BufferProvider.Provide();

            Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_end_notify, res6, ServerType.Area);

            IBuffer res3 = BufferProvider.Provide();

            res3.WriteUInt32(client.Character.DeadBodyInstanceId);
            Router.Send(client.Map, (ushort)AreaPacketId.recv_object_disappear_notify, res3, ServerType.Area);

            client.Character.hadDied     = false;
            client.Character.Hp.depleted = false;
            RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(client.Character, client.Soul.Name);

            Router.Send(client, cData.ToPacket());

            IBuffer res7 = BufferProvider.Provide();

            res7.WriteByte(0);
            Router.Send(client, (ushort)AreaPacketId.recv_event_end, res7, ServerType.Area);
        }
        private void AttackObjectsInRange(NecClient client, int damage)
        {
            float perHp = 100.0f;

            //Damage Players in range
            foreach (NecClient targetClient in client.map.clientLookup.GetAll())
            {
                if (targetClient == client)
                {
                    continue;                         //skip damaging yourself
                }
                if (targetClient.character.partyId == client.character.partyId && client.character.partyId != 0)
                {
                    continue;                                                                                              //skip damaging party members
                }
                //if (targetClient.Soul.CriminalLevel == 0 && client.CriminalOnlyDamage == true) continue; //skip attacking non criminal players.  TODO

                double distanceToCharacter = Distance(targetClient.character.x, targetClient.character.y,
                                                      client.character.x, client.character.y);
                _Logger.Debug(
                    $"target Character name [{targetClient.character.name}] distanceToCharacter [{distanceToCharacter}] Radius { /*[{monsterSpawn.Radius}]*/" 125 "} {targetClient.character.name}");
                if (distanceToCharacter > /*targetClient.Character.Radius +*/ 125)
                {
                    continue;
                }

                if (targetClient.character.hp.depleted)
                {
                    continue;
                }

                damage -= targetClient.character.battleParam.plusPhysicalDefence;
                if (damage < 0)
                {
                    damage = 1;             //pity damage
                }
                targetClient.character.hp.Modify(-damage, client.character.instanceId);
                perHp = (float)targetClient.character.hp.current / targetClient.character.hp.max * 100;
                _Logger.Debug(
                    $"CurrentHp [{targetClient.character.hp.current}] MaxHp[{targetClient.character.hp.max}] perHp[{perHp}]");
                RecvCharaUpdateHp cHpUpdate = new RecvCharaUpdateHp(targetClient.character.hp.current);
                _server.router.Send(targetClient, cHpUpdate.ToPacket());

                //logic to turn characters to criminals on criminal actions.  possibly should move to character task.
                client.character.criminalState += 1;
                if ((client.character.criminalState == 1) | (client.character.criminalState == 2) |
                    (client.character.criminalState == 3))
                {
                    IBuffer res40 = BufferProvider.Provide();
                    res40.WriteUInt32(client.character.instanceId);
                    res40.WriteByte(client.character.criminalState);

                    _Logger.Debug($"Setting crime level for Character {client.character.name} to {client.character.criminalState}");
                    router.Send(client.map, (ushort)AreaPacketId.recv_chara_update_notify_crime_lv, res40, ServerType.Area);
                    //Router.Send(client.Map, (ushort) AreaPacketId.recv_charabody_notify_crime_lv, res40, ServerType.Area, client);
                }

                if (client.character.criminalState > 255)
                {
                    client.character.criminalState = 255;
                }

                DamageTheObject(client, targetClient.character.instanceId, damage, perHp);
            }

            //Damage Monsters in range
            foreach (MonsterSpawn monsterSpawn in client.map.monsterSpawns.Values)
            {
                double distanceToObject =
                    Distance(monsterSpawn.x, monsterSpawn.y, client.character.x, client.character.y);
                //_Logger.Debug($"target Monster name [{monsterSpawn.name}] distanceToObject [{distanceToObject}] Radius [{monsterSpawn.radius}] {monsterSpawn.name}");
                if (distanceToObject > monsterSpawn.radius * 5
                    ) //increased hitbox for monsters by a factor of 5.  Beetle radius is 40
                {
                    continue;
                }

                if (monsterSpawn.hp.depleted)
                {
                    continue;
                }

                monsterSpawn.hp.Modify(-damage, client.character.instanceId);
                perHp = (float)monsterSpawn.hp.current / monsterSpawn.hp.max * 100;
                _Logger.Debug($"CurrentHp [{monsterSpawn.hp.current}] MaxHp[{monsterSpawn.hp.max}] perHp[{perHp}]");

                //just for fun. turn on inactive monsters
                if (monsterSpawn.active == false)
                {
                    monsterSpawn.active      = true;
                    monsterSpawn.spawnActive = true;
                    if (!monsterSpawn.taskActive)
                    {
                        MonsterTask monsterTask = new MonsterTask(_server, monsterSpawn);
                        if (monsterSpawn.defaultCoords)
                        {
                            monsterTask.monsterHome = monsterSpawn.monsterCoords[0];
                        }
                        else
                        {
                            monsterTask.monsterHome = monsterSpawn.monsterCoords.Find(x => x.coordIdx == 64);
                        }
                        monsterTask.Start();
                    }
                }

                DamageTheObject(client, monsterSpawn.instanceId, damage, perHp);
            }

            //Damage NPCs in range
            foreach (NpcSpawn npcSpawn in client.map.npcSpawns.Values)
            {
                double distanceToObject = Distance(npcSpawn.x, npcSpawn.y, client.character.x, client.character.y);
                // _Logger.Debug($"target NPC name [{npcSpawn.name}] distanceToObject [{distanceToObject}] Radius [{npcSpawn.radius}] {npcSpawn.name}");
                if (distanceToObject > npcSpawn.radius)
                {
                    continue;
                }

                //attacking an NPC is a misdimeanor crime for non-criminals.
                if ((client.character.criminalState == 0))
                {
                    client.character.criminalState += 1;
                    IBuffer res40 = BufferProvider.Provide();
                    res40.WriteUInt32(client.character.instanceId);
                    res40.WriteByte(client.character.criminalState);

                    router.Send(client.map, (ushort)AreaPacketId.recv_chara_update_notify_crime_lv, res40, ServerType.Area);
                }

                DamageTheObject(client, npcSpawn.instanceId, damage, perHp);
            }
        }
Пример #5
0
        private void AttackObjectsInRange(NecClient client, int damage)
        {
            float perHp = 100.0f;

            //Damage Players in range
            foreach (NecClient targetClient in client.Map.ClientLookup.GetAll())
            {
                if (targetClient == client)
                {
                    continue;
                }

                double distanceToCharacter = distance(targetClient.Character.X, targetClient.Character.Y,
                                                      client.Character.X, client.Character.Y);
                Logger.Debug(
                    $"target Character name [{targetClient.Character.Name}] distanceToCharacter [{distanceToCharacter}] Radius { /*[{monsterSpawn.Radius}]*/" 125 "} {targetClient.Character.Name}");
                if (distanceToCharacter > /*targetClient.Character.Radius +*/ 125)
                {
                    continue;
                }

                if (targetClient.Character.Hp.depleted)
                {
                    continue;
                }

                targetClient.Character.Hp.Modify(-damage, client.Character.InstanceId);
                perHp = (float)targetClient.Character.Hp.current / targetClient.Character.Hp.max * 100;
                Logger.Debug(
                    $"CurrentHp [{targetClient.Character.Hp.current}] MaxHp[{targetClient.Character.Hp.max}] perHp[{perHp}]");
                RecvCharaUpdateHp cHpUpdate = new RecvCharaUpdateHp(targetClient.Character.Hp.current);
                _server.Router.Send(targetClient, cHpUpdate.ToPacket());

                //logic to turn characters to criminals on criminal actions.  possibly should move to character task.
                client.Character.criminalState += 1;
                if (client.Character.criminalState == 1 | client.Character.criminalState == 2 |
                    client.Character.criminalState == 3)
                {
                    IBuffer res40 = BufferProvider.Provide();
                    res40.WriteUInt32(client.Character.InstanceId);
                    res40.WriteByte(client.Character.criminalState);

                    Logger.Debug(
                        $"Setting crime level for Character {client.Character.Name} to {client.Character.criminalState}");
                    Router.Send(client, (ushort)AreaPacketId.recv_chara_update_notify_crime_lv, res40,
                                ServerType.Area);
                    Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_notify_crime_lv, res40,
                                ServerType.Area, client);
                }

                if (client.Character.criminalState > 255)
                {
                    client.Character.criminalState = 255;
                }

                DamageTheObject(client, targetClient.Character.InstanceId, damage, perHp);
            }

            //Damage Monsters in range
            foreach (MonsterSpawn monsterSpawn in client.Map.MonsterSpawns.Values)
            {
                double distanceToObject =
                    distance(monsterSpawn.X, monsterSpawn.Y, client.Character.X, client.Character.Y);
                Logger.Debug(
                    $"target Monster name [{monsterSpawn.Name}] distanceToObject [{distanceToObject}] Radius [{monsterSpawn.Radius}] {monsterSpawn.Name}");
                if (distanceToObject > monsterSpawn.Radius * 5
                    ) //increased hitbox for monsters by a factor of 5.  Beetle radius is 40
                {
                    continue;
                }

                if (monsterSpawn.Hp.depleted)
                {
                    continue;
                }

                monsterSpawn.Hp.Modify(-damage, client.Character.InstanceId);
                perHp = (float)monsterSpawn.Hp.current / monsterSpawn.Hp.max * 100;
                Logger.Debug($"CurrentHp [{monsterSpawn.Hp.current}] MaxHp[{monsterSpawn.Hp.max}] perHp[{perHp}]");

                DamageTheObject(client, monsterSpawn.InstanceId, damage, perHp);
            }

            //Damage NPCs in range
            foreach (NpcSpawn npcSpawn in client.Map.NpcSpawns.Values)
            {
                double distanceToObject = distance(npcSpawn.X, npcSpawn.Y, client.Character.X, client.Character.Y);
                Logger.Debug(
                    $"target NPC name [{npcSpawn.Name}] distanceToObject [{distanceToObject}] Radius [{npcSpawn.Radius}] {npcSpawn.Name}");
                if (distanceToObject > npcSpawn.Radius)
                {
                    continue;
                }

                DamageTheObject(client, npcSpawn.InstanceId, damage, perHp);
            }
        }
Пример #6
0
        private void OldBattleLogic(NecClient client, uint instanceId)
        {
            int   damage = 0;
            float perHp  = 100.0f;
            int   seed   = Util.GetRandomNumber(0, 20);

            if (seed < 2)
            {
                damage = Util.GetRandomNumber(1, 4); // Light hit
            }
            else if (seed < 19)
            {
                damage = Util.GetRandomNumber(16, 24); // Normal hit
            }
            else
            {
                damage = Util.GetRandomNumber(32, 48); // Critical hit
            }
            //stops the logic gate below if nothing is targeted.  This was because Rev 1 of battle logic only worked on targeted objects.  probably will go away with progress on 'area of affect' based melee
            if (instanceId == 0)
            {
                return;
            }

            IInstance instance = Server.Instances.GetInstance(instanceId);

            switch (instance)
            {
            case NpcSpawn npcSpawn:
                client.Map.NpcSpawns.TryGetValue(npcSpawn.InstanceId, out npcSpawn);
                {
                    double distanceToNPC = distance(npcSpawn.X, npcSpawn.Y, client.Character.X, client.Character.Y);
                    Logger.Debug(
                        $"NPC name [{npcSpawn.Name}] distanceToNPC [{distanceToNPC}] Radius [{npcSpawn.Radius}] {npcSpawn.Name}");
                    if (distanceToNPC > npcSpawn.Radius + 125)
                    {
                        //SendBattleReportEndNotify(client, instance);
                        return;
                    }

                    if (client.Character.criminalState < 1)
                    {
                        client.Character.criminalState = 1;
                        IBuffer res40 = BufferProvider.Provide();
                        res40.WriteUInt32(client.Character.InstanceId);
                        res40.WriteByte(client.Character.criminalState);

                        Logger.Debug(
                            $"Setting crime level for Character {client.Character.Name} to {client.Character.criminalState}");
                        Router.Send(client, (ushort)AreaPacketId.recv_chara_update_notify_crime_lv, res40,
                                    ServerType.Area);
                        Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_notify_crime_lv, res40,
                                    ServerType.Area, client);
                    }
                }
                break;

            case MonsterSpawn monsterSpawn:
                client.Map.MonsterSpawns.TryGetValue(monsterSpawn.InstanceId, out monsterSpawn);
                {
                    double distanceToMonster = distance(monsterSpawn.X, monsterSpawn.Y, client.Character.X,
                                                        client.Character.Y);
                    Logger.Debug(
                        $"monster name [{monsterSpawn.Name}] distanceToMonster [{distanceToMonster}] Radius [{monsterSpawn.Radius}] {monsterSpawn.Name}");
                    if (distanceToMonster > monsterSpawn.Radius + 125)
                    {
                        //SendBattleReportEndNotify(client, instance);
                        return;
                    }

                    if (monsterSpawn.GetAgroCharacter(client.Character.InstanceId))
                    {
                        monsterSpawn.UpdateHP(-damage);
                    }
                    else
                    {
                        monsterSpawn.UpdateHP(-damage, _server, true, client.Character.InstanceId);
                    }

                    if (client.Character.IsStealthed())
                    {
                        uint newState = client.Character.ClearStateBit(0x8);
                        RecvCharaNotifyStateflag charState =
                            new RecvCharaNotifyStateflag(client.Character.InstanceId, newState);
                        _server.Router.Send(client.Map, charState);
                    }

                    perHp = (float)monsterSpawn.Hp.current / monsterSpawn.Hp.max * 100;
                    Logger.Debug($"CurrentHp [{monsterSpawn.Hp.current}] MaxHp[{monsterSpawn.Hp.max}] perHp[{perHp}]");
                }
                break;

            case Character character:
                NecClient targetClient        = client.Map.ClientLookup.GetByCharacterInstanceId(instance.InstanceId);
                double    distanceToCharacter = distance(targetClient.Character.X, targetClient.Character.Y,
                                                         client.Character.X, client.Character.Y);
                Logger.Debug(
                    $"target Character name [{targetClient.Character.Name}] distanceToCharacter [{distanceToCharacter}] Radius { /*[{monsterSpawn.Radius}]*/" 125 "} {targetClient.Character.Name}");
                if (distanceToCharacter > /*targetClient.Character.Radius +*/ 125)
                {
                    //SendBattleReportEndNotify(client, instance);
                    return;
                }

                targetClient.Character.Hp.Modify(-damage, character.InstanceId);
                perHp = (float)targetClient.Character.Hp.current / targetClient.Character.Hp.max * 100;
                Logger.Debug(
                    $"CurrentHp [{targetClient.Character.Hp.current}] MaxHp[{targetClient.Character.Hp.max}] perHp[{perHp}]");
                RecvCharaUpdateHp cHpUpdate = new RecvCharaUpdateHp(targetClient.Character.Hp.current);
                _server.Router.Send(targetClient, cHpUpdate.ToPacket());

                //logic to turn characters to criminals on criminal actions.  possibly should move to character task.
                client.Character.criminalState += 1;
                if (client.Character.criminalState == 1 | client.Character.criminalState == 2 |
                    client.Character.criminalState == 3)
                {
                    IBuffer res40 = BufferProvider.Provide();
                    res40.WriteUInt32(client.Character.InstanceId);
                    res40.WriteByte(client.Character.criminalState);

                    Logger.Debug(
                        $"Setting crime level for Character {client.Character.Name} to {client.Character.criminalState}");
                    Router.Send(client, (ushort)AreaPacketId.recv_chara_update_notify_crime_lv, res40,
                                ServerType.Area);
                    Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_notify_crime_lv, res40,
                                ServerType.Area, client);
                }

                if (client.Character.criminalState > 255)
                {
                    client.Character.criminalState = 255;
                }

                break;

            default:
                Logger.Error($"Instance with InstanceId: {instance.InstanceId} does not exist");
                break;
            }

            List <PacketResponse>            brTargetList = new List <PacketResponse>();
            RecvBattleReportStartNotify      brStart      = new RecvBattleReportStartNotify(client.Character.InstanceId);
            RecvBattleReportEndNotify        brEnd        = new RecvBattleReportEndNotify();
            RecvBattleReportActionAttackExec brAttack     = new RecvBattleReportActionAttackExec((int)instance.InstanceId);
            RecvBattleReportNotifyHitEffect  brHit        = new RecvBattleReportNotifyHitEffect(instance.InstanceId);
            RecvBattleReportPhyDamageHp      brPhyHp      = new RecvBattleReportPhyDamageHp(instance.InstanceId, damage);
            RecvBattleReportDamageHp         brHp         = new RecvBattleReportDamageHp(instance.InstanceId, damage);
            RecvObjectHpPerUpdateNotify      oHpUpdate    = new RecvObjectHpPerUpdateNotify(instance.InstanceId, perHp);


            brTargetList.Add(brStart);
            brTargetList.Add(brAttack);
            brTargetList.Add(brHit);
            brTargetList.Add(brPhyHp);
            //brTargetList.Add(brHp);
            brTargetList.Add(oHpUpdate);
            brTargetList.Add(brEnd);
            Router.Send(client.Map, brTargetList);
        }
        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.soulFormState == 1)
            {
                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 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

                client.Character.soulFormState -= 1;
                client.Character.Hp.toMax();
                client.Character.movementId = client.Character.InstanceId;
                client.Character.state      = 0b00000000;


                IBuffer res2 = BufferProvider.Provide();
                res2.WriteInt32(0); // Error code, 0 = success
                Router.Send(client, (ushort)AreaPacketId.recv_revive_execute_r, res2, ServerType.Area);

                RecvCharaUpdateHp cHpUpdate = new RecvCharaUpdateHp(client.Character.Hp.current);
                Router.Send(client, cHpUpdate.ToPacket());

                IBuffer res4 = BufferProvider.Provide();
                res4.WriteUInt32(client.Character.InstanceId);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_start_notify, res4, ServerType.Area);

                IBuffer res5 = BufferProvider.Provide();
                res5.WriteUInt32(client.Character.InstanceId);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_notify_raise, res5, ServerType.Area);

                IBuffer res6 = BufferProvider.Provide();
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_end_notify, res6, ServerType.Area);
                //

                IBuffer res3 = BufferProvider.Provide();
                res3.WriteUInt32(client.Character.DeadBodyInstanceId);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_object_disappear_notify, res3, ServerType.Area);

                client.Character.hadDied     = false;
                client.Character.Hp.depleted = false;
                RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(client.Character, client.Soul.Name);
                Router.Send(client, cData.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.Map, (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.Map, (ushort) AreaPacketId.recv_raisescale_request_revive_r, res, ServerType.Area);
             *
             *  IBuffer res5 = BufferProvider.Provide();
             *  Router.Send(client.Map, (ushort) AreaPacketId.recv_self_lost_notify, res5, ServerType.Area);
             * }*/
        }