Exemple #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())
            {
                uint newState = client.Character.ClearStateBit(0x8);
                RecvCharaNotifyStateflag charState =
                    new RecvCharaNotifyStateflag(client.Character.InstanceId, newState);
                _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 = (((float)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);
            }
        }
        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);
        }