Example #1
0
        public bool Check(Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster, SkillObject skillObject)
        {
            var res = true;

            switch (Kind)
            {
            case PlotConditionType.Distance:
                //var dist = MathUtil.CalculateDistance(caster.Position, target.Position);
                var dist = 10;
                res = dist >= Param1 && dist <= Param2;
                break;

            case PlotConditionType.BuffTag:
                res = target.Effects.CheckBuffs(SkillManager.Instance.GetBuffsByTagId((uint)Param1));
                break;

            case PlotConditionType.Unk6:
                res = false;     //TODO
                break;

            case PlotConditionType.Unk7:
                res = false;     //TODO
                break;
            }

            return(NotCondition ? !res : res);
        }
Example #2
0
        public void Execute(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj,
                            CastAction castObj,
                            Skill skill, SkillObject skillObject, DateTime time, int Value1, int Value2, int Value3, int Value4)
        {
            if (caster is Character character)
            {
                character.DisabledSetPosition = true;

                character.SendPacket(
                    new SCLoadInstancePacket(
                        1,
                        character.WorldPosition.ZoneId,
                        character.WorldPosition.X,
                        character.WorldPosition.Y,
                        character.WorldPosition.Z,
                        0,
                        0,
                        0
                        )
                    );

                character.InstanceId    = 1; // TODO ....
                character.Position      = character.WorldPosition.Clone();
                character.WorldPosition = null;
            }
        }
        public void Execute(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj,
                            CastAction castObj, Skill skill, SkillObject skillObject, DateTime time, int Value1, int Value2, int Value3,
                            int Value4)
        {
            var owner     = (Character)caster;
            var skillData = (SkillItem)casterObj;

            var itemInfo = owner.Inventory.GetItem(skillData.ItemId);

            if (itemInfo == null || itemInfo.Count <= 0)
            {
                return;
            }

            var tasks = new List <ItemTask>
            {
                InventoryHelper.GetTaskAndRemoveItem(owner, itemInfo, 1)
            };

            owner.BmPoint += Value1;
            owner.SendPacket(new SCBmPointPacket(owner.BmPoint));
            owner.SendPacket(new SCItemTaskSuccessPacket(ItemTaskType.SkillReagents, tasks, new List <ulong>()));

            // TODO - LOYALT IS ACCOUNT WIDE
        }
 void IStage.Enter()
 {
     _DatumPosition = _Player.GetPosition();
     _Player.Aid();
     _Caster = SkillCaster.Build(ACTOR_STATUS_TYPE.AID);
     _TimeCounter.Reset();
 }
Example #5
0
        public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj,
                                   CastAction castObj,
                                   Skill skill, SkillObject skillObject, DateTime time)
        {
            _log.Debug("InteractionEffect, {0}", WorldInteraction);

            var classType = Type.GetType("AAEmu.Game.Models.Game.World.Interactions." + WorldInteraction);

            if (classType == null)
            {
                _log.Error("InteractionEffect, Unknown world interaction: {0}", WorldInteraction);
                return;
            }

            _log.Debug("InteractionEffect, Action: {0}", classType); // TODO help to debug...

            var action = (IWorldInteraction)Activator.CreateInstance(classType);

            action.Execute(caster, casterObj, target, targetObj, skill.Template.Id);

            if (caster is Character character)
            {
                character.Quests.OnInteraction(WorldInteraction);
            }
        }
Example #6
0
 public CastTask(Skill skill, Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster, SkillObject skillObject) : base(skill)
 {
     _caster       = caster;
     _casterCaster = casterCaster;
     _target       = target;
     _targetCaster = targetCaster;
     _skillObject  = skillObject;
 }
Example #7
0
 // Use this for initialization
 private void Start()
 {
     _agent          = GetComponent <NavMeshAgent>();
     _skillCaster    = GetComponent <SkillCaster>();
     _AIControl      = GetComponent <EnemyCharacter>();
     _characterStats = GetComponent <CharacterStats>();
     InvokeRepeating("Check", 0f, checkFrequency);
 }
Example #8
0
 public SCUnitHealedPacket(CastAction castAction, SkillCaster skillCaster, uint targetId, byte type, int value) : base(0x0a1, 1)
 {
     _castAction  = castAction;
     _skillCaster = skillCaster;
     _targetId    = targetId;
     _type        = type;
     _value       = value;
 }
