Ejemplo n.º 1
0
 public void AddTrap(uint instanceId, TrapStack trap)
 {
     lock (_trapLock)
     {
         traps.Add(instanceId, trap);
     }
 }
Ejemplo n.º 2
0
        private void Trap(NecClient client, int skillId, SkillBaseSetting skillBaseSetting)
        {
            Logger.Debug($"skillId : {skillId}");
            if (!int.TryParse($"{skillId}".Substring(1, 5), out int skillBase))
            {
                Logger.Error($"Creating skillBase from skillid [{skillId}]");
                int            errorCode = -1;
                RecvSkillExecR execFail  = new RecvSkillExecR(errorCode, 0, 0);
                Router.Send(execFail, client);
                return;
            }

            if (!int.TryParse($"{skillId}".Substring(1, 7), out int effectBase))
            {
                Logger.Error($"Creating skillBase from skillid [{skillId}]");
                int            errorCode = -1;
                RecvSkillExecR execFail  = new RecvSkillExecR(errorCode, 0, 0);
                Router.Send(execFail, client);
                return;
            }

            bool isBaseTrap = TrapTask.baseTrap(skillBase);

            effectBase += 1;
            if (!_server.SettingRepository.EoBase.TryGetValue(effectBase, out EoBaseSetting eoBaseSetting))
            {
                Logger.Error($"Getting EoBaseSetting from effectBase [{effectBase}]");
                int            errorCode = -1;
                RecvSkillExecR execFail  = new RecvSkillExecR(errorCode, 0, 0);
                Router.Send(execFail, client);
                return;
            }

            if (!_server.SettingRepository.EoBase.TryGetValue(effectBase + 1, out EoBaseSetting eoBaseSettingTriggered))
            {
                Logger.Error($"Getting EoBaseSetting from effectBase+1 [{effectBase + 1}]");
                int            errorCode = -1;
                RecvSkillExecR execFail  = new RecvSkillExecR(errorCode, 0, 0);
                Router.Send(execFail, client);
                return;
            }

            RecvSkillExecR execSuccess =
                new RecvSkillExecR(0, skillBaseSetting.CastingCooldown, skillBaseSetting.RigidityTime);

            Router.Send(execSuccess, client);

            // ToDo  verify trap parts available and remove correct number from inventory
            TrapStack trapStack = (TrapStack)Server.Instances.GetInstance((uint)client.Character.activeSkillInstance);
            Trap      trap      = new Trap(skillBase, skillBaseSetting, eoBaseSetting, eoBaseSettingTriggered);

            _server.Instances.AssignInstance(trap);
            Logger.Debug($"trap.InstanceId [{trap.InstanceId}]  trap.Name [{trap._name}]  skillId[{skillId}]");
            trapStack.SkillExec(trap, isBaseTrap);
            Vector3 trapPos = new Vector3(client.Character.X, client.Character.Y, client.Character.Z);
        }
Ejemplo n.º 3
0
        private void Trap(NecClient client, int skillId)
        {
            if (!int.TryParse($"{skillId}".Substring(1, 5), out int skillBase))
            {
                _Logger.Error($"Creating skillBase from skillid [{skillId}]");
                int errorCode = -1;
                RecvSkillStartCastR skillFail = new RecvSkillStartCastR(errorCode, 0);
                router.Send(skillFail, client);
                return;
            }

            if (!int.TryParse($"{skillId}".Substring(1, 7), out int effectBase))
            {
                _Logger.Error($"Creating skillBase from skillid [{skillId}]");
                int errorCode = -1;
                RecvSkillStartCastR skillFail = new RecvSkillStartCastR(errorCode, 0);
                router.Send(skillFail, client);
                return;
            }

            effectBase += 1;
            _Logger.Debug($"skillId [{skillId}] skillBase [{skillBase}] effectBase [{effectBase}]");
            if (!_server.settingRepository.skillBase.TryGetValue(skillId, out SkillBaseSetting skillBaseSetting))
            {
                _Logger.Error($"Getting SkillBaseSetting for skillid [{skillId}]");
                return;
            }

            if (!_server.settingRepository.eoBase.TryGetValue(effectBase, out EoBaseSetting eoBaseSetting))
            {
                _Logger.Error($"Getting EoBaseSetting from effectBase [{effectBase}]");
                return;
            }

            Vector3   charPos    = new Vector3(client.character.x, client.character.y, client.character.z);
            bool      isBaseTrap = TrapTask.BaseTrap(skillBase);
            TrapStack trapStack  = null;

            if (isBaseTrap)
            {
                int trapRadius = eoBaseSetting.effectRadius;
                trapStack = new TrapStack(_server, client, charPos, trapRadius);
                server.instances.AssignInstance(trapStack);
            }
            else
            {
                trapStack = client.map.GetTrapCharacterRange(client.character.instanceId, 75, charPos);
            }

            if (isBaseTrap)
            {
                _Logger.Debug(
                    $"Is base trap skillId [{skillId}] skillBase [{skillBase}] trapStack._trapRadius [{trapStack.trapRadius}]");
                if (client.map.GetTrapsCharacterRange(client.character.instanceId, trapStack.trapRadius, charPos))
                {
                    _Logger.Debug($"First trap with another trap too close [{skillId}]");
                    int errorCode = -1309;
                    RecvSkillStartCastR skillFail = new RecvSkillStartCastR(errorCode, 0);
                    router.Send(skillFail, client);
                    return;
                }
            }
            else
            {
                _Logger.Debug(
                    $"Is trap enhancement skillId [{skillId}] skillBase [{skillBase}] trapRadius [{trapStack.trapRadius}]");
                if (!client.map.GetTrapsCharacterRange(client.character.instanceId, trapStack.trapRadius, charPos))
                {
                    _Logger.Debug($"Trap enhancement without a base trap [{skillId}]");
                    int errorCode = -1;
                    RecvSkillStartCastR skillFail = new RecvSkillStartCastR(errorCode, 0);
                    router.Send(skillFail, client);
                    return;
                }
            }

            _Logger.Debug($"Valid position check for monsters skillId [{skillId}] skillBase [{skillBase}]");
            if (client.map.MonsterInRange(charPos, trapStack.trapRadius))
            {
                _Logger.Debug($"Monster too close [{skillId}]");
                int errorCode = -1310;
                RecvSkillStartCastR skillFail = new RecvSkillStartCastR(errorCode, 0);
                router.Send(skillFail, client);
                return;
            }

            _Logger.Debug(
                $"skillBaseSetting.Id [{skillBaseSetting.id}] skillBaseSetting.Name [{skillBaseSetting.name} eoBaseSetting.]");
            _Logger.Debug($"spearTrap.InstanceId [{trapStack.instanceId}] SpearTrap skillID [{skillId}]");
            client.character.activeSkillInstance = trapStack.instanceId;
            client.character.castingSkill        = true;
            trapStack.StartCast(skillBaseSetting);
        }