public void SkillExec()
        {
            Vector3      trgCoord     = new Vector3();
            NpcSpawn     npcSpawn     = null;
            MonsterSpawn monsterSpawn = null;
            Character    character    = null;
            IInstance    target       = _server.instances.GetInstance(_targetInstanceId);

            switch (target)
            {
            case NpcSpawn npc:
                npcSpawn = npc;
                _Logger.Debug(
                    $"NPCId: {npcSpawn.instanceId} 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;

                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: {_targetInstanceId} 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;
            }

            if (!int.TryParse($"{_skillId}".Substring(1, 6) + 1, out int effectId))
            {
                _Logger.Error($"Creating effectId from skillid [{_skillId}]");
            }

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

            brList.Add(brStart);
            brList.Add(brExec);
            brList.Add(brEof);
            brList.Add(brEnd);
            _server.router.Send(_client.map, brList);
            brList.Clear();
            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);

            int damage = Util.GetRandomNumber(70, 90);
            //RecvDataNotifyEoData eoTriggerData = new RecvDataNotifyEoData(_client.Character.InstanceId, monsterSpawn.InstanceId, effectId, _srcCoord, 2, 2);
            //_server.Router.Send(_client.Map, eoTriggerData);
            int monsterHp = monsterSpawn.hp.current;
            List <PacketResponse> brList2 = new List <PacketResponse>();
            float perHp = monsterHp > 0 ? monsterHp / (float)monsterSpawn.hp.max * 100 : 0;
            RecvBattleReportStartNotify brStart1 = new RecvBattleReportStartNotify(_client.character.instanceId);
            RecvBattleReportEndNotify   brEnd1   = new RecvBattleReportEndNotify();
            //RecvBattleReportDamageHp brHp = new RecvBattleReportDamageHp(monsterSpawn.InstanceId, damage);
            RecvBattleReportPhyDamageHp     brPhyHp   = new RecvBattleReportPhyDamageHp(monsterSpawn.instanceId, damage);
            RecvObjectHpPerUpdateNotify     oHpUpdate = new RecvObjectHpPerUpdateNotify(monsterSpawn.instanceId, perHp);
            RecvBattleReportNotifyHitEffect brHit     = new RecvBattleReportNotifyHitEffect(monsterSpawn.instanceId);

            brList2.Add(brStart1);
            //brList2.Add(brHp);
            brList2.Add(brPhyHp);
            brList2.Add(oHpUpdate);
            brList2.Add(brHit);
            brList2.Add(brEnd1);
            //brList.Add(oHpUpdate);
            _server.router.Send(_client.map, brList2);
            //if (monsterSpawn.GetAgroCharacter(_client.Character.InstanceId))
            //{
            // monsterSpawn.UpdateHP(-damage);
            //}
            //else
            //{
            //monsterSpawn.UpdateHP(-damage, _server, true, _client.Character.InstanceId);
            //}
            _Logger.Debug($"{monsterSpawn.name} has {monsterSpawn.hp.current} HP left.");
        }
Beispiel #2
0
        protected override void Execute()
        {
            while (expireTime > DateTime.Now && trapActive)
            {
                List <MonsterSpawn> monsters = _map.GetMonstersRange(TrapPos, detectRadius);
                if (triggered)
                {
                    Trap trap = TrapList[0];
                    foreach (MonsterSpawn monster in monsters)
                    {
                        Vector3 monsterPos = new Vector3(monster.X, monster.Y, monster.Z);
                        Logger.Debug(
                            $"Enhancement monster.InstanceId [{monster.InstanceId}] trap._name [{trap._name}] trap._effectRadius [{trap._effectRadius}]");
                        if (Vector3.Distance(monsterPos, TrapPos) <= trap._effectRadius)
                        {
                            TriggerTrap(trap, monster);
                        }
                    }

                    TrapList.Remove(trap);
                    if (TrapList.Count == 0)
                    {
                        trapActive = false;
                    }
                }
                else if (monsters.Count > 0)
                {
                    foreach (MonsterSpawn monster in monsters)
                    {
                        Vector3 monsterPos = new Vector3(monster.X, monster.Y, monster.Z);
                        if ((Vector3.Distance(monsterPos, TrapPos) <= triggerRadius) &&
                            (monsterPos.Z - TrapPos.Z <= detectHeight))
                        {
                            triggered = true;
                            break;
                        }
                    }

                    if (!triggered)
                    {
                        tickTime = 50;
                    }
                    else
                    {
                        tickTime = 500;
                        Trap trap = TrapList[0];
                        foreach (MonsterSpawn monster in monsters)
                        {
                            Vector3 monsterPos = new Vector3(monster.X, monster.Y, monster.Z);
                            Logger.Debug(
                                $"Base trap monster.InstanceId [{monster.InstanceId}] trap._name [{trap._name}] trap._effectRadius [{trap._effectRadius}]");
                            if (Vector3.Distance(monsterPos, TrapPos) <= trap._effectRadius)
                            {
                                MonsterList.Add(monster);
                                TriggerTrap(trap, monster);
                            }
                        }

                        TrapList.Remove(trap);
                        if (TrapList.Count == 0)
                        {
                            trapActive = false;
                        }
                    }
                }
                else
                {
                    tickTime = 400;
                }

                Thread.Sleep(tickTime);
            }

            foreach (Trap trap in TrapList)
            {
                RecvDataNotifyEoData eoDestroyData =
                    new RecvDataNotifyEoData(trap.InstanceId, trap.InstanceId, 0, TrapPos, 0, 0);
                _server.Router.Send(_map, eoDestroyData);
                RecvEoNotifyDisappearSchedule eoDisappear = new RecvEoNotifyDisappearSchedule(trap.InstanceId, 0.0F);
                _server.Router.Send(_map, eoDisappear);
            }

            TrapList.Clear();
            _map.RemoveTrap(stackInstanceId);
            this.Stop();
        }
Beispiel #3
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((uint)_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 ? (((float)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);
        }