Example #9
0
 public void Execute(Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster,
                     uint skillId)
 {
     if (target is House house && caster is Character character)
     {
         HousingManager.Instance.Demolish(character.Connection, house);
     }
 }
Example #10
0
        public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj,
                                   CastAction castObj,
                                   Skill skill, SkillObject skillObject, DateTime time)
        {
            _log.Debug("CraftEffect, {0}", WorldInteraction);

            var wiGroup = WorldManager.Instance.GetWorldInteractionGroup((uint)WorldInteraction);

            if (caster is Character character)
            {
                switch (wiGroup)
                {
                case WorldInteractionGroup.Craft:
                    character.Craft.EndCraft();
                    break;

                case WorldInteractionGroup.Collect:
                    break;

                case WorldInteractionGroup.Building when target is House house:     // TODO not done, debug only
                    if (house.Template.BuildSteps.Count == 0)
                    {
                        house.CurrentStep = -1;
                    }
                    else
                    {
                        house.AddBuildAction();
                    }

                    character.BroadcastPacket(
                        new SCHouseBuildProgressPacket(
                            house.TlId,
                            house.ModelId,
                            house.AllAction,
                            house.CurrentStep == -1 ? house.AllAction : house.CurrentAction
                            ),
                        true
                        );

                    if (house.CurrentStep == -1)
                    {
                        var doodads = house.AttachedDoodads.ToArray();
                        foreach (var doodad in doodads)
                        {
                            doodad.Spawn();
                        }
                    }

                    break;

                default:
                    _log.Warn("CraftEffect, {0} not have wi group", WorldInteraction);
                    break;
                }

                character.Quests.OnInteraction(WorldInteraction);
            }
        }
Example #11
0
 public SCSkillFiredPacket(uint id, ushort tl, SkillCaster caster, SkillCastTarget target, Skill skill, SkillObject skillObject) : base(0x09b, 1)
 {
     _id          = id;
     _tl          = tl;
     _caster      = caster;
     _target      = target;
     _skill       = skill;
     _skillObject = skillObject;
 }
Example #12
0
 public ApplySkillTask(Skill skill, Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster, SkillObject skillObject)
 {
     _skill        = skill;
     _caster       = caster;
     _casterCaster = casterCaster;
     _target       = target;
     _targetCaster = targetCaster;
     _skillObject  = skillObject;
 }
Example #13
0
        public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj,
                                   Skill skill, SkillObject skillObject, DateTime time)
        {
            Character character = (Character)caster;

            character.Craft.EndCraft();

            _log.Debug("CraftEffect");
        }
Example #14
0
 public SCUnitDamagedPacket(CastAction castAction, SkillCaster skillCaster, uint casterId, uint targetId, int damage)
     : base(0x0a0, 1)
 {
     _castAction  = castAction;
     _skillCaster = skillCaster;
     _casterId    = casterId;
     _targetId    = targetId;
     _damage      = damage;
 }
Example #15
0
 public SCSkillStartedPacket(uint id, ushort tl, SkillCaster caster, SkillCastTarget target, Skill skill, SkillObject skillObject)
     : base(SCOffsets.SCSkillStartedPacket, 5)
 {
     _id          = id;
     _tl          = tl;
     _caster      = caster;
     _target      = target;
     _skill       = skill;
     _skillObject = skillObject;
 }
 public PlotTask(Skill skill, Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster,
                 SkillObject skillObject, PlotNextEvent nextEvent) : base(skill)
 {
     _caster       = caster;
     _casterCaster = casterCaster;
     _target       = target;
     _targetCaster = targetCaster;
     _skillObject  = skillObject;
     _nextEvent    = nextEvent;
 }
Example #17
0
        public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj,
                                   Skill skill, SkillObject skillObject, DateTime time)
        {
            var portalInfo  = (SkillObjectUnk1)skillObject;
            var portalOwner = (Character)caster;

            _log.Debug("OpenPortalEffect, Owner: {0}, PortalId: {1}", portalOwner.Name, portalInfo.Id);

            PortalManager.Instance.OpenPortal(portalOwner, portalInfo); // TODO - Use Distance
        }
