Exemple #1
0
        public void Start()
        {
            Log.Info("Ability", "Start : " + Caster.Name);
            IsStarted = true;
            StartTime = TCPServer.GetTimeStampMS();

            if (Handler != null)
            {
                Handler.Start(this);
            }
        }
        public void StartCast(ushort AbilityID)
        {
            Ability_Info Info = GetAbility(AbilityID);

            if (Info == null)
            {
                return;
            }

            if (IsCasting() && CurrentAbility.Info == Info)
            {
                return;
            }

            Log.Info("AbilityInterface", "StartCast : " + AbilityID);

            if (CurrentAbility != null)
            {
                CurrentAbility.Stop();
                CurrentAbility = null;
            }

            GameData.AbilityResult Result = CanCast(Info);

            if (Result == GameData.AbilityResult.ABILITYRESULT_OK)
            {
                LastCast = TCPServer.GetTimeStampMS();

                CurrentAbility = new Ability(Info, Obj);
                CurrentAbility.Start();

                if (CurrentAbility.Handler != null)
                {
                    Result = CurrentAbility.Handler.CanCast();
                }

                Log.Info("Cast", "CastResult = " + Result);

                if (CurrentAbility.Handler == null || Result == GameData.AbilityResult.ABILITYRESULT_OK)
                {
                    Obj.GetUnit().ActionPoints -= Info.ActionPoints;
                    if (Obj.IsPlayer())
                    {
                        Obj.GetPlayer().SendHealh();
                    }
                }
                else
                {
                    CurrentAbility.Stop();
                }
            }
        }
Exemple #3
0
        public void Update()
        {
            Log.Info("Ability", "Update Start=" + StartTime + ",Cur=" + TCPServer.GetTimeStampMS() + ",Info=" + Info.CastTime);
            if (Handler != null)
            {
                Handler.Update();
            }

            if (StartTime + Info.CastTime < TCPServer.GetTimeStampMS())
            {
                Cast();
            }
        }
        public GameData.AbilityResult CanCast(Ability_Info Info)
        {
            if (LastCast + GlobalMSCoolDown > TCPServer.GetTimeStampMS())
            {
                return(GameData.AbilityResult.ABILITYRESULT_NOTREADY);
            }
            else if (Info.ActionPoints > GetPlayer().ActionPoints)
            {
                return(GameData.AbilityResult.ABILITYRESULT_AP);
            }

            return(GameData.AbilityResult.ABILITYRESULT_OK);
        }
Exemple #5
0
        public void Start()
        {
            //Log.Info("Ability", "Start : " + Caster.Name);
            IsStarted = true;
            StartTime = TCPServer.GetTimeStampMS();
            NextTick  = StartTime + 1000;
            Caster.EvtInterface.Notify(EventName.ON_START_CASTING, Caster, this);

            if (Handler != null)
            {
                Handler.Start(this);
            }

            if (!IsBuff)
            {
                SendStart();
            }
        }
Exemple #6
0
        public bool Cast()
        {
            if (IsDone)
            {
                return(false);
            }

            bool CanCast = true;

            if (Caster.AbtInterface.CanCast(Info, false) == GameData.AbilityResult.ABILITYRESULT_OK)
            {
                Caster.ActionPoints -= Info.Info.ApCost;

                if (Info.Info.ApSec == 0)
                {
                    DoneTime = TCPServer.GetTimeStampMS();
                }

                if (Handler != null)
                {
                    if (CanCast && Handler.CanCast(false) == GameData.AbilityResult.ABILITYRESULT_OK)
                    {
                        Caster.EvtInterface.Notify(EventName.ON_CAST, Caster, this);
                        Handler.Cast();
                    }
                    else
                    {
                        Handler.SendDone();
                    }
                }
                else
                {
                    SendAbilityDone(0);
                }

                WorldMgr.GeneralScripts.OnCastAbility(this);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #7
0
        public void Cast()
        {
            Log.Info("Ability", "Cast");

            if (IsDone)
            {
                return;
            }

            IsDone   = true;
            DoneTime = TCPServer.GetTimeStampMS();

            if (Handler != null)
            {
                GameData.AbilityResult Result = Handler.CanCast();

                if (Result == GameData.AbilityResult.ABILITYRESULT_OK)
                {
                    Handler.Cast();
                }
            }
        }
Exemple #8
0
        public void Update(long Tick)
        {
            if (Handler != null)
            {
                Handler.Update(Tick);
            }

            if (NextTick < Tick)
            {
                NextTick = Tick + 1000;
                OnTick(TickCount);
                ++TickCount;
            }

            if (!IsBuff)
            {
                if (StartTime + Info.Info.CastTime <= TCPServer.GetTimeStampMS())
                {
                    if (Info.Info.ApSec == 0)
                    {
                        Cast();
                    }
                    else
                    {
                        OnTick(TickCount);
                    }

                    Stop();
                }
            }

            if (EndTime != 0 && EndTime < Tick)
            {
                Stop();
            }
        }
Exemple #9
0
 public void SetBuff(long MSEndTime)
 {
     IsBuff  = true;
     EndTime = TCPServer.GetTimeStampMS() + MSEndTime;
     InitEffect((byte)(MSEndTime / 1000));
 }