Esempio n. 1
0
        private static void AddItem(XmlNode item)
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            XmlNodeList childList = item.ChildNodes;
            for (int i = 0; i < childList.Count; i++)
                data.Add(childList.Item(i).Name, childList.Item(i).InnerText);

            if (!data.ContainsKey("id")) return;
            try
            {
                List<Bonus> nList = new List<Bonus>();
                uint id = uint.Parse(data["id"]);

                for (int i = 1; i <= 10; i++)
                {
                    ADDITION_BONUS bonus = (ADDITION_BONUS)Enum.Parse(typeof(ADDITION_BONUS), data["Func" + i]);
                    if (bonus != (ADDITION_BONUS)0)
                    {
                        Bonus nAdd = new Bonus();
                        nAdd.Effect = bonus;
                        nAdd.Value = int.Parse(data["Value" + i]);
                        nList.Add(nAdd);
                    }
                }
                additions.Add(id, nList);
            }
            catch (Exception e) { Logger.ShowError(" cannot parse: " + data["id"],null); Logger.ShowError(e,null);  return; }
        }
Esempio n. 2
0
        private void AddBonus(Actor actor, SagaDB.Items.Bonus i, BonusType type, bool unequip, uint id)
        {
            bool    isRate = false;
            ActorPC pc     = null;

            ActorEventHandlers.PC_EventHandler eh = null;
            if (actor.type == ActorType.PC)
            {
                pc = (ActorPC)actor;
                eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
            }
            if (i.Value > 20000 || i.Value < -20000)
            {
                isRate = true;
            }
            switch (i.Effect)
            {
            case ADDITION_BONUS.STR:
                if (actor.type != ActorType.PC || type != BonusType.Equipment)
                {
                    return;
                }
                pc.BattleStatus.strbonus += AddInt(i.Value, isRate, pc.str, unequip);
                break;

            case ADDITION_BONUS.DEX:
                if (actor.type != ActorType.PC || type != BonusType.Equipment)
                {
                    return;
                }
                pc.BattleStatus.dexbonus += AddInt(i.Value, isRate, pc.dex, unequip);
                break;

            case ADDITION_BONUS.CON:
                if (actor.type != ActorType.PC || type != BonusType.Equipment)
                {
                    return;
                }
                pc.BattleStatus.conbonus += AddInt(i.Value, isRate, pc.con, unequip);
                break;

            case ADDITION_BONUS.INT:
                if (actor.type != ActorType.PC || type != BonusType.Equipment)
                {
                    return;
                }
                pc.BattleStatus.intbonus += AddInt(i.Value, isRate, pc.intel, unequip);
                break;

            case ADDITION_BONUS.LUK:
                if (actor.type != ActorType.PC || type != BonusType.Equipment)
                {
                    return;
                }
                pc.BattleStatus.lukbonus += AddInt(i.Value, isRate, pc.luk, unequip);
                break;

            case ADDITION_BONUS.PhysicalDef:
                if (type == BonusType.Equipment)
                {
                    actor.BattleStatus.defbonus += AddInt(i.Value, isRate, actor.BattleStatus.def, unequip);
                }
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.defskill += AddInt(i.Value, isRate, actor.BattleStatus.def, unequip);
                }
                break;

            case ADDITION_BONUS.HPMax:
                if (actor.type != ActorType.PC)
                {
                    return;
                }
                if (type == BonusType.Equipment)
                {
                    pc.BattleStatus.hpbonus += AddInt(i.Value, isRate, pc.BattleStatus.hpBasic, unequip);
                }
                if (type == BonusType.Skill)
                {
                    pc.BattleStatus.hpskill += (short)AddInt(i.Value, isRate, pc.BattleStatus.hpBasic, unequip);
                }
                Skills.SkillHandler.CalcHPSP(ref pc);
                break;

            case ADDITION_BONUS.SPMax:
                if (actor.type != ActorType.PC)
                {
                    return;
                }
                if (type == BonusType.Equipment)
                {
                    pc.BattleStatus.spbonus += AddInt(i.Value, isRate, pc.BattleStatus.spBasic, unequip);
                }
                if (type == BonusType.Skill)
                {
                    pc.BattleStatus.spskill += (short)AddInt(i.Value, isRate, pc.BattleStatus.spBasic, unequip);
                }
                Skills.SkillHandler.CalcHPSP(ref pc);
                break;

            case ADDITION_BONUS.HPRecover:
                if (pc.Tasks.ContainsKey("RegenerationHP"))
                {
                    Tasks.Regeneration hp = (Tasks.Regeneration)pc.Tasks["RegenerationHP"];
                    if (type == BonusType.Equipment)
                    {
                        pc.BattleStatus.hpregbonus += AddInt(i.Value, isRate, hp.hp, unequip);
                    }
                    if (type == BonusType.Skill)
                    {
                        pc.BattleStatus.hpregskill += AddInt(i.Value, isRate, hp.hp, unequip);
                    }
                }
                break;

            case ADDITION_BONUS.SPRecover:
                if (pc.Tasks.ContainsKey("RegenerationSP"))
                {
                    Tasks.Regeneration sp = (Tasks.Regeneration)pc.Tasks["RegenerationSP"];
                    if (type == BonusType.Equipment)
                    {
                        pc.BattleStatus.spregbonus += AddInt(i.Value, isRate, sp.hp, unequip);
                    }
                    if (type == BonusType.Skill)
                    {
                        pc.BattleStatus.spregskill += AddInt(i.Value, isRate, sp.hp, unequip);
                    }
                }
                break;

            case ADDITION_BONUS.PhysicalFlee:
                if (type == BonusType.Equipment)
                {
                    actor.BattleStatus.fleebonus += AddInt(i.Value, isRate, actor.BattleStatus.flee, unequip);
                }
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.fleeskill += AddInt(i.Value, isRate, actor.BattleStatus.flee, unequip);
                }
                break;

            case ADDITION_BONUS.RangedFlee:
                if (type == BonusType.Equipment)
                {
                    actor.BattleStatus.rfleebonus += AddInt(i.Value, isRate, actor.BattleStatus.rflee, unequip);
                }
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.rfleeskill += AddInt(i.Value, isRate, actor.BattleStatus.rflee, unequip);
                }
                break;

            case ADDITION_BONUS.MagicalFlee:
                if (type == BonusType.Equipment)
                {
                    actor.BattleStatus.mfleebonus += AddInt(i.Value, isRate, actor.BattleStatus.mflee, unequip);
                }
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.mfleeskill += AddInt(i.Value, isRate, actor.BattleStatus.mflee, unequip);
                }
                break;

            case ADDITION_BONUS.PhysicalATK:
                int min, max;
                if (actor.type != ActorType.PC)
                {
                    return;
                }
                Skills.SkillHandler.GetPCATK(pc, out min, out max);
                if (type == BonusType.Equipment)
                {
                    actor.BattleStatus.atkbonus += AddInt(i.Value, isRate, max, unequip);
                }
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.atkskill += AddInt(i.Value, isRate, max, unequip);
                }
                Skills.SkillHandler.CalcAtk(ref actor);
                break;

            case ADDITION_BONUS.MaxWDamage:
            case ADDITION_BONUS.AtkMax:
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.atkmaxbonus += AddInt(i.Value, isRate, 0, unequip);
                }
                break;

            case ADDITION_BONUS.MinWDamage:
            case ADDITION_BONUS.AtkMin:
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.atkminbonus += AddInt(i.Value, isRate, 0, unequip);
                }
                break;

            case ADDITION_BONUS.MaxMWDamage:
            case ADDITION_BONUS.MagicalAtkMax:
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.matkmaxbonus += AddInt(i.Value, isRate, 0, unequip);
                }
                break;

            case ADDITION_BONUS.MinMWDamage:
            case ADDITION_BONUS.MagicalAtkMin:
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.matkminbonus += AddInt(i.Value, isRate, 0, unequip);
                }
                break;

            case ADDITION_BONUS.MaxRWDamage:
            case ADDITION_BONUS.RangedAtkMax:
                if (type == BonusType.Skill)
                {
                    actor.BattleStatus.ratkmaxbonus += AddInt(i.Value, isRate, 0, unequip);
                }
                break;

            case ADDITION_BONUS.WalkSpeed:
                if (actor.type == ActorType.PC)
                {
                    if (type == BonusType.Skill)
                    {
                        actor.BattleStatus.speedskill += AddInt(i.Value, isRate, 500, unequip);
                    }
                    else
                    {
                        actor.BattleStatus.speedbonus += AddInt(i.Value, isRate, 500, unequip);
                    }
                }
                else
                {
                    Scripting.Mob mob = (Scripting.Mob)actor.e;
                    mob.WalkBonus += AddInt(i.Value, isRate, mob.mWalkSpeed, unequip);
                    mob.RunBonus  += AddInt(i.Value, isRate, mob.mRunSpeed, unequip);
                }
                break;

            case ADDITION_BONUS.ItemHPRecover:
                if (actor.type == ActorType.PC)
                {
                    int value = SagaLib.Global.Random.Next(i.Value, (int)(i.Value * (1.5)));
                    pc.HP = (ushort)(pc.HP + value);
                    if (pc.HP > pc.maxHP)
                    {
                        pc.HP = pc.maxHP;
                    }
                    eh.C.SendCharStatus(0);
                    eh.C.SendSkillEffect(id, SagaMap.Skills.SkillEffects.HP, (uint)value);
                }
                break;

            case ADDITION_BONUS.ItemSPRecover:
                if (actor.type == ActorType.PC)
                {
                    int value = SagaLib.Global.Random.Next(i.Value, (int)(i.Value * (1.5)));
                    pc.HP = (ushort)(pc.SP + value);
                    if (pc.SP > pc.maxHP)
                    {
                        pc.SP = pc.maxSP;
                    }
                    eh.C.SendCharStatus(0);
                    eh.C.SendSkillEffect(id, SagaMap.Skills.SkillEffects.SP, (uint)value);
                }
                break;
            }
        }