Example #18
0
    private void Awake()
    {
        Instance = this;

        LoadIcon();

        Caster = new SkillCaster();
        //角色拥有的测试技能
        TotalSkills = GetTestSkills();
    }
 public BattleCasterStatus(ISoulBinder binder, Entity player, IMapFinder map, SkillCaster caster)
 {
     _CastTimer = new TimeCounter();
     _Attacked = new HashSet<Guid>();
     _Binder = binder;
     _Player = player;
     _Map = map;
     _Caster = caster;
     _MoveController = new MoveController(player);
 }
Example #20
0
    /// <summary>
    /// 释放技能
    /// </summary>
    /// <param name="index">技能索引</param>
    public void Cast(int index)
    {
        // 技能组配置
        SkillGroupCfg cfg = ConfigManager.instance.GetSkillGroupCfg(_cfg.ID, index);

        // 技能基础配置
        SkillBasicCfg basicCfg = ConfigManager.instance.GetSkillBasicCfg(cfg.ID);

        // 技能发射器
        SkillCaster skillCaster = _skillCasters[cfg.ID];

        // 战斗界面
        //BattleWnd battleWnd = UIManager.instance.Get<BattleWnd>();

        //if (basicCfg.NeedTarget && _lockedTarget == null)
        //{
        //    battleWnd.ShowTips("需要一个目标");
        //    return;
        //}

        //if (basicCfg.NeedTarget && _lockedTarget != null && basicCfg.AffectSide == AffectSide.Enemy && _lockedTarget.side == side)
        //{
        //    battleWnd.ShowTips("非法目标");
        //    return;
        //}

        //if (basicCfg.NeedTarget && _lockedTarget != null && basicCfg.AffectSide == AffectSide.Friend && _lockedTarget.side != side)
        //{
        //    battleWnd.ShowTips("非法目标");
        //    return;
        //}

        //if (!skillCaster.cooldown)
        //{
        //    battleWnd.ShowTips("这个法术还没有准备好");
        //    return;
        //}

        //if (basicCfg.NeedTarget && _lockedTarget != null && Vector3.Distance(_transform.position, _lockedTarget.position) >= basicCfg.MaxRange)
        //{
        //    battleWnd.ShowTips("不在攻击范围之内");
        //    return;
        //}

        skillCaster.Cast();

        // 施法者播放动画
        Attack(basicCfg);

        // 播放特效
        if (basicCfg.CastEffect != null)
        {
            SkillManager.instance.PlayEffect(basicCfg.CastEffect, position, forward);
        }
    }
Example #21
0
 public PlotTask(Skill skill, Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster,
                 SkillObject skillObject, PlotNextEvent nextEvent, Dictionary <uint, int> counter) : base(skill)
 {
     _caster       = caster;
     _casterCaster = casterCaster;
     _target       = target;
     _targetCaster = targetCaster;
     _skillObject  = skillObject;
     _nextEvent    = nextEvent;
     _counter      = counter;
 }
        public void Execute(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj,
                            CastAction castObj, Skill skill, SkillObject skillObject, DateTime time, int Value1, int Value2, int Value3,
                            int Value4)
        {
            var owner     = (Character)caster;
            var skillData = (SkillItem)casterObj;

            _log.Warn("SlaveCall");

            SlaveManager.Instance.Create(owner, skillData);
        }
        public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj,
                                   CastAction castObj,
                                   Skill skill, SkillObject skillObject, DateTime time)
        {
            _log.Debug("AcceptQuestEffect");

            if (target is Character character)
            {
                character.Quests.Add(QuestId);
            }
        }
Example #24
0
 public void Execute(Unit caster, SkillCaster casterCaster, BaseUnit target, SkillCastTarget targetCaster, uint skillId)
 {
     if (target is Doodad doodad)
     {
         var func = DoodadManager.Instance.GetFunc(doodad.FuncGroupId, skillId);
         if (func == null)
         {
             return;
         }
         func.Use(caster, doodad, skillId);
     }
 }
Example #25
0
        public SkillStateBase(Engine.Utility.StateMachine <ISkillPart> machine, ISkillPart skillpart)
        {
            m_Statemachine = machine;
            m_SkillPart    = skillpart;
            if (skillpart.GetSkillPartType() == SkillPartType.SKILL_PLAYERPART)
            {
                PlayerSkillPart skill = skillpart as PlayerSkillPart;

                m_isMainPlayer = SkillSystem.GetClientGlobal().IsMainPlayer(skill.GetMaster());
                m_caster       = skill.Caster;
            }
        }
