コード例 #1
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);
        }
コード例 #2
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);
        }