Ejemplo n.º 1
0
 /// <summary>
 /// Initialize the timer
 /// </summary>
 /// <param name="interval">Interval</param>
 /// <param name="duetime">Due Time</param>
 protected void InitTimer(int interval, int duetime)
 {
     this.m_task      = new MultiRunTask(duetime, interval);
     this.m_task.Func = new MultiRunTask.func(timerCallback);
 }
Ejemplo n.º 2
0
Archivo: PC.cs Proyecto: xxlio109/Saga
        public void OnJobChange(byte NewJob, byte ChangeWeapon, ushort postfix)
        {
            //removing passive status

            #region Old Addition handling
            List <string> dellist = new List <string>();
            foreach (string i in this.Char.Tasks.Keys)
            {
                try
                {
                    if (i == "AutoSave" || i == "RegenerationHP" || i == "RegenerationSP" || i == "LPReduction")
                    {
                        continue;
                    }
                    MultiRunTask task = this.Char.Tasks[i];
                    task.Deactivate();
                    dellist.Add(i);
                }
                catch (Exception ex)
                {
                    Logger.ShowError(ex);
                }
            }
            foreach (string i in dellist)
            {
                this.Char.Tasks.Remove(i);
            }
            #endregion

            #region New Addition Handling
            Addition[] additionlist = new Addition[this.Char.BattleStatus.Additions.Count];
            this.Char.BattleStatus.Additions.Values.CopyTo(additionlist, 0);
            foreach (Addition i in additionlist)
            {
                if (i.Activated)
                {
                    i.AdditionEnd();
                }
            }
            this.Char.BattleStatus.Additions.Clear();
            #endregion

            if (!this.Char.JobLevels.ContainsKey(this.Char.job))
            {
                this.Char.JobLevels.Add(this.Char.job, (byte)this.Char.jLevel);
                MapServer.charDB.NewJobLevel(this.Char, this.Char.job, (byte)this.Char.jLevel);
            }
            else
            {
                this.Char.JobLevels[this.Char.job] = (byte)this.Char.jLevel;
                MapServer.charDB.UpdateJobLevel(this.Char, this.Char.job, (byte)this.Char.jLevel);
            }
            this.Char.job = (JobType)NewJob;
            if (!this.Char.JobLevels.ContainsKey(this.Char.job))
            {
                this.Char.JobLevels.Add(this.Char.job, 1);
                MapServer.charDB.NewJobLevel(this.Char, this.Char.job, 1);
            }
            this.Char.jLevel = this.Char.JobLevels[this.Char.job];
            this.Char.jExp   = ExperienceManager.Instance.GetExpForLevel(this.Char.jLevel - 1, ExperienceManager.LevelType.JLEVEL);

            Weapon weapon = WeaponFactory.GetActiveWeapon(this.Char);
            //Change weapon
            if (ChangeWeapon == 1)
            {
                WeaponInfo info;
                switch (this.Char.job)
                {
                case JobType.ENCHANTER:
                    weapon.type        = (ushort)WeaponType.SWORD_STICK;
                    weapon.augeSkillID = 150029;
                    break;

                case JobType.SWORDMAN:
                    weapon.type        = (ushort)WeaponType.LONG_SWORD;
                    weapon.augeSkillID = 150015;
                    break;

                case JobType.THIEF:
                    weapon.type        = (ushort)WeaponType.SHORT_SWORD;
                    weapon.augeSkillID = 150001;
                    break;

                case JobType.RECRUIT:
                    weapon.type        = (ushort)WeaponType.DAMPTFLINTE;
                    weapon.augeSkillID = 150043;
                    break;

                case JobType.CLOWN:
                    weapon.type        = (ushort)WeaponType.SHORT_SWORD;
                    weapon.augeSkillID = 150001;
                    break;

                case JobType.NOVICE:
                    weapon.type        = (ushort)WeaponType.SHORT_SWORD;
                    weapon.augeSkillID = 150001;
                    break;
                }
                info = WeaponFactory.GetWeaponInfo((byte)weapon.type, weapon.level);
                if (weapon.durability > info.maxdurability)
                {
                    weapon.durability = (ushort)info.maxdurability;
                }
            }

            /*this.Char.str = 5;
             * this.Char.dex = 3;
             * this.Char.con = 3;
             * this.Char.intel = 2;
             * this.Char.luk = 0;
             * this.Char.stpoints = (byte)(2 * (this.Char.cLevel - 1));*/
            SkillHandler.SkillResetOnJobChange(this.Char);
            SkillHandler.CalcHPSP(ref this.client.Char);
            this.client.SendCharStatus(0);
            this.client.SendBattleStatus();
            this.client.SendExtStats();
            Packets.Server.WeaponTypeChange p = new SagaMap.Packets.Server.WeaponTypeChange();
            p.SetType(weapon.type);
            p.SetWeaponAuge(weapon.augeSkillID);
            p.SetPostFix(postfix);
            this.client.netIO.SendPacket(p, client.SessionID);
            //if (this.checkTwoHanded())  //this is not working
            this.MakeInactive(EQUIP_SLOT.LEFT_HAND);
            Packets.Server.ChangedJob p2 = new SagaMap.Packets.Server.ChangedJob();
            p2.SetJob(NewJob);
            p2.SetUnknown(this.Char.id);
            this.client.netIO.SendPacket(p2, client.SessionID);
            if (this.Char.CurTarget != null)
            {
                Npc npc = (Npc)this.Char.CurTarget.e;
                npc.NPCChat(this.Char, 1758);
            }
            else
            {
                Logger.ShowDebug(this.Char.name + "->CurTarget == null ", null);
            }
            if (this.client.Party != null)
            {
                this.client.Party.UpdateMemberInfo(this.client);
            }
        }