Example #26
0
        public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj,
                                   Skill skill, SkillObject skillObject, DateTime time)
        {
            _log.Debug("RestoreManaEffect");

            if (!(target is Unit))
            {
                return;
            }
            var trg = (Unit)target;
            var min = 0;
            var max = 0;

            if (UseFixedValue)
            {
                min += FixedMin;
                max += FixedMax;
            }

            var unk        = 0f;
            var unk2       = 1f;
            var skillLevel = 1;

            if (skill != null)
            {
                skillLevel = (skill.Level - 1) * skill.Template.LevelStep + skill.Template.AbilityLevel;
                if (skillLevel >= skill.Template.AbilityLevel)
                {
                    unk = 0.15f * (skillLevel - skill.Template.AbilityLevel + 1);
                }
                unk2 = (1 + unk) * 1.3f;
            }

            if (UseLevelValue)
            {
                var levelMd = (unk + 1) * LevelMd;
                min += (int)(caster.LevelDps * levelMd + 0.5f);
                max += (int)((((skillLevel - 1) * 0.020408163f * (LevelVaEnd - LevelVaStart) + LevelVaStart) * 0.0099999998f + 1f) *
                             caster.LevelDps * levelMd + 0.5f);
            }

            // TODO ...
            // min += (int)((caster.MDps + caster.MDpsInc) * 0.001f * unk2 + 0.5f);
            // max += (int)((caster.MDps + caster.MDpsInc) * 0.001f * unk2 + 0.5f);

            var value = Rand.Next(min, max);

            trg.BroadcastPacket(new SCUnitHealedPacket(castObj, casterObj, trg.ObjId, 1, value), true);
            trg.Mp += value;
            trg.Mp  = Math.Min(trg.Mp, trg.MaxMp);
            trg.BroadcastPacket(new SCUnitPointsPacket(trg.ObjId, trg.Hp, trg.Mp), true);
        }
Example #27
0
    /// <summary>
    /// 释放技能
    /// </summary>
    /// <param name="caster"></param>
    public override void Cast(SkillCaster caster)
    {
        caster.Cast();

        // 施法者播放动画
        Attack(caster.SkillBasicCfg);

        // 播放特效
        if (caster.SkillBasicCfg.CastEffect != null)
        {
            SkillManager.instance.PlayEffect(caster.SkillBasicCfg.CastEffect, position, forward);
        }
    }
 public override void Apply(Unit caster, SkillCaster casterObj, BaseUnit target, SkillCastTarget targetObj, CastAction castObj,
                            Skill skill, SkillObject skillObject, DateTime time)
 {
     if (RequireBuffId > 0 && !target.Effects.CheckBuff(RequireBuffId))
     {
         return; //TODO send error?
     }
     if (target.Effects.CheckBuffImmune(Id))
     {
         return; //TODO  error of immune?
     }
     target.Effects.AddEffect(new Effect(target, caster, casterObj, this, skill, time));
 }
Example #29
0
        public override void Read(PacketStream stream)
        {
            var skillId = stream.ReadUInt32();

            var skillCasterType = stream.ReadByte(); // кто применяет
            var skillCaster     = SkillCaster.GetByType((SkillCasterType)skillCasterType);

            skillCaster.Read(stream);

            var skillCastTargetType = stream.ReadByte(); // на кого применяют
            var skillCastTarget     = SkillCastTarget.GetByType((SkillCastTargetType)skillCastTargetType);

            skillCastTarget.Read(stream);

            var flag        = stream.ReadByte();
            var flagType    = flag & 15;
            var skillObject = SkillObject.GetByType((SkillObjectType)flagType);

            if (flagType > 0)
            {
                skillObject.Read(stream);
            }

            _log.Debug("StartSkill: Id {0}, flag {1}", skillId, flag);

            if (SkillManager.Instance.IsDefaultSkill(skillId) || SkillManager.Instance.IsCommonSkill(skillId))
            {
                var skill = new Skill(SkillManager.Instance.GetSkillTemplate(skillId)); // TODO переделать...
                skill.Use(Connection.ActiveChar, skillCaster, skillCastTarget, skillObject);
            }
            else if (skillCaster is SkillItem)
            {
                var item = Connection.ActiveChar.Inventory.GetItem(((SkillItem)skillCaster).ItemId);
                if (item == null || skillId != item.Template.UseSkillId)
                {
                    return;
                }
                Connection.ActiveChar.Quests.OnItemUse(item);
                var skill = new Skill(SkillManager.Instance.GetSkillTemplate(skillId));
                skill.Use(Connection.ActiveChar, skillCaster, skillCastTarget, skillObject);
            }
            else if (Connection.ActiveChar.Skills.Skills.ContainsKey(skillId))
            {
                var skill = Connection.ActiveChar.Skills.Skills[skillId];
                skill.Use(Connection.ActiveChar, skillCaster, skillCastTarget, skillObject);
            }
            else
            {
                _log.Warn("StartSkill: Id {0}, undefined use type", skillId);
            }
        }
