Пример #1
0
        public void TriggerTrap(Trap trap, MonsterSpawn monster)
        {
            _Logger.Debug(
                $"trap._name [{trap.name}] trap.InstanceId [{trap.instanceId}] trap._skillEffectId [{trap.skillEffectId}] trap._triggerEffectId [{trap.triggerEffectId}]");
            NecClient client = _map.clientLookup.GetByCharacterInstanceId(ownerInstanceId);

            if (client.character.IsStealthed())
            {
                client.character.ClearStateBit(CharacterState.StealthForm);
                RecvCharaNotifyStateflag charState =
                    new RecvCharaNotifyStateflag(client.character.instanceId, (uint)client.character.state);
                server.router.Send(client.map, charState);
            }

            int damage = Util.GetRandomNumber(70, 90);
            RecvDataNotifyEoData eoTriggerData = new RecvDataNotifyEoData(trap.instanceId, monster.instanceId,
                                                                          trap.triggerEffectId, trapPos, 2, 2);

            server.router.Send(_map, eoTriggerData);
            float perHp = monster.hp.current / (float)monster.hp.max * 100;
            List <PacketResponse>            brList    = new List <PacketResponse>();
            RecvBattleReportStartNotify      brStart   = new RecvBattleReportStartNotify(ownerInstanceId);
            RecvBattleReportEndNotify        brEnd     = new RecvBattleReportEndNotify();
            RecvBattleReportActionAttackExec brAttack  = new RecvBattleReportActionAttackExec(trap.skillId);
            RecvBattleReportNotifyHitEffect  brHit     = new RecvBattleReportNotifyHitEffect(monster.instanceId);
            RecvBattleReportPhyDamageHp      brPhyHp   = new RecvBattleReportPhyDamageHp(monster.instanceId, damage);
            RecvObjectHpPerUpdateNotify      oHpUpdate = new RecvObjectHpPerUpdateNotify(monster.instanceId, perHp);
            RecvBattleReportDamageHp         brHp      = new RecvBattleReportDamageHp(monster.instanceId, damage);

            brList.Add(brStart);
            //brList.Add(brAttack);
            brList.Add(brHit);
            //brList.Add(brPhyHp);
            brList.Add(brHp);
            brList.Add(oHpUpdate);
            brList.Add(brEnd);
            server.router.Send(_map, brList);
            if (monster.GetAgroCharacter(ownerInstanceId))
            {
                monster.UpdateHp(-damage);
            }
            else
            {
                monster.UpdateHp(-damage, server, true, ownerInstanceId);
            }
        }
Пример #2
0
        public void SkillExec()
        {
            Vector3      trgCoord     = new Vector3();
            NpcSpawn     npcSpawn     = null;
            MonsterSpawn monsterSpawn = null;
            Character    character    = null;
            float        perHp        = 0;
            int          damage       = Util.GetRandomNumber(70, 90);
            IInstance    target       = _server.instances.GetInstance(_targetInstanceId);

            switch (target)
            {
            case NpcSpawn npc:
                npcSpawn = npc;
                _Logger.Debug(
                    $"NPCId: {npcSpawn.instanceId} SerialId: {npcSpawn.id} is gettin blasted by Skill Effect {_client.character.skillStartCast}");
                trgCoord.X = npcSpawn.x;
                trgCoord.Y = npcSpawn.y;
                trgCoord.Z = npcSpawn.z;
                break;

            case MonsterSpawn monster:
                monsterSpawn = monster;
                _Logger.Debug(
                    $"MonsterId: {monsterSpawn.instanceId} is gettin blasted by Skill Effect {_client.character.skillStartCast}");
                trgCoord.X = monsterSpawn.x;
                trgCoord.Y = monsterSpawn.y;
                trgCoord.Z = monsterSpawn.z;
                int monsterHp = monsterSpawn.hp.current;
                perHp = monsterHp > 0 ? monsterHp / (float)monsterSpawn.hp.max * 100 : 0;
                if (monsterSpawn.GetAgroCharacter(_client.character.instanceId))
                {
                    monsterSpawn.UpdateHp(-damage);
                }
                else
                {
                    monsterSpawn.UpdateHp(-damage, _server, true, _client.character.instanceId);
                }

                break;

            case Character chara:
                character = chara;
                _Logger.Debug(
                    $"CharacterId: {character.instanceId} is gettin blasted by Skill Effect {_client.character.skillStartCast}");
                trgCoord.X = character.x;
                trgCoord.Y = character.y;
                trgCoord.Z = character.z;
                break;

            default:
                _Logger.Error(
                    $"Instance with InstanceId: {target.instanceId} does not exist.  the ground is gettin blasted");
                break;
            }

            if (!_server.settingRepository.skillBase.TryGetValue(_skillId, out SkillBaseSetting skillBaseSetting))
            {
                _Logger.Error($"Could not get SkillBaseSetting for skillId : {_skillId}");
                return;
            }

            List <PacketResponse>           brList  = new List <PacketResponse>();
            RecvBattleReportStartNotify     brStart = new RecvBattleReportStartNotify(_client.character.instanceId);
            RecvBattleReportEndNotify       brEnd   = new RecvBattleReportEndNotify();
            RecvBattleReportActionSkillExec brExec  =
                new RecvBattleReportActionSkillExec(_client.character.skillStartCast);

            brList.Add(brStart);
            brList.Add(brExec);
            brList.Add(brEnd);
            _server.router.Send(_client.map, brList);
            if (!int.TryParse($"{_skillId}".Substring(1, 6) + 1, out int effectId))
            {
                _Logger.Error($"Creating effectId from skillid [{_skillId}]");
            }

            trgCoord.Z += 10;
            _Logger.Debug($"skillid [{_skillId}] effectId [{effectId}]");
            RecvDataNotifyEoData eoData =
                new RecvDataNotifyEoData(instanceId, _targetInstanceId, effectId, trgCoord, 2, 2);

            _server.router.Send(_client.map, eoData);
            RecvEoNotifyDisappearSchedule eoDisappear = new RecvEoNotifyDisappearSchedule(instanceId, 2.0F);

            _server.router.Send(_client.map, eoDisappear);

            Vector3  srcCoord   = new Vector3(_client.character.x, _client.character.y, _client.character.z);
            Recv8D92 effectMove = new Recv8D92(srcCoord, trgCoord, instanceId, _client.character.skillStartCast, 3000,
                                               2, 2); // ToDo need real velocities

            _server.router.Send(_client.map, effectMove);

            RecvDataNotifyEoData eoTriggerData = new RecvDataNotifyEoData(_client.character.instanceId,
                                                                          _targetInstanceId, effectId, srcCoord, 2, 2);

            _server.router.Send(_client.map, eoTriggerData);

            RecvBattleReportDamageHp        brHp      = new RecvBattleReportDamageHp(_targetInstanceId, damage);
            RecvObjectHpPerUpdateNotify     oHpUpdate = new RecvObjectHpPerUpdateNotify(_targetInstanceId, perHp);
            RecvBattleReportNotifyHitEffect brHit     = new RecvBattleReportNotifyHitEffect(_targetInstanceId);

            brList.Add(brStart);
            brList.Add(brHp);
            brList.Add(oHpUpdate);
            brList.Add(brHit);
            brList.Add(brEnd);
            brList.Add(oHpUpdate);
            _server.router.Send(_client.map, brList);
        }