Example #30
0
    /// <summary>
    /// Updates the skill references.
    /// </summary>
    /// <param name="skillCaster">The skill caster component of the local player</param>
    public void UpdateSkills(SkillCaster skillCaster)
    {
        for (int i = 0; i < _skillIcons.Length; i++)
        {
            _skillIcons[i].skill = skillCaster.skills[i + 1];                                              // Set skill reference
            _skillIcons[i].GetComponent <Image>().sprite = _skillIcons[i].skill.skillIcon;                 // Set icon
            _skillIcons[i].transform.Find("Keybind").GetComponent <Text>().text = SkillNumToString(i + 1); // Set keybind
        }

        if (Input.GetJoystickNames().Length > 0)
        {
            AdjustControllerText();
        }
    }
Example #31
0
    /// <summary>
    /// 追击
    /// </summary>
    public void Chase()
    {
        SkillCaster caster = GetSkillCaster();

        if (caster == null)
        {
            Vector3 targetPosition = _host.lockedTarget.position + (_host.position - _host.lockedTarget.position).normalized * 1f;
            _host.Move(targetPosition);
        }
        else
        {
            _host.Cast(caster);
        }
    }
Example #32
0
    /// <summary>
    /// 获取已经冷却完成的且满足施法范围的技能发射器
    /// </summary>
    /// <returns></returns>
    public SkillCaster GetSkillCaster()
    {
        SkillCaster caster = null;

        foreach (SkillCaster c in _host.skillCasters.Values)
        {
            float distance = Vector3.Distance(_host.position, _host.lockedTarget.position);
            if (c.cooldown && distance <= c.maxRange)
            {
                caster = c;
            }
        }

        return(caster);
    }
        public void GetPositionTest()
        {
            var data = new SkillData();
            data.Total = 10.0f;
            /*data.Roots = new[]
            {
                new Vector2(0,0),
                new Vector2(1,0),
            };*/
            var skill = new SkillCaster(data ,  null);
            var pos1 = skill.GetPosition(0);

            var pos2 = skill.GetPosition(1);

            Assert.AreEqual(0, pos1.X);
            Assert.AreEqual(0, pos1.Y);

            Assert.AreEqual(0.1f, pos2.X);
            Assert.AreEqual(0.1f, pos2.Y);
        }
        public float GetTrunSpeed()
        {
            if (_MoveController != null)
            {
                var status = _Entiry.GetStatus();
                var skill = Resource.Instance.FindSkill(status);
                var caster = new SkillCaster(skill, new Determination(skill));

                return caster.GetTurnRight();
            }

            return 0;
        }
 private void _ToCast(SkillCaster caster)
 {
     var status = new BattleCasterStatus(_Binder, _Player, _Map , caster);
     status.NextEvent += _ToCast;
     status.BattleIdleEvent += _ToBattle;
     status.DisarmEvent += _ToDone;
     _SetStatus(status);
 }
        void ICastSkill.Cast(ACTOR_STATUS_TYPE skill)
        {
            if (_Overdraft)
                return;

            _NextCaster = _Caster.FindNext(skill);
        }
        private void _ToKnockout()
        {
            var skill = Resource.Instance.FindSkill(ACTOR_STATUS_TYPE.KNOCKOUT1);
            var caster = new SkillCaster(skill, new Determination(skill));
            var stage = new BattleCasterStatus(_Binder, _Player, _Map, caster);
            stage.BattleIdleEvent += _ToBattle;
            stage.NextEvent += _ToCast;

            _SetStatus(stage